MCPcopy
hub / github.com/codeaashu/claude-code / getAgentStatuses

Function getAgentStatuses

src/utils/tasks.ts:763–798  ·  view source on GitHub ↗
(
  teamName: string,
)

Source from the content-addressed store, hash-verified

761 * @returns Array of agent statuses, or null if team not found
762 */
763export async function getAgentStatuses(
764 teamName: string,
765): Promise<AgentStatus[] | null> {
766 const teamData = await readTeamMembers(teamName)
767 if (!teamData) {
768 return null
769 }
770
771 const taskListId = sanitizeName(teamName)
772 const allTasks = await listTasks(taskListId)
773
774 // Get unresolved tasks grouped by owner (open or in_progress)
775 const unresolvedTasksByOwner = new Map<string, string[]>()
776 for (const task of allTasks) {
777 if (task.status !== 'completed' && task.owner) {
778 const existing = unresolvedTasksByOwner.get(task.owner) || []
779 existing.push(task.id)
780 unresolvedTasksByOwner.set(task.owner, existing)
781 }
782 }
783
784 // Build status for each agent (leader is already in members)
785 return teamData.members.map(member => {
786 // Check both name (new) and agentId (legacy) for backwards compatibility
787 const tasksByName = unresolvedTasksByOwner.get(member.name) || []
788 const tasksById = unresolvedTasksByOwner.get(member.agentId) || []
789 const currentTasks = uniq([...tasksByName, ...tasksById])
790 return {
791 agentId: member.agentId,
792 name: member.name,
793 agentType: member.agentType,
794 status: currentTasks.length === 0 ? 'idle' : 'busy',
795 currentTasks,
796 }
797 })
798}
799
800/**
801 * Result of unassigning tasks from a teammate

Callers

nothing calls this directly

Calls 7

readTeamMembersFunction · 0.85
listTasksFunction · 0.85
uniqFunction · 0.85
sanitizeNameFunction · 0.70
getMethod · 0.65
pushMethod · 0.45
setMethod · 0.45

Tested by

no test coverage detected