Tools
askui.tools.AgentOs
Abstract base class for Agent OS. Cannot be instantiated directly.
This class defines the interface for operating system interactions including mouse control, keyboard input, and screen capture functionality. Implementations should provide concrete functionality for these abstract methods.
click
Simulates clicking a mouse button.
Arguments:
button
Literal[“left”, “middle”, “right”], optional - The mouse button to click. Defaults to"left"
.count
int, optional - Number of times to click. Defaults to1
.
connect
Establishes a connection to the Agent OS.
This method is called before performing any OS-level operations. It handles any necessary setup or initialization required for the OS interaction.
disconnect
Terminates the connection to the Agent OS.
This method is called after all OS-level operations are complete. It handles any necessary cleanup or resource release.
keyboard_pressed
Simulates pressing and holding a keyboard key.
Arguments:
key
PcKey | ModifierKey - The key to press.modifier_keys
list[ModifierKey] | None, optional - List of modifier keys to press along with the main key. Defaults toNone
.
keyboard_release
Simulates releasing a keyboard key.
Arguments:
key
PcKey | ModifierKey - The key to release.modifier_keys
list[ModifierKey] | None, optional - List of modifier keys to release along with the main key. Defaults toNone
.
keyboard_tap
Simulates pressing and immediately releasing a keyboard key.
Arguments:
key
PcKey | ModifierKey - The key to tap.modifier_keys
list[ModifierKey] | None, optional - List of modifier keys to press along with the main key. Defaults toNone
.count
int, optional - The number of times to tap the key. Defaults to1
.
mouse
Moves the mouse cursor to specified screen coordinates.
Arguments:
x
int - The horizontal coordinate (in pixels) to move to.y
int - The vertical coordinate (in pixels) to move to.
mouse_down
Simulates pressing and holding a mouse button.
Arguments:
button
Literal[“left”, “middle”, “right”], optional - The mouse button to press. Defaults to"left"
.
mouse_scroll
Simulates scrolling the mouse wheel.
Arguments:
x
int - The horizontal scroll amount. Positive values scroll right, negative values scroll left.y
int - The vertical scroll amount. Positive values scroll down, negative values scroll up.
mouse_up
Simulates releasing a mouse button.
Arguments:
button
Literal[“left”, “middle”, “right”], optional - The mouse button to release. Defaults to"left"
.
screenshot
Captures a screenshot of the current display.
Arguments:
report
bool, optional - Whether to include the screenshot in reporting. Defaults toTrue
.
Returns:
Image.Image
- A PIL Image object containing the screenshot.
set_display
Sets the active display for screen interactions.
Arguments:
displayNumber
int, optional - The display number to set as active. Defaults to1
.
type
Simulates typing text as if entered on a keyboard.
Arguments:
text
str - The text to be typed.typing_speed
int, optional - The speed of typing in characters per minute. Defaults to50
.
askui.tools.askui.AskUiControllerClient
Implementation of AgentOs
that communicates with the AskUI Remote Device Controller via gRPC.
Arguments:
reporter
Reporter - Reporter used for reporting with the"AgentOs"
.display
int, optional - Display number to use. Defaults to1
.controller_server
AskUiControllerServer | None, optional - Custom controller server. Defaults toControllerServer
.
__enter__
Context manager entry point that establishes the connection.
Returns:
Self
- The instance of AskUiControllerClient.
__exit__
Context manager exit point that disconnects the client.
Arguments:
exc_type
- The exception type if an exception was raised.exc_value
- The exception value if an exception was raised.traceback
- The traceback if an exception was raised.
click
Simulates clicking a mouse button.
Arguments:
button
Literal[“left”, “middle”, “right”], optional - The mouse button to click. Defaults to"left"
.count
int, optional - Number of times to click. Defaults to1
.
connect
Establishes a connection to the AskUI Remote Device Controller.
This method starts the controller server, establishes a gRPC channel, creates a session, and sets up the initial display.
disconnect
Terminates the connection to the AskUI Remote Device Controller.
This method stops the execution, ends the session, closes the gRPC channel, and stops the controller server.
keyboard_pressed
Simulates pressing and holding a keyboard key.
Arguments:
key
PcKey | ModifierKey - The key to press.modifier_keys
list[ModifierKey] | None, optional - List of modifier keys to press along with the main key. Defaults toNone
.
keyboard_release
Simulates releasing a keyboard key.
Arguments:
key
PcKey | ModifierKey - The key to release.modifier_keys
list[ModifierKey] | None, optional - List of modifier keys to release along with the main key. Defaults toNone
.
keyboard_tap
Press and immediately release a keyboard key.
Arguments:
key
PcKey | ModifierKey - The key to tap.modifier_keys
list[ModifierKey] | None, optional - List of modifier keys to press along with the main key. Defaults toNone
.count
int, optional - The number of times to tap the key. Defaults to1
.
mouse
Moves the mouse cursor to specified screen coordinates.
Arguments:
x
int - The horizontal coordinate (in pixels) to move to.y
int - The vertical coordinate (in pixels) to move to.
mouse_down
Simulates pressing and holding a mouse button.
Arguments:
button
Literal[“left”, “middle”, “right”], optional - The mouse button to press. Defaults to"left"
.
mouse_scroll
Simulates scrolling the mouse wheel.
Arguments:
x
int - The horizontal scroll amount. Positive values scroll right, negative values scroll left.y
int - The vertical scroll amount. Positive values scroll down, negative values scroll up.
mouse_up
Simulates releasing a mouse button.
Arguments:
button
Literal[“left”, “middle”, “right”], optional - The mouse button to release. Defaults to"left"
.
screenshot
Captures a screenshot of the current display.
Arguments:
report
bool, optional - Whether to include the screenshot in reporting. Defaults toTrue
.
Returns:
Image.Image
- A PIL Image object containing the screenshot.
set_display
Sets the active display for screen interactions.
Arguments:
displayNumber
int, optional - The display number to set as active. Defaults to1
.
type
Simulates typing text as if entered on a keyboard.
Arguments:
text
str - The text to be typed.typing_speed
int, optional - The speed of typing in characters per second. Defaults to50
.
askui.tools.askui.exceptions.AskUiControllerError
Base exception for AskUI controller errors.
This exception is raised when there is an error in the AskUI controller (client), which handles the communication with the AskUI controller (server).
Arguments:
message
str - The error message.
askui.tools.askui.exceptions.AskUiControllerOperationFailedError
Exception raised when a controller operation fails.
This exception is raised when a specific operation in the AskUI controller fails, such as starting/stopping the controller or executing an action.
Arguments:
operation
str - The operation that failed.error
Exception - The original error that caused the failure.
askui.tools.askui.exceptions.AskUiControllerOperationTimeoutError
Exception raised when a controller action times out.
This exception is raised when an action in the AskUI controller takes longer than the expected timeout period to complete.
Arguments:
message
str - The error message.timeout_seconds
float | None - Optional timeout duration in seconds.
askui.tools.askui.AskUiControllerServer
Concrete implementation of ControllerServer
for managing the AskUI Remote Device Controller process.
Handles process discovery, startup, and shutdown for the native controller binary.
start
Start the controller process.
Arguments:
clean_up
bool, optional - Whether to clean up existing processes (only on Windows) before starting. Defaults toFalse
.
stop
Stop the controller process.
Arguments:
force
bool, optional - Whether to forcefully terminate the process. Defaults toFalse
.
askui.tools.exceptions.ToolError
Raised when a tool encounters an error.
Arguments:
message
str - The error message.result
ToolResult - The ToolResult that caused the error.
askui.tools.exceptions.ToolResult
Represents the result of a tool execution.
Arguments:
output
str | None, optional - The output of the tool.error
str | None, optional - The error message of the tool.base64_image
str | None, optional - The base64 image of the tool.system
str | None, optional - The system message of the tool.