Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## Unreleased

- 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 (`<offer message>: <https 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`.

## 0.7.0 (2026-11-23)

- Web sessions: `cdp()` (TypeScript, Python, `AsyncSession`) and `CDP(ctx)` (Go) return a single-use Chrome DevTools Protocol endpoint, `{ url, expiresAt }` / `CDPEndpoint(url, expires_at)` / `CDPEndpoint{URL, ExpiresAt}`, valid for 60 seconds, so Playwright (`connectOverCDP`), Puppeteer or chromedp can attach to the session's browser while `instruction()` and `validation()` keep working. It posts `device-proxy/{run}/cdp`. iOS, Android and computers throw `NOT_AVAILABLE_ON_PLATFORM` before any request, a closed session `SESSION_ENDED`, and a backend without the route `NOT_AVAILABLE_ON_PLATFORM`. The endpoint's url is left out of `console.log`, `repr()` and `fmt` output. The API page and the Python and Go READMEs list the rules (one connection at a time, the session's own page, `browser.close()` only disconnects, http(s) navigation only, no downloads, a fixed window size, a 24 MB reply limit), with runnable Playwright and chromedp examples in `examples/web-cdp`, `python/examples/cdp_playwright.py` and `go/examples/cdp`.
Expand Down
4 changes: 2 additions & 2 deletions go/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ Run with `go test -v -timeout 6m`. `t.Fatal` runs deferred cleanup. The URL and

- **Web:** `Target{Platform: verify.Web, AppID: "…", URL: "https://…"}` registers a deployed HTTPS URL as a web build. Alternatively supply `BuildID`, or omit URL and build ID to select the latest web build on `Branch` (the app's default branch if omitted). `Viewport` accepts `Width`, `Height`, and optional `DeviceScaleFactor`; `SignIn` accepts `Path`, `Secret` (the stored secret's name, never its value), and optional `Persona`.
- **iOS and Android:** set `Platform` to `verify.IOS` or `verify.Android` and exactly one of `AppID`, `BuildID`, `ArtifactURL` (HTTPS), or `BundleID` (an app already installed). `DeviceModel` and `OSVersion` are optional and written as Revyl names them, such as `DeviceModel: "iPhone 16", OSVersion: "iOS 18.5"` or `DeviceModel: "Pixel 7", OSVersion: "Android 14"`. A value Revyl doesn't offer returns `ErrInvalidArgument` listing the values it accepts, and no session starts. An `AppID` or `BuildID` Revyl can't find returns `ErrInvalidArgument` naming what wasn't found and how to fix it, and no session starts. A `BundleID` that can't be launched returns `ErrSessionStartFailed` naming the bundle ID, with the session link. `URL`, `Branch`, `Viewport`, and `SignIn` are web-only.
- **Mac computers:** `Target{Platform: verify.Mac}` creates a workspace; only `StartTimeout` is accepted alongside the platform. Mac computers are available to organizations on a current paid Revyl plan. A 429 `ErrComputerLimit` means queued work or a concurrency limit; Verify does not guess which cause applies or retry creation. See [computer availability](https://github.com/RevylAI/verify/blob/main/packages/verify/docs/computers.md#availability-and-errors).
- **Mac computers:** `Target{Platform: verify.Mac}` creates a workspace; only `StartTimeout` is accepted alongside the platform. Mac computers are available to organizations on a current paid Revyl plan. When Revyl says Pro would unlock Macs for a Free-plan organization (`computer_not_enabled` with `unlocks_with_card: true`), `Open` and `OpenPersistent` return `ErrNotAvailableOnPlatform` with `Reason` `ReasonUpgradeRequired`, and the message gives Revyl's upgrade offer and its HTTPS billing link, or says to add a card in Revyl's billing settings when Revyl sends no offer. A 429 `ErrComputerLimit` means queued work or a concurrency limit; Verify does not guess which cause applies or retry creation. See [computer availability](https://github.com/RevylAI/verify/blob/main/packages/verify/docs/computers.md#availability-and-errors).
- `Target.StartTimeout` bounds startup (default 10 minutes); on web/mobile, `IdleTimeoutSeconds` sets the session's idle timeout (default 600 seconds). All methods also honor the caller's context.
- `Open` takes at most one `OpenOptions` value, plus `WithModel`, `WithCustomModel` or `WithAgent` to run steps on your own model; `Instruction` and `Validation` take the same options for one step. `OpenOptions{StepTimeout: 3*time.Minute}` changes the default step timeout. Per-call `StepOptions{Timeout: time.Minute}` and `ValidationOptions{Timeout: time.Minute, Soft: true}` override it. Run one step at a time per session.
- `OpenOptions{Profile: "signed-in"}` runs a session profile from your project's `.revyl/config.yaml` before `Open` returns; `Profile: "none"` runs no profile. Left empty, the project's `session.default_profile` runs when it sets one. Web, iOS, Android and Mac computers. See [Session profiles](#session-profiles).
Expand Down Expand Up @@ -670,7 +670,7 @@ Errors support `errors.Is(err, verify.ErrTimeout)` and `errors.As(err, &sdkError

`ErrEdgeBlocked` (`EDGE_BLOCKED`) identifies HTTP 403 with a `text/html` content type and nonempty `cf-ray`, unless the body is syntactically valid JSON. HTML branding is not required; `cf-ray` alone is not enough. Other responses retain their existing mapping, including JSON 401/403 authentication errors. Edge-block errors expose `HTTPStatus` but no body or ray ID. Check network access or contact support; Verify does not retry blocked requests.

`Error.HTTPStatus` exposes the HTTP status when a server response caused the error (zero for local failures), and `Error.Reason` is an optional `RefusalReason` drawn only from known service refusal codes. Constants such as `ReasonComputerAtCapacity`, `ReasonComputerCannotHostPlatform`, and `ReasonWebRuntimeUnavailable` let callers distinguish capacity, compatibility, and runtime refusals without parsing messages. Unknown server content is never copied into `Reason`. Existing non-hosted codes remain unchanged, including `ErrAPI` for a web 409, `ErrComputerLimit` for computer admission limits, and `ErrNotAvailableOnPlatform` for computer runtime unavailability.
`Error.HTTPStatus` exposes the HTTP status when a server response caused the error (zero for local failures), and `Error.Reason` is an optional `RefusalReason` drawn only from known service refusal codes. Constants such as `ReasonComputerAtCapacity`, `ReasonComputerCannotHostPlatform`, `ReasonWebRuntimeUnavailable`, and `ReasonUpgradeRequired` (a Mac computer refused until the organization upgrades to Pro) let callers distinguish capacity, compatibility, and runtime refusals without parsing messages. Unknown server content is never copied into `Reason`. Existing non-hosted codes remain unchanged, including `ErrAPI` for a web 409, `ErrComputerLimit` for computer admission limits, and `ErrNotAvailableOnPlatform` for computer runtime unavailability.

Credentials resolve from `REVYL_API_KEY`, then `~/.revyl/credentials.json`. A usable CLI login marked `local_auth_override` takes precedence over the environment key, matching the TypeScript SDK and Revyl CLI. Expired access tokens fall back to a stored API key. Never put keys, tokens, or private session content in source, fixtures, or logs.

Expand Down
31 changes: 31 additions & 0 deletions go/computer.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
"net/url"
"os"
"path/filepath"
"regexp"
"slices"
"strconv"
"strings"
Expand All @@ -24,6 +25,31 @@ import (

const computerAvailability = "Mac computers need a current paid Revyl plan, and Linux computers are not generally available. Ask support@revyl.ai about access."

const macUpgradeRefusal = "Mac computers come with Pro, so Revyl refused this computer (computer_not_enabled, upgrade_required)."

var (
offerMessagePattern = regexp.MustCompile(`^[^\x00-\x1f\x7f\x{85}\x{2028}\x{2029}]{1,160}$`)
billingURLPattern = regexp.MustCompile(`^https://[!-~]+$`)
)

func macUpgradeMessage(r response) string {
var body struct {
UnlocksWithCard bool `json:"unlocks_with_card"`
Offer json.RawMessage `json:"offer"`
}
if json.Unmarshal(r.body, &body) != nil || !body.UnlocksWithCard {
return ""
}
var offer struct {
Message string `json:"message"`
BillingURL string `json:"billing_url"`
}
if json.Unmarshal(body.Offer, &offer) == nil && strings.TrimSpace(offer.Message) != "" && offerMessagePattern.MatchString(offer.Message) && billingURLPattern.MatchString(offer.BillingURL) {
return macUpgradeRefusal + " " + offer.Message + ": " + offer.BillingURL
}
return macUpgradeRefusal + " Add a card in Revyl's billing settings to unlock them."
}

var computerRefusalNextSteps = map[Code]string{
ErrAuthRejected: "Check that REVYL_API_KEY is a current key and that its owner has the Member role or above in this computer's organization.",
ErrSessionEnded: "This computer has stopped; start a new computer to continue.",
Expand Down Expand Up @@ -510,6 +536,11 @@ func (s *Session) computerRequestTimeout(ctx context.Context, method, suffix str
if suffix == "/screen/screenshot" && ((detail == "screen_unavailable" && (r.status == 409 || r.status == 503)) || (detail == "screen_starting" && r.status == 409)) {
return r, nil
}
if detail == "computer_not_enabled" {
if upgrade := macUpgradeMessage(r); upgrade != "" {
return r, &Error{Code: ErrNotAvailableOnPlatform, Reason: ReasonUpgradeRequired, HTTPStatus: r.status, Message: upgrade + " See " + s.viewer}
}
}
if detail == "computer_not_enabled" || (r.status == 503 && detail == "runtime_unavailable") {
return r, responseFailure(r, ErrNotAvailableOnPlatform, fmt.Sprintf("Revyl refused the computer request (%s). %s See %s", detail, computerAvailability, s.viewer))
}
Expand Down
1 change: 1 addition & 0 deletions go/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ const (
ReasonProjectNotFound RefusalReason = "project_not_found"
ReasonRepositoryUnavailable RefusalReason = "repository_unavailable"
ReasonLifetimeUnsupported RefusalReason = "lifetime_unsupported"
ReasonUpgradeRequired RefusalReason = "upgrade_required"
)

func (c Code) Error() string { return string(c) }
Expand Down
5 changes: 5 additions & 0 deletions go/persistent.go
Original file line number Diff line number Diff line change
Expand Up @@ -673,6 +673,11 @@ func persistentCall(ctx context.Context, c *client, method, path string, body an
if blocked := responseFailure(r, ErrAPI, ""); errors.Is(blocked, ErrEdgeBlocked) {
return r, blocked
}
if detail == "computer_not_enabled" {
if upgrade := macUpgradeMessage(r); upgrade != "" {
return r, &Error{Code: ErrNotAvailableOnPlatform, Reason: ReasonUpgradeRequired, HTTPStatus: r.status, Message: upgrade}
}
}
if known, ok := persistentRefusals[detail]; ok {
var reason RefusalReason
if detail == string(ReasonPersistentComputersNotEnabled) {
Expand Down
2 changes: 1 addition & 1 deletion packages/verify/docs/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { attach, open, defineConfig, VerifyError, isVerifyError } from '@revyl/v

Starts a Revyl cloud browser, device, or Mac computer. Mobile first-screen readiness is [best-effort](mobile.md#steps), not a foreground/rendered-readiness guarantee. Computer starts retain a 10-minute default timeout; an unclaimed start may fail after 120 seconds with no-host context.

Mac computers are available to organizations on a current paid Revyl plan.
Mac computers are available to organizations on a current paid Revyl plan. On a Free-plan organization, starting one throws `NOT_AVAILABLE_ON_PLATFORM` with `reason: 'upgrade_required'` and a message with Revyl's billing link to upgrade to Pro; see [computer availability](computers.md#availability-and-errors).

```ts
const web = await open('web'); // a target named in verify.config.ts
Expand Down
2 changes: 1 addition & 1 deletion packages/verify/docs/computers.md
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ The HTTPS URL is signed and short-lived. Keep it private, including its query st

## Availability and errors

Mac computers are available to organizations on a current paid Revyl plan. A `503 runtime_unavailable` or typed `computer_not_enabled` becomes `NOT_AVAILABLE_ON_PLATFORM` with this availability guidance. A `429 computer_limit` becomes `COMPUTER_LIMIT`: queued work (including iOS) or the concurrency limit can cause it, and the response does not identify which. Verify does not retry the create or send a stop after these definite admission refusals. `operation_limit` remains `SESSION_BUSY`. Availability is determined by the server.
Mac computers are available to organizations on a current paid Revyl plan. A `503 runtime_unavailable` or typed `computer_not_enabled` becomes `NOT_AVAILABLE_ON_PLATFORM` with this availability guidance. When Revyl says Pro would unlock Macs for the organization (`computer_not_enabled` with `unlocks_with_card: true`, sent to Free-plan organizations), the error keeps `NOT_AVAILABLE_ON_PLATFORM` but has `reason: 'upgrade_required'` and says so: `Mac computers come with Pro, so Revyl refused this computer (computer_not_enabled, upgrade_required).`, followed by Revyl's upgrade offer and its HTTPS billing link when Revyl sends one (an owner or admin is asked to add a card; a member is asked to ask one of them), and otherwise by `Add a card in Revyl's billing settings to unlock them.` `openPersistent()` refuses the same way, without the session link. A `429 computer_limit` becomes `COMPUTER_LIMIT`: queued work (including iOS) or the concurrency limit can cause it, and the response does not identify which. Verify does not retry the create or send a stop after these definite admission refusals. `operation_limit` remains `SESSION_BUSY`. Availability is determined by the server.

The default `startTimeout` remains 600000 ms; override it explicitly if needed. An unclaimed start can transition to `failed` with `failure_reason: 'no_host'` after 120 seconds from create. Verify stops readiness polling and throws `SESSION_START_FAILED` with that context, then attempts bounded cleanup. This is not a 120-second timeout for every start: claimed guests may take longer. `device_limit` also yields `SESSION_START_FAILED`, with queued-work/concurrency context. A start timeout or unconfirmed close does not prove resources were released. Inspect the session and contact support rather than blindly repeating a start or stop.

Expand Down
1 change: 1 addition & 0 deletions packages/verify/docs/errors.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
| Session profile script missing | `SESSION_PROFILE_FAILED` (`outcome: 'script_unavailable'`) | `session_profile_script_unavailable` |
| 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_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.

Expand Down
16 changes: 16 additions & 0 deletions packages/verify/src/api/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,22 @@ export function responseDetail(response: RawResponse): string | undefined {
return undefined;
}

const MAC_UPGRADE_REFUSAL = 'Mac computers come with Pro, so Revyl refused this computer (computer_not_enabled, upgrade_required).';

export function macUpgradeMessage(response: RawResponse): string | undefined {
let body: { unlocks_with_card?: unknown; offer?: { message?: unknown; billing_url?: unknown } | null } | null;
try {
body = JSON.parse(new TextDecoder().decode(response.body));
} catch {
return undefined;
}
if (body?.unlocks_with_card !== true) return undefined;
const message = body.offer?.message;
const url = body.offer?.billing_url;
if (typeof message === 'string' && message.trim() !== '' && /^[^\x00-\x1f\x7f\x85\u2028\u2029]{1,160}$/u.test(message) && typeof url === 'string' && /^https:\/\/[!-~]+$/.test(url)) return `${MAC_UPGRADE_REFUSAL} ${message}: ${url}`;
return `${MAC_UPGRADE_REFUSAL} Add a card in Revyl's billing settings to unlock them.`;
}

export function responseErrorCode(response: RawResponse): string | undefined {
try {
const parsed = JSON.parse(new TextDecoder().decode(response.body)) as { error?: unknown };
Expand Down
4 changes: 3 additions & 1 deletion packages/verify/src/computer-session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { createHash, randomUUID } from 'node:crypto';
import { mkdir, writeFile } from 'node:fs/promises';
import { dirname, resolve } from 'node:path';
import { setTimeout as delay } from 'node:timers/promises';
import { RevylClient, edgeBlockedError, responseDetail, responseErrorCode, responseRefusalReason, sessionViewerUrl, type RawResponse } from './api/client.js';
import { RevylClient, edgeBlockedError, macUpgradeMessage, responseDetail, responseErrorCode, responseRefusalReason, sessionViewerUrl, type RawResponse } from './api/client.js';
import type { ComputerCommand, ComputerCommandResponse, ComputerPlatform, ComputerRecordingResponse, ComputerReport, ComputerResult, ComputerScreenshot } from './api/types.js';
import { trackSession, untrackSession } from './cleanup.js';
import { validateHostedTarget, type HostedTargetConfig, type ResolvedComputerTarget } from './config.js';
Expand Down Expand Up @@ -546,6 +546,8 @@ export class ComputerSession implements Session {
const code = raw?.detail ?? raw?.message ?? raw?.error;
if ((code === 'screen_unavailable' && (response.status === 409 || response.status === 503)) || (code === 'screen_starting' && response.status === 409)) return response;
}
const upgrade = detail === 'computer_not_enabled' ? macUpgradeMessage(response) : undefined;
if (upgrade) throw new VerifyError('NOT_AVAILABLE_ON_PLATFORM', `${upgrade} See ${this.viewerUrl}`, { reason: 'upgrade_required', httpStatus: response.status });
if (detail === 'computer_not_enabled' || (response.status === 503 && detail === 'runtime_unavailable')) {
throw new VerifyError('NOT_AVAILABLE_ON_PLATFORM', `Revyl refused the computer request (${detail}). ${COMPUTER_AVAILABILITY} See ${this.viewerUrl}`, refusal);
}
Expand Down
Loading
Loading