Overview
TheClient interface defines the methods your client must implement to handle incoming requests from the agent. There are two required methods and several optional ones depending on the capabilities you advertise.
Required Methods
requestPermission()
Requests permission from the user for a tool call operation.The session requesting permission.
Information about the tool call requiring permission, including:
toolCallId: Unique identifiertitle: Human-readable descriptioncontent: Tool call details
Available permission options to present to the user:
optionId: Unique identifier for this optionname: Display name (e.g., “Allow”, “Deny”, “Always Allow”)kind: Type of option ("allow","deny","apply_patch","modify_request")data: Additional data for the option (e.g., modified patch content)
The user’s decision:
{ outcome: "selected", optionId: string }: User selected an option{ outcome: "cancelled" }: User cancelled the prompt (sent after client callssession/cancel)
Example Implementation
If the client cancels the prompt turn via
session/cancel, it MUST respond to any pending requestPermission request with { outcome: { outcome: "cancelled" } }.sessionUpdate()
Handles real-time session update notifications from the agent.The session that generated this update.
The update content. The
sessionUpdate field discriminates the type:"agent_message_chunk": Streaming agent response"agent_thought_chunk": Agent’s internal reasoning"tool_call": New tool call initiated"tool_call_update": Tool call status changed"plan": Execution plan- And more…
Example Implementation
src/acp.ts:45-72
Optional Methods
These methods are only required if you advertise the corresponding capabilities during initialization.readTextFile()
Reads content from a text file in the client’s file system.Only implement if you advertise
fs.readTextFile: true in client capabilities.The session making the request.
Absolute file path to read.
The file contents as a UTF-8 string.
Example Implementation
writeTextFile()
Writes content to a text file in the client’s file system.Only implement if you advertise
fs.writeTextFile: true in client capabilities.The session making the request.
Absolute file path to write.
The content to write (UTF-8).
Returns an empty object on success.
Example Implementation
createTerminal()
Creates a new terminal to execute a command.Only implement if you advertise
terminal: true in client capabilities.The session creating the terminal.
The command to execute.
Command arguments.
Working directory for the command.
Environment variables.
Unique identifier for this terminal.
terminalOutput()
Gets the current output and exit status of a terminal.The session ID.
The terminal ID.
The terminal output (combined stdout/stderr).
Exit status if the command has completed:
{ type: "exit_code", code: number }{ type: "signal", signal: string }
waitForTerminalExit()
Waits for a terminal command to exit and returns its exit status.killTerminal()
Kills a terminal command without releasing the terminal.releaseTerminal()
Releases a terminal and frees all associated resources.Extension Methods
extMethod()
Handles arbitrary requests not part of the ACP spec.extNotification()
Handles arbitrary notifications not part of the ACP spec.Complete Example
Here’s a complete client implementation:See Also
- ClientSideConnection - Using the connection class
- Handling Session Updates - Processing real-time updates
- Permission Requests - Building permission UI
- File System Operations - Implementing file access
- Terminal Operations - Managing terminal execution