Tools

class Tools(ABC)
Abstract base class for all tools. This class provides a common interface for all tools to implement.

Tools.ui_action

def ui_action(func)
” Decorator to capture screenshots and UI states for actions that modify the UI.

Tools.get_state

def get_state() -> Dict[str, Any]
Get the current state of the tool.

Tools.tap_by_index

def tap_by_index(index: int) -> str
Tap the element at the given index.

Tools.swipe

def swipe(
    start_x: int,
    start_y: int,
    end_x: int,
    end_y: int,
    duration_ms: int = 300
) -> bool
Swipe from the given start coordinates to the given end coordinates.

Tools.drag

def drag(
    start_x: int,
    start_y: int,
    end_x: int,
    end_y: int,
    duration_ms: int = 3000
) -> bool
Drag from the given start coordinates to the given end coordinates.

Tools.input_text

def input_text(text: str) -> str
Input the given text into a focused input field.

Tools.back

def back() -> str
Press the back button.

Tools.press_key

def press_key(keycode: int) -> str
Enter the given keycode.

Tools.start_app

def start_app(package: str, activity: str = "") -> str
Start the given app.

Tools.take_screenshot

def take_screenshot() -> Tuple[str, bytes]
Take a screenshot of the device.

Tools.list_packages

def list_packages(include_system_apps: bool = False) -> List[str]
List all packages on the device.

Tools.remember

def remember(information: str) -> str
Remember the given information. This is used to store information in the tool’s memory.

Tools.get_memory

def get_memory() -> List[str]
Get the memory of the tool.

Tools.complete

def complete(success: bool, reason: str = "") -> None
Complete the tool. This is used to indicate that the tool has completed its task.

describe_tools

def describe_tools(
    tools: Tools,
    exclude_tools: Optional[List[str]] = None
) -> Dict[str, Callable[..., Any]]
Describe the tools available for the given Tools instance. Arguments:
  • tools - The Tools instance to describe.
  • exclude_tools - List of tool names to exclude from the description.
Returns: A dictionary mapping tool names to their descriptions.