26#include <asio/awaitable.hpp>
37namespace neograph::graph {
class CancelToken; }
39namespace neograph::a2a {
41#ifdef NEOGRAPH_A2A_TESTING
42namespace test {
class A2AClientTestAccess; }
50 : std::runtime_error(what), code_(code) {}
51 int code()
const noexcept {
return code_; }
161 const std::string& text,
162 const std::string& task_id =
"",
163 const std::string& context_id =
"",
178 asio::awaitable<Task> get_task_async(
const std::string& task_id,
int history_length = 0);
182 asio::awaitable<Task> cancel_task_async(
const std::string& task_id);
198 Task send_message_stream(
const std::string& text,
200 const std::string& task_id =
"",
201 const std::string& context_id =
"");
209 json
rpc_call(
const std::string& method,
const json& params,
210 std::optional<WireDialect> dialect = std::nullopt);
211 asio::awaitable<json> rpc_call_async(
212 const std::string& method,
const json& params,
213 std::optional<WireDialect> dialect = std::nullopt);
215 const std::string& base_url()
const {
return base_url_; }
222#ifdef NEOGRAPH_A2A_TESTING
223 friend class test::A2AClientTestAccess;
225 std::string base_url_;
226 std::chrono::seconds timeout_ = std::chrono::seconds(0);
227 std::chrono::seconds connect_timeout_ = std::chrono::seconds(30);
228 std::atomic<int> request_id_{0};
230 mutable std::shared_ptr<std::mutex> state_mutex_ = std::make_shared<std::mutex>();
231 bool card_loading_ =
false;
235 bool card_loaded_ =
false;
237 bool card_unavailable_ =
false;
238 bool allow_cross_origin_ =
false;
239 std::string authorization_header_;
247 std::optional<Selection> selection_;
252 std::optional<Selection> resolve_selection();
254 asio::awaitable<std::optional<Selection>> select_async();
255 void remember_probe(WireDialect dialect);
257 asio::awaitable<json> post_rpc(
const std::string& url,
const std::string& method,
258 const json& params, std::optional<WireDialect> dialect);
263 asio::awaitable<json> call_method(
264 const char* v1_method,
const char* v03_method,
265 const std::function<json(WireDialect,
const std::string& tenant)>& build);
267 Task stream_once(WireDialect dialect,
const std::string& tenant,
const std::string& url,
268 const MessageSendParams& params,
const EventCallback& on_event,
271 std::string request_authorization_header()
const;
273 std::chrono::seconds request_timeout()
const;
274 std::chrono::seconds request_connect_timeout()
const;
Core data types for the Agent-to-Agent (A2A) protocol.
WireDialect
A2A wire dialect — the JSON encoding of the data model.
NEOGRAPH_API export/import macro for shared-library builds.
A2A client — call a remote agent over JSON-RPC + HTTP.
AgentCard fetch_agent_card(bool force=false)
GET /.well-known/agent-card.json.
void set_allow_cross_origin_interfaces(bool allow)
Allow the AgentCard to direct RPCs to an interface URL on another origin than base_url (default false...
asio::awaitable< AgentCard > fetch_agent_card_async(bool force=false)
Async variant of fetch_agent_card.
Task get_task(const std::string &task_id, int history_length=0)
tasks/get — fetch the latest snapshot of a task.
json rpc_call(const std::string &method, const json ¶ms, std::optional< WireDialect > dialect=std::nullopt)
Lower-level: arbitrary JSON-RPC method, sent verbatim.
Task send_message_sync(const std::string &text, const std::string &task_id="", const std::string &context_id="", graph::CancelToken *cancel=nullptr)
message/send — convenience wrapper around send_message_sync().
Task cancel_task(const std::string &task_id)
tasks/cancel — request cancellation. Returns updated Task.
void set_timeout(std::chrono::seconds t)
Bound the whole exchange of each request (connect, write, and reading the reply or the event stream t...
void set_authorization_header(std::string authorization_header)
Set the explicit Authorization header for subsequent RPC requests.
std::optional< WireDialect > wire_dialect() const
Wire dialect in use: selected from the fetched AgentCard or learned by probing.
std::function< bool(const StreamEvent &)> EventCallback
SendStreamingMessage / message/stream — send a message and receive SSE-framed status updates as the a...
Task send_message_sync(const MessageSendParams ¶ms, graph::CancelToken *cancel=nullptr)
Send an arbitrary Message (multipart, file, structured data).
void set_connect_timeout(std::chrono::seconds t)
Bound the time to resolve the host, connect and finish the TLS handshake of each request to t (defaul...
std::string endpoint_url() const
The JSON-RPC endpoint in use: the selected interface URL, or base_url before a selection or when the ...
asio::awaitable< Task > send_message_async(const MessageSendParams ¶ms)
Async variant — server's response payload may be either a Message or a Task; we coerce both into a Ta...
A2AClient(std::string base_url)
JSON-RPC error object returned by the remote agent.
Cooperative cancel primitive shared between caller and engine.
Subset of AgentCard required to interact (spec §5.5).
Params object for message/send and message/stream.
Tagged union over the two streaming event types + the terminal Task message.
A unit of work tracked by the agent (spec §6.1).