Crate agent_client_protocol

Crate agent_client_protocol 

Source
Expand description

Agent Client Protocol

§Agent Client Protocol (ACP)

The Agent Client Protocol standardizes communication between code editors (IDEs, text-editors, etc.) and coding agents (programs that use generative AI to autonomously modify code).

§Protocol & Transport

ACP is a JSON-RPC based protocol. While clients typically start agents as subprocesses and communicate over stdio (stdin/stdout), this crate is transport-agnostic.

You can use any bidirectional stream that implements AsyncRead and AsyncWrite.

§Core Components

  • Agent: Programs that use generative AI to autonomously modify code
  • Client: Code editors that provide the interface between users and agents

§Getting Started

To understand the protocol, start by exploring the Agent and Client traits, which define the core methods and capabilities of each side of the connection.

To see working examples of these traits in action, check out the agent and client example binaries included with this crate.

§Implementation Pattern

ACP uses a symmetric design where each participant implements one trait and creates a connection that provides the complementary trait:

  • Agent builders implement the Agent trait to handle client requests (like initialization, authentication, and prompts). They pass this implementation to AgentSideConnection::new, which returns a connection providing Client methods for requesting permissions and accessing the file system.

  • Client builders implement the Client trait to handle agent requests (like file system operations and permission checks). They pass this implementation to ClientSideConnection::new, which returns a connection providing Agent methods for managing sessions and sending prompts.

For the complete protocol specification and documentation, visit: https://agentclientprotocol.com

Structs§

AgentCapabilities
Capabilities supported by the agent.
AgentMethodNames
Names of all methods that agents handle.
AgentSide
Marker type representing the agent side of an ACP connection.
AgentSideConnection
An agent-side connection to a client.
Annotations
Optional annotations for the client. The client can use annotations to inform how objects are used or displayed
AudioContent
Audio provided to or from an LLM.
AuthMethod
Describes an available authentication method.
AuthMethodId
Unique identifier for an authentication method.
AuthenticateRequest
Request parameters for the authenticate method.
BlobResourceContents
Binary resource contents.
CancelNotification
Notification to cancel ongoing operations for a session.
ClientCapabilities
Capabilities supported by the client.
ClientMethodNames
Names of all methods that clients handle.
ClientSide
Marker type representing the client side of an ACP connection.
ClientSideConnection
A client-side connection to an agent.
Diff
A diff representing file modifications.
EmbeddedResource
The contents of a resource, embedded into a prompt or tool call result.
EnvVariable
An environment variable to set when launching an MCP server.
Error
JSON-RPC error object.
ErrorCode
Predefined error codes for common JSON-RPC and ACP-specific errors.
FileSystemCapability
File system capabilities that a client may support.
ImageContent
An image provided to or from an LLM.
InitializeRequest
Request parameters for the initialize method.
InitializeResponse
Response from the initialize method.
LoadSessionRequest
Request parameters for loading an existing session.
McpServer
Configuration for connecting to an MCP (Model Context Protocol) server.
NewSessionRequest
Request parameters for creating a new session.
NewSessionResponse
Response from creating a new session.
PermissionOption
An option presented to the user when requesting permission.
PermissionOptionId
Unique identifier for a permission option.
Plan
An execution plan for accomplishing complex tasks.
PlanEntry
A single entry in the execution plan.
PromptCapabilities
Prompt capabilities supported by the agent in session/prompt requests.
PromptRequest
Request parameters for sending a user prompt to the agent.
PromptResponse
Response from processing a user prompt.
ProtocolVersion
Protocol version identifier.
ReadTextFileRequest
Request to read content from a text file.
ReadTextFileResponse
Response containing the contents of a text file.
RequestPermissionRequest
Request for user permission to execute a tool call.
RequestPermissionResponse
Response to a permission request.
ResourceLink
A resource that the server is capable of reading, included in a prompt or tool call result.
SessionId
A unique identifier for a conversation session between a client and agent.
SessionNotification
Notification containing a session update from the agent.
StreamMessage
A message that flows through the RPC stream.
StreamReceiver
A receiver for observing the message stream.
TextContent
Text provided to or from an LLM.
TextResourceContents
Text-based resource contents.
ToolCall
Represents a tool call that the language model has requested.
ToolCallId
Unique identifier for a tool call within a session.
ToolCallLocation
A file location being accessed or modified by a tool.
ToolCallUpdate
An update to an existing tool call.
ToolCallUpdateFields
Optional fields that can be updated in a tool call.
WriteTextFileRequest
Request to write content to a text file.

Enums§

AgentNotification
All possible notifications that an agent can send to a client.
AgentRequest
All possible requests that an agent can send to a client.
AgentResponse
All possible responses that an agent can send to a client.
ClientNotification
All possible notifications that a client can send to an agent.
ClientRequest
All possible requests that a client can send to an agent.
ClientResponse
All possible responses that a client can send to an agent.
ContentBlock
Content blocks represent displayable information in the Agent Client Protocol.
EmbeddedResourceResource
Resource content that can be embedded in a message.
PermissionOptionKind
The type of permission option being presented to the user.
PlanEntryPriority
Priority levels for plan entries.
PlanEntryStatus
Status of a plan entry in the execution flow.
RequestPermissionOutcome
The outcome of a permission request.
Role
The sender or recipient of messages and data in a conversation.
SessionUpdate
Different types of updates that can be sent during session processing.
StopReason
Reasons why an agent stops processing a prompt turn.
StreamMessageContent
The content of a stream message.
StreamMessageDirection
The direction of a message in the RPC stream.
ToolCallContent
Content produced by a tool call.
ToolCallStatus
Execution status of a tool call.
ToolKind
Categories of tools that can be invoked.

Constants§

AGENT_METHOD_NAMES
Constant containing all agent method names.
CLIENT_METHOD_NAMES
Constant containing all client method names.
V0
V1
VERSION

Traits§

Agent
Defines the interface that all ACP-compliant agents must implement.
Client
Defines the interface that ACP-compliant clients must implement.