NeoGraph 0.10.0
A C++17 Graph Agent Engine Library — LangGraph for C++
Loading...
Searching...
No Matches
neograph::acp::ACPClient Class Reference

Agent-side handle for issuing requests back to the editor. More...

#include <server.h>

Public Member Functions

 ACPClient ()
 Construct an unbound client.
 
 ACPClient (ACPServer *server)
 Construct a client already bound to server.
 
void bind (ACPServer *server)
 Late-binding hook — set the back-pointer to the server. Idempotent.
 
bool bound () const noexcept
 True once bind has been called with a non-null server.
 
std::string read_text_file (std::string_view session_id, std::string_view path, std::optional< int > line={}, std::optional< int > limit={})
 Read a workspace file via the editor.
 
RequestPermissionOutcome request_permission (std::string_view session_id, const ToolCallUpdate &tool_call, const std::vector< PermissionOption > &options)
 Ask the editor to surface a permission prompt for an upcoming tool call.
 
void set_timeout (std::chrono::milliseconds t)
 Default per-call timeout.
 
void write_text_file (std::string_view session_id, std::string_view path, std::string_view content)
 Write (create or overwrite) a workspace file via the editor.
 

Detailed Description

Agent-side handle for issuing requests back to the editor.

ACP is bidirectional — the client (editor) drives the agent with session/prompt etc., but the agent talks back not just via session/update notifications but also via requests like fs/read_text_file (read a workspace file) and fs/write_text_file (write a workspace file). These calls block until the editor responds.

Obtain an instance via ACPServer::client(). Capture it inside a node's lambda; pull session_id out of the graph state (the default ACPGraphAdapter writes it to the _acp_session_id channel).

auto client = server.client();
NodeFactory::instance().register_type("read_workspace_file",
[client](const std::string& n, const json&, const NodeContext&) {
return std::make_unique<MyNode>(n, client);
});
// inside MyNode::execute(state):
auto sid = state.get("_acp_session_id").get<std::string>();
auto path = state.get("path").get<std::string>();
auto src = client->read_text_file(sid, path);

Calls throw std::runtime_error on transport failure, on JSON-RPC error envelopes, and on timeout.

Definition at line 119 of file server.h.

Constructor & Destructor Documentation

◆ ACPClient()

neograph::acp::ACPClient::ACPClient ( )

Construct an unbound client.

Bind it to a server later via bind or ACPServer::attach_client. This is the form you want when nodes capture the client during compile() — long before the ACPServer instance exists.

Member Function Documentation

◆ read_text_file()

std::string neograph::acp::ACPClient::read_text_file ( std::string_view  session_id,
std::string_view  path,
std::optional< int >  line = {},
std::optional< int >  limit = {} 
)

Read a workspace file via the editor.

line is 1-based; omitted = from start. limit is the max line count; omitted = whole file. Throws if not yet bound to a server.

◆ request_permission()

RequestPermissionOutcome neograph::acp::ACPClient::request_permission ( std::string_view  session_id,
const ToolCallUpdate &  tool_call,
const std::vector< PermissionOption > &  options 
)

Ask the editor to surface a permission prompt for an upcoming tool call.

Blocks until the user picks an option or the prompt is cancelled. The returned outcome tells the caller whether to proceed (kind == Selected, inspect optionId/kind) or abort (kind == Cancelled — the prompt turn itself was cancelled). Throws if not yet bound to a server.

◆ set_timeout()

void neograph::acp::ACPClient::set_timeout ( std::chrono::milliseconds  t)

Default per-call timeout.

Editors usually respond fast, but fs/* may be slow for large files; tune via set_timeout.

◆ write_text_file()

void neograph::acp::ACPClient::write_text_file ( std::string_view  session_id,
std::string_view  path,
std::string_view  content 
)

Write (create or overwrite) a workspace file via the editor.

Throws if not yet bound to a server.


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