Skip to content
zereightPublic

About

Unified iOS simulator and Android emulator pool, TTL lease, cap, and slimming manager for AI agents

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

18 Commits

Folders and files

Repository files navigation

mobpool

Unified iOS Simulator & Android Emulator Pool, TTL Lease, and Slimming Guardrails for AI Coding Agents

Python 3.10+ Zero Dependencies Platforms OS Agent Skill

Stop parallel AI agents from melting your Mac or killing each other's simulators and emulators.


mobpool unified web dashboard showing a running slim iOS simulator, an externally owned device locked from takeover, and ready Android emulators

Manage iOS simulators and Android emulators in one local dashboard — one-click slim start, live RAM and cap guardrails, TTL leases, and automatic protection for devices owned by other sessions.


30-Second Quick Start

1. Install mobpool

# Required for iOS simulators (macOS)
brew install mobai-app/tap/simslim

# Install mobpool (pick one)
uv tool install git+https://github.com/zereight/mobpool.git
# or: pipx install git+https://github.com/zereight/mobpool.git
Alternative: zero-build symlink or editable pip install
# Option A: Symlink to PATH (zero build step)
git clone https://github.com/zereight/mobpool.git ~/Documents/mobpool
mkdir -p ~/.local/bin
ln -sf ~/Documents/mobpool/bin/mobpool ~/.local/bin/mobpool
# Make sure ~/.local/bin is in your PATH (default macOS zsh does not include it):
export PATH="$HOME/.local/bin:$PATH"

# Option B: Editable pip install
git clone https://github.com/zereight/mobpool.git
cd mobpool && pip install -e .

2. Launch (Humans) or Register Skill (AI Agents)

For humans — open the local web dashboard:

mobpool gui

Opens http://127.0.0.1:8765/. On first run, click Auto-pick best devices (or run mobpool init --platform all), then click Start iOS or Start Android.

For AI coding agents — register skill/SKILL.md:

git clone https://github.com/zereight/mobpool.git ~/Documents/mobpool
mkdir -p ~/.agents/skills ~/.claude/skills
ln -sfn ~/Documents/mobpool/skill ~/.agents/skills/mobpool
ln -sfn ~/.agents/skills/mobpool ~/.claude/skills/mobpool

Once linked, agents (Codex, Claude Code, Cursor, OpenMyBot, etc.) automatically call mobpool preflight / acquire / renew / release before booting or stopping any virtual device.


See It in Action

Web Dashboard (mobpool gui)

mobpool web dashboard demo: starting a slim iOS simulator, extending its lease with +1h, starting an Android emulator, and hitting the 2/2 concurrency cap guardrail

One-click Start iOS (slim boot + 1h TTL) → +1h lease renewal → Start Android with live progress → automatic 2 / 2 concurrency cap guardrail preventing Mac overload.

CLI Multi-Agent Guardrail

# 1. Agent A acquires a slim iOS simulator (1h TTL by default)
mobpool acquire --platform ios --owner feat-login
# → A1B2C3D4-1111-4000-8000-000000000001

# 2. Inspect running devices, RAM/CPU, slim status, leases, and Mac free memory
mobpool audit

# 3. Agent B cannot accidentally kill Agent A's simulator
mobpool release A1B2C3D4-1111-4000-8000-000000000001
# → BLOCKED: owned by feat-login (pass --force to override)

# 4. Agent A extends the lease during long runs, then releases cleanly
mobpool renew A1B2C3D4-1111-4000-8000-000000000001 --ttl 3600
mobpool release A1B2C3D4-1111-4000-8000-000000000001

Example mobpool audit output (use --json for scripts and agent pipelines):

Booted devices: 1/2 (iOS 1/2, Android 0/1), total RAM 2.41 GB
  [ios] A1B2C3D4-1111-4000-8000-000000000001  iPhone 17 Pro (iOS 26.2)  2.41 GB RAM  11.8% CPU  slim (163/173)  [claimed:feat-login]
