class ACP::ProcessTransport

Overview

A convenience wrapper that spawns an agent process and creates a StdioTransport connected to its stdin/stdout. The agent's stderr is forwarded to a configurable IO (default: STDERR).

Defined in:

acp/transport.cr

Constructors

Instance Method Summary

Instance methods inherited from class ACP::StdioTransport

close : Nil close, closed? : Bool closed?, incoming : Channel(JSON::Any | Nil) incoming, receive(timeout : Time::Span) : JSON::Any | Nil
receive : JSON::Any | Nil
receive
, send(message : Hash(String, JSON::Any)) : Nil send

Constructor methods inherited from class ACP::StdioTransport

new(reader : IO, writer : IO, buffer_size : Int32 = 256) new

Instance methods inherited from class ACP::Transport

close : Nil close, closed? : Bool closed?, receive : JSON::Any | Nil receive, send(message : Hash(String, JSON::Any)) : Nil send, send_json(obj : Hash(String, JSON::Any)) : Nil send_json

Constructor Detail

def self.new(command : String, args : Array(String) = [] of String, env : Process::Env = nil, chdir : String | Nil = nil, stderr : IO = STDERR, buffer_size : Int32 = 256) #

Spawns an agent process with the given command and arguments, and sets up the stdio transport.

  • command — the agent executable (e.g., "claude-agent").
  • args — command-line arguments for the agent.
  • env — optional environment variables.
  • chdir — optional working directory for the process.
  • stderr — where to send the agent's stderr (default: STDERR).
  • buffer_size — channel buffer size (default: 256).

[View source]

Instance Method Detail

def close : Nil #

Closes the transport and terminates the agent process if it's still running.


[View source]
def process : Process #

The underlying child process.


[View source]
def terminated? : Bool #

Returns true if the agent process has terminated.


[View source]
def wait : Process::Status #

Waits for the agent process to exit and returns its status.


[View source]