Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions src/askui/agent.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import logging
import subprocess
import time
import types
from typing import Annotated, Literal, Optional, Type, overload
Expand Down Expand Up @@ -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:
Expand Down
13 changes: 13 additions & 0 deletions src/askui/tools/agent_os.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
21 changes: 21 additions & 0 deletions src/askui/tools/askui/askui_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
),
)