Files
hive/backend/app/models/agent.py
anthonyrawlins b6bff318d9 WIP: Save current work before CHORUS rebrand
- Agent roles integration progress
- Various backend and frontend updates
- Storybook cache cleanup

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-01 02:20:56 +10:00

67 lines
3.2 KiB
Python

from sqlalchemy import Column, Integer, String, DateTime, JSON, Text
from sqlalchemy.sql import func
from sqlalchemy.orm import relationship
from ..core.database import Base
class Agent(Base):
__tablename__ = "agents"
id = Column(String, primary_key=True, index=True)
name = Column(String, nullable=False) # Agent display name
endpoint = Column(String, nullable=False)
model = Column(String, nullable=True)
specialty = Column(String, nullable=True)
specialization = Column(String, nullable=True) # Legacy field for compatibility
max_concurrent = Column(Integer, default=2)
current_tasks = Column(Integer, default=0)
agent_type = Column(String, default="ollama") # "ollama" or "cli"
cli_config = Column(JSON, nullable=True) # CLI-specific configuration
capabilities = Column(JSON, nullable=True) # Agent capabilities
hardware_config = Column(JSON, nullable=True) # Hardware configuration
status = Column(String, default="offline") # Agent status
performance_targets = Column(JSON, nullable=True) # Performance targets
created_at = Column(DateTime(timezone=True), server_default=func.now())
updated_at = Column(DateTime(timezone=True), onupdate=func.now())
last_seen = Column(DateTime(timezone=True), nullable=True)
# Role-based collaboration fields
role = Column(String, nullable=True) # Role from Bees-AgenticWorkers
system_prompt = Column(Text, nullable=True) # Role-specific system prompt
reports_to = Column(JSON, nullable=True) # Array of roles this agent reports to
expertise = Column(JSON, nullable=True) # Array of expertise areas
deliverables = Column(JSON, nullable=True) # Array of deliverables
collaboration_settings = Column(JSON, nullable=True) # Collaboration preferences
# Relationships
tasks = relationship("Task", back_populates="assigned_agent")
context_feedback = relationship("ContextFeedback", back_populates="agent")
permissions = relationship("AgentPermissions", back_populates="agent")
def to_dict(self):
return {
"id": self.id,
"name": self.name,
"endpoint": self.endpoint,
"model": self.model,
"specialty": self.specialty,
"specialization": self.specialization,
"max_concurrent": self.max_concurrent,
"current_tasks": self.current_tasks,
"agent_type": self.agent_type,
"cli_config": self.cli_config,
"capabilities": self.capabilities,
"hardware_config": self.hardware_config,
"status": self.status,
"performance_targets": self.performance_targets,
"created_at": self.created_at.isoformat() if self.created_at else None,
"updated_at": self.updated_at.isoformat() if self.updated_at else None,
"last_seen": self.last_seen.isoformat() if self.last_seen else None,
# Role-based fields
"role": self.role,
"system_prompt": self.system_prompt,
"reports_to": self.reports_to,
"expertise": self.expertise,
"deliverables": self.deliverables,
"collaboration_settings": self.collaboration_settings
}