(
agentId: string,
agents: LocalAgentInfo[],
agentDefinitions: Map<string, { spawnableAgents?: string[] }>,
localAgentIds: Set<string>,
ancestorIds: Set<string>,
)
| 47 | } |
| 48 | |
| 49 | function buildDepTree( |
| 50 | agentId: string, |
| 51 | agents: LocalAgentInfo[], |
| 52 | agentDefinitions: Map<string, { spawnableAgents?: string[] }>, |
| 53 | localAgentIds: Set<string>, |
| 54 | ancestorIds: Set<string>, |
| 55 | ): DepTreeNode[] { |
| 56 | const definition = agentDefinitions.get(agentId) |
| 57 | const spawnableAgents = definition?.spawnableAgents ?? [] |
| 58 | |
| 59 | const newAncestorIds = new Set(ancestorIds) |
| 60 | newAncestorIds.add(agentId) |
| 61 | |
| 62 | const children: DepTreeNode[] = [] |
| 63 | for (const spawnableId of spawnableAgents) { |
| 64 | const simpleId = getSimpleAgentId(spawnableId) |
| 65 | if (localAgentIds.has(simpleId) && !newAncestorIds.has(simpleId)) { |
| 66 | const agent = agents.find((a) => a.id === simpleId) |
| 67 | if (agent) { |
| 68 | children.push({ |
| 69 | id: agent.id, |
| 70 | displayName: agent.displayName, |
| 71 | children: buildDepTree(simpleId, agents, agentDefinitions, localAgentIds, newAncestorIds), |
| 72 | }) |
| 73 | } |
| 74 | } |
| 75 | } |
| 76 | |
| 77 | return children |
| 78 | } |
| 79 | |
| 80 | // Render dependency tree recursively |
| 81 | const DepTree: React.FC<{ |
no test coverage detected