| 5 | |
| 6 | @register_tool("mobile_use") |
| 7 | class MobileUse(BaseTool): |
| 8 | @property |
| 9 | def description(self): |
| 10 | return f""" |
| 11 | Use a touchscreen to interact with a mobile device, and take screenshots. |
| 12 | * This is an interface to a mobile device with touchscreen. You can perform actions like clicking, typing, swiping, etc. |
| 13 | * Some applications may take time to start or process actions, so you may need to wait and take successive screenshots to see the results of your actions. |
| 14 | * The screen's resolution is {self.display_width_px}x{self.display_height_px}. |
| 15 | * Make sure to click any buttons, links, icons, etc with the cursor tip in the center of the element. Don't click boxes on their edges unless asked. |
| 16 | """.strip() |
| 17 | |
| 18 | parameters = { |
| 19 | "properties": { |
| 20 | "action": { |
| 21 | "description": """ |
| 22 | The action to perform. The available actions are: |
| 23 | * `key`: Perform a key event on the mobile device. |
| 24 | - This supports adb's `keyevent` syntax. |
| 25 | - Examples: "volume_up", "volume_down", "power", "camera", "clear". |
| 26 | * `click`: Click the point on the screen with coordinate (x, y). |
| 27 | * `long_press`: Press the point on the screen with coordinate (x, y) for specified seconds. |
| 28 | * `swipe`: Swipe from the starting point with coordinate (x, y) to the end point with coordinates2 (x2, y2). |
| 29 | * `type`: Input the specified text into the activated input box. |
| 30 | * `system_button`: Press the system button. |
| 31 | * `open`: Open an app on the device. |
| 32 | * `wait`: Wait specified seconds for the change to happen. |
| 33 | * `terminate`: Terminate the current task and report its completion status. |
| 34 | """.strip(), |
| 35 | "enum": [ |
| 36 | "key", |
| 37 | "click", |
| 38 | "long_press", |
| 39 | "swipe", |
| 40 | "type", |
| 41 | "system_button", |
| 42 | "open", |
| 43 | "wait", |
| 44 | "terminate", |
| 45 | ], |
| 46 | "type": "string", |
| 47 | }, |
| 48 | "coordinate": { |
| 49 | "description": "(x, y): The x (pixels from the left edge) and y (pixels from the top edge) coordinates to move the mouse to. Required only by `action=click`, `action=long_press`, and `action=swipe`.", |
| 50 | "type": "array", |
| 51 | }, |
| 52 | "coordinate2": { |
| 53 | "description": "(x, y): The x (pixels from the left edge) and y (pixels from the top edge) coordinates to move the mouse to. Required only by `action=swipe`.", |
| 54 | "type": "array", |
| 55 | }, |
| 56 | "text": { |
| 57 | "description": "Required only by `action=key`, `action=type`, and `action=open`.", |
| 58 | "type": "string", |
| 59 | }, |
| 60 | "time": { |
| 61 | "description": "The seconds to wait. Required only by `action=long_press` and `action=wait`.", |
| 62 | "type": "number", |
| 63 | }, |
| 64 | "button": { |
no outgoing calls
no test coverage detected