Skip to content
Draft
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
15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,21 @@ To be published as the `go/v0.6.1` tag.
- 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.8.0 (unreleased)

- Session profiles: `open(target, { profile: "signed-in", sessionProfileProjectId: "<project UUID>" })` runs a project's named session profile from Git without reading local `.revyl/config.yaml` or sending a local script or Git branch. The project option requires a named profile and a valid UUID, otherwise `INVALID_ARGUMENT` is thrown. Web, iOS, Android and Mac are supported; Linux still refuses a profile name. Explicit checkout profiles and `profile: "none"` are unchanged.
- Implicit checkout defaults on web, iOS and Android send `instruction: "default"` only when the backend advertises `device_session_session_profile_picks`, so an untargeted app can start without the profile. A missing capability or failed read preserves the named request; explicit profiles and Mac computer defaults are unchanged.

## Go 0.7.0 (unreleased)

- Session profiles: `OpenOptions.SessionProfileProjectID` with `Profile` runs a project's named session profile from Git without a local checkout, as in TypeScript 0.8.0. Invalid nonempty UUIDs and empty or `"none"` profiles return `ErrInvalidArgument`; `Attach` and `CurrentComputer` reject the option. An empty project ID preserves checkout behavior.
- Implicit checkout defaults negotiate `instruction: "default"` on capable web, iOS and Android backends, preserving named requests on older backends and for Mac computers, as in TypeScript 0.8.0.

## Python 0.6.0 (unreleased)

- Session profiles: `open(..., profile="signed-in", session_profile_project_id="<project UUID>")` and `async_open` run a project's named session profile from Git without a local checkout, as in TypeScript 0.8.0. An invalid UUID or a missing, empty or `"none"` profile raises `INVALID_ARGUMENT`. Explicit checkout profiles and `profile="none"` are unchanged.
- Implicit checkout defaults negotiate `instruction="default"` on capable web, iOS and Android backends, preserving named requests on older backends and for Mac computers, as in TypeScript 0.8.0.

