module ACP

Defined in:

acp.cr
acp/client.cr
acp/errors.cr
acp/protocol/capabilities.cr
acp/protocol/chunk_content_helper.cr
acp/protocol/client_methods.cr
acp/protocol/content_block.cr
acp/protocol/enums.cr
acp/protocol/tool_call_content.cr
acp/protocol/tool_call_content_helper.cr
acp/protocol/types.cr
acp/protocol/updates.cr
acp/session.cr
acp/transport.cr
acp/version.cr

Constant Summary

ClientLog = ::Log.for("acp.client")

Logger for client-level diagnostics.

Log = ::Log.for("acp.transport")

Logger for transport-level diagnostics.

MIN_PROTOCOL_VERSION = 1_u16

The oldest ACP protocol version this client can still speak. The initialize handshake is a negotiation: the agent replies with the version it will use — the same version when it supports our request, otherwise the latest version it supports (which may be lower). The client accepts any returned version within [MIN_PROTOCOL_VERSION, PROTOCOL_VERSION] and proceeds using it.

PROTOCOL_VERSION = 1_u16

The latest ACP protocol version this client implements. This is the version sent in the initialize request.

VERSION = "0.3.0"

Keep this in sync with version: in shard.yml — it is also advertised to agents as clientInfo.version during the initialize handshake.

Class Method Summary

Class Method Detail

def self.connect(command : String, args : Array(String) = [] of String, client_name : String = "acp-crystal", client_version : String = VERSION, capabilities : Protocol::ClientCapabilities = Protocol::ClientCapabilities.new, env : Process::Env = nil, chdir : String | Nil = nil) : Client #

Shortcut to create a client connected to a local agent process via stdio.

  • command — the agent executable path or name.
  • args — command-line arguments for the agent.
  • client_name — name to identify this client during initialization.
  • client_version — version string for the client.
  • capabilities — client capabilities to advertise.
  • env — optional environment variables for the agent process.
  • chdir — optional working directory for the agent process.

Spawns the agent, wraps it in a Client, performs the initialize handshake, and returns the ready-to-use (initialized) client — so callers can immediately create a session. The caller is responsible for calling client.close when done.

Raises whatever Client#initialize_connection raises if the handshake fails (e.g. VersionMismatchError, JsonRpcError). On such a failure the spawned process is torn down before the error propagates. Callers who need to register callbacks or authenticate before the handshake should build a ProcessTransport + Client directly instead of using this shortcut.


[View source]
def self.supports_protocol_version?(version : UInt16) : Bool #

Whether this client can speak the given negotiated protocol version.


[View source]