ACP.Client behaviour (agent_client_protocol v0.1.0)

Copy Markdown View Source

Behaviour defining the interface that ACP-compliant clients must implement.

Clients are typically code editors that provide the interface between users and AI agents.

Required callbacks: request_permission/1, session_notification/1. Optional callbacks have default implementations that return {:error, method_not_found}.

Summary

Callbacks

Create a new terminal and execute a command. Optional.

Handle extension method requests. Optional.

Handle extension notifications. Optional.

Kill terminal command without releasing. Optional.

Read content from a text file. Optional.

Release a terminal. Optional.

Request permission from the user for a tool call operation.

Handle session update notifications from the agent.

Get terminal output and exit status. Optional.

Wait for terminal command to exit. Optional.

Write content to a text file. Optional.

Types

result(t)

@type result(t) :: {:ok, t} | {:error, ACP.Error.t()}

Callbacks

create_terminal(t)

(optional)
@callback create_terminal(ACP.CreateTerminalRequest.t()) ::
  result(ACP.CreateTerminalResponse.t())

Create a new terminal and execute a command. Optional.

ext_method(t)

(optional)
@callback ext_method(ACP.ExtRequest.t()) :: result(ACP.ExtResponse.t())

Handle extension method requests. Optional.

ext_notification(t)

(optional)
@callback ext_notification(ACP.ExtNotification.t()) :: :ok | {:error, ACP.Error.t()}

Handle extension notifications. Optional.

kill_terminal_command(t)

(optional)
@callback kill_terminal_command(ACP.KillTerminalCommandRequest.t()) ::
  result(ACP.KillTerminalCommandResponse.t())

Kill terminal command without releasing. Optional.

read_text_file(t)

(optional)
@callback read_text_file(ACP.ReadTextFileRequest.t()) ::
  result(ACP.ReadTextFileResponse.t())

Read content from a text file. Optional.

release_terminal(t)

(optional)
@callback release_terminal(ACP.ReleaseTerminalRequest.t()) ::
  result(ACP.ReleaseTerminalResponse.t())

Release a terminal. Optional.

request_permission(t)

@callback request_permission(ACP.RequestPermissionRequest.t()) ::
  result(ACP.RequestPermissionResponse.t())

Request permission from the user for a tool call operation.

session_notification(t)

@callback session_notification(ACP.SessionNotification.t()) ::
  :ok | {:error, ACP.Error.t()}

Handle session update notifications from the agent.

terminal_output(t)

(optional)
@callback terminal_output(ACP.TerminalOutputRequest.t()) ::
  result(ACP.TerminalOutputResponse.t())

Get terminal output and exit status. Optional.

wait_for_terminal_exit(t)

(optional)
@callback wait_for_terminal_exit(ACP.WaitForTerminalExitRequest.t()) ::
  result(ACP.WaitForTerminalExitResponse.t())

Wait for terminal command to exit. Optional.

write_text_file(t)

(optional)
@callback write_text_file(ACP.WriteTextFileRequest.t()) ::
  result(ACP.WriteTextFileResponse.t())

Write content to a text file. Optional.