Skip to content

Commit 7a1ca29

Browse files
committed
fix(app-server): clarify command control APIs
1 parent 0b8d020 commit 7a1ca29

3 files changed

Lines changed: 40 additions & 12 deletions

File tree

codex/app_server/_async_services.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -377,16 +377,26 @@ async def write_stdin(
377377
)
378378
return await self._rpc.request_typed("command/exec/write", params, EmptyResult)
379379

380-
async def resize(
380+
async def resize_terminal(
381381
self,
382382
*,
383383
process_id: str,
384384
size: protocol.CommandExecTerminalSize,
385385
) -> EmptyResult:
386+
"""Resize the terminal attached to a running `command/exec` process.
387+
388+
This wraps the app-server `command/exec/resize` request and sends the
389+
new terminal dimensions as `cols` and `rows`.
390+
"""
386391
params = protocol.CommandExecResizeParams(processId=process_id, size=size)
387392
return await self._rpc.request_typed("command/exec/resize", params, EmptyResult)
388393

389-
async def terminate(self, *, process_id: str) -> EmptyResult:
394+
async def terminate_process(self, *, process_id: str) -> EmptyResult:
395+
"""Terminate a running `command/exec` process.
396+
397+
This wraps the app-server `command/exec/terminate` request for the
398+
client-supplied process id.
399+
"""
390400
params = protocol.CommandExecTerminateParams(processId=process_id)
391401
return await self._rpc.request_typed("command/exec/terminate", params, EmptyResult)
392402

codex/app_server/_sync_services.py

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -206,14 +206,14 @@ async def write_stdin(
206206
delta_base64: str | None = None,
207207
) -> EmptyResult: ...
208208

209-
async def resize(
209+
async def resize_terminal(
210210
self,
211211
*,
212212
process_id: str,
213213
size: protocol.CommandExecTerminalSize,
214214
) -> EmptyResult: ...
215215

216-
async def terminate(self, *, process_id: str) -> EmptyResult: ...
216+
async def terminate_process(self, *, process_id: str) -> EmptyResult: ...
217217

218218

219219
class _AsyncExternalAgentConfigClientLike(Protocol):
@@ -609,16 +609,26 @@ def write_stdin(
609609
)
610610
)
611611

612-
def resize(
612+
def resize_terminal(
613613
self,
614614
*,
615615
process_id: str,
616616
size: protocol.CommandExecTerminalSize,
617617
) -> EmptyResult:
618-
return self._run(self._async_client.resize(process_id=process_id, size=size))
618+
"""Resize the terminal attached to a running `command/exec` process.
619619
620-
def terminate(self, *, process_id: str) -> EmptyResult:
621-
return self._run(self._async_client.terminate(process_id=process_id))
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))
622632

623633

624634
class _ExternalAgentConfigClient(_SyncRunner):

tests/test_app_server_client.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1943,11 +1943,11 @@ def command_terminate(message: JsonObject) -> JsonObject:
19431943
delta_base64="aGVsbG8K",
19441944
close_stdin=True,
19451945
)
1946-
resized = await client.command.resize(
1946+
resized = await client.command.resize_terminal(
19471947
process_id="proc-1",
19481948
size=protocol.CommandExecTerminalSize(cols=100, rows=30),
19491949
)
1950-
terminated = await client.command.terminate(process_id="proc-1")
1950+
terminated = await client.command.terminate_process(process_id="proc-1")
19511951

19521952
assert result.exit_code == 0
19531953
assert wrote == EmptyResult()
@@ -2595,11 +2595,19 @@ def login_account(message: JsonObject) -> JsonObject:
25952595
assert client.command.write_stdin.__doc__ is not None
25962596
assert "command/exec/write" in client.command.write_stdin.__doc__
25972597
assert "stdin" in client.command.write_stdin.__doc__
2598-
assert tuple(inspect.signature(client.command.resize).parameters) == (
2598+
assert tuple(inspect.signature(client.command.resize_terminal).parameters) == (
25992599
"process_id",
26002600
"size",
26012601
)
2602-
assert tuple(inspect.signature(client.command.terminate).parameters) == ("process_id",)
2602+
assert client.command.resize_terminal.__doc__ is not None
2603+
assert "command/exec/resize" in client.command.resize_terminal.__doc__
2604+
assert "terminal" in client.command.resize_terminal.__doc__
2605+
assert tuple(inspect.signature(client.command.terminate_process).parameters) == (
2606+
"process_id",
2607+
)
2608+
assert client.command.terminate_process.__doc__ is not None
2609+
assert "command/exec/terminate" in client.command.terminate_process.__doc__
2610+
assert "process" in client.command.terminate_process.__doc__
26032611
assert tuple(inspect.signature(client.account.login_chatgpt_tokens).parameters) == (
26042612
"access_token",
26052613
"chatgpt_account_id",

0 commit comments

Comments
 (0)