|
NeoGraph 0.16.0
A C++20 Graph Agent Engine Library — LangGraph for C++
|
HTTP server exposing a NeoGraph as an A2A agent. More...
#include <server.h>
Public Member Functions | |
| A2AServer (neograph::graph::GraphExecution execution, AgentCard card, std::shared_ptr< GraphAgentAdapter > adapter={}) | |
| Preferred constructor: retain only execution-facing capabilities. | |
| A2AServer (std::shared_ptr< neograph::graph::GraphEngine > engine, AgentCard card, std::shared_ptr< GraphAgentAdapter > adapter={}) | |
| bool | is_running () const |
| True once start_async() has the server listening. | |
| int | port () const |
| Bound port — useful when caller passed 0 to bind a free port. | |
| void | set_http_config (A2AHttpConfig config) |
| Set the Host and Origin checks and the request size limit (see A2AHttpConfig). | |
| void | set_trust_forwarded_headers (bool enabled) |
When the card has no configured url, the served card advertises the address the client used, with the http scheme. | |
| bool | start (const std::string &host, int port) |
| Bind + listen. | |
| bool | start_async (const std::string &host, int port) |
| Bind + spawn a worker thread; returns when the server is ready to accept connections. | |
| void | stop () |
| Signal the server to stop accepting connections and join. | |
HTTP server exposing a NeoGraph as an A2A agent.
When NEOGRAPH_BUILD_PROGRAM is enabled, the ProgramAgentAdapter overload projects an admitted ProgramVersion through ProgramRuntime while retaining the same JSON-RPC methods and legacy GraphEngine constructor.
| neograph::a2a::A2AServer::A2AServer | ( | std::shared_ptr< neograph::graph::GraphEngine > | engine, |
| AgentCard | card, | ||
| std::shared_ptr< GraphAgentAdapter > | adapter = {} |
||
| ) |
| engine | The graph engine that handles incoming messages. |
| card | Discovery payload returned at /.well-known/agent-card.json. |
| adapter | Optional input/output mapping override. |
| void neograph::a2a::A2AServer::set_http_config | ( | A2AHttpConfig | config | ) |
Set the Host and Origin checks and the request size limit (see A2AHttpConfig).
Without a call, a loopback bind answers only the loopback Host names and its own loopback origin, a remote bind checks no Host and admits a request that carries an Origin only when it is listed, and bodies are limited to the default of A2AHttpConfig::max_payload_bytes.
| std::invalid_argument | for an allowed_hosts entry that is not a host name without a port, an IPv6 address in brackets or *, or for a zero max_payload_bytes. |
| std::logic_error | while the server is listening: call it before start() or start_async(). |
| void neograph::a2a::A2AServer::set_trust_forwarded_headers | ( | bool | enabled | ) |
When the card has no configured url, the served card advertises the address the client used, with the http scheme.
Behind a TLS-terminating reverse proxy, either configure AgentCard::url (the public URL, always preferred) or enable this to take the scheme and host from RFC 7239 Forwarded, else X-Forwarded-Proto / X-Forwarded-Host. Off by default: those headers are set by the client unless a proxy you control overwrites them. A server bound to a loopback address also answers the proxy's public Host only when A2AHttpConfig::allowed_hosts lists it.
| bool neograph::a2a::A2AServer::start | ( | const std::string & | host, |
| int | port | ||
| ) |
Bind + listen.
Blocks the calling thread.
| bool neograph::a2a::A2AServer::start_async | ( | const std::string & | host, |
| int | port | ||
| ) |
| void neograph::a2a::A2AServer::stop | ( | ) |
Signal the server to stop accepting connections and join.
Requests already being handled are answered first, a stream with at least its opening Task; a request that arrives meanwhile gets JSON-RPC error -32603 (reason UNAVAILABLE). Open streams and blocking sends end when their runs publish a final state, and a stop never cancels a run.