Class: A2A::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/a2a/client.rb

Overview

Faraday-based A2A protocol client.

Supports both protocol bindings: JSON-RPC 2.0 and HTTP+JSON/REST. Uses the async-http-faraday adapter for fiber-based non-blocking I/O and supports SSE streaming for long-lived connections.

Request params are validated against the operation’s request schema before sending. Responses are returned as Schema::Definition objects.

# JSON-RPC (default)
client = A2A::Client.new("http://localhost:9292")

# REST
client = A2A::Client.new("http://localhost:9292", binding: :rest)

Instance Method Summary collapse

Constructor Details

#initialize(url, binding: :json_rpc, &block) ⇒ Client

Returns a new instance of Client.



26
27
28
29
30
# File 'lib/a2a/client.rb', line 26

def initialize(url, binding: :json_rpc, &block)
  @url     = url.chomp("/")
  @binding = binding
  @conn    = build_connection(&block)
end

Instance Method Details

#agent_cardObject

GET /.well-known/agent-card.json

Returns an A2A::Schema[“Agent Card”] instance.



35
36
37
38
39
# File 'lib/a2a/client.rb', line 35

def agent_card
  response = @conn.get("/.well-known/agent-card.json")
  parsed = response.body
  A2A::Schema["Agent Card"].new(parsed)
end