Skip to content

Agent Client Protocol (ACP) v1 — Server & Client ​

Kompile implements bidirectional Agent Client Protocol (ACP) v1 over newline-delimited JSON-RPC 2.0 on stdio:

  1. Kompile as an ACP Agent Server (kompile acp / kompile chat --acp) — connect ACP-compatible editors and clients (Zed, JetBrains IDEs, Neovim, Emacs, or another Kompile session) directly to Kompile's full coding harness (AgenticChatLoop, tool registry, permissions, memory, skills, MCP servers, and session history).
  2. Kompile as a Generic ACP Client (--provider acp, --acp-command, /acp) — drive any external ACP v1 coding agent from inside Kompile Chat with live streaming, session mode/config inspection, and workspace-contained client fs/* + terminal/* handlers.

Architecture at a Glance ​

mermaid
flowchart LR
    subgraph ClientSide["ACP Client (Editor or Kompile Chat)"]
        ED["Zed / JetBrains / Neovim /\nkompile chat --acp-command"]
        CH["Client Handlers\nfs/* • terminal/* • permissions"]
    end

    subgraph Wire["Stdio JSON-RPC 2.0 (NDJSON, ACP v1)"]
        RPC["initialize • session/new|load|resume|list|close|delete\nsession/prompt • session/cancel • session/update\nsession/request_permission • fs/* • terminal/*"]
    end

    subgraph ServerSide["ACP Agent Server (kompile acp or External Agent)"]
        SRV["KompileAcpServer / External ACP Agent"]
        HARN["Kompile Harness\nTools • Permissions • Memory • Skills • MCP"]
    end

    ED <--> RPC
    CH <--> RPC
    RPC <--> SRV
    SRV --> HARN

1. Running Kompile as an ACP Agent Server ​

Expose Kompile's chat harness over stdio JSON-RPC 2.0 with either of two equivalent entry points:

bash
kompile acp [options]
# or
kompile chat --acp [options]

Server CLI Options ​

FlagDefaultDescription
-C, --working-dir, --cwd <DIR>Current directoryDefault working directory when session/new omits cwd.
--agent <NAME>coderInitial Kompile agent mode (coder, planner, crawler, or any configured agent).
--model <ID>Effective configOverride the configured LLM model for ACP sessions.
--provider <ID>Effective configOverride the configured LLM provider for ACP sessions.
--auth <METHOD>Effective configOverride the configured authentication method.
--thinking, --effort <LEVEL>Effective configOverride reasoning effort (off, low, medium, high).
--dangerously-skip-permissionsfalseAuto-approve tool permission checks instead of asking the ACP client via session/request_permission.
--no-client-fsfalseAlways use Kompile's local file tools even when the client advertises fs/* capabilities.
--no-client-terminalfalseAlways use Kompile's local bash tool even when the client advertises terminal/* capabilities.
--log-file <FILE>stderrRedirect non-protocol diagnostic output to FILE.

Strict stdio isolation: kompile acp captures the real stdin/stdout streams exclusively for newline-delimited JSON-RPC 2.0 frames and redirects System.out to System.err (or --log-file) so console logs never corrupt the protocol stream.

Editor Configuration Example (Zed) ​

Add Kompile to your Zed settings.json under agent_servers:

json
{
  "agent_servers": {
    "Kompile": {
      "command": "kompile",
      "args": ["acp"]
    }
  }
}

To pin a specific agent mode, model, or diagnostic log file:

json
{
  "agent_servers": {
    "Kompile": {
      "command": "kompile",
      "args": [
        "acp",
        "--agent", "coder",
        "--log-file", "/tmp/kompile-acp.log"
      ]
    }
  }
}

Supported ACP v1 Protocol Surface ​

CategorySupported Methods / Capabilities
Lifecycle & Authinitialize (protocol version 1), authenticate (verifies Kompile chat config; returns -32000 if unconfigured), logout
Session Managementsession/new (with per-session cwd and mcpServers), session/load (replays persisted history), session/resume, session/list (paginated, 50/page), session/close, session/delete
Turns & Controlsession/prompt, session/cancel (notification), session/set_mode, session/set_model, session/set_config_option
Streaming Updates (session/update)agent_message_chunk, agent_thought_chunk, tool_call, tool_call_update, plan, available_commands_update, current_mode_update, config_option_update, session_info_update, usage_update
Prompt & MCP CapabilitiespromptImage: true, promptEmbeddedContext: true, promptAudio: false, mcpHttp: true, mcpSse: true — MCP servers passed in session/new mcpServers are mounted directly into the session ToolRegistry via McpBundleToolLoader.loadExplicit
In-Session Slash CommandsAdvertised via available_commands_update: /help, /status, /mode <id>, /model <id>, /thinking <level>, /clear

Client Delegation (fs/*, terminal/*) & Permission Bridge ​

When the connecting ACP client advertises capabilities during initialize, Kompile integrates natively with the editor rather than bypassing it:

  • File delegation (AcpClientToolBridge): when fs.readTextFile / fs.writeTextFile are advertised (and --no-client-fs is not set), Kompile wraps read, write, and edit so reads see unsaved editor buffers and writes/edits emit structured diff metadata (acp_diff_path, acp_diff_old, acp_diff_new) for native editor review. Binary files stay on the local path.
  • Terminal delegation (AcpClientToolBridge): when terminal is advertised (and --no-client-terminal is not set), Kompile routes bash execution through terminal/create, terminal/output, terminal/wait_for_exit, terminal/kill, and terminal/release so commands stream inside the editor's embedded terminal UI.
  • Permission prompts (AcpPermissionBridge): unless --dangerously-skip-permissions is set, Kompile's PermissionService translates interactive approvals into ACP session/request_permission requests with four standard ACP options: allow_once, allow_always, reject_once, and reject_always.

2. Connecting Kompile Chat as an ACP Client ​

You can also drive any external ACP v1 coding agent directly from Kompile Chat using provider = "acp". Need to install an external client CLI first (agy, opencode, claude, codex, gemini, pi)? See Installable Client Harnesses for /install commands, auto-install behavior, and client capabilities.

Launching from the CLI ​

Use --acp-command with either a built-in preset name or any shell-style command string (optional extra arguments can be appended with --acp-args):

bash
# Built-in preset (automatically selects --provider acp and standard mode)
kompile chat --acp-command opencode
kompile chat --acp-command claude-acp
kompile chat --acp-command kompile

# Arbitrary ACP server command + extra arguments
kompile chat --acp-command "my-agent acp" --acp-args --verbose

Built-in ACP Presets (/acp presets) ​

Preset IDCommandDescription
kompilekompile acpKompile CLI chat running as an ACP v1 agent
agyagy acpGoogle Antigravity CLI ACP server
opencodeopencode acpOpenCode ACP server
claude-acpclaude-code-acpClaude Code ACP adapter
codex-acpcodex-acpOpenAI Codex ACP adapter
geminigemini --experimental-acpGemini CLI ACP server

Interactive /acp Slash Commands ​

Inside kompile chat, manage external ACP connections live without restarting the session:

text
/acp status                     # Show connection, agent capabilities, mode, and config
/acp presets                    # List built-in ACP agent presets
/acp connect <preset|cmd ...>   # Switch the session to an external ACP agent
/acp mode [modeId]              # List or switch ACP session modes
/acp config [id value]          # List or set ACP session config options
/acp sessions                   # List sessions advertised by the connected ACP agent
/acp disconnect                 # Close the current ACP agent subprocess (alias: /acp reset)

Configuration Fields (chat-config.json) ​

ACP client settings persist cleanly in project .kompile/chat-config.json or ~/.kompile/chat-config.json:

json
{
  "chatMode": "standard",
  "provider": "acp",
  "acpPreset": "opencode",
  "acpCommand": "opencode",
  "acpArgs": ["acp"],
  "acpEnv": {
    "CUSTOM_FLAG": "1"
  },
  "acpExposeClientFs": true,
  "acpExposeClientTerminal": true
}

Workspace Containment for External ACP Agents ​

When Kompile acts as the ACP client (acpExposeClientFs / acpExposeClientTerminal enabled), AcpClientHandlers.LocalHandlers enforces strict workspace root containment on every incoming fs/read_text_file, fs/write_text_file, and terminal/create request so an external ACP agent cannot read, write, or spawn terminals outside the session's workspace roots.


Relationship to Antigravity (agy) and MCP ​

  • Antigravity (agy): Kompile's dedicated agy route (--provider gemini --auth native or --mode passthrough --agent agy) uses a specialized agy acp integration with Antigravity login, model catalog discovery, and native tool guards. The generic ACP client (provider = "acp") works with any ACP v1 agent — including agy, opencode, claude-code-acp, codex-acp, or another kompile acp instance. See Antigravity (agy) Quickstart.
  • MCP vs. ACP: MCP (kompile mcp-stdio / kompile serve) exposes tools and context to an external agent; ACP (kompile acp) exposes the entire interactive agent loop (streaming thoughts, tool calls, plans, permissions, modes, and session lifecycle) to an editor or host client — and an ACP client can even pass extra mcpServers into session/new for Kompile to load alongside its own tools.

Released under the Apache-2.0 License.