|
1 | 1 | from __future__ import annotations |
2 | 2 |
|
3 | | -from collections.abc import Callable, Coroutine, Sequence |
| 3 | +from collections.abc import Callable, Coroutine, Mapping, Sequence |
4 | 4 | from typing import Any, Protocol |
5 | 5 |
|
6 | 6 | from codex.app_server._sync_support import _SyncRunner |
|
25 | 25 | ModelInfo, |
26 | 26 | ModelListResult, |
27 | 27 | SkillsConfigWriteResult, |
| 28 | + SkillsListEntry, |
28 | 29 | SkillsListResult, |
29 | 30 | WindowsSandboxSetupStartResult, |
30 | 31 | ) |
@@ -76,7 +77,7 @@ async def list( |
76 | 77 | cwds: Sequence[str] | None = None, |
77 | 78 | force_reload: bool | None = None, |
78 | 79 | per_cwd_extra_user_roots: Sequence[protocol.SkillsListExtraRootsForCwd] | None = None, |
79 | | - ) -> list[protocol.SkillsListEntry]: ... |
| 80 | + ) -> list[SkillsListEntry]: ... |
80 | 81 |
|
81 | 82 | async def list_page( |
82 | 83 | self, |
@@ -184,10 +185,36 @@ async def execute( |
184 | 185 | *, |
185 | 186 | command: Sequence[str], |
186 | 187 | cwd: str | None = None, |
| 188 | + disable_output_cap: bool | None = None, |
| 189 | + disable_timeout: bool | None = None, |
| 190 | + env: Mapping[str, object | None] | None = None, |
| 191 | + output_bytes_cap: int | None = None, |
| 192 | + process_id: str | None = None, |
187 | 193 | sandbox_policy: protocol.SandboxPolicy | None = None, |
| 194 | + size: protocol.CommandExecTerminalSize | None = None, |
| 195 | + stream_stdin: bool | None = None, |
| 196 | + stream_stdout_stderr: bool | None = None, |
188 | 197 | timeout_ms: int | None = None, |
| 198 | + tty: bool | None = None, |
189 | 199 | ) -> CommandExecResult: ... |
190 | 200 |
|
| 201 | + async def write_stdin( |
| 202 | + self, |
| 203 | + *, |
| 204 | + process_id: str, |
| 205 | + close_stdin: bool | None = None, |
| 206 | + delta_base64: str | None = None, |
| 207 | + ) -> EmptyResult: ... |
| 208 | + |
| 209 | + async def resize_terminal( |
| 210 | + self, |
| 211 | + *, |
| 212 | + process_id: str, |
| 213 | + size: protocol.CommandExecTerminalSize, |
| 214 | + ) -> EmptyResult: ... |
| 215 | + |
| 216 | + async def terminate_process(self, *, process_id: str) -> EmptyResult: ... |
| 217 | + |
191 | 218 |
|
192 | 219 | class _AsyncExternalAgentConfigClientLike(Protocol): |
193 | 220 | async def detect( |
@@ -312,7 +339,7 @@ def list( |
312 | 339 | cwds: Sequence[str] | None = None, |
313 | 340 | force_reload: bool | None = None, |
314 | 341 | per_cwd_extra_user_roots: Sequence[protocol.SkillsListExtraRootsForCwd] | None = None, |
315 | | - ) -> list[protocol.SkillsListEntry]: |
| 342 | + ) -> list[SkillsListEntry]: |
316 | 343 | return self._run( |
317 | 344 | self._async_client.list( |
318 | 345 | cwds=cwds, |
@@ -529,20 +556,80 @@ def execute( |
529 | 556 | *, |
530 | 557 | command: Sequence[str], |
531 | 558 | cwd: str | None = None, |
| 559 | + disable_output_cap: bool | None = None, |
| 560 | + disable_timeout: bool | None = None, |
| 561 | + env: Mapping[str, object | None] | None = None, |
| 562 | + output_bytes_cap: int | None = None, |
| 563 | + process_id: str | None = None, |
532 | 564 | sandbox_policy: protocol.SandboxPolicy | None = None, |
| 565 | + size: protocol.CommandExecTerminalSize | None = None, |
| 566 | + stream_stdin: bool | None = None, |
| 567 | + stream_stdout_stderr: bool | None = None, |
533 | 568 | timeout_ms: int | None = None, |
| 569 | + tty: bool | None = None, |
534 | 570 | ) -> CommandExecResult: |
535 | 571 | return self._run( |
536 | 572 | self._async_client.execute( |
537 | 573 | command=command, |
538 | 574 | cwd=cwd, |
| 575 | + disable_output_cap=disable_output_cap, |
| 576 | + disable_timeout=disable_timeout, |
| 577 | + env=env, |
| 578 | + output_bytes_cap=output_bytes_cap, |
| 579 | + process_id=process_id, |
539 | 580 | sandbox_policy=sandbox_policy, |
| 581 | + size=size, |
| 582 | + stream_stdin=stream_stdin, |
| 583 | + stream_stdout_stderr=stream_stdout_stderr, |
540 | 584 | timeout_ms=timeout_ms, |
| 585 | + tty=tty, |
541 | 586 | ) |
542 | 587 | ) |
543 | 588 |
|
544 | 589 | exec = execute |
545 | 590 |
|
| 591 | + def write_stdin( |
| 592 | + self, |
| 593 | + *, |
| 594 | + process_id: str, |
| 595 | + close_stdin: bool | None = None, |
| 596 | + delta_base64: str | None = None, |
| 597 | + ) -> EmptyResult: |
| 598 | + """Write stdin bytes to a running `command/exec` process or close stdin. |
| 599 | +
|
| 600 | + This wraps the app-server `command/exec/write` request. `delta_base64` |
| 601 | + is optional base64-encoded stdin data; `close_stdin` closes the |
| 602 | + process stdin after the optional write. |
| 603 | + """ |
| 604 | + return self._run( |
| 605 | + self._async_client.write_stdin( |
| 606 | + process_id=process_id, |
| 607 | + close_stdin=close_stdin, |
| 608 | + delta_base64=delta_base64, |
| 609 | + ) |
| 610 | + ) |
| 611 | + |
| 612 | + def resize_terminal( |
| 613 | + self, |
| 614 | + *, |
| 615 | + process_id: str, |
| 616 | + size: protocol.CommandExecTerminalSize, |
| 617 | + ) -> EmptyResult: |
| 618 | + """Resize the terminal attached to a running `command/exec` process. |
| 619 | +
|
| 620 | + This wraps the app-server `command/exec/resize` request and sends the |
| 621 | + new terminal dimensions as `cols` and `rows`. |
| 622 | + """ |
| 623 | + return self._run(self._async_client.resize_terminal(process_id=process_id, size=size)) |
| 624 | + |
| 625 | + def terminate_process(self, *, process_id: str) -> EmptyResult: |
| 626 | + """Terminate a running `command/exec` process. |
| 627 | +
|
| 628 | + This wraps the app-server `command/exec/terminate` request for the |
| 629 | + client-supplied process id. |
| 630 | + """ |
| 631 | + return self._run(self._async_client.terminate_process(process_id=process_id)) |
| 632 | + |
546 | 633 |
|
547 | 634 | class _ExternalAgentConfigClient(_SyncRunner): |
548 | 635 | def __init__( |
|
0 commit comments