ACPRequests
🛈 DocStrings¶
Clean API for creating and sending ACP session requests.
Provides convenient methods for common request patterns, handling both creation and sending in a single call.
Source code in src/aclientp/agent/acp_requests.py
41 42 43 44 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 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 | |
create_terminal
async
¶
create_terminal(
command: str,
*,
args: list[str] | None = None,
cwd: str | None = None,
env: dict[str, str] | None = None,
output_byte_limit: int | None = None,
metadata: dict[str, str] | None = None,
) -> TerminalHandle
Create a new terminal session.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
command
|
str
|
Command to run. For shell commands (pipes, redirects, etc.), pass the full command string and omit args. |
required |
args
|
list[str] | None
|
Command arguments, appended to command. |
None
|
cwd
|
str | None
|
Working directory for terminal |
None
|
env
|
dict[str, str] | None
|
Environment variables for terminal |
None
|
output_byte_limit
|
int | None
|
Maximum bytes to capture from output |
None
|
metadata
|
dict[str, str] | None
|
Optional metadata to include with the request |
None
|
Source code in src/aclientp/agent/acp_requests.py
elicit
async
¶
elicit(request: ElicitationRequest) -> ElicitationResponse
Ask the user for structured input (elicitation/create), scoped to this session.
Only allowed if the client advertised the matching elicitation mode.
Source code in src/aclientp/agent/acp_requests.py
kill_terminal
async
¶
Kill a terminal session.
Source code in src/aclientp/agent/acp_requests.py
read_text_file
async
¶
read_text_file(
path: str,
*,
limit: int | None = None,
line: int | None = None,
metadata: dict[str, str] | None = None,
) -> str
Read text content from a file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str
|
File path to read |
required |
limit
|
int | None
|
Maximum number of lines to read |
None
|
line
|
int | None
|
Line number to start reading from (1-based) |
None
|
metadata
|
dict[str, str] | None
|
Optional metadata to include with the request |
None
|
Returns:
| Type | Description |
|---|---|
str
|
File content as string |
Source code in src/aclientp/agent/acp_requests.py
release_terminal
async
¶
Release a terminal session.
Source code in src/aclientp/agent/acp_requests.py
request_permission
async
¶
request_permission(
tool_call_id: str,
*,
title: str | None = None,
raw_input: dict[str, Any] | None = None,
options: Sequence[PermissionOption] | None = None,
metadata: dict[str, str] | None = None,
) -> RequestPermissionResponse
Request permission from user before executing a tool call.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tool_call_id
|
str
|
Unique identifier for the tool call |
required |
title
|
str | None
|
Human-readable description of the operation |
None
|
raw_input
|
dict[str, Any] | None
|
The raw input parameters for the tool call |
None
|
options
|
Sequence[PermissionOption] | None
|
Available permission options (defaults to allow/reject once) |
None
|
metadata
|
dict[str, str] | None
|
Metadata to include with the request |
None
|
Returns:
| Type | Description |
|---|---|
RequestPermissionResponse
|
Permission response with user's decision |
Source code in src/aclientp/agent/acp_requests.py
run_command
async
¶
run_command(
command: str,
*,
args: list[str] | None = None,
cwd: str | None = None,
env: dict[str, str] | None = None,
output_byte_limit: int | None = None,
timeout_seconds: int | None = None,
metadata: dict[str, str] | None = None,
) -> tuple[str, int | None]
Execute a shell command and return output and exit code.
This is a high-level convenience method that creates a terminal, runs the command, waits for completion, and cleans up.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
command
|
str
|
Command to execute |
required |
args
|
list[str] | None
|
Command arguments |
None
|
cwd
|
str | None
|
Working directory for command execution |
None
|
env
|
dict[str, str] | None
|
Environment variables for command execution |
None
|
output_byte_limit
|
int | None
|
Maximum bytes to capture from output |
None
|
timeout_seconds
|
int | None
|
Command timeout in seconds |
None
|
metadata
|
dict[str, str] | None
|
Metadata for the requests |
None
|
Returns:
| Type | Description |
|---|---|
tuple[str, int | None]
|
Tuple of (output, exit_code) |
Source code in src/aclientp/agent/acp_requests.py
terminal_output
async
¶
terminal_output(terminal_id: str, metadata: dict[str, str] | None = None) -> TerminalOutputResponse
Get output from a terminal session.
Source code in src/aclientp/agent/acp_requests.py
wait_for_terminal_exit
async
¶
wait_for_terminal_exit(
terminal_id: str, metadata: dict[str, str] | None = None
) -> WaitForTerminalExitResponse
Wait for a terminal to exit.
Source code in src/aclientp/agent/acp_requests.py
write_text_file
async
¶
Write text content to a file.