48#include <neograph/graph/execution.h>
50#ifdef NEOGRAPH_A2A_PROGRAM
64#ifdef NEOGRAPH_A2A_PROGRAM
65namespace neograph::program {
71namespace neograph::a2a {
73#ifdef NEOGRAPH_A2A_PROGRAM
74class ProgramAgentAdapter;
77#ifdef NEOGRAPH_A2A_TESTING
78namespace test {
class A2AServerTestAccess; }
105 const neograph::json& output,
106 const std::string& task_id)
const;
120 std::string data_channel,
121 std::string input_channel =
"prompt");
126 const neograph::json& output,
127 const std::string& task_id)
const override;
130 std::string contract_;
132 std::string data_channel_;
133 std::string input_channel_;
176 std::size_t max_payload_bytes = 4 * 1024 * 1024;
199 A2AServer(std::shared_ptr<neograph::graph::GraphEngine> engine,
201 std::shared_ptr<GraphAgentAdapter> adapter = {});
205 std::shared_ptr<GraphAgentAdapter> adapter = {});
207#ifdef NEOGRAPH_A2A_PROGRAM
226 using CollaborationAuthenticator = std::function<std::optional<CollaborationPeerIdentity>(
227 std::string_view authorization_header)>;
229 A2AServer(std::shared_ptr<ProgramAgentAdapter> adapter,
231 CollaborationAuthenticator collaboration_authenticator = {},
232 bool require_authenticated_requests =
false);
234 A2AServer(std::shared_ptr<neograph::program::ProgramRuntime> runtime,
235 neograph::program::ProgramVersion version,
236 std::string owner_scope,
238 std::shared_ptr<CollaborationMailbox> mailbox = {},
239 CollaborationAuthenticator collaboration_authenticator = {},
240 bool require_authenticated_requests =
false);
241 A2AServer(std::shared_ptr<neograph::program::ProgramRuntime> runtime,
242 neograph::program::ProgramVersion version,
244 std::string owner_scope,
245 std::shared_ptr<CollaborationMailbox> mailbox = {},
246 CollaborationAuthenticator collaboration_authenticator = {},
247 bool require_authenticated_requests =
false);
256 bool start(
const std::string& host,
int port);
301#ifdef NEOGRAPH_A2A_TESTING
302 friend class test::A2AServerTestAccess;
305 std::unique_ptr<Impl> impl_;
310#ifdef NEOGRAPH_A2A_TESTING
311namespace neograph::a2a::test {
313class A2AServerTestAccess {
315 static void set_max_inflight_runs(A2AServer& server, std::size_t cap);
317 static void set_stream_keepalive(A2AServer& server, std::chrono::milliseconds interval);
320 static void set_stream_handoff_hook(A2AServer& server, std::function<
void()> hook);
322 static bool draining(
const A2AServer& server);
Core data types for the Agent-to-Agent (A2A) protocol.
NEOGRAPH_API export/import macro for shared-library builds.
HTTP server exposing a NeoGraph as an A2A agent.
bool start(const std::string &host, int port)
Bind + listen.
void stop()
Signal the server to stop accepting connections and join.
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.
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,...
bool start_async(const std::string &host, int port)
Bind + spawn a worker thread; returns when the server is ready to accept connections.
int port() const
Bound port — useful when caller passed 0 to bind a free port.
Adapt a NeoGraph run to the A2A request/response shape.
virtual neograph::json build_resume_value(const Message &message) const
The value a follow-up message to an INPUT_REQUIRED task resumes the interrupted run with (spec 3....
virtual std::string output_channel() const
Channel name to read the agent's text response from (default "response").
virtual neograph::json build_initial_state(const std::string &user_text) const
Hook to populate the initial graph state.
virtual std::string input_channel() const
Channel name to write the inbound user text into (default "prompt").
virtual std::optional< Artifact > build_output_artifact(const neograph::json &output, const std::string &task_id) const
Optionally promote a graph output into a typed A2A artifact.
Adapt one JSON-valued graph output channel into a versioned A2A DataPart.
std::string input_channel() const override
Channel name to write the inbound user text into (default "prompt").
std::string output_channel() const override
Channel name to read the agent's text response from (default "response").
std::optional< Artifact > build_output_artifact(const neograph::json &output, const std::string &task_id) const override
Optionally promote a graph output into a typed A2A artifact.
Owning, concrete execution capability for protocol hosts.
Program-owned collaboration envelopes carried by A2A.
ProgramRuntime-backed A2A collaboration adapter.
Which Host and Origin values an A2AServer answers, and how large a request body it reads.
std::vector< std::string > allowed_hosts
Host header names the server answers: host names, IPv4 addresses and bracketed IPv6 addresses ([::1])...
std::vector< std::string > allowed_origins
Exact allowed Origin values.
Subset of AgentCard required to interact (spec §5.5).
A single conversational turn (spec §6.4).