Skip to content

Latest commit

 

History

History
74 lines (48 loc) · 3.26 KB

File metadata and controls

74 lines (48 loc) · 3.26 KB
Agent Client Protocol

ACP Go Library

The official Go implementation of the Agent Client Protocol (ACP) — a standardized communication protocol between code editors and AI‑powered coding agents.

Learn more at https://agentclientprotocol.com

Installation

go get github.com/zed-industries/agent-client-protocol/go@latest

Get Started

Understand the Protocol

Start by reading the official ACP documentation to understand the core concepts and protocol specification.

Try the Examples

The examples directory contains simple implementations of both Agents and Clients in Go. You can run them from your terminal or connect to external ACP agents.

  • Run the example Agent:
    • cd go && go run ./example/agent
  • Run the example Client (connects to the example Agent):
    • cd go && go run ./example/client
  • Connect to the Gemini CLI (ACP mode):
    • cd go && go run ./example/gemini -yolo
    • Optional flags: -model, -sandbox, -debug, -gemini /path/to/gemini
  • Connect to Claude Code (via npx):
    • cd go && go run ./example/claude-code -yolo

Explore the API

Browse the Go package docs on pkg.go.dev for detailed API documentation:

If you're building an Agent:

  • Implement the acp.Agent interface (and optionally acp.AgentLoader for session/load).
  • Create a connection with acp.NewAgentSideConnection(agent, os.Stdout, os.Stdin).
  • Send updates and make client requests using the returned connection.

If you're building a Client:

  • Implement the acp.Client interface (and optionally acp.ClientTerminal for terminal features).
  • Launch or connect to your Agent process (stdio), then create a connection with acp.NewClientSideConnection(client, stdin, stdout).
  • Call Initialize, NewSession, and Prompt to run a turn and stream updates.

Helper constructors are provided to reduce boilerplate when working with union types:

  • Content blocks: acp.TextBlock, acp.ImageBlock, acp.AudioBlock, acp.ResourceLinkBlock, acp.ResourceBlock.
  • Tool content: acp.ToolContent, acp.ToolDiffContent, acp.ToolTerminalRef.
  • Utility: acp.Ptr[T] for pointer fields in request/update structs.

Study a Production Implementation

For a complete, production‑ready integration, see the Gemini CLI Agent which exposes an ACP interface. The Go example client go/example/gemini demonstrates connecting to it via stdio.

Resources

Contributing

See the main repository for contribution guidelines.