NeoGraph 0.16.0
A C++20 Graph Agent Engine Library — LangGraph for C++
Loading...
Searching...
No Matches
neograph::acp::ACPHttpServer Class Reference

ACP over Streamable HTTP and WebSocket; see the file comment for the mapping, the deviations from the draft and the security rules. More...

#include <http_server.h>

Public Types

using ConnectionFactory = std::function< ACPHttpConnection(std::string_view principal)>
 Called once per new connection, with the principal the authenticator returned (empty without one). It must return a fresh ACPServer; it may be called on any HTTP thread and concurrently.
 

Public Member Functions

 ACPHttpServer (ConnectionFactory factory, ACPHttpConfig config={})
 
void attach_client (std::shared_ptr< ACPClient > client)
 Bind a client that graph nodes captured before this server existed, as ACPServer::attach_client does for one connection: an unbound std::make_shared<ACPClient>() is captured when the engine is compiled and attached here once the server is built.
 
std::shared_ptr< ACPClient > client ()
 A handle for agent-to-client requests (fs/*, permission) that reaches the connection owning the session named in each call, so graph nodes can capture it once, before any connection exists. A call for a session that no live connection holds throws std::runtime_error.
 
std::size_t connection_count () const
 The number of open connections.
 
int port () const
 The bound port; useful when ACPHttpConfig::port is 0.
 
bool start ()
 Bind and serve until stop() is called. Returns false if the address cannot be bound.
 
bool start_async ()
 Bind and serve on a background listener thread.
 
void stop ()
 Stop accepting, close every connection (cancelling its prompts) and join the threads. The connections' ACPServers are destroyed here.
 

Detailed Description

ACP over Streamable HTTP and WebSocket; see the file comment for the mapping, the deviations from the draft and the security rules.

acp::ACPHttpServer server([&](std::string_view) {
connection.server = std::make_unique<acp::ACPServer>(
engine, neograph::json{{"name", "my-agent"}});
return connection;
});
server.start_async(); // loopback, free port; see server.port()
ACP over Streamable HTTP and WebSocket; see the file comment for the mapping, the deviations from the...
bool start_async()
Bind and serve on a background listener thread.
What the factory of an ACPHttpServer returns for one new connection.

Definition at line 245 of file http_server.h.

Constructor & Destructor Documentation

◆ ACPHttpServer()

neograph::acp::ACPHttpServer::ACPHttpServer ( ConnectionFactory  factory,
ACPHttpConfig  config = {} 
)
Exceptions
std::invalid_argumentfor a missing factory, an invalid limit or endpoint, an allowed_hosts entry that is not a host name without a port, an IPv6 address in brackets or *, a remote bind without authenticator, or no transport enabled.

The documentation for this class was generated from the following file: