sedum-cli 0.1.0-alpha.12 → 0.1.0-alpha.17
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.
- package/dist/{affected-selection-WV5WY5NQ.js → affected-selection-KRK5HRF4.js} +7 -5
- package/dist/{chunk-HT6BIET2.js → chunk-A7HBQLEM.js} +188 -36
- package/dist/chunk-ACDJLEMS.js +508 -0
- package/dist/{chunk-HXQDSNLL.js → chunk-F4RD4S4P.js} +27 -46
- package/dist/{chunk-S7OB3JEF.js → chunk-GJ5QI7JQ.js} +38 -38
- package/dist/chunk-N5CTUO2A.js +27 -0
- package/dist/{chunk-FAGJCNV7.js → chunk-OKZ6VJKA.js} +145 -48
- package/dist/{chunk-AWBC7NOM.js → chunk-ZAACPFCW.js} +50 -2
- package/dist/cli.js +5 -3
- package/dist/{doctor-command-F4Y5KW36.js → doctor-command-KIGPIDQA.js} +3 -2
- package/dist/explore-command-NRRJADY4.js +25 -0
- package/dist/index.d.ts +21 -11
- package/dist/index.js +5 -3
- package/dist/{init-command-62IUO5LA.js → init-command-DEEVMROG.js} +81 -38
- package/dist/{run-command-ZEIANJWZ.js → run-command-EVUWZI4F.js} +75 -47
- package/package.json +5 -5
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { RunResult, BrowserKind, VerifyPolicy,
|
|
1
|
+
import { RunResult, BrowserKind, VerifyPolicy, RelevanceProvider, ClassificationProvider, BrowserInstallResult } from '@sedum-dev/core';
|
|
2
2
|
import { AuthProbeResult } from '@sedum-dev/provider-typesafe';
|
|
3
3
|
export { Ai, AiValue, AiValues, BrowserContext, Locator, Page, Parser, SecretValue, TestBody, TestContext, TestInfo, TestOptions, expect, secret, test } from '@sedum-dev/core/script';
|
|
4
4
|
|
|
@@ -47,8 +47,8 @@ interface ProjectConfigOverrides {
|
|
|
47
47
|
readonly baseUrl?: string;
|
|
48
48
|
readonly vision?: {
|
|
49
49
|
readonly enabled?: boolean;
|
|
50
|
-
readonly model?: string;
|
|
51
50
|
};
|
|
51
|
+
readonly screenshots?: boolean;
|
|
52
52
|
}
|
|
53
53
|
interface ResolvedProjectConfig {
|
|
54
54
|
readonly projectRoot: string;
|
|
@@ -70,17 +70,24 @@ interface ResolvedProjectConfig {
|
|
|
70
70
|
readonly reporterDir: string;
|
|
71
71
|
readonly baseUrl: string | null;
|
|
72
72
|
readonly variables: Readonly<Record<string, string | undefined>>;
|
|
73
|
-
readonly providerName: "typesafe" | "clef";
|
|
73
|
+
readonly providerName: "typesafe" | "clef" | "openrouter";
|
|
74
74
|
readonly apiKey: string | undefined;
|
|
75
|
+
readonly apiKeyEnv?: string;
|
|
76
|
+
/** Integration secrets retained for redaction, never injected into tests. */
|
|
77
|
+
readonly credentialValues?: readonly string[];
|
|
75
78
|
readonly cloudflareAccountId: string | undefined;
|
|
76
79
|
readonly providerBaseUrl: string;
|
|
77
80
|
readonly providerModel: string;
|
|
81
|
+
/** Ask the provider's image model about ambiguous or unmatched clicks. */
|
|
78
82
|
readonly vision: {
|
|
79
83
|
readonly enabled: boolean;
|
|
80
|
-
readonly model: string;
|
|
81
|
-
readonly timeoutMs: number;
|
|
82
84
|
};
|
|
83
|
-
|
|
85
|
+
/**
|
|
86
|
+
* Send viewport screenshots to the provider (TypeSafe images preview): a
|
|
87
|
+
* visual check of each model-resolved target, and the Judge's evidence.
|
|
88
|
+
* On by default for the direct TypeSafe endpoint only.
|
|
89
|
+
*/
|
|
90
|
+
readonly screenshots: boolean;
|
|
84
91
|
}
|
|
85
92
|
interface ProjectConfigLoadOptions {
|
|
86
93
|
/**
|
|
@@ -112,6 +119,7 @@ interface CliDiagnostic {
|
|
|
112
119
|
readonly message: string;
|
|
113
120
|
readonly fix: string;
|
|
114
121
|
}
|
|
122
|
+
type ProviderName = ResolvedProjectConfig["providerName"];
|
|
115
123
|
|
|
116
124
|
interface RunCommandOptions {
|
|
117
125
|
/**
|
|
@@ -125,7 +133,8 @@ interface RunCommandOptions {
|
|
|
125
133
|
readonly environment?: string;
|
|
126
134
|
readonly browser?: string;
|
|
127
135
|
readonly vision?: boolean;
|
|
128
|
-
|
|
136
|
+
/** Overrides `screenshots` in sedum.config.yaml. */
|
|
137
|
+
readonly screenshots?: boolean;
|
|
129
138
|
readonly urlOverride?: string;
|
|
130
139
|
readonly outputDir?: string;
|
|
131
140
|
readonly reporterDir?: string;
|
|
@@ -144,11 +153,13 @@ interface RunCommandOptions {
|
|
|
144
153
|
readonly providerConcurrency?: number;
|
|
145
154
|
/** Injected for tests; defaults to `os.availableParallelism()`. */
|
|
146
155
|
readonly availableParallelism?: number;
|
|
147
|
-
/** Injected for tests; defaults to OpenRouter's unbilled key endpoint. */
|
|
148
|
-
readonly probeVisionKey?: (apiKey: string) => Promise<VisionKeyProbe>;
|
|
149
156
|
readonly replay: boolean;
|
|
150
157
|
readonly evidence: boolean;
|
|
151
158
|
readonly sensitiveOrigins: readonly string[];
|
|
159
|
+
/** `--detect`: flag steps whose page reported errors or looks broken; findings never fail a step. */
|
|
160
|
+
readonly detect?: "off" | "browser" | "semantic";
|
|
161
|
+
/** `--detect-allow`: rules for known noise, added to the defaults. */
|
|
162
|
+
readonly detectAllow?: readonly string[];
|
|
152
163
|
readonly locatorCacheDisabled?: boolean;
|
|
153
164
|
readonly locatorCacheCi?: boolean;
|
|
154
165
|
readonly signal?: AbortSignal;
|
|
@@ -178,14 +189,13 @@ interface DoctorProbes {
|
|
|
178
189
|
readonly model: string;
|
|
179
190
|
}) => Promise<AuthProbeResult>;
|
|
180
191
|
readonly output?: (config: ResolvedProjectConfig) => Promise<void>;
|
|
181
|
-
readonly visionAuth?: (apiKey: string) => Promise<VisionKeyProbe>;
|
|
182
192
|
}
|
|
183
193
|
|
|
184
194
|
type ClassificationProviderFactory = (options: {
|
|
185
195
|
readonly apiKey?: string;
|
|
186
196
|
readonly baseURL: string;
|
|
187
197
|
readonly model: string;
|
|
188
|
-
readonly providerName?:
|
|
198
|
+
readonly providerName?: ProviderName;
|
|
189
199
|
readonly accountId?: string;
|
|
190
200
|
}) => ClassificationProvider | Promise<ClassificationProvider>;
|
|
191
201
|
|
package/dist/index.js
CHANGED
|
@@ -2,14 +2,16 @@ import {
|
|
|
2
2
|
renderRunSummary,
|
|
3
3
|
runCli,
|
|
4
4
|
runExitCode
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-A7HBQLEM.js";
|
|
6
|
+
import "./chunk-ACDJLEMS.js";
|
|
6
7
|
import "./chunk-EFRMSNBD.js";
|
|
7
|
-
import "./chunk-
|
|
8
|
+
import "./chunk-N5CTUO2A.js";
|
|
9
|
+
import "./chunk-GJ5QI7JQ.js";
|
|
8
10
|
import {
|
|
9
11
|
ProjectConfigError,
|
|
10
12
|
discoverConfiguredTests,
|
|
11
13
|
loadProjectConfig
|
|
12
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-OKZ6VJKA.js";
|
|
13
15
|
|
|
14
16
|
// src/index.ts
|
|
15
17
|
import { test, expect, secret } from "@sedum-dev/core/script";
|
|
@@ -2,11 +2,12 @@ import {
|
|
|
2
2
|
browserAvailable,
|
|
3
3
|
keyPresent,
|
|
4
4
|
supportedNode
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-F4RD4S4P.js";
|
|
6
|
+
import "./chunk-GJ5QI7JQ.js";
|
|
6
7
|
import {
|
|
7
8
|
ProjectConfigError,
|
|
8
9
|
loadProjectConfig
|
|
9
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-OKZ6VJKA.js";
|
|
10
11
|
|
|
11
12
|
// src/init-command.ts
|
|
12
13
|
import { constants } from "fs";
|
|
@@ -37,17 +38,42 @@ test(
|
|
|
37
38
|
var ENV_EXAMPLE = `# Get a TypeSafe key and put it in .env, or set it in your shell.
|
|
38
39
|
# For a compatible provider, also set TYPESAFE_BASE_URL and optionally TYPESAFE_DEFAULT_MODEL.
|
|
39
40
|
TYPESAFE_API_KEY=
|
|
41
|
+
# If provider.name is openrouter, use this instead (never commit .env).
|
|
42
|
+
# OPENROUTER_API_KEY=
|
|
40
43
|
# If provider.name is clef, use these instead (never commit .env).
|
|
41
44
|
# CLOUDFLARE_ACCOUNT_ID=
|
|
42
45
|
# CLOUDFLARE_AUTH_TOKEN=
|
|
43
46
|
# Public SauceDemo sample account; no Sauce Labs account is required.
|
|
44
47
|
SAUCE_PASSWORD=secret_sauce
|
|
45
48
|
`;
|
|
49
|
+
var PROVIDER_SETUP = {
|
|
50
|
+
typesafe: {
|
|
51
|
+
source: "Get a key at https://typesafe.ai/.",
|
|
52
|
+
instructions: [
|
|
53
|
+
"Open .env and set TYPESAFE_API_KEY to your key (or set it in your shell).",
|
|
54
|
+
"For a compatible provider, also set TYPESAFE_BASE_URL and use that provider's key as TYPESAFE_API_KEY."
|
|
55
|
+
]
|
|
56
|
+
},
|
|
57
|
+
clef: {
|
|
58
|
+
source: "Create a scoped Workers AI token in the Cloudflare dashboard.",
|
|
59
|
+
instructions: [
|
|
60
|
+
"Open .env and set CLOUDFLARE_ACCOUNT_ID and CLOUDFLARE_AUTH_TOKEN (or set them in your shell)."
|
|
61
|
+
]
|
|
62
|
+
},
|
|
63
|
+
openrouter: {
|
|
64
|
+
source: "Get a key at https://openrouter.ai/settings/keys.",
|
|
65
|
+
instructions: [
|
|
66
|
+
"Open .env and set OPENROUTER_API_KEY to your key (or set it in your shell)."
|
|
67
|
+
]
|
|
68
|
+
}
|
|
69
|
+
};
|
|
46
70
|
var IGNORE = [
|
|
47
71
|
"node_modules/",
|
|
48
72
|
".env",
|
|
49
73
|
".sedum/runs/",
|
|
50
|
-
".sedum/reports/"
|
|
74
|
+
".sedum/reports/",
|
|
75
|
+
// `sedum explore` traces, reports and page frames.
|
|
76
|
+
".sedum/explore/"
|
|
51
77
|
];
|
|
52
78
|
var WORDMARK = [
|
|
53
79
|
" \u2588\u2588\u2588\u2588 \u2588\u2588\u2588\u2588\u2588 \u2588\u2588\u2588\u2588 \u2588 \u2588 \u2588 \u2588 \u2588\u2588\u2588\u2588 \u2588\u2588\u2588\u2588\u2588 \u2588 \u2588",
|
|
@@ -95,18 +121,6 @@ async function pathExists(file) {
|
|
|
95
121
|
throw error;
|
|
96
122
|
}
|
|
97
123
|
}
|
|
98
|
-
async function regularDirectory(directory) {
|
|
99
|
-
try {
|
|
100
|
-
await mkdir(directory);
|
|
101
|
-
} catch (error) {
|
|
102
|
-
if (code(error) !== "EEXIST") throw error;
|
|
103
|
-
}
|
|
104
|
-
const info = await lstat(directory);
|
|
105
|
-
if (!info.isDirectory() || info.isSymbolicLink())
|
|
106
|
-
throw new Error(
|
|
107
|
-
`${path.basename(directory)} exists but is not a regular directory.`
|
|
108
|
-
);
|
|
109
|
-
}
|
|
110
124
|
async function createOrKeep(file, contents) {
|
|
111
125
|
try {
|
|
112
126
|
await writeFile(file, contents, { flag: "wx", mode: 420 });
|
|
@@ -151,6 +165,55 @@ ${missing.map((line) => ` ${line}`).join("\n")}
|
|
|
151
165
|
return `updated .gitignore (${missing.join(", ")})
|
|
152
166
|
`;
|
|
153
167
|
}
|
|
168
|
+
async function createStarterFiles(root, say) {
|
|
169
|
+
const directory = path.join(root, "tests");
|
|
170
|
+
try {
|
|
171
|
+
await mkdir(directory);
|
|
172
|
+
} catch (error) {
|
|
173
|
+
if (code(error) !== "EEXIST") throw error;
|
|
174
|
+
}
|
|
175
|
+
const info = await lstat(directory);
|
|
176
|
+
if (!info.isDirectory() || info.isSymbolicLink())
|
|
177
|
+
throw new Error(
|
|
178
|
+
`${path.basename(directory)} exists but is not a regular directory.`
|
|
179
|
+
);
|
|
180
|
+
say(
|
|
181
|
+
`${await createOrKeep(path.join(root, "sedum.config.yaml"), CONFIG)} sedum.config.yaml
|
|
182
|
+
`
|
|
183
|
+
);
|
|
184
|
+
const config = await loadProjectConfig(root);
|
|
185
|
+
const defaultKeyName = {
|
|
186
|
+
typesafe: "TYPESAFE_API_KEY",
|
|
187
|
+
openrouter: "OPENROUTER_API_KEY",
|
|
188
|
+
clef: "CLOUDFLARE_AUTH_TOKEN"
|
|
189
|
+
}[config.providerName];
|
|
190
|
+
const keyName = config.apiKeyEnv ?? defaultKeyName;
|
|
191
|
+
const setup = {
|
|
192
|
+
source: PROVIDER_SETUP[config.providerName].source,
|
|
193
|
+
instructions: PROVIDER_SETUP[config.providerName].instructions.map(
|
|
194
|
+
(line) => line.replaceAll(defaultKeyName, keyName)
|
|
195
|
+
)
|
|
196
|
+
};
|
|
197
|
+
const template = ENV_EXAMPLE.replaceAll(defaultKeyName, keyName);
|
|
198
|
+
const createdExample = await createOrKeep(
|
|
199
|
+
path.join(root, "tests/example.test.ts"),
|
|
200
|
+
EXAMPLE
|
|
201
|
+
);
|
|
202
|
+
say(`${createdExample} tests/example.test.ts
|
|
203
|
+
`);
|
|
204
|
+
const envExample = await createOrKeep(
|
|
205
|
+
path.join(root, ".env.example"),
|
|
206
|
+
template
|
|
207
|
+
);
|
|
208
|
+
say(`${envExample} .env.example
|
|
209
|
+
`);
|
|
210
|
+
return {
|
|
211
|
+
config,
|
|
212
|
+
setup,
|
|
213
|
+
createdExample: createdExample === "created",
|
|
214
|
+
keptEnvExample: envExample === "kept"
|
|
215
|
+
};
|
|
216
|
+
}
|
|
154
217
|
async function executeInitCommand(options) {
|
|
155
218
|
const root = path.resolve(options.cwd);
|
|
156
219
|
const output = [];
|
|
@@ -159,22 +222,8 @@ async function executeInitCommand(options) {
|
|
|
159
222
|
options.onOutput?.(value);
|
|
160
223
|
};
|
|
161
224
|
try {
|
|
162
|
-
let keptEnvExample = false;
|
|
163
|
-
let createdExample = false;
|
|
164
225
|
if (options.interactive && options.color) say(initBanner(options.columns));
|
|
165
|
-
await
|
|
166
|
-
for (const [name, contents] of [
|
|
167
|
-
["sedum.config.yaml", CONFIG],
|
|
168
|
-
["tests/example.test.ts", EXAMPLE],
|
|
169
|
-
[".env.example", ENV_EXAMPLE]
|
|
170
|
-
]) {
|
|
171
|
-
const result = await createOrKeep(path.join(root, name), contents);
|
|
172
|
-
if (name === ".env.example" && result === "kept") keptEnvExample = true;
|
|
173
|
-
if (name === "tests/example.test.ts" && result === "created")
|
|
174
|
-
createdExample = true;
|
|
175
|
-
say(`${result} ${name}
|
|
176
|
-
`);
|
|
177
|
-
}
|
|
226
|
+
const { config, setup, createdExample, keptEnvExample } = await createStarterFiles(root, say);
|
|
178
227
|
say(await updateIgnore(root, options));
|
|
179
228
|
say("\nSedum runs plain-language tests in a browser.\n");
|
|
180
229
|
if (createdExample) {
|
|
@@ -198,19 +247,13 @@ ${++step}. ${title}
|
|
|
198
247
|
};
|
|
199
248
|
if (!supportedNode(options.nodeVersion ?? process.versions.node))
|
|
200
249
|
next("Update Node.js", ["Install Node 20.19.0 or newer."]);
|
|
201
|
-
const config = await loadProjectConfig(root);
|
|
202
250
|
const hasBrowser = (options.browser ?? browserAvailable)(config.browser);
|
|
203
251
|
const hasEnv = await pathExists(path.join(root, ".env"));
|
|
204
252
|
if (!keyPresent(config))
|
|
205
253
|
next("Add a provider API key", [
|
|
206
|
-
|
|
254
|
+
setup.source,
|
|
207
255
|
...hasEnv ? [] : ["cp .env.example .env"],
|
|
208
|
-
...
|
|
209
|
-
"Open .env and set CLOUDFLARE_ACCOUNT_ID and CLOUDFLARE_AUTH_TOKEN (or set them in your shell)."
|
|
210
|
-
] : [
|
|
211
|
-
"Open .env and set TYPESAFE_API_KEY to your key (or set it in your shell).",
|
|
212
|
-
"For a compatible provider, also set TYPESAFE_BASE_URL and use that provider's key as TYPESAFE_API_KEY."
|
|
213
|
-
]
|
|
256
|
+
...setup.instructions
|
|
214
257
|
]);
|
|
215
258
|
if (!hasBrowser)
|
|
216
259
|
next(
|
|
@@ -5,19 +5,22 @@ import {
|
|
|
5
5
|
} from "./chunk-EFRMSNBD.js";
|
|
6
6
|
import {
|
|
7
7
|
discoverRunTests
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-ZAACPFCW.js";
|
|
9
9
|
import {
|
|
10
|
+
createCliProvider
|
|
11
|
+
} from "./chunk-N5CTUO2A.js";
|
|
12
|
+
import {
|
|
13
|
+
DetectorUnsupportedError,
|
|
10
14
|
canonicalDiagnosticError,
|
|
11
|
-
createCliProvider,
|
|
12
15
|
flowDiagnostic,
|
|
13
16
|
outputDiagnostic,
|
|
14
17
|
setupDiagnostic,
|
|
15
18
|
stopsRun
|
|
16
|
-
} from "./chunk-
|
|
19
|
+
} from "./chunk-GJ5QI7JQ.js";
|
|
17
20
|
import {
|
|
18
21
|
ProjectConfigError,
|
|
19
22
|
loadProjectConfig
|
|
20
|
-
} from "./chunk-
|
|
23
|
+
} from "./chunk-OKZ6VJKA.js";
|
|
21
24
|
|
|
22
25
|
// src/run-command/implementation.ts
|
|
23
26
|
import {
|
|
@@ -999,9 +1002,10 @@ async function resolveRunConfig(invocationRoot, options) {
|
|
|
999
1002
|
...options.browser ? { browser: options.browser } : {},
|
|
1000
1003
|
...options.outputDir ? { outputDir: options.outputDir } : {},
|
|
1001
1004
|
...options.reporterDir ? { reporterDir: options.reporterDir } : {},
|
|
1002
|
-
...visionOverride(options)
|
|
1005
|
+
...visionOverride(options),
|
|
1006
|
+
...options.screenshots === void 0 ? {} : { screenshots: options.screenshots }
|
|
1003
1007
|
});
|
|
1004
|
-
|
|
1008
|
+
validateVision(config);
|
|
1005
1009
|
return config;
|
|
1006
1010
|
}
|
|
1007
1011
|
function validateBrowser(invocationRoot, browser) {
|
|
@@ -1043,27 +1047,19 @@ function isValidOverride(value) {
|
|
|
1043
1047
|
}
|
|
1044
1048
|
}
|
|
1045
1049
|
function visionOverride(options) {
|
|
1046
|
-
|
|
1047
|
-
return {};
|
|
1048
|
-
return {
|
|
1049
|
-
vision: {
|
|
1050
|
-
...options.vision !== void 0 ? { enabled: options.vision } : {},
|
|
1051
|
-
...options.visionModel !== void 0 ? { model: options.visionModel } : {}
|
|
1052
|
-
}
|
|
1053
|
-
};
|
|
1050
|
+
return options.vision === void 0 ? {} : { vision: { enabled: options.vision } };
|
|
1054
1051
|
}
|
|
1055
|
-
function
|
|
1056
|
-
if (!config.vision.enabled) return;
|
|
1057
|
-
if (config.visionApiKey) return;
|
|
1052
|
+
function validateVision(config) {
|
|
1053
|
+
if (!config.vision.enabled || config.screenshots) return;
|
|
1058
1054
|
throw new ProjectConfigError([
|
|
1059
1055
|
{
|
|
1060
|
-
code: "
|
|
1061
|
-
file: path7.join(config.projectRoot, ".
|
|
1056
|
+
code: "vision_needs_screenshots",
|
|
1057
|
+
file: config.configPath ?? path7.join(config.projectRoot, "sedum.config.yaml"),
|
|
1062
1058
|
line: 1,
|
|
1063
1059
|
col: 1,
|
|
1064
|
-
key: "
|
|
1065
|
-
message: "Vision fallback
|
|
1066
|
-
fix: "
|
|
1060
|
+
key: "vision.enabled",
|
|
1061
|
+
message: "Vision fallback sends screenshots to the provider, but screenshots are off for this run.",
|
|
1062
|
+
fix: "Use the TypeSafe API with screenshots on (the default there), or turn vision off with --no-vision."
|
|
1067
1063
|
}
|
|
1068
1064
|
]);
|
|
1069
1065
|
}
|
|
@@ -1104,9 +1100,12 @@ function safeDiscoveryText(value, config) {
|
|
|
1104
1100
|
return safeText(
|
|
1105
1101
|
withoutUrls,
|
|
1106
1102
|
{
|
|
1107
|
-
secretValues:
|
|
1108
|
-
|
|
1109
|
-
|
|
1103
|
+
secretValues: [
|
|
1104
|
+
...config.credentialValues ?? [],
|
|
1105
|
+
...Object.values(config.variables).filter(
|
|
1106
|
+
(entry) => typeof entry === "string" && entry.length >= 4
|
|
1107
|
+
)
|
|
1108
|
+
]
|
|
1110
1109
|
},
|
|
1111
1110
|
512
|
|
1112
1111
|
);
|
|
@@ -1116,18 +1115,29 @@ function safeDiscoveryText(value, config) {
|
|
|
1116
1115
|
import {
|
|
1117
1116
|
DEFAULT_PROVIDER_CONCURRENCY,
|
|
1118
1117
|
FileClassificationCache,
|
|
1119
|
-
OpenRouterVisionResolver,
|
|
1120
1118
|
PlaywrightBrowserDriver,
|
|
1121
1119
|
ProviderGate,
|
|
1122
1120
|
ReusableBrowserDriver,
|
|
1123
1121
|
isScriptTestFile,
|
|
1124
|
-
probeOpenRouterKey,
|
|
1125
1122
|
runFlow,
|
|
1126
1123
|
runScriptTest
|
|
1127
1124
|
} from "@sedum-dev/core";
|
|
1128
1125
|
import { availableParallelism } from "os";
|
|
1129
1126
|
import path9 from "path";
|
|
1130
1127
|
import { randomBytes } from "crypto";
|
|
1128
|
+
|
|
1129
|
+
// src/run-command/detector.ts
|
|
1130
|
+
import { BugDetector, isPageInspector } from "@sedum-dev/core";
|
|
1131
|
+
function createDetector(options, provider, providerName) {
|
|
1132
|
+
if (!options.detect || options.detect === "off") return void 0;
|
|
1133
|
+
const allow = options.detectAllow ?? [];
|
|
1134
|
+
if (options.detect === "browser") return new BugDetector({ allow });
|
|
1135
|
+
if (!isPageInspector(provider))
|
|
1136
|
+
throw new DetectorUnsupportedError(providerName);
|
|
1137
|
+
return new BugDetector({ allow, semantic: { inspector: provider } });
|
|
1138
|
+
}
|
|
1139
|
+
|
|
1140
|
+
// src/run-command/tests.ts
|
|
1131
1141
|
async function executeSelectedTests(request) {
|
|
1132
1142
|
const lanes = planLanes(
|
|
1133
1143
|
request.options.parallel ?? 1,
|
|
@@ -1135,12 +1145,16 @@ async function executeSelectedTests(request) {
|
|
|
1135
1145
|
request.files.length
|
|
1136
1146
|
);
|
|
1137
1147
|
const providerConcurrency = request.options.providerConcurrency ?? Math.min(DEFAULT_PROVIDER_CONCURRENCY, lanes * 2);
|
|
1138
|
-
|
|
1139
|
-
|
|
1148
|
+
await selectTests(
|
|
1149
|
+
request,
|
|
1150
|
+
lanes,
|
|
1151
|
+
providerConcurrency,
|
|
1152
|
+
await visionModel(request.config)
|
|
1153
|
+
);
|
|
1140
1154
|
if (request.signal.aborted) throw new Error("canceled");
|
|
1141
1155
|
const gate = new ProviderGate({ concurrency: providerConcurrency });
|
|
1142
1156
|
const resources = await createExecutionResources(request, gate);
|
|
1143
|
-
const driver = new PlaywrightBrowserDriver();
|
|
1157
|
+
const driver = new PlaywrightBrowserDriver({ callerHandlesSignals: true });
|
|
1144
1158
|
const browsers = Array.from(
|
|
1145
1159
|
{ length: lanes },
|
|
1146
1160
|
() => new ReusableBrowserDriver(driver)
|
|
@@ -1164,13 +1178,12 @@ async function executeSelectedTests(request) {
|
|
|
1164
1178
|
}
|
|
1165
1179
|
return outcome;
|
|
1166
1180
|
}
|
|
1167
|
-
async function
|
|
1181
|
+
async function visionModel(config) {
|
|
1168
1182
|
if (!config.vision.enabled) return null;
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
).catch(() => "unreachable");
|
|
1183
|
+
const { IMAGE_MODEL } = await import("@sedum-dev/provider-typesafe");
|
|
1184
|
+
return IMAGE_MODEL;
|
|
1172
1185
|
}
|
|
1173
|
-
async function selectTests(request, lanes, providerConcurrency,
|
|
1186
|
+
async function selectTests(request, lanes, providerConcurrency, visionModel2) {
|
|
1174
1187
|
await request.recorder.selectTests(request.files.length, {
|
|
1175
1188
|
parallel: { requested: request.options.parallel ?? 1, lanes },
|
|
1176
1189
|
shard: request.options.shard ? {
|
|
@@ -1178,15 +1191,18 @@ async function selectTests(request, lanes, providerConcurrency, visionKey) {
|
|
|
1178
1191
|
globalSelectedTests: request.globalSelectedTests
|
|
1179
1192
|
} : null,
|
|
1180
1193
|
providerConcurrency,
|
|
1181
|
-
...
|
|
1194
|
+
...visionModel2 ? { vision: { model: visionModel2 } } : {}
|
|
1182
1195
|
});
|
|
1183
1196
|
if (request.discoveryProblems.length)
|
|
1184
1197
|
await request.recorder.addDiscoveryProblems(request.discoveryProblems);
|
|
1185
1198
|
}
|
|
1186
1199
|
async function createExecutionResources(request, gate) {
|
|
1187
1200
|
const { config, options } = request;
|
|
1201
|
+
const provider = await createCliProvider(config, { gate });
|
|
1202
|
+
const detector = createDetector(options, provider, config.providerName);
|
|
1188
1203
|
return {
|
|
1189
|
-
provider
|
|
1204
|
+
provider,
|
|
1205
|
+
...detector ? { detector } : {},
|
|
1190
1206
|
classificationCache: await FileClassificationCache.load(
|
|
1191
1207
|
path9.join(config.projectRoot, ".sedum", "classifications.json"),
|
|
1192
1208
|
config.providerModel,
|
|
@@ -1197,13 +1213,19 @@ async function createExecutionResources(request, gate) {
|
|
|
1197
1213
|
ciOptIn: options.locatorCacheCi ?? false,
|
|
1198
1214
|
env: process.env
|
|
1199
1215
|
}),
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1216
|
+
screenshots: screenshotOptions(config, provider),
|
|
1217
|
+
...visionOption(config, provider)
|
|
1218
|
+
};
|
|
1219
|
+
}
|
|
1220
|
+
function visionOption(config, provider) {
|
|
1221
|
+
return config.vision.enabled && config.screenshots && "chooseFromScreenshot" in provider ? { visionResolver: provider } : {};
|
|
1222
|
+
}
|
|
1223
|
+
function screenshotOptions(config, provider) {
|
|
1224
|
+
if (!config.screenshots || !("checkTarget" in provider))
|
|
1225
|
+
return { judge: false };
|
|
1226
|
+
return {
|
|
1227
|
+
targetChecker: provider,
|
|
1228
|
+
judge: true
|
|
1207
1229
|
};
|
|
1208
1230
|
}
|
|
1209
1231
|
async function runSelectedTest(request, resources, slot, outcome) {
|
|
@@ -1242,6 +1264,8 @@ function testDependencies(request, resources, slot) {
|
|
|
1242
1264
|
classificationCache: resources.classificationCache,
|
|
1243
1265
|
locatorCache: resources.locatorCache,
|
|
1244
1266
|
...resources.visionResolver ? { visionResolver: resources.visionResolver } : {},
|
|
1267
|
+
...resources.detector ? { detector: resources.detector } : {},
|
|
1268
|
+
screenshots: resources.screenshots,
|
|
1245
1269
|
env: {
|
|
1246
1270
|
...config.variables,
|
|
1247
1271
|
SEDUM_PARALLEL_INDEX: String(lane),
|
|
@@ -1262,7 +1286,7 @@ function testDependencies(request, resources, slot) {
|
|
|
1262
1286
|
recorder: request.recorder,
|
|
1263
1287
|
slot: { ordinal, lane },
|
|
1264
1288
|
privacy: {
|
|
1265
|
-
secretValues: [],
|
|
1289
|
+
secretValues: [...config.credentialValues ?? []],
|
|
1266
1290
|
sensitiveOrigins: options.sensitiveOrigins
|
|
1267
1291
|
},
|
|
1268
1292
|
evidenceEnabled: options.evidence,
|
|
@@ -1273,7 +1297,11 @@ function testDependencies(request, resources, slot) {
|
|
|
1273
1297
|
}
|
|
1274
1298
|
async function handleOperationalFailure(request, slot, result, outcome) {
|
|
1275
1299
|
await slot.browser.recycle();
|
|
1276
|
-
const diagnostic = flowDiagnostic(
|
|
1300
|
+
const diagnostic = flowDiagnostic(
|
|
1301
|
+
result,
|
|
1302
|
+
request.config.providerName,
|
|
1303
|
+
request.config.apiKeyEnv
|
|
1304
|
+
);
|
|
1277
1305
|
outcome.operational ??= diagnostic;
|
|
1278
1306
|
if (stopsRun(result.code)) return "stop";
|
|
1279
1307
|
outcome.erroredTests += 1;
|
|
@@ -1543,7 +1571,7 @@ async function handleRunError(execution, error) {
|
|
|
1543
1571
|
if (error instanceof ReporterOutputError) return session.reporterFailure();
|
|
1544
1572
|
if (error instanceof ProgressWriterError)
|
|
1545
1573
|
return progressWriteFailure(session, error);
|
|
1546
|
-
const diagnostic = deadline.signal.aborted ? interruptionConclusion(deadline.timedOut).diagnostic : setupDiagnostic(error, config.providerName);
|
|
1574
|
+
const diagnostic = deadline.signal.aborted ? interruptionConclusion(deadline.timedOut).diagnostic : setupDiagnostic(error, config.providerName, config.apiKeyEnv);
|
|
1547
1575
|
return finishUnexpectedError(session, deadline, diagnostic);
|
|
1548
1576
|
}
|
|
1549
1577
|
async function progressWriteFailure(session, error) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "sedum-cli",
|
|
3
|
-
"version": "0.1.0-alpha.
|
|
3
|
+
"version": "0.1.0-alpha.17",
|
|
4
4
|
"description": "Plain-English browser tests on Playwright. Write steps as sentences, keep TypeScript, and run the suite on every pull request.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"playwright",
|
|
@@ -43,10 +43,10 @@
|
|
|
43
43
|
"commander": "14.0.2",
|
|
44
44
|
"minimatch": "10.2.6",
|
|
45
45
|
"yaml": "2.9.1",
|
|
46
|
-
"@sedum-dev/core": "0.1.0-alpha.
|
|
47
|
-
"@sedum-dev/provider-
|
|
48
|
-
"@sedum-dev/
|
|
49
|
-
"@sedum-dev/
|
|
46
|
+
"@sedum-dev/core": "0.1.0-alpha.17",
|
|
47
|
+
"@sedum-dev/provider-typesafe": "0.1.0-alpha.17",
|
|
48
|
+
"@sedum-dev/reporters": "0.1.0-alpha.17",
|
|
49
|
+
"@sedum-dev/provider-clef": "0.1.0-alpha.17"
|
|
50
50
|
},
|
|
51
51
|
"scripts": {
|
|
52
52
|
"build": "tsup src/index.ts src/cli.ts --format esm --dts --clean --out-dir dist",
|