agent2agentSourceA2AServerDispatcher

class Dispatcher

Routes incoming A2A operations to their registered handler stacks.

Each operation maps to exactly one Rack app (a compiled middleware stack built by the Agent DSL). The Dispatcher is a terminal Rack app that reads env["a2a.operation"] set by Triage, looks up the matching route, and calls it.

Returns domain objects (A2A::Schema::Definition or A2A::Error) — the binding layer is responsible for formatting these into HTTP.

Definitions

def register(handler)

Register a handler object.

The handler must respond to: #operations -> Array(String) (e.g. ["SendMessage", "GetTask"]) #call(env) -> A2A::Schema::Definition | A2A::Error

Implementation

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