UI Actions - Core UI interaction tools for Android device control.

AdbTools

class AdbTools(Tools)

Core UI interaction tools for Android device control.

AdbTools.__init__

def __init__(serial: str) -> None

Initialize the AdbTools instance.

Arguments:

  • serial - Device serial number

AdbTools.create

async def create(cls: Type[Self], serial: str = None) -> Self

Create an AdbTools instance.

Arguments:

  • serial - Optional device serial number. If not provided, the first device found will be used.

Returns:

AdbTools instance

AdbTools.tap_by_index

async def tap_by_index(index: int, serial: Optional[str] = None) -> str

Tap on a UI element by its index.

This function uses the cached clickable elements to find the element with the given index and tap on its center coordinates.

Arguments:

  • index - Index of the element to tap

Returns:

Result message

AdbTools.tap_by_coordinates

async def tap_by_coordinates(x: int, y: int) -> bool

Tap on the device screen at specific coordinates.

Arguments:

  • x - X coordinate
  • y - Y coordinate

Returns:

Bool indicating success or failure

AdbTools.tap

async def tap(index: int) -> str

Tap on a UI element by its index.

This function uses the cached clickable elements from the last get_clickables call to find the element with the given index and tap on its center coordinates.

Arguments:

  • index - Index of the element to tap

Returns:

Result message

AdbTools.swipe

async def swipe(
    start_x: int,
    start_y: int,
    end_x: int,
    end_y: int,
    duration_ms: int = 300
) -> bool

Performs a straight-line swipe gesture on the device screen. To perform a hold (long press), set the start and end coordinates to the same values and increase the duration as needed.

Arguments:

  • start_x - Starting X coordinate
  • start_y - Starting Y coordinate
  • end_x - Ending X coordinate
  • end_y - Ending Y coordinate
  • duration_ms - Duration of swipe in milliseconds

Returns:

Bool indicating success or failure

AdbTools.input_text

async def input_text(text: str, serial: Optional[str] = None) -> str

Input text on the device. Always make sure that the Focused Element is not None before inputting text.

Arguments:

  • text - Text to input. Can contain spaces, newlines, and special characters including non-ASCII.

Returns:

Result message

AdbTools.back

async def back() -> str

Go back on the current view. This presses the Android back button.

AdbTools.press_key

async def press_key(keycode: int) -> str

Press a key on the Android device.

Common keycodes:

  • 3: HOME
  • 4: BACK
  • 66: ENTER
  • 67: DELETE

Arguments:

  • keycode - Android keycode to press

AdbTools.start_app

async def start_app(package: str, activity: str = "") -> str

Start an app on the device.

Arguments:

  • package - Package name (e.g., “com.android.settings”)
  • activity - Optional activity name

AdbTools.install_app

async def install_app(
    apk_path: str,
    reinstall: bool = False,
    grant_permissions: bool = True
) -> str

Install an app on the device.

Arguments:

  • apk_path - Path to the APK file
  • reinstall - Whether to reinstall if app exists
  • grant_permissions - Whether to grant all permissions

AdbTools.take_screenshot

async def take_screenshot() -> Tuple[str, bytes]

Take a screenshot of the device. This function captures the current screen and adds the screenshot to context in the next message. Also stores the screenshot in the screenshots list with timestamp for later GIF creation.

AdbTools.list_packages

async def list_packages(include_system_apps: bool = False) -> List[str]

List installed packages on the device.

Arguments:

  • include_system_apps - Whether to include system apps (default: False)

Returns:

List of package names

AdbTools.complete

def complete(success: bool, reason: str = "")

Mark the task as finished.

Arguments:

  • success - Indicates if the task was successful.
  • reason - Reason for failure/success

AdbTools.remember

async def remember(information: str) -> str

Store important information to remember for future context.

This information will be extracted and included into your next steps to maintain context across interactions. Use this for critical facts, observations, or user preferences that should influence future decisions.

Arguments:

  • information - The information to remember

Returns:

Confirmation message

AdbTools.get_memory

def get_memory() -> List[str]

Retrieve all stored memory items.

Returns:

List of stored memory items

AdbTools.get_state

async def get_state(serial: Optional[str] = None) -> Dict[str, Any]

Get both the a11y tree and phone state in a single call using the combined /state endpoint.

Arguments:

  • serial - Optional device serial number

Returns:

Dictionary containing both ‘a11y_tree’ and ‘phone_state’ data

