Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
27 changes: 27 additions & 0 deletions .github/workflows/pytest.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Pytest

on:
pull_request:
push:
branches: [main, develop]

jobs:
pytest:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.11", "3.12", "3.13"]
steps:
- uses: actions/checkout@v4
with:
submodules: true

- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Install uv
run: python -m pip install uv

- name: Run unit tests
run: uv run --locked --extra sandbox --extra dev pytest tests/unit
84 changes: 51 additions & 33 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,23 @@ Agent skills live in the `skills/` submodule (`droidrun/skills`).
See [mobilerun/README.md](mobilerun/README.md) for the detailed package map,
examples, and dependency diagram.

- `mobilerun/core/`: device, state, operator and resource interfaces.
- `mobilerun/core/`: operators, extensions, screen views, recording and account resources.
- `mobilerun-core` (separate package): native device actions, observation, lifecycle and action hooks.
- `mobilerun/core/webhooks/`: organization webhook endpoints; commands in `mobilerun/cli/webhook/`.
- LLM-backed agent execution is in the separate `mobilerun-agents` package (not yet publicly published).
- `mobilerun/clients/`: cloud, local and Portal service adapters.
- `mobilerun/clients/`: account service adapters and shared client helpers.
- `mobilerun/models/`, `config/`, `errors/`, `logs/`, `utils/`: shared types and support.
- `mobilerun/cli/`: command groups and shared CLI helpers.
- `mobilerun/macro/`, `sandbox/`, `skills/`: independent framework features.
- `mobilerun-agents` (separate package): agent execution, integrations and agent commands.
- `tests/unit/`: unit tests and opt-in real-world smoke tests.
- `skills/`: git submodule; `hatch_build.py` bundles its files in the wheel.

Shared core must not import agents or feature packages. The intended boundaries
are checked in `tests/unit/architecture/test_layers.py`. The agent-required
dependency test (`tests/unit/test_agent_required_dependencies.py`) lives in the
separate `mobilerun-agents` repository. The CLI entry point has a special role; see the boundary tests for exceptions.
The v008 migration and legacy path resolver locate `mobilerun_agents` prompt assets without importing the add-on.
Shared core must not import agents or feature packages. The
[architecture tests](tests/unit/architecture/test_layers.py) enforce the public
`mobilerun_core` import boundary in production code and tests. They reject
imports from the retired framework device and state packages. See those tests
for the CLI entry point and fake-driver exceptions.

## Where code goes

