Retrieved article excerpt
Open article · Retrieved 2026-10-30T21:24:15.139134+00:00
# mobile-agent
mobile-agent drives Android devices, Android emulators, iOS Simulators and physical iPhones for AI agents, and is designed around the latency of each tap-and-observe step. A daemon keeps a live mirror of every attached screen (its windows, accessibility tree and latest frame), updates it from the platform's change events and frame callbacks, and answers snapshots, waits and settle checks from that mirror instead of reading the device and sleeping on every request. On Android, a single-dex agent pushed over adb runs as the shell user under `app_process` and holds the device's UI automation role: no APK is installed and no instrumentation runs. On the iOS Simulator the driver works from the host: input goes through the Simulator's dtuhidd HID service, frames come from the display's IOSurface, and the accessibility tree comes from a Rust reader that the daemon spawns into the Simulator, with no XCTest runner and nothing installed. A physical iPhone's tree can be read only from an XCTest runner, so there a Rust runner built in this repository, started through the phone's test manager and kept for the session, serves the tree and text entry over the same device protocol, while the driver does the rest from the host: input through the developer disk image's dtuhidd, frames from screenshots it polls, and the phone's services over a CoreDevice tunnel it opens in its own process, without root or a helper. The `mobile-agent` CLI follows agent-browser's command grammar, `@eN` refs and JSON envelope, so prompts and skills written for agent-browser carry over where devices have the same concepts, and the `mobile-agent-mcp` server gives an MCP client the same tools, refs and replies (Agent surfaces).
**Status.** Experimental and pre-release: nothing is published to crates.io or as a binary yet, so mobile-agent is built from source (Build), and `main` is the version CI builds and tests on macOS and Linux. The drivers rely on private Apple and hidden Android interfaces, which makes this development tooling, never something to ship inside an app (Status and limitations). It is under the MIT License (`LICENSE`, `THIRD-PARTY-NOTICES.md`); `CONTRIBUTING.md` says how a change is made and checked, `SECURITY.md` how to report a vulnerability, and `CHANGELOG.md` what has changed.
## Supported platforms
| Platform | Status | Tested on |
| --- | --- | --- |
| macOS host | Simulator, Android and physical iPhone drivers, the iPhone's only when `MOBILE_AGENT_DRIVERS` names `ios` | macOS 26.6.2, Apple M1 Max |
| Linux host | Android driver only; the Simulator and iPhone drivers build as stubs | CI builds and tests it on `ubuntu-latest`, without a device |
| Xcode | for the Simulator driver, 26.0 up to, not including, 28; other versions are refused with `unsupported_xcode`. The iPhone's runner is built from Xcode's `XCTRunner.app` and iPhoneOS SDK, tried with 27.0 alone | Xcode 27.0 (27A266a); CI also builds with Xcode 26 |
| iOS Simulator | booted Simulators; no gate on the runtime version | iOS 26.5 (23F77), iPhone 17 |
| Android emulator | fast path through the emulator's gRPC controller when it answers, the agent's path with `--emulator-controller off` | API 36, arm64, Pixel 8 profile, Android Emulator 37.1.11 |
| Android agent | minimum API 26: the dex is built with `--min-api 26`, and a platform member that exists only from a later level is read behind a check of the level (`agent-android/src/dev/mobileagent/agent/Levels.kt`) | API 36 on the emulator; API 27 (Android 8.1) on a Nexus 5X, from agent 0.4.3 |
| Physical Android device | through the same agent, without a frame stream: taps and screenshots go through the agent | a Nexus 5X on Android 8.1 (API 27), a `user` build (`reports/10.3-physical-android.md`) |
| Physical iPhone | on USB, through a runner signed for a paid development team (Quick start); iOS 17.4 up to, not including, 27, other versions refused with `unsupported_ios`; input from the host from iOS 18, through the runner below it; built and measured for iOS 26, whose dtuhidd takes the host's input without a display stream, while iOS 27's, which needs one, is a later path (`crates/ios/README.md`, Compatibility) | an iPhone SE (3rd generation) on iOS 26.6.2 under Xcode 27.0, with `idevice` 0.1.68 (`reports/11.1-ios-device.md`) |
CI (`.github/workflows/ci.yml`) validates and runs no benchmark; the benchmarks have a workflow of their own, which never runs per push (How measurements are made). `ci.yml` runs `just validate` in three jobs: Linux, which also builds the Android agent and the Compose fixture; macOS with Xcode 26 on GitHub's `macos-26` image; and macOS with Xcode 27 on its `xcode-27` image. A fourth, Audit, lints the workflows with actionlint, audits them with zizmor, its online audits included, and checks the dependencies' advisories, licenses, bans and sources with cargo-deny (`deny.toml`). Every job starts without permissions and reads only what it needs, every action is pinned to a full commit SHA, no checkout keeps its credentials, and the tools come from lockfiles or from releases pinned with their SHA-256 (`docs/research/open-sourcing.md`). Each macOS job keeps the image's default Xcode when it has that major version and otherwise selects the newest `Xcode_<major>*.app`. The macOS jobs build and test the iPhone driver (`crates/ios`, on its fake device) and the runner's crate (`agent-ios`, on the host); nothing runs against a phone, the device tests skipping without `MOBILE_AGENT_IOS_UDID`, and the signed runner bundle is not built there, since `just agent-ios-build` skips with `SKIP_AGENT_BUILD=1` or without `MOBILE_AGENT_IOS_TEAM`, as `just agent-build` skips the Android agent with `SKIP_AGENT_BUILD=1`. The Simulator integration tests, the spikes and every measurement ran on Xcode 27.0 with CoreSimulator 1171.7 and iOS 26.5. Nothing has run on Xcode 26, where input would be touch only, through the older Indigo transport (`crates/simulator/README.md`, Compatibility).
## Build
Requirements:
- **Rust.** Install rustup. It takes the toolchain from `rust-toolchain.toml`: the version pinned there, with clippy, rustfmt and the `aarch64-apple-ios-sim` target. Run `rustup toolchain install` in the checkout, as CI does, to install them before the first build, or when cargo reports that the pinned toolchain is not installed; `rustup show active-toolchain` there names the toolchain in use.
- **macOS, for the Simulator.** Xcode 26 or 27, selected with `xcode-select`, with an iOS Simulator runtime; and libjpeg-turbo, `brew install jpeg-turbo`, which the frame encoder links statically from Homebrew's Apple silicon prefix (`.cargo/config.toml`; set `TURBOJPEG_LIB_DIR` and `TURBOJPEG_INCLUDE_DIR` for another prefix).
- **The Android agent.** The daemon's build compiles the agent with `agent-android/build.sh` (kotlinc and R8, no Gradle) and embeds the jar, so it needs a JDK 17 or newer with `java` and `jar` on `PATH` (tested with Temurin 21), the Kotlin compiler, `kotlinc` on `PATH` or `KOTLIN_HOME` set to the compiler's home, the directory holding `bin/kotlinc` and `lib/` (tested with 2.4.20), and an Android SDK at `ANDROID_HOME`, by default `$HOME/Library/Android/sdk`, with `platforms;android-36` and a `build-tools` package (CI installs 37.0.0). On Linux, set `ANDROID_HOME`.
- **Android at run time.** The SDK's `platform-tools`, whose adb server the driver talks to on port 5037, and for an emulator, the `emulator` package and an AVD.
- **The iPhone's runner.** `agent-ios/build.sh`, which `just agent-ios-build` runs, builds the runner for `aarch64-apple-ios`, the second target `rust-toolchain.toml` names, links it into a copy of Xcode's `XCTRunner.app` with the iPhoneOS SDK's `clang` and signs it with `codesign` for the team `MOBILE_AGENT_IOS_TEAM` names, with no `xcodebuild` project, into the git-ignored `agent-ios/dist/` (`agent-ios/README.md`, Building and signing). It needs Xcode 27.0's iPhoneOS SDK, the only one tried, and the team's identity and profile (Quick start). The daemon installs that bundle from the workspace it was built in, or the one `MOBILE_AGENT_IOS_RUNNER_APP` names, when the phone's runner is missing or says hello with another version (`crates/daemon/README.md`, The physical iPhone driver).
From the checkout:
```
cargo build --release # target/release/mobile-agent, mobile-agent-daemon and mobile-agent-mcp
export PATH="$PWD/target/release:$PATH" # the CLI starts the daemon it finds beside itself
```
- `cargo build --profile profiling` builds the release code with line-level debug information and nothing stripped, into `target/profiling/`, for a sampling profiler such as Instruments' Time Profiler, which then names inlined functions and lines; release builds strip the debug information (spike S15, `docs/spikes/s15-profiles.md`).
- `SKIP_AGENT_BUILD=1 cargo build --release` builds without the Android toolchain. That daemon deploys an agent only from a jar that `MOBILE_AGENT_JAR` names at run time; `MOBILE_AGENT_JAR` set at build time embeds that jar instead of building one.
- The Simulator's tree reader is cross-compiled for `aarch64-apple-ios-sim` during the build and embedded in the daemon, behind the `reader` feature of `crates/simulator`, which is on by default. The daemon spawns it into each booted Simulator it attaches. Without that Rust target the build warns and embeds no reader, and tree reads fall back to the slower host translator, marked degraded; `doctor` shows which one a build has.
- Contributors: every dependency install goes through Socket Firewall. Install it with `npm i -g sfw`, then prefix installs with it: `sfw cargo fetch`, `sfw cargo add`, `sfw cargo install just`, `sfw npm install -g @fission-ai/openspec`. `just validate` runs the checks a change must pass: build, clippy with warnings denied, format check, the publish scan (`just check-public`: no machine path, device identifier, team id, email, host model or private term in a tracked file, and gitleaks' rules when it is installed), the workflows' lint and audit (actionlint and zizmor, when installed), the dependencies' check (`cargo deny`, when installed), tests, the checks of the repository's own scripts, the agent build, the iPhone runner's build, the Kotlin codec cross-check, the fixture scripts' checks with fake build tools, the fixture builds (with the SwiftUI and Expo fixtures' device builds when `MOBILE_AGENT_IOS_TEAM` is set) and `openspec validate`. The tests that need a Simulator, an emulator or an iPhone skip unless their environment names one (`crates/daemon/README.md`, `crates/simulator/README.md`, `crates/ios/README.md`).
## Quick start
The daemon attaches to targets that are already running; it boots nothing. For Android, put the SDK's tools on `PATH`, start an adb server, and start an emulator with its gRPC control endpoint, whose port is the console port plus 3000, or connect a device with USB debugging on and its prompt accepted:
```
export ANDROID_HOME="${ANDROID_HOME:-$HOME/Library/Android/sdk}"
export PATH="$ANDROID_HOME/platform-tools:$ANDROID_HOME/emulator:$PATH"
adb start-server
emulator -avd <name> -grpc 8554 -grpc-use-token # in a terminal of its own
```
Without the control endpoint, taps and screenshots go through the agent and there is no frame stream; `doctor` and `status` say how to enable it on a running emulator: `adb -s emulator-5554 emu grpc 8554`. Emulator 37.1.11 serves the endpoint even when started without `-grpc` (only `-ports` leaves it off), so to take the agent's path on an emulator that serves it, as a physical device does, start the daemon with `--emulator-controller off` or `MOBILE_AGENT_EMULATOR_CONTROLLER=off`; `status` and `doctor` report the setting. For the iOS Simulator, boot one in Simulator.app or with `xcrun simctl boot <name or UDID>`.
For a physical iPhone, the daemon registers its driver only when `MOBILE_AGENT_DRIVERS` names `ios` (`MOBILE_AGENT_DRIVERS=ios` drives iPhones