Mac memory free: 61% (floor 25%)

The Problem

When multiple AI coding agents (Claude Code, Codex, Cursor, OpenMyBot, etc.) run mobile builds and UI verifications in parallel on one Mac:

  • Thermal & RAM meltdown: Agents independently call xcrun simctl boot or emulator -avd, stacking 4–6 full virtual devices until macOS thrashes swap.
  • Friendly fire: Agent B shuts down or wipes Agent A's active simulator mid-test because there is no shared ownership model.
  • Broken PID locks: Traditional PID-based claims vanish immediately when an agent's short-lived shell tool call exits.
  • Fragmented workflows: iOS (simctl / simslim) and Android (adb / emulator / avdslim) require completely different commands, IDs, and boot flags.

Why mobpool?

mobpool owns device lifecycle (pool selection, concurrency caps, host memory floor, atomic boot locks, TTL leases, and slim booting) and hands off UI interaction to your driver of choice (such as Argent, Maestro, Appium, simctl, or adb).

  • One CLI for iOS + Android — Same init, audit, preflight, acquire, renew, release, owners, and slim workflow across both platforms.
  • Unified Local Web GUI (mobpool gui) — Manage iOS simulators and Android emulators together in one browser dashboard (127.0.0.1 loopback-only, CSRF/Origin/CSP protected, zero external dependencies).
  • TTL + heartbeat leases — Leases persist across transient agent subprocesses and auto-expire if a session crashes without cleanup.
  • Atomic boot lock — mkdir-based lock with dead-PID stale-lock recovery prevents concurrent agents from racing past your device caps.
  • Host memory & cap guardrails — Enforces per-platform caps (IOS_CAP, ANDROID_CAP), machine-wide TOTAL_CAP, and a macOS memory_pressure free-memory floor before booting.
  • External owner awareness — Detects external worktree claims, legacy sim-guard / agent-device claims, and live app processes (MOBPOOL_APP_ID) so agents never touch someone else's device.
  • Slim by default — Uses simslim on iOS and avdslim (or lightweight emulator flags when avdslim is absent) on Android.
  • Zero Python dependencies — Pure Python 3.10+ standard library. Ships with an agent-ready skill/SKILL.md.

Architecture

flowchart LR
    A1["AI Agent A<br/>(Claude / Codex / Cursor)"] --> CLI
    A2["AI Agent B<br/>(Parallel Session)"] --> CLI

    subgraph Core["mobpool Core (Python stdlib)"]
        CLI["mobpool CLI<br/>init · audit · preflight · acquire · renew · release"]
        GUI["mobpool GUI<br/>Local Web Dashboard (127.0.0.1)"]
        SVC["Shared Service Layer<br/>(service.py)"]
        LOCK["Atomic Boot Lock<br/>(mkdir + stale PID recovery)"]
        GUARD["Caps & Memory Floor<br/>(IOS/ANDROID/TOTAL + memory_pressure)"]
        CLAIMS["Owner & TTL Lease Resolver<br/>(TTL leases · worktrees · sim-guard · live app)"]
        POOL["Pool Store<br/>(~/.config/mobpool/pools.json)"]

        CLI --> SVC
        GUI --> SVC
        SVC --> LOCK
        SVC --> GUARD
        SVC --> CLAIMS
        SVC --> POOL
    end

    subgraph Platforms["Platform Adapters"]
        IOS["iOSAdapter<br/>xcrun simctl + simslim"]
        AND["AndroidAdapter<br/>adb + emulator + optional avdslim"]
    end

    Core --> IOS
    Core --> AND

    IOS --> ID1["Booted iOS UDID"]
    AND --> ID2["Booted emulator-XXXX"]

    ID1 --> UI["UI Driver<br/>(Argent / Maestro / Appium / simctl / adb)"]
    ID2 --> UI
Loading

Multi-Agent Lease Lifecycle