Expand All @@ -39,37 +40,37 @@ If yes, it belongs in an optional feature (`sandbox/`,
`mcp/`, `macro/`, `skills/`); if not, put it in `core/` or a shared package.
For example, `sandbox/` is removable; `core/webhooks/` is not, because the
webhook CLI and sandbox both use it. In `mobilerun/`, `core/` holds domain
objects: devices, operators, state, credentials, proxies, numbers, mailboxes,
webhooks, workspace, and extensions. `models/`, `clients/`, `errors/`, `utils/`,
`config/`, and `logs/` supply shared building blocks. Phone behavior lives in
`core/devices/` and its components; account-wide resources live in their own
core folders or on `Workspace`. See the [topic map](mobilerun/core/README.md#topic-map).
interfaces that use a device, plus account resources. Native phone behavior lives
in `mobilerun-core`. Account resources live in their own core folders or on
`Workspace`. See the [topic map](mobilerun/core/README.md#topic-map).

Features keep their own CLI, errors, models, settings, and utilities in their
folders. Shared packages (including `cli/`) do not import features. Features do
not import each other or the agent add-on. Core can use clients; clients do not
import core or the root package. Register feature CLI groups via
`mobilerun.cli` entry points in `pyproject.toml`.

Core subpackages (`core/credentials/`, `core/devices/`, `core/webhooks/`, …)
Core subpackages (`core/credentials/`, `core/screen/`, `core/webhooks/`, …)
are part of core, not features: they never get their own `settings.py`,
`utils.py`, `errors.py` or `models.py`. Their tunables go in
`config/settings.py`, helpers in `utils/`, errors in `errors/`, models in
`config/settings.py`, helpers in `utils/<topic>/`, errors in `errors/`, models in
`models/`. Domain constants that callers need (e.g. a default event type) are
exported from the subpackage's `__init__.py`; backend limits stay private in
the module that uses them. Only feature packages (`macro/`, `mcp/`, `skills/`,
`sandbox/`, `addons/`) own a `settings.py`.

| New code | Location |
| --- | --- |
| Device error | `errors/device.py` |
| Macro error | `macro/errors.py` |
| Core tunable (e.g. webhook page size) | `config/settings.py` |
| Core helper (e.g. URL masking) | `utils/` (e.g. `utils/redaction.py`) |
| Core cloud adapter | `clients/cloud/<area>.py` |
| Proxy CLI command | `cli/proxy/` |
| Webhook CLI command | `cli/webhook/` |
| Skills CLI | `skills/cli/` |
| Native device operation | `mobilerun-core` repository |
| Operator or prompt screen view | `mobilerun/core/operator/` or `mobilerun/core/screen/` |
| Action or screen recording | `mobilerun/core/runs/` |
| Macro error | `mobilerun/macro/errors.py` |
| Core tunable (e.g. webhook page size) | `mobilerun/config/settings.py` |
| Framework core helper (e.g. redaction) | `mobilerun/utils/` |
| Framework cloud account adapter | `mobilerun/clients/cloud/` |
| Proxy CLI command | `mobilerun/cli/proxy/` |
| Webhook CLI command | `mobilerun/cli/webhook/` |
| Skills CLI | `mobilerun/skills/cli/` |

## Setup

Expand Down Expand Up @@ -130,28 +131,45 @@ security checks (`bandit -r mobilerun`, `safety scan`) and external docs updates

## Code rules

- Feature packages mirror the top-level layout with few files and no extra
subfolders beyond `cli/`.
- Keep config/settings modules declarative; put logic in role-named modules and
helpers in `utils.py`.
- Put tunable constants (URLs, timeouts, names) in the package's `settings.py`,
built like `mobilerun/config/settings.py`.
- Each folder contains one kind of file. Split distinct roles into subfolders
such as `cli/`, `clients/`, or `helpers/`. Put shared utilities in `utils/<topic>/`.
Feature packages stay self-contained.
- Keep one behavior class per file. Related value types may share a file.
Do not put module-level functions beside classes except private helpers used
only by that file's base class. Use a classmethod for an instance builder.
- Use one interface per concept. Call it directly: no pass-through wrappers or
one-caller hops. Keep config/settings modules declarative.
- Pin Mobilerun-owned packages exactly; give third-party dependencies a lower
bound only.
- Put framework core tunables in `mobilerun/config/settings.py` and feature
tunables in the feature's `settings.py`.
- Ship each feature or fix with unit tests using fakes, without devices or cost.
- Do not add speculative functions: add code used by a caller or public API.
- Use type hints and explicit contracts. Device capabilities that are unavailable
raise `DeviceOperationNotSupported`; do not guess capabilities on our classes.
- Use type hints and explicit contracts. For device access, import only public
`mobilerun_core` APIs, not its driver packages or `adbutils`. Open handles with
`AsyncMobilerun`; use `AsyncDevice.from_driver()` for caller-owned drivers or
fakes. Check `device.supports(verb)` where needed. Use native errors from
`mobilerun_core.errors`, or `UnsupportedOperation` from `mobilerun_core`.
- Pass devices to operators per call and extensions to the operator constructor.
Do not attach an operator or an extension registry to a device.
- In device action flows, use `await device.wait(seconds)` rather than
`asyncio.sleep`: recording captures device waits for macro replay.
- Use `async with` or `close()` for lifecycle cleanup. Release resources created
`asyncio.sleep`: recording captures device waits for macro replay. The screen
recorder's settle timer is host-only; an action hook must not call another
action on the same device.
- Use `async with` for core handles or `aclose()` when managing them manually.
Close framework resources through their own APIs. Release resources created
in this run, not resources supplied by ID; preserve ownership on reuse.
- Billing defaults to `paid`; `MOBILERUN_BILLING` changes the default and an
explicit `billing=` argument overrides both.
Respect guards in `mobilerun/clients/cloud/billing.py`; `no_commerce` blocks
Respect guards in `mobilerun/clients/cloud/billing_policy.py`; `no_commerce` blocks
purchases.
- Never expose secret values in logs, exceptions or representations. Cloud tasks
use vault references from `CloudCredentials`, not local credential values.
- CLI commands should prompt for missing values when interactive, confirm paid
or destructive actions, and support `--yes` and non-interactive operation.
Use the decorators in `mobilerun.cli.devices.base.device` so device commands
use core's approval gate. Do not approve unrelated operations.
Proxy replacement requires `--force` or interactive confirmation.
- No compatibility layer: use the current public API and CLI command paths; agent code comes from the `mobilerun-agents` add-on.

## Documentation
Expand Down
Loading
Loading