Cloud browsers, mobile devices and computers from Python.
-Verify is a thin [Revyl](https://revyl.com) SDK, not a test runner. Open a web browser, iOS simulator or Android emulator for natural-language instructions and validations, or an early-access Mac computer for commands, files, processes and screenshots. +Verify is a thin [Revyl](https://revyl.com) SDK, not a test runner. Open a web browser, iOS simulator or Android emulator for natural-language instructions and validations, or an early-access Mac computer for commands, files, processes, screenshots and, on a Mac opened with inference, validations and extracts. ## For coding agents @@ -90,6 +90,23 @@ asyncio.run(main()) `async_open` returns an `AsyncSession`. Its async methods adapt the synchronous implementation through worker threads, rather than introducing another HTTP stack. Cancelling a method schedules best-effort session close; cancelling open interrupts startup and attempts cleanup as soon as an identity is known. Cancellation does not forcibly terminate an in-flight thread or undo a remote operation; do not replay an uncertain mutation. Always close explicitly or use `async with await async_open(...)`. +### Read a value with extract() + +**Since 0.6.0.** `extract(text)` reads one value off the screen and returns a `StepResult` whose `value` is the string it read: + +```python +from revyl_verify import Target, open + +with open(Target(platform="ios", bundle_id="com.apple.Preferences")) as session: + session.instruction("Open General, then About") + version = session.extract("the iOS version number") + print(version.value) +``` + +Describe one value that is on the screen now, such as `"the order number on the confirmation"`. When nothing can be read, it raises `STEP_FAILED` with the reason and a hint on how to describe the value. It works on every session: on Web, iOS and Android it runs on Revyl's agent like `instruction()` and `validation()`, and on a Mac computer opened with `inference=True` it reads the Mac's own screen with the Mac's own model (see [validation() and extract() on a Mac](#validation-and-extract-on-a-mac)). A session opened with `model` or `agent` raises `INVALID_ARGUMENT`: read the value from `screenshot()` with your model instead. `AsyncSession.extract()` is the same, awaited. + +Every `StepResult` also has `engine`: `"local"` when the vision model of the Mac the step ran on or inside answered, `"hosted"` when Revyl's hosted model did, and `None` when Revyl doesn't say, as on ordinary Web, iOS and Android sessions. `value` is set on extract steps only. + ### Mac computer Mac computers are available to organizations on a current paid Revyl plan. If yours can't start one, ask support@revyl.ai: @@ -107,7 +124,7 @@ with open(Target(platform="mac", start_timeout=600)) as session: recording = session.recording() # after close; waits until the video is saved ``` -`exec(argv, stdin=bytes_or_string, timeout=30, check=True)` preserves argument boundaries and raises on command failure by default. File and process operations are computer-only. File paths are workspace-relative, not arbitrary absolute guest paths. To get the screen recording, call `recording()` after the computer is closed (after its `with` block or `close()`), on the same object and before your script exits: Revyl saves the video a few seconds after release, so it asks every 5 seconds until it is saved and returns `ComputerRecording(url, duration_seconds, started_at)`, or `None` if none was saved within `timeout` seconds (`recording(timeout=900)`, 15 minutes by default; 0 asks once; a check under way at that point can take up to 30 seconds more). Called on a computer that is still running it raises `SESSION_BUSY` saying to close it first. `attach()` can't reopen a closed computer, so a later process can't fetch it. Since 0.5.1; earlier versions returned `None` at once while the video was still uploading. It doesn't download the video. Signed URLs in that metadata are credentials. Recording is locally unavailable on devices. +`exec(argv, stdin=bytes_or_string, timeout=30, check=True)` preserves argument boundaries and raises on command failure by default. File and process operations are computer-only. File paths are workspace-relative, not arbitrary absolute guest paths. To get the screen recording, call `recording()` after the computer is closed (after its `with` block or `close()`), on the same object and before your script exits: Revyl saves the video a few seconds after release, so it asks every 5 seconds until it is saved and returns `ComputerRecording(url, duration_seconds, started_at)`, or `None` if none was saved within `timeout` seconds (`recording(timeout=900)`, 15 minutes by default; 0 asks once). A check already under way when `timeout` runs out can take up to 30 seconds more. Called on a computer that is still running it raises `SESSION_BUSY` saying to close it first. `attach()` can't reopen a closed computer, so a later process can't fetch it. Since 0.5.1; earlier versions returned `None` at once while the video was still uploading. It doesn't download the video. Signed URLs in that metadata are credentials. Recording is locally unavailable on devices. Since 0.4.0, a script can click, type and press keys on the computer's screen at points it reads off `screenshot()`: @@ -131,6 +148,38 @@ On a computer, as everywhere, type with `type("description", text)`: it clicks t **Breaking wire change:** computer-operation arguments use `argv_b64` (one padded URL-safe base64 UTF-8 string per argument) and file paths use `path_b64`, with no raw `argv` or `path`. This SDK is incompatible with the previous backend contract. Deploy the encoded-only backend before publishing or upgrading to this SDK. Public APIs and decoded limits are unchanged; `stdin` and file `data` retain their existing standard base64 encoding, and process commands are unchanged. Encoding is not encryption, and Verify does not fall back to plaintext or replay the request. +### validation() and extract() on a Mac + +**Since 0.6.0.** On a Mac opened with `inference=True`, `validation()` and `extract()` run on the Mac's own vision model, next to the computer, and their `StepResult` has `engine="local"`. A typical answer takes 1 to 3 seconds. Local inference is enabled per organization: ask support@revyl.ai. + +```python +from revyl_verify import Target, open + +with open(Target(platform="mac", inference=True)) as mac: + print(mac.inference) # "ready", "unavailable" or "unknown" + mac.validation("The Dock is visible at the bottom of the screen") + date = mac.extract("the date at the right end of the menu bar") + print(date.value, date.engine) # the date as shown, then "local" +``` + +- `validation(text, soft=False)` returns a `StepResult` with `passed`. A false statement raises `VALIDATION_FAILED`, unless you pass `soft=True`, which returns `passed=False`. +- `extract(text)` returns a `StepResult` whose `value` is the string read off the screen. Describe one value that is visible now. When the model finds nothing, it raises `STEP_FAILED` with the model's reason, such as `local_model_found_no_value`. +- An answer the model can't confirm is never a pass: it raises `STEP_FAILED`. Describe one thing that is visible on the screen now. +- Run one step at a time on a computer. The Mac's model also answers for the app sessions inside it, so a step that waits too long for it raises `SESSION_BUSY`, with `step_engine_busy` in the message; try again in a few seconds. While someone controls the screen in the viewer, a step raises `SESSION_BUSY` (`screen_control_held`); try again after they release it. +- `instruction()` stays unavailable on computers. It raises `NOT_AVAILABLE_ON_PLATFORM` and names the calls to use instead: `tap("the Save button")` to click one thing, and `type("the search field", text)` to type into a field. +- Your own `model` or `agent` doesn't run steps on computers; passing one raises `NOT_AVAILABLE_ON_PLATFORM`. + +`mac.inference` says whether the Mac's model answered: `"ready"`, `"unavailable"`, or `"unknown"` when Verify can't tell yet. Verify refreshes it whenever it reads the computer's report: at `open()`, `attach()` and `open_persistent()`, and on each `report()`. It is `None` on every other session, including a Mac opened without inference. + +| Error | When | What to do | +| --- | --- | --- | +| `NOT_AVAILABLE_ON_PLATFORM`, `reason="inference_not_enabled"` | `open()` with `inference=True`, and your organization doesn't have local inference | Ask support@revyl.ai to turn it on, or open the Mac without `inference` | +| `NOT_AVAILABLE_ON_PLATFORM`, `reason="inference_unavailable"` | No Mac with a model is up right now; nothing was started | Try again later, or open the Mac without `inference` | +| `NOT_AVAILABLE_ON_PLATFORM`, `reason="step_engine_unavailable"` | `validation()` or `extract()` on a Mac opened without inference; on a Linux computer, before anything is sent; or on a Mac opened with inference whose model isn't answering | Open the Mac with `Target(platform="mac", inference=True)`. If it already was, check `mac.inference` and try again shortly | +| `INVALID_ARGUMENT` | `inference=True` on a Linux target | Use `Target(platform="mac", inference=True)` | + +[`examples/mac_inference.py`](https://github.com/RevylAI/verify/blob/main/python/examples/mac_inference.py) runs these steps, and with `IOS_APP_ID` and `IOS_BUILD_ID` set also an iOS app inside the Mac (`cd python && uv run python examples/mac_inference.py`). It starts a billable Mac computer. The [Mac model checks guide](https://github.com/RevylAI/verify/blob/main/packages/verify/docs/guides/mac-model-checks.md) has more. + ### Attach and open a hosted browser Attach to an existing active computer with `attach(computer_id)`, or create one with `open(Target(platform="mac"))`. Attaching checks its identity, operating system and unexpired active report without creating or stopping anything on failure. A successful attach takes close ownership by default: exiting its context stops that computer, not merely the local handle. @@ -152,14 +201,47 @@ with attach("aaaaaaaa-bbbb-4ccc-8ddd-eeeeeeeeeeee", stop_on_close=False) as comp Use real IDs from the same authorized environment; these are placeholders. `stop_on_close=False` leaves a computer you don't own running when the context exits; leave it out only for a computer your script owns. To reach `http://localhost: