agent2agentSourceA2AServerDispatcher

class Dispatcher

Routes incoming A2A operations to registered handler objects.

Each handler declares the operations it handles via #operations. When an operation arrives, the dispatcher finds all matching handlers and calls them. Errors in one handler do not prevent others from running.

The Dispatcher is a Rack app (terminal, not middleware). It reads env["a2a.operation"] set by Triage and fans out to matching handlers.

Definitions

def register(handler)

Register a handler object.

The handler must respond to: #operations -> Array(String) (e.g. ["SendMessage", "GetTask"]) #call(env) -> void (sets env["a2a.result"])

Implementation

def register(handler)
  handler.operations.each do |op|
    @handlers[op] << handler
    Console.info(self) { "Registered #{handler.class.name} for #{op}" }
  end
end