## 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
24 changes: 21 additions & 3 deletions go/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ Run with `go test -v -timeout 6m`. `t.Fatal` runs deferred cleanup. The URL and
- `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).
- `OpenOptions.SessionProfileProjectID`: a Revyl project UUID to read the named session profile from Git instead of your checkout. Requires `Profile` to name a session profile, not `"none"`. Verify reads no local `.revyl/config.yaml` and sends no local script or Git branch. An empty project ID keeps checkout behavior.
- Redirects are rejected, not followed with credentials.
- `OpenOptions{Log: func(line string) { ... }}` opts into progress lines: `<platform>: starting <platform> session <link>` as soon as the session ID exists, before the browser or device is ready, then `ready`, on web, iOS, Android and hosted sessions; computer lifecycle; evidence-gap messages; mobile best-effort first-screen debug notes; and the turns of steps run on your own model. The default is quiet for all targets, so pass `Log: func(line string) { log.Println(line) }` to see the session link while a slow start runs. Keep that callback concurrency-safe if operations run concurrently. A confirmed execution result remains usable when its report evidence is pending or failed; the callback identifies that gap without logging private output or recording URLs.

Expand All @@ -175,14 +176,29 @@ bare, err := verify.Open(ctx, verify.Target{Platform: verify.Web, AppID: "…",
| `Profile` | What Verify sends |
| --- | --- |
| `"signed-in"` | That profile, with the project and the script from this checkout. |
| `""` (left out) | The project's `session.default_profile`, the same way, when `.revyl/config.yaml` sets one. Otherwise nothing, so the start request is the same as before profiles existed. |
| `""` (left out) | The checkout's `session.default_profile` when set. On web, iOS and Android, a capable backend skips it if the project doesn't target the launched app. Otherwise nothing is sent. |
| `"none"` | No profile, not even the default: Verify sends no profile fields, so the start request is the same as before profiles existed. Needs no `.revyl/config.yaml`. |

Profiles work on web, iOS, Android and Mac computers. On a Linux computer, a profile name returns `ErrNotAvailableOnPlatform` before anything is sent, and no default runs; `"none"` is accepted. Hosted sessions (`computer.Open`), `Attach` and `CurrentComputer` never run a profile: `computer.Open` takes no options, and `Attach` and `CurrentComputer` return `ErrInvalidArgument` when `Profile` is set.
Profiles work on web, iOS, Android and Mac computers. On a Linux computer, a profile name returns `ErrNotAvailableOnPlatform` before anything is sent, and no default runs; `"none"` is accepted without a project option. Hosted sessions (`computer.Open`), `Attach` and `CurrentComputer` never run a profile: `computer.Open` takes no options, and `Attach` and `CurrentComputer` return `ErrInvalidArgument` when `Profile` or `SessionProfileProjectID` is set.

For an implicit checkout default on web, iOS or Android, Verify reads `GET /api/v1/backend-capabilities?contract=session_profile_starts`. If `capabilities` includes `device_session_session_profile_picks`, it sends `instruction: "default"` with the default's name and the same checkout files and source. Revyl runs it when the project targets the launched app, or when no registered app launches; otherwise the session starts without a profile. A missing capability or a failed read keeps today's `instruction: "named"` request. Explicit profiles and Mac computer defaults always use `named` and make no capability request.

### Without a checkout

Pass `SessionProfileProjectID` with a named `Profile` to use the project's session profile from Git, without any local `.revyl/config.yaml`:

```go
s, err := verify.Open(ctx, verify.Target{Platform: verify.Mac}, verify.OpenOptions{
Profile: "signed-in",
SessionProfileProjectID: "0b9e6f3a-1c2d-4e5f-8a9b-0c1d2e3f4a5b",
})
```

Verify sends `session_profile` with `instruction: "named"` and the profile name, and `session_profile_source` with only `project_id`. It sends no `session_profile_files` or `git_branch_name`; Revyl reads the project's default branch in Git. A local config, even if present, is ignored. An invalid nonempty project UUID or an empty or `"none"` profile returns `ErrInvalidArgument` before any request. Refusals, repository retries and waiting for the profile follow the same rules as checkout starts; an explicit profile is never silently skipped on an older backend.

### Where Verify reads the profile

Verify reads `.revyl/config.yaml` in the working directory (`os.Getwd()`) or the nearest folder above it that has one: the file `revyl init` writes in your app's checkout. In `go test`, the working directory is the package's folder, so the file is found when it sits in that folder or above it. Verify needs `project.id` and the profile under `session.profiles`, and reads nothing else from the file:
Without `SessionProfileProjectID`, Verify reads `.revyl/config.yaml` in the working directory (`os.Getwd()`) or the nearest folder above it that has one: the file `revyl init` writes in your app's checkout. In `go test`, the working directory is the package's folder, so the file is found when it sits in that folder or above it. Verify needs `project.id` and the profile under `session.profiles`, and reads nothing else from the file:

```yaml
project:
Expand Down Expand Up @@ -228,6 +244,8 @@ Neither errors nor logs contain the script's content or output. Check the code w
| `script_unavailable` | The script isn't in this checkout or in Git, or the Library Script is missing | Commit the script or add it to `.revyl/scripts`, or create the Library Script |
| `output_invalid` | A file the script wrote broke a rule; `FailureReason` names the file and the line | Fix what the script writes there |
| `runner_failed` | Something failed on Revyl's side | Open the session again |
| `script_execution_unknown` | The run ended after Revyl let the script start because its runner was lost or the session stopped, timed out, or was cancelled, so the script may have run | Check the session before retrying |
| `cancelled_before_script_execution` | The session stopped, timed out, or was cancelled before the script started | Retry the profile when the session can remain active long enough to run it |

## Which call works where

Expand Down
18 changes: 16 additions & 2 deletions go/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,20 @@ type Code string

type RefusalReason string

// SessionProfileOutcome describes how a session profile run ended.
type SessionProfileOutcome string

