Agentic.Protocol.ACP.Client
(agentic v0.2.2)
Copy Markdown
JSON-RPC 2.0 client over stdio for ACP communication.
Manages bidirectional communication with an ACP agent subprocess. Handles request/response correlation, notification delivery, and incoming requests from the agent (e.g. permission requests).
Architecture
A listener process reads from the subprocess stdout and routes:
- Responses (has "id") to waiting callers via
:persistent_term - Notifications (no "id") to the registered notification handler
- Incoming requests (has "id" and "method" from agent) to request handler
Usage
{:ok, client} = Agentic.Protocol.ACP.Client.start_link(
command: "kimi",
args: ["acp"],
env: %{}
)
{:ok, result} = Agentic.Protocol.ACP.Client.request(client, "initialize", params)
Agentic.Protocol.ACP.Client.notify(client, "session/cancel", %{sessionId: "..."})
Agentic.Protocol.ACP.Client.stop(client)
Summary
Functions
Returns a specification to start this module under a supervisor.
Get the command that was used to start this client.
Get the current prompt accumulator text and updates list.
Send a JSON-RPC notification (no response expected).
Send a JSON-RPC request and wait for the response.
Reset the prompt accumulator and updates list.
Start an ACP client that communicates with a subprocess.
Gracefully stop the client and terminate the subprocess.
Types
@type client() :: pid()
@type request_opts() :: [{:timeout, non_neg_integer()}]
Functions
Returns a specification to start this module under a supervisor.
See Supervisor.
Get the command that was used to start this client.
Get the current prompt accumulator text and updates list.
Send a JSON-RPC notification (no response expected).
Send a JSON-RPC request and wait for the response.
@spec reset_prompt_state(client()) :: :ok
Reset the prompt accumulator and updates list.
@spec start_link(keyword()) :: GenServer.on_start()
Start an ACP client that communicates with a subprocess.
Options
:command- CLI binary path (required):args- List of arguments:env- Extra environment variables (map):notification_handler- Function called with(method, params)for notifications:request_handler- Function called with(id, method, params)for incoming requests, must return response
@spec stop(client()) :: :ok
Gracefully stop the client and terminate the subprocess.