client
Class info¶
Classes¶
| Name | Children | Inherits |
|---|---|---|
| Client aclientp.v2.client Base class of a v2 client. Override the methods the client supports. |
||
| ClientSideConnection aclientp.v2.client **UNSTABLE**: Connection of a v2 client to an agent. |
🛈 DocStrings¶
UNSTABLE: Client side of the draft ACP v2 protocol.
Subclass :class:Client and override the methods the client supports; every other
request from the agent is answered with -32601 (Method not found), and other
notifications are ignored. :class:ClientSideConnection runs the JSON-RPC connection
and offers typed calls for every agent method.
Mirrors the client bindings of the pinned TypeScript SDK (schema/references.toml).
Client
¶
Base class of a v2 client. Override the methods the client supports.
Source code in src/aclientp/v2/client.py
auth_status_update
async
¶
auth_status_update(params: AuthStatusUpdateNotification) -> None
complete_elicitation
async
¶
complete_elicitation(params: CompleteElicitationNotification) -> None
create_elicitation
async
¶
create_elicitation(params: CreateElicitationRequest) -> CreateElicitationResponse
ext_method
async
¶
Handle a custom (_-prefixed) request; params is None if omitted.
mcp_message
async
¶
mcp_message(params: MessageMcpRequest) -> MessageMcpResponse
mcp_notification
async
¶
mcp_notification(params: MessageMcpNotification) -> None
request_permission
async
¶
request_permission(params: RequestPermissionRequest) -> RequestPermissionResponse
Handle session/request_permission.
session_update
async
¶
session_update(params: UpdateSessionNotification) -> None
ClientSideConnection
¶
UNSTABLE: Connection of a v2 client to an agent.
Requests from the agent are answered with -32600 until initialize has
completed; earlier notifications are ignored.
Source code in src/aclientp/v2/client.py
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 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 | |
__init__
¶
__init__(
to_client: Callable[[ClientSideConnection], Client] | Client,
input_stream: ByteSendStream,
output_stream: ByteReceiveStream,
observers: list[StreamObserver] | None = None,
) -> None
Start the connection.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
to_client
|
Callable[[ClientSideConnection], Client] | Client
|
The client, or a factory receiving this connection. |
required |
input_stream
|
ByteSendStream
|
Stream to the agent. |
required |
output_stream
|
ByteReceiveStream
|
Stream from the agent. |
required |
observers
|
list[StreamObserver] | None
|
Observers of the raw messages. |
None
|
Source code in src/aclientp/v2/client.py
archive_session
async
¶
archive_session(params: ArchiveSessionRequest) -> ArchiveSessionResponse
auth_status
async
¶
auth_status(params: AuthStatusRequest) -> AuthStatusResponse
cancel
async
¶
cancel(params: CancelSessionNotification) -> None
cancel_terminal
async
¶
cancel_terminal(params: CancelTerminalRequest) -> CancelTerminalResponse
cancel_tool_call
async
¶
cancel_tool_call(params: CancelToolCallRequest) -> CancelToolCallResponse
Send tool_call/cancel.
close
async
¶
close_session
async
¶
close_session(params: CloseSessionRequest) -> CloseSessionResponse
delete_session
async
¶
delete_session(params: DeleteSessionRequest) -> DeleteSessionResponse
disable_provider
async
¶
disable_provider(params: DisableProviderRequest) -> DisableProviderResponse
Send providers/disable.
ext_method
async
¶
fork_session
async
¶
fork_session(params: ForkSessionRequest) -> ForkSessionResponse
handle
async
¶
Handle one incoming message (the connection's handler).
Source code in src/aclientp/v2/client.py
initialize
async
¶
initialize(params: InitializeRequest) -> InitializeResponse
Send initialize; the agent must answer with protocol version 2.
Raises:
| Type | Description |
|---|---|
ProtocolVersionError
|
The agent answered with another protocol version,
e.g. |
Source code in src/aclientp/v2/client.py
list_providers
async
¶
list_providers(params: ListProvidersRequest) -> ListProvidersResponse
list_sessions
async
¶
list_sessions(params: ListSessionsRequest) -> ListSessionsResponse
login
async
¶
login(params: LoginAuthRequest) -> LoginAuthResponse
logout
async
¶
logout(params: LogoutAuthRequest) -> LogoutAuthResponse
mcp_message
async
¶
mcp_message(params: MessageMcpRequest) -> MessageMcpResponse
Send an mcp/message request to the agent.
mcp_notification
async
¶
mcp_notification(params: MessageMcpNotification) -> None
new_session
async
¶
new_session(params: NewSessionRequest) -> NewSessionResponse
prompt
async
¶
prompt(params: PromptRequest) -> PromptResponse
Send session/prompt; returns once the message is inserted, not when the turn ends.
Source code in src/aclientp/v2/client.py
resume_session
async
¶
resume_session(params: ResumeSessionRequest) -> ResumeSessionResponse
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_config_option
async
¶
set_session_config_option(params: SetSessionConfigOptionRequest) -> SetSessionConfigOptionResponse
Send session/set_config_option.
Source code in src/aclientp/v2/client.py
set_session_title
async
¶
set_session_title(params: SetSessionTitleRequest) -> SetSessionTitleResponse
Send session/set_title.
unarchive_session
async
¶
unarchive_session(params: UnarchiveSessionRequest) -> UnarchiveSessionResponse
Send session/unarchive.