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.string
The session requesting permission.
ToolCall
Information about the tool call requiring permission, including:
toolCallId: Unique identifiertitle: Human-readable descriptioncontent: Tool call details
PermissionOption[]
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)
RequestPermissionOutcome
required
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.string
The session that generated this update.
SessionUpdate
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.string
The session making the request.
string
Absolute file path to read.
string
required
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.string
The session making the request.
string
Absolute file path to write.
string
The content to write (UTF-8).
object
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.string
The session creating the terminal.
string
The command to execute.
string[]
Command arguments.
string
Working directory for the command.
Record<string, string>
Environment variables.
string
required
Unique identifier for this terminal.
terminalOutput()
Gets the current output and exit status of a terminal.string
The session ID.
string
The terminal ID.
string
The terminal output (combined stdout/stderr).
ExitStatus
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