UI Actions - Core UI interaction tools for Android device control.

AdbTools

class AdbTools(Tools)

Core UI interaction tools for Android device control.

AdbTools.__init__

def __init__(serial: str) -> None

Initialize the AdbTools instance.

Arguments:

  • serial - Device serial number

AdbTools.create

async def create(cls: Type[Self], serial: str = None) -> Self

Create an AdbTools instance.

Arguments:

  • serial - Optional device serial number. If not provided, the first device found will be used.

Returns:

AdbTools instance

AdbTools.tap_by_index

async def tap_by_index(index: int, serial: Optional[str] = None) -> str

Tap on a UI element by its index.

This function uses the cached clickable elements to find the element with the given index and tap on its center coordinates.

Arguments:

  • index - Index of the element to tap

Returns:

Result message

AdbTools.tap_by_coordinates

async def tap_by_coordinates(x: int, y: int) -> bool

Tap on the device screen at specific coordinates.

Arguments:

  • x - X coordinate
  • y - Y coordinate

Returns:

Bool indicating success or failure

AdbTools.tap

async def tap(index: int) -> str

Tap on a UI element by its index.

This function uses the cached clickable elements from the last get_clickables call to find the element with the given index and tap on its center coordinates.

Arguments:

  • index - Index of the element to tap

Returns:

Result message

AdbTools.swipe

async def swipe(
    start_x: int,
    start_y: int,
    end_x: int,
    end_y: int,
    duration_ms: int = 300
) -> bool

Performs a straight-line swipe gesture on the device screen. To perform a hold (long press), set the start and end coordinates to the same values and increase the duration as needed.

Arguments:

  • start_x - Starting X coordinate
  • start_y - Starting Y coordinate
  • end_x - Ending X coordinate
  • end_y - Ending Y coordinate
  • duration_ms - Duration of swipe in milliseconds

Returns:

Bool indicating success or failure

AdbTools.input_text

async def input_text(text: str, serial: Optional[str] = None) -> str

Input text on the device. Always make sure that the Focused Element is not None before inputting text.

Arguments:

  • text - Text to input. Can contain spaces, newlines, and special characters including non-ASCII.

Returns:

Result message

AdbTools.back

async def back() -> str

Go back on the current view. This presses the Android back button.

AdbTools.press_key

async def press_key(keycode: int) -> str

Press a key on the Android device.

Common keycodes:

  • 3: HOME
  • 4: BACK
  • 66: ENTER
  • 67: DELETE

Arguments:

  • keycode - Android keycode to press

AdbTools.start_app

async def start_app(package: str, activity: str = "") -> str

Start an app on the device.

Arguments:

  • package - Package name (e.g., “com.android.settings”)
  • activity - Optional activity name

AdbTools.install_app

async def install_app(
    apk_path: str,
    reinstall: bool = False,
    grant_permissions: bool = True
) -> str

Install an app on the device.

Arguments:

  • apk_path - Path to the APK file
  • reinstall - Whether to reinstall if app exists
  • grant_permissions - Whether to grant all permissions

AdbTools.take_screenshot

async def take_screenshot() -> Tuple[str, bytes]

Take a screenshot of the device. This function captures the current screen and adds the screenshot to context in the next message. Also stores the screenshot in the screenshots list with timestamp for later GIF creation.

AdbTools.list_packages

async def list_packages(include_system_apps: bool = False) -> List[str]

List installed packages on the device.

Arguments:

  • include_system_apps - Whether to include system apps (default: False)

Returns:

List of package names

AdbTools.complete

def complete(success: bool, reason: str = "")

Mark the task as finished.

Arguments:

  • success - Indicates if the task was successful.
  • reason - Reason for failure/success

AdbTools.remember

async def remember(information: str) -> str

Store important information to remember for future context.

This information will be extracted and included into your next steps to maintain context across interactions. Use this for critical facts, observations, or user preferences that should influence future decisions.

Arguments:

  • information - The information to remember

Returns:

Confirmation message

AdbTools.get_memory

def get_memory() -> List[str]

Retrieve all stored memory items.

Returns:

List of stored memory items

AdbTools.get_state

async def get_state(serial: Optional[str] = None) -> Dict[str, Any]

Get both the a11y tree and phone state in a single call using the combined /state endpoint.

Arguments:

  • serial - Optional device serial number

Returns:

Dictionary containing both ‘a11y_tree’ and ‘phone_state’ data