RegisterRemote registers a remote agent by creating a remote agent client. The protocol field determines what kind of remote agent to register (matched case-insensitively): - "axp" (default): AX's proto.AgentService. - "a2a": A2A protocol.
(ctx context.Context, cfg config.RemoteAgentConfig)
| 79 | // - "axp" (default): AX's proto.AgentService. |
| 80 | // - "a2a": A2A protocol. |
| 81 | func (r *Registry) RegisterRemote(ctx context.Context, cfg config.RemoteAgentConfig) error { |
| 82 | r.mu.Lock() |
| 83 | defer r.mu.Unlock() |
| 84 | |
| 85 | if err := validateID(cfg.ID); err != nil { |
| 86 | return err |
| 87 | } |
| 88 | if _, ok := r.agents[cfg.ID]; ok { |
| 89 | return fmt.Errorf("agent %s already registered", cfg.ID) |
| 90 | } |
| 91 | |
| 92 | switch strings.ToLower(cfg.Protocol) { |
| 93 | case "", "axp": |
| 94 | return r.registerRemote(cfg) |
| 95 | case "a2a": |
| 96 | return r.registerA2A(ctx, cfg) |
| 97 | default: |
| 98 | return fmt.Errorf("remote agent %s: invalid protocol %q (want \"axp\" or \"a2a\")", cfg.ID, cfg.Protocol) |
| 99 | } |
| 100 | } |
| 101 | |
| 102 | func (r *Registry) registerRemote(cfg config.RemoteAgentConfig) error { |
| 103 | remoteAgent, err := agent.NewRemoteAgent(agent.RemoteAgentConfig{ |