ACPex.Transport.Ndjson (ACPex v0.1.0)

View Source

Newline-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

Summary

Functions

Returns a specification to start this module under a supervisor.

Starts a new ndjson transport process.

Functions

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

start_link(parent, opts \\ [])

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