sequenceDiagram
    autonumber
    participant A as Agent A (feat-login)
    participant B as Agent B (feat-pay)
    participant M as mobpool
    participant D as Simulator / Emulator Pool

    A->>M: mobpool acquire --platform ios --owner feat-login
    M->>M: Acquire atomic mkdir lock & check caps + Mac free RAM
    M->>D: simslim boot <UDID-1> & write TTL lease (3600s)
    M-->>A: <UDID-1> (claimed: feat-login)

    B->>M: mobpool acquire --platform ios --owner feat-pay
    M->>M: Skip <UDID-1> ([claimed:feat-login]), check cap
    M->>D: simslim boot <UDID-2> & write TTL lease (3600s)
    M-->>B: <UDID-2> (claimed: feat-pay)

    Note over A,B: Agents run builds & UI automation (e.g. Argent) safely in parallel

    A->>M: mobpool renew <UDID-1> --ttl 3600
    M-->>A: Lease extended (heartbeat)

    B->>M: mobpool release <UDID-1>
    M-->>B: Blocked! Owned by feat-login (use --force to override)

    A->>M: mobpool release <UDID-1>
    M->>D: Uninstall test apps, reset keychain, shutdown & drop lease
    M-->>A: Released <UDID-1>
Loading

Dependencies

mobpool itself has zero external Python package dependencies (standard library only). Platform features rely on the native SDK tools installed on your Mac:

Layer Dependency Required? Purpose & Install
Core Runtime Python 3.10+ Required Runs mobpool using stdlib only (pyproject.toml)
Host Guard macOS memory_pressure Built-in (macOS) Checks free memory % before booting (gracefully skipped if unavailable)
iOS Xcode Command Line Tools (xcrun simctl, plutil) Required for iOS Lists, inspects, cleans apps, resets keychain on iOS simulators
iOS simslim Required for iOS Boots simulators in slim mode, disables background daemons, reports RAM/CPU (brew install mobai-app/tap/simslim)
Android Android SDK platform-tools (adb) Required for Android Maps AVDs to emulator-XXXX serials, waits for boot, cleans apps, shuts down
Android Android SDK emulator + ≥1 AVD Required for Android Lists AVDs and boots emulators ($ANDROID_HOME/emulator/emulator)
Android avdslim Optional Applies AVD slim profile; if absent, mobpool falls back to lightweight boot flags (-no-audio -no-boot-anim -gpu host -no-snapshot-save)
UI Automation Argent / Maestro / Appium Optional Drives UI taps, typing, and screenshots against the booted UDID or emulator-XXXX

CLI Reference

Command Flags Description
mobpool init --platform ios|android|all, --count N Picks unowned devices (preferring plain iOS-X-Y runtimes), applies slimming, and saves pool to ~/.config/mobpool/pools.json
mobpool audit --platform ios|android|all, --json Lists booted devices, RAM/CPU usage, slim status, active owners, and Mac free memory %
mobpool preflight --platform ios|android Runs audit and exits non-zero if platform cap, total cap, or Mac memory floor would be exceeded
mobpool acquire --platform ios|android, --ttl SEC, --owner LABEL Atomically acquires lock, checks caps/memory, boots a free slim pool device, and writes a TTL lease
mobpool renew <id> --ttl SEC, --force Extends an active TTL lease (heartbeat) by UDID, AVD name, or emulator-XXXX serial; refuses leases owned by another session unless --force
mobpool release <id> --keep-apps, --force Refuses to kill non-self owned devices unless --force; cleans user apps, shuts down, and removes lease
mobpool owners --platform ios|android|all Lists all currently claimed devices and their resolved owner source
mobpool slim <id> --platform ios|android, --force Applies the slimming profile (simslim on / avdslim on); blocks non-self owned devices unless --force
mobpool gui --host HOST, --port PORT, --no-open Launches the unified local web dashboard (127.0.0.1, localhost, or ::1 only; default port 8765)

