|
NeoGraph 0.10.0
A C++17 Graph Agent Engine Library — LangGraph for C++
|
A2A client — call a remote agent over JSON-RPC + HTTP. More...
#include <client.h>
Public Types | |
| using | EventCallback = std::function< bool(const StreamEvent &)> |
message/stream — send a message and receive SSE-framed status updates as the agent progresses, plus the final Task. | |
| using | StreamCallback = EventCallback |
Public Member Functions | |
| A2AClient (std::string base_url) | |
| Task | cancel_task (const std::string &task_id) |
tasks/cancel — request cancellation. Returns updated Task. | |
| AgentCard | fetch_agent_card (bool force=false) |
| GET /.well-known/agent-card.json. | |
| 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) |
| Lower-level: arbitrary JSON-RPC method. | |
| asio::awaitable< json > | rpc_call_with_fallback (const std::string &v1_method, const std::string &v03_method, const json ¶ms) |
| Two A2A protocol generations are deployed in the wild: v1 (PascalCase, e.g. | |
| 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 Task with the message in history so callers have one shape to handle. | |
| Task | send_message_sync (const MessageSendParams ¶ms) |
| Send an arbitrary Message (multipart, file, structured data). | |
| Task | send_message_sync (const std::string &text, const std::string &task_id="", const std::string &context_id="") |
message/send — convenience wrapper around send_message_sync(). | |
| void | set_timeout (std::chrono::seconds t) |
| Override the default 30 s request timeout. | |
A2A client — call a remote agent over JSON-RPC + HTTP.
Thread-safe: every public method acquires its own ephemeral HTTP connection; no shared in-flight state. Reuses neograph::async::async_post for transport.
| using neograph::a2a::A2AClient::EventCallback = std::function<bool(const StreamEvent&)> |
message/stream — send a message and receive SSE-framed status updates as the agent progresses, plus the final Task.
on_event is invoked synchronously on the network thread for each parsed StreamEvent. Return true to keep reading or false to abort early. The final Task (or a status-update with final=true) ends the stream regardless.
EventCallback to avoid colliding with neograph::StreamCallback (provider.h: void(string)). The shapes are different (return type + argument), so a TU pulling in both <neograph/provider.h> and <neograph/a2a/client.h> would shadow one with the other. Old name kept as an alias for back-compat — prefer EventCallback in new code.
|
explicit |
| base_url | Agent endpoint URL (e.g. "https://agent.example.com"). The well-known card path is appended on discovery. |
| AgentCard neograph::a2a::A2AClient::fetch_agent_card | ( | bool | force = false | ) |
GET /.well-known/agent-card.json.
Exposes the agent's identity, transports, and skills. Caches the result in-instance — repeat calls are no-ops unless force is set.
| asio::awaitable< json > neograph::a2a::A2AClient::rpc_call_with_fallback | ( | const std::string & | v1_method, |
| const std::string & | v03_method, | ||
| const json & | params | ||
| ) |
Two A2A protocol generations are deployed in the wild: v1 (PascalCase, e.g.
"SendMessage") used by a2a-sdk Python ≥1.0.0, and v0.3 (slash-form, e.g. "message/send") used by a2a-js HEAD and pre-v1 deployments. Try v1_method first; on a -32601 "method not found" reply, retry with v03_method on the same params. Other JSON-RPC errors propagate.
| Task neograph::a2a::A2AClient::send_message_sync | ( | const std::string & | text, |
| const std::string & | task_id = "", |
||
| const std::string & | context_id = "" |
||
| ) |
message/send — convenience wrapper around send_message_sync().
| text | Plain text content for a single TextPart. |
| task_id | Optional existing task to continue. |
| context_id | Optional grouping id. |