RegisterLocal registers a local (in-process) agent.
(cfg config.LocalAgentConfig)
| 51 | |
| 52 | // RegisterLocal registers a local (in-process) agent. |
| 53 | func (r *Registry) RegisterLocal(cfg config.LocalAgentConfig) error { |
| 54 | r.mu.Lock() |
| 55 | defer r.mu.Unlock() |
| 56 | |
| 57 | if err := validateID(cfg.ID); err != nil { |
| 58 | return err |
| 59 | } |
| 60 | |
| 61 | if _, ok := r.agents[cfg.ID]; ok { |
| 62 | return fmt.Errorf("agent %s already registered", cfg.ID) |
| 63 | } |
| 64 | |
| 65 | r.agents[cfg.ID] = cfg.Agent |
| 66 | r.agentInfo[cfg.ID] = &agent.AgentInfo{ |
| 67 | ID: cfg.ID, |
| 68 | Name: cfg.Name, |
| 69 | Description: cfg.Description, |
| 70 | Metadata: cfg.Metadata, |
| 71 | } |
| 72 | |
| 73 | return nil |
| 74 | } |
| 75 | |
| 76 | // RegisterRemote registers a remote agent by creating a remote agent client. |
| 77 | // The protocol field determines what kind of remote agent to register |