diff --git a/src/askui/agent.py b/src/askui/agent.py index 490dd0c2..e87576c4 100644 --- a/src/askui/agent.py +++ b/src/askui/agent.py @@ -1,5 +1,4 @@ import logging -import subprocess import time import types from typing import Annotated, Literal, Optional, Type, overload @@ -533,7 +532,7 @@ def cli( ``` """ logger.debug("VisionAgent received instruction to execute '%s' on cli", command) - subprocess.run(command.split(" ")) + self.tools.os.run_command(command) @telemetry.record_call(flush=True) def close(self) -> None: diff --git a/src/askui/tools/agent_os.py b/src/askui/tools/agent_os.py index a88ddbc1..cb719899 100644 --- a/src/askui/tools/agent_os.py +++ b/src/askui/tools/agent_os.py @@ -302,3 +302,16 @@ def set_display(self, displayNumber: int = 1) -> None: Defaults to `1`. """ raise NotImplementedError + + @abstractmethod + def run_command(self, command: str, timeout_ms: int = 30000) -> None: + """ + Executes a shell command. + + Args: + command (str): The command to execute. + timeout_ms (int, optional): The timeout for command + execution in milliseconds. Defaults to `30000` (30 seconds). + + """ + raise NotImplementedError diff --git a/src/askui/tools/askui/askui_controller.py b/src/askui/tools/askui/askui_controller.py index 72f9b040..786f6a26 100644 --- a/src/askui/tools/askui/askui_controller.py +++ b/src/askui/tools/askui/askui_controller.py @@ -702,3 +702,24 @@ def set_display(self, displayNumber: int = 1) -> None: controller_v1_pbs.Request_SetActiveDisplay(displayID=displayNumber) ) self._display = displayNumber + + @telemetry.record_call(exclude={"command"}) + @override + def run_command(self, command: str, timeout_ms: int = 30000) -> None: + """ + Execute a shell command. + + Args: + command (str): The command to execute. + timeout_ms (int, optional): The timeout for command + execution in milliseconds. Defaults to `30000` (30 seconds). + """ + self._reporter.add_message("AgentOS", f'run_command("{command}", {timeout_ms})') + self._run_recorder_action( + acion_class_id=controller_v1_pbs.ActionClassID_RunCommand, + action_parameters=controller_v1_pbs.ActionParameters( + runcommand=controller_v1_pbs.ActionParameters_RunCommand( + command=command, timeoutInMilliseconds=timeout_ms + ) + ), + )