diff --git a/CHANGELOG.md b/CHANGELOG.md index 9a1f9fe..032f798 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 (`: `) 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`. diff --git a/go/README.md b/go/README.md index d393a8d..0f031a2 100644 --- a/go/README.md +++ b/go/README.md @@ -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). @@ -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. diff --git a/go/computer.go b/go/computer.go index 938f20f..317b066 100644 --- a/go/computer.go +++ b/go/computer.go @@ -15,6 +15,7 @@ import ( "net/url" "os" "path/filepath" + "regexp" "slices" "strconv" "strings" @@ -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.", @@ -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)) } diff --git a/go/errors.go b/go/errors.go index 34c5622..ff0d6e4 100644 --- a/go/errors.go +++ b/go/errors.go @@ -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) } diff --git a/go/persistent.go b/go/persistent.go index babaed7..3af029d 100644 --- a/go/persistent.go +++ b/go/persistent.go @@ -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) { diff --git a/packages/verify/docs/api.md b/packages/verify/docs/api.md index 46ca49c..e46eec1 100644 --- a/packages/verify/docs/api.md +++ b/packages/verify/docs/api.md @@ -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 diff --git a/packages/verify/docs/computers.md b/packages/verify/docs/computers.md index 45a15c6..6ab1f8b 100644 --- a/packages/verify/docs/computers.md +++ b/packages/verify/docs/computers.md @@ -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. diff --git a/packages/verify/docs/errors.md b/packages/verify/docs/errors.md index bb7812b..ee7a238 100644 --- a/packages/verify/docs/errors.md +++ b/packages/verify/docs/errors.md @@ -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. diff --git a/packages/verify/src/api/client.ts b/packages/verify/src/api/client.ts index e9b0bf4..f4ffc59 100644 --- a/packages/verify/src/api/client.ts +++ b/packages/verify/src/api/client.ts @@ -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 }; diff --git a/packages/verify/src/computer-session.ts b/packages/verify/src/computer-session.ts index 05bc8d2..3db7ad2 100644 --- a/packages/verify/src/computer-session.ts +++ b/packages/verify/src/computer-session.ts @@ -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'; @@ -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); } diff --git a/packages/verify/src/errors.ts b/packages/verify/src/errors.ts index 9addfe0..31504f7 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' | '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'; export class VerifyError extends Error { readonly code: VerifyErrorCode; diff --git a/packages/verify/src/persistent.ts b/packages/verify/src/persistent.ts index 1583f8a..b74b7e9 100644 --- a/packages/verify/src/persistent.ts +++ b/packages/verify/src/persistent.ts @@ -1,5 +1,5 @@ import { setTimeout as delay } from 'node:timers/promises'; -import { RevylClient, edgeBlockedError, responseDetail, type RawResponse } from './api/client.js'; +import { RevylClient, edgeBlockedError, macUpgradeMessage, responseDetail, type RawResponse } from './api/client.js'; import type { ComputerReport } from './api/types.js'; import { ComputerSession, computerOperationId } from './computer-session.js'; import { trackSession } from './cleanup.js'; @@ -353,6 +353,8 @@ async function call(client: RevylClient, method: 'GET' | 'POST' | 'DELETE', path const detail = responseDetail(response); if (detail && options.accept?.includes(detail)) return response; const refusal = { httpStatus: response.status }; + const upgrade = detail === 'computer_not_enabled' ? macUpgradeMessage(response) : undefined; + if (upgrade) throw new VerifyError('NOT_AVAILABLE_ON_PLATFORM', upgrade, { ...refusal, reason: 'upgrade_required' }); const known = detail ? REFUSALS[detail] : undefined; if (known) throw new VerifyError(known[0], known[1], { ...refusal, reason: known[2] }); if (response.status === 401 || response.status === 403) throw new VerifyError('AUTH_REJECTED', `Revyl rejected the request (HTTP ${response.status}${detail ? `, ${detail}` : ''}). Check that REVYL_API_KEY is a current key and that its owner has the Member role or above.`, refusal); diff --git a/python/README.md b/python/README.md index 04ab0ec..f5bc620 100644 --- a/python/README.md +++ b/python/README.md @@ -535,7 +535,7 @@ Session properties include `id`, `platform`, `viewer_url`, `expires_at` and `clo | iOS simulator / Android emulator | Yes | — | Yes | | Mac computer | — | Yes | Yes | -Mac computers are available to organizations on a current paid Revyl plan. Computer admission may return `COMPUTER_LIMIT`; the SDK does not retry creation. Computer sessions have a hard lifetime from creation: 2 hours by default, or up to 24 hours with `Target(platform="mac", timeout=...)` (seconds, 60 to 86400). `session.extend(timeout)` keeps a running computer going at least that long from now, up to 24 hours after creation; it never shortens the lifetime, so retrying is safe, and it refreshes `expires_at`, the authoritative deadline. Lifetimes over 2 hours can be refused with `COMPUTER_LIMIT` (`computer_long_limit`, at most 2 such computers per organization at once) or `NOT_AVAILABLE_ON_PLATFORM` (no host can run that long, or the host can't extend). Screenshot observation retries structured startup screen-not-ready errors within a bounded window; other errors are not silently replayed. +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 `open_persistent()` raise `NOT_AVAILABLE_ON_PLATFORM` with `reason="upgrade_required"`. The message starts `Mac computers come with Pro, so Revyl refused this computer (computer_not_enabled, upgrade_required).` and ends with Revyl's upgrade offer and its HTTPS billing link, or with `Add a card in Revyl's billing settings to unlock them.` when Revyl sends no offer. Any other `computer_not_enabled` keeps the support guidance and no reason. Computer admission may return `COMPUTER_LIMIT`; the SDK does not retry creation. Computer sessions have a hard lifetime from creation: 2 hours by default, or up to 24 hours with `Target(platform="mac", timeout=...)` (seconds, 60 to 86400). `session.extend(timeout)` keeps a running computer going at least that long from now, up to 24 hours after creation; it never shortens the lifetime, so retrying is safe, and it refreshes `expires_at`, the authoritative deadline. Lifetimes over 2 hours can be refused with `COMPUTER_LIMIT` (`computer_long_limit`, at most 2 such computers per organization at once) or `NOT_AVAILABLE_ON_PLATFORM` (no host can run that long, or the host can't extend). Screenshot observation retries structured startup screen-not-ready errors within a bounded window; other errors are not silently replayed. Context-manager exit calls `close()`. Device close acknowledges a stop request; computer close requires terminal state **and confirmed resource release**. Close submits its stop mutation once; repeated calls share the first outcome, including an unconfirmed failure. Interpreter-exit cleanup is best effort and cannot replace explicit close, especially with asyncio. A failed close is not proof the resource was released; investigate it rather than starting replacement sessions blindly. diff --git a/python/src/revyl_verify/_computer.py b/python/src/revyl_verify/_computer.py index 2cf0689..16e9c80 100644 --- a/python/src/revyl_verify/_computer.py +++ b/python/src/revyl_verify/_computer.py @@ -53,6 +53,7 @@ VerifyError, decode_bytes, edge_blocked_error, + mac_upgrade_message, obj, refusal_reason, timestamp, @@ -596,6 +597,14 @@ def _request( or (detail == "screen_starting" and response.status == 409) ): return response + upgrade = mac_upgrade_message(response) if detail == "computer_not_enabled" else None + if upgrade is not None: + raise VerifyError( + "NOT_AVAILABLE_ON_PLATFORM", + f"{upgrade} See {self.viewer_url}", + reason="upgrade_required", + http_status=response.status, + ) if detail == "computer_not_enabled" or ( response.status == 503 and detail == "runtime_unavailable" ): diff --git a/python/src/revyl_verify/_persistent.py b/python/src/revyl_verify/_persistent.py index 7462d55..380adb6 100644 --- a/python/src/revyl_verify/_persistent.py +++ b/python/src/revyl_verify/_persistent.py @@ -21,6 +21,7 @@ Response, VerifyError, edge_blocked_error, + mac_upgrade_message, obj, origin, timestamp, @@ -599,6 +600,14 @@ def _call( detail = _detail(response) if detail is not None and detail in accept: return response + upgrade = mac_upgrade_message(response) if detail == "computer_not_enabled" else None + if upgrade is not None: + raise VerifyError( + "NOT_AVAILABLE_ON_PLATFORM", + upgrade, + reason="upgrade_required", + http_status=response.status, + ) known = _REFUSALS.get(detail or "") if known is not None: raise VerifyError( diff --git a/python/src/revyl_verify/_transport.py b/python/src/revyl_verify/_transport.py index 7f15471..fc8c9ba 100644 --- a/python/src/revyl_verify/_transport.py +++ b/python/src/revyl_verify/_transport.py @@ -60,6 +60,7 @@ "project_not_found", "repository_unavailable", "lifetime_unsupported", + "upgrade_required", ] SessionProfileOutcome = Literal[ "succeeded", @@ -382,6 +383,35 @@ def refusal_reason(response: Response) -> RefusalReason | None: return None +_MAC_UPGRADE_REFUSAL = ( + "Mac computers come with Pro, so Revyl refused this computer " + "(computer_not_enabled, upgrade_required)." +) +_OFFER_MESSAGE = re.compile(r"[^\x00-\x1f\x7f\x85\u2028\u2029]{1,160}") +_BILLING_URL = re.compile(r"https://[!-~]+") + + +def mac_upgrade_message(response: Response) -> str | None: + try: + raw = obj(response.json()) + except VerifyError: + return None + if raw.get("unlocks_with_card") is not True: + return None + offer = raw.get("offer") + message = offer.get("message") if isinstance(offer, dict) else None + url = offer.get("billing_url") if isinstance(offer, dict) else None + if ( + isinstance(message, str) + and message.strip() + and _OFFER_MESSAGE.fullmatch(message) + and isinstance(url, str) + and _BILLING_URL.fullmatch(url) + ): + return f"{_MAC_UPGRADE_REFUSAL} {message}: {url}" + return f"{_MAC_UPGRADE_REFUSAL} Add a card in Revyl's billing settings to unlock them." + + def start_refusal(response: Response) -> VerifyError | None: if response.status not in (400, 404, 422) or edge_blocked_error(response) is not None: return None