Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
e6d5b9c
feat: add Go implementation for ACP SDK
ThomasK33 Aug 29, 2025
d4c9cae
feat: add terminal support and improve validation
ThomasK33 Aug 29, 2025
7784e3e
feat: refactor interfaces to separate stable, experimental, and optio…
ThomasK33 Aug 30, 2025
25d4360
feat: split terminal methods into separate ClientTerminal interface
ThomasK33 Aug 30, 2025
53f0c7f
feat: improve error handling with JSON-formatted RequestError output …
ThomasK33 Aug 31, 2025
56a191b
feat: refactor code generation into modular emit package with dispatc…
ThomasK33 Aug 31, 2025
becba9a
feat: add constructor helpers and compact examples for Go ACP impleme…
ThomasK33 Aug 31, 2025
1b1b7dc
docs: add Go library README with installation and usage guide
ThomasK33 Aug 31, 2025
291245d
docs: add Go library to documentation with package info and examples
ThomasK33 Aug 31, 2025
e8062b1
feat: add context parameter to all ACP interface methods and handle c…
ThomasK33 Aug 31, 2025
1def049
Merge branch 'upstream-main'
ThomasK33 Sep 2, 2025
977cdb3
refactor: convert fields to pointer types and update union generation
ThomasK33 Sep 2, 2025
9de508b
test: add JSON parity tests with golden file validation
ThomasK33 Sep 2, 2025
0710c38
test: enhance JSON parity tests with constructor function validation
ThomasK33 Sep 2, 2025
cd12c48
test: refactor JSON parity tests with enhanced constructor function v…
ThomasK33 Sep 2, 2025
bdd623d
refactor: improve code generation with cleaner function signatures an…
ThomasK33 Sep 2, 2025
3bdf7c1
refactor: extract helpers to static file and optimize code generation
ThomasK33 Sep 2, 2025
43d82f0
test: remove trailing newlines from JSON golden files
ThomasK33 Sep 2, 2025
913fa9c
feat: add Nix development environment with JSON Schema defaults and G…
ThomasK33 Sep 10, 2025
630c0dc
refactor: improve connection handling with context-based cancellation…
ThomasK33 Sep 10, 2025
35fcd9d
Merge branch 'upstream-main'
ThomasK33 Sep 10, 2025
422dc56
feat: add session modes and MCP capabilities support
ThomasK33 Sep 10, 2025
1549a98
feat: update LoadSession method to return LoadSessionResponse
ThomasK33 Sep 12, 2025
55ce342
Merge branch 'upstream-main'
ThomasK33 Sep 12, 2025
f952023
feat: consolidate terminal methods into main Client interface and add…
ThomasK33 Sep 12, 2025
2c5041b
Merge branch 'upstream-main'
ThomasK33 Sep 22, 2025
784c708
feat: update method signatures to return response types for consistency
ThomasK33 Sep 22, 2025
6a82f1b
refactor: move unstable methods to experimental interfaces
ThomasK33 Sep 22, 2025
3e124b0
feat: add logging support to ACP connections
ThomasK33 Sep 22, 2025
b68e107
Merge branch 'upstream-main'
ThomasK33 Sep 22, 2025
6c9b0a0
chore: regenerate go files
ThomasK33 Sep 22, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,14 @@ jobs:
node-version: latest
cache: "npm"

- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: stable
cache: true
cache-dependency-path: |
go/cmd/generate/go.sum

- name: Setup Rust
uses: actions-rust-lang/setup-rust-toolchain@fb51252c7ba57d633bc668f941da052e410add48
with:
Expand Down
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,12 @@ typescript/*.js.map

# TypeDoc generated documentation
typescript/docs/

# Go files
.gocache
.gopath

.envrc
.direnv
.rustup/
.cargo/
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ Learn more at [agentclientprotocol.com](https://agentclientprotocol.com/).

- **Rust**: [`agent-client-protocol`](https://crates.io/crates/agent-client-protocol) - See [examples/agent.rs](./rust/examples/agent.rs) and [examples/client.rs](./rust/examples/client.rs)
- **TypeScript**: [`@zed-industries/agent-client-protocol`](https://www.npmjs.com/package/@zed-industries/agent-client-protocol) - See [examples/](./typescript/examples/)
- **Go**: [`github.com/zed-industries/agent-client-protocol/go`](https://pkg.go.dev/github.com/zed-industries/agent-client-protocol/go) - See [example/](./go/example/) and the [Go README](./go/README.md)
- **JSON Schema**: [schema.json](./schema/schema.json)
- [**use-acp**](https://github.com/marimo-team/use-acp): React hooks for connecting to Agent Client Protocol (ACP) servers.

Expand Down
1 change: 1 addition & 0 deletions docs/docs.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@
"pages": [
"libraries/typescript",
"libraries/rust",
"libraries/go",
"libraries/community"
]
},
Expand Down
33 changes: 33 additions & 0 deletions docs/libraries/go.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
---
title: "Go"
description: "Go library for the Agent Client Protocol"
---

The [`github.com/zed-industries/agent-client-protocol/go`](https://pkg.go.dev/github.com/zed-industries/agent-client-protocol/go)
package provides implementations of both sides of the Agent Client Protocol that
you can use to build your own agent server or client.

To get started, add the module to your project:

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

Depending on what kind of tool you're building, you'll create either the
[AgentSideConnection](https://pkg.go.dev/github.com/zed-industries/agent-client-protocol/go#NewAgentSideConnection)
or the
[ClientSideConnection](https://pkg.go.dev/github.com/zed-industries/agent-client-protocol/go#NewClientSideConnection)
and implement the corresponding interfaces (`Agent`, `Client`).

You can find example implementations of both sides in the
[main repository](https://github.com/zed-industries/agent-client-protocol/tree/main/go/example).
These can be run from your terminal or connected to external ACP agents, making
them great starting points for your own integration!

Browse the Go package docs on
[pkg.go.dev](https://pkg.go.dev/github.com/zed-industries/agent-client-protocol/go)
for detailed API documentation.

For a complete, production-ready implementation of an ACP agent, see the
[Gemini CLI](https://github.com/google-gemini/gemini-cli) which exposes an ACP
interface. The Go example client demonstrates connecting to it via stdio.
96 changes: 96 additions & 0 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

78 changes: 78 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
{
description = "Devshell for ACP";

inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-25.05";
flake-utils.url = "github:numtide/flake-utils";
rust-overlay.url = "github:oxalica/rust-overlay";
};

outputs =
{
self,
nixpkgs,
flake-utils,
rust-overlay,
}:
flake-utils.lib.eachDefaultSystem (
system:
let
pkgs = import nixpkgs {
inherit system;
overlays = [ rust-overlay.overlays.default ];
};

formatter = pkgs.nixfmt-rfc-style;

# Use rustup to manage toolchains so `cargo +nightly` works in dev shell
rustup = pkgs.rustup;
in
{
inherit formatter;

devShells.default = pkgs.mkShell {
packages = with pkgs; [
# Rustup manages stable/nightly toolchains according to rust-toolchain.toml
rustup
pkg-config
openssl

# Node.js toolchain
nodejs_24

# Go toolchain
go_1_24

# Nix formatter
formatter
];

RUST_BACKTRACE = "1";

# Ensure rustup shims are used and install required toolchains on first entry
shellHook = ''
export RUSTUP_HOME="$PWD/.rustup"
export CARGO_HOME="$PWD/.cargo"
export PATH="$CARGO_HOME/bin:$PATH"

if ! command -v rustup >/dev/null 2>&1; then
echo "rustup not found in PATH" 1>&2
else
# Install toolchains if missing; respect pinned channel from rust-toolchain.toml
if ! rustup toolchain list | grep -q nightly; then
rustup toolchain install nightly --profile minimal >/dev/null 2>&1 || true
fi
# Ensure stable toolchain from rust-toolchain.toml exists (rustup will auto-select it)
# Attempt to install channel specified in rust-toolchain.toml (fallback to stable)
TOOLCHAIN_CHANNEL=$(sed -n 's/^channel\s*=\s*"\(.*\)"/\1/p' rust-toolchain.toml || true)
if [ -n "$TOOLCHAIN_CHANNEL" ]; then
if ! rustup toolchain list | grep -q "$TOOLCHAIN_CHANNEL"; then
rustup toolchain install "$TOOLCHAIN_CHANNEL" --profile minimal --component rustfmt clippy >/dev/null 2>&1 || true
fi
fi
fi
'';
};
}
);
}
3 changes: 3 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module github.com/zed-industries/agent-client-protocol

go 1.21
74 changes: 74 additions & 0 deletions go/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
<a href="https://agentclientprotocol.com/" >
<img alt="Agent Client Protocol" src="https://zed.dev/img/acp/banner-dark.webp">
</a>

# 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

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

## Get Started

### Understand the Protocol

Start by reading the [official ACP documentation](https://agentclientprotocol.com) to understand the core concepts and protocol specification.

### Try the Examples

The [examples directory](https://github.com/zed-industries/agent-client-protocol/tree/main/go/example) 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:

- <https://pkg.go.dev/github.com/zed-industries/agent-client-protocol/go>

If you're building an [Agent](https://agentclientprotocol.com/protocol/overview#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](https://agentclientprotocol.com/protocol/overview#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](https://github.com/google-gemini/gemini-cli) which exposes an ACP interface. The Go example client `go/example/gemini` demonstrates connecting to it via stdio.

## Resources

- [Go package docs](https://pkg.go.dev/github.com/zed-industries/agent-client-protocol/go)
- [Examples (Go)](https://github.com/zed-industries/agent-client-protocol/tree/main/go/example)
- [Protocol Documentation](https://agentclientprotocol.com)
- [GitHub Repository](https://github.com/zed-industries/agent-client-protocol)

## Contributing

See the main [repository](https://github.com/zed-industries/agent-client-protocol) for contribution guidelines.
Loading