const (
SessionProfileSucceeded SessionProfileOutcome = "succeeded"
SessionProfileScriptFailed SessionProfileOutcome = "script_failed"
SessionProfileScriptTimedOut SessionProfileOutcome = "script_timed_out"
SessionProfileScriptUnavailable SessionProfileOutcome = "script_unavailable"
SessionProfileOutputInvalid SessionProfileOutcome = "output_invalid"
SessionProfileRunnerFailed SessionProfileOutcome = "runner_failed"
SessionProfileScriptExecutionUnknown SessionProfileOutcome = "script_execution_unknown"
SessionProfileCancelledBeforeScriptExecution SessionProfileOutcome = "cancelled_before_script_execution"
)

const (
ReasonWebRuntimeUnavailable RefusalReason = "web_runtime_unavailable"
ReasonWebRuntimeNotConfigured RefusalReason = "web_runtime_not_configured"
Expand Down Expand Up @@ -86,8 +100,8 @@ type Error struct {
Message string
Cause error
ExecResult *ExecResult
// Outcome is set on ErrSessionProfileFailed: how the profile's run ended, such as "script_failed".
Outcome string
// Outcome is set on ErrSessionProfileFailed: how the profile's run ended.
Outcome SessionProfileOutcome
// FailureReason is set on ErrSessionProfileFailed: Revyl's reason, which never holds a secret or the script's output.
FailureReason string

Expand Down
3 changes: 3 additions & 0 deletions go/hosted.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,9 @@ func CurrentComputer(ctx context.Context, options ...OpenOptions) (*Session, err

func rejectProfile(options []OpenOptions) error {
for _, option := range options {
if option.SessionProfileProjectID != "" {
return failure(ErrInvalidArgument, "SessionProfileProjectID runs only when Open starts a new web, iOS, Android or Mac session; Attach and CurrentComputer can't run one. Leave SessionProfileProjectID empty.")
}
if option.Profile != "" {
return failure(ErrInvalidArgument, "Profile runs only when Open starts a new web, iOS, Android or Mac session; Attach and CurrentComputer can't run one. Leave Profile empty.")
}
Expand Down
16 changes: 12 additions & 4 deletions go/session.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,12 @@ type OpenOptions struct {
StepTimeout time.Duration
Log func(string)
StopOnClose *bool
// Profile names a session profile from session.profiles in .revyl/config.yaml, such as "signed-in", that Revyl runs before
// Profile names a session profile from session.profiles in .revyl/config.yaml locally or in SessionProfileProjectID's Git
// repository, such as "signed-in", that Revyl runs before
// Open returns, or "none" for no profile. Left empty, the project's session.default_profile runs when it sets one. Open reads
// .revyl/config.yaml from the working directory upward. Web, iOS, Android and Mac only.
Profile string
// .revyl/config.yaml from the working directory upward unless SessionProfileProjectID is set. Web, iOS, Android and Mac only.
Profile string
SessionProfileProjectID string
}

// OpenOption configures Open: an OpenOptions value, or an Option from WithModel, WithCustomModel or WithAgent.
Expand Down Expand Up @@ -136,7 +138,7 @@ func Open(ctx context.Context, target Target, options ...OpenOption) (*Session,
return nil, err
}
cwd, _ := os.Getwd()
profile, err := planSessionProfile(opt.Profile, target.Platform, cwd)
profile, err := planSessionProfile(opt.Profile, target.Platform, cwd, opt.SessionProfileProjectID)
if err != nil {
return nil, err
}
Expand All @@ -147,6 +149,9 @@ func Open(ctx context.Context, target Target, options ...OpenOption) (*Session,
if err != nil {
return nil, err
}
if profile != nil && profile.implicit && target.Platform != Mac && supportsSessionProfileDefaults(ctx, c) {
profile.usesDefaultInstruction = true
}
s, err := openStart(ctx, c, viewer, target, opt, agent, profile)
if err == nil || profile == nil || !profile.implicit || !isLegacyProfileRefusal(err) {
return s, err
Expand Down Expand Up @@ -453,6 +458,9 @@ func (s *Session) profileDone(profile *reportedProfile, active bool) (bool, erro
return false, nil
}
if profile == nil {
if plan.usesDefaultInstruction {
return true, nil
}
return false, profileNotReportedError(s.platform, s.viewer)
}
return profile.status == "succeeded", nil
Expand Down
Loading
Loading