ACPex.Transport.Ndjson (ACPex v0.1.0)
View SourceNewline-delimited JSON (ndjson) transport for ACP using Erlang Ports.
The Agent Client Protocol uses newline-delimited JSON for message framing.
Each JSON-RPC message is encoded as a single line terminated by \n
.
This transport uses native Erlang Ports for robust external process management with:
- Line-buffered I/O for automatic message framing
- Non-blocking asynchronous message passing
- Automatic process cleanup on termination
- Bidirectional communication over stdin/stdout
Message Format
Messages are sent as complete JSON objects, one per line:
{"jsonrpc":"2.0","id":1,"method":"initialize","params":{...}}\n
{"jsonrpc":"2.0","id":1,"result":{...}}\n
References
- ACP Specification: https://agentclientprotocol.com
- NDJSON Specification: https://github.com/ndjson/ndjson-spec
- Erlang Ports: https://www.erlang.org/doc/tutorial/c_port.html
Summary
Functions
Returns a specification to start this module under a supervisor.
Starts a new ndjson transport process.
Functions
Returns a specification to start this module under a supervisor.
See Supervisor
.
Starts a new ndjson transport process.
Parameters
parent
- The parent process (typically ACPex.Protocol.Connection)opts
- Transport options (see below)
Options
:port_opts
- Port command specification (e.g.,{:spawn_executable, path}
):port_args
- Command-line arguments to pass to the executable