Skip to content

Commit b985fe4

Browse files
committed
Audit ACP compatibility and extract functional cores
1 parent fd97953 commit b985fe4

54 files changed

Lines changed: 2914 additions & 872 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

docs/ACP_GUIDE.md

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,7 @@ ACP sessions represent ongoing conversations with an agent.
154154
```elixir
155155
# Create a new session
156156
{:ok, %{"sessionId" => sid}} = ExMCP.ACP.Client.new_session(client, "/project",
157+
additional_directories: ["/shared/docs"],
157158
mcp_servers: [
158159
ExMCP.ACP.Types.http_mcp_server("my-server", "http://localhost:3000/mcp")
159160
]
@@ -167,7 +168,13 @@ ACP sessions represent ongoing conversations with an agent.
167168

168169
# List available sessions with optional filters (if supported)
169170
{:ok, %{"sessions" => sessions}} =
170-
ExMCP.ACP.Client.list_sessions(client, cwd: "/project")
171+
ExMCP.ACP.Client.list_sessions(client,
172+
cwd: "/project",
173+
additional_directories: ["/shared/docs"]
174+
)
175+
176+
# Delete a session from session history (if supported)
177+
{:ok, %{}} = ExMCP.ACP.Client.delete_session(client, sid)
171178

172179
# Send prompts (blocks until agent responds)
173180
{:ok, result} = ExMCP.ACP.Client.prompt(client, sid, "Add error handling")
@@ -233,9 +240,13 @@ defmodule MyApp.ACPHandler do
233240

234241
@impl true
235242
def handle_permission_request(_session_id, tool_call, options, state) do
236-
allow_option = Enum.find(options, &(&1["kind"] == "allow_once")) || List.first(options)
243+
reject_option = Enum.find(options, &(&1["kind"] == "reject_once")) || List.first(options)
244+
237245
# Return the direct outcome; ExMCP wraps it as result.outcome on the wire.
238-
{:ok, %{"outcome" => "selected", "optionId" => allow_option["optionId"]}, state}
246+
case reject_option do
247+
nil -> {:ok, %{"outcome" => "cancelled"}, state}
248+
option -> {:ok, %{"outcome" => "selected", "optionId" => option["optionId"]}, state}
249+
end
239250
end
240251

241252
# Optional: handle file read requests from the agent
@@ -289,15 +300,8 @@ The ACP spec defines these session update types (all supported by ExMCP):
289300
| `session_info_update` | Session metadata such as title and updatedAt |
290301
| `usage_update` | Context window usage and optional cost information |
291302

292-
ExMCP adapters also emit these extension types:
293-
294-
| Type | Description |
295-
|------|-------------|
296-
| `status` | Operational status (compacting, retrying, etc.) |
297-
| `usage` | Legacy adapter-specific token usage tracking |
298-
| `error` | Adapter-specific error notification |
299-
| `rpc_response` / `rpc_error` | Pi extension command responses |
300-
| `extension_ui_request` | Pi extension UI request bridge |
303+
Adapter-specific status, error, and extension bridge details are attached under
304+
`_meta.ex_mcp` on spec-defined update types, usually `session_info_update`.
301305

302306
## Writing Custom Adapters
303307

@@ -441,7 +445,7 @@ Translates between ACP and Pi's RPC NDJSON protocol.
441445

442446
**Config options:** `thinking_level`, `auto_compaction`, `auto_retry`, `steering_mode`, `follow_up_mode`
443447

444-
**Extended commands** (via `pi/*` ACP methods): steer, follow_up, compact, set_thinking_level, set_model, get_state, get_session_stats, switch_session, fork, bash, export_html, and more.
448+
**Extended commands** (via `_ex_mcp.pi/*` ACP extension methods): steer, follow_up, compact, set_thinking_level, set_model, get_state, get_session_stats, switch_session, fork, bash, export_html, and more. The adapter still accepts deprecated `pi/*` aliases for older consumers, but only the underscore-prefixed methods are advertised.
445449

446450
## Content Block Types
447451

@@ -482,6 +486,7 @@ ACP agents can use MCP servers as tool providers. Pass MCP server configurations
482486

483487
```elixir
484488
{:ok, %{"sessionId" => sid}} = ExMCP.ACP.Client.new_session(client, "/project",
489+
additional_directories: ["/shared/docs"],
485490
mcp_servers: [
486491
ExMCP.ACP.Types.stdio_mcp_server("local-tools", "my_mcp_server", args: ["--stdio"]),
487492
ExMCP.ACP.Types.http_mcp_server("remote-tools", "http://localhost:4000/mcp")

0 commit comments

Comments
 (0)