Add comprehensive agent role integration from Bees-AgenticWorkers

- Add role-based configuration to AgentConfig with 15 predefined roles
- Enhanced message types for role-based collaboration
- Role-based topic subscription system
- Agent initialization with automatic role assignment
- Role announcements and collaboration settings
- Support for expertise areas, reporting hierarchy, and deliverables

🤖 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:43 +10:00
parent e94df4be6b
commit 81b473d48f
4 changed files with 542 additions and 1 deletions

81
main.go
View File

@@ -91,6 +91,20 @@ func main() {
}
}
// Apply role-based configuration if no role is set
if cfg.Agent.Role == "" {
// Determine default role based on specialization
defaultRole := getDefaultRoleForSpecialization(cfg.Agent.Specialization)
if defaultRole != "" {
fmt.Printf("🎭 Applying default role: %s\n", defaultRole)
if err := cfg.ApplyRoleDefinition(defaultRole); err != nil {
fmt.Printf("⚠️ Failed to apply role definition: %v\n", err)
} else {
fmt.Printf("✅ Role applied: %s\n", cfg.Agent.Role)
}
}
}
fmt.Printf("🐝 Bzzz node started successfully\n")
fmt.Printf("📍 Node ID: %s\n", node.ID().ShortString())
fmt.Printf("🤖 Agent ID: %s\n", cfg.Agent.ID)
@@ -120,6 +134,15 @@ func main() {
}
defer ps.Close()
// Join role-based topics if role is configured
if cfg.Agent.Role != "" {
if err := ps.JoinRoleBasedTopics(cfg.Agent.Role, cfg.Agent.Expertise, cfg.Agent.ReportsTo); err != nil {
fmt.Printf("⚠️ Failed to join role-based topics: %v\n", err)
} else {
fmt.Printf("🎯 Joined role-based collaboration topics\n")
}
}
// === Hive & Dynamic Repository Integration ===
// Initialize Hive API client
hiveClient := hive.NewHiveClient(cfg.HiveAPI.BaseURL, cfg.HiveAPI.APIKey)
@@ -173,9 +196,10 @@ func main() {
activeTasks: make(map[string]bool),
}
// Announce capabilities
// Announce capabilities and role
go announceAvailability(ps, node.ID().ShortString(), taskTracker)
go announceCapabilitiesOnChange(ps, node.ID().ShortString(), cfg)
go announceRoleOnStartup(ps, node.ID().ShortString(), cfg)
// Start status reporting
go statusReporter(node)
@@ -467,4 +491,59 @@ func getChangeReason(current, stored map[string]interface{}) string {
}
return "unknown_change"
}
// getDefaultRoleForSpecialization maps specializations to default roles
func getDefaultRoleForSpecialization(specialization string) string {
roleMap := map[string]string{
"code_generation": "backend_developer",
"advanced_reasoning": "senior_software_architect",
"code_analysis": "security_expert",
"general_developer": "full_stack_engineer",
"debugging": "qa_engineer",
"frontend": "frontend_developer",
"backend": "backend_developer",
"devops": "devops_engineer",
"security": "security_expert",
"design": "ui_ux_designer",
"architecture": "senior_software_architect",
}
if role, exists := roleMap[specialization]; exists {
return role
}
// Default fallback
return "full_stack_engineer"
}
// announceRoleOnStartup announces the agent's role when starting up
func announceRoleOnStartup(ps *pubsub.PubSub, nodeID string, cfg *config.Config) {
if cfg.Agent.Role == "" {
return // No role to announce
}
roleData := map[string]interface{}{
"node_id": nodeID,
"role": cfg.Agent.Role,
"expertise": cfg.Agent.Expertise,
"reports_to": cfg.Agent.ReportsTo,
"deliverables": cfg.Agent.Deliverables,
"capabilities": cfg.Agent.Capabilities,
"specialization": cfg.Agent.Specialization,
"timestamp": time.Now().Unix(),
"status": "online",
}
opts := pubsub.MessageOptions{
FromRole: cfg.Agent.Role,
RequiredExpertise: cfg.Agent.Expertise,
Priority: "medium",
}
if err := ps.PublishRoleBasedMessage(pubsub.RoleAnnouncement, roleData, opts); err != nil {
fmt.Printf("❌ Failed to announce role: %v\n", err)
} else {
fmt.Printf("📢 Role announced: %s\n", cfg.Agent.Role)
}
}