|
NeoGraph 0.10.0
A C++17 Graph Agent Engine Library — LangGraph for C++
|
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. | |
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).
Calls throw std::runtime_error on transport failure, on JSON-RPC error envelopes, and on timeout.
| 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.
| 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.
| 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.
| 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.
| 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.