euxis-a2a-cpp¶
C++23 A2A v0.2 protocol implementation — agent cards, task management, JSON-RPC server, HTTP transport.
README¶
euxis::a2a
The A2A v0.2 JSON-RPC surface for euxis: agent-card publication, task lifecycle handlers, and HTTP + WebSocket transports. C++23, header-first.
Contents¶
Quick start — serve an agent card + create a task
Install¶
add_subdirectory(libs/a2a)
target_link_libraries(my_app PRIVATE euxis-a2a-cpp)
Quick start¶
#include <iostream>
#include <nlohmann/json.hpp>
#include "euxis/a2a/agent_card.hpp"
#include "euxis/a2a/server.hpp"
int main() {
using namespace euxis::a2a;
// 1. Publish an agent card.
AgentCard card;
card.name = "scan-agent";
card.description = "Scans repos for SAST findings";
card.url = "https://example.com/a2a";
card.version = "1.0.0";
card.capabilities.push_back(Capability{
.name = "scan",
.description = "Run a full scan",
.input_schema = std::nullopt,
.output_schema = std::nullopt,
});
// 2. Mount the JSON-RPC handler.
A2AServerHandler handler{std::move(card)};
// 3. Dispatch a `tasks.create` request — usually via the HTTP or
// WebSocket transport. Here we drive the handler directly.
const nlohmann::json params{
{"capability", "scan"},
{"input", nlohmann::json::object()},
};
const auto response = handler.handle_request("tasks.create", params);
std::cout << response.dump(2) << '\n';
}
Overview¶
This module implements the A2A v0.2 protocol surface: agent-card metadata, task lifecycle (create / get / cancel), and two transports (HTTP via cpp-httplib and WebSocket via IXWebSocket). The agent card is serialisable to JSON and MessagePack.
In scope:
AgentCard+ msgpack round-tripA2ATasklifecycle statesJSON-RPC dispatch via
A2AServerHandler::handle_request(method, params)HTTP + WebSocket transports
Deliberately out of scope:
Identity verification (lives in
libs/identity, including theerc8004.hppsurface)Bidding / delegation envelopes (
BidRequest+BidResponselive inlibs/a2a-types, consumed bylibs/core::DelegationCoordinator)
Public surface¶
Header |
What it owns |
|---|---|
|
|
|
|
|
|
|
HTTP transport binding ( |
|
|
Examples¶
Round-trip an agent card through msgpack¶
#include "euxis/a2a/agent_card.hpp"
#include <cassert>
using namespace euxis::a2a;
AgentCard card;
card.name = "scan-agent";
card.url = "https://example.com/a2a";
card.version = "1.0.0";
const auto bytes = card.to_msgpack();
const auto parsed = AgentCard::from_msgpack(bytes);
assert(parsed.has_value());
assert(parsed->name == "scan-agent");
Drive a full task lifecycle¶
auto rsp = handler.handle_request("tasks.create",
{{"capability", "scan"}, {"input", {{"path", "src/"}}}});
const auto task_id = rsp["id"].get<std::string>();
// Poll until the task reports a terminal state.
nlohmann::json status;
do {
status = handler.handle_request("tasks.get", {{"id", task_id}});
} while (status["state"] != "completed" && status["state"] != "failed");
Wire format¶
A2AServerHandler::handle_request accepts the four canonical A2A methods:
Method |
Returns |
|---|---|
|
The published |
|
Array of |
|
A fresh |
|
Current state of a known task by id |
|
Acknowledges cancellation |
Testing¶
cmake --build build/cmake-build --target euxis-a2a-cpp_tests
./build/cmake-build/libs/a2a/euxis-a2a-cpp_tests
License¶
AGPL-3.0-only. See LICENSE.