From 67ea7b4ee6e4063191ed9cbf9bb884f839269c85 Mon Sep 17 00:00:00 2001 From: onur-askui <210008309+onur-askui@users.noreply.github.com> Date: Fri, 30 May 2025 14:50:47 +0200 Subject: [PATCH 1/3] feat: forward cli command to agentos --- src/askui/agent.py | 3 +-- src/askui/tools/agent_os.py | 13 +++++++++++++ src/askui/tools/askui/askui_controller.py | 23 +++++++++++++++++++++++ 3 files changed, 37 insertions(+), 2 deletions(-) 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..54f794ac 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_in_milliseconds: int = 30000) -> None: + """ + Executes a shell command. + + Args: + command (str): The command to execute. + timeout_in_milliseconds (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..8816192b 100644 --- a/src/askui/tools/askui/askui_controller.py +++ b/src/askui/tools/askui/askui_controller.py @@ -702,3 +702,26 @@ def set_display(self, displayNumber: int = 1) -> None: controller_v1_pbs.Request_SetActiveDisplay(displayID=displayNumber) ) self._display = displayNumber + + @telemetry.record_call() + @override + def run_command(self, command: str, timeout_in_milliseconds: int = 30000) -> None: + """ + Execute a shell command and return the output. + + Args: + command (str): The command to execute. + timeout_in_milliseconds (int, optional): The timeout for command + execution in milliseconds. Defaults to `30000` (30 seconds). + """ + self._reporter.add_message( + "AgentOS", f'run_command("{command}", timeout:{timeout_in_milliseconds})' + ) + 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_in_milliseconds + ) + ), + ) From 16f9de6afbf024dd835cff5e82dc0b19c4b30ec5 Mon Sep 17 00:00:00 2001 From: onur-askui <210008309+onur-askui@users.noreply.github.com> Date: Mon, 2 Jun 2025 09:40:42 +0200 Subject: [PATCH 2/3] refactor: rename timeout parameter and remove telemetry for run_command --- src/askui/tools/agent_os.py | 4 ++-- src/askui/tools/askui/askui_controller.py | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/askui/tools/agent_os.py b/src/askui/tools/agent_os.py index 54f794ac..cb719899 100644 --- a/src/askui/tools/agent_os.py +++ b/src/askui/tools/agent_os.py @@ -304,13 +304,13 @@ def set_display(self, displayNumber: int = 1) -> None: raise NotImplementedError @abstractmethod - def run_command(self, command: str, timeout_in_milliseconds: int = 30000) -> None: + def run_command(self, command: str, timeout_ms: int = 30000) -> None: """ Executes a shell command. Args: command (str): The command to execute. - timeout_in_milliseconds (int, optional): The timeout for command + timeout_ms (int, optional): The timeout for command execution in milliseconds. Defaults to `30000` (30 seconds). """ diff --git a/src/askui/tools/askui/askui_controller.py b/src/askui/tools/askui/askui_controller.py index 8816192b..605cf798 100644 --- a/src/askui/tools/askui/askui_controller.py +++ b/src/askui/tools/askui/askui_controller.py @@ -703,25 +703,25 @@ def set_display(self, displayNumber: int = 1) -> None: ) self._display = displayNumber - @telemetry.record_call() + @telemetry.record_call(exclude={"command"}) @override - def run_command(self, command: str, timeout_in_milliseconds: int = 30000) -> None: + def run_command(self, command: str, timeout_ms: int = 30000) -> None: """ - Execute a shell command and return the output. + Execute a shell command. Args: command (str): The command to execute. - timeout_in_milliseconds (int, optional): The timeout for command + 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:{timeout_in_milliseconds})' + "AgentOS", f'run_command("{command}", timeout:{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_in_milliseconds + command=command, timeoutInMilliseconds=timeout_ms ) ), ) From 5196ec01529b433d2710fe0e899c61f2df3009bc Mon Sep 17 00:00:00 2001 From: Onur <210008309+onur-askui@users.noreply.github.com> Date: Mon, 2 Jun 2025 10:23:12 +0200 Subject: [PATCH 3/3] Update src/askui/tools/askui/askui_controller.py Co-authored-by: adi-wan-askui <105295410+adi-wan-askui@users.noreply.github.com> --- src/askui/tools/askui/askui_controller.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/askui/tools/askui/askui_controller.py b/src/askui/tools/askui/askui_controller.py index 605cf798..786f6a26 100644 --- a/src/askui/tools/askui/askui_controller.py +++ b/src/askui/tools/askui/askui_controller.py @@ -714,9 +714,7 @@ def run_command(self, command: str, timeout_ms: int = 30000) -> None: 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:{timeout_ms})' - ) + 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(