Add agent role management system for Bees-AgenticWorkers integration

Backend:
- Database migration for agent role fields and predefined roles
- AgentRole and AgentCollaboration models
- Updated Agent model with role-based fields

Frontend:
- AgentRoleSelector component for role assignment
- CollaborationDashboard for monitoring agent interactions
- AgentManagement interface with role analytics

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
anthonyrawlins
2025-07-27 15:24:53 +10:00
parent ef3b61740b
commit 9262e63374
7 changed files with 1137 additions and 2 deletions

View File

@@ -0,0 +1,69 @@
from sqlalchemy import Column, String, DateTime, JSON, Text
from sqlalchemy.sql import func
from sqlalchemy.orm import relationship
from ..core.database import Base
class AgentRole(Base):
__tablename__ = "agent_roles"
id = Column(String, primary_key=True, index=True)
name = Column(String, unique=True, nullable=False, index=True) # Role identifier (e.g., "senior_software_architect")
display_name = Column(String, nullable=False) # Human-readable name
system_prompt = Column(Text, nullable=False) # Role-specific system prompt
reports_to = Column(JSON, nullable=True) # Array of roles this role reports to
expertise = Column(JSON, nullable=True, index=True) # Array of expertise areas
deliverables = Column(JSON, nullable=True) # Array of deliverables
capabilities = Column(JSON, nullable=True) # Array of capabilities
collaboration_defaults = Column(JSON, nullable=True) # Default collaboration settings
created_at = Column(DateTime(timezone=True), server_default=func.now())
updated_at = Column(DateTime(timezone=True), onupdate=func.now())
def to_dict(self):
return {
"id": self.id,
"name": self.name,
"display_name": self.display_name,
"system_prompt": self.system_prompt,
"reports_to": self.reports_to,
"expertise": self.expertise,
"deliverables": self.deliverables,
"capabilities": self.capabilities,
"collaboration_defaults": self.collaboration_defaults,
"created_at": self.created_at.isoformat() if self.created_at else None,
"updated_at": self.updated_at.isoformat() if self.updated_at else None
}
class AgentCollaboration(Base):
__tablename__ = "agent_collaborations"
id = Column(String, primary_key=True, index=True)
from_agent_id = Column(String, nullable=False, index=True) # References agents(id)
to_agent_id = Column(String, nullable=True, index=True) # References agents(id), can be null for broadcasts
message_type = Column(String, nullable=False) # Type of collaboration message
thread_id = Column(String, nullable=True, index=True) # Conversation thread ID
project_id = Column(String, nullable=True, index=True) # Associated project
message_data = Column(JSON, nullable=True) # Original message data
response_data = Column(JSON, nullable=True) # Response data
status = Column(String, default="pending", index=True) # pending, responded, escalated, resolved
priority = Column(String, default="medium", index=True) # low, medium, high, urgent
created_at = Column(DateTime(timezone=True), server_default=func.now())
responded_at = Column(DateTime(timezone=True), nullable=True)
resolved_at = Column(DateTime(timezone=True), nullable=True)
def to_dict(self):
return {
"id": self.id,
"from_agent_id": self.from_agent_id,
"to_agent_id": self.to_agent_id,
"message_type": self.message_type,
"thread_id": self.thread_id,
"project_id": self.project_id,
"message_data": self.message_data,
"response_data": self.response_data,
"status": self.status,
"priority": self.priority,
"created_at": self.created_at.isoformat() if self.created_at else None,
"responded_at": self.responded_at.isoformat() if self.responded_at else None,
"resolved_at": self.resolved_at.isoformat() if self.resolved_at else None
}