Android REPL
Use this skill to drive an Android device through the public agent-android beta surface published in the aivanelabs/ai-rpa repo.
Runtime prerequisites:
agent-android is available on PATH
- if it is missing, install the CLI with
uv tool install aivane-agent-android; then run uv tool update-shell if the command is still not found
- the user has provided a trusted device URL such as
http://<device-ip>:8080; use the phone-side configured port if it is not 8080
The public path is local-first:
- the phone hosts the lightweight HTTP service locally
- the desktop connects directly to the phone URL, usually
http://<device-ip>:8080
- UI reads, taps, inputs, and screenshots stay on the phone and controlling machine
- the current tradeoff is LAN-only control; an optional server-side or relay path may arrive later
If an agent-android command suddenly stops working, first check whether the AIVane app or its local API service has exited on the phone.
Safety Boundaries
- Connect only to a device URL explicitly provided by the user.
- Do not scan local networks or guess device IP addresses.
- Treat UI trees and screenshots as sensitive because they may contain private app content.
- Save screenshots or raw UI dumps only when the user explicitly asks for a file output.
- Ask for confirmation before operating sensitive apps, private content, account settings, or irreversible actions.
- Do not expose the phone-side service on a public network.
Core Workflow
Every Android control task should follow the same short loop:
- Confirm connectivity with
/health
- Discover the target app with
apps if needed
- Launch one app
- Inspect the current UI tree
- Perform one action
- Inspect again
Keep the loop short. Prefer inspect -> act -> inspect over long speculative command chains.
Quick Start
Start the REPL with the user-provided device URL:
agent-android --repl --url http://<device-ip>:8080
Built-in help:
agent-android --help
- In the REPL:
h
Essential CLI Commands
Use the one-off CLI when you already know the exact action you want.
Connectivity:
agent-android --health --url http://<device-ip>:8080
Discovery:
agent-android --apps --url http://<device-ip>:8080
agent-android --list --url http://<device-ip>:8080
agent-android --id com.example:id/search --url http://<device-ip>:8080
agent-android --text Search --url http://<device-ip>:8080
agent-android --inputs --url http://<device-ip>:8080
agent-android --refId 7 --url http://<device-ip>:8080
agent-android --xpath 7 --url http://<device-ip>:8080
agent-android --get-attr 7 text --url http://<device-ip>:8080
Actions:
agent-android --launch com.xingin.xhs --url http://<device-ip>:8080
agent-android --tap 7 --url http://<device-ip>:8080
agent-android --input 7 "hello world" --url http://<device-ip>:8080
agent-android --swipe up --url http://<device-ip>:8080
agent-android --swipe up --swipe-refid 7 --url http://<device-ip>:8080
agent-android --swipe up --swipe-xpath "//RecyclerView[1]" --url http://<device-ip>:8080
agent-android --back --url http://<device-ip>:8080
agent-android --press home --url http://<device-ip>:8080
agent-android --screenshot --url http://<device-ip>:8080
agent-android --application-bundle app.zip --main-template-file __main__.json --url http://<device-ip>:8080
agent-android --template template.json --async --url http://<device-ip>:8080
agent-android --application-bundle app.zip --main-template-file __main__.json --async --url http://<device-ip>:8080
agent-android --upload foo.json --remote-path Templates/foo.json --url http://<device-ip>:8080
Waiting and output:
agent-android --wait-for Search --timeout 30 --url http://<device-ip>:8080
agent-android --list --raw --url http://<device-ip>:8080
agent-android --tasks --url http://<device-ip>:8080
agent-android --task TASK_ID --url http://<device-ip>:8080
agent-android --task-logs TASK_ID --url http://<device-ip>:8080
agent-android --stop-task TASK_ID --url http://<device-ip>:8080
REPL Command Reference
Use the REPL for exploratory tasks and smoke runs. Short aliases and long names both work.
Browse
health or hl
Check /health.
l [n] or list [n]
List the first n elements, or all cached elements when n is omitted.
ss or snapshot
Force-refresh the UI tree and print it again.
f <text> or find <text>
Filter by text or content description.
id <resourceId>
Filter by Android resource ID.
ref <refId>
Show the full element detail for one refId.
x <refId> or xpath <refId>
Generate XPath candidates and validate their runtime match counts.
xx <refId>
Tap by the best unique generated XPath candidate. Refuses ambiguous matches.
vx <xpath> [idx] or validatex <xpath> [idx]
Validate one XPath against the runtime. Optionally inspect one match by zero-based index.
Interact
t <refId> or tap <refId>
Tap the element center point from the current tree.
tx <xpath> or tapx <xpath>
Tap one runtime-resolved XPath target.
i <refId> <text> or input <refId> <text>
Input text into a refId target.
Use --clear or "" to clear instead of typing.
ix <xpath> <text> or inputx <xpath> <text>
Input text into one XPath target.
Use ix <xpath> -- or --clear to clear the field.
sw <d|u|l|r> [refId] [--dur N] [--dist N] or swipe ...
Swipe down/up/left/right across the screen, or inside a refId target when provided.
swx <d|u|l|r> <xpath> [--dur N] [--dist N] or swipex ...
Swipe inside one XPath target.
p <back|home|recents> or press ...
Press a system key.
b or back
Press Back.
la <package> or launch <package>
Launch an app by package name.
s [path] or screenshot [path]
Capture a screenshot to an auto-generated or explicit path.
up <local> <path> or upload <local> <path>
Upload a local file to the phone. Overwrites by default; add --no-overwrite to reject an existing target.
Wait And Inspect
wf <text> [--t N] or waitfor ...
Wait for an element to appear.
g <refId> <attr> or get <refId> <attr>
Read an attribute such as text, class, bounds, x, y, or xpath.
apps
List launcher apps from /apps.
Session
raw
Toggle raw JSON mode.
vars
Show current URL, timeout, raw mode, and tree cache state.
set timeout 30
Set the default wait timeout in seconds.
h or help
Show the built-in help text.
q or quit
Exit the REPL.
Common Patterns
First smoke flow
- Start the REPL with
agent-android --repl --url http://<device-ip>:8080.
health
apps
la <package>
l
t <refId>
i <refId> hello
b
s
Find the right package before launch
apps
la com.example.app
l
Inspect an element before using XPath
l
ref 12
x 12
vx //EditText[@text='Search']
Clear and refill an input
i 7 --clear
i 7 hello world
ix //EditText[@text='Search'] --
ix //EditText[@text='Search'] -- hello world
Run a local template bundle
- Zip the local folder containing the main template and child templates.
- Run
agent-android --application-bundle app.zip --main-template-file __main__.json --url http://<device-ip>:8080.
- Use
--upload only for standalone images, ordinary binary files, or one-off file sync.
Troubleshooting
- If an
agent-android command fails, first check whether the AIVane app or phone-side API service has exited.
- If
agent-android is not found, run uv tool update-shell, reopen the terminal, and retry.
- Re-open the app or restart the phone-side service, then retry
curl http://<device-ip>:8080/health.
- If
health works but UI commands fail, run ss to force-refresh the tree before tapping or inputting.
- If
tx or ix fails, run vx <xpath> and make sure the XPath resolves to exactly one runtime match.
- If screenshots fail the first time, confirm the on-device MediaProjection permission prompt was accepted.
- If everything suddenly stops responding, confirm the phone IP did not change and that the desktop is still on the same LAN.
When To Stop
Stop and ask for user help when:
- the device is unreachable on LAN
- the app is not running and cannot be restarted from the current path
- required Android permissions are missing
- launcher discovery returns nothing useful
- the runtime UI no longer matches the expected screen after repeated refreshes
References
1---2name: agent-android3description: Control Android over LAN without USB, ADB, or root.4---56# Android REPL78Use this skill to drive an Android device through the public `agent-android` beta surface published in the `aivanelabs/ai-rpa` repo.910Runtime prerequisites:1112- `agent-android` is available on `PATH`13- if it is missing, install the CLI with `uv tool install aivane-agent-android`; then run `uv tool update-shell` if the command is still not found14- the user has provided a trusted device URL such as `http://<device-ip>:8080`; use the phone-side configured port if it is not `8080`1516The public path is local-first:1718- the phone hosts the lightweight HTTP service locally19- the desktop connects directly to the phone URL, usually `http://<device-ip>:8080`20- UI reads, taps, inputs, and screenshots stay on the phone and controlling machine21- the current tradeoff is LAN-only control; an optional server-side or relay path may arrive later2223If an `agent-android` command suddenly stops working, first check whether the AIVane app or its local API service has exited on the phone.2425## Safety Boundaries2627- Connect only to a device URL explicitly provided by the user.28- Do not scan local networks or guess device IP addresses.29- Treat UI trees and screenshots as sensitive because they may contain private app content.30- Save screenshots or raw UI dumps only when the user explicitly asks for a file output.31- Ask for confirmation before operating sensitive apps, private content, account settings, or irreversible actions.32- Do not expose the phone-side service on a public network.3334## Core Workflow3536Every Android control task should follow the same short loop:37381. Confirm connectivity with `/health`392. Discover the target app with `apps` if needed403. Launch one app414. Inspect the current UI tree425. Perform one action436. Inspect again4445Keep the loop short. Prefer inspect -> act -> inspect over long speculative command chains.4647## Quick Start4849Start the REPL with the user-provided device URL:5051- `agent-android --repl --url http://<device-ip>:8080`5253Built-in help:5455- `agent-android --help`56- In the REPL: `h`5758## Essential CLI Commands5960Use the one-off CLI when you already know the exact action you want.6162Connectivity:6364- `agent-android --health --url http://<device-ip>:8080`6566Discovery:6768- `agent-android --apps --url http://<device-ip>:8080`69- `agent-android --list --url http://<device-ip>:8080`70- `agent-android --id com.example:id/search --url http://<device-ip>:8080`71- `agent-android --text Search --url http://<device-ip>:8080`72- `agent-android --inputs --url http://<device-ip>:8080`73- `agent-android --refId 7 --url http://<device-ip>:8080`74- `agent-android --xpath 7 --url http://<device-ip>:8080`75- `agent-android --get-attr 7 text --url http://<device-ip>:8080`7677Actions:7879- `agent-android --launch com.xingin.xhs --url http://<device-ip>:8080`80- `agent-android --tap 7 --url http://<device-ip>:8080`81- `agent-android --input 7 "hello world" --url http://<device-ip>:8080`82- `agent-android --swipe up --url http://<device-ip>:8080`83- `agent-android --swipe up --swipe-refid 7 --url http://<device-ip>:8080`84- `agent-android --swipe up --swipe-xpath "//RecyclerView[1]" --url http://<device-ip>:8080`85- `agent-android --back --url http://<device-ip>:8080`86- `agent-android --press home --url http://<device-ip>:8080`87- `agent-android --screenshot --url http://<device-ip>:8080`88- `agent-android --application-bundle app.zip --main-template-file __main__.json --url http://<device-ip>:8080`89- `agent-android --template template.json --async --url http://<device-ip>:8080`90- `agent-android --application-bundle app.zip --main-template-file __main__.json --async --url http://<device-ip>:8080`91- `agent-android --upload foo.json --remote-path Templates/foo.json --url http://<device-ip>:8080`9293Waiting and output:9495- `agent-android --wait-for Search --timeout 30 --url http://<device-ip>:8080`96- `agent-android --list --raw --url http://<device-ip>:8080`97- `agent-android --tasks --url http://<device-ip>:8080`98- `agent-android --task TASK_ID --url http://<device-ip>:8080`99- `agent-android --task-logs TASK_ID --url http://<device-ip>:8080`100- `agent-android --stop-task TASK_ID --url http://<device-ip>:8080`101102## REPL Command Reference103104Use the REPL for exploratory tasks and smoke runs. Short aliases and long names both work.105106### Browse107108- `health` or `hl`109 Check `/health`.110- `l [n]` or `list [n]`111 List the first `n` elements, or all cached elements when `n` is omitted.112- `ss` or `snapshot`113 Force-refresh the UI tree and print it again.114- `f <text>` or `find <text>`115 Filter by text or content description.116- `id <resourceId>`117 Filter by Android resource ID.118- `ref <refId>`119 Show the full element detail for one refId.120- `x <refId>` or `xpath <refId>`121 Generate XPath candidates and validate their runtime match counts.122- `xx <refId>`123 Tap by the best unique generated XPath candidate. Refuses ambiguous matches.124- `vx <xpath> [idx]` or `validatex <xpath> [idx]`125 Validate one XPath against the runtime. Optionally inspect one match by zero-based index.126127### Interact128129- `t <refId>` or `tap <refId>`130 Tap the element center point from the current tree.131- `tx <xpath>` or `tapx <xpath>`132 Tap one runtime-resolved XPath target.133- `i <refId> <text>` or `input <refId> <text>`134 Input text into a refId target.135 Use `--clear` or `""` to clear instead of typing.136- `ix <xpath> <text>` or `inputx <xpath> <text>`137 Input text into one XPath target.138 Use `ix <xpath> --` or `--clear` to clear the field.139- `sw <d|u|l|r> [refId] [--dur N] [--dist N]` or `swipe ...`140 Swipe down/up/left/right across the screen, or inside a refId target when provided.141- `swx <d|u|l|r> <xpath> [--dur N] [--dist N]` or `swipex ...`142 Swipe inside one XPath target.143- `p <back|home|recents>` or `press ...`144 Press a system key.145- `b` or `back`146 Press Back.147- `la <package>` or `launch <package>`148 Launch an app by package name.149- `s [path]` or `screenshot [path]`150 Capture a screenshot to an auto-generated or explicit path.151- `up <local> <path>` or `upload <local> <path>`152 Upload a local file to the phone. Overwrites by default; add `--no-overwrite` to reject an existing target.153154### Wait And Inspect155156- `wf <text> [--t N]` or `waitfor ...`157 Wait for an element to appear.158- `g <refId> <attr>` or `get <refId> <attr>`159 Read an attribute such as `text`, `class`, `bounds`, `x`, `y`, or `xpath`.160- `apps`161 List launcher apps from `/apps`.162163### Session164165- `raw`166 Toggle raw JSON mode.167- `vars`168 Show current URL, timeout, raw mode, and tree cache state.169- `set timeout 30`170 Set the default wait timeout in seconds.171- `h` or `help`172 Show the built-in help text.173- `q` or `quit`174 Exit the REPL.175176## Common Patterns177178### First smoke flow1791801. Start the REPL with `agent-android --repl --url http://<device-ip>:8080`.1812. `health`1823. `apps`1834. `la <package>`1845. `l`1856. `t <refId>`1867. `i <refId> hello`1878. `b`1889. `s`189190### Find the right package before launch191192- `apps`193- `la com.example.app`194- `l`195196### Inspect an element before using XPath197198- `l`199- `ref 12`200- `x 12`201- `vx //EditText[@text='Search']`202203### Clear and refill an input204205- `i 7 --clear`206- `i 7 hello world`207- `ix //EditText[@text='Search'] --`208- `ix //EditText[@text='Search'] -- hello world`209210### Run a local template bundle211212- Zip the local folder containing the main template and child templates.213- Run `agent-android --application-bundle app.zip --main-template-file __main__.json --url http://<device-ip>:8080`.214- Use `--upload` only for standalone images, ordinary binary files, or one-off file sync.215216## Troubleshooting217218- If an `agent-android` command fails, first check whether the AIVane app or phone-side API service has exited.219- If `agent-android` is not found, run `uv tool update-shell`, reopen the terminal, and retry.220- Re-open the app or restart the phone-side service, then retry `curl http://<device-ip>:8080/health`.221- If `health` works but UI commands fail, run `ss` to force-refresh the tree before tapping or inputting.222- If `tx` or `ix` fails, run `vx <xpath>` and make sure the XPath resolves to exactly one runtime match.223- If screenshots fail the first time, confirm the on-device MediaProjection permission prompt was accepted.224- If everything suddenly stops responding, confirm the phone IP did not change and that the desktop is still on the same LAN.225226## When To Stop227228Stop and ask for user help when:229230- the device is unreachable on LAN231- the app is not running and cannot be restarted from the current path232- required Android permissions are missing233- launcher discovery returns nothing useful234- the runtime UI no longer matches the expected screen after repeated refreshes235236## References237238- Smoke checklist: [GitHub](https://github.com/aivanelabs/ai-rpa/blob/main/skills/agent-android/references/smoke-flow.md)239- Quickstart: [GitHub](https://github.com/aivanelabs/ai-rpa/blob/main/docs/quickstart.md)240- Install guide: [GitHub](https://github.com/aivanelabs/ai-rpa/blob/main/docs/install-agent-android.md)241- Public protocol: [GitHub](https://github.com/aivanelabs/ai-rpa/blob/main/docs/protocol-v1.md)242- Known beta limits: [GitHub](https://github.com/aivanelabs/ai-rpa/blob/main/docs/known-limitations.md)