This document explains how to register Book as an Agent Client Protocol (ACP) agent in Xcode 26.6 or later.

For ACP server configuration (transports, _meta keys) see ACP Server Configuration. For MCP tool configuration see MCP Configuration. For the server architecture internals see Embedding Book as an ACP Agent (Phase 4).

Prerequisites

Requirement Notes

Xcode 26.6 or later

ACP agent support shipped in 26.6

Book installed

~/.local/bin/book must exist and be executable

OPENAI_API_KEY configured

Set in ~/.bk/config or as an environment variable

Registering Book in Xcode

  1. Open Xcode โ†’ Settings โ†’ AI (or use the menu Xcode โ†’ Integrations โ†’ AI Agents).

  2. Click Add an ACP Agent (the + button).

  3. Fill in the following fields:

Field Value

Name

Book

Command

/Users/<your-username>/.local/bin/bk

Arguments

serve (or --mode acp)

Environment

(leave empty โ€” Book reads from ~/.bk/config)

Tip: You can find the exact path to the bk binary by running which bk in Terminal.

  1. Click Save. Xcode will launch bk serve as a subprocess and perform the ACP initialize handshake automatically.

How It Works

When Xcode launches bk serve, the following protocol sequence occurs:

Xcode                           bk serve (subprocess)
โ”€โ”€โ”€โ”€โ”€โ”€                          โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
  stdin  โ”€โ”€โ”€ initialize โ”€โ”€โ”€โ”€โ”€โ”€โ–ถ  AgentInfo{capabilities}
  stdout โ—€โ”€โ”€ response โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
  stdin  โ”€โ”€โ”€ session/new โ”€โ”€โ”€โ”€โ”€โ”€โ–ถ  AcpAgentSession{sessionId}
  stdout โ—€โ”€โ”€ response โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
  stdin  โ”€โ”€โ”€ session/prompt โ”€โ”€โ”€โ–ถ  AgentLoop.run()
  stdout โ—€โ”€โ”€ session/update* โ”€โ”€   (streaming text deltas, tool calls, token usage updates)
  stdout โ—€โ”€โ”€ PromptResponse โ”€โ”€โ”€
  ...
  stdin  โ”€โ”€โ”€ (close) โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–ถ  bk process exits

All messages are NDJSON (newline-delimited JSON), one JSON-RPC 2.0 object per line. After each prompt turn, bk serve streams session/update notifications containing text deltas, tool calls, and token usage statistics (usage_update, enabled by default; embedding CLIs can set emitUsageUpdates = false in AcpStartConfig to opt out). Logging is written under ~/.bk/agent/logs/ โ€” stdout is reserved exclusively for ACP messages.

Capabilities Advertised to Xcode

Book advertises the following capabilities during initialize:

Capability Value Meaning

loadSession

true

Xcode can restore a previous Book session

listSessions

{}

Xcode can browse Book’s session history

availableCommands

see below

Slash commands visible in Xcode’s UI

Available Slash Commands

Command Description

/compact

Compact session context (summarise and prune)

/new

Start a new session

/resume

Resume a session by ID or fragment

/fork

Fork the current session

/model

Select a different LLM model

/skills

List loaded skills

/tree

Show session tree

/init

Initialise project config (.bk/SYSTEM.md)

/help

Show all available commands

Commands with rendering == TUI_ONLY are excluded from this list โ€” they are not meaningful outside the terminal UI.

Model Selection & Reasoning Effort Pickers

Xcode renders native model and reasoning effort selection pickers based on the configOptions advertised by Book.

When you select a model or reasoning effort level in Xcode’s UI:

  • Xcode issues a session/set_config_option JSON-RPC call (configId: "model" or configId: "thought_level").

  • For model changes, Book validates the requested model against configured API keys, updates the model on the agent loop, and sends a SessionUpdate.ConfigOptionUpdate and an immediate SessionUpdate.UsageUpdate to update Xcode’s context window usage meter.

  • Model changes requested while a prompt turn is active are rejected with an error; changing model while idle succeeds immediately.

Session Persistence

Each session/new request creates a new Book session stored in the default session directory. Sessions created via Xcode are identical to sessions created from the terminal โ€” they appear in bk sessions list output and can be resumed from either interface.

Use session/load (triggered by Xcode’s session restore UI) to continue a previous conversation, including full message history.

Troubleshooting

Xcode shows "Agent failed to initialize"

  1. Open Terminal and run:

bash echo '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"0.26","clientCapabilities":{}}}' \ | bk serve ` You should see a JSON response on stdout. If you see an error, check the logs under `~/.bk/agent/logs/ for details.

  1. Confirm OPENAI_API_KEY is set:

`bash grep OPENAI_API_KEY ~/.bk/config `

Xcode shows a non-JSON line before the first response

The first line kotlin-logging: initializing…​ is printed by the logging framework before the log redirect takes effect. This is cosmetic โ€” ACP-compliant clients must ignore any non-JSON lines on stdout per the ACP transport spec. As a workaround:

java -Dkotlin-logging.init=false -jar ~/.local/bin/bk.jar serve

Tool calls are not visible in Xcode

Book emits session/notifications/update messages with tool_call type for each tool execution. If Xcode does not display them, ensure you are running Xcode 26.6 or later.

Sessions created via Xcode don’t appear in bk sessions list

Sessions are stored relative to the working directory Xcode passes in session/new โ†’ params.cwd. Run bk sessions list --all to list sessions across all directories.

Known Limitations (v1)

Limitation Status

No MCP server pass-through at startup

MCP config arrives per-session via session/new._meta.mcpServers

No HTTP/WebSocket transport

--acp-transport http throws NotImplementedError โ€” ACP SDK v0.25.0 has no HTTP transport

kotlin-logging banner on stdout

Cosmetic โ€” see Troubleshooting above

session/resume (unstable ACP API) not implemented

session/load is used instead; tracked for v2