/** * Agent Spawner * Spawn and manage swarm agents */ class AgentSpawner { constructor(swarm) { this.swarm = swarm; this.activeAgents = new Map(); } initializeSwarm(agentTypes) { console.log('\nšŸš€ Initializing swarm agents...'); console.log(` Agent types: ${agentTypes.join(', ')}`); for (const agentType of agentTypes) { this.spawnAgent(agentType); } console.log(`\nāœ… Swarm initialized with ${agentTypes.length} agent types`); } spawnAgent(agentType) { console.log(`\nšŸ“¦ Spawning agent: ${agentType}`); const agent = { id: `${agentType}-${Date.now()}`, type: agentType, status: 'idle', createdAt: Date.now() }; this.activeAgents.set(agent.id, agent); this.swarm.log('success', `Agent ${agentType} spawned (ID: ${agent.id})`); return agent; } getAgent(agentId) { return this.activeAgents.get(agentId); } getAgentsByType(agentType) { return Array.from(this.activeAgents.values()).filter(a => a.type === agentType); } getActiveAgents() { return Array.from(this.activeAgents.values()); } updateAgentStatus(agentId, status) { const agent = this.activeAgents.get(agentId); if (agent) { agent.status = status; this.swarm.log('info', `Agent ${agentId} status → ${status}`); } } shutdown() { console.log('\nšŸ›‘ Shutting down swarm agents...'); this.activeAgents.clear(); console.log('āœ… All agents stopped'); } } module.exports = AgentSpawner;