From 70a6273d73d5f78db235067fe8e43936b1488f25 Mon Sep 17 00:00:00 2001 From: finalerock44 Date: Tue, 17 Nov 2026 12:28:03 +0000 Subject: [PATCH 1/3] docs(devices): open_link, set_location and a wait on tap (draft) Draft: the reference parts follow the merged code. The links, location and permissions sections are to be checked against the dev tests before this is opened. --- api/device-sessions.md | 54 +++++++++++++++-- cli/dcd-device.md | 26 +++++++- mcp/agent-devices-tools.md | 25 +++++++- mcp/agent-devices.md | 12 ++-- public/openapi.yaml | 118 ++++++++++++++++++++++++++++++++++--- 5 files changed, 214 insertions(+), 21 deletions(-) diff --git a/api/device-sessions.md b/api/device-sessions.md index 0306918..f6c651c 100644 --- a/api/device-sessions.md +++ b/api/device-sessions.md @@ -20,7 +20,7 @@ A session is named by its `id` (for example `brave-teal-otter`) in every path. E |---|---| | `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. 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 | @@ -29,17 +29,61 @@ A session is named by its `id` (for example `brave-teal-otter`) in every path. E ## What a session runs -A session takes Maestro YAML and runs the common Maestro commands: `tapOn`, `doubleTapOn`, `longPressOn`, `inputText`, `eraseText`, `hideKeyboard`, `pressKey` (`Back`, `Home` and `Enter`), `swipe`, `scroll`, `scrollUntilVisible`, `assertVisible`, `assertNotVisible`, `extendedWaitUntil`, `waitForAnimationToEnd`, `launchApp`, `stopApp`, `killApp`, `clearState`, `openLink`, `takeScreenshot`, `back`, and `runFlow`, `repeat` and `retry`. +A session takes Maestro YAML and runs the common Maestro commands: `tapOn`, `doubleTapOn`, `longPressOn`, `inputText`, `eraseText`, `hideKeyboard`, `pressKey` (`Back`, `Home` and `Enter`), `swipe`, `scroll`, `scrollUntilVisible`, `assertVisible`, `assertNotVisible`, `extendedWaitUntil`, `waitForAnimationToEnd`, `launchApp`, `stopApp`, `killApp`, `clearState`, `setPermissions`, `openLink`, `takeScreenshot`, `back`, and `runFlow`, `repeat` and `retry`. -It doesn't run flow scripts: `runScript`, `evalScript`, or a JavaScript condition or expression. Only `${NAME}` variables from `env` are filled in. It also doesn't run `copyTextFrom`, `pasteText`, `inputRandom*`, `setLocation`, `travel` or `addMedia`, or other `pressKey` keys. A flow with a command it doesn't run fails before its first step, and the error names the line. +It doesn't run flow scripts: `runScript`, `evalScript`, or a JavaScript condition or expression. Only `${NAME}` variables from `env` are filled in. It also doesn't run `copyTextFrom`, `pasteText`, `inputRandom*`, `setLocation`, `travel` or `addMedia`, or other `pressKey` keys. A flow with a command it doesn't run fails before its first step, and the error names the line. To set the device's position, use the [`set_location` action](#location). + +A flow's `openLink` opens the link inside the flow's app. On Android a web link that app doesn't handle fails there. To open a link the way the device would, use the [`open_link` action](#links). + +`launch` grants the app every permission before it opens it, so no permission dialog covers its first screen, and a flow's `launchApp` does the same unless it sets `permissions` itself. See [permissions](#permissions) to deny one. These flows are run by a Maestro-compatible engine, not by Maestro itself. A [test run](../getting-started/quickstart.md) runs your flows on Maestro, so check a flow there before you rely on it there. Two things differ by platform: -- **iOS.** A session works on the app in front. On the home screen the screen reads as empty and a tap is refused, so launch an app first. When a tap opens another app, such as a link into Safari, the session follows it. `lock`, `power`, `volume_up` and `volume_down` aren't available on a simulator. +- **iOS.** A session works on the app in front. On the home screen the screen reads as empty and a tap is refused, so launch an app first. When a tap or a link opens another app, such as a link into Safari, the session follows it. There is 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 doesn't change. It doesn't close a keyboard. `lock`, `power`, `volume_up` and `volume_down` aren't available on a simulator. - **Android.** `eraseText` must be at the top level of a flow, not inside `runFlow`, `repeat` or `retry`. +## 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. + +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`. + +## 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. +- An app reads it only if it has the location permission. `launch` grants it. +- Values are kept to six decimal places. + +## 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 `](../cli/dcd-device.md) does this for you. @@ -72,7 +116,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 letters, digits and `_`, and don't start with a digit. Names starting with `DCD_` 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 diff --git a/cli/dcd-device.md b/cli/dcd-device.md index 9ed1f95..aff0fc0 100644 --- a/cli/dcd-device.md +++ b/cli/dcd-device.md @@ -101,13 +101,14 @@ Save a screenshot. `-o ` sets where (default `./-