Agent Client Protocol (ACP) v1 — Server & Client
Kompile implements bidirectional Agent Client Protocol (ACP) v1 over newline-delimited JSON-RPC 2.0 on stdio:
- 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). - 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 clientfs/*+terminal/*handlers.
Architecture at a Glance
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 --> HARN1. 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:
kompile acp [options]
# or
kompile chat --acp [options]Server CLI Options
| Flag | Default | Description |
|---|---|---|
-C, --working-dir, --cwd <DIR> | Current directory | Default working directory when session/new omits cwd. |
--agent <NAME> | coder | Initial Kompile agent mode (coder, planner, crawler, or any configured agent). |
--model <ID> | Effective config | Override the configured LLM model for ACP sessions. |
--provider <ID> | Effective config | Override the configured LLM provider for ACP sessions. |
--auth <METHOD> | Effective config | Override the configured authentication method. |
--thinking, --effort <LEVEL> | Effective config | Override reasoning effort (off, low, medium, high). |
--dangerously-skip-permissions | false | Auto-approve tool permission checks instead of asking the ACP client via session/request_permission. |
--no-client-fs | false | Always use Kompile's local file tools even when the client advertises fs/* capabilities. |
--no-client-terminal | false | Always use Kompile's local bash tool even when the client advertises terminal/* capabilities. |
--log-file <FILE> | stderr | Redirect 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:
{
"agent_servers": {
"Kompile": {
"command": "kompile",
"args": ["acp"]
}
}
}To pin a specific agent mode, model, or diagnostic log file:
{
"agent_servers": {
"Kompile": {
"command": "kompile",
"args": [
"acp",
"--agent", "coder",
"--log-file", "/tmp/kompile-acp.log"
]
}
}
}Supported ACP v1 Protocol Surface
| Category | Supported Methods / Capabilities |
|---|---|
| Lifecycle & Auth | initialize (protocol version 1), authenticate (verifies Kompile chat config; returns -32000 if unconfigured), logout |
| Session Management | session/new (with per-session cwd and mcpServers), session/load (replays persisted history), session/resume, session/list (paginated, 50/page), session/close, session/delete |
| Turns & Control | session/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 Capabilities | promptImage: 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 Commands | Advertised 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): whenfs.readTextFile/fs.writeTextFileare advertised (and--no-client-fsis not set), Kompile wrapsread,write, andeditso 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): whenterminalis advertised (and--no-client-terminalis not set), Kompile routesbashexecution throughterminal/create,terminal/output,terminal/wait_for_exit,terminal/kill, andterminal/releaseso commands stream inside the editor's embedded terminal UI. - Permission prompts (
AcpPermissionBridge): unless--dangerously-skip-permissionsis set, Kompile'sPermissionServicetranslates interactive approvals into ACPsession/request_permissionrequests with four standard ACP options:allow_once,allow_always,reject_once, andreject_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):
# 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 --verboseBuilt-in ACP Presets (/acp presets)
| Preset ID | Command | Description |
|---|---|---|
kompile | kompile acp | Kompile CLI chat running as an ACP v1 agent |
agy | agy acp | Google Antigravity CLI ACP server |
opencode | opencode acp | OpenCode ACP server |
claude-acp | claude-code-acp | Claude Code ACP adapter |
codex-acp | codex-acp | OpenAI Codex ACP adapter |
gemini | gemini --experimental-acp | Gemini CLI ACP server |
Interactive /acp Slash Commands
Inside kompile chat, manage external ACP connections live without restarting the session:
/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:
{
"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 dedicatedagyroute (--provider gemini --auth nativeor--mode passthrough --agent agy) uses a specializedagy acpintegration with Antigravity login, model catalog discovery, and native tool guards. The generic ACP client (provider = "acp") works with any ACP v1 agent — includingagy,opencode,claude-code-acp,codex-acp, or anotherkompile acpinstance. 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 extramcpServersintosession/newfor Kompile to load alongside its own tools.
Related Documentation
- CLI Harness (TUI & Config) — Kompile CLI harness architecture and configuration layers.
- How the MCP Server Works — Exposing Kompile tools over MCP stdio / HTTP / Unix socket.
- Slash Commands (
/) — Full list of chat REPL commands, including/acp. - Antigravity (
agy) Users — Dedicatedagy acpsetup and model discovery.