Unified Local Web GUI (mobpool gui)

Manage iOS simulators and Android emulators from one local browser dashboard instead of switching between Xcode Devices and Android Studio Device Manager. Because it runs on Python's standard library, there are no extra dependencies and no macOS code-signing or Apple Developer account requirements.

Launch

# Start on http://127.0.0.1:8765/ and open in your default browser
mobpool gui

# Bind an automatic free port and print the URL without opening a browser
mobpool gui --port 0 --no-open

# Use a custom loopback host/port (only 127.0.0.1, localhost, or ::1 are allowed)
mobpool gui --host localhost --port 9000

Press Ctrl+C in the terminal to stop the local server.

Dashboard Workflow

  • At-a-glance status & one-click start: The top bar shows running slots and macOS free RAM (0 / 2 running · 64% RAM free) and auto-refreshes every 8 seconds while the tab is visible. Click Start iOS or Start Android to boot the next available slim device from your Quick-start list.
  • Running: Always pinned at the top with plain status (Yours · 52m left, In use by <owner>, or Started outside mobpool), RAM usage, one-click ID copy, +1h (adds one hour to your reservation), Stop & clean (or Force stop with confirmation if used by another session), and a ⋯ menu for Stop (keep apps), Optimize RAM (Slim), or pinning.
  • Quick-start: Lists your pinned pool devices with simple All / iOS / Android tabs and a single Start button per device (disabled when another session owns the device or when caps/memory limits are reached). When no pool is configured yet, click Auto-pick best devices.
  • Other installed devices: Collapsed by default so unused simulators stay out of the way. Expand or type in Search devices... to Start any installed device directly (with slim setup applied automatically) or Pin it to Quick-start.
  • No settings screen: Devices you start are labeled mobpool-gui (or your configured owner) and reserved for the configured default TTL. Recent activity appears at the bottom only after you run an action.

Guardrails & Localhost Security

  • Same guardrails as the CLI: Every action goes through the shared service.py layer, enforcing atomic boot locks, concurrency caps, the macOS free-memory floor, and ownership checks. Foreign-owned devices (whether running or shut down) cannot be pinned or slimmed without explicit confirmation, and pinning an already-booted device never triggers a forced reboot.
  • Loopback-only & CSRF-protected: Refuses non-loopback --host values, sends a strict CSP header, and validates Host, Origin, Sec-Fetch-Site, and a per-session X-Mobpool-Token header on every mutating request.

Configuration

mobpool resolves settings in the following precedence order:

  1. Environment variables (highest priority)
  2. Local config file: ~/.config/mobpool/config.json (override path via MOBPOOL_CONFIG_FILE)
  3. Built-in defaults

Example ~/.config/mobpool/config.json

{
  "ios_cap": 2,
  "android_cap": 1,
  "total_cap": 2,
  "min_free_pct": 25,
  "default_ttl_sec": 3600,
  "simslim_except": "store,web",
  "app_id": "com.example.app.dev",
  "worktree_claims_dir": "~/.cache/worktree-claims"
}

All Settings

Env Variable config.json Key Default Purpose
MOBPOOL_CONFIG_DIR — ~/.config/mobpool Base directory for config, pools, claims, and locks
MOBPOOL_CONFIG_FILE — <config_dir>/config.json Path to local JSON config file
MOBPOOL_IOS_CAP ios_cap 2 Max concurrently booted iOS simulators
MOBPOOL_ANDROID_CAP android_cap 1 Max concurrently booted Android emulators
MOBPOOL_TOTAL_CAP total_cap 2 Max concurrently booted virtual devices machine-wide
MOBPOOL_MIN_FREE_PCT min_free_pct 25 Minimum macOS free memory % required before booting
MOBPOOL_CLAIM_TTL default_ttl_sec 3600 Default lease duration in seconds
MOBPOOL_OWNER owner_label workspace basename Default owner label written into new leases
MOBPOOL_ANDROID_FLAGS android_flags -no-audio -no-boot-anim -gpu host -no-snapshot-save Lightweight Android emulator boot flags
SIMSLIM_EXCEPT simslim_except store,web simslim daemon categories kept enabled on iOS
MOBPOOL_APP_ID app_id unset Bundle/package ID treated as an active owner while running
MOBPOOL_WORKTREE_CLAIMS_DIR worktree_claims_dir unset Directory of <device_id>/owner external worktree claim files (also checks RB_CLAIMS)
MOBPOOL_FORCE_RELEASE — 0 Set 1 to bypass non-self owner protection on release

