What is ACP?
The Agent Client Protocol (ACP) is a standardized communication protocol that enables seamless interaction between code editors (clients) and AI-powered coding agents. It provides a structured way for AI assistants to understand context, execute tools, and collaborate with developers in real-time. Learn more about the protocol at agentclientprotocol.comWhat is ACP Dart?
The ACP Dart SDK is the official Dart implementation of the Agent Client Protocol. It provides a complete, type-safe implementation that makes it easy to:Build AI Agents
Create intelligent agents that process prompts, execute tools, and interact with development environments
Build ACP Clients
Implement code editors or IDEs that communicate with AI agents through the standardized protocol
Type-Safe Communication
Leverage full Dart type annotations with null safety for robust, error-free implementations
Stream-Based Protocol
Use NDJSON-based communication over stdio for efficient, real-time data exchange
Key Features
Type Safety
Full Dart type annotations with null safety ensure your code is robust and catches errors at compile time:RPC Unions
Sealed union types enable exhaustive request/response handling with pattern matching:Stream-Based Communication
Built-in NDJSON stream handling for stdio-based communication:Comprehensive Error Handling
- Parameter validation failures map to
-32602 Invalid params - Unexpected runtime failures map to
-32603 Internal error - Protocol cancellation with
-32800cancelled error semantics - Type-safe error types:
RequestError,ErrorResponse
Protocol Support
The SDK tracks both stable and unstable ACP surfaces:Stable Methods
Agent Methods
Agent Methods
initialize- Establish connection and negotiate capabilitiesauthenticate- Handle authentication requestssession/new- Create new conversation sessionssession/load- Load existing sessionssession/prompt- Process user promptssession/cancel- Cancel ongoing operationssession/set_mode- Switch agent modessession/set_config_option- Configure session options
Client Methods
Client Methods
fs/read_text_file- Read file contentsfs/write_text_file- Write file contentssession/request_permission- Request user permissionssession/update- Send session updates
Terminal Methods
Terminal Methods
terminal/create- Create new terminalsterminal/output- Get terminal outputterminal/wait_for_exit- Wait for command completionterminal/kill- Kill running commandsterminal/release- Release terminal resources
Unstable Methods
These methods are experimental and may change in future versions:
session/list- List available sessionssession/fork- Fork existing sessionssession/resume- Resume sessions without replaysession/set_model- Change the active model
Core Components
The library provides several key components:| Component | Purpose |
|---|---|
AgentSideConnection | Implement AI agents that process prompts and execute tools |
ClientSideConnection | Implement ACP clients (editors/IDEs) |
Agent interface | Define agent-side request handlers |
Client interface | Define client-side request handlers |
TerminalHandle | Manage terminal operations |
ndJsonStream | Handle NDJSON-based communication |
| Schema types | Comprehensive definitions for all ACP messages |
| RPC unions | Type-safe request/response handling |
Architecture
Building an Agent? Start with the
Agent interface and AgentSideConnection to handle prompts and tool execution.Building a Client? Start with the Client interface and ClientSideConnection to integrate AI capabilities into your editor.Next Steps
Installation
Install the ACP Dart SDK in your project
Quickstart
Build your first agent or client in minutes
Protocol Documentation
Deep dive into the ACP specification
Examples
Explore working examples on GitHub