Skip to content
Merged
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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 69 additions & 2 deletions api/device-sessions.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ To get a `binaryUploadId`, upload the build with [`dcd upload`](../cli/dcd-uploa
|---|---|
| `POST /device/sessions/:id/install` | Install a build: `{ "binaryUploadId": "..." }`, or `{ "url": "https://..." }` for an `.apk` or a zipped simulator `.app` at a link (up to 500 MB). It installs in the background. A command sent meanwhile waits up to 45 s for it, then answers `LIVE_NOT_READY` |
| `POST /device/sessions/:id/launch` | Launch an app: `{ "appId"?: "...", "clearState"?: true }`. Without `appId`, the installed build |
| `POST /device/sessions/:id/actions` | One action: `tap` (`x`/`y` percent, `text` or `id`), `type` (`text`, and `sensitive: true` to keep it secret), `swipe` (`direction`: `up`, `down`, `left` or `right`, or `from`/`to` points in percent), `press_key` (`key`: `back`, `home`, `enter`, `backspace`, `tab`, and on Android `volume_up`, `volume_down`, `lock` or `power`). Answered once the screen has settled. `text` and `id` are matched whole, ignoring case. A `tap` on something that is not on screen waits about 17 s before it fails |
| `POST /device/sessions/:id/actions` | One action: `tap` (`x`/`y` percent, `text` or `id`), `type` (`text`, and `sensitive: true` to keep it secret), `swipe` (`direction`: `up`, `down`, `left` or `right`, or `from`/`to` points in percent), `press_key` (`key`: `back`, `home`, `enter`, `backspace`, `tab`, and on Android `volume_up`, `volume_down`, `lock` or `power`), `open_link` (`url`: see [links](#links)) or `set_location` (`latitude`, `longitude`: see [location](#location)). Answered once the screen has settled. `text` and `id` are matched whole, ignoring case. A `tap` on text or an id that is not on screen waits for it, 17 s unless `timeoutSeconds` (0 to 60) says otherwise, and then fails. `0` looks at the screen once |
| `POST /device/sessions/:id/run` | Run a Maestro flow, within [what a session runs](#what-a-session-runs): `{ "yaml": "..." }` for one flow, or `{ "flowUploadId": "...", "flow"?: "..." }` for a [flow bundle](#flow-bundles). `env` passes [secrets and variables](#secrets). Waits up to 110 s, or `waitSeconds` (0 to 300), then answers `running` with a `command_id`. A failed run's result includes `screen_text`, the app's visible text after the failure |
| `GET /device/sessions/:id/commands/:commandId` | The status and result of a `run` that answered `running`. `?waitSeconds=` (0 to 300) waits for it to finish instead of answering at once |
| `GET /device/sessions/:id/inspect` | The screen as compact JSON. On Android, the on-screen keyboard and the System UI are left out unless you add `?all=true`. Some apps also drop their own fields from the tree while a keyboard is open, and `all` cannot bring them back: hide the keyboard first (`run` with `- hideKeyboard`), then inspect again |
Expand All @@ -92,6 +92,73 @@ To get a `binaryUploadId`, upload the build with [`dcd upload`](../cli/dcd-uploa

A session runs the common Maestro commands, but not flow scripts, and a few things differ by platform. [What a session runs](../mcp/agent-devices.md#what-a-session-runs) in Agent Devices lists them.

## Links

`open_link` opens a link the way the device would if someone tapped it:

```json
{ "type": "open_link", "url": "myapp://orders/42" }
```

- A link your app handles opens in your app: its own scheme, such as `myapp://orders/42`, or a web link it claims.
- Any other web link opens in the browser: Chrome on Android, Safari on iOS.
- When nothing on the device opens the link, the action fails and says so.

The action answers once the link has opened. `inspect` next shows where it led. On iOS the session then works on whichever app the link brought to the front.

The first link of a session can meet a screen that is shown only once:

- **iOS, a link into your app.** iOS asks "Open in “Your App”?" the first time. The action presses **Open** for you, and its result says so.
- **Android, a web link.** Chrome opens on its welcome screens. Tap **Use without an account**, then **No thanks**, and the page is behind them.
- **iOS, a web link.** Safari may cover the page with a tip. Tap **Close**.

A link into your app takes about a second on Android and 3 to 4 seconds on iOS. The first web link starts the browser, which takes 2 to 3 seconds on Android and 10 seconds or more on iOS.

A sign-in link is a credential. Send it with `"sensitive": true` and it is encrypted before it is stored and never shown in the timeline, like a sensitive `type`.

A flow's `openLink` is not the same thing: it opens the link inside the flow's app. See [What a session runs](../mcp/agent-devices.md#what-a-session-runs).

## Location

`set_location` sets the device's GPS position, in decimal degrees. South and west are negative:

```json
{ "type": "set_location", "latitude": 51.5074, "longitude": -0.1278 }
```

- It applies to the whole device, and stays until you set another or the session ends. Leaving an app, relaunching it, and `launch` with `clearState` all keep it.
- An app that is watching the position gets a new one within about 2 seconds. An app that asks later gets it when it asks.
- An app reads it only once it has the location permission, and gets nothing without it. `launch` grants your app every permission.
- Values are kept to six decimal places. iOS gives an app all six. Android gives about five: `51.507351` reads as `51.50735`.
- A position within `0.0001` of `0, 0` on both axes is refused, because a device takes 0, 0 to mean no position. One axis at 0 is fine, such as `0, 10`.

Until you set a position, an iOS app that asks is told the position is unavailable, and an Android app gets the emulator's own default, in California. Every session starts on a new device, so nothing carries over from an earlier one.

A web page reads the position through the browser, and the browser asks first. On Android, give Chrome the permission in a flow, and Chrome then asks for the site (**Allow while visiting the site**):

```yaml
appId: com.android.chrome
---
- setPermissions:
appId: com.android.chrome
permissions:
location: allow
```

On iOS, Safari asks twice: **Allow While Using App** for Safari, then **Allow** for the site.

## Permissions

`launch` grants the app every permission. To deny one, or to see the app ask for it, set it in a flow before the app needs it:

```yaml
- setPermissions:
permissions:
notifications: deny
```

A permission is `allow`, `deny` or `unset`, and `unset` makes the app ask again. The names are `all`, `camera`, `microphone`, `photos`, `contacts`, `notifications`, `calendar`, `location`, `medialibrary`, `motion`, `reminders` and `siri`. `launchApp` takes the same `permissions`. A permission the app doesn't declare fails the step, and the error names it.

## Flow bundles

To run several flows, or a flow that runs others, upload them as a zip, then pass its id to `run` as `flowUploadId`. `flow` names the entry file inside the zip; without it, every flow runs. [`dcd device run <directory>`](../cli/dcd-device.md) does this for you.
Expand Down Expand Up @@ -124,7 +191,7 @@ Taking control of a device is for people in the console. While someone has contr

`env` on `run` is an object of names to string values: up to 50 of them, each up to 4096 characters. Names are up to 64 letters, digits and `_`, and don't start with a digit. Names starting with `DCD_`, in any case, are reserved. Refer to them in the YAML as `${NAME}`. They're encrypted before they're stored, never shown in the timeline, and masked in the command's output and in `inspect`.

A `type` action with `sensitive: true` sends its text the same way.
A `type` action with `sensitive: true` sends its text the same way, and an `open_link` action its link.

## Rate limits

Expand Down
26 changes: 24 additions & 2 deletions cli/dcd-device.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,13 +101,14 @@ Save a screenshot. `-o <file>` sets where (default `./<session>-<time>.jpg`). Wi

## `dcd device tap [id]`

Tap one thing on the screen, by exactly one target. Answers once the screen has settled. A target that is not on screen waits about 17 seconds before it fails, so `dcd device inspect` first. A failed tap exits `2`.
Tap one thing on the screen, by exactly one target. Answers once the screen has settled. A `--text` or `--rid` that is not on screen is waited for, 17 seconds unless `--timeout` says otherwise, and then the tap fails. So `dcd device inspect` first, or give a short `--timeout` when the element may not be there. A failed tap exits `2`.

| Flag | Description |
|------|-------------|
| `--text <text>` | The element's text, label or hint, matched whole and ignoring case (not a regex) |
| `--rid <id>` | The element's resource id, `rid` in `dcd device inspect` |
| `--x <n> --y <n>` | A point, as percentages of the screen (0 to 100) |
| `--timeout <seconds>` | With `--text` or `--rid`: how long to wait for it to appear, from 0 to 60. `0` looks at the screen once and fails at once if it isn't there. Requires CLI 5.14.0 or later |

## `dcd device type [id] --text <text>`

Expand All @@ -123,7 +124,28 @@ Swipe across most of the screen in a direction (`up` scrolls the content up, dow

## `dcd device press-key [id] <key>`

Press a key: `back`, `home`, `enter`, `backspace`, `tab`, and on Android `volume_up`, `volume_down`, `lock` or `power`. `enter` submits the focused field. On Android `back` closes a keyboard or goes back; on iOS it uses the app's own back control when it has one. On iOS, `enter`, `backspace` and `tab` need a focused field.
Press a key: `back`, `home`, `enter`, `backspace`, `tab`, and on Android `volume_up`, `volume_down`, `lock` or `power`. `enter` submits the focused field. On Android `back` closes a keyboard or goes back. iOS has no back key: there `back` presses the app's own back button, or taps the top-left corner where one usually is, and fails if the screen doesn't change. It is navigation, not a way to close a keyboard: press `enter`, or tap outside the field. On iOS, `enter`, `backspace` and `tab` need a focused field.

## `dcd device open-link [id] <url>`

Open a link on the device, the way tapping it would. A link your app handles, such as `myapp://orders/42`, opens in your app. Any other web link opens in the browser. Nothing on the device opening the link is a failure, and exits `2`. See [links](../api/device-sessions.md#links) for what the first link of a session can meet. Requires CLI 5.14.0 or later.

`--sensitive` is for a link that carries a token, such as a sign-in link: it is stored encrypted, never shown in the timeline, and not printed.

```bash
dcd device open-link myapp://orders/42
dcd device open-link "https://example.com/welcome?token=..." --sensitive
```

Quote a link that has a `?` or an `&` in it, so your shell passes it whole.

## `dcd device set-location [id] --latitude <n> --longitude <n>`

Set the device's GPS position, in decimal degrees. South and west are negative. It stays until you set another or the session ends. A position at `0, 0` is refused. See [location](../api/device-sessions.md#location) for what an app then reads. Requires CLI 5.14.0 or later.

```bash
dcd device set-location --latitude 51.5074 --longitude -0.1278
```

Each of these sends one [typed action](../api/device-sessions.md). For several steps, an assertion, scrolling until something is visible, or launching an app, use `run`.

Expand Down
25 changes: 23 additions & 2 deletions mcp/agent-devices-tools.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ Read-only.

## `tap_on`

Tap one thing on the screen: an element by its text (txt or a11y from inspect_screen, matched whole and ignoring case, not as a regex), by its id (rid), or a point as x and y percentages of the screen. Give exactly one target. The fastest way to act: it answers once the screen has settled, usually well under a second. A target that is not on screen waits about 17 seconds before it fails, so inspect_screen first. For several steps or an assertion, use run.
Tap one thing on the screen: an element by its text (txt or a11y from inspect_screen, matched whole and ignoring case, not as a regex), by its id (rid), or a point as x and y percentages of the screen. Give exactly one target. The fastest way to act: it answers once the screen has settled, in about a second. A text or an id that is not on screen is waited for, 17 seconds unless timeout_seconds says otherwise, and then the tap fails: inspect_screen first, or give a short timeout_seconds when the element may not be there. For several steps or an assertion, use run.

| Input | Type | Required | Description |
|-------|------|----------|-------------|
Expand All @@ -132,6 +132,7 @@ Tap one thing on the screen: an element by its text (txt or a11y from inspect_sc
| `id` | string, up to 1000 characters | No | The element's resource id (rid in inspect_screen). |
| `x` | number, 0 to 100 | No | x as a percentage of the screen, 0 to 100. |
| `y` | number, 0 to 100 | No | y as a percentage of the screen, 0 to 100. |
| `timeout_seconds` | number, 0 to 60 | No | With text or id: how long to wait for it to appear before failing, in seconds. Default 17; 0 looks at the screen once. |

## `input_text`

Expand All @@ -156,13 +157,33 @@ Swipe across the screen: a direction (up scrolls the content up, i.e. down the p

## `press_key`

Press a device key: back, home, enter, backspace, tab, and on Android volume_up, volume_down, lock, power (an iOS simulator has no such buttons). enter submits the focused field; on Android back closes a keyboard or goes back, on iOS it uses the app's own back control when it has one. On iOS enter, backspace and tab need a focused field. Answers once the screen has settled.
Press a device key: back, home, enter, backspace, tab, and on Android volume_up, volume_down, lock, power (an iOS simulator has no such buttons). enter submits the focused field. On Android back closes a keyboard or goes back. iOS has no back key: back presses the app's own back button, or taps the top-left corner where one usually is and fails if the screen does not change, so it is navigation, not a way to close the keyboard (press enter, or tap outside the field). On iOS enter, backspace and tab need a focused field. Answers once the screen has settled.

| Input | Type | Required | Description |
|-------|------|----------|-------------|
| `session_id` | string | No | The session id from start_device, e.g. "brave-teal-otter". Optional when your organization has exactly one open session. |
| `key` | `back`, `home`, `enter`, `backspace`, `tab`, `volume_up`, `volume_down`, `lock` or `power` | Yes | Which key. |

## `open_link`

Open a link on the device, as tapping it would: a web link opens in the app that claims it, or else in the browser, and an app link such as myapp://path opens in its app. Use it to go straight to a screen, or to sign a test user in by link. It fails when nothing on the device opens the link. With sensitive: true the link is stored encrypted and never shown: use it when the link carries a token. Answers once the link has opened; inspect_screen next to see where it led.

| Input | Type | Required | Description |
|-------|------|----------|-------------|
| `session_id` | string | No | The session id from start_device, e.g. "brave-teal-otter". Optional when your organization has exactly one open session. |
| `url` | string, up to 2048 characters | Yes | The link with its scheme, e.g. "https://example.com/page" or "myapp://path". No spaces: percent-encode them. |
| `sensitive` | boolean | No | The link is a secret: it carries a token or a code. Default false. |

## `set_location`

Set where the device is: the GPS position its apps read, in decimal degrees. It applies to the whole device and stays until you set another or the session ends. An app reads it only if it has location permission, which launch_app grants. Answers once the device has taken the position.

| Input | Type | Required | Description |
|-------|------|----------|-------------|
| `session_id` | string | No | The session id from start_device, e.g. "brave-teal-otter". Optional when your organization has exactly one open session. |
| `latitude` | number, -90 to 90 | Yes | Decimal degrees, north positive, e.g. 51.5074. |
| `longitude` | number, -180 to 180 | Yes | Decimal degrees, east positive, e.g. -0.1278. |

## `run`

Run a Maestro flow on the device: `yaml` is one flow (a header naming the app, `---`, then commands), run whole. Or `flow_upload_id` runs an uploaded zip of flows (`flow` names the entry file; omitted, all of them run). For a single tap, swipe, key or typed text prefer tap_on, swipe, press_key and input_text, which are faster; use run for several steps, assertions, scrolling until something is visible, or launching an app. A device session runs the common Maestro commands and no flow scripts (runScript, evalScript, JavaScript conditions): cheat_sheet lists what it runs. A command it does not run fails the flow before its first step, with its line. Waits up to 110s (wait_seconds changes it); a longer flow answers status "running" with a command_id: call get_command_status with wait: true. A failed run's result has screen_text, the app's visible text after the failure, and failed_at: the file, line and command that failed.
Expand Down
Loading
Loading