@qawolf/cli 1.20.1 → 1.21.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,24 @@
1
+ import type { ListedRunner, RunnerSdkOptions, SdkResult } from "./types.js";
2
+ export type { ActRequest, EvaluateSnippetRequest, EvaluatedSnippet, EventsRequest, FileSync, HighlightRequest, HighlightSelectorRequest, HighlightedSelector, ImportPackageRequest, ImportedPackage, InspectRequest, Inspected, Journal, JournalWindow, KeptAlive, LaunchRequest, LaunchedRunner, LinesLocation, ListedRunner, PackageVersion, PerformedAction, PromoteSnapshotRequest, PromotedSnapshot, RunEnvironment, RunFilter, RunRequest, RunSelection, RunnerFamily, RunnerRequest, RunnerSdkOptions, Screenshot, SdkResult, SnippetScope, StoppedRun, SubmittedRun, TerminatedRunner, } from "./types.js";
3
+ export type RunnerSdk = ReturnType<typeof createRunnerSdk>;
4
+ /**
5
+ * Drives interactive runners on the caller's team through the QA Wolf public
6
+ * API. Every verb names the runner it addresses, so nothing is launched or
7
+ * billed implicitly: call `launch` for that.
8
+ */
9
+ export declare function createRunnerSdk(options: RunnerSdkOptions): {
10
+ list(): Promise<SdkResult<ListedRunner[]>>;
11
+ evaluateSnippet({ runnerId, scope, source, }: import("./types.js").EvaluateSnippetRequest): Promise<SdkResult<import("./types.js").EvaluatedSnippet>>;
12
+ importPackage({ name, runnerId, version, }: import("./types.js").ImportPackageRequest): Promise<SdkResult<import("./types.js").ImportedPackage>>;
13
+ act({ action, runnerId, }: import("./types.js").ActRequest): Promise<SdkResult<import("./types.js").PerformedAction>>;
14
+ highlightSelector({ highlight, runnerId, }: import("./types.js").HighlightSelectorRequest): Promise<SdkResult<import("./types.js").HighlightedSelector>>;
15
+ inspect({ request, runnerId, }: import("./types.js").InspectRequest): Promise<SdkResult<import("./types.js").Inspected>>;
16
+ promoteSnapshot({ baselinePath, runnerId, screenshotPath, }: import("./types.js").PromoteSnapshotRequest): Promise<SdkResult<import("./types.js").PromotedSnapshot>>;
17
+ screenshot({ runnerId, }: import("./types.js").RunnerRequest): Promise<SdkResult<import("./types.js").Screenshot>>;
18
+ events({ runFilter, runnerId, stream, window, }: import("./types.js").EventsRequest): Promise<SdkResult<import("./types.js").Journal>>;
19
+ run({ entryPointPath, environment, runnerId, selection, }: import("./types.js").RunRequest): Promise<SdkResult<import("./types.js").SubmittedRun>>;
20
+ keepalive({ runnerId, }: import("./types.js").RunnerRequest): Promise<SdkResult<import("./types.js").KeptAlive>>;
21
+ launch({ id, runnerFamily, }: import("./types.js").LaunchRequest): Promise<SdkResult<import("./types.js").LaunchedRunner>>;
22
+ stopRun({ runnerId }: import("./types.js").RunnerRequest): Promise<SdkResult<import("./types.js").StoppedRun>>;
23
+ terminate({ runnerId, }: import("./types.js").RunnerRequest): Promise<SdkResult<import("./types.js").TerminatedRunner>>;
24
+ };
@@ -0,0 +1,120 @@
1
+ import type { BrowserAction, InspectOnRunnerRequest, JournalStream, PublicApiOutput, ReadJournalResponse, RunnerNameForPublicApi, publicContractsV1 } from "@qawolf/api-contracts/v1";
2
+ type Runner = typeof publicContractsV1.runner;
3
+ export type RunnerSdkOptions = {
4
+ /** A QA Wolf team API key. The SDK never reads the CLI's stored credentials. */
5
+ apiKey: string;
6
+ /** Defaults to `QAWOLF_HOST_URL`, then `https://app.qawolf.com`. */
7
+ baseUrl?: string | undefined;
8
+ /** Where a run collects its files from. Defaults to `process.cwd()`. */
9
+ cwd?: string | undefined;
10
+ fetch?: typeof globalThis.fetch | undefined;
11
+ };
12
+ export type SdkResult<Value> = {
13
+ error: string;
14
+ ok: false;
15
+ } | {
16
+ ok: true;
17
+ value: Value;
18
+ };
19
+ export type RunSelection = "whole-flow" | {
20
+ endLine: number;
21
+ linesIn: LinesLocation;
22
+ startLine: number;
23
+ };
24
+ export type LinesLocation = "entry-point" | {
25
+ filePath: string;
26
+ };
27
+ export type RunEnvironment = "ambient" | {
28
+ id: string;
29
+ };
30
+ export type SnippetScope = "no-imports" | {
31
+ filePath: string;
32
+ };
33
+ export type HighlightRequest = "clear" | {
34
+ selector: string;
35
+ };
36
+ export type PackageVersion = "latest" | {
37
+ exact: string;
38
+ };
39
+ export type RunnerFamily = "default" | {
40
+ name: RunnerNameForPublicApi;
41
+ };
42
+ export type JournalWindow = "newest" | {
43
+ sinceSequence: number;
44
+ } | {
45
+ tail: number;
46
+ };
47
+ export type RunFilter = "all-runs" | {
48
+ runId: string;
49
+ };
50
+ export type LaunchRequest = {
51
+ id: string;
52
+ runnerFamily: RunnerFamily;
53
+ };
54
+ export type RunnerRequest = {
55
+ runnerId: string;
56
+ };
57
+ export type RunRequest = RunnerRequest & {
58
+ entryPointPath: string;
59
+ environment: RunEnvironment;
60
+ selection: RunSelection;
61
+ };
62
+ export type EventsRequest = RunnerRequest & {
63
+ runFilter: RunFilter;
64
+ stream: JournalStream;
65
+ window: JournalWindow;
66
+ };
67
+ export type ActRequest = RunnerRequest & {
68
+ action: BrowserAction;
69
+ };
70
+ export type EvaluateSnippetRequest = RunnerRequest & {
71
+ scope: SnippetScope;
72
+ source: string;
73
+ };
74
+ export type InspectRequest = RunnerRequest & {
75
+ request: InspectOnRunnerRequest;
76
+ };
77
+ export type ImportPackageRequest = RunnerRequest & {
78
+ name: string;
79
+ version: PackageVersion;
80
+ };
81
+ export type HighlightSelectorRequest = RunnerRequest & {
82
+ highlight: HighlightRequest;
83
+ };
84
+ export type PromoteSnapshotRequest = RunnerRequest & {
85
+ baselinePath: string;
86
+ screenshotPath: string;
87
+ };
88
+ export type LaunchedRunner = PublicApiOutput<Runner["launch"]>;
89
+ export type TerminatedRunner = PublicApiOutput<Runner["terminate"]>;
90
+ export type StoppedRun = PublicApiOutput<Runner["stopRun"]>;
91
+ export type Screenshot = PublicApiOutput<Runner["takeScreenshot"]>;
92
+ export type PerformedAction = PublicApiOutput<Runner["performAction"]>;
93
+ export type EvaluatedSnippet = PublicApiOutput<Runner["evaluateSnippet"]>;
94
+ export type Inspected = PublicApiOutput<Runner["inspect"]>;
95
+ export type ImportedPackage = PublicApiOutput<Runner["importPackage"]>;
96
+ export type HighlightedSelector = PublicApiOutput<Runner["highlightSelector"]>;
97
+ export type PromotedSnapshot = PublicApiOutput<Runner["promoteSnapshot"]>;
98
+ /** A journal window, as the public API answers it. */
99
+ export type Journal = ReadJournalResponse;
100
+ /** The CLI's own answer: the file set it sent whole, or only what changed. */
101
+ export type FileSync = "delta" | "full";
102
+ /**
103
+ * `fileSync` and `bootstrappedRunner` are the CLI's own, so this is not the
104
+ * `runner.runFlow` output verbatim.
105
+ */
106
+ export type SubmittedRun = {
107
+ bootstrappedRunner: boolean;
108
+ fileSync: FileSync;
109
+ runId: string;
110
+ };
111
+ /** Runners this working directory launched, which the API has no notion of. */
112
+ export type ListedRunner = {
113
+ id: string;
114
+ isDefault: boolean;
115
+ runnerName: string | undefined;
116
+ };
117
+ export type KeptAlive = {
118
+ id: string;
119
+ };
120
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@qawolf/cli",
3
- "version": "1.20.1",
3
+ "version": "1.21.0",
4
4
  "description": "Run and manage QA Wolf flows from the terminal, CI, or an AI agent",
