Help us shape the future of Go! Take the 2026 Go Developer Survey

acp

module
v0.3.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 16, 2026 License: Apache-2.0

README

acp

github.com/looprig/acp is a bidirectional Agent Client Protocol (ACP) bridge for Looprig. It lets a Go program:

  • drive a foreign ACP agent (for example claude-agent-acp or codex-acp) as a client, over the agent's stdin/stdout; and
  • expose a Harness-shaped session host as an ACP agent, so an ACP client (such as an editor) can talk to it.

The wire layer is independent of Harness and usable against any ACP peer; only the agent package adapts it onto Harness.

Status

Released and in use by foreignloops. The wire types are generated from the pinned upstream ACP schema release schema-v1.20.0 (wire protocol version 1, stable surface only; see protocol/schema/v1/REVISION).

Known limits:

  • Spawning a child process (transport/stdio.Spawn, and therefore client and launch) is supported on Linux (non-Android) and macOS only. Other platforms fail before any child is started.
  • launch.Gemini is only a gateway environment adapter (HarnessAdapter), not a managed ACP connector. No Gemini CLI ACP adapter contract has been verified.
  • The agent-side Zed checklist in docs/interop/zed.md is covered by automated subprocess tests, not by a live run under Zed.

Install

go get github.com/looprig/acp@latest

Packages

Package Purpose
protocol JSON-RPC 2.0 framing (NDJSON), the Conn dispatcher, generated ACP types and method constants, and the typed AgentConn/ClientConn surfaces.
transport/stdio Process-boundary transport: Serve runs a Conn over the current process's stdio; Spawn starts and supervises a child whose stdio carries the other end.
client Drives a foreign ACP agent: Dial/New, sessions (NewSession, LoadSession, ResumeSession), prompts, cancellation, and optional permission, filesystem and terminal handlers.
launch Supervises an ACP child together with an optional model proxy. Ships ClaudeCode and Codex connectors (with ProbeCodexVersion preflight), DialNative for adapters using their own auth, and the Gemini env adapter.
agent The ACP agent facade over a consumer-supplied SessionHost/LiveSession: initialize, authenticate, session new/load/resume/list/close/delete, prompt, cancel, permission gates, config options and /compact. Optional capabilities are advertised only when their Options field is set.

protocol, transport/stdio, client and launch never import harness or core; agent is the only package that does.

Usage

Drive an ACP agent as a child process (adapted from examples/composition/example_test.go):

c, err := client.Dial(ctx, stdio.Command{Path: "/abs/path/to/agent", Env: env}, client.Options{})
if err != nil {
	return err
}
defer c.Close(ctx)

meta, _ := c.InitializeMetadata()
session, err := c.NewSession(ctx, client.NewSessionParams{Cwd: "/workspace"})
if err != nil {
	return err
}
fmt.Println(meta.AgentInfo.Name, session.ID())

Expose a session host as an ACP agent (see agent/examples/host/example_test.go):

facade, err := agent.New(agent.Options{Host: myHost})
if err != nil {
	return err
}
conn := protocol.NewConn(os.Stdin, os.Stdout, protocol.ConnOptions{})
facade.Register(conn)
return stdio.Serve(ctx, os.Stdin, os.Stdout, conn)

More runnable examples: Example_proxyBacked and Example_adapterConfiguration in examples/composition/example_test.go. Further documentation:

  • docs/connectors/inference-gateway.md: gateway-backed connectors in launch.
  • docs/interop/client-interop.md: client interop against a real ACP agent.
  • docs/interop/zed.md: the agent-side Zed checklist.

Where it sits

Tier 4 in the Looprig graph. Direct Looprig dependencies: core and harness (used only by agent). Consumed by foreignloops and carbon.

Development

Go 1.26.9 baseline.

GOWORK=off go test ./...
make test      # layering boundary check + go test -race ./...
make build     # boundary check + CGO_ENABLED=0 go build -trimpath ./...
make check     # fmt-check, vet, staticcheck, gosec, govulncheck, test, build
make fuzz      # prints the fuzz targets (FuzzEnvelope, FuzzFrameReader) and how to run them

make boundary enforces the layering rule above. The live interop probes are opt-in: set ACP_INTEROP_AGENT_PATH for client/interop_integration_test.go (-tags integration) and ACP_ADAPTER_PATH for TestInstalledAdapterLive. To regenerate the protocol types, run go generate ./protocol.

See CONTRIBUTING.md for contribution rules.

License

Apache License 2.0. See LICENSE.

Directories

Path Synopsis
agent.go defines the Agent facade: the struct that binds Options to real ACP wire methods over a *protocol.Conn (see conn.go's Handle/HandleNotify).
agent.go defines the Agent facade: the struct that binds Options to real ACP wire methods over a *protocol.Conn (see conn.go's Handle/HandleNotify).
client.go implements Client: the connection runtime that drives a foreign ACP agent as a client, over a subprocess spawned via acp/transport/stdio and a protocol.Conn built on top of it.
client.go implements Client: the connection runtime that drives a foreign ACP agent as a client, over a subprocess spawned via acp/transport/stdio and a protocol.Conn built on top of it.
internal
boundary
Package boundary anchors module tooling below the repository root.
Package boundary anchors module tooling below the repository root.
exampleagent command
Package main builds exampleagent: a thin, test-only composition of the real acp/agent facade over a minimal, purely in-memory SessionHost/LiveSession implementation.
Package main builds exampleagent: a thin, test-only composition of the real acp/agent facade over a minimal, purely in-memory SessionHost/LiveSession implementation.
gen command
Command gen reads a pinned ACP schema.json + meta.json pair and writes protocol/types_gen.go and protocol/methods_gen.go.
Command gen reads a pinned ACP schema.json + meta.json pair and writes protocol/types_gen.go and protocol/methods_gen.go.
mockpeer command
Package main builds mockpeer: a small, real ACP agent used as a scriptable test peer.
Package main builds mockpeer: a small, real ACP agent used as a scriptable test peer.
claude_connector.go implements ClaudeConnector's session-level behavior: locating claude-agent-acp's "model" select config option (tolerating a legacy identifier quirk some adapter versions have), applying model selection, and setting only permission modes the adapter actually advertised.
claude_connector.go implements ClaudeConnector's session-level behavior: locating claude-agent-acp's "model" select config option (tolerating a legacy identifier quirk some adapter versions have), applying model selection, and setting only permission modes the adapter actually advertised.
acp.go is the typed protocol surface over Conn: it binds the generated method-name constants in methods_gen.go to the generated request/response types in types_gen.go, one Go method per ACP RPC.
acp.go is the typed protocol surface over Conn: it binds the generated method-name constants in methods_gen.go to the generated request/response types in types_gen.go, one Go method per ACP RPC.
transport
stdio
Package stdio is the process-boundary transport for the Agent Client Protocol bridge: it carries a *protocol.Conn over a process's stdin and stdout.
Package stdio is the process-boundary transport for the Agent Client Protocol bridge: it carries a *protocol.Conn over a process's stdin and stdout.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL