
'''Layer 10: Multi-Agent Coordinator'''
from typing import List, Dict

class MultiAgentCoordinator:
    def __init__(self):
        self.agents = {}
        self.shared_knowledge = []
    
    def register_agent(self, agent_id: str, specialization: str):
        '''Register an agent with specialization'''
        self.agents[agent_id] = {
            'id': agent_id,
            'specialization': specialization,
            'knowledge': []
        }
    
    def share_knowledge(self, from_agent: str, knowledge: Dict):
        '''Share knowledge across agents'''
        self.shared_knowledge.append({
            'source': from_agent,
            'knowledge': knowledge,
            'timestamp': 'now'
        })
        # Broadcast to other agents
        for agent_id in self.agents:
            if agent_id != from_agent:
                self.agents[agent_id]['knowledge'].append(knowledge)
    
    def coordinate_task(self, task: str) -> Dict:
        '''Assign task to best agent'''
        # Simple: match task to specialization
        for agent_id, agent in self.agents.items():
            if agent['specialization'] in task.lower():
                return {
                    'assigned_to': agent_id,
                    'reason': f'Matches specialization: {agent["specialization"]}'
                }
        return {'assigned_to': 'general', 'reason': 'No specialist available'}

if __name__ == '__main__':
    mac = MultiAgentCoordinator()
    mac.register_agent('eden_db', 'database')
    mac.register_agent('eden_net', 'network')
    result = mac.coordinate_task('database performance issue')
    print(f"Task assigned to: {result['assigned_to']}")
