/ go / internal / agents / registry.go
registry.go
  1  package agents
  2  
  3  import (
  4  	"fmt"
  5  	"sync"
  6  
  7  	"github.com/TransformerOS/kamaji-go/internal/tools"
  8  	"github.com/TransformerOS/kamaji-go/internal/types"
  9  )
 10  
 11  // AgentRegistry manages all available agents
 12  type AgentRegistry struct {
 13  	agents map[string]*SpecializedAgent
 14  	mutex  sync.RWMutex
 15  }
 16  
 17  // NewAgentRegistry creates a new agent registry
 18  func NewAgentRegistry() *AgentRegistry {
 19  	return &AgentRegistry{
 20  		agents: make(map[string]*SpecializedAgent),
 21  	}
 22  }
 23  
 24  // RegisterAllAgents registers all specialized agents
 25  func (r *AgentRegistry) RegisterAllAgents(llm types.LLMProvider, toolRegistry *tools.Registry) error {
 26  	// Get all tools
 27  	allTools := toolRegistry.List()
 28  	
 29  	// Register all specialized agents
 30  	agents := []*SpecializedAgent{
 31  		NewCodeArchitectAgent(llm, allTools),
 32  		NewSecuritySpecialistAgent(llm, allTools),
 33  		NewDevOpsEngineerAgent(llm, allTools),
 34  		NewDataScientistAgent(llm, allTools),
 35  		NewProductManagerAgent(llm, allTools),
 36  		NewCreativeDesignerAgent(llm, allTools),
 37  		NewResearchScientistAgent(llm, allTools),
 38  		NewWriterAgent(llm, allTools),
 39  		NewLearningAgent(llm, allTools),
 40  		NewVisionaryAgent(llm, allTools),
 41  		NewKamajiAgent(llm, allTools),
 42  		NewHayaoAgent(llm, allTools),
 43  		NewChihiroAgent(llm, allTools),
 44  		NewTimBLAgent(llm, allTools),
 45  		NewMoeAgent(llm, allTools),
 46  	}
 47  	
 48  	for _, agent := range agents {
 49  		if err := r.Register(agent); err != nil {
 50  			return err
 51  		}
 52  	}
 53  	
 54  	return nil
 55  }
 56  
 57  // Register registers a single agent
 58  func (r *AgentRegistry) Register(agent *SpecializedAgent) error {
 59  	r.mutex.Lock()
 60  	defer r.mutex.Unlock()
 61  	
 62  	if agent.ID == "" {
 63  		return fmt.Errorf("agent ID cannot be empty")
 64  	}
 65  	
 66  	r.agents[agent.ID] = agent
 67  	return nil
 68  }
 69  
 70  // Get retrieves an agent by ID
 71  func (r *AgentRegistry) Get(id string) (*SpecializedAgent, error) {
 72  	r.mutex.RLock()
 73  	defer r.mutex.RUnlock()
 74  	
 75  	agent, exists := r.agents[id]
 76  	if !exists {
 77  		return nil, fmt.Errorf("agent not found: %s", id)
 78  	}
 79  	
 80  	return agent, nil
 81  }
 82  
 83  // List returns all registered agents
 84  func (r *AgentRegistry) List() []*SpecializedAgent {
 85  	r.mutex.RLock()
 86  	defer r.mutex.RUnlock()
 87  	
 88  	agents := make([]*SpecializedAgent, 0, len(r.agents))
 89  	for _, agent := range r.agents {
 90  		agents = append(agents, agent)
 91  	}
 92  	
 93  	return agents
 94  }
 95  
 96  // ListByLevel returns agents filtered by intelligence level
 97  func (r *AgentRegistry) ListByLevel(level IntelligenceLevel) []*SpecializedAgent {
 98  	r.mutex.RLock()
 99  	defer r.mutex.RUnlock()
100  	
101  	agents := make([]*SpecializedAgent, 0)
102  	for _, agent := range r.agents {
103  		if agent.Level == level {
104  			agents = append(agents, agent)
105  		}
106  	}
107  	
108  	return agents
109  }
110  
111  // ListByType returns agents filtered by type
112  func (r *AgentRegistry) ListByType(agentType string) []*SpecializedAgent {
113  	r.mutex.RLock()
114  	defer r.mutex.RUnlock()
115  	
116  	agents := make([]*SpecializedAgent, 0)
117  	for _, agent := range r.agents {
118  		if agent.Type == agentType {
119  			agents = append(agents, agent)
120  		}
121  	}
122  	
123  	return agents
124  }
125  
126  // GetAgentInfo returns formatted information about an agent
127  func GetAgentInfo(agent *SpecializedAgent) string {
128  	levelStr := getLevelString(agent.Level)
129  	
130  	info := fmt.Sprintf(`
131  Agent: %s (%s)
132  ID: %s
133  Level: %s
134  Personality: %s
135  Traits: %v
136  Specialties: %v
137  
138  Capabilities:
139  `, agent.Name, agent.Type, agent.ID, levelStr, 
140  		agent.Personality.Name, agent.Personality.Traits, agent.Personality.Specialties)
141  	
142  	for _, cap := range agent.Capabilities {
143  		info += fmt.Sprintf("  • %s: %s\n", cap.Name, cap.Description)
144  	}
145  	
146  	return info
147  }
148  
149  // getLevelString converts intelligence level to string
150  func getLevelString(level IntelligenceLevel) string {
151  	switch level {
152  	case Basic:
153  		return "Basic"
154  	case Intermediate:
155  		return "Intermediate"
156  	case Advanced:
157  		return "Advanced"
158  	case Expert:
159  		return "Expert"
160  	case Master:
161  		return "Master"
162  	case Autonomous:
163  		return "Autonomous"
164  	default:
165  		return "Unknown"
166  	}
167  }
168  
169  // GetLevelColor returns color code for intelligence level
170  func GetLevelColor(level IntelligenceLevel) string {
171  	switch level {
172  	case Basic:
173  		return "#808080" // Gray
174  	case Intermediate:
175  		return "#4A90E2" // Blue
176  	case Advanced:
177  		return "#7B68EE" // Purple
178  	case Expert:
179  		return "#FF6B6B" // Red
180  	case Master:
181  		return "#E6E6FA" // Lavender - serene wisdom
182  	case Autonomous:
183  		return "#FFD700" // Gold
184  	default:
185  		return "#FFFFFF" // White
186  	}
187  }
188  
189  // GetTypeIcon returns emoji icon for agent type
190  func GetTypeIcon(agentType string) string {
191  	icons := map[string]string{
192  		"natural-consciousness": "💡",
193  		"architect":         "🏗️",
194  		"security":          "🛡️",
195  		"devops":            "⚙️",
196  		"datascience":       "📊",
197  		"product":           "📱",
198  		"designer":          "🎨",
199  		"researcher":        "🔬",
200  		"writer":            "✍️",
201  		"learning":          "📚",
202  		"visionary":         "🔮",
203  		"boiler-man":        "🔥",
204  		"master-storyteller": "🎬",
205  		"adaptive-learner":   "🌱",
206  		"web-architect":      "🌐",
207  	}
208  	
209  	if icon, exists := icons[agentType]; exists {
210  		return icon
211  	}
212  	return "🤖"
213  }