Module: A2A
- Defined in:
- lib/a2a.rb,
lib/a2a/agent.rb,
lib/a2a/client.rb,
lib/a2a/errors.rb,
lib/a2a/server.rb,
lib/a2a/version.rb,
lib/a2a/protocol.rb,
lib/a2a/server/env.rb,
lib/a2a/test_helpers.rb,
lib/a2a/server/triage.rb,
lib/a2a/errors/rest_error.rb,
lib/a2a/protocol/protobuf.rb,
lib/a2a/server/sse/stream.rb,
lib/a2a/server/well_known.rb,
lib/a2a/protocol/json_schema.rb,
lib/a2a/server/bindings/grpc.rb,
lib/a2a/server/bindings/rest.rb,
lib/a2a/errors/json_rpc_error.rb,
lib/a2a/server/sse/rest_stream.rb,
lib/a2a/server/sse/event_parser.rb,
lib/a2a/server/bindings/json_rpc.rb,
lib/a2a/server/sse/json_rpc_stream.rb,
lib/a2a/server/middleware/fetch_task.rb,
lib/a2a/server/middleware/sse_stream.rb,
lib/a2a/client/middleware/rest/request.rb,
lib/a2a/client/middleware/rest/response.rb,
lib/a2a/protocol/json_schema/definition.rb,
lib/a2a/client/middleware/schema_request.rb,
lib/a2a/server/middleware/extract_message.rb,
lib/a2a/client/middleware/json_rpc/request.rb,
lib/a2a/client/middleware/json_rpc/response.rb,
lib/a2a/protocol/json_schema/validation_error.rb,
lib/a2a/server/middleware/limit_history_length.rb,
lib/a2a/server/middleware/limit_pagination_size.rb
Defined Under Namespace
Modules: Internal, Protocol, TestHelpers Classes: Agent, Client, ContentTypeNotSupportedError, Error, ExtendedAgentCardNotConfiguredError, ExtensionSupportRequiredError, InvalidAgentResponseError, InvalidParamsError, JsonRpcError, PushNotificationNotSupportedError, RestError, Server, TaskNotCancelableError, TaskNotFoundError, UnsupportedOperationError, VersionNotSupportedError
Constant Summary collapse
- VERSION =
"2.0.0"
Class Method Summary collapse
-
.agent(**options, &block) ⇒ Object
Builds a complete A2A server (a rack app) from a handler block — the one-call entrypoint.
Class Method Details
.agent(**options, &block) ⇒ Object
Builds a complete A2A server (a rack app) from a handler block — the one-call entrypoint.
The block receives the rack env and returns a domain object (A2A::Protocol::JsonSchema::Definition) — the binding layer formats it into HTTP. Route operations with pattern matching:
run A2A.agent(agent_card: { "name" => "My Agent" }) do |env|
case env["a2a.operation"]
in "SendMessage"
A2A::Protocol::JsonSchema["Send Message Response"].new({})
in "GetTask"
task = Task.find_by(id: env["a2a.request"].id)
raise A2A::TaskNotFoundError.new(env["a2a.request"].id) unless task
task.to_a2a
end
end
To route on request contents as well, match a tuple — Definition implements deconstruct_keys, so patterns destructure recursively:
case [env["a2a.operation"], env["a2a.request"]]
in ["SendMessage", { message: { task_id: String => id } }] if !id.empty?
# continuation of task `id`
in ["SendMessage", _]
# new task
end
36 |
# File 'lib/a2a/agent.rb', line 36 def self.agent(**, &block) = Server.new(**, &block) |