Ownership & Safety Model

Before booting, selecting pool devices, or shutting anything down, mobpool resolves device ownership across four layers:

  1. mobpool TTL leases (~/.config/mobpool/claims/) — Active leases with expiration timestamps and heartbeat renewal.
  2. External worktree claims (MOBPOOL_WORKTREE_CLAIMS_DIR / RB_CLAIMS) — Respects devices claimed by build scripts or git worktrees.
  3. Legacy sim-guard / agent-device claims — Seamlessly coexists with existing simulator guard setups.
  4. Running target app detection (MOBPOOL_APP_ID) — Marks a booted device as owned if your dev app process is actively running on it.

Any device owned by another session is marked [claimed:...] in audit, skipped by init and acquire, and protected from release unless explicitly overridden with --force or MOBPOOL_FORCE_RELEASE=1.

A lease can only be renewed by the session that holds it: the same MOBPOOL_OWNER, or the workspace that acquired it (or a folder inside it). Renewing someone else's lease prints BLOCKED and leaves it untouched, so a dead session's lease still expires on time. renew --force overrides this; MOBPOOL_FORCE_RELEASE does not.


Project Structure

mobpool/
├── .githooks/pre-commit         # Blocks commits that stage this machine's device IDs
├── bin/mobpool                  # Executable CLI entrypoint
├── docs/assets/                 # README dashboard screenshot & demo GIF
├── pyproject.toml               # Python 3.10+ packaging (zero dependencies)
├── scripts/
│   └── check_no_device_ids.py   # Device-ID check the pre-commit hook runs
├── skill/SKILL.md               # Drop-in AI agent skill instructions
├── src/mobpool/
│   ├── cli.py                   # Unified CLI subcommands
│   ├── service.py               # Shared CLI & GUI lifecycle/pool/audit logic
│   ├── gui.py                   # Localhost-only HTTP server & async job controller
│   ├── gui_assets.py            # Embedded HTML/CSS/JS dashboard assets
│   ├── config.py                # Env + local config.json loader
│   ├── claims.py                # TTL leases & external owner resolution
│   ├── lock.py                  # Atomic mkdir boot/state locks + stale recovery
│   ├── memory.py                # macOS memory_pressure check
│   ├── pool_store.py            # Pool persistence (~/.config/mobpool/pools.json)
│   └── platforms/
│       ├── base.py              # PlatformAdapter interface
│       ├── ios.py               # xcrun simctl + simslim adapter
│       └── android.py           # adb + emulator + optional avdslim adapter
└── tests/                       # Unit & CLI integration tests

Development & Tests

PYTHONPATH=src python3 -m unittest discover -s tests -v

# Once per clone: refuse commits that stage this Mac's simulator UDIDs, adb serials, or AVD names
git config core.hooksPath .githooks

The hook runs scripts/check_no_device_ids.py, which compares the paths and added lines you stage against xcrun simctl list devices, adb devices, and emulator -list-avds on your machine. Example IDs such as A1B2C3D4-1111-4000-8000-000000000001 still pass, a missing tool is skipped, and emulator-5554-style serials are ignored because every machine shares them.

About

Unified iOS simulator and Android emulator pool, TTL lease, cap, and slimming manager for AI agents

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages