English · 简体中文
A production-ready Dart SDK for the Agent Client Protocol (ACP), the open protocol connecting code editors and AI coding agents. The implementation follows the official Rust SDK and targets stable ACP v1.
| Package | Platforms | Purpose |
|---|---|---|
acpd |
Dart VM, Flutter, Web, WASM | Complete ACP v1 schema, frame-aware JSON-RPC, cancellation, roles, and high-level sessions. |
acpd_io |
Dart VM, Flutter native | Stdio transport, line framing, subprocess launch, stderr tail, tracing, and process-tree cleanup. |
acpd_http |
Dart VM, Flutter native | HTTP + scoped SSE and WebSocket clients and servers, authorization, CORS, limits, and session routing. |
acpd_test |
All acpd platforms |
In-memory transport pairs and programmable mock peers. |
acpd_example |
Dart VM | Runnable stdio agents and clients. |
Choose only the transports your application needs:
dart pub add acpd
dart pub add acpd_io # stdio and local processes
dart pub add acpd_http # HTTP/SSE and WebSocketimport 'package:acpd/acpd.dart';
import 'package:acpd_io/acpd_io.dart';
Future<void> main() async {
final agent = await AcpAgent.start(
const AcpAgentConfig(command: 'my-agent'),
);
final client = ClientRole()
.onRequestPermission((context, request, cancellation) {
return const RequestPermissionResponse(
outcome: PermissionCancelled(),
);
})
.connect(agent.transport);
try {
await client.client.initialize(
const InitializeRequest(
protocolVersion: ProtocolVersion.v1,
clientInfo: Implementation(name: 'my-client', version: '1.0.0'),
),
);
final session = await Session.create(
client,
const NewSessionRequest(cwd: '.', mcpServers: []),
);
try {
final turn = await session.sendPrompt(
const <ContentBlock>[TextContentBlock(text: 'Hello!')],
);
print(turn.agentText);
} finally {
session.dispose();
}
} finally {
await client.close();
await agent.close();
}
}For a remote agent, replace agent.transport with:
final transport = await AcpHttpClient('https://agent.example').connect();- Complete stable ACP v1 schema and typed request/response models.
- Typed
AgentRoleandClientRolehandlers for every stable ACP v1 method; raw handlers remain available only for protocol extensions. - Single and batch JSON-RPC frames with ordered grouped responses.
- Concurrent bidirectional requests, notifications, timeouts, and cooperative cancellation.
- Session creation/loading, prompt turns, streamed updates, modes, config options, permissions, filesystem, and terminal APIs.
- Stdio/process, HTTP + scoped SSE, and WebSocket transports.
- HTTP server authorization, CORS, health checks, body/queue limits, per-connection and per-session routing.
- Explicit error streams and bounded process stderr capture without leaking handler internals to peers.
ACPD does not read keychains or persist credentials. Applications own authentication and may inspect each incoming HTTP/WebSocket request through AcpHttpServer.authorize. Transport headers and process environment values stay caller-controlled.
- Dart
>=3.5.0 <4.0.0 - Flutter
>=3.24.0when used from Flutter
dart pub get
dart run melos bootstrap
dart fix --apply
dart format .
dart analyze
dart run melos run test --no-selectApache License 2.0, matching the official ACP SDKs.
