agent
Class info¶
Re-exported classes¶
| Class | Module | Description |
|---|---|---|
| ACPAgentAPI | aclientp.agent.acp_agent_api | Thin wrapper for client-to-agent ACP interactions. |
| Agent | aclientp.agent.protocol | Base agent interface for ACP. |
| AgentSideConnection | aclientp.agent.connection | Agent-side connection. |
🛈 DocStrings¶
Agent (Server) ACP Connection.
ACPAgentAPI
¶
Thin wrapper for client-to-agent ACP interactions.
Avoids manual instantiation of request/notification objects.
Source code in src/aclientp/agent/acp_agent_api.py
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 | |
__init__
¶
__init__(connection: Agent) -> None
Initialize agent API helper.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
connection
|
Agent
|
The Agent protocol connection (e.g., ClientSideConnection) |
required |
authenticate
async
¶
authenticate(method_id: str) -> AuthenticateResponse | None
Authenticate with the agent.
cancel
async
¶
Cancel the current operation in a session.
ext_method
async
¶
ext_notification
async
¶
fork_session
async
¶
fork_session(
session_id: str,
cwd: str,
mcp_servers: Sequence[McpServer] | None = None,
metadata: dict[str, Any] | None = None,
) -> ForkSessionResponse
Fork an existing session.
Source code in src/aclientp/agent/acp_agent_api.py
initialize
async
¶
initialize(
*,
title: str,
version: str,
name: str,
protocol_version: int = 1,
terminal: bool = True,
read_text_file: bool = True,
write_text_file: bool = True,
terminal_auth: bool = False,
metadata: dict[str, Any] | None = None,
) -> InitializeResponse
Initialize the ACP connection.
Source code in src/aclientp/agent/acp_agent_api.py
list_sessions
async
¶
list_sessions(
cwd: str | None = None, cursor: str | None = None, metadata: dict[str, Any] | None = None
) -> ListSessionsResponse
List available sessions.
Source code in src/aclientp/agent/acp_agent_api.py
load_session
async
¶
load_session(
session_id: str,
cwd: str,
mcp_servers: Sequence[McpServer] | None = None,
metadata: dict[str, Any] | None = None,
) -> LoadSessionResponse
Load an existing session.
Source code in src/aclientp/agent/acp_agent_api.py
logout
async
¶
logout() -> LogoutResponse | None
new_session
async
¶
new_session(
cwd: str | None = None,
mcp_servers: Sequence[McpServer] | None = None,
metadata: dict[str, Any] | None = None,
) -> NewSessionResponse
Create a new ACP session.
Source code in src/aclientp/agent/acp_agent_api.py
prompt
async
¶
prompt(
session_id: str, prompt: Sequence[ContentBlock], metadata: dict[str, Any] | None = None
) -> PromptResponse
Send a prompt to the agent.
Source code in src/aclientp/agent/acp_agent_api.py
resume_session
async
¶
resume_session(
session_id: str,
cwd: str,
mcp_servers: Sequence[McpServer] | None = None,
metadata: dict[str, Any] | None = None,
) -> ResumeSessionResponse
Resume a paused session.
Source code in src/aclientp/agent/acp_agent_api.py
set_session_config_option
async
¶
set_session_config_option(
session_id: str, config_id: str, value: str | bool
) -> SetSessionConfigOptionResponse | None
Set a session configuration option.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
session_id
|
str
|
The session ID. |
required |
config_id
|
str
|
The config option ID. |
required |
value
|
str | bool
|
String value ID for select options, or bool for boolean options. |
required |
Source code in src/aclientp/agent/acp_agent_api.py
set_session_mode
async
¶
set_session_mode(session_id: str, mode_id: str) -> SetSessionModeResponse | None
Set the session mode.
Source code in src/aclientp/agent/acp_agent_api.py
Agent
¶
Bases: Protocol
Base agent interface for ACP.
Methods with a default body are optional and gated by a capability the agent
advertises. Their defaults reject the call with method not found.
Source code in src/aclientp/agent/protocol.py
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 | |
archive_session
async
¶
archive_session(params: ArchiveSessionRequest) -> ArchiveSessionResponse
auth_status
async
¶
auth_status(params: AuthStatusRequest) -> AuthStatusResponse
disable_provider
async
¶
disable_provider(params: DisableProviderRequest) -> DisableProviderResponse
list_providers
async
¶
list_providers(params: ListProvidersRequest) -> ListProvidersResponse
mcp_message
async
¶
mcp_message(params: MessageMcpRequest) -> MessageMcpResponse
UNSTABLE: Inner MCP request to an acp MCP server the agent declared.
mcp_notification
async
¶
mcp_notification(params: MessageMcpNotification) -> None
UNSTABLE: Inner MCP notification for an acp MCP server the agent declared.
session_options
async
¶
session_options(params: SessionOptionsRequest) -> SessionOptionsResponse
session_status
async
¶
session_status(params: SessionStatusRequest) -> SessionStatusResponse
set_provider
async
¶
set_provider(params: SetProviderRequest) -> SetProviderResponse
set_session_title
async
¶
set_session_title(params: SetSessionTitleRequest) -> SetSessionTitleResponse
unarchive_session
async
¶
unarchive_session(params: UnarchiveSessionRequest) -> UnarchiveSessionResponse
AgentSideConnection
¶
Bases: Client
Agent-side connection.
Use when you implement the Agent and need to talk to a Client.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
to_agent
|
Callable[[AgentSideConnection], Agent] | Agent
|
factory that receives this connection and returns your Agent |
required |
input
|
ByteSendStream (local -> peer) |
required | |
output
|
ByteReceiveStream (peer -> local) |
required |
Source code in src/aclientp/agent/connection.py
91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 | |
__aenter__
async
¶
__aexit__
async
¶
__init__
¶
__init__(
to_agent: Callable[[AgentSideConnection], Agent] | Agent,
input_stream: ByteSendStream,
output_stream: ByteReceiveStream,
observers: list[StreamObserver] | None = None,
*,
debug_file: str | None = None,
) -> None
Initialize the agent-side connection.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
to_agent
|
Callable[[AgentSideConnection], Agent] | Agent
|
factory that receives this connection and returns your Agent |
required |
input_stream
|
ByteSendStream
|
ByteSendStream (local -> peer) |
required |
output_stream
|
ByteReceiveStream
|
ByteReceiveStream (peer -> local) |
required |
observers
|
list[StreamObserver] | None
|
list of StreamObserver instances to observe the connection |
None
|
debug_file
|
str | None
|
path to a file to write debug information to |
None
|
Source code in src/aclientp/agent/connection.py
auth_status_update
async
¶
auth_status_update(params: AuthStatusUpdateNotification) -> None
UNSTABLE: Notify the client that the authentication state changed.
Source code in src/aclientp/agent/connection.py
close
async
¶
create_terminal
async
¶
create_terminal(params: CreateTerminalRequest) -> CreateTerminalResponse
Create a terminal on the client.
Source code in src/aclientp/agent/connection.py
elicitation
async
¶
elicitation(params: ElicitationRequest) -> ElicitationResponse
Request structured user input from the client.
Source code in src/aclientp/agent/connection.py
elicitation_complete
async
¶
elicitation_complete(params: ElicitationCompleteNotification) -> None
Notify the client that a URL-based elicitation has completed.
Source code in src/aclientp/agent/connection.py
ext_method
async
¶
ext_notification
async
¶
kill_terminal
async
¶
kill_terminal(params: KillTerminalRequest) -> KillTerminalResponse
Kill a terminal on the client.
Source code in src/aclientp/agent/connection.py
mcp_message
async
¶
mcp_message(params: MessageMcpRequest) -> MessageMcpResponse
UNSTABLE: Send an inner MCP request to an acp MCP server the client declared.
Source code in src/aclientp/agent/connection.py
mcp_notification
async
¶
mcp_notification(params: MessageMcpNotification) -> None
UNSTABLE: Send an inner MCP notification over mcp/message.
Source code in src/aclientp/agent/connection.py
on_connection
classmethod
¶
on_connection(
connection: Connection, to_agent: Callable[[AgentSideConnection], Agent] | Agent
) -> tuple[AgentSideConnection, MethodHandler]
Serve v1 on an existing connection, returning the side and its handler.
Used by the version router (:mod:aclientp.router), which owns the connection
until initialize and then delegates incoming messages to the handler.
Source code in src/aclientp/agent/connection.py
read_text_file
async
¶
read_text_file(params: ReadTextFileRequest) -> ReadTextFileResponse
Read text file from the client.
Source code in src/aclientp/agent/connection.py
release_terminal
async
¶
release_terminal(params: ReleaseTerminalRequest) -> ReleaseTerminalResponse
Release a terminal on the client.
Source code in src/aclientp/agent/connection.py
request_permission
async
¶
request_permission(params: RequestPermissionRequest) -> RequestPermissionResponse
Request permission from the client.
Source code in src/aclientp/agent/connection.py
session_update
async
¶
session_update(params: SessionNotification) -> None
Send session update notification.
Source code in src/aclientp/agent/connection.py
terminal_output
async
¶
terminal_output(params: TerminalOutputRequest) -> TerminalOutputResponse
Show terminal output on the client.
Source code in src/aclientp/agent/connection.py
wait_closed
async
¶
wait_for_terminal_exit
async
¶
wait_for_terminal_exit(params: WaitForTerminalExitRequest) -> WaitForTerminalExitResponse
Wait for a terminal to exit on the client.
Source code in src/aclientp/agent/connection.py
write_text_file
async
¶
write_text_file(params: WriteTextFileRequest) -> WriteTextFileResponse
Write text file to the client.