5
5
  "keywords": [
6
6
  "automation",
@@ -28,16 +28,27 @@
28
28
  "LICENSE",
29
29
  "README.md",
30
30
  "dist/cli.js",
31
+ "dist/runner-sdk.js",
32
+ "dist/types/runnerSdk/index.d.ts",
33
+ "dist/types/runnerSdk/types.d.ts",
31
34
  "skills"
32
35
  ],
33
36
  "type": "module",
37
+ "exports": {
38
+ "./runner-sdk": {
39
+ "types": "./dist/types/runnerSdk/index.d.ts",
40
+ "import": "./dist/runner-sdk.js"
41
+ },
42
+ "./package.json": "./package.json"
43
+ },
34
44
  "publishConfig": {
35
45
  "access": "public"
36
46
  },
37
47
  "scripts": {
38
48
  "build": "bun run build:bundle",
39
- "build:bundle": "bun run generate && bun scripts/build.ts",
40
49
  "build:binary": "bun run build && bun scripts/buildBinary.ts",
50
+ "build:bundle": "bun run generate && bun scripts/build.ts",
51
+ "build:types-gate": "bun scripts/checkSdkTypes.ts",
41
52
  "dev": "bun run src/main.ts",
42
53
  "format": "oxfmt .",
43
54
  "format:check": "oxfmt --check .",
@@ -60,7 +71,7 @@
60
71
  "@clack/prompts": "1.5.1",
61
72
  "@napi-rs/keyring": "1.3.0",
62
73
  "@oxc-node/core": "0.1.0",
63
- "@qawolf/api-contracts": "0.35.0",
74
+ "@qawolf/api-contracts": "0.37.0",
64
75
  "@qawolf/emails": "1.1.1",
65
76
  "@qawolf/flow-targets": "1.0.0",
66
77
  "@qawolf/flows": "0.1.4",
@@ -92,7 +92,7 @@ something:
92
92
  - `screenshot` and `act` fail with exit code `2`, except `navigate`, which
93
93
  fails with exit code `1` (`action-failed`): it skips the screen but still
94
94
  needs the runner to have run something
95
- - `exec` fails with exit code `4`
95
+ - `exec` fails with exit code `2`
96
96
  - `events recorder` reads as empty
97
97
 
98
98
  None of that is a fault, and none of it clears on its own. **Only
@@ -120,9 +120,6 @@ Retry on the exit code, not on the message text:
120
120
  run a flow, or the runner has no browser at all, so launch with
121
121
  `--name playwright` instead. The message says which.
122
122
 
123
- The one exception is `exec`, which reports both as `4`; read its message to tell
124
- them apart.
125
-
126
123
  ## Seeing and acting: the loop is yours
127
124
 
128
125
  Two primitives, and you close the loop with your own model. There is no hosted
@@ -288,7 +285,7 @@ When a run's image diff fails and the new screenshot is the one you want, this
288
285
  replaces the baseline on the runner that produced it:
289
286
 
290
287
  ```sh
291
- qawolf runner events run-events --tail 20 | jq 'select(.type == "image-diff-artifact")'
288
+ qawolf runner events run-events --tail 20 | jq 'select(.type == "imageDiffArtifact")'
292
289
  qawolf runner promote-snapshot --screenshot checkout-1-actual.png --baseline checkout-1.png
293
290
  ```
294
291