Skip to content

Repository files navigation

acpd logo

acpd — Dart Agent Client Protocol SDK

CI pub package license

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.

Packages

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.

Install

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 WebSocket

Client quick start

import '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();

Protocol coverage

  • Complete stable ACP v1 schema and typed request/response models.
  • Typed AgentRole and ClientRole handlers 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.

Security model

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.

Requirements

  • Dart >=3.5.0 <4.0.0
  • Flutter >=3.24.0 when used from Flutter

Development

dart pub get
dart run melos bootstrap
dart fix --apply
dart format .
dart analyze
dart run melos run test --no-select

License

Apache License 2.0, matching the official ACP SDKs.

About

No description, website, or topics provided.

Resources

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages