From 8eb85df6d82ca58119b51940332478d0227ae1a5 Mon Sep 17 00:00:00 2001 From: finalerock44 Date: Thu, 12 Nov 2026 17:55:36 +0000 Subject: [PATCH] docs(agent-devices): what a device session runs, now that it runs on agent-device Device sessions run flows on a Maestro-compatible engine rather than on Maestro. `run` still takes Maestro YAML, so the pages say what a session runs and what it does not: - A "What a session runs" section on the Agent Devices page and the device sessions API page: the supported commands, no flow scripts, that an unsupported command fails before the first step, that iOS works on the app in front (nothing on the home screen, no lock, power or volume keys), and that Android eraseText must be at the top level of a flow. - The tool reference and agent instructions match the hosted MCP server's new `run` and `cheat_sheet` descriptions. - openapi.yaml: the same wording on POST /device/sessions/{id}/actions, /run and the press_key schema. No path or schema changes. Hold until the engine change is in production. --- api/device-sessions.md | 17 +++++++++++++++-- mcp/agent-devices-skill.md | 4 ++-- mcp/agent-devices-tools.md | 4 ++-- mcp/agent-devices.md | 15 +++++++++++++++ public/openapi.yaml | 22 ++++++++++++++-------- 5 files changed, 48 insertions(+), 14 deletions(-) diff --git a/api/device-sessions.md b/api/device-sessions.md index 80df63d..519b8fd 100644 --- a/api/device-sessions.md +++ b/api/device-sessions.md @@ -20,13 +20,26 @@ 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`, `volume_up`, `volume_down`, `lock` or `power`) | -| `POST /device/sessions/:id/run` | Run Maestro: `{ "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 | +| `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`) | +| `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 | | `GET /device/sessions/:id/screenshot` | The screen as it is now, as a JPEG data URL. `fresh` is `false` when no new frame came within 3 s, so this is the latest there is | | `GET /device/sessions/:id/logs` | The installed app's recent device log lines. `lines` (default 200, at most 2000), `level` (`warning` or `error`) and `grep` (any case) narrow them. The answer stops at 24 KB, with `truncated: true` when older lines were left out | +## 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`. + +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. + +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. +- **Android.** `eraseText` must be at the top level of a flow, not inside `runFlow`, `repeat` or `retry`. + ## 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. diff --git a/mcp/agent-devices-skill.md b/mcp/agent-devices-skill.md index 5c60478..a0aa5f2 100644 --- a/mcp/agent-devices-skill.md +++ b/mcp/agent-devices-skill.md @@ -11,7 +11,7 @@ Codex, Cursor, Claude Code and most other agents read an `AGENTS.md` file at the Use the DeviceCloud MCP tools to check app changes on a real iOS simulator or Android emulator. -1. Call `cheat_sheet` once for Maestro syntax. +1. Call `cheat_sheet` once: it lists the Maestro commands a session runs. 2. `start_device` with the platform (`list_devices` shows the models). Give the user the session's `monitor_url`, where they can watch. A queued session is normal: it starts on its own. Until it is ready, call `get_device_status` with `wait: true`. 3. `install_app`, then `get_device_status` with `wait: true` until the install is done, then `launch_app`. 4. Loop: `inspect_screen` to see what is on screen, then `run` with Maestro commands to act, then `inspect_screen` again. Target elements by their text or id from `inspect_screen`, not by coordinates. Use `take_screenshot` when the layout matters. If the app's own fields are missing from `inspect_screen` while a keyboard is open, hide it (`run` with `- hideKeyboard`) and inspect again. @@ -34,7 +34,7 @@ description: Check app changes on a real cloud iOS simulator or Android emulator # Testing on a DeviceCloud device -1. Call `cheat_sheet` once for Maestro syntax. +1. Call `cheat_sheet` once: it lists the Maestro commands a session runs. 2. `start_device` with the platform, and give the user the session's `monitor_url`. A queued session starts on its own: call `get_device_status` with `wait: true` until it is ready. 3. `install_app` (with `app_path` for a local build when using `dcd mcp`), wait with `get_device_status` until it is installed, then `launch_app`. 4. Loop: `inspect_screen`, then `run` with Maestro commands, then `inspect_screen` again. Target elements by text or id, not coordinates. If the app's fields are missing while a keyboard is open, hide it (`- hideKeyboard`) and inspect again. diff --git a/mcp/agent-devices-tools.md b/mcp/agent-devices-tools.md index 99fdfb0..2fcac2c 100644 --- a/mcp/agent-devices-tools.md +++ b/mcp/agent-devices-tools.md @@ -120,7 +120,7 @@ Read-only. ## `run` -Run Maestro 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). 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. See cheat_sheet for syntax. +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). 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. See cheat_sheet for syntax. | Input | Type | Required | Description | |-------|------|----------|-------------| @@ -177,7 +177,7 @@ Read-only. ## `cheat_sheet` -Maestro syntax and how to work with DeviceCloud device sessions. Read it before your first run. +How to work with DeviceCloud device sessions, and the Maestro commands a session runs. Read it before your first run. Read-only. diff --git a/mcp/agent-devices.md b/mcp/agent-devices.md index 9b02f20..6e86ae2 100644 --- a/mcp/agent-devices.md +++ b/mcp/agent-devices.md @@ -115,6 +115,21 @@ Every response carries a short **session** block: the session's state, how long The full list of tools is in the [tool reference](agent-devices-tools.md). To teach your agent this loop, add the [agent instructions](agent-devices-skill.md) to your project. +## 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`. + +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. + +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. +- **Android.** `eraseText` must be at the top level of a flow, not inside `runFlow`, `repeat` or `retry`. + +The agent is told all of this by the `cheat_sheet` tool. + ## When the agent needs a person Some things only a person can do: enter a 2FA code, solve a CAPTCHA, approve a payment sheet. The agent calls `request_human` with what it needs, and then: diff --git a/public/openapi.yaml b/public/openapi.yaml index 8cc20de..db4a361 100644 --- a/public/openapi.yaml +++ b/public/openapi.yaml @@ -1422,9 +1422,10 @@ paths: operationId: performAction summary: Perform one action description: >- - Sends one action to the device: `tap`, `type`, `swipe` or `press_key`. Each becomes one Maestro - command. The request waits for it to finish, up to 120 s, after waiting up to 45 s for a device that - is still starting or installing. An action that fails on the device still answers 201, with + Sends one action to the device: `tap`, `type`, `swipe` or `press_key`. The request waits for it to + finish, up to 120 s, after waiting up to 45 s for a device that is still starting or installing. A + `tap` on text or an id that is not on screen waits about 17 s for it before it fails. On iOS an + action goes to the app in front: on the home screen it is refused, so launch an app first. An action that fails on the device still answers 201, with `result.success` false. A `type` action with `sensitive: true` sends its text as a secret: it never appears in the timeline and is masked in `inspect`. parameters: @@ -1595,8 +1596,11 @@ paths: operationId: runFlow summary: Run a Maestro flow description: >- - Runs Maestro on the device: `yaml` for one flow, or `flowUploadId` for a flow bundle (`flow` names - the entry file; without it, every flow in the bundle runs). `env` passes secrets and variables. The + Runs a Maestro flow on the device: `yaml` for one flow, or `flowUploadId` for a flow bundle (`flow` + names the entry file; without it, every flow in the bundle runs). A session runs the common Maestro + commands and no flow scripts (`runScript`, `evalScript`, JavaScript conditions); a flow with a + command it does not run fails before its first step and names the line. `env` passes secrets and + variables. The request waits for the flow up to 110 s, or `waitSeconds`. A flow that takes longer answers `running` with a `command_id`: follow it with GET /device/sessions/{id}/commands/{commandId}. A failed run answers 201 with `status` `failed`; its result says where it failed and lists the app's visible text @@ -4145,7 +4149,9 @@ components: PressKeyAction: type: object - description: Press a device key. + description: >- + Press a device key. `volume_up`, `volume_down`, `lock` and `power` are Android only: an iOS + simulator has no such buttons. On iOS, `enter`, `backspace` and `tab` need a focused field. required: [type, key] properties: type: @@ -4183,7 +4189,7 @@ components: type: boolean output: type: string - description: What Maestro reported. Often a JSON document in a string. + description: What the device reported. Often a JSON document in a string. error: type: string description: Why it failed. @@ -4273,7 +4279,7 @@ components: output: type: string description: >- - Maestro's report, usually a JSON document in a string. Variable values are never included, and a + The run's report, usually a JSON document in a string. Variable values are never included, and a failed run's command count is left out. error: type: string