feat(#233): Connect agent dashboard to real orchestrator API
- Add GET /agents endpoint to orchestrator controller - Update AgentStatusWidget to fetch from real API instead of mock data - Add comprehensive tests for listAgents endpoint - Auto-refresh agent list every 30 seconds - Display agent status with proper icons and formatting - Show error states when API is unavailable Fixes #233 Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -70,6 +70,47 @@ export class AgentsController {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* List all agents
|
||||
* @returns Array of all agent sessions with their status
|
||||
*/
|
||||
@Get()
|
||||
listAgents(): {
|
||||
agentId: string;
|
||||
taskId: string;
|
||||
status: string;
|
||||
agentType: string;
|
||||
spawnedAt: string;
|
||||
completedAt?: string;
|
||||
error?: string;
|
||||
}[] {
|
||||
this.logger.log("Received request to list all agents");
|
||||
|
||||
try {
|
||||
// Get all sessions from spawner service
|
||||
const sessions = this.spawnerService.listAgentSessions();
|
||||
|
||||
// Map to response format
|
||||
const agents = sessions.map((session) => ({
|
||||
agentId: session.agentId,
|
||||
taskId: session.taskId,
|
||||
status: session.state,
|
||||
agentType: session.agentType,
|
||||
spawnedAt: session.spawnedAt.toISOString(),
|
||||
completedAt: session.completedAt?.toISOString(),
|
||||
error: session.error,
|
||||
}));
|
||||
|
||||
this.logger.log(`Found ${agents.length.toString()} agents`);
|
||||
|
||||
return agents;
|
||||
} catch (error: unknown) {
|
||||
const errorMessage = error instanceof Error ? error.message : String(error);
|
||||
this.logger.error(`Failed to list agents: ${errorMessage}`);
|
||||
throw new Error(`Failed to list agents: ${errorMessage}`);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get agent status
|
||||
* @param agentId Agent ID to query
|
||||
|
||||
Reference in New Issue
Block a user