From c780d5997b3358b4f5f648d93f25e6a5c851d450 Mon Sep 17 00:00:00 2001 From: anamhira47 <7093246+anamhira47@users.noreply.github.com> Date: Wed, 25 Nov 2026 05:51:14 +0000 Subject: [PATCH 1/8] Verify 0.7.1 / Python 0.5.1 / Go v0.6.1: no_focused_input maps to ACTION_FAILED, type({ target }) on computers and as the one typing rule, recording() waits for the video after close Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> --- CHANGELOG.md | 26 ++++++++- README.md | 17 +++--- examples/agent-platform/README.md | 2 +- examples/agent-platform/package.json | 2 +- examples/byo-model/package.json | 2 +- examples/mac-workspace/package.json | 2 +- examples/mobile-settings/package.json | 2 +- examples/web-cdp/package.json | 2 +- examples/web-store/package.json | 2 +- go/README.md | 53 ++++++++++------- go/actions.go | 8 +-- go/agent.go | 4 +- go/client.go | 2 +- go/computer.go | 77 ++++++++++++++++++++++--- go/computer_test.go | 8 ++- go/errors.go | 1 + go/examples/cdp/go.mod | 2 +- go/session.go | 2 + package-lock.json | 18 +++--- packages/revyl-verify/README.md | 2 +- packages/revyl-verify/package.json | 4 +- packages/verify/docs/agents.md | 8 +-- packages/verify/docs/api.md | 31 ++++++---- packages/verify/docs/computers.md | 23 +++++--- packages/verify/docs/errors.md | 5 +- packages/verify/docs/getting-started.md | 2 +- packages/verify/docs/llms.txt | 4 +- packages/verify/docs/mobile.md | 9 +-- packages/verify/docs/own-model.md | 4 +- packages/verify/docs/web.md | 14 ++--- packages/verify/package.json | 2 +- packages/verify/src/agent/loop.ts | 4 +- packages/verify/src/computer-session.ts | 44 ++++++++++---- packages/verify/src/errors.ts | 2 +- packages/verify/src/session.ts | 12 ++-- packages/verify/test/computer.test.ts | 4 +- python/README.md | 35 +++++------ python/pyproject.toml | 2 +- python/src/revyl_verify/__init__.py | 2 +- python/src/revyl_verify/_agent.py | 8 ++- python/src/revyl_verify/_async.py | 4 +- python/src/revyl_verify/_computer.py | 63 ++++++++++++++++---- python/src/revyl_verify/_login.py | 2 +- python/src/revyl_verify/_session.py | 15 ++++- python/src/revyl_verify/_transport.py | 3 +- python/tests/test_computer.py | 2 +- python/tests/test_release.py | 24 ++++---- python/tests/wheel_smoke.py | 2 +- python/uv.lock | 2 +- 49 files changed, 387 insertions(+), 183 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 032f798..94bec72 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,10 +1,30 @@ # Changelog -## Unreleased +## 0.7.1 (unreleased) +- Web: `typeFocused()` with no text field focused throws `ACTION_FAILED` with the new reason `no_focused_input` and the message `Nothing was typed: no text field has focus (no_focused_input). Use type({ target: 'the email field' }, text), which taps the field and types into it, or tap the field first.` Revyl answers this with HTTP 409, which 0.7.0 reported as `SESSION_BUSY`, so a script or agent gave up on a call it could fix. Your own model's loop now feeds the message back to the model instead of ending the step, because `ACTION_FAILED` doesn't abort it. A session that really is busy, such as a second step while one runs, still throws `SESSION_BUSY`. +- Typing has one rule on every platform: `type({ target }, text)`. Mac computers now take `type(at, text, { clear })`: it clicks the field (a description or a point), selects its text with Command+A (Ctrl+A on Linux) unless `clear` is `false`, types, and resolves with the point clicked. It refuses control characters other than `\n` and `\t` before clicking. `typeFocused()` on iOS and Android still throws `NOT_AVAILABLE_ON_PLATFORM` before anything is sent, now naming `type({ target: 'the email field' }, text)`. The README, the API page and the web, mobile, computers, errors and agents pages teach `type({ target }, text)` as the way to type everywhere, and your own model's tool list describes `type` as the way to type and `type_focused` as needing a focused field. +- Computers: `recording()` after `close()` waits until Revyl has saved the video, asking every 5 seconds, and returns it; it returns `null` only when none was saved within `timeoutMs` (`recording({ timeoutMs })`, 15 minutes by default, 0 to ask once). Revyl saves the video a few seconds after release, so 0.7.0's `recording()` right after `close()` returned `null`, and `attach()` can't reopen a closed computer to fetch it later. Called on a running computer it still throws `SESSION_BUSY`, now saying to call `close()` first. The docs say to call `recording()` on the same object after `close()`, before the script exits. +- Docs: session profiles run on Revyl's production backend, so the API page and the Python and Go READMEs no longer say a profile name is refused there (#66). - Computers: a Mac computer create that Revyl refuses with `computer_not_enabled` and `unlocks_with_card: true`, as it does for a Free-plan organization, throws `NOT_AVAILABLE_ON_PLATFORM` with the new reason `upgrade_required` instead of no reason and the generic support guidance. The message reads `Mac computers come with Pro, so Revyl refused this computer (computer_not_enabled, upgrade_required).`, then Revyl's upgrade offer and billing link (`: `) when Revyl sends one with an HTTPS link and a single-line message of at most 160 characters, and otherwise `Add a card in Revyl's billing settings to unlock them.` `open()` adds the session link as before; `openPersistent()` refuses the same way. The code is unchanged, the create is still not retried and no stop is sent, and any other `computer_not_enabled` refusal keeps its current message. -- Python: the same, with `reason="upgrade_required"` on `open()` and `open_persistent()`. -- Go: the same, with `Reason` `ReasonUpgradeRequired` on `Open` and `OpenPersistent`. + +## Go 0.6.1 (unreleased) + +To be published as the `go/v0.6.1` tag. + +- Web: `TypeFocused` with no text field focused returns `ErrActionFailed` with `Reason` `ReasonNoFocusedInput` and a message naming `session.Type(ctx, verify.Element("the email field"), text)`, as in TypeScript 0.7.1, instead of `ErrSessionBusy`. A session that really is busy still returns `ErrSessionBusy`. +- `Type(ctx, at, text, TypeOptions{Clear})` works on Mac computers, as in TypeScript 0.7.1. `TypeFocused` on iOS and Android names `Type(ctx, verify.Element(…), text)`. +- Computers: `Recording(ctx)` after `Close` waits until Revyl has saved the video, for up to 15 minutes or `ctx`'s deadline, as in TypeScript 0.7.1; it returns `(nil, nil)` only when none was saved by then, and `ctx.Err()` when `ctx` is canceled. +- A Mac computer create refused with `computer_not_enabled` and `unlocks_with_card: true` returns `ErrNotAvailableOnPlatform` with `Reason` `ReasonUpgradeRequired` on `Open` and `OpenPersistent`, as in TypeScript 0.7.1. +- `verify.Version` and the `User-Agent` report 0.6.1. + +## Python 0.5.1 (unreleased) + +- Web: `type_focused()` with no text field focused raises `ACTION_FAILED` with `reason="no_focused_input"` and a message naming `type("the email field", text)`, as in TypeScript 0.7.1, instead of `SESSION_BUSY`. A session that really is busy still raises `SESSION_BUSY`. +- `type(at, text, clear=True)` works on Mac computers, as in TypeScript 0.7.1. `type_focused()` on iOS and Android names `type("the email field", text)`. +- Computers: `recording(timeout=900)` after the computer is closed waits until Revyl has saved the video, as in TypeScript 0.7.1, and returns `None` only when none was saved within `timeout` seconds. `AsyncSession.recording()` takes `timeout` too. +- A Mac computer create refused with `computer_not_enabled` and `unlocks_with_card: true` raises `NOT_AVAILABLE_ON_PLATFORM` with `reason="upgrade_required"` on `open()` and `open_persistent()`, as in TypeScript 0.7.1. +- The `User-Agent` reports 0.5.1. ## 0.7.0 (2026-11-23) diff --git a/README.md b/README.md index 9c1365d..0f5d2b6 100644 --- a/README.md +++ b/README.md @@ -60,7 +60,9 @@ await session.instruction('Accept the terms if they are shown'); // the age await session.validation('The welcome screen is shown'); ``` -`doubleTap`, `typeFocused`, `back`, `goHome`, `openUrl`, `launchApp`, `locate` and `screenSize` round them out; [which call works where](#which-call-works-where) shows the platform limits. Early access. Since TypeScript (`@revyl/verify`) 0.4.0, Python (`revyl-verify`) 0.2.0 and Go v0.3.0. `doubleTap`, `longPress`, `drag`, `typeFocused`, `goHome`, and Web keys and modifiers in `pressKey`, are new in TypeScript 0.5.0, Python 0.3.0 and Go v0.4.0. On a Mac computer's screen, `tap` (by point or by description), `screenSize`, `typeFocused` and `pressKey` are new in TypeScript 0.6.0, Python 0.4.0 and Go v0.5.0. The [Python](https://github.com/RevylAI/verify/blob/v0.7.0/python/README.md#exact-actions) and [Go](https://github.com/RevylAI/verify/blob/v0.7.0/go/README.md#exact-actions) READMEs show them with each language's names. The [web](packages/verify/docs/web.md#exact-actions) and [mobile](packages/verify/docs/mobile.md#exact-actions) guides have runnable scripts, and [api.md](packages/verify/docs/api.md#exact-actions) lists every call. +**Typing: one rule on every platform.** To type, call `type({ target: 'Email field' }, text)`: it taps the field you describe and types into it, replacing its text unless you pass `{ clear: false }`. It works the same on Web, iOS, Android and a Mac computer. `typeFocused(text)` types wherever focus already is, without tapping, and only on Web and computers; on Web, when no field has focus it throws `ACTION_FAILED` with reason `no_focused_input` and types nothing. + +`doubleTap`, `typeFocused`, `back`, `goHome`, `openUrl`, `launchApp`, `locate` and `screenSize` round them out; [which call works where](#which-call-works-where) shows the platform limits. Early access. Since TypeScript (`@revyl/verify`) 0.4.0, Python (`revyl-verify`) 0.2.0 and Go v0.3.0. `doubleTap`, `longPress`, `drag`, `typeFocused`, `goHome`, and Web keys and modifiers in `pressKey`, are new in TypeScript 0.5.0, Python 0.3.0 and Go v0.4.0. On a Mac computer's screen, `tap` (by point or by description), `screenSize`, `typeFocused` and `pressKey` are new in TypeScript 0.6.0, Python 0.4.0 and Go v0.5.0, and `type` in TypeScript 0.7.1, Python 0.5.1 and Go v0.6.1. The [Python](https://github.com/RevylAI/verify/blob/v0.7.1/python/README.md#exact-actions) and [Go](https://github.com/RevylAI/verify/blob/v0.7.1/go/README.md#exact-actions) READMEs show them with each language's names. The [web](packages/verify/docs/web.md#exact-actions) and [mobile](packages/verify/docs/mobile.md#exact-actions) guides have runnable scripts, and [api.md](packages/verify/docs/api.md#exact-actions) lists every call. ## Your own model @@ -74,7 +76,7 @@ await session.instruction('Open Privacy', { model: 'openai/gpt-5.5' }); await open('ios', { model: { id: 'qwen-3.8-27b', baseURL: 'https://api.cerebras.ai/v1', apiKey: process.env.CEREBRAS_API_KEY } }); ``` -Since TypeScript (`@revyl/verify`) 0.4.0, Python (`revyl-verify`) 0.2.0 and Go v0.3.0; the [Python](https://github.com/RevylAI/verify/blob/v0.7.0/python/README.md#your-own-model) and [Go](https://github.com/RevylAI/verify/blob/v0.7.0/go/README.md#your-own-model) READMEs show them with each language's names. Built in: `anthropic`, `openai`, `google`, `openrouter`, `groq`, `cerebras`, `xai` and `ollama`; anything OpenAI-compatible works through `baseURL`. Early access; [Use your own model](packages/verify/docs/own-model.md) covers the providers, picking a model, what Revyl still sees, limits and troubleshooting. +Since TypeScript (`@revyl/verify`) 0.4.0, Python (`revyl-verify`) 0.2.0 and Go v0.3.0; the [Python](https://github.com/RevylAI/verify/blob/v0.7.1/python/README.md#your-own-model) and [Go](https://github.com/RevylAI/verify/blob/v0.7.1/go/README.md#your-own-model) READMEs show them with each language's names. Built in: `anthropic`, `openai`, `google`, `openrouter`, `groq`, `cerebras`, `xai` and `ollama`; anything OpenAI-compatible works through `baseURL`. Early access; [Use your own model](packages/verify/docs/own-model.md) covers the providers, picking a model, what Revyl still sees, limits and troubleshooting. ## Packages @@ -82,7 +84,7 @@ Since TypeScript (`@revyl/verify`) 0.4.0, Python (`revyl-verify`) 0.2.0 and Go v | --- | --- | --- | | [`@revyl/verify`](https://www.npmjs.com/package/@revyl/verify) | `npm install @revyl/verify` | TypeScript SDK and the `verify` CLI (`init`, `login`, `logout`, `whoami`). Published on npm, Node.js 22.18 or later. | | [`revyl-verify`](https://www.npmjs.com/package/revyl-verify) (npm) | `npm install revyl-verify` | Alias of `@revyl/verify` at the same version. | -| [Go module](https://github.com/RevylAI/verify/tree/go/v0.6.0/go) | `go get github.com/RevylAI/verify/go@v0.6.0` | Published as the `go/v0.6.0` tag, Go 1.26.9 or later. Calls return errors instead of throwing. | +| [Go module](https://github.com/RevylAI/verify/tree/go/v0.6.1/go) | `go get github.com/RevylAI/verify/go@v0.6.1` | Published as the `go/v0.6.1` tag, Go 1.26.9 or later. Calls return errors instead of throwing. | | [`revyl-verify`](https://pypi.org/project/revyl-verify/) (PyPI) | `pip install revyl-verify` or `uv add revyl-verify` | Python SDK, published on PyPI. Python 3.10 or later, sync and asyncio APIs, no CLI; see the [Python guide](python/README.md). | ## Platforms @@ -92,7 +94,7 @@ Since TypeScript (`@revyl/verify`) 0.4.0, Python (`revyl-verify`) 0.2.0 and Go v | Web | Yes | Yes | — | Yes | | iOS simulator | Yes | Yes | — | Yes | | Android emulator | Yes | Yes | — | Yes | -| Mac computer | — | Screen: `tap`, `typeFocused`, `pressKey` | Yes | Yes | +| Mac computer | — | Screen: `tap`, `type`, `typeFocused`, `pressKey` | Yes | Yes | ### Which call works where @@ -100,9 +102,10 @@ Since TypeScript (`@revyl/verify`) 0.4.0, Python (`revyl-verify`) 0.2.0 and Go v | --- | --- | --- | --- | --- | | `tap({ x, y })`, `tap({ target })`, `screenSize` | Yes | Yes | Yes | Yes | | `locate` | Yes | Yes | Yes | No, use `tap({ target })`, which returns the point it clicked, or read the point off `screenshot()` | -| `doubleTap`, `longPress`, `type`, `swipe`, `drag` | Yes | Yes | Yes | No | +| `type({ target }, text)`, the way to type | Yes | Yes | Yes | Yes: clicks the field, selects its text unless `{ clear: false }`, then types | +| `doubleTap`, `longPress`, `swipe`, `drag` | Yes | Yes | Yes | No | | `pressKey(key, { modifiers })` | Yes: `'enter'`, `'backspace'`, `'tab'`, `'escape'`, arrows and more, with modifiers | `'enter'` and `'backspace'` only | `'enter'` and `'backspace'` only | Yes: the Web keys and modifiers, where `'meta'` is Command | -| `typeFocused(text, { clear })` | Yes, types into the focused field | No, use `type(location, text)` | No, use `type(location, text)` | Yes, with `{ clear: false }` | +| `typeFocused(text, { clear })` | Yes, types into the focused field; `ACTION_FAILED` (`no_focused_input`) when none has focus | No, use `type({ target }, text)` | No, use `type({ target }, text)` | Yes, with `{ clear: false }` | | `back()` | Yes, browser history | No, tap the on-screen back control | Yes, the system back button | No | | `goHome()` | No, use `openUrl` or `navigate` | Yes, the home screen | Yes, the home screen | No | | `openUrl(url)` | Yes, loads an http(s) URL in the tab | Yes, a URL or deep link | Yes, a URL or deep link | No | @@ -116,7 +119,7 @@ Since TypeScript (`@revyl/verify`) 0.4.0, Python (`revyl-verify`) 0.2.0 and Go v A call a platform doesn't support throws `NOT_AVAILABLE_ON_PLATFORM`, and its message names the alternative. -Web is available to every organization. Mac computers are available to organizations on a current paid Revyl plan and have a server-bounded lifetime; see [computers](packages/verify/docs/computers.md). +Web is available to every organization. Mac computers are available to organizations on a current paid Revyl plan and have a server-bounded lifetime; see [computers](packages/verify/docs/computers.md). To get a Mac computer's screen recording, call `await computer.close()` and then `await computer.recording()` on the same object, in the same process: it waits until Revyl has saved the video, usually a few seconds, and returns `{ url, durationSeconds?, startedAt? }`, or `null` if none was saved within `timeoutMs` (15 minutes by default). `attach()` can't reopen a closed computer, so fetch the recording before your script exits. ## Documentation diff --git a/examples/agent-platform/README.md b/examples/agent-platform/README.md index b379b46..c783b85 100644 --- a/examples/agent-platform/README.md +++ b/examples/agent-platform/README.md @@ -6,7 +6,7 @@ One task fans out to a cloud browser and an iOS simulator through `@revyl/verify You need Node.js **22.18+**, the [Revyl CLI](https://docs.revyl.com/cli), and a Revyl account with web and mobile session access. No Xcode, Android SDK, extra app IDs, or mobile builds are needed. -This checkout uses the local workspace SDK (**0.7.0**). From the repository root, install and build once, before loading any API credentials: +This checkout uses the local workspace SDK (**0.7.1**). From the repository root, install and build once, before loading any API credentials: ```sh npm ci diff --git a/examples/agent-platform/package.json b/examples/agent-platform/package.json index 969109e..108d823 100644 --- a/examples/agent-platform/package.json +++ b/examples/agent-platform/package.json @@ -10,7 +10,7 @@ "typecheck": "tsc -p tsconfig.json" }, "devDependencies": { - "@revyl/verify": "0.7.0", + "@revyl/verify": "0.7.1", "@types/node": "^22.10.0", "typescript": "^5.9.0" } diff --git a/examples/byo-model/package.json b/examples/byo-model/package.json index de67bb8..127fc3c 100644 --- a/examples/byo-model/package.json +++ b/examples/byo-model/package.json @@ -10,7 +10,7 @@ "typecheck": "tsc -p tsconfig.json" }, "devDependencies": { - "@revyl/verify": "0.7.0", + "@revyl/verify": "0.7.1", "@types/node": "^22.10.0", "typescript": "^5.9.0" } diff --git a/examples/mac-workspace/package.json b/examples/mac-workspace/package.json index b46007e..cf9ff3e 100644 --- a/examples/mac-workspace/package.json +++ b/examples/mac-workspace/package.json @@ -9,7 +9,7 @@ "typecheck": "tsc -p tsconfig.json" }, "devDependencies": { - "@revyl/verify": "0.7.0", + "@revyl/verify": "0.7.1", "@types/node": "^22.10.0", "typescript": "^5.9.0" } diff --git a/examples/mobile-settings/package.json b/examples/mobile-settings/package.json index 338ad74..59cc98b 100644 --- a/examples/mobile-settings/package.json +++ b/examples/mobile-settings/package.json @@ -10,7 +10,7 @@ "typecheck": "tsc -p tsconfig.json" }, "devDependencies": { - "@revyl/verify": "0.7.0", + "@revyl/verify": "0.7.1", "@types/node": "^22.10.0", "typescript": "^5.9.0" } diff --git a/examples/web-cdp/package.json b/examples/web-cdp/package.json index 4aebc3a..4fad296 100644 --- a/examples/web-cdp/package.json +++ b/examples/web-cdp/package.json @@ -9,7 +9,7 @@ "typecheck": "tsc -p tsconfig.json" }, "devDependencies": { - "@revyl/verify": "0.7.0", + "@revyl/verify": "0.7.1", "@types/node": "^22.10.0", "playwright-core": "^1.65.1", "typescript": "^5.9.0" diff --git a/examples/web-store/package.json b/examples/web-store/package.json index 49fc704..c2729cb 100644 --- a/examples/web-store/package.json +++ b/examples/web-store/package.json @@ -9,7 +9,7 @@ "typecheck": "tsc -p tsconfig.json" }, "devDependencies": { - "@revyl/verify": "0.7.0", + "@revyl/verify": "0.7.1", "@types/node": "^22.10.0", "typescript": "^5.9.0" } diff --git a/go/README.md b/go/README.md index 0f031a2..49edf14 100644 --- a/go/README.md +++ b/go/README.md @@ -9,10 +9,10 @@ Use Go 1.26.9 or later and a Revyl account. Set `REVYL_API_KEY` through your she The module lives in the repository's `go/` subdirectory. Install the tagged release with: ```sh -go get github.com/RevylAI/verify/go@v0.6.0 +go get github.com/RevylAI/verify/go@v0.6.1 ``` -Go releases use independent repository tags such as `go/v0.6.0`; npm versions do not version this module. Commit the resulting `go.mod` and `go.sum` in your app to pin dependencies. +Go releases use independent repository tags such as `go/v0.6.1`; npm versions do not version this module. Commit the resulting `go.mod` and `go.sum` in your app to pin dependencies. ## Quick start: iOS Settings @@ -21,7 +21,7 @@ This program opens the iOS Settings app on a cloud simulator, which every accoun ```sh mkdir verify-go && cd verify-go go mod init example.com/verify-go -go get github.com/RevylAI/verify/go@v0.6.0 +go get github.com/RevylAI/verify/go@v0.6.1 ``` Save this as `main.go`: @@ -235,9 +235,10 @@ Neither errors nor logs contain the script's content or output. Check the code w | --- | --- | --- | --- | --- | | `Tap` with a `verify.Point` or a `verify.Element`, `ScreenSize` | Yes | Yes | Yes | Yes | | `Locate` | Yes | Yes | Yes | No, tap a `verify.Element`, which returns the point it clicked, or read the point off `Screenshot` | -| `DoubleTap`, `LongPress`, `Type`, `Swipe`, `Drag` | Yes | Yes | Yes | No | +| `Type(ctx, verify.Element("…"), text)`, the way to type | Yes | Yes | Yes | Yes: clicks the field, selects its text unless `Clear` points to `false`, then types | +| `DoubleTap`, `LongPress`, `Swipe`, `Drag` | Yes | Yes | Yes | No | | `PressKey(ctx, key, KeyOptions{Modifiers})` | Yes: `KeyEnter`, `KeyBackspace`, `KeyTab`, `KeyEscape`, arrows and more, with modifiers | `KeyEnter` and `KeyBackspace` only | `KeyEnter` and `KeyBackspace` only | Yes: the Web keys and modifiers, where `ModifierMeta` is Command | -| `TypeFocused` | Yes, types into the focused field | No, use `Type(ctx, location, text)` | No, use `Type(ctx, location, text)` | Yes, with `Clear` pointing to `false` | +| `TypeFocused` | Yes, types into the focused field; `ErrActionFailed` (`no_focused_input`) when none has focus | No, use `Type(ctx, verify.Element("…"), text)` | No, use `Type(ctx, verify.Element("…"), text)` | Yes, with `Clear` pointing to `false` | | `Back` | Yes, browser history | No, tap the on-screen back control | Yes, the system back button | No | | `GoHome` | No, use `OpenURL` or `Navigate` | Yes, the home screen | Yes, the home screen | No | | `OpenURL` | Yes, loads an http(s) URL in the tab | Yes, a URL or deep link | Yes, a URL or deep link | No | @@ -252,7 +253,7 @@ Coordinates follow the rule in [Exact actions](#exact-actions). A call a platfor ## Exact actions -**Since Go `v0.3.0`. Early access.** Web, iOS and Android sessions take device actions that need no agent. `DoubleTap`, `LongPress`, `Drag`, `TypeFocused`, `GoHome`, and Web keys and modifiers in `PressKey`, are new in `v0.4.0`. `Tap` (with a point or an `Element`), `ScreenSize`, `TypeFocused` and `PressKey` on a Mac computer's screen are new in `v0.5.0`; see [Mac screen](#mac-screen). A location is a `verify.Point{X, Y}` in whole, non-negative screenshot pixels from the top-left corner, or a `verify.Element("Login button")` that Revyl's grounding model finds on the current screen. +**Since Go `v0.3.0`. Early access.** Web, iOS and Android sessions take device actions that need no agent. `DoubleTap`, `LongPress`, `Drag`, `TypeFocused`, `GoHome`, and Web keys and modifiers in `PressKey`, are new in `v0.4.0`. `Tap` (with a point or an `Element`), `ScreenSize`, `TypeFocused` and `PressKey` on a Mac computer's screen are new in `v0.5.0`, and `Type` there in `v0.6.1`; see [Mac screen](#mac-screen). A location is a `verify.Point{X, Y}` in whole, non-negative screenshot pixels from the top-left corner, or a `verify.Element("Login button")` that Revyl's grounding model finds on the current screen. ```go if _, err := s.Tap(ctx, verify.Element("General")); err != nil { @@ -279,16 +280,18 @@ if err := s.GoHome(ctx); err != nil { // the home screen, on iOS and Android } ``` -On Web, type where the focus is and press more keys: +**Typing: one rule on every platform.** To type, call `s.Type(ctx, verify.Element("Email field"), text)`: it taps the field you describe and types into it, replacing its text unless `TypeOptions.Clear` points to `false`. It works the same on Web, iOS, Android and a Mac computer. `TypeFocused` types wherever focus already is, without tapping, and only on Web and computers; on Web, when no field has focus it returns `ErrActionFailed` with `Reason` `ReasonNoFocusedInput` (`no_focused_input`) and types nothing. + +On Web, type into a field, then where the focus moves, and press more keys: ```go -if _, err := s.Tap(ctx, verify.Element("Username field")); err != nil { +if _, err := s.Type(ctx, verify.Element("Username field"), "standard_user"); err != nil { // taps the field, then types return err } -if err := s.TypeFocused(ctx, "standard_user"); err != nil { // replaces the focused field's text unless Clear points to false +if err := s.PressKey(ctx, verify.KeyTab); err != nil { // focus moves to the password field return err } -if err := s.PressKey(ctx, verify.KeyTab); err != nil { // focus moves to the password field +if err := s.TypeFocused(ctx, "secret_sauce"); err != nil { // replaces the focused field's text unless Clear points to false return err } if err := s.PressKey(ctx, verify.Key("a"), verify.KeyOptions{Modifiers: []verify.KeyModifier{verify.ModifierCtrl}}); err != nil { // a chord @@ -304,8 +307,8 @@ if err := s.PressKey(ctx, verify.KeyEscape); err != nil { | `Tap(ctx, at)` | Taps (clicks on Web and Mac computers) and returns the `Point` tapped. On a Mac computer a tap on a `verify.Element` takes several seconds and can click a look-alike, so check the point | | `DoubleTap(ctx, at)` | Double-taps (double-clicks on Web) and returns the `Point` | | `LongPress(ctx, at, LongPressOptions{Duration})` | Presses and holds for `Duration`, whole milliseconds from 1 millisecond to 5 seconds (zero means 1.5 seconds), and returns the `Point` | -| `Type(ctx, at, text, TypeOptions{Clear})` | Taps a text field and types into it, clearing it first unless `Clear` points to `false` | -| `TypeFocused(ctx, text, TypeOptions{Clear})` | Web and Mac computers: types into the field that already has focus, without clicking. Focus the field first, for example with `Tap` or `PressKey(ctx, verify.KeyTab)`. With no field focused nothing is typed and no error is returned, so check the result. On Web it replaces the field's text unless `Clear` points to `false`. On a Mac computer `Clear` must point to `false`: it types where the cursor is, and leaving `Clear` unset returns `ErrInvalidArgument`. To replace text there, select it first with `PressKey(ctx, verify.Key("a"), verify.KeyOptions{Modifiers: []verify.KeyModifier{verify.ModifierMeta}})`. On iOS and Android it returns `ErrNotAvailableOnPlatform`; use `Type(ctx, location, text)` | +| `Type(ctx, at, text, TypeOptions{Clear})` | The way to type, on every platform. Taps a text field and types into it, clearing it first unless `Clear` points to `false`, and returns the `Point` tapped. On a Mac computer it clicks the field, selects its text with Command+A unless `Clear` points to `false`, and types | +| `TypeFocused(ctx, text, TypeOptions{Clear})` | Web and Mac computers: types into the field that already has focus, without clicking. Prefer `Type(ctx, verify.Element("…"), text)`. On Web, with no field focused nothing is typed and it returns `ErrActionFailed` with `Reason` `ReasonNoFocusedInput`; on a Mac computer the keys go to whatever has focus, so check the result. On Web it replaces the field's text unless `Clear` points to `false`. On a Mac computer `Clear` must point to `false`: it types where the cursor is, and leaving `Clear` unset returns `ErrInvalidArgument`. To replace text there, select it first with `PressKey(ctx, verify.Key("a"), verify.KeyOptions{Modifiers: []verify.KeyModifier{verify.ModifierMeta}})`. On iOS and Android it returns `ErrNotAvailableOnPlatform` before anything is sent; use `Type(ctx, verify.Element("…"), text)` | | `Swipe(ctx, direction, SwipeOptions{From})` | Swipes from a location or the screen's center; `SwipeUp` moves the finger up, which scrolls content down | | `Drag(ctx, from, to)` | Presses at one location, moves to the other and releases, for example to reorder a list, move a slider or select text | | `PressKey(ctx, key, KeyOptions{Modifiers})` | Presses a key on the focused element. Every platform takes `KeyEnter` and `KeyBackspace`. Web and Mac computers also take `KeyTab`, `KeyEscape`, `KeyDelete`, `KeySpace`, `KeyArrowUp`, `KeyArrowDown`, `KeyArrowLeft`, `KeyArrowRight`, `KeyHome`, `KeyEnd`, `KeyPageUp` and `KeyPageDown`, and `Modifiers`: up to four of `ModifierCtrl`, `ModifierShift`, `ModifierAlt` and `ModifierMeta`, held while the key is pressed. With modifiers a lowercase letter or digit works too, such as `verify.Key("a")`. The shortcut key differs: select all with `ModifierMeta` on a Mac computer, where it is Command and `ModifierAlt` is Option, and with `ModifierCtrl` on Web, where `ModifierMeta` is not the shortcut key. Other keys and any modifiers return `ErrNotAvailableOnPlatform` on iOS and Android | @@ -627,7 +630,19 @@ Operations submit once, then poll the deterministic operation ID after an asynch An unclaimed start may fail with `no_host` after 120 seconds from creation. Verify stops readiness polling and attempts bounded cleanup; this does not shorten the default 10-minute startup timeout for already-claimed guests or prove that physical release succeeded. -`Recording(ctx)` works after `Close` and checks the terminal report and confirmed physical release before requesting retained recording metadata. It returns `*ComputerRecording{URL, Duration, StartedAt}` without downloading the video; `Duration` and `StartedAt` are nullable pointers. Recording processing is asynchronous, so a 404 `recording_unavailable` returns `(nil, nil)`; other errors remain typed. Before confirmed terminal release, it returns `ErrSessionBusy`. Signed recording URLs last up to one hour, are private, and are never logged; call `Recording` again to refresh metadata rather than retaining an expired URL. +To get the screen recording, call `Recording(ctx)` after `Close`, on the same session and before your program exits: + +```go +if err := s.Close(ctx); err != nil { + return err +} +recording, err := s.Recording(ctx) // waits until Revyl has saved the video +if err != nil { + return err +} +``` + +Revyl saves the video a few seconds after release, so `Recording` asks every 5 seconds until it is saved and returns `*ComputerRecording{URL, Duration, StartedAt}` without downloading the video; `Duration` and `StartedAt` are nullable pointers. It returns `(nil, nil)` only when none was saved within 15 minutes or before `ctx`'s deadline, and `ctx.Err()` when `ctx` is canceled. Since `v0.6.1`; earlier versions returned `(nil, nil)` at once while the video was still uploading. On a computer that is still running it returns `ErrSessionBusy` saying to call `Close` first. `Attach` can't reopen a closed computer, so a later process can't fetch it. Signed recording URLs last up to one hour, are private, and are never logged; call `Recording` again to refresh metadata rather than retaining an expired URL. ## Mac screen @@ -644,23 +659,19 @@ time.Sleep(3 * time.Second) // let the window open if _, err := s.Screenshot(ctx, ".verify/mac.png"); err != nil { // open it and find the text return err } -if _, err := s.Tap(ctx, verify.Point{X: 400, Y: 300}); err != nil { // the point as you read it +if _, err := s.Type(ctx, verify.Element("the TextEdit document"), "First line\nSecond line"); err != nil { // clicks, selects all, types return err } keep := false -if err := s.TypeFocused(ctx, "First line\nSecond line", verify.TypeOptions{Clear: &keep}); err != nil { - return err -} -selectAll := verify.KeyOptions{Modifiers: []verify.KeyModifier{verify.ModifierMeta}} // Command+A -if err := s.PressKey(ctx, verify.Key("a"), selectAll); err != nil { +if err := s.TypeFocused(ctx, "\nThird line", verify.TypeOptions{Clear: &keep}); err != nil { // types where the cursor already is return err } -if err := s.TypeFocused(ctx, "Replacement", verify.TypeOptions{Clear: &keep}); err != nil { // replaces the selection +if _, err := s.Tap(ctx, verify.Point{X: 400, Y: 300}); err != nil { // or click a point as you read it return err } ``` -On a computer, `TypeFocused` needs `Clear` pointing to `false`: it types where the cursor is and clears nothing, so to replace text, select it first. `ModifierMeta` is Command and `ModifierAlt` is Option. `ScreenSize` works too. `Tap(ctx, verify.Element("the Help menu in the menu bar"))` clicks a description and returns the `Point` it clicked. It takes several seconds and can click a look-alike, or something else when the target isn't on the screen, so check the point or take a screenshot afterwards, and use a `verify.Point` from a screenshot for anything that's hard to undo. `Locate` and the other exact actions aren't available on computers and return `ErrNotAvailableOnPlatform` before anything is sent. When Revyl answers `screen_starting`, nothing happened, so Verify waits and tries again for up to 30 seconds. A program keeps control of the screen for 120 seconds after its last action, so a teammate can't take control in the Revyl viewer until then; while someone does control it there, actions return `ErrSessionBusy` and nothing happens. A 403 returns `ErrAuthRejected`: the key's owner needs the Member role or above, and CI runner keys can't control the screen yet. Revyl's `screen_input_uncertain` returns `ErrActionUncertain`, so take a screenshot before you act again. [computers.md](https://github.com/RevylAI/verify/blob/main/packages/verify/docs/computers.md#screen) lists every screen error. +On a computer, as everywhere, type with `Type(ctx, verify.Element("description"), text)`: it clicks the field, selects its text with Command+A unless `Clear` points to `false`, and types. `TypeFocused` needs `Clear` pointing to `false`: it types where the cursor is and clears nothing, so to replace text, select it first. `ModifierMeta` is Command and `ModifierAlt` is Option. `ScreenSize` works too. `Tap(ctx, verify.Element("the Help menu in the menu bar"))` clicks a description and returns the `Point` it clicked. It takes several seconds and can click a look-alike, or something else when the target isn't on the screen, so check the point or take a screenshot afterwards, and use a `verify.Point` from a screenshot for anything that's hard to undo. `Locate` and the exact actions other than `Tap`, `Type`, `TypeFocused`, `PressKey` and `ScreenSize` aren't available on computers and return `ErrNotAvailableOnPlatform` before anything is sent. When Revyl answers `screen_starting`, nothing happened, so Verify waits and tries again for up to 30 seconds. A program keeps control of the screen for 120 seconds after its last action, so a teammate can't take control in the Revyl viewer until then; while someone does control it there, actions return `ErrSessionBusy` and nothing happens. A 403 returns `ErrAuthRejected`: the key's owner needs the Member role or above, and CI runner keys can't control the screen yet. Revyl's `screen_input_uncertain` returns `ErrActionUncertain`, so take a screenshot before you act again. [computers.md](https://github.com/RevylAI/verify/blob/main/packages/verify/docs/computers.md#screen) lists every screen error. ## Results and errors diff --git a/go/actions.go b/go/actions.go index 31d6089..c3140a6 100644 --- a/go/actions.go +++ b/go/actions.go @@ -218,12 +218,12 @@ func (s *Session) Tap(ctx context.Context, at Location, options ...TapOptions) ( // Type taps a text field and types into it, clearing it first unless TypeOptions.Clear is false. It returns the point tapped. func (s *Session) Type(ctx context.Context, at Location, text string, options ...TypeOptions) (Point, error) { - if s.platform.computer() { - return Point{}, s.computerAgentUnavailable("Type") - } if len(options) > 1 { return Point{}, failure(ErrInvalidArgument, "Type accepts at most one options value.") } + if s.platform.computer() { + return s.computerType(ctx, at, text, len(options) == 0 || options[0].Clear == nil || *options[0].Clear) + } if textLength(text) > 16384 { return Point{}, failure(ErrInvalidArgument, "Type takes text of at most 16384 characters.") } @@ -283,7 +283,7 @@ func (s *Session) TypeFocused(ctx context.Context, text string, options ...TypeO return failure(ErrInvalidArgument, "TypeFocused accepts at most one options value.") } if s.platform != Web { - return failure(ErrNotAvailableOnPlatform, "TypeFocused is available only on web sessions; on iOS and Android, use Type(ctx, location, text), which taps the field first.") + return failure(ErrNotAvailableOnPlatform, "TypeFocused isn't available on iOS and Android sessions. Use session.Type(ctx, verify.Element(\"the email field\"), text), which taps the field and types into it.") } if textLength(text) > 16384 { return failure(ErrInvalidArgument, "TypeFocused takes text of at most 16384 characters.") diff --git a/go/agent.go b/go/agent.go index 972a8fc..3fa85df 100644 --- a/go/agent.go +++ b/go/agent.go @@ -446,10 +446,10 @@ func instructionTools(platform Platform, grounding Grounding) []ModelTool { {Name: "tap", Description: "Tap an element.", Parameters: location}, {Name: "double_tap", Description: "Double-tap an element.", Parameters: location}, {Name: "long_press", Description: "Press and hold an element, for example to open a context menu.", Parameters: location}, - {Name: "type", Description: "Tap a text field and type into it. Clears the field first unless clear is false.", Parameters: json.RawMessage(`{"type":"object","properties":{` + properties + `,"text":{"type":"string"},"clear":{"type":"boolean"}},"required":[` + required + `,"text"]}`)}, + {Name: "type", Description: "Tap a text field and type into it. Use this to type. Clears the field first unless clear is false.", Parameters: json.RawMessage(`{"type":"object","properties":{` + properties + `,"text":{"type":"string"},"clear":{"type":"boolean"}},"required":[` + required + `,"text"]}`)}, } if platform == Web { - tools = append(tools, ModelTool{Name: "type_focused", Description: "Type into the field that already has focus, without tapping. Clears the field first unless clear is false.", Parameters: json.RawMessage(`{"type":"object","properties":{"text":{"type":"string"},"clear":{"type":"boolean"}},"required":["text"]}`)}) + tools = append(tools, ModelTool{Name: "type_focused", Description: "Type into the field that already has focus, without tapping. Nothing is typed when no field has focus, so prefer type. Clears the field first unless clear is false.", Parameters: json.RawMessage(`{"type":"object","properties":{"text":{"type":"string"},"clear":{"type":"boolean"}},"required":["text"]}`)}) } tools = append(tools, ModelTool{Name: "swipe", Description: "Swipe from a point, or from the screen's center. up moves the finger up, which scrolls content down.", Parameters: json.RawMessage(`{"type":"object","properties":{"direction":{"type":"string","enum":["up","down","left","right"]},` + properties + `},"required":["direction"]}`)}, diff --git a/go/client.go b/go/client.go index d758558..0a4dfb5 100644 --- a/go/client.go +++ b/go/client.go @@ -19,7 +19,7 @@ import ( const ( backendURL = "https://backend.revyl.ai" appURL = "https://app.revyl.ai" - Version = "0.6.0" + Version = "0.6.1" ) type client struct { diff --git a/go/computer.go b/go/computer.go index 317b066..6bea023 100644 --- a/go/computer.go +++ b/go/computer.go @@ -230,7 +230,12 @@ func (s *Session) logLine(message string) { } } -const computerScreenCalls = "For the screen, use Screenshot, Tap with a Point or an Element, TypeFocused with Clear set to false, and PressKey; for commands, use Exec." +const ( + recordingWait = 15 * time.Minute + recordingPoll = 5 * time.Second +) + +const computerScreenCalls = "For the screen, use Screenshot, Tap with a Point or an Element, Type with an Element, TypeFocused with Clear set to false, and PressKey; for commands, use Exec." func (s *Session) computerAgentUnavailable(method string) error { return failure(ErrNotAvailableOnPlatform, method+" is not available on computers. "+computerScreenCalls+" See "+s.viewer) @@ -332,6 +337,32 @@ func (s *Session) computerTapTarget(ctx context.Context, target string) (Point, return Point{X: *result.Point.X, Y: *result.Point.Y}, nil } +func (s *Session) computerType(ctx context.Context, at Location, text string, clearFirst bool) (Point, error) { + if !utf8.ValidString(text) || textLength(text) > 16384 { + return Point{}, failure(ErrInvalidArgument, "Type takes UTF-8 text of at most 16384 characters.") + } + for index, character := range text { + if (character < 0x20 && character != '\n' && character != '\t') || (character >= 0x7f && character <= 0x9f) { + return Point{}, failure(ErrInvalidArgument, fmt.Sprintf("Nothing was typed: Type on a computer takes newline and tab but no other control characters, and the text has one at index %d. Use PressKey for keys such as KeyEscape.", textLength(text[:index]))) + } + } + point, err := s.computerTap(ctx, at) + if err != nil { + return Point{}, err + } + if clearFirst { + selectAll := ModifierMeta + if s.platform != Mac { + selectAll = ModifierCtrl + } + if err := s.computerPressKey(ctx, Key("a"), []KeyOptions{{Modifiers: []KeyModifier{selectAll}}}); err != nil { + return Point{}, err + } + } + keep := false + return point, s.computerTypeFocused(ctx, text, []TypeOptions{{Clear: &keep}}) +} + func (s *Session) computerTypeFocused(ctx context.Context, text string, options []TypeOptions) error { if len(options) > 1 { return failure(ErrInvalidArgument, "TypeFocused accepts at most one options value.") @@ -1154,13 +1185,22 @@ func (s *Session) Extend(ctx context.Context, timeout time.Duration) error { return nil } +// Recording returns a computer's recording after Close, waiting until Revyl has saved it, usually seconds after Close. +// It returns nil, nil when none was saved within 15 minutes or before ctx's deadline. func (s *Session) Recording(ctx context.Context) (*ComputerRecording, error) { if !s.platform.computer() { return nil, s.assertComputerOpen() } - ctx, cancel := context.WithTimeout(ctx, 30*time.Second) - defer cancel() - r, err := s.computerRequest(ctx, "GET", "/report", nil) + deadline := time.Now().Add(recordingWait) + if ctxDeadline, ok := ctx.Deadline(); ok && ctxDeadline.Before(deadline) { + deadline = ctxDeadline + } + get := func(suffix string) (response, error) { + requestCtx, cancel := context.WithTimeout(ctx, 30*time.Second) + defer cancel() + return s.computerRequest(requestCtx, "GET", suffix, nil) + } + r, err := get("/report") if err != nil { return nil, err } @@ -1169,11 +1209,32 @@ func (s *Session) Recording(ctx context.Context) (*ComputerRecording, error) { return nil, err } if report.Release != "confirmed" || (report.State != "stopped" && report.State != "failed" && report.State != "owner_lost") { - return nil, failure(ErrSessionBusy, "Recording is available only after confirmed physical release. See "+s.viewer) + return nil, failure(ErrSessionBusy, "The computer is still running, so it has no recording yet. Call Close first, then Recording, which waits until Revyl has saved the video. See "+s.viewer) } - r, err = s.computerRequest(ctx, "GET", "/recording", nil) - if err != nil || r.status == 404 { - return nil, err + for waited := false; ; waited = true { + if r, err = get("/recording"); err != nil { + return nil, err + } + if r.status != 404 { + break + } + remaining := time.Until(deadline) - time.Second + if remaining <= 0 { + if waited { + s.logLine("no recording was saved in time") + } + return nil, nil + } + if !waited { + s.logLine("waiting for Revyl to save the recording") + } + timer := time.NewTimer(min(recordingPoll, remaining)) + select { + case <-ctx.Done(): + timer.Stop() + return nil, ctx.Err() + case <-timer.C: + } } var raw struct { URL string `json:"url"` diff --git a/go/computer_test.go b/go/computer_test.go index 71e9faf..da4a59a 100644 --- a/go/computer_test.go +++ b/go/computer_test.go @@ -1340,7 +1340,9 @@ func TestComputerRecordings(t *testing.T) { if err := s.Close(ctx); err != nil { t.Fatal(err) } - recording, err := s.Recording(ctx) + recordingCtx, cancelRecording := context.WithTimeout(ctx, 2*time.Second) + defer cancelRecording() + recording, err := s.Recording(recordingCtx) switch mode { case "active", "terminal-unreleased", "active-released": requireCode(t, err, verify.ErrSessionBusy) @@ -1456,7 +1458,9 @@ func TestComputerExpiry(t *testing.T) { if err := s.Close(ctx); err != nil { t.Fatal(err) } - if recording, err := s.Recording(ctx); recording != nil || err != nil { + recordingCtx, cancelRecording := context.WithTimeout(ctx, 2*time.Second) + defer cancelRecording() + if recording, err := s.Recording(recordingCtx); recording != nil || err != nil { t.Fatal("close or recording was blocked by expired session lifetime") } }) diff --git a/go/errors.go b/go/errors.go index ff0d6e4..e8a60df 100644 --- a/go/errors.go +++ b/go/errors.go @@ -46,6 +46,7 @@ const ( ReasonRepositoryUnavailable RefusalReason = "repository_unavailable" ReasonLifetimeUnsupported RefusalReason = "lifetime_unsupported" ReasonUpgradeRequired RefusalReason = "upgrade_required" + ReasonNoFocusedInput RefusalReason = "no_focused_input" ) func (c Code) Error() string { return string(c) } diff --git a/go/examples/cdp/go.mod b/go/examples/cdp/go.mod index a349b0c..5dd426d 100644 --- a/go/examples/cdp/go.mod +++ b/go/examples/cdp/go.mod @@ -3,7 +3,7 @@ module github.com/RevylAI/verify/go/examples/cdp go 1.26.9 require ( - github.com/RevylAI/verify/go v0.6.0 + github.com/RevylAI/verify/go v0.6.1 github.com/chromedp/cdproto v0.160.1 github.com/chromedp/chromedp v0.24.0 ) diff --git a/go/session.go b/go/session.go index 69724aa..a04e0c2 100644 --- a/go/session.go +++ b/go/session.go @@ -532,6 +532,8 @@ func (s *Session) workerError(method, action string, r response) error { return httpError(r) case r.status == 501 || detail.Error == "not_available_on_platform" || detail.Error == "step_output_not_available": code = ErrNotAvailableOnPlatform + case detail.Error == "no_focused_input": + return &Error{Code: ErrActionFailed, Reason: ReasonNoFocusedInput, HTTPStatus: r.status, Message: "Nothing was typed: no text field has focus (no_focused_input). Use session.Type(ctx, verify.Element(\"the email field\"), text), which taps the field and types into it, or tap the field first. See " + s.viewer} case webTargetErrors[targetError]: return responseFailure(r, ErrActionFailed, fmt.Sprintf("%s could not act on the screen (%s). Take a fresh screenshot and try again. See %s", strings.Split(action, "/")[0], targetError, s.viewer)) case r.status == 404 || r.status == 410: diff --git a/package-lock.json b/package-lock.json index f7f3dc0..f081200 100644 --- a/package-lock.json +++ b/package-lock.json @@ -18,7 +18,7 @@ "name": "verify-example-agent-platform", "version": "0.0.0", "devDependencies": { - "@revyl/verify": "0.7.0", + "@revyl/verify": "0.7.1", "@types/node": "^22.10.0", "typescript": "^5.9.0" } @@ -27,7 +27,7 @@ "name": "verify-example-byo-model", "version": "0.0.0", "devDependencies": { - "@revyl/verify": "0.7.0", + "@revyl/verify": "0.7.1", "@types/node": "^22.10.0", "typescript": "^5.9.0" } @@ -36,7 +36,7 @@ "name": "verify-example-mac-workspace", "version": "0.0.0", "devDependencies": { - "@revyl/verify": "0.7.0", + "@revyl/verify": "0.7.1", "@types/node": "^22.10.0", "typescript": "^5.9.0" } @@ -45,7 +45,7 @@ "name": "verify-example-mobile-settings", "version": "0.0.0", "devDependencies": { - "@revyl/verify": "0.7.0", + "@revyl/verify": "0.7.1", "@types/node": "^22.10.0", "typescript": "^5.9.0" } @@ -54,7 +54,7 @@ "name": "verify-example-web-cdp", "version": "0.0.0", "devDependencies": { - "@revyl/verify": "0.7.0", + "@revyl/verify": "0.7.1", "@types/node": "^22.10.0", "playwright-core": "^1.65.1", "typescript": "^5.9.0" @@ -64,7 +64,7 @@ "name": "verify-example-web-store", "version": "0.0.0", "devDependencies": { - "@revyl/verify": "0.7.0", + "@revyl/verify": "0.7.1", "@types/node": "^22.10.0", "typescript": "^5.9.0" } @@ -1324,10 +1324,10 @@ } }, "packages/revyl-verify": { - "version": "0.7.0", + "version": "0.7.1", "license": "Apache-2.0", "dependencies": { - "@revyl/verify": "0.7.0" + "@revyl/verify": "0.7.1" }, "bin": { "revyl-verify": "cli.js" @@ -1338,7 +1338,7 @@ }, "packages/verify": { "name": "@revyl/verify", - "version": "0.7.0", + "version": "0.7.1", "license": "Apache-2.0", "dependencies": { "jiti": "^2.6.0", diff --git a/packages/revyl-verify/README.md b/packages/revyl-verify/README.md index 5ece6ca..58b76a6 100644 --- a/packages/revyl-verify/README.md +++ b/packages/revyl-verify/README.md @@ -15,4 +15,4 @@ The CLI delegates to `@revyl/verify`, including its output, generated imports, a import { open } from 'revyl-verify'; ``` -Use Node.js 22.18 or later. See the [Verify documentation](https://github.com/RevylAI/verify/tree/v0.7.0/packages/verify/docs) for configuration, API and platform availability. This package shares Verify's [Apache 2.0 license](https://github.com/RevylAI/verify/blob/v0.7.0/LICENSE). +Use Node.js 22.18 or later. See the [Verify documentation](https://github.com/RevylAI/verify/tree/v0.7.1/packages/verify/docs) for configuration, API and platform availability. This package shares Verify's [Apache 2.0 license](https://github.com/RevylAI/verify/blob/v0.7.1/LICENSE). diff --git a/packages/revyl-verify/package.json b/packages/revyl-verify/package.json index 899d59c..9917523 100644 --- a/packages/revyl-verify/package.json +++ b/packages/revyl-verify/package.json @@ -1,6 +1,6 @@ { "name": "revyl-verify", - "version": "0.7.0", + "version": "0.7.1", "description": "Unscoped alias for @revyl/verify, with the same API and CLI.", "homepage": "https://github.com/RevylAI/verify#readme", "repository": { @@ -29,7 +29,7 @@ "node": ">=22.18" }, "dependencies": { - "@revyl/verify": "0.7.0" + "@revyl/verify": "0.7.1" }, "scripts": { "prepack": "cp ../../LICENSE LICENSE && chmod +x cli.js" diff --git a/packages/verify/docs/agents.md b/packages/verify/docs/agents.md index 18732b7..178692a 100644 --- a/packages/verify/docs/agents.md +++ b/packages/verify/docs/agents.md @@ -24,7 +24,7 @@ This page is for AI coding agents (Claude Code, Cursor, Codex, and others) that ## Exact actions and coordinates -Use `instruction()` when the step needs judgement, and exact actions (`tap`, `doubleTap`, `longPress`, `type`, `swipe`, `drag`, `pressKey`, `locate`, `screenSize`) when you know exactly what to press. They work on Web, iOS and Android. On a Mac computer's screen, `tap({ x, y })`, `tap({ target })`, `screenSize()`, `typeFocused(text, { clear: false })` and `pressKey` work; see [computers.md](computers.md#screen). On Web and Mac computers, `typeFocused(text)` types into the field that has focus, and `pressKey` also takes keys such as `'escape'`, `'tab'` and arrows, with `modifiers`. Select all with `pressKey('a', { modifiers: ['meta'] })` on a Mac computer, where `'meta'` is Command, and with `pressKey('a', { modifiers: ['ctrl'] })` on Web, where `'meta'` is not the shortcut key. On iOS and Android, `goHome()` goes to the home screen, `pressKey` takes only `'enter'` and `'backspace'`, and you type with `type(location, text)`. A call the platform lacks throws `NOT_AVAILABLE_ON_PLATFORM` before anything is sent, and the message names what to use instead. +Use `instruction()` when the step needs judgement, and exact actions (`tap`, `doubleTap`, `longPress`, `type`, `swipe`, `drag`, `pressKey`, `locate`, `screenSize`) when you know exactly what to press. They work on Web, iOS and Android. To type, on every platform, use `type({ target: 'Email field' }, text)`: it taps the field and types into it. On a Mac computer's screen, `tap({ x, y })`, `tap({ target })`, `type({ target }, text)`, `screenSize()`, `typeFocused(text, { clear: false })` and `pressKey` work; see [computers.md](computers.md#screen). On Web and Mac computers, `typeFocused(text)` types into the field that already has focus (on Web it throws `ACTION_FAILED` with reason `no_focused_input` when none has), and `pressKey` also takes keys such as `'escape'`, `'tab'` and arrows, with `modifiers`. Select all with `pressKey('a', { modifiers: ['meta'] })` on a Mac computer, where `'meta'` is Command, and with `pressKey('a', { modifiers: ['ctrl'] })` on Web, where `'meta'` is not the shortcut key. On iOS and Android, `goHome()` goes to the home screen, `pressKey` takes only `'enter'` and `'backspace'`, and `typeFocused` throws `NOT_AVAILABLE_ON_PLATFORM`. A call the platform lacks throws `NOT_AVAILABLE_ON_PLATFORM` before anything is sent, and the message names what to use instead. Prefer a description, such as `tap({ target: 'Sign in button' })`: Revyl finds the element on the current screen, and you never handle coordinates. Otherwise a point is `{ x, y }` in screenshot pixels on every platform: whole numbers from the top-left corner of the image `screenshot()` returns. So a position you read off a screenshot goes to `tap()`, `type()`, `swipe()` and every other exact action unchanged. `screenSize()` returns the screenshot's width and height, and `locate()` and the points `tap()`, `doubleTap()`, `longPress()` and `type()` return use the same pixels. A point outside the screenshot is refused with `INVALID_ARGUMENT` before any action is sent, and the message names the valid range. On iOS, Verify converts the pixels to the screen's points for you. On Web they equal CSS pixels at the default device scale factor of 1, and you still pass screenshot pixels at any other. This holds from TypeScript 0.4.1, Python 0.2.1 and Go v0.3.1; earlier versions took iOS points. On a Mac computer a point is in screenshot pixels too, and `tap({ target })` returns the point it clicked in the same pixels. Verify refuses a negative or fractional point before sending it, and Revyl refuses one past the screen's edge without clicking; both throw `INVALID_ARGUMENT` naming the valid range. @@ -53,15 +53,15 @@ try { } ``` -The [Python](https://github.com/RevylAI/verify/blob/v0.7.0/python/README.md#exact-actions) and [Go](https://github.com/RevylAI/verify/blob/v0.7.0/go/README.md#exact-actions) READMEs state the same rule with each language's names. [api.md](api.md#exact-actions) lists every call and its errors. +The [Python](https://github.com/RevylAI/verify/blob/v0.7.1/python/README.md#exact-actions) and [Go](https://github.com/RevylAI/verify/blob/v0.7.1/go/README.md#exact-actions) READMEs state the same rule with each language's names. [api.md](api.md#exact-actions) lists every call and its errors. ## Rules Mac computers are available to organizations on a current paid Revyl plan. Ask before starting a computer, as for a device; do not repeat an uncertain start/stop to probe availability. -For computer work, use structured `exec(['program', 'arg'])`, `readFile`, `writeFile`, `stat`, and run-owned handles from `processes()`/`terminate(id)`. Check command output with ordinary assertions and close in `finally`; screenshots are supported, but instruction/validation are not. To use the screen, read a point off `screenshot()` and `tap({ x, y })` it, or describe it with `tap({ target })`, and type with `typeFocused(text, { clear: false })`. A described click takes several seconds, because Revyl takes a screenshot and finds the element first. It can pick a look-alike, and when the target isn't on the screen it can still click something else instead of failing. So check the point it returns or take a screenshot afterwards, and for anything that's hard to undo, read the point off `screenshot()` and use `tap({ x, y })`. After `ACTION_UNCERTAIN`, take a screenshot before you act again. Do not fall back to agent steps on computers or shell/file methods on mobile/web. See [computers.md](computers.md) for limits. Starting a computer is a paid external action and needs the same approval as starting a device. +For computer work, use structured `exec(['program', 'arg'])`, `readFile`, `writeFile`, `stat`, and run-owned handles from `processes()`/`terminate(id)`. Check command output with ordinary assertions and close in `finally`; screenshots are supported, but instruction/validation are not. To use the screen, read a point off `screenshot()` and `tap({ x, y })` it, or describe it with `tap({ target })`, and type with `type({ target: 'the search field' }, text)`, which clicks the field and types into it, or `typeFocused(text, { clear: false })` where the cursor already is. A described click takes several seconds, because Revyl takes a screenshot and finds the element first. It can pick a look-alike, and when the target isn't on the screen it can still click something else instead of failing. So check the point it returns or take a screenshot afterwards, and for anything that's hard to undo, read the point off `screenshot()` and use `tap({ x, y })`. After `ACTION_UNCERTAIN`, take a screenshot before you act again. Do not fall back to agent steps on computers or shell/file methods on mobile/web. See [computers.md](computers.md) for limits. Starting a computer is a paid external action and needs the same approval as starting a device. -Computers have a hard lifetime from create, not from readiness or activity: 2 hours by default, up to 24 hours with `timeoutMs` on the target, and `extend(timeoutMs)` lengthens a running computer up to 24 hours from create. `expiresAt` is the authoritative deadline. `expiresAt` is optional on older APIs; expiry does not prevent close. After terminal state and confirmed release, `recording()` can return private signed metadata or null, including after close. Never log or share its signed URL/query. Do not automatically wait for recordings or retry `COMPUTER_LIMIT` starts: queued work (including iOS) or the concurrency limit may be responsible. +Computers have a hard lifetime from create, not from readiness or activity: 2 hours by default, up to 24 hours with `timeoutMs` on the target, and `extend(timeoutMs)` lengthens a running computer up to 24 hours from create. `expiresAt` is the authoritative deadline. `expiresAt` is optional on older APIs; expiry does not prevent close. To get the screen recording, call `await computer.close()` and then `await computer.recording()` on the same object before the script exits: it waits until Revyl has saved the video, usually a few seconds, and returns `{ url, durationSeconds?, startedAt? }`, or null if none was saved within 15 minutes. `attach()` can't reopen a closed computer to fetch it later. Never log or share its signed URL/query. Do not retry `COMPUTER_LIMIT` starts: queued work (including iOS) or the concurrency limit may be responsible. - Write steps the way you would brief a person: what to do, or what should be true, in one sentence. Name visible things ("the blue Save button in the footer"), not implementation details. - Use `instruction` for doing and `validation` for checking. Do not ask an instruction to check something, or a validation to change anything. diff --git a/packages/verify/docs/api.md b/packages/verify/docs/api.md index e46eec1..1896f2d 100644 --- a/packages/verify/docs/api.md +++ b/packages/verify/docs/api.md @@ -192,15 +192,18 @@ On iOS, Android and Mac computers `cdp()` throws `NOT_AVAILABLE_ON_PLATFORM` bef ## Exact actions -**Early access.** Since TypeScript (`@revyl/verify`) 0.4.0, Python (`revyl-verify`) 0.2.0 and Go v0.3.0. `doubleTap`, `longPress`, `drag`, `typeFocused`, `goHome`, and Web keys and modifiers in `pressKey`, are new in TypeScript 0.5.0, Python 0.3.0 and Go v0.4.0. On a Mac computer's screen, `tap` (by point or by description), `screenSize`, `typeFocused` and `pressKey` are new in TypeScript 0.6.0, Python 0.4.0 and Go v0.5.0. The [Python](https://github.com/RevylAI/verify/blob/v0.7.0/python/README.md#exact-actions) and [Go](https://github.com/RevylAI/verify/blob/v0.7.0/go/README.md#exact-actions) READMEs show them with each language's names. Web, iOS and Android sessions, and a Mac computer's screen, take device actions that need no agent. +**Early access.** Since TypeScript (`@revyl/verify`) 0.4.0, Python (`revyl-verify`) 0.2.0 and Go v0.3.0. `doubleTap`, `longPress`, `drag`, `typeFocused`, `goHome`, and Web keys and modifiers in `pressKey`, are new in TypeScript 0.5.0, Python 0.3.0 and Go v0.4.0. On a Mac computer's screen, `tap` (by point or by description), `screenSize`, `typeFocused` and `pressKey` are new in TypeScript 0.6.0, Python 0.4.0 and Go v0.5.0, and `type` in TypeScript 0.7.1, Python 0.5.1 and Go v0.6.1. The [Python](https://github.com/RevylAI/verify/blob/v0.7.1/python/README.md#exact-actions) and [Go](https://github.com/RevylAI/verify/blob/v0.7.1/go/README.md#exact-actions) READMEs show them with each language's names. Web, iOS and Android sessions, and a Mac computer's screen, take device actions that need no agent. + +**Typing: one rule on every platform.** To type, call `type({ target: 'Email field' }, text)`: it taps the field you describe and types into it, replacing its text unless you pass `{ clear: false }`. It works the same on Web, iOS, Android and a Mac computer. `typeFocused(text)` types wherever focus already is, without tapping, and only on Web and computers; on Web, when no field has focus it throws `ACTION_FAILED` with reason `no_focused_input` and types nothing. | Call | Web | iOS | Android | Mac computer | | --- | --- | --- | --- | --- | | `tap({ x, y })`, `tap({ target })`, `screenSize` | Yes | Yes | Yes | Yes | | `locate` | Yes | Yes | Yes | No, use `tap({ target })`, which returns the point it clicked, or read the point off `screenshot()` | -| `doubleTap`, `longPress`, `type`, `swipe`, `drag` | Yes | Yes | Yes | No | +| `type({ target }, text)`, the way to type | Yes | Yes | Yes | Yes: clicks the field, selects its text unless `{ clear: false }`, then types | +| `doubleTap`, `longPress`, `swipe`, `drag` | Yes | Yes | Yes | No | | `pressKey(key, { modifiers })` | Yes: `'enter'`, `'backspace'`, `'tab'`, `'escape'`, arrows and more, with modifiers | `'enter'` and `'backspace'` only | `'enter'` and `'backspace'` only | Yes: the Web keys and modifiers, where `'meta'` is Command | -| `typeFocused(text, { clear })` | Yes, types into the focused field | No, use `type(location, text)` | No, use `type(location, text)` | Yes, with `{ clear: false }` | +| `typeFocused(text, { clear })` | Yes, types into the focused field; `ACTION_FAILED` (`no_focused_input`) when none has focus | No, use `type({ target }, text)` | No, use `type({ target }, text)` | Yes, with `{ clear: false }` | | `back()` | Yes, browser history | No, tap the on-screen back control | Yes, the system back button | No | | `goHome()` | No, use `openUrl` or `navigate` | Yes, the home screen | Yes, the home screen | No | | `openUrl(url)` | Yes, loads an http(s) URL in the tab | Yes, a URL or deep link | Yes, a URL or deep link | No | @@ -220,8 +223,8 @@ A location is `{ x, y }` in screenshot pixels (see [Coordinates](#coordinates)) | `tap(at)` | Taps (clicks on Web and Mac computers) and resolves with the point tapped. On a Mac computer a described tap takes several seconds, can click a look-alike, and can click something else when the target isn't on the screen, so check the point or a screenshot afterwards; see [computers.md](computers.md#screen) | | `doubleTap(at)` | Double-taps (double-clicks on Web) and resolves with the point | | `longPress(at, { duration })` | Presses and holds for `duration` milliseconds, 1 to 5000 (default 1500), and resolves with the point | -| `type(at, text, { clear })` | Taps a text field and types into it, clearing it first unless `clear` is `false` | -| `typeFocused(text, { clear })` | Web and Mac computers: types into the field that already has focus, without clicking. Focus the field first, for example with `tap` or `pressKey('tab')`. With no field focused nothing is typed and no error is thrown, so check the result. On Web it replaces the field's text unless `clear` is `false`. On a Mac computer pass `{ clear: false }`: it types where the cursor is, and leaving `clear` out throws `INVALID_ARGUMENT`. To replace text there, select it first with `pressKey('a', { modifiers: ['meta'] })`. On iOS and Android it throws `NOT_AVAILABLE_ON_PLATFORM`; use `type(location, text)` | +| `type(at, text, { clear })` | The way to type, on every platform. Taps a text field and types into it, clearing it first unless `clear` is `false`, and resolves with the point tapped. On a Mac computer it clicks the field, selects its text with Command+A unless `clear` is `false`, and types, so the text replaces what was there | +| `typeFocused(text, { clear })` | Web and Mac computers: types into the field that already has focus, without clicking, for example after `pressKey('tab')`. Prefer `type({ target }, text)`. On Web, with no field focused nothing is typed and it throws `ACTION_FAILED` with reason `no_focused_input`; on a Mac computer the keys go to whatever has focus, so check the result. On Web it replaces the field's text unless `clear` is `false`. On a Mac computer pass `{ clear: false }`: it types where the cursor is, and leaving `clear` out throws `INVALID_ARGUMENT`. To replace text there, select it first with `pressKey('a', { modifiers: ['meta'] })`. On iOS and Android it throws `NOT_AVAILABLE_ON_PLATFORM` before anything is sent; use `type({ target }, text)` | | `swipe(direction, { from })` | Swipes from a location or the screen's center; `'up'` moves the finger up, which scrolls content down | | `drag(from, to)` | Presses at one location, moves to the other and releases, for example to reorder a list, move a slider or select text | | `pressKey(key, { modifiers })` | Presses a key on the focused element. Every platform takes `'enter'` and `'backspace'`. Web and Mac computers also take `'tab'`, `'escape'`, `'delete'`, `'space'`, `'arrowup'`, `'arrowdown'`, `'arrowleft'`, `'arrowright'`, `'home'`, `'end'`, `'pageup'` and `'pagedown'`, and `modifiers`: up to four of `'ctrl'`, `'shift'`, `'alt'` and `'meta'`, held while the key is pressed. With modifiers a lowercase letter or digit works too. The shortcut key differs: select all with `pressKey('a', { modifiers: ['meta'] })` on a Mac computer, where `'meta'` is Command and `'alt'` is Option, and with `pressKey('a', { modifiers: ['ctrl'] })` on Web, where `'meta'` is not the shortcut key. Other keys and any modifiers throw `NOT_AVAILABLE_ON_PLATFORM` on iOS and Android | @@ -301,7 +304,7 @@ When inspecting `revyl device report --session-id `, read validation verdict ## Your own model -**Early access.** Since TypeScript (`@revyl/verify`) 0.4.0, Python (`revyl-verify`) 0.2.0 and Go v0.3.0; the [Python](https://github.com/RevylAI/verify/blob/v0.7.0/python/README.md#your-own-model) and [Go](https://github.com/RevylAI/verify/blob/v0.7.0/go/README.md#your-own-model) READMEs show them with each language's names. Runs instructions and validations on a model you choose, in your process, instead of Revyl's agent. Revyl still provides the browser or device. Leave `model` out and Revyl's agent runs the step, as before. +**Early access.** Since TypeScript (`@revyl/verify`) 0.4.0, Python (`revyl-verify`) 0.2.0 and Go v0.3.0; the [Python](https://github.com/RevylAI/verify/blob/v0.7.1/python/README.md#your-own-model) and [Go](https://github.com/RevylAI/verify/blob/v0.7.1/go/README.md#your-own-model) READMEs show them with each language's names. Runs instructions and validations on a model you choose, in your process, instead of Revyl's agent. Revyl still provides the browser or device. Leave `model` out and Revyl's agent runs the step, as before. ```ts const session = await open('ios', { model: 'anthropic/claude-sonnet-5-5' }); // every step on your model @@ -352,17 +355,25 @@ For owning computers, cleanup must be confirmed; a terminal state alone does not ## Computer commands, files, and processes -Mac sessions provide `exec(argv: string[], options?)`, `readFile(path, options?)` returning `Buffer`, `writeFile(path, string | Uint8Array, options?)`, `stat(path, options?)` returning `{ kind, size }`, `processes(options?)` returning `{ id, state, exitCode? }[]`, and `terminate(id, options?)`. They throw `NOT_AVAILABLE_ON_PLATFORM` on web/iOS/Android. See [computers.md](computers.md) for complete signatures, limits, timeouts, and examples. Both support `screenshot()`, and computers take `tap({ x, y })`, `screenSize()`, `typeFocused(text, { clear: false })` and `pressKey` on the screen (see [computers.md](computers.md#screen)); instruction/validation do not run on computers. +Mac sessions provide `exec(argv: string[], options?)`, `readFile(path, options?)` returning `Buffer`, `writeFile(path, string | Uint8Array, options?)`, `stat(path, options?)` returning `{ kind, size }`, `processes(options?)` returning `{ id, state, exitCode? }[]`, and `terminate(id, options?)`. They throw `NOT_AVAILABLE_ON_PLATFORM` on web/iOS/Android. See [computers.md](computers.md) for complete signatures, limits, timeouts, and examples. Both support `screenshot()`, and computers take `tap({ x, y })`, `tap({ target })`, `type({ target }, text)`, `screenSize()`, `typeFocused(text, { clear: false })` and `pressKey` on the screen (see [computers.md](computers.md#screen)); instruction/validation do not run on computers. ### `session.extend(timeoutMs: number): Promise` Computers only. Keeps a running computer going at least `timeoutMs` (whole seconds in milliseconds, from 60000 to 86400000) from now, up to 24 hours after it was created, and updates `expiresAt`. It never shortens the lifetime, so retrying is safe. Throws `COMPUTER_LIMIT` with reason `computer_long_limit` when the organization already has 2 computers running longer than 2 hours and `NOT_AVAILABLE_ON_PLATFORM` when the computer's host can't extend. Devices reject this call locally with `NOT_AVAILABLE_ON_PLATFORM`. -### `session.recording(): Promise` +### `session.recording({ timeoutMs }?): Promise` + +**Since 0.2.0.** Waits for the recording since 0.7.1. + +Computers only. Call it after `close()`, on the same session object and before your process exits: -**Since 0.2.0.** This method is not available in 0.1.0. +```ts +await computer.close(); +const recording = await computer.recording(); // waits until Revyl has saved the video +console.log(recording?.url); +``` -Computers only. First reads the report and requires terminal state plus confirmed release, otherwise throws `SESSION_BUSY`. Returns `{ url: string, durationSeconds?: number, startedAt?: Date }` or null for an unavailable recording. Nullable optional wire fields are omitted. This method works after `close()`, does not wait for upload, and does not download or fetch the URL. Keep the signed HTTPS URL and its query private. Request fresh metadata when the URL expires. The normal report has no recording URL. Devices reject this call locally with `NOT_AVAILABLE_ON_PLATFORM`. +It reads the report and requires terminal state plus confirmed release; on a computer that is still running it throws `SESSION_BUSY` saying to call `close()` first. Revyl saves the video a few seconds after release, so `recording()` asks every 5 seconds until it is saved and returns `{ url: string, durationSeconds?: number, startedAt?: Date }`. It returns `null` only when none was saved within `timeoutMs`: 900000 (15 minutes) by default, whole milliseconds from 0 to 3600000, where 0 asks once without waiting. `attach()` can't reopen a closed computer, so a later process can't fetch it with Verify; the recording stays in the session at `viewerUrl`. Nullable optional wire fields are omitted. It does not download or fetch the URL. Keep the signed HTTPS URL and its query private. Request fresh metadata when the URL expires. The normal report has no recording URL. Devices reject this call locally with `NOT_AVAILABLE_ON_PLATFORM`. ## Other session properties diff --git a/packages/verify/docs/computers.md b/packages/verify/docs/computers.md index 6ab1f8b..f2f0599 100644 --- a/packages/verify/docs/computers.md +++ b/packages/verify/docs/computers.md @@ -61,14 +61,13 @@ try { await computer.exec(['open', '-a', 'TextEdit', 'notes.txt']); // exec runs in the workspace await new Promise((resolve) => setTimeout(resolve, 3_000)); // let the window open await computer.screenshot({ path: '.verify/mac.png' }); // open it and find the text - await computer.tap({ x: 400, y: 300 }); // the point as you read it - await computer.typeFocused('First line\nSecond line', { clear: false }); - await computer.pressKey('a', { modifiers: ['meta'] }); // Command+A selects all - await computer.typeFocused('Replacement', { clear: false }); // typing replaces the selection + await computer.type({ target: 'the TextEdit document' }, 'First line\nSecond line'); // clicks, selects all, types + await computer.typeFocused('\nThird line', { clear: false }); // types where the cursor already is await computer.screenshot({ path: '.verify/mac-after.png' }); } finally { await computer.close(); } +const recording = await computer.recording(); // waits until Revyl has saved the video ``` | Call | What it does | @@ -77,10 +76,11 @@ try { | `screenSize()` | The screenshot's `{ width, height }`: x is 0 to width - 1, y is 0 to height - 1 | | `tap({ x, y })` | Clicks the point with the left button and resolves with it. Whole numbers from the top-left corner of the screenshot | | `tap({ target })` | Revyl finds the described element on a fresh screenshot, clicks it, and resolves with the point it clicked, in screenshot pixels. The description is 1 to 500 characters. Takes several seconds | +| `type({ target }, text, { clear })` | The way to type: clicks the described field (or a point `{ x, y }`), selects its text with Command+A unless `clear` is `false`, then types, so the text replaces what was there. Resolves with the point clicked. The same limits on text as `typeFocused` | | `typeFocused(text, { clear: false })` | Types the text where the cursor is, in the app that has focus. `{ clear: false }` is required, because Verify doesn't clear anything first: to replace text, select it with `pressKey('a', { modifiers: ['meta'] })` and type over it. Up to 16,384 characters, including line breaks (`\n`) and tabs (`\t`); other control characters are refused before anything is typed. Long text goes in pieces of up to 500 characters, in order | | `pressKey(key, { modifiers })` | Presses a key: `'enter'`, `'backspace'`, `'tab'`, `'escape'`, `'delete'`, `'space'`, `'arrowup'`, `'arrowdown'`, `'arrowleft'`, `'arrowright'`, `'home'`, `'end'`, `'pageup'` or `'pagedown'`, with up to four `modifiers`: `'meta'` (Command), `'ctrl'`, `'alt'` (Option) and `'shift'`. With modifiers a lowercase letter or digit works too, so Command+A is `pressKey('a', { modifiers: ['meta'] })`. On Web the shortcut key is `'ctrl'` instead | -`locate()` isn't available on computers, because Revyl can't find a point there without clicking it; `tap({ target })` returns the point it clicked instead. `doubleTap`, `longPress`, `type(location, text)`, `swipe`, `drag`, `back`, `goHome`, `openUrl` and `launchApp` aren't available on computers either, and a description works only in `tap`. They throw `NOT_AVAILABLE_ON_PLATFORM` before anything is sent; open apps and files with `exec()`, such as `exec(['open', '-a', 'TextEdit', 'notes.txt'])`. For TextEdit, open a file rather than the bare app: opened without a file, it may show a file picker instead of a document. +`locate()` isn't available on computers, because Revyl can't find a point there without clicking it; `tap({ target })` returns the point it clicked instead. `doubleTap`, `longPress`, `swipe`, `drag`, `back`, `goHome`, `openUrl` and `launchApp` aren't available on computers either, and a description works only in `tap` and `type`. They throw `NOT_AVAILABLE_ON_PLATFORM` before anything is sent; open apps and files with `exec()`, such as `exec(['open', '-a', 'TextEdit', 'notes.txt'])`. For TextEdit, open a file rather than the bare app: opened without a file, it may show a file picker instead of a document. ### Described clicks @@ -100,7 +100,7 @@ A script that controls the screen keeps control for 120 seconds after its last a | What happened | Error | What to do | | --- | --- | --- | | A point past the screen's edge (`screen_point_outside`), or a negative or fractional one | `INVALID_ARGUMENT`, and nothing was clicked | The message names the valid range | -| `typeFocused` without `{ clear: false }`, with control characters other than `\n` and `\t`, or with more than 16,384 characters | `INVALID_ARGUMENT` before anything is sent | The message says how to fix the call | +| `typeFocused` without `{ clear: false }`, or `type` or `typeFocused` with control characters other than `\n` and `\t`, or with more than 16,384 characters | `INVALID_ARGUMENT` before anything is sent | The message says how to fix the call | | The computer can't type some of the characters (`screen_text_unsupported`) | `INVALID_ARGUMENT`, and nothing was typed | Type those characters another way, such as writing a file with `writeFile` | | Someone controls the screen in the viewer (`screen_control_held`) | `SESSION_BUSY`, and nothing happened | Try again after they release it; control frees itself after 2 minutes without input | | Control of the screen changed hands before the action was sent (`screen_control_lost`) | `SESSION_BUSY`, and nothing happened | Try again; if someone controls the screen in the viewer, wait until they release it | @@ -117,9 +117,16 @@ A script that controls the screen keeps control for 120 seconds after its last a When long text fails part way, the error says how many characters were certainly typed and whether the piece that failed may have been typed, counting characters as Unicode code points, so an emoji is one. Every other refusal names its reason and what to do next, such as starting a new computer after `run_closed`. -## Recording metadata +## Recording -After terminal state **and** confirmed release, `await computer.recording()` returns `{ url, durationSeconds?, startedAt? }` or `null` if the recording is unavailable or still processing. `durationSeconds` is a finite nonnegative number; `startedAt` is a `Date`. Missing or nullable optional fields are omitted. Calling before terminal state and confirmed release throws `SESSION_BUSY`; Verify does not wait for the recording or download it. The method works after `close()` and checks the report before requesting the recording. +To get a computer's screen recording, close it and then call `recording()` on the same object, in the same process: + +```ts +await computer.close(); +const recording = await computer.recording(); // { url, durationSeconds?, startedAt? } or null +``` + +Revyl saves the video a few seconds after the computer is released, so `recording()` waits: it asks every 5 seconds until the video is saved, for up to `timeoutMs` (`recording({ timeoutMs })`, 900000, 15 minutes, by default; 0 asks once). It returns `null` only when none was saved in that time. Since 0.7.1; earlier versions returned `null` at once while the video was still uploading. On a computer that is still running it throws `SESSION_BUSY` saying to call `close()` first. `attach()` can't reopen a closed computer, so get the recording before your script exits; after that it is only in the session at `viewerUrl`. `durationSeconds` is a finite nonnegative number; `startedAt` is a `Date`. Missing or nullable optional fields are omitted. Verify doesn't download the video. The HTTPS URL is signed and short-lived. Keep it private, including its query string; do not log or publish it. Call `recording()` again when a fresh URL is needed. The report carries no recording URL; `viewerUrl` remains a Revyl UI link, not a download URL. Web/mobile sessions reject `recording()` locally with `NOT_AVAILABLE_ON_PLATFORM`. diff --git a/packages/verify/docs/errors.md b/packages/verify/docs/errors.md index ee7a238..901aab9 100644 --- a/packages/verify/docs/errors.md +++ b/packages/verify/docs/errors.md @@ -21,6 +21,7 @@ | Repository unreadable after 3 attempts | `API_ERROR` | `repository_unavailable` | | Computer HTTP 409: no host can keep it running for the requested `timeoutMs` | `NOT_AVAILABLE_ON_PLATFORM` | `lifetime_unsupported` | | Computer HTTP 403 `computer_not_enabled` that Pro would lift (`unlocks_with_card: true`) | `NOT_AVAILABLE_ON_PLATFORM` | `upgrade_required` | +| Web HTTP 409 on `typeFocused`: no text field has focus, and nothing was typed | `ACTION_FAILED` | `no_focused_input` | `web_runtime_unavailable` does not distinguish full capacity from an unavailable runtime. `computer_limit` does not distinguish queued work from concurrency exhaustion. Inspect these fields to classify refusal without parsing prose; do not infer a specific cause or automatically start a replacement session. @@ -53,13 +54,13 @@ try { | `SESSION_START_FAILED` | The browser, device, or computer did not start, or the app an iOS or Android target names by bundle id could not be launched (the message names the bundle id and has the session link) | Computer `no_host` reports the 120-second unclaimed-start context; `device_limit` reports queued-work/concurrency context. Inspect the session and cleanup before starting again. | | `SESSION_PROFILE_FAILED` | A session profile failed: Verify couldn't send its script, Revyl couldn't find it, or it ran and failed. `error.outcome` is `script_failed`, `script_timed_out`, `script_unavailable`, `output_invalid` or `runner_failed`, and `error.failureReason` is Revyl's reason | Follow the message for the outcome; see [Session profiles](api.md#session-profile-errors). Revyl stops the session itself | | `SESSION_ENDED` | The session was closed, stopped, or expired, or Revyl answered 404 for the session itself | Close explicitly; computer expiry does not prove release | -| `SESSION_BUSY` | A step conflict, computer operation limit, someone controlling a computer's screen in the Revyl viewer, or recording requested before terminal state and confirmed release | Inspect the state before another call; a terminal computer alone does not prove release | +| `SESSION_BUSY` | A step conflict, computer operation limit, someone controlling a computer's screen in the Revyl viewer, or `recording()` on a computer you haven't closed | Inspect the state before another call; a terminal computer alone does not prove release | | `COMPUTER_LIMIT` | Computer admission was refused due to queued work (including iOS) or the concurrency limit | Wait for capacity; Verify does not retry or stop a definitely refused start | | `NOT_AVAILABLE_ON_PLATFORM` | The call is unavailable: computer agent steps, device shell/file/recording methods, an exact action the platform lacks (such as `back()` on iOS, `goHome()` or `launchApp()` on Web, `typeFocused()` or keys other than Enter and Backspace on iOS and Android), computer access or runtime unavailable, or a backend without web steps | See [web.md](web.md) and [computers.md](computers.md#availability-and-errors) | | `COMMAND_FAILED` | A computer command exited nonzero | Read its reason; use `exec(argv, { check: false })` to inspect the exit code and output instead | | `NOT_FOUND` | A computer file or resource was not found | Check the workspace-relative path | | `ACCESS_DENIED` | The computer refused access | Check permissions; do not assume host/root access | -| `ACTION_FAILED` | Revyl refused or failed a request on the session | Read the reason in the message | +| `ACTION_FAILED` | Revyl refused or failed a request on the session, such as `typeFocused` on Web with no field focused (reason `no_focused_input`) | Read the reason in the message; for `no_focused_input`, type with `type({ target }, text)`, which taps the field first | | `ACTION_UNCERTAIN` | The connection failed mid-request, or Revyl couldn't confirm a computer screen action, so the step may or may not have run | Verify does not repeat it; check the session link before deciding what to do | | `INSTRUCTION_FAILED` | Revyl's agent, or your model, could not do what the instruction asked. `error.result` is the failed `StepResult`, with `model` when it ran on your model | Make the instruction more specific, or split it into smaller steps | | `VALIDATION_FAILED` | The validation did not hold | The message has Revyl's reason; watch the recording at the session link | diff --git a/packages/verify/docs/getting-started.md b/packages/verify/docs/getting-started.md index 6e4508b..b830d55 100644 --- a/packages/verify/docs/getting-started.md +++ b/packages/verify/docs/getting-started.md @@ -106,7 +106,7 @@ Illustrative output (durations vary): [verify] ios: closed ``` -Open the link to watch the session live. After the session ends, the link keeps its report and any available recording. The Revyl CLI prints the stored report with `revyl device report --session-id ` for web/mobile, or `revyl computer report ` for computers. Computer recordings can be absent or still processing after release; `recording()` retrieves optional private metadata without waiting or downloading. +Open the link to watch the session live. After the session ends, the link keeps its report and any available recording. The Revyl CLI prints the stored report with `revyl device report --session-id ` for web/mobile, or `revyl computer report ` for computers. For a computer, call `recording()` after `close()` on the same object: it waits until Revyl has saved the video and returns its private link, without downloading it. For validation verdicts in device reports, inspect each step's `effective_status` and `validation_result`, and compare `validations_passed` with `total_validations`. `passed_steps`, `failed_steps`, and transport `status: success` can describe successful execution of a validation whose verdict is false. See the [live example](end-to-end.md#reading-the-verdict). diff --git a/packages/verify/docs/llms.txt b/packages/verify/docs/llms.txt index 74410b8..3e67f12 100644 --- a/packages/verify/docs/llms.txt +++ b/packages/verify/docs/llms.txt @@ -1,6 +1,6 @@ # Verify -> Verify (@revyl/verify) is an open-source TypeScript library for Revyl. It opens cloud browsers and iOS/Android devices for agent instruction/validation steps, or Mac computers for commands, files, processes, screenshots, clicks and keys on the screen, and optional private recording metadata after release. Call it from a plain script, coding agent, CI, or any test runner. It has no test runner of its own. +> Verify (@revyl/verify) is an open-source TypeScript library for Revyl. It opens cloud browsers and iOS/Android devices for agent instruction/validation steps, or Mac computers for commands, files, processes, screenshots, clicks and keys on the screen, and the private screen recording after close. Call it from a plain script, coding agent, CI, or any test runner. It has no test runner of its own. ## Docs @@ -22,6 +22,6 @@ Mac computers are available to organizations on a current paid Revyl plan. See c Prefer a description, such as `tap({ target: 'Sign in button' })`: Revyl finds the element on the current screen, and you never handle coordinates. Otherwise a point is `{ x, y }` in screenshot pixels on every platform: whole numbers from the top-left corner of the image `screenshot()` returns. So a position you read off a screenshot goes to `tap()`, `type()`, `swipe()` and every other exact action unchanged. `screenSize()` returns the screenshot's width and height, and `locate()` and the points `tap()`, `doubleTap()`, `longPress()` and `type()` return use the same pixels. A point outside the screenshot is refused with `INVALID_ARGUMENT` before any action is sent, and the message names the valid range. On iOS, Verify converts the pixels to the screen's points for you. On Web they equal CSS pixels at the default device scale factor of 1, and you still pass screenshot pixels at any other. This holds from TypeScript 0.4.1, Python 0.2.1 and Go v0.3.1; earlier versions took iOS points. On a Mac computer a point is in screenshot pixels too, and `tap({ target })` returns the point it clicked in the same pixels. Verify refuses a negative or fractional point before sending it, and Revyl refuses one past the screen's edge without clicking; both throw `INVALID_ARGUMENT` naming the valid range. See [For coding agents](agents.md#exact-actions-and-coordinates) for a runnable example. -Exact actions are `tap`, `doubleTap`, `longPress`, `type`, `swipe`, `drag`, `pressKey`, `locate` and `screenSize` on Web, iOS and Android. Web adds `typeFocused(text)`, which types into the field that has focus, and `pressKey` keys such as `'escape'`, `'tab'` and arrows with `modifiers`. iOS and Android add `goHome()`; their `pressKey` takes only `'enter'` and `'backspace'`, and you type with `type(location, text)`. A Mac computer's screen takes `tap({ x, y })`, `tap({ target })` (which returns the point it clicked; check it, because grounding can click a look-alike or something else when the target isn't there), `screenSize()`, `typeFocused(text, { clear: false })` and `pressKey` with the Web keys, where `'meta'` is Command: select all with `pressKey('a', { modifiers: ['meta'] })` there and `pressKey('a', { modifiers: ['ctrl'] })` on Web. See [computers.md](computers.md#screen). A call the platform lacks throws `NOT_AVAILABLE_ON_PLATFORM` before anything is sent, naming what to use instead. See [api.md](api.md#exact-actions) for every call. +Exact actions are `tap`, `doubleTap`, `longPress`, `type`, `swipe`, `drag`, `pressKey`, `locate` and `screenSize` on Web, iOS and Android. Web adds `typeFocused(text)`, which types into the field that has focus, and `pressKey` keys such as `'escape'`, `'tab'` and arrows with `modifiers`. iOS and Android add `goHome()`; their `pressKey` takes only `'enter'` and `'backspace'`. To type on every platform, use `type({ target: 'Email field' }, text)`, which taps the field and types into it; `typeFocused` on Web with no field focused throws `ACTION_FAILED` (reason `no_focused_input`), and on iOS and Android it throws `NOT_AVAILABLE_ON_PLATFORM`. A Mac computer's screen takes `tap({ x, y })`, `tap({ target })` (which returns the point it clicked; check it, because grounding can click a look-alike or something else when the target isn't there), `type({ target }, text)`, `screenSize()`, `typeFocused(text, { clear: false })` and `pressKey` with the Web keys, where `'meta'` is Command: select all with `pressKey('a', { modifiers: ['meta'] })` there and `pressKey('a', { modifiers: ['ctrl'] })` on Web. See [computers.md](computers.md#screen). A call the platform lacks throws `NOT_AVAILABLE_ON_PLATFORM` before anything is sent, naming what to use instead. See [api.md](api.md#exact-actions) for every call. On Web the browser runtime waits after each `tap`, `doubleTap`, `longPress`, `type`, `typeFocused`, `swipe`, `drag` and `pressKey` until the page stops changing, up to about 6 seconds, and a game or animation never stops. Pass `{ settle: false }` for games, animations and rapid input such as `pressKey('arrowleft', { settle: false })` every few hundred milliseconds: the call returns as soon as the input is sent, before the screen may have changed, so take a `screenshot()` or run a `validation()` when you need to see the result, and don't rely on the next screenshot showing it. iOS, Android and Mac computers don't wait, so `settle: false` changes nothing there. Python takes `settle=False` and Go `Settle: new(false)`. See [api.md](api.md#exact-actions). diff --git a/packages/verify/docs/mobile.md b/packages/verify/docs/mobile.md index eafa13d..c3e7847 100644 --- a/packages/verify/docs/mobile.md +++ b/packages/verify/docs/mobile.md @@ -50,7 +50,7 @@ For Android Settings (`bundleId: 'com.android.settings'`), instruct the agent to ## Exact actions -**Early access.** Since TypeScript (`@revyl/verify`) 0.4.0, Python (`revyl-verify`) 0.2.0 and Go v0.3.0. `doubleTap`, `longPress`, `drag`, `typeFocused`, `goHome`, and Web keys and modifiers in `pressKey`, are new in TypeScript 0.5.0, Python 0.3.0 and Go v0.4.0. The [Python](https://github.com/RevylAI/verify/blob/v0.7.0/python/README.md#exact-actions) and [Go](https://github.com/RevylAI/verify/blob/v0.7.0/go/README.md#exact-actions) READMEs show them with each language's names. When you know exactly what to press, skip the agent. Exact actions run on the device as given, with no model, and mix freely with `instruction()` and `validation()` in one script: +**Early access.** Since TypeScript (`@revyl/verify`) 0.4.0, Python (`revyl-verify`) 0.2.0 and Go v0.3.0. `doubleTap`, `longPress`, `drag`, `typeFocused`, `goHome`, and Web keys and modifiers in `pressKey`, are new in TypeScript 0.5.0, Python 0.3.0 and Go v0.4.0. The [Python](https://github.com/RevylAI/verify/blob/v0.7.1/python/README.md#exact-actions) and [Go](https://github.com/RevylAI/verify/blob/v0.7.1/go/README.md#exact-actions) READMEs show them with each language's names. When you know exactly what to press, skip the agent. Exact actions run on the device as given, with no model, and mix freely with `instruction()` and `validation()` in one script: ```ts import { open } from '@revyl/verify'; @@ -97,7 +97,7 @@ try { } ``` -`goHome()` goes to the home screen on iOS and Android. `longPress()` holds for 1500 ms unless you pass `duration`, from 1 to 5000. `drag(from, to)` presses at one location, moves to the other and releases. On iOS and Android, type into a field with `type(location, text)`, which taps it first; `typeFocused()` is Web only and throws `NOT_AVAILABLE_ON_PLATFORM` here. +`goHome()` goes to the home screen on iOS and Android. `longPress()` holds for 1500 ms unless you pass `duration`, from 1 to 5000. `drag(from, to)` presses at one location, moves to the other and releases. On iOS and Android, as everywhere, type with `type({ target: 'Search field' }, text)`, which taps the field and then types; `typeFocused()` throws `NOT_AVAILABLE_ON_PLATFORM` here before anything is sent, naming `type({ target }, text)`. On Android, `back()` presses the system back button. On both platforms, `goHome()` goes to the home screen, `launchApp(bundleId)` brings an installed app to the front and `openUrl('myapp://orders/42')` opens a deep link. A failed action throws `ACTION_FAILED`. One whose outcome Revyl can't confirm throws `ACTION_UNCERTAIN` or `TIMEOUT`, so check the session before acting again. Actions are never repeated. If Verify can't reach Revyl, the action fails with `API_ERROR` and isn't resent either, so check the session before trying it again. [api.md](api.md#exact-actions) lists every call. @@ -105,9 +105,10 @@ On Android, `back()` presses the system back button. On both platforms, `goHome( | --- | --- | --- | --- | --- | | `tap({ x, y })`, `tap({ target })`, `screenSize` | Yes | Yes | Yes | Yes | | `locate` | Yes | Yes | Yes | No, use `tap({ target })`, which returns the point it clicked, or read the point off `screenshot()` | -| `doubleTap`, `longPress`, `type`, `swipe`, `drag` | Yes | Yes | Yes | No | +| `type({ target }, text)`, the way to type | Yes | Yes | Yes | Yes: clicks the field, selects its text unless `{ clear: false }`, then types | +| `doubleTap`, `longPress`, `swipe`, `drag` | Yes | Yes | Yes | No | | `pressKey(key, { modifiers })` | Yes: `'enter'`, `'backspace'`, `'tab'`, `'escape'`, arrows and more, with modifiers | `'enter'` and `'backspace'` only | `'enter'` and `'backspace'` only | Yes: the Web keys and modifiers, where `'meta'` is Command | -| `typeFocused(text, { clear })` | Yes, types into the focused field | No, use `type(location, text)` | No, use `type(location, text)` | Yes, with `{ clear: false }` | +| `typeFocused(text, { clear })` | Yes, types into the focused field; `ACTION_FAILED` (`no_focused_input`) when none has focus | No, use `type({ target }, text)` | No, use `type({ target }, text)` | Yes, with `{ clear: false }` | | `back()` | Yes, browser history | No, tap the on-screen back control | Yes, the system back button | No | | `goHome()` | No, use `openUrl` or `navigate` | Yes, the home screen | Yes, the home screen | No | | `openUrl(url)` | Yes, loads an http(s) URL in the tab | Yes, a URL or deep link | Yes, a URL or deep link | No | diff --git a/packages/verify/docs/own-model.md b/packages/verify/docs/own-model.md index 9cd94b5..4d90849 100644 --- a/packages/verify/docs/own-model.md +++ b/packages/verify/docs/own-model.md @@ -1,6 +1,6 @@ # Use your own model -**Early access.** Since TypeScript (`@revyl/verify`) 0.4.0, Python (`revyl-verify`) 0.2.0 and Go v0.3.0; the [Python](https://github.com/RevylAI/verify/blob/v0.7.0/python/README.md#your-own-model) and [Go](https://github.com/RevylAI/verify/blob/v0.7.0/go/README.md#your-own-model) READMEs show them with each language's names. Verify normally runs `instruction()` and `validation()` on Revyl's agent. Pass a `model` and the agent loop runs in your process instead, on a model you choose, with your own key. Revyl still provides the cloud browser or device and, by default, finds the elements your model names on screen. +**Early access.** Since TypeScript (`@revyl/verify`) 0.4.0, Python (`revyl-verify`) 0.2.0 and Go v0.3.0; the [Python](https://github.com/RevylAI/verify/blob/v0.7.1/python/README.md#your-own-model) and [Go](https://github.com/RevylAI/verify/blob/v0.7.1/go/README.md#your-own-model) READMEs show them with each language's names. Verify normally runs `instruction()` and `validation()` on Revyl's agent. Pass a `model` and the agent loop runs in your process instead, on a model you choose, with your own key. Revyl still provides the cloud browser or device and, by default, finds the elements your model names on screen. Use it when you want a specific model, your own prompts and key, or faster steps on a cheap model. Leave `model` out and nothing changes. @@ -52,7 +52,7 @@ log.Println(step.Model.ID, len(step.Model.Turns), step.Model.InputTokens, step.M _, err = s.Validation(ctx, "The screen shows the iOS version") ``` -The [Python](https://github.com/RevylAI/verify/blob/v0.7.0/python/README.md#your-own-model) and [Go](https://github.com/RevylAI/verify/blob/v0.7.0/go/README.md#your-own-model) READMEs have the full reference for each. +The [Python](https://github.com/RevylAI/verify/blob/v0.7.1/python/README.md#your-own-model) and [Go](https://github.com/RevylAI/verify/blob/v0.7.1/go/README.md#your-own-model) READMEs have the full reference for each. Set `model` on `open()` to run every step on it, or on one step to override it: diff --git a/packages/verify/docs/web.md b/packages/verify/docs/web.md index 80c7935..11f4588 100644 --- a/packages/verify/docs/web.md +++ b/packages/verify/docs/web.md @@ -53,7 +53,7 @@ Revyl runs one step at a time on a session. A step sent while another is still r ## Exact actions -**Early access.** Since TypeScript (`@revyl/verify`) 0.4.0, Python (`revyl-verify`) 0.2.0 and Go v0.3.0. `doubleTap`, `longPress`, `drag`, `typeFocused`, `goHome`, and Web keys and modifiers in `pressKey`, are new in TypeScript 0.5.0, Python 0.3.0 and Go v0.4.0. The [Python](https://github.com/RevylAI/verify/blob/v0.7.0/python/README.md#exact-actions) and [Go](https://github.com/RevylAI/verify/blob/v0.7.0/go/README.md#exact-actions) READMEs show them with each language's names. When you know exactly what to click, skip the agent. Exact actions run in the browser as given, with no model, and mix freely with `instruction()` and `validation()`: +**Early access.** Since TypeScript (`@revyl/verify`) 0.4.0, Python (`revyl-verify`) 0.2.0 and Go v0.3.0. `doubleTap`, `longPress`, `drag`, `typeFocused`, `goHome`, and Web keys and modifiers in `pressKey`, are new in TypeScript 0.5.0, Python 0.3.0 and Go v0.4.0. The [Python](https://github.com/RevylAI/verify/blob/v0.7.1/python/README.md#exact-actions) and [Go](https://github.com/RevylAI/verify/blob/v0.7.1/go/README.md#exact-actions) READMEs show them with each language's names. When you know exactly what to click, skip the agent. Exact actions run in the browser as given, with no model, and mix freely with `instruction()` and `validation()`: ```ts import { open } from '@revyl/verify'; @@ -86,10 +86,9 @@ import { open } from '@revyl/verify'; const session = await open('web'); // https://www.saucedemo.com in examples/web-store try { - await session.tap({ target: 'Username field' }); - await session.typeFocused('standard_user'); // types into the field that has focus, replacing its text + await session.type({ target: 'Username field' }, 'standard_user'); // taps the field, then types await session.pressKey('tab'); // focus moves to the password field - await session.typeFocused('secret_sauce'); + await session.typeFocused('secret_sauce'); // types into the field that has focus, replacing its text await session.pressKey('enter'); await session.validation('A list of products is shown'); await session.tap({ target: 'Open Menu button' }); @@ -104,15 +103,16 @@ try { } ``` -`typeFocused(text)` types where the focus already is, without clicking, and replaces the field's text unless you pass `{ clear: false }`. Focus the field first, with `tap()` or `pressKey('tab')`: with no field focused, nothing is typed and no error is thrown. `pressKey()` takes `'enter'`, `'backspace'`, `'tab'`, `'escape'`, `'delete'`, `'space'`, `'arrowup'`, `'arrowdown'`, `'arrowleft'`, `'arrowright'`, `'home'`, `'end'`, `'pageup'` and `'pagedown'`, with up to four `modifiers` held (`'ctrl'`, `'shift'`, `'alt'`, `'meta'`); with modifiers a lowercase letter or digit works too. The shortcut key on Web is `'ctrl'`, so select all with `pressKey('a', { modifiers: ['ctrl'] })`: `'meta'` is not the shortcut key here, though it is Command on a [Mac computer](computers.md#screen). `longPress()` holds for 1500 ms unless you pass `duration`, from 1 to 5000. `drag(from, to)` presses at one location, moves to the other and releases. A failed action throws `ACTION_FAILED`. One whose outcome Revyl can't confirm throws `ACTION_UNCERTAIN` or `TIMEOUT`, so check the session before acting again. Actions are never repeated. If Verify can't reach Revyl, the action fails with `API_ERROR` and isn't resent either, so check the session before trying it again. [api.md](api.md#exact-actions) lists every call. +**Typing: one rule on every platform.** To type, call `type({ target: 'Email field' }, text)`: it taps the field you describe and types into it, replacing its text unless you pass `{ clear: false }`. It works the same on Web, iOS, Android and a Mac computer. `typeFocused(text)` types wherever focus already is, without tapping, and only on Web and computers; on Web, when no field has focus it throws `ACTION_FAILED` with reason `no_focused_input` and types nothing. `typeFocused` replaces the field's text unless you pass `{ clear: false }`; it suits a field you reached with `pressKey('tab')`. `pressKey()` takes `'enter'`, `'backspace'`, `'tab'`, `'escape'`, `'delete'`, `'space'`, `'arrowup'`, `'arrowdown'`, `'arrowleft'`, `'arrowright'`, `'home'`, `'end'`, `'pageup'` and `'pagedown'`, with up to four `modifiers` held (`'ctrl'`, `'shift'`, `'alt'`, `'meta'`); with modifiers a lowercase letter or digit works too. The shortcut key on Web is `'ctrl'`, so select all with `pressKey('a', { modifiers: ['ctrl'] })`: `'meta'` is not the shortcut key here, though it is Command on a [Mac computer](computers.md#screen). `longPress()` holds for 1500 ms unless you pass `duration`, from 1 to 5000. `drag(from, to)` presses at one location, moves to the other and releases. A failed action throws `ACTION_FAILED`. One whose outcome Revyl can't confirm throws `ACTION_UNCERTAIN` or `TIMEOUT`, so check the session before acting again. Actions are never repeated. If Verify can't reach Revyl, the action fails with `API_ERROR` and isn't resent either, so check the session before trying it again. [api.md](api.md#exact-actions) lists every call. | Call | Web | iOS | Android | Mac computer | | --- | --- | --- | --- | --- | | `tap({ x, y })`, `tap({ target })`, `screenSize` | Yes | Yes | Yes | Yes | | `locate` | Yes | Yes | Yes | No, use `tap({ target })`, which returns the point it clicked, or read the point off `screenshot()` | -| `doubleTap`, `longPress`, `type`, `swipe`, `drag` | Yes | Yes | Yes | No | +| `type({ target }, text)`, the way to type | Yes | Yes | Yes | Yes: clicks the field, selects its text unless `{ clear: false }`, then types | +| `doubleTap`, `longPress`, `swipe`, `drag` | Yes | Yes | Yes | No | | `pressKey(key, { modifiers })` | Yes: `'enter'`, `'backspace'`, `'tab'`, `'escape'`, arrows and more, with modifiers | `'enter'` and `'backspace'` only | `'enter'` and `'backspace'` only | Yes: the Web keys and modifiers, where `'meta'` is Command | -| `typeFocused(text, { clear })` | Yes, types into the focused field | No, use `type(location, text)` | No, use `type(location, text)` | Yes, with `{ clear: false }` | +| `typeFocused(text, { clear })` | Yes, types into the focused field; `ACTION_FAILED` (`no_focused_input`) when none has focus | No, use `type({ target }, text)` | No, use `type({ target }, text)` | Yes, with `{ clear: false }` | | `back()` | Yes, browser history | No, tap the on-screen back control | Yes, the system back button | No | | `goHome()` | No, use `openUrl` or `navigate` | Yes, the home screen | Yes, the home screen | No | | `openUrl(url)` | Yes, loads an http(s) URL in the tab | Yes, a URL or deep link | Yes, a URL or deep link | No | diff --git a/packages/verify/package.json b/packages/verify/package.json index 854e851..f1e3a39 100644 --- a/packages/verify/package.json +++ b/packages/verify/package.json @@ -1,6 +1,6 @@ { "name": "@revyl/verify", - "version": "0.7.0", + "version": "0.7.1", "description": "Open Revyl cloud browsers and mobile devices for agent steps, or Mac computers for commands and files, from TypeScript.", "keywords": [ "e2e", diff --git a/packages/verify/src/agent/loop.ts b/packages/verify/src/agent/loop.ts index 2967e08..15b759d 100644 --- a/packages/verify/src/agent/loop.ts +++ b/packages/verify/src/agent/loop.ts @@ -364,13 +364,13 @@ function instructionTools(platform: AgentControls['platform'], grounding: Ground { name: 'long_press', description: 'Press and hold an element, for example to open a context menu.', parameters: { type: 'object', ...at } }, { name: 'type', - description: 'Tap a text field and type into it. Clears the field first unless clear is false.', + description: 'Tap a text field and type into it. Use this to type. Clears the field first unless clear is false.', parameters: { type: 'object', properties: { ...at.properties, text: { type: 'string' }, clear: { type: 'boolean' } }, required: [...at.required, 'text'] }, }, ...(web ? [{ name: 'type_focused', - description: 'Type into the field that already has focus, without tapping. Clears the field first unless clear is false.', + description: 'Type into the field that already has focus, without tapping. Nothing is typed when no field has focus, so prefer type. Clears the field first unless clear is false.', parameters: { type: 'object', properties: { text: { type: 'string' }, clear: { type: 'boolean' } }, required: ['text'] }, }] : []), diff --git a/packages/verify/src/computer-session.ts b/packages/verify/src/computer-session.ts index 3db7ad2..264d6e9 100644 --- a/packages/verify/src/computer-session.ts +++ b/packages/verify/src/computer-session.ts @@ -28,7 +28,10 @@ const REFUSAL_NEXT_STEPS = { SESSION_BUSY: 'The computer is busy with other work; try again once it finishes.', API_ERROR: 'Try again; if it keeps failing, send this message to support@revyl.ai.', } satisfies Partial>; -const SCREEN_CALLS = 'For the screen, use screenshot(), tap({ x, y }) or tap({ target }), typeFocused(text, { clear: false }) and pressKey(); for commands, use exec().'; +const RECORDING_WAIT_MS = 900_000; +const RECORDING_POLL_MS = 5_000; +const COMPUTER_CONTROL_CHARACTER = /[\u0000-\u0008\u000b-\u001f\u007f-\u009f]|[\ud800-\udbff](?![\udc00-\udfff])|(? { - return this.unavailable('type'); + /** Clicks a field, selects its text unless clear is false, and types, so the text replaces what was there. Returns the point clicked. */ + async type(at: Location, text: string, options: { clear?: boolean } & ActionOptions = {}): Promise { + checkSettle(options.settle); + if (typeof text !== 'string' || text.length > 16_384) throw new VerifyError('INVALID_ARGUMENT', 'type() takes text of at most 16384 characters.'); + const control = COMPUTER_CONTROL_CHARACTER.exec(text); + if (control) throw new VerifyError('INVALID_ARGUMENT', `Nothing was typed: type() on a computer takes newline and tab but no other control characters, and the text has one at index ${control.index}. Use pressKey() for keys such as 'escape'.`); + const point = await this.tap(at); + if (options.clear !== false) await this.pressKey('a', { modifiers: [this.platform === 'mac' ? 'meta' : 'ctrl'] }); + await this.typeFocused(text, { clear: false }); + return point; } /** Types into whatever has keyboard focus. Computers can't clear a field, so pass { clear: false }. */ @@ -203,7 +214,7 @@ export class ComputerSession implements Session { checkSettle(options.settle); if (options.clear !== false) throw new VerifyError('INVALID_ARGUMENT', "On a computer, typeFocused() can't clear the field first, so pass { clear: false } to type at the cursor: typeFocused(text, { clear: false }). To replace text, select it first, for example with pressKey('a', { modifiers: ['meta'] }) (Command+A on a Mac computer)."); if (typeof text !== 'string' || text.length > 16_384) throw new VerifyError('INVALID_ARGUMENT', 'typeFocused() takes text of at most 16384 characters.'); - const control = /[\u0000-\u0008\u000b-\u001f\u007f-\u009f]|[\ud800-\udbff](?![\udc00-\udfff])|(? { - const signal = AbortSignal.timeout(30_000); - const report = this.parseReport(await this.request('GET', '/report', undefined, signal)); + /** After close(), waits until Revyl has saved the computer's recording, usually seconds, and returns it; null when none was saved within timeoutMs (default 15 minutes). */ + async recording(options: { timeoutMs?: number } = {}): Promise { + const timeoutMs = options.timeoutMs ?? RECORDING_WAIT_MS; + if (!Number.isInteger(timeoutMs) || timeoutMs < 0 || timeoutMs > 3_600_000) throw new VerifyError('INVALID_ARGUMENT', 'recording() timeoutMs is whole milliseconds from 0 to 3600000.'); + const deadline = Date.now() + timeoutMs; + const report = this.parseReport(await this.request('GET', '/report', undefined, AbortSignal.timeout(30_000))); if (!['stopped', 'failed', 'owner_lost'].includes(report.state) || report.release !== 'confirmed') { - throw new VerifyError('SESSION_BUSY', `The computer recording can be requested only after terminal state and confirmed release. See ${this.viewerUrl}`); + throw new VerifyError('SESSION_BUSY', `The computer is still running, so it has no recording yet. Call close() first, then recording(), which waits until Revyl has saved the video. See ${this.viewerUrl}`); + } + let response: RawResponse; + for (let waited = false; ; waited = true) { + response = await this.request('GET', '/recording', undefined, AbortSignal.timeout(30_000)); + if (response.status !== 404 || responseErrorCode(response) !== 'recording_unavailable') break; + const remainingMs = deadline - Date.now(); + if (remainingMs <= 0) { + if (waited) this.log(`no recording was saved within ${Math.round(timeoutMs / 1_000)} seconds`); + return null; + } + if (!waited) this.log('waiting for Revyl to save the recording'); + await delay(Math.min(RECORDING_POLL_MS, remainingMs)); } - const response = await this.request('GET', '/recording', undefined, signal); - if (response.status === 404 && responseErrorCode(response) === 'recording_unavailable') return null; const raw = parseComputerJson(response); if (!raw || typeof raw.url !== 'string' || !/^https:\/\//i.test(raw.url) || /[\x00-\x20\x7f]/.test(raw.url)) throw invalidResponse(); let url: URL; diff --git a/packages/verify/src/errors.ts b/packages/verify/src/errors.ts index 31504f7..7a794bc 100644 --- a/packages/verify/src/errors.ts +++ b/packages/verify/src/errors.ts @@ -28,7 +28,7 @@ export type VerifyErrorCode = | 'SESSION_PROFILE_FAILED' | 'TIMEOUT'; -export type RefusalReason = 'web_runtime_unavailable' | 'web_runtime_not_configured' | 'computer_limit' | 'runtime_unavailable' | 'computer_runtime_unavailable' | 'computer_at_capacity' | 'computer_platform_at_capacity' | 'computer_not_running' | 'computer_cannot_host_platform' | 'computer_not_found' | 'web_build_required' | 'web_build_not_supported' | 'ios_build_required' | 'ios_build_not_supported' | 'android_build_required' | 'android_build_not_supported' | 'web_session_conflict' | 'ios_session_conflict' | 'android_session_conflict' | 'not_available_on_platform' | 'persistent_computers_not_enabled' | 'upgrade_required' | 'request_timeout' | 'protocol_error' | 'session_profile_undefined' | 'session_profile_source_required' | 'session_profile_files_need_named' | 'session_profile_script_unavailable' | 'repository_connection_missing' | 'project_not_found' | 'repository_unavailable' | 'lifetime_unsupported'; +export type RefusalReason = 'web_runtime_unavailable' | 'web_runtime_not_configured' | 'computer_limit' | 'runtime_unavailable' | 'computer_runtime_unavailable' | 'computer_at_capacity' | 'computer_platform_at_capacity' | 'computer_not_running' | 'computer_cannot_host_platform' | 'computer_not_found' | 'web_build_required' | 'web_build_not_supported' | 'ios_build_required' | 'ios_build_not_supported' | 'android_build_required' | 'android_build_not_supported' | 'web_session_conflict' | 'ios_session_conflict' | 'android_session_conflict' | 'not_available_on_platform' | 'persistent_computers_not_enabled' | 'upgrade_required' | 'request_timeout' | 'protocol_error' | 'session_profile_undefined' | 'session_profile_source_required' | 'session_profile_files_need_named' | 'session_profile_script_unavailable' | 'repository_connection_missing' | 'project_not_found' | 'repository_unavailable' | 'lifetime_unsupported' | 'no_focused_input'; export class VerifyError extends Error { readonly code: VerifyErrorCode; diff --git a/packages/verify/src/session.ts b/packages/verify/src/session.ts index 2d424a0..6149448 100644 --- a/packages/verify/src/session.ts +++ b/packages/verify/src/session.ts @@ -162,7 +162,8 @@ export interface Session { readonly steps: StepResult[]; readonly closed: boolean; readonly expiresAt?: Date; - recording(): Promise; + /** A computer's recording after close(), waiting until Revyl has saved it; null when none was saved within timeoutMs (default 15 minutes). Computers only. */ + recording(options?: { timeoutMs?: number }): Promise; /** Asks Revyl's agent to do something on the app. Browsers and devices only. */ instruction(text: string, options?: StepOptions): Promise; /** Asks Revyl's agent whether something holds on screen. Browsers and devices only. */ @@ -203,9 +204,9 @@ export interface OpenedSession extends Session { * On web, { settle: false } returns without waiting for the page to settle; see ActionOptions. */ tap(at: Location, options?: ActionOptions): Promise; - /** Taps a text field and types into it, clearing it first unless clear is false. Returns the point tapped. Browsers and devices only. */ + /** The way to type on every platform: taps a text field and types into it, clearing it first unless clear is false. Returns the point tapped. */ type(at: Location, text: string, options?: { clear?: boolean } & ActionOptions): Promise; - /** Types into the field that already has focus, without tapping, replacing its content unless clear is false. Web and Mac computers, where clear must be false; on iOS and Android, use type(location, text). */ + /** Types into the field that already has focus, without tapping, replacing its content unless clear is false. Web and computers, where clear must be false; on iOS and Android, use type({ target }, text). */ typeFocused(text: string, options?: { clear?: boolean } & ActionOptions): Promise; /** Double-taps a point in screenshot pixels, or an element Revyl locates from a description. Returns the point, in screenshot pixels. Browsers and devices only. */ doubleTap(at: Location, options?: ActionOptions): Promise; @@ -728,7 +729,7 @@ export class DeviceSession implements Session { /** Types into the field that already has focus, without tapping, replacing its content unless clear is false. Web only. */ async typeFocused(text: string, options: { clear?: boolean } & ActionOptions = {}): Promise { - if (this.platform !== 'web') throw new VerifyError('NOT_AVAILABLE_ON_PLATFORM', 'typeFocused() is available only on web sessions; on iOS and Android, use type(location, text), which taps the field first.'); + if (this.platform !== 'web') throw new VerifyError('NOT_AVAILABLE_ON_PLATFORM', "typeFocused() isn't available on iOS and Android sessions. Use type({ target: 'the email field' }, text), which taps the field and types into it."); if (typeof text !== 'string' || text.length > 16_384) throw new VerifyError('INVALID_ARGUMENT', 'typeFocused() takes text of at most 16384 characters.'); const settle = checkSettle(options.settle); await this.perform({ kind: 'type_focused', text, clear: options.clear !== false }, undefined, undefined, settle); @@ -1054,6 +1055,9 @@ export class DeviceSession implements Session { } return new VerifyError('NOT_AVAILABLE_ON_PLATFORM', `${baseAction} is not available on ${this.platform} sessions (${reason}).`); } + if (code === 'no_focused_input') { + return new VerifyError('ACTION_FAILED', `Nothing was typed: no text field has focus (no_focused_input). Use type({ target: 'the email field' }, text), which taps the field and types into it, or tap the field first. See ${this.viewerUrl}`, { reason: 'no_focused_input', httpStatus: response.status }); + } if (WEB_TARGET_ERRORS.has(code ?? detail ?? '')) { return new VerifyError('ACTION_FAILED', `${baseAction} could not act on the screen (${code ?? detail}). Take a fresh screenshot and try again. See ${this.viewerUrl}`); } diff --git a/packages/verify/test/computer.test.ts b/packages/verify/test/computer.test.ts index 75fd0cf..8e34c62 100644 --- a/packages/verify/test/computer.test.ts +++ b/packages/verify/test/computer.test.ts @@ -451,9 +451,9 @@ describe.each(['mac', 'linux'] as const)('%s computer recording', (platform) => await expect((await start(fake, [], platform)).recording()).rejects.toMatchObject({ code: 'API_ERROR', message: 'Revyl returned an invalid computer response.' }); }); - it('returns null only for the recording_unavailable error without waiting', async () => { + it('returns null only for the recording_unavailable error once timeoutMs has passed', async () => { const fake = recordingFake().on('GET', /\/recording$/, () => json({ error: 'recording_unavailable' }, 404)); - expect(await (await start(fake, [], platform)).recording()).toBeNull(); + expect(await (await start(fake, [], platform)).recording({ timeoutMs: 0 })).toBeNull(); expect(fake.calls('GET', /\/recording$/)).toHaveLength(1); }); diff --git a/python/README.md b/python/README.md index f5bc620..df437c9 100644 --- a/python/README.md +++ b/python/README.md @@ -104,10 +104,10 @@ with open(Target(platform="mac", start_timeout=600)) as session: processes = session.processes() session.screenshot(path="mac.png") -recording = session.recording() +recording = session.recording() # after the with block closes the computer; 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. `recording()` returns computer recording metadata or `None`, including after close; it does not wait for or download a recording. 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). 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()`: @@ -121,13 +121,12 @@ with open(Target(platform="mac", start_timeout=600)) as computer: computer.exec(["open", "-a", "TextEdit", "notes.txt"]) # exec runs in the workspace time.sleep(3) # let the window open computer.screenshot(path=".verify/mac.png") # open it and find the text - computer.tap(Point(400, 300)) # the point as you read it - computer.type_focused("First line\nSecond line", clear=False) - computer.press_key("a", modifiers=["meta"]) # Command+A selects all - computer.type_focused("Replacement", clear=False) # typing replaces the selection + computer.type("the TextEdit document", "First line\nSecond line") # clicks, selects all, types + computer.type_focused("\nThird line", clear=False) # types where the cursor already is + computer.tap(Point(400, 300)) # or click a point as you read it ``` -On a computer, `type_focused` needs `clear=False`: it types where the cursor is and clears nothing, so to replace text, select it first. `"meta"` is Command and `"alt"` is Option. `screen_size()` works too. `tap("the Help menu in the menu bar")` clicks a description and returns the `Point` it clicked. It takes several seconds and can click a look-alike, or something else when the target isn't on the screen, so check the point or take a screenshot afterwards, and use `tap(Point(x, y))` from a screenshot for anything that's hard to undo. `locate()` and the other exact actions aren't available on computers and raise `NOT_AVAILABLE_ON_PLATFORM` before anything is sent. When Revyl answers `screen_starting`, nothing happened, so Verify waits and tries again for up to 30 seconds. A script keeps control of the screen for 120 seconds after its last action, so a teammate can't take control in the Revyl viewer until then; while someone does control it there, actions raise `SESSION_BUSY` and nothing happens. A 403 raises `AUTH_REJECTED`: the key's owner needs the Member role or above, and CI runner keys can't control the screen yet. [computers.md](https://github.com/RevylAI/verify/blob/main/packages/verify/docs/computers.md#screen) lists every screen error. +On a computer, as everywhere, type with `type("description", text)`: it clicks the field, selects its text with Command+A unless `clear=False`, and types. `type_focused` needs `clear=False`: it types where the cursor is and clears nothing, so to replace text, select it first. `"meta"` is Command and `"alt"` is Option. `screen_size()` works too. `tap("the Help menu in the menu bar")` clicks a description and returns the `Point` it clicked. It takes several seconds and can click a look-alike, or something else when the target isn't on the screen, so check the point or take a screenshot afterwards, and use `tap(Point(x, y))` from a screenshot for anything that's hard to undo. `locate()` and the exact actions other than `tap`, `type`, `type_focused`, `press_key` and `screen_size` aren't available on computers and raise `NOT_AVAILABLE_ON_PLATFORM` before anything is sent. When Revyl answers `screen_starting`, nothing happened, so Verify waits and tries again for up to 30 seconds. A script keeps control of the screen for 120 seconds after its last action, so a teammate can't take control in the Revyl viewer until then; while someone does control it there, actions raise `SESSION_BUSY` and nothing happens. A 403 raises `AUTH_REJECTED`: the key's owner needs the Member role or above, and CI runner keys can't control the screen yet. [computers.md](https://github.com/RevylAI/verify/blob/main/packages/verify/docs/computers.md#screen) lists every screen error. **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. @@ -251,7 +250,9 @@ Neither errors nor logs contain the script's content or output. A refusal keeps ## Exact actions -**Since 0.2.0. Early access.** Web, iOS and Android sessions take device actions that need no agent. They match the TypeScript SDK's exact actions in snake_case, and `AsyncSession` has the same methods to await. `double_tap`, `long_press`, `drag`, `type_focused`, `go_home`, and Web keys and modifiers in `press_key`, are new in 0.3.0. `tap` (by point or description), `screen_size`, `type_focused` and `press_key` on a Mac computer's screen are new in 0.4.0; see [Mac computer](#mac-computer). +**Since 0.2.0. Early access.** Web, iOS and Android sessions take device actions that need no agent. They match the TypeScript SDK's exact actions in snake_case, and `AsyncSession` has the same methods to await. `double_tap`, `long_press`, `drag`, `type_focused`, `go_home`, and Web keys and modifiers in `press_key`, are new in 0.3.0. `tap` (by point or description), `screen_size`, `type_focused` and `press_key` on a Mac computer's screen are new in 0.4.0, and `type` there in 0.5.1; see [Mac computer](#mac-computer). + +**Typing: one rule on every platform.** To type, call `type("Email field", text)`: it taps the field you describe and types into it, replacing its text unless you pass `clear=False`. It works the same on Web, iOS, Android and a Mac computer. `type_focused(text)` types wherever focus already is, without tapping, and only on Web and computers; on Web, when no field has focus it raises `ACTION_FAILED` with `reason="no_focused_input"` and types nothing. ```python from revyl_verify import Point, Target, open @@ -272,7 +273,7 @@ with open(Target(platform="ios", bundle_id="com.apple.Preferences")) as session: session.go_home() # the home screen, on iOS and Android ``` -On Web, type where the focus is and press more keys: +On Web, type into a field, then where the focus moves, and press more keys: ```python import os @@ -281,10 +282,9 @@ from revyl_verify import Target, open web = Target(platform="web", app_id=os.environ["REVYL_WEB_APP_ID"], url="https://www.saucedemo.com") with open(web) as session: - session.tap("Username field") - session.type_focused("standard_user") # replaces the focused field's text unless clear=False + session.type("Username field", "standard_user") # taps the field, then types session.press_key("tab") # focus moves to the password field - session.type_focused("secret_sauce") + session.type_focused("secret_sauce") # replaces the focused field's text unless clear=False session.press_key("enter") session.tap("Open Menu button") session.press_key("escape") # closes the menu @@ -298,8 +298,8 @@ A location is a `Point(x, y)` in whole, non-negative screenshot pixels from the | `tap(at)` | Taps (clicks on Web and Mac computers) and returns the `Point` tapped. On a Mac computer a described tap takes several seconds and can click a look-alike, so check the point | | `double_tap(at)` | Double-taps (double-clicks on Web) and returns the `Point` | | `long_press(at, duration=None)` | Presses and holds for `duration` seconds, 0.001 to 5 in whole milliseconds (1.5 by default), and returns the `Point` | -| `type(at, text, clear=True)` | Taps a text field and types into it, clearing it first unless `clear` is `False`; returns the `Point` tapped | -| `type_focused(text, clear=True)` | Web and Mac computers: types into the field that already has focus, without clicking. Focus the field first, for example with `tap` or `press_key("tab")`. With no field focused nothing is typed and nothing is raised, so check the result. On Web it replaces the field's text unless `clear` is `False`. On a Mac computer pass `clear=False`: it types where the cursor is, and leaving `clear` out raises `INVALID_ARGUMENT`. To replace text there, select it first with `press_key("a", modifiers=["meta"])`. On iOS and Android it raises `NOT_AVAILABLE_ON_PLATFORM`; use `type(location, text)` | +| `type(at, text, clear=True)` | The way to type, on every platform. Taps a text field and types into it, clearing it first unless `clear` is `False`; returns the `Point` tapped. On a Mac computer it clicks the field, selects its text with Command+A unless `clear` is `False`, and types | +| `type_focused(text, clear=True)` | Web and Mac computers: types into the field that already has focus, without clicking. Prefer `type("description", text)`. On Web, with no field focused nothing is typed and it raises `ACTION_FAILED` with `reason="no_focused_input"`; on a Mac computer the keys go to whatever has focus, so check the result. On Web it replaces the field's text unless `clear` is `False`. On a Mac computer pass `clear=False`: it types where the cursor is, and leaving `clear` out raises `INVALID_ARGUMENT`. To replace text there, select it first with `press_key("a", modifiers=["meta"])`. On iOS and Android it raises `NOT_AVAILABLE_ON_PLATFORM` before anything is sent; use `type("description", text)` | | `swipe(direction, from_=None)` | Swipes from a location or the screen's center; `"up"` moves the finger up, which scrolls content down | | `drag(start, end)` | Presses at one location, moves to the other and releases, for example to reorder a list, move a slider or select text | | `press_key(key, modifiers=())` | Presses a key on the focused element. Every platform takes `"enter"` and `"backspace"`. Web and Mac computers also take `"tab"`, `"escape"`, `"delete"`, `"space"`, `"arrowup"`, `"arrowdown"`, `"arrowleft"`, `"arrowright"`, `"home"`, `"end"`, `"pageup"` and `"pagedown"`, and `modifiers`: up to four of `"ctrl"`, `"shift"`, `"alt"` and `"meta"`, held while the key is pressed. With modifiers a lowercase letter or digit works too. The shortcut key differs: select all with `press_key("a", modifiers=["meta"])` on a Mac computer, where `"meta"` is Command and `"alt"` is Option, and with `press_key("a", modifiers=["ctrl"])` on Web, where `"meta"` is not the shortcut key. Other keys and any modifiers raise `NOT_AVAILABLE_ON_PLATFORM` on iOS and Android | @@ -339,9 +339,10 @@ size = session.screen_size() # the screenshot's size: x is 0 to size.width - 1 | --- | --- | --- | --- | --- | | `tap(Point(x, y))`, `tap("description")`, `screen_size` | Yes | Yes | Yes | Yes | | `locate` | Yes | Yes | Yes | No, use `tap("description")`, which returns the point it clicked, or read the point off `screenshot()` | -| `double_tap`, `long_press`, `type`, `swipe`, `drag` | Yes | Yes | Yes | No | +| `type("description", text)`, the way to type | Yes | Yes | Yes | Yes: clicks the field, selects its text unless `clear=False`, then types | +| `double_tap`, `long_press`, `swipe`, `drag` | Yes | Yes | Yes | No | | `press_key(key, modifiers)` | Yes: `"enter"`, `"backspace"`, `"tab"`, `"escape"`, arrows and more, with modifiers | `"enter"` and `"backspace"` only | `"enter"` and `"backspace"` only | Yes: the Web keys and modifiers, where `"meta"` is Command | -| `type_focused(text, clear)` | Yes, types into the focused field | No, use `type(location, text)` | No, use `type(location, text)` | Yes, with `clear=False` | +| `type_focused(text, clear)` | Yes, types into the focused field; `ACTION_FAILED` (`no_focused_input`) when none has focus | No, use `type("description", text)` | No, use `type("description", text)` | Yes, with `clear=False` | | `back()` | Yes, browser history | No, tap the on-screen back control | Yes, the system back button | No | | `go_home()` | No, use `open_url` or `navigate` | Yes, the home screen | Yes, the home screen | No | | `open_url(url)` | Yes, loads an http(s) URL in the tab | Yes, a URL or deep link | Yes, a URL or deep link | No | @@ -568,7 +569,7 @@ Use an empty `dist/` before building; the package checker rejects stale or extra ## Troubleshooting -- **`NOT_AVAILABLE_ON_PLATFORM`:** computers do not support instruction/validation, your own model, or exact actions other than `tap`, `screen_size()`, `type_focused(text, clear=False)` and `press_key`; devices do not support commands, files, processes or recording metadata; iOS has no `back()`, Web has no `launch_app()` or `go_home()`, and iOS and Android have no `type_focused()` and no keys other than Enter and Backspace. +- **`NOT_AVAILABLE_ON_PLATFORM`:** computers do not support instruction/validation, your own model, or exact actions other than `tap`, `type`, `screen_size()`, `type_focused(text, clear=False)` and `press_key`; devices do not support commands, files, processes or recording metadata; iOS has no `back()`, Web has no `launch_app()` or `go_home()`, and iOS and Android have no `type_focused()` and no keys other than Enter and Backspace. - **`SESSION_PROFILE_FAILED`:** the session profile's script couldn't be sent, Revyl couldn't find it, or it ran and failed. `error.outcome` and `error.failure_reason` say which; see [Session profile errors](#session-profile-errors). - **`MODEL_KEY_MISSING`:** the provider's key variable named in the message is not set. Set it, or pass `CustomModel(id, base_url, api_key=...)`. - **`MODEL_ERROR`:** the model's endpoint refused the request or the model misbehaved. The message names the host, the HTTP status and the next step: a rejected key and the variable it came from, an unknown model, the path Verify added on a 404, a rate limit after retries, a text-only model, no tool support, a reply cut off at its output cap, or three turns without a tool call. diff --git a/python/pyproject.toml b/python/pyproject.toml index 79a700c..e4df0d4 100644 --- a/python/pyproject.toml +++ b/python/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "hatchling.build" [project] name = "revyl-verify" -version = "0.5.0" +version = "0.5.1" description = "Cloud browsers, mobile devices and computers from Python with Revyl" readme = "README.md" requires-python = ">=3.10" diff --git a/python/src/revyl_verify/__init__.py b/python/src/revyl_verify/__init__.py index 3c5df57..b16a550 100644 --- a/python/src/revyl_verify/__init__.py +++ b/python/src/revyl_verify/__init__.py @@ -69,7 +69,7 @@ seconds, ) -__version__ = "0.5.0" +__version__ = "0.5.1" __all__ = [ "AsyncSession", "CDPEndpoint", diff --git a/python/src/revyl_verify/_agent.py b/python/src/revyl_verify/_agent.py index 8abe09c..3e3cdd0 100644 --- a/python/src/revyl_verify/_agent.py +++ b/python/src/revyl_verify/_agent.py @@ -715,7 +715,8 @@ def _instruction_tools(platform: DevicePlatform, grounding: Grounding) -> list[M ), ModelTool( "type", - "Tap a text field and type into it. Clears the field first unless clear is false.", + "Tap a text field and type into it. Use this to type. Clears the field first unless " + "clear is false.", { "type": "object", "properties": { @@ -731,8 +732,9 @@ def _instruction_tools(platform: DevicePlatform, grounding: Grounding) -> list[M tools.append( ModelTool( "type_focused", - "Type into the field that already has focus, without tapping. Clears the field " - "first unless clear is false.", + "Type into the field that already has focus, without tapping. Nothing is typed " + "when no field has focus, so prefer type. Clears the field first unless clear is " + "false.", { "type": "object", "properties": {"text": {"type": "string"}, "clear": {"type": "boolean"}}, diff --git a/python/src/revyl_verify/_async.py b/python/src/revyl_verify/_async.py index 52a701a..cb24ea1 100644 --- a/python/src/revyl_verify/_async.py +++ b/python/src/revyl_verify/_async.py @@ -190,8 +190,8 @@ async def cdp(self) -> CDPEndpoint: async def report(self) -> dict[str, Json]: return await self._call(self._session.report) - async def recording(self) -> ComputerRecording | None: - return await self._call(self._session.recording) + async def recording(self, *, timeout: float = 900) -> ComputerRecording | None: + return await self._call(functools.partial(self._session.recording, timeout=timeout)) async def extend(self, timeout: int) -> None: await self._call(functools.partial(self._session.extend, timeout)) diff --git a/python/src/revyl_verify/_computer.py b/python/src/revyl_verify/_computer.py index 16e9c80..a80f6f6 100644 --- a/python/src/revyl_verify/_computer.py +++ b/python/src/revyl_verify/_computer.py @@ -116,7 +116,8 @@ } _SCREEN_CALLS = ( 'For the screen, use screenshot(), tap(Point(x, y)) or tap("description"), ' - "type_focused(text, clear=False) and press_key(); for commands, use exec()." + 'type("description", text), type_focused(text, clear=False) and press_key(); for ' + "commands, use exec()." ) _REFUSAL_NEXT_STEPS: dict[str, str] = { "AUTH_REJECTED": "Check that REVYL_API_KEY is a current key and that its owner has the " @@ -1096,18 +1097,38 @@ def _screen_not_ready(self) -> VerifyError: f"window. Try again later. See {self.viewer_url}", ) - def recording(self) -> ComputerRecording | None: - deadline = Deadline(30) - report = self._report(self._request("GET", "/report", None, deadline)) + def recording(self, *, timeout: float = 900) -> ComputerRecording | None: + """After close(), waits until Revyl has saved the computer's recording, usually seconds, + and returns it; None when none was saved within timeout seconds (default 15 minutes).""" + if ( + isinstance(timeout, bool) + or not isinstance(timeout, (int, float)) + or not 0 <= timeout <= 3600 + ): + raise VerifyError("INVALID_ARGUMENT", "recording() timeout is seconds from 0 to 3600.") + until = time.monotonic() + timeout + report = self._report(self._request("GET", "/report", None, Deadline(30))) if report["state"] not in _TERMINAL or report.get("release") != "confirmed": raise VerifyError( "SESSION_BUSY", - "The computer recording can be requested only after terminal state " - f"and confirmed release. See {self.viewer_url}", + "The computer is still running, so it has no recording yet. Call close() first, " + "then recording(), which waits until Revyl has saved the video. " + f"See {self.viewer_url}", ) - response = self._request("GET", "/recording", None, deadline) - if response.status == 404: - return None + waited = False + while True: + response = self._request("GET", "/recording", None, Deadline(30)) + if response.status != 404: + break + remaining = until - time.monotonic() + if remaining <= 0: + if waited: + self._log(f"no recording was saved within {round(timeout)} seconds") + return None + if not waited: + self._log("waiting for Revyl to save the recording") + waited = True + time.sleep(min(5, remaining)) raw = obj(response.json()) url = raw.get("url") if not isinstance(url, str) or re.search(r"[\x00-\x20\x7f]", url): @@ -1224,8 +1245,28 @@ def _tap_target(self, target: str) -> Point: ) return Point(x, y) - def type(self, at: Location, text: str, *, clear: bool = True, settle: bool = True) -> NoReturn: - self._unavailable("type") + def type(self, at: Location, text: str, *, clear: bool = True, settle: bool = True) -> Point: + """Clicks a field, selects its text unless clear is False, and types, so the text replaces + what was there. Returns the point clicked.""" + _check_settle(settle) + if not isinstance(text, str) or text_length(text) > 16_384: + raise VerifyError("INVALID_ARGUMENT", "type() takes text of at most 16384 characters.") + if not isinstance(clear, bool): + raise VerifyError("INVALID_ARGUMENT", "clear must be a boolean.") + control = _CONTROL_CHARACTER.search(text) + if control is not None: + raise VerifyError( + "INVALID_ARGUMENT", + "Nothing was typed: type() on a computer takes newline and tab but no other " + "control characters, and the text has one at index " + f"{text_length(text[: control.start()])}. Use press_key() for keys such as " + "'escape'.", + ) + point = self.tap(at) + if clear: + self.press_key("a", modifiers=["meta" if self.platform == "mac" else "ctrl"]) + self.type_focused(text, clear=False) + return point def type_focused(self, text: str, *, clear: bool = True, settle: bool = True) -> None: """Types into whatever has keyboard focus. Computers can't clear a field: pass diff --git a/python/src/revyl_verify/_login.py b/python/src/revyl_verify/_login.py index fb0d5be..d745ef1 100644 --- a/python/src/revyl_verify/_login.py +++ b/python/src/revyl_verify/_login.py @@ -179,7 +179,7 @@ def _call( ) -> dict[str, Json]: headers = { "Accept": "application/json", - "User-Agent": "revyl-verify/0.5.0 python", + "User-Agent": "revyl-verify/0.5.1 python", "X-Revyl-Client": "verify", } data = None diff --git a/python/src/revyl_verify/_session.py b/python/src/revyl_verify/_session.py index 9215478..4ba5cba 100644 --- a/python/src/revyl_verify/_session.py +++ b/python/src/revyl_verify/_session.py @@ -620,6 +620,15 @@ def _worker_error(self, method: str, response: Response) -> VerifyError: "step_output_not_available", ): code = "NOT_AVAILABLE_ON_PLATFORM" + elif error == "no_focused_input": + return VerifyError( + "ACTION_FAILED", + "Nothing was typed: no text field has focus (no_focused_input). Use " + 'type("the email field", text), which taps the field and types into it, or tap ' + f"the field first. See {self.viewer_url}", + reason="no_focused_input", + http_status=response.status, + ) elif screen_error in _WEB_TARGET_ERRORS: return VerifyError( "ACTION_FAILED", @@ -789,8 +798,8 @@ def type_focused(self, text: str, *, clear: bool = True, settle: bool = True) -> if self.platform != "web": raise VerifyError( "NOT_AVAILABLE_ON_PLATFORM", - "type_focused() is available only on web sessions; on iOS and Android, " - "use type(location, text), which taps the field first.", + "type_focused() isn't available on iOS and Android sessions. Use " + 'type("the email field", text), which taps the field and types into it.', ) if not isinstance(text, str) or text_length(text) > 16_384: raise VerifyError( @@ -1564,7 +1573,7 @@ def processes(self, *, timeout: float = 30) -> list[ComputerProcess]: def terminate(self, handle_id: str, *, timeout: float = 30) -> None: self._computer_only() - def recording(self) -> ComputerRecording | None: + def recording(self, *, timeout: float = 900) -> ComputerRecording | None: self._computer_only() def extend(self, timeout: int) -> None: diff --git a/python/src/revyl_verify/_transport.py b/python/src/revyl_verify/_transport.py index fc8c9ba..1a30294 100644 --- a/python/src/revyl_verify/_transport.py +++ b/python/src/revyl_verify/_transport.py @@ -61,6 +61,7 @@ "repository_unavailable", "lifetime_unsupported", "upgrade_required", + "no_focused_input", ] SessionProfileOutcome = Literal[ "succeeded", @@ -628,7 +629,7 @@ def _once( headers = { "Authorization": f"Bearer {self._token}", "Accept": "application/json", - "User-Agent": "revyl-verify/0.5.0 python", + "User-Agent": "revyl-verify/0.5.1 python", "X-Revyl-Client": "verify", } if worker: diff --git a/python/tests/test_computer.py b/python/tests/test_computer.py index acd2ebd..deb45a7 100644 --- a/python/tests/test_computer.py +++ b/python/tests/test_computer.py @@ -484,7 +484,7 @@ def test_recording_validation_and_unavailable(self) -> None: ) self.assert_code("API_ERROR", session.recording) self.api.recording = 404, {"error": "recording_unavailable"} - self.assertIsNone(session.recording()) + self.assertIsNone(session.recording(timeout=0)) self.api.recording = 404, {"error": "other"} self.assert_code("API_ERROR", session.recording) diff --git a/python/tests/test_release.py b/python/tests/test_release.py index d14eadb..aa32d73 100644 --- a/python/tests/test_release.py +++ b/python/tests/test_release.py @@ -31,7 +31,7 @@ def __init__(self, content: bytes | Exception) -> None: self.content = content def open(self, request: Request, *, timeout: int) -> Response: - assert request.full_url == "https://pypi.org/pypi/revyl-verify/0.5.0/json" + assert request.full_url == "https://pypi.org/pypi/revyl-verify/0.5.1/json" assert timeout == 30 if isinstance(self.content, Exception): raise self.content @@ -65,19 +65,19 @@ def test_registry_only_skips_exact_published_distribution(monkeypatch: pytest.Mo module, json.dumps( { - "info": {"name": "revyl-verify", "version": "0.5.0"}, + "info": {"name": "revyl-verify", "version": "0.5.1"}, "urls": [ { - "filename": "revyl_verify-0.5.0-py3-none-any.whl", + "filename": "revyl_verify-0.5.1-py3-none-any.whl", "digests": {"sha256": "a" * 64}, } ], } ).encode(), ) - assert module.published_version_exists("revyl-verify", "0.5.0") is True + assert module.published_version_exists("revyl-verify", "0.5.1") is True patch_registry(monkeypatch, module, HTTPError("", 404, "missing", Message(), None)) - assert module.published_version_exists("revyl-verify", "0.5.0") is False + assert module.published_version_exists("revyl-verify", "0.5.1") is False @pytest.mark.parametrize("status", [301, 302, 401, 403, 429, 500, 503]) @@ -85,7 +85,7 @@ def test_registry_http_errors_fail_closed(monkeypatch: pytest.MonkeyPatch, statu module = release_module() patch_registry(monkeypatch, module, HTTPError("", status, "failure", Message(), None)) with pytest.raises(RuntimeError, match=f"HTTP {status}"): - module.published_version_exists("revyl-verify", "0.5.0") + module.published_version_exists("revyl-verify", "0.5.1") @pytest.mark.parametrize( @@ -94,11 +94,11 @@ def test_registry_http_errors_fail_closed(monkeypatch: pytest.MonkeyPatch, statu b"not json", b"[]", b"{}", - b'{"info":{"name":"other","version":"0.5.0"},"urls":[{}]}', + b'{"info":{"name":"other","version":"0.5.1"},"urls":[{}]}', b'{"info":{"name":"revyl-verify","version":"0.0.1"},"urls":[{}]}', - b'{"info":{"name":"revyl-verify","version":"0.5.0"},"urls":[]}', - b'{"info":{"name":"revyl-verify","version":"0.5.0"},"urls":[{}]}', - b'{"info":{"name":"revyl-verify","version":"0.5.0"},"urls":["invalid"]}', + b'{"info":{"name":"revyl-verify","version":"0.5.1"},"urls":[]}', + b'{"info":{"name":"revyl-verify","version":"0.5.1"},"urls":[{}]}', + b'{"info":{"name":"revyl-verify","version":"0.5.1"},"urls":["invalid"]}', ], ) def test_registry_malformed_metadata_fails_closed( @@ -107,14 +107,14 @@ def test_registry_malformed_metadata_fails_closed( module = release_module() patch_registry(monkeypatch, module, content) with pytest.raises(ValueError): - module.published_version_exists("revyl-verify", "0.5.0") + module.published_version_exists("revyl-verify", "0.5.1") def test_registry_transport_errors_fail_closed(monkeypatch: pytest.MonkeyPatch) -> None: module = release_module() patch_registry(monkeypatch, module, URLError("network unavailable")) with pytest.raises(URLError): - module.published_version_exists("revyl-verify", "0.5.0") + module.published_version_exists("revyl-verify", "0.5.1") @pytest.mark.parametrize("enabled", [None, "", "false", "TRUE", "1"]) diff --git a/python/tests/wheel_smoke.py b/python/tests/wheel_smoke.py index 62b5baf..550d1bd 100644 --- a/python/tests/wheel_smoke.py +++ b/python/tests/wheel_smoke.py @@ -125,7 +125,7 @@ def respond(self) -> None: try: import revyl_verify - assert revyl_verify.__version__ == "0.5.0" + assert revyl_verify.__version__ == "0.5.1" assert callable(revyl_verify.attach) and callable(revyl_verify.async_attach) assert callable(revyl_verify.ComputerSession.open) assert callable(revyl_verify.Session.navigate) diff --git a/python/uv.lock b/python/uv.lock index 3280af8..6be9e09 100644 --- a/python/uv.lock +++ b/python/uv.lock @@ -1311,7 +1311,7 @@ wheels = [ [[package]] name = "revyl-verify" -version = "0.5.0" +version = "0.5.1" source = { editable = "." } dependencies = [ { name = "pillow", version = "12.3.0", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version < '3.11'" }, From 88af4e93f5670ae7d872e1c68e288d7d1878296e Mon Sep 17 00:00:00 2001 From: anamhira47 <7093246+anamhira47@users.noreply.github.com> Date: Wed, 25 Nov 2026 05:54:34 +0000 Subject: [PATCH 2/8] docs(python): keep the recording example within ruff's line length Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> --- python/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/README.md b/python/README.md index df437c9..21b3e21 100644 --- a/python/README.md +++ b/python/README.md @@ -104,7 +104,7 @@ with open(Target(platform="mac", start_timeout=600)) as session: processes = session.processes() session.screenshot(path="mac.png") -recording = session.recording() # after the with block closes the computer; waits until the video is saved +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). 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. From 57d4de2f0d569a9fc578641ff5be33259c3cd4ff Mon Sep 17 00:00:00 2001 From: anamhira47 <7093246+anamhira47@users.noreply.github.com> Date: Wed, 25 Nov 2026 05:57:27 +0000 Subject: [PATCH 3/8] docs: name an unambiguous field in the Mac type() examples Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> --- go/README.md | 2 +- packages/verify/docs/computers.md | 2 +- python/README.md | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go/README.md b/go/README.md index 49edf14..291dd71 100644 --- a/go/README.md +++ b/go/README.md @@ -659,7 +659,7 @@ time.Sleep(3 * time.Second) // let the window open if _, err := s.Screenshot(ctx, ".verify/mac.png"); err != nil { // open it and find the text return err } -if _, err := s.Type(ctx, verify.Element("the TextEdit document"), "First line\nSecond line"); err != nil { // clicks, selects all, types +if _, err := s.Type(ctx, verify.Element("the white text area of the TextEdit window"), "First line\nSecond line"); err != nil { // clicks, selects all, types return err } keep := false diff --git a/packages/verify/docs/computers.md b/packages/verify/docs/computers.md index f2f0599..d518767 100644 --- a/packages/verify/docs/computers.md +++ b/packages/verify/docs/computers.md @@ -61,7 +61,7 @@ try { await computer.exec(['open', '-a', 'TextEdit', 'notes.txt']); // exec runs in the workspace await new Promise((resolve) => setTimeout(resolve, 3_000)); // let the window open await computer.screenshot({ path: '.verify/mac.png' }); // open it and find the text - await computer.type({ target: 'the TextEdit document' }, 'First line\nSecond line'); // clicks, selects all, types + await computer.type({ target: 'the white text area of the TextEdit window' }, 'First line\nSecond line'); // clicks, selects all, types; check the point it returns await computer.typeFocused('\nThird line', { clear: false }); // types where the cursor already is await computer.screenshot({ path: '.verify/mac-after.png' }); } finally { diff --git a/python/README.md b/python/README.md index 21b3e21..d22d5f1 100644 --- a/python/README.md +++ b/python/README.md @@ -121,7 +121,7 @@ with open(Target(platform="mac", start_timeout=600)) as computer: computer.exec(["open", "-a", "TextEdit", "notes.txt"]) # exec runs in the workspace time.sleep(3) # let the window open computer.screenshot(path=".verify/mac.png") # open it and find the text - computer.type("the TextEdit document", "First line\nSecond line") # clicks, selects all, types + computer.type("the white text area of the TextEdit window", "First line\nSecond line") # clicks, selects all, types computer.type_focused("\nThird line", clear=False) # types where the cursor already is computer.tap(Point(400, 300)) # or click a point as you read it ``` From a2dc219055a25c2bac99b0e7f8040d0845ad3fc9 Mon Sep 17 00:00:00 2001 From: anamhira47 <7093246+anamhira47@users.noreply.github.com> Date: Wed, 25 Nov 2026 05:57:47 +0000 Subject: [PATCH 4/8] docs(python): keep the Mac type() example ruff-formatted Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> --- python/README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/python/README.md b/python/README.md index d22d5f1..e730ca2 100644 --- a/python/README.md +++ b/python/README.md @@ -121,7 +121,8 @@ with open(Target(platform="mac", start_timeout=600)) as computer: computer.exec(["open", "-a", "TextEdit", "notes.txt"]) # exec runs in the workspace time.sleep(3) # let the window open computer.screenshot(path=".verify/mac.png") # open it and find the text - computer.type("the white text area of the TextEdit window", "First line\nSecond line") # clicks, selects all, types + document = "the white text area of the TextEdit window" + computer.type(document, "First line\nSecond line") # clicks, selects all, types computer.type_focused("\nThird line", clear=False) # types where the cursor already is computer.tap(Point(400, 300)) # or click a point as you read it ``` From 91dbd055eb412c622a726b975418fc9636639972 Mon Sep 17 00:00:00 2001 From: anamhira47 <7093246+anamhira47@users.noreply.github.com> Date: Wed, 25 Nov 2026 06:13:36 +0000 Subject: [PATCH 5/8] fix: clear a computer field for empty type() text and keep recording() polls inside their wait Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> --- go/computer.go | 26 ++++++++++++++++++++----- packages/verify/src/computer-session.ts | 7 +++++-- python/src/revyl_verify/_computer.py | 5 ++++- 3 files changed, 30 insertions(+), 8 deletions(-) diff --git a/go/computer.go b/go/computer.go index 6bea023..288b13e 100644 --- a/go/computer.go +++ b/go/computer.go @@ -358,6 +358,11 @@ func (s *Session) computerType(ctx context.Context, at Location, text string, cl if err := s.computerPressKey(ctx, Key("a"), []KeyOptions{{Modifiers: []KeyModifier{selectAll}}}); err != nil { return Point{}, err } + if text == "" { + if err := s.computerPressKey(ctx, KeyBackspace, nil); err != nil { + return Point{}, err + } + } } keep := false return point, s.computerTypeFocused(ctx, text, []TypeOptions{{Clear: &keep}}) @@ -1195,12 +1200,12 @@ func (s *Session) Recording(ctx context.Context) (*ComputerRecording, error) { if ctxDeadline, ok := ctx.Deadline(); ok && ctxDeadline.Before(deadline) { deadline = ctxDeadline } - get := func(suffix string) (response, error) { - requestCtx, cancel := context.WithTimeout(ctx, 30*time.Second) + get := func(suffix string, timeout time.Duration) (response, error) { + requestCtx, cancel := context.WithTimeout(ctx, timeout) defer cancel() return s.computerRequest(requestCtx, "GET", suffix, nil) } - r, err := get("/report") + r, err := get("/report", 30*time.Second) if err != nil { return nil, err } @@ -1212,13 +1217,20 @@ func (s *Session) Recording(ctx context.Context) (*ComputerRecording, error) { return nil, failure(ErrSessionBusy, "The computer is still running, so it has no recording yet. Call Close first, then Recording, which waits until Revyl has saved the video. See "+s.viewer) } for waited := false; ; waited = true { - if r, err = get("/recording"); err != nil { + timeout := 30 * time.Second + if waited { + timeout = min(timeout, max(time.Second, time.Until(deadline))) + } + if r, err = get("/recording", timeout); err != nil { + if waited && errors.Is(ctx.Err(), context.DeadlineExceeded) { + return nil, nil + } return nil, err } if r.status != 404 { break } - remaining := time.Until(deadline) - time.Second + remaining := time.Until(deadline) if remaining <= 0 { if waited { s.logLine("no recording was saved in time") @@ -1232,6 +1244,10 @@ func (s *Session) Recording(ctx context.Context) (*ComputerRecording, error) { select { case <-ctx.Done(): timer.Stop() + if errors.Is(ctx.Err(), context.DeadlineExceeded) { + s.logLine("no recording was saved in time") + return nil, nil + } return nil, ctx.Err() case <-timer.C: } diff --git a/packages/verify/src/computer-session.ts b/packages/verify/src/computer-session.ts index 264d6e9..f9cf08a 100644 --- a/packages/verify/src/computer-session.ts +++ b/packages/verify/src/computer-session.ts @@ -204,7 +204,10 @@ export class ComputerSession implements Session { const control = COMPUTER_CONTROL_CHARACTER.exec(text); if (control) throw new VerifyError('INVALID_ARGUMENT', `Nothing was typed: type() on a computer takes newline and tab but no other control characters, and the text has one at index ${control.index}. Use pressKey() for keys such as 'escape'.`); const point = await this.tap(at); - if (options.clear !== false) await this.pressKey('a', { modifiers: [this.platform === 'mac' ? 'meta' : 'ctrl'] }); + if (options.clear !== false) { + await this.pressKey('a', { modifiers: [this.platform === 'mac' ? 'meta' : 'ctrl'] }); + if (!text) await this.pressKey('backspace'); + } await this.typeFocused(text, { clear: false }); return point; } @@ -316,7 +319,7 @@ export class ComputerSession implements Session { } let response: RawResponse; for (let waited = false; ; waited = true) { - response = await this.request('GET', '/recording', undefined, AbortSignal.timeout(30_000)); + response = await this.request('GET', '/recording', undefined, AbortSignal.timeout(waited ? Math.min(30_000, Math.max(1_000, deadline - Date.now())) : 30_000)); if (response.status !== 404 || responseErrorCode(response) !== 'recording_unavailable') break; const remainingMs = deadline - Date.now(); if (remainingMs <= 0) { diff --git a/python/src/revyl_verify/_computer.py b/python/src/revyl_verify/_computer.py index a80f6f6..d0706e9 100644 --- a/python/src/revyl_verify/_computer.py +++ b/python/src/revyl_verify/_computer.py @@ -1117,7 +1117,8 @@ def recording(self, *, timeout: float = 900) -> ComputerRecording | None: ) waited = False while True: - response = self._request("GET", "/recording", None, Deadline(30)) + budget = min(30, max(1, until - time.monotonic())) if waited else 30 + response = self._request("GET", "/recording", None, Deadline(budget)) if response.status != 404: break remaining = until - time.monotonic() @@ -1265,6 +1266,8 @@ def type(self, at: Location, text: str, *, clear: bool = True, settle: bool = Tr point = self.tap(at) if clear: self.press_key("a", modifiers=["meta" if self.platform == "mac" else "ctrl"]) + if not text: + self.press_key("backspace") self.type_focused(text, clear=False) return point From 3bc5584e7fd6fd85da3a80c84f6c150f37d2b822 Mon Sep 17 00:00:00 2001 From: anamhira47 <7093246+anamhira47@users.noreply.github.com> Date: Wed, 25 Nov 2026 21:23:12 +0000 Subject: [PATCH 6/8] chore: date the 0.7.1, Go 0.6.1 and Python 0.5.1 changelog entries Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> --- CHANGELOG.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 94bec72..31e789b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,6 @@ # Changelog -## 0.7.1 (unreleased) +## 0.7.1 (2026-11-25) - Web: `typeFocused()` with no text field focused throws `ACTION_FAILED` with the new reason `no_focused_input` and the message `Nothing was typed: no text field has focus (no_focused_input). Use type({ target: 'the email field' }, text), which taps the field and types into it, or tap the field first.` Revyl answers this with HTTP 409, which 0.7.0 reported as `SESSION_BUSY`, so a script or agent gave up on a call it could fix. Your own model's loop now feeds the message back to the model instead of ending the step, because `ACTION_FAILED` doesn't abort it. A session that really is busy, such as a second step while one runs, still throws `SESSION_BUSY`. - Typing has one rule on every platform: `type({ target }, text)`. Mac computers now take `type(at, text, { clear })`: it clicks the field (a description or a point), selects its text with Command+A (Ctrl+A on Linux) unless `clear` is `false`, types, and resolves with the point clicked. It refuses control characters other than `\n` and `\t` before clicking. `typeFocused()` on iOS and Android still throws `NOT_AVAILABLE_ON_PLATFORM` before anything is sent, now naming `type({ target: 'the email field' }, text)`. The README, the API page and the web, mobile, computers, errors and agents pages teach `type({ target }, text)` as the way to type everywhere, and your own model's tool list describes `type` as the way to type and `type_focused` as needing a focused field. @@ -8,7 +8,7 @@ - Docs: session profiles run on Revyl's production backend, so the API page and the Python and Go READMEs no longer say a profile name is refused there (#66). - Computers: a Mac computer create that Revyl refuses with `computer_not_enabled` and `unlocks_with_card: true`, as it does for a Free-plan organization, throws `NOT_AVAILABLE_ON_PLATFORM` with the new reason `upgrade_required` instead of no reason and the generic support guidance. The message reads `Mac computers come with Pro, so Revyl refused this computer (computer_not_enabled, upgrade_required).`, then Revyl's upgrade offer and billing link (`: `) when Revyl sends one with an HTTPS link and a single-line message of at most 160 characters, and otherwise `Add a card in Revyl's billing settings to unlock them.` `open()` adds the session link as before; `openPersistent()` refuses the same way. The code is unchanged, the create is still not retried and no stop is sent, and any other `computer_not_enabled` refusal keeps its current message. -## Go 0.6.1 (unreleased) +## Go 0.6.1 (2026-11-25) To be published as the `go/v0.6.1` tag. @@ -18,7 +18,7 @@ To be published as the `go/v0.6.1` tag. - A Mac computer create refused with `computer_not_enabled` and `unlocks_with_card: true` returns `ErrNotAvailableOnPlatform` with `Reason` `ReasonUpgradeRequired` on `Open` and `OpenPersistent`, as in TypeScript 0.7.1. - `verify.Version` and the `User-Agent` report 0.6.1. -## Python 0.5.1 (unreleased) +## Python 0.5.1 (2026-11-25) - Web: `type_focused()` with no text field focused raises `ACTION_FAILED` with `reason="no_focused_input"` and a message naming `type("the email field", text)`, as in TypeScript 0.7.1, instead of `SESSION_BUSY`. A session that really is busy still raises `SESSION_BUSY`. - `type(at, text, clear=True)` works on Mac computers, as in TypeScript 0.7.1. `type_focused()` on iOS and Android names `type("the email field", text)`. From 98a01937eb19fe7330359dc73936c3e2a90257d8 Mon Sep 17 00:00:00 2001 From: anamhira47 <7093246+anamhira47@users.noreply.github.com> Date: Wed, 25 Nov 2026 21:27:56 +0000 Subject: [PATCH 7/8] fix: let a recording() check finish so a late answer is returned, not a timeout Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> --- go/computer.go | 12 ++++-------- packages/verify/src/computer-session.ts | 4 ++-- python/src/revyl_verify/_computer.py | 6 +++--- 3 files changed, 9 insertions(+), 13 deletions(-) diff --git a/go/computer.go b/go/computer.go index 288b13e..3faff41 100644 --- a/go/computer.go +++ b/go/computer.go @@ -1200,12 +1200,12 @@ func (s *Session) Recording(ctx context.Context) (*ComputerRecording, error) { if ctxDeadline, ok := ctx.Deadline(); ok && ctxDeadline.Before(deadline) { deadline = ctxDeadline } - get := func(suffix string, timeout time.Duration) (response, error) { - requestCtx, cancel := context.WithTimeout(ctx, timeout) + get := func(suffix string) (response, error) { + requestCtx, cancel := context.WithTimeout(ctx, 30*time.Second) defer cancel() return s.computerRequest(requestCtx, "GET", suffix, nil) } - r, err := get("/report", 30*time.Second) + r, err := get("/report") if err != nil { return nil, err } @@ -1217,11 +1217,7 @@ func (s *Session) Recording(ctx context.Context) (*ComputerRecording, error) { return nil, failure(ErrSessionBusy, "The computer is still running, so it has no recording yet. Call Close first, then Recording, which waits until Revyl has saved the video. See "+s.viewer) } for waited := false; ; waited = true { - timeout := 30 * time.Second - if waited { - timeout = min(timeout, max(time.Second, time.Until(deadline))) - } - if r, err = get("/recording", timeout); err != nil { + if r, err = get("/recording"); err != nil { if waited && errors.Is(ctx.Err(), context.DeadlineExceeded) { return nil, nil } diff --git a/packages/verify/src/computer-session.ts b/packages/verify/src/computer-session.ts index f9cf08a..d18cd69 100644 --- a/packages/verify/src/computer-session.ts +++ b/packages/verify/src/computer-session.ts @@ -308,7 +308,7 @@ export class ComputerSession implements Session { this.log(`lifetime extended to ${report.expires_at}`); } - /** After close(), waits until Revyl has saved the computer's recording, usually seconds, and returns it; null when none was saved within timeoutMs (default 15 minutes). */ + /** After close(), waits until Revyl has saved the computer's recording, usually seconds, and returns it; null when none was saved within timeoutMs (default 15 minutes). Each check can take up to 30 more seconds, so a late answer isn't lost. */ async recording(options: { timeoutMs?: number } = {}): Promise { const timeoutMs = options.timeoutMs ?? RECORDING_WAIT_MS; if (!Number.isInteger(timeoutMs) || timeoutMs < 0 || timeoutMs > 3_600_000) throw new VerifyError('INVALID_ARGUMENT', 'recording() timeoutMs is whole milliseconds from 0 to 3600000.'); @@ -319,7 +319,7 @@ export class ComputerSession implements Session { } let response: RawResponse; for (let waited = false; ; waited = true) { - response = await this.request('GET', '/recording', undefined, AbortSignal.timeout(waited ? Math.min(30_000, Math.max(1_000, deadline - Date.now())) : 30_000)); + response = await this.request('GET', '/recording', undefined, AbortSignal.timeout(30_000)); if (response.status !== 404 || responseErrorCode(response) !== 'recording_unavailable') break; const remainingMs = deadline - Date.now(); if (remainingMs <= 0) { diff --git a/python/src/revyl_verify/_computer.py b/python/src/revyl_verify/_computer.py index d0706e9..768f3b7 100644 --- a/python/src/revyl_verify/_computer.py +++ b/python/src/revyl_verify/_computer.py @@ -1099,7 +1099,8 @@ def _screen_not_ready(self) -> VerifyError: def recording(self, *, timeout: float = 900) -> ComputerRecording | None: """After close(), waits until Revyl has saved the computer's recording, usually seconds, - and returns it; None when none was saved within timeout seconds (default 15 minutes).""" + and returns it; None when none was saved within timeout seconds (default 15 minutes). + Each check can take up to 30 more seconds, so a late answer isn't lost.""" if ( isinstance(timeout, bool) or not isinstance(timeout, (int, float)) @@ -1117,8 +1118,7 @@ def recording(self, *, timeout: float = 900) -> ComputerRecording | None: ) waited = False while True: - budget = min(30, max(1, until - time.monotonic())) if waited else 30 - response = self._request("GET", "/recording", None, Deadline(budget)) + response = self._request("GET", "/recording", None, Deadline(30)) if response.status != 404: break remaining = until - time.monotonic() From 5294204e12160ac7471052f3bb29d196d97bfc4c Mon Sep 17 00:00:00 2001 From: anamhira47 <7093246+anamhira47@users.noreply.github.com> Date: Wed, 25 Nov 2026 21:29:51 +0000 Subject: [PATCH 8/8] docs: say a recording() check under way at the timeout can finish Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> --- README.md | 2 +- packages/verify/docs/api.md | 2 +- packages/verify/docs/computers.md | 2 +- python/README.md | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 0f5d2b6..f727022 100644 --- a/README.md +++ b/README.md @@ -119,7 +119,7 @@ Since TypeScript (`@revyl/verify`) 0.4.0, Python (`revyl-verify`) 0.2.0 and Go v A call a platform doesn't support throws `NOT_AVAILABLE_ON_PLATFORM`, and its message names the alternative. -Web is available to every organization. Mac computers are available to organizations on a current paid Revyl plan and have a server-bounded lifetime; see [computers](packages/verify/docs/computers.md). To get a Mac computer's screen recording, call `await computer.close()` and then `await computer.recording()` on the same object, in the same process: it waits until Revyl has saved the video, usually a few seconds, and returns `{ url, durationSeconds?, startedAt? }`, or `null` if none was saved within `timeoutMs` (15 minutes by default). `attach()` can't reopen a closed computer, so fetch the recording before your script exits. +Web is available to every organization. Mac computers are available to organizations on a current paid Revyl plan and have a server-bounded lifetime; see [computers](packages/verify/docs/computers.md). To get a Mac computer's screen recording, call `await computer.close()` and then `await computer.recording()` on the same object, in the same process: it waits until Revyl has saved the video, usually a few seconds, and returns `{ url, durationSeconds?, startedAt? }`, or `null` if none was saved within `timeoutMs` (15 minutes by default; a check under way at that point can take up to 30 seconds more). `attach()` can't reopen a closed computer, so fetch the recording before your script exits. ## Documentation diff --git a/packages/verify/docs/api.md b/packages/verify/docs/api.md index 1896f2d..81e4847 100644 --- a/packages/verify/docs/api.md +++ b/packages/verify/docs/api.md @@ -373,7 +373,7 @@ const recording = await computer.recording(); // waits until Revyl has saved t console.log(recording?.url); ``` -It reads the report and requires terminal state plus confirmed release; on a computer that is still running it throws `SESSION_BUSY` saying to call `close()` first. Revyl saves the video a few seconds after release, so `recording()` asks every 5 seconds until it is saved and returns `{ url: string, durationSeconds?: number, startedAt?: Date }`. It returns `null` only when none was saved within `timeoutMs`: 900000 (15 minutes) by default, whole milliseconds from 0 to 3600000, where 0 asks once without waiting. `attach()` can't reopen a closed computer, so a later process can't fetch it with Verify; the recording stays in the session at `viewerUrl`. Nullable optional wire fields are omitted. It does not download or fetch the URL. Keep the signed HTTPS URL and its query private. Request fresh metadata when the URL expires. The normal report has no recording URL. Devices reject this call locally with `NOT_AVAILABLE_ON_PLATFORM`. +It reads the report and requires terminal state plus confirmed release; on a computer that is still running it throws `SESSION_BUSY` saying to call `close()` first. Revyl saves the video a few seconds after release, so `recording()` asks every 5 seconds until it is saved and returns `{ url: string, durationSeconds?: number, startedAt?: Date }`. It returns `null` only when none was saved within `timeoutMs`: 900000 (15 minutes) by default, whole milliseconds from 0 to 3600000, where 0 asks once without waiting. A check already under way when `timeoutMs` runs out can take up to 30 seconds more, so its answer isn't lost. `attach()` can't reopen a closed computer, so a later process can't fetch it with Verify; the recording stays in the session at `viewerUrl`. Nullable optional wire fields are omitted. It does not download or fetch the URL. Keep the signed HTTPS URL and its query private. Request fresh metadata when the URL expires. The normal report has no recording URL. Devices reject this call locally with `NOT_AVAILABLE_ON_PLATFORM`. ## Other session properties diff --git a/packages/verify/docs/computers.md b/packages/verify/docs/computers.md index d518767..89d053d 100644 --- a/packages/verify/docs/computers.md +++ b/packages/verify/docs/computers.md @@ -126,7 +126,7 @@ await computer.close(); const recording = await computer.recording(); // { url, durationSeconds?, startedAt? } or null ``` -Revyl saves the video a few seconds after the computer is released, so `recording()` waits: it asks every 5 seconds until the video is saved, for up to `timeoutMs` (`recording({ timeoutMs })`, 900000, 15 minutes, by default; 0 asks once). It returns `null` only when none was saved in that time. Since 0.7.1; earlier versions returned `null` at once while the video was still uploading. On a computer that is still running it throws `SESSION_BUSY` saying to call `close()` first. `attach()` can't reopen a closed computer, so get the recording before your script exits; after that it is only in the session at `viewerUrl`. `durationSeconds` is a finite nonnegative number; `startedAt` is a `Date`. Missing or nullable optional fields are omitted. Verify doesn't download the video. +Revyl saves the video a few seconds after the computer is released, so `recording()` waits: it asks every 5 seconds until the video is saved, for up to `timeoutMs` (`recording({ timeoutMs })`, 900000, 15 minutes, by default; 0 asks once). It returns `null` only when none was saved in that time. A check already under way when the time runs out can take up to 30 seconds more, so its answer isn't lost. Since 0.7.1; earlier versions returned `null` at once while the video was still uploading. On a computer that is still running it throws `SESSION_BUSY` saying to call `close()` first. `attach()` can't reopen a closed computer, so get the recording before your script exits; after that it is only in the session at `viewerUrl`. `durationSeconds` is a finite nonnegative number; `startedAt` is a `Date`. Missing or nullable optional fields are omitted. Verify doesn't download the video. The HTTPS URL is signed and short-lived. Keep it private, including its query string; do not log or publish it. Call `recording()` again when a fresh URL is needed. The report carries no recording URL; `viewerUrl` remains a Revyl UI link, not a download URL. Web/mobile sessions reject `recording()` locally with `NOT_AVAILABLE_ON_PLATFORM`. diff --git a/python/README.md b/python/README.md index e730ca2..f9ef84d 100644 --- a/python/README.md +++ b/python/README.md @@ -107,7 +107,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). 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 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. Since 0.4.0, a script can click, type and press keys on the computer's screen at points it reads off `screenshot()`: