sedum-cli 0.1.0-alpha.12 → 0.1.0-alpha.18
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-DAQPGKOZ.js} +6 -6
- package/dist/{chunk-AWBC7NOM.js → chunk-6ILFLNDI.js} +50 -2
- package/dist/{chunk-HT6BIET2.js → chunk-EPXLY5Q4.js} +188 -38
- package/dist/chunk-FG46OUHT.js +538 -0
- package/dist/{chunk-FAGJCNV7.js → chunk-KZF4NZ6M.js} +348 -49
- package/dist/chunk-N5CTUO2A.js +27 -0
- package/dist/{chunk-HXQDSNLL.js → chunk-SI2F6MBN.js} +26 -47
- package/dist/cli.js +4 -3
- package/dist/{doctor-command-F4Y5KW36.js → doctor-command-7IBKI5YO.js} +2 -2
- package/dist/explore-command-QZCKFDYM.js +25 -0
- package/dist/index.d.ts +21 -11
- package/dist/index.js +4 -3
- package/dist/{init-command-62IUO5LA.js → init-command-MBTLGU5J.js} +80 -38
- package/dist/{run-command-ZEIANJWZ.js → run-command-P55TKTX3.js} +76 -50
- package/package.json +5 -5
- package/dist/chunk-S7OB3JEF.js +0 -208
|
@@ -5,19 +5,20 @@ import {
|
|
|
5
5
|
} from "./chunk-EFRMSNBD.js";
|
|
6
6
|
import {
|
|
7
7
|
discoverRunTests
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-6ILFLNDI.js";
|
|
9
9
|
import {
|
|
10
|
+
createCliProvider
|
|
11
|
+
} from "./chunk-N5CTUO2A.js";
|
|
12
|
+
import {
|
|
13
|
+
DetectorUnsupportedError,
|
|
14
|
+
ProjectConfigError,
|
|
10
15
|
canonicalDiagnosticError,
|
|
11
|
-
createCliProvider,
|
|
12
16
|
flowDiagnostic,
|
|
17
|
+
loadProjectConfig,
|
|
13
18
|
outputDiagnostic,
|
|
14
19
|
setupDiagnostic,
|
|
15
20
|
stopsRun
|
|
16
|
-
} from "./chunk-
|
|
17
|
-
import {
|
|
18
|
-
ProjectConfigError,
|
|
19
|
-
loadProjectConfig
|
|
20
|
-
} from "./chunk-FAGJCNV7.js";
|
|
21
|
+
} from "./chunk-KZF4NZ6M.js";
|
|
21
22
|
|
|
22
23
|
// src/run-command/implementation.ts
|
|
23
24
|
import {
|
|
@@ -999,9 +1000,10 @@ async function resolveRunConfig(invocationRoot, options) {
|
|
|
999
1000
|
...options.browser ? { browser: options.browser } : {},
|
|
1000
1001
|
...options.outputDir ? { outputDir: options.outputDir } : {},
|
|
1001
1002
|
...options.reporterDir ? { reporterDir: options.reporterDir } : {},
|
|
1002
|
-
...visionOverride(options)
|
|
1003
|
+
...visionOverride(options),
|
|
1004
|
+
...options.screenshots === void 0 ? {} : { screenshots: options.screenshots }
|
|
1003
1005
|
});
|
|
1004
|
-
|
|
1006
|
+
validateVision(config);
|
|
1005
1007
|
return config;
|
|
1006
1008
|
}
|
|
1007
1009
|
function validateBrowser(invocationRoot, browser) {
|
|
@@ -1043,27 +1045,19 @@ function isValidOverride(value) {
|
|
|
1043
1045
|
}
|
|
1044
1046
|
}
|
|
1045
1047
|
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
|
-
};
|
|
1048
|
+
return options.vision === void 0 ? {} : { vision: { enabled: options.vision } };
|
|
1054
1049
|
}
|
|
1055
|
-
function
|
|
1056
|
-
if (!config.vision.enabled) return;
|
|
1057
|
-
if (config.visionApiKey) return;
|
|
1050
|
+
function validateVision(config) {
|
|
1051
|
+
if (!config.vision.enabled || config.screenshots) return;
|
|
1058
1052
|
throw new ProjectConfigError([
|
|
1059
1053
|
{
|
|
1060
|
-
code: "
|
|
1061
|
-
file: path7.join(config.projectRoot, ".
|
|
1054
|
+
code: "vision_needs_screenshots",
|
|
1055
|
+
file: config.configPath ?? path7.join(config.projectRoot, "sedum.config.yaml"),
|
|
1062
1056
|
line: 1,
|
|
1063
1057
|
col: 1,
|
|
1064
|
-
key: "
|
|
1065
|
-
message: "Vision fallback
|
|
1066
|
-
fix: "
|
|
1058
|
+
key: "vision.enabled",
|
|
1059
|
+
message: "Vision fallback sends screenshots to the provider, but screenshots are off for this run.",
|
|
1060
|
+
fix: "Use the TypeSafe API with screenshots on (the default there), or turn vision off with --no-vision."
|
|
1067
1061
|
}
|
|
1068
1062
|
]);
|
|
1069
1063
|
}
|
|
@@ -1104,9 +1098,12 @@ function safeDiscoveryText(value, config) {
|
|
|
1104
1098
|
return safeText(
|
|
1105
1099
|
withoutUrls,
|
|
1106
1100
|
{
|
|
1107
|
-
secretValues:
|
|
1108
|
-
|
|
1109
|
-
|
|
1101
|
+
secretValues: [
|
|
1102
|
+
...config.credentialValues ?? [],
|
|
1103
|
+
...Object.values(config.variables).filter(
|
|
1104
|
+
(entry) => typeof entry === "string" && entry.length >= 4
|
|
1105
|
+
)
|
|
1106
|
+
]
|
|
1110
1107
|
},
|
|
1111
1108
|
512
|
|
1112
1109
|
);
|
|
@@ -1116,18 +1113,29 @@ function safeDiscoveryText(value, config) {
|
|
|
1116
1113
|
import {
|
|
1117
1114
|
DEFAULT_PROVIDER_CONCURRENCY,
|
|
1118
1115
|
FileClassificationCache,
|
|
1119
|
-
OpenRouterVisionResolver,
|
|
1120
1116
|
PlaywrightBrowserDriver,
|
|
1121
1117
|
ProviderGate,
|
|
1122
1118
|
ReusableBrowserDriver,
|
|
1123
1119
|
isScriptTestFile,
|
|
1124
|
-
probeOpenRouterKey,
|
|
1125
1120
|
runFlow,
|
|
1126
1121
|
runScriptTest
|
|
1127
1122
|
} from "@sedum-dev/core";
|
|
1128
1123
|
import { availableParallelism } from "os";
|
|
1129
1124
|
import path9 from "path";
|
|
1130
1125
|
import { randomBytes } from "crypto";
|
|
1126
|
+
|
|
1127
|
+
// src/run-command/detector.ts
|
|
1128
|
+
import { BugDetector, isPageInspector } from "@sedum-dev/core";
|
|
1129
|
+
function createDetector(options, provider, providerName) {
|
|
1130
|
+
if (!options.detect || options.detect === "off") return void 0;
|
|
1131
|
+
const allow = options.detectAllow ?? [];
|
|
1132
|
+
if (options.detect === "browser") return new BugDetector({ allow });
|
|
1133
|
+
if (!isPageInspector(provider))
|
|
1134
|
+
throw new DetectorUnsupportedError(providerName);
|
|
1135
|
+
return new BugDetector({ allow, semantic: { inspector: provider } });
|
|
1136
|
+
}
|
|
1137
|
+
|
|
1138
|
+
// src/run-command/tests.ts
|
|
1131
1139
|
async function executeSelectedTests(request) {
|
|
1132
1140
|
const lanes = planLanes(
|
|
1133
1141
|
request.options.parallel ?? 1,
|
|
@@ -1135,12 +1143,16 @@ async function executeSelectedTests(request) {
|
|
|
1135
1143
|
request.files.length
|
|
1136
1144
|
);
|
|
1137
1145
|
const providerConcurrency = request.options.providerConcurrency ?? Math.min(DEFAULT_PROVIDER_CONCURRENCY, lanes * 2);
|
|
1138
|
-
|
|
1139
|
-
|
|
1146
|
+
await selectTests(
|
|
1147
|
+
request,
|
|
1148
|
+
lanes,
|
|
1149
|
+
providerConcurrency,
|
|
1150
|
+
await visionModel(request.config)
|
|
1151
|
+
);
|
|
1140
1152
|
if (request.signal.aborted) throw new Error("canceled");
|
|
1141
1153
|
const gate = new ProviderGate({ concurrency: providerConcurrency });
|
|
1142
1154
|
const resources = await createExecutionResources(request, gate);
|
|
1143
|
-
const driver = new PlaywrightBrowserDriver();
|
|
1155
|
+
const driver = new PlaywrightBrowserDriver({ callerHandlesSignals: true });
|
|
1144
1156
|
const browsers = Array.from(
|
|
1145
1157
|
{ length: lanes },
|
|
1146
1158
|
() => new ReusableBrowserDriver(driver)
|
|
@@ -1164,13 +1176,12 @@ async function executeSelectedTests(request) {
|
|
|
1164
1176
|
}
|
|
1165
1177
|
return outcome;
|
|
1166
1178
|
}
|
|
1167
|
-
async function
|
|
1179
|
+
async function visionModel(config) {
|
|
1168
1180
|
if (!config.vision.enabled) return null;
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
).catch(() => "unreachable");
|
|
1181
|
+
const { IMAGE_MODEL } = await import("@sedum-dev/provider-typesafe");
|
|
1182
|
+
return IMAGE_MODEL;
|
|
1172
1183
|
}
|
|
1173
|
-
async function selectTests(request, lanes, providerConcurrency,
|
|
1184
|
+
async function selectTests(request, lanes, providerConcurrency, visionModel2) {
|
|
1174
1185
|
await request.recorder.selectTests(request.files.length, {
|
|
1175
1186
|
parallel: { requested: request.options.parallel ?? 1, lanes },
|
|
1176
1187
|
shard: request.options.shard ? {
|
|
@@ -1178,15 +1189,18 @@ async function selectTests(request, lanes, providerConcurrency, visionKey) {
|
|
|
1178
1189
|
globalSelectedTests: request.globalSelectedTests
|
|
1179
1190
|
} : null,
|
|
1180
1191
|
providerConcurrency,
|
|
1181
|
-
...
|
|
1192
|
+
...visionModel2 ? { vision: { model: visionModel2 } } : {}
|
|
1182
1193
|
});
|
|
1183
1194
|
if (request.discoveryProblems.length)
|
|
1184
1195
|
await request.recorder.addDiscoveryProblems(request.discoveryProblems);
|
|
1185
1196
|
}
|
|
1186
1197
|
async function createExecutionResources(request, gate) {
|
|
1187
1198
|
const { config, options } = request;
|
|
1199
|
+
const provider = await createCliProvider(config, { gate });
|
|
1200
|
+
const detector = createDetector(options, provider, config.providerName);
|
|
1188
1201
|
return {
|
|
1189
|
-
provider
|
|
1202
|
+
provider,
|
|
1203
|
+
...detector ? { detector } : {},
|
|
1190
1204
|
classificationCache: await FileClassificationCache.load(
|
|
1191
1205
|
path9.join(config.projectRoot, ".sedum", "classifications.json"),
|
|
1192
1206
|
config.providerModel,
|
|
@@ -1197,13 +1211,19 @@ async function createExecutionResources(request, gate) {
|
|
|
1197
1211
|
ciOptIn: options.locatorCacheCi ?? false,
|
|
1198
1212
|
env: process.env
|
|
1199
1213
|
}),
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1214
|
+
screenshots: screenshotOptions(config, provider),
|
|
1215
|
+
...visionOption(config, provider)
|
|
1216
|
+
};
|
|
1217
|
+
}
|
|
1218
|
+
function visionOption(config, provider) {
|
|
1219
|
+
return config.vision.enabled && config.screenshots && "chooseFromScreenshot" in provider ? { visionResolver: provider } : {};
|
|
1220
|
+
}
|
|
1221
|
+
function screenshotOptions(config, provider) {
|
|
1222
|
+
if (!config.screenshots || !("checkTarget" in provider))
|
|
1223
|
+
return { judge: false };
|
|
1224
|
+
return {
|
|
1225
|
+
targetChecker: provider,
|
|
1226
|
+
judge: true
|
|
1207
1227
|
};
|
|
1208
1228
|
}
|
|
1209
1229
|
async function runSelectedTest(request, resources, slot, outcome) {
|
|
@@ -1242,6 +1262,8 @@ function testDependencies(request, resources, slot) {
|
|
|
1242
1262
|
classificationCache: resources.classificationCache,
|
|
1243
1263
|
locatorCache: resources.locatorCache,
|
|
1244
1264
|
...resources.visionResolver ? { visionResolver: resources.visionResolver } : {},
|
|
1265
|
+
...resources.detector ? { detector: resources.detector } : {},
|
|
1266
|
+
screenshots: resources.screenshots,
|
|
1245
1267
|
env: {
|
|
1246
1268
|
...config.variables,
|
|
1247
1269
|
SEDUM_PARALLEL_INDEX: String(lane),
|
|
@@ -1262,7 +1284,7 @@ function testDependencies(request, resources, slot) {
|
|
|
1262
1284
|
recorder: request.recorder,
|
|
1263
1285
|
slot: { ordinal, lane },
|
|
1264
1286
|
privacy: {
|
|
1265
|
-
secretValues: [],
|
|
1287
|
+
secretValues: [...config.credentialValues ?? []],
|
|
1266
1288
|
sensitiveOrigins: options.sensitiveOrigins
|
|
1267
1289
|
},
|
|
1268
1290
|
evidenceEnabled: options.evidence,
|
|
@@ -1273,7 +1295,11 @@ function testDependencies(request, resources, slot) {
|
|
|
1273
1295
|
}
|
|
1274
1296
|
async function handleOperationalFailure(request, slot, result, outcome) {
|
|
1275
1297
|
await slot.browser.recycle();
|
|
1276
|
-
const diagnostic = flowDiagnostic(
|
|
1298
|
+
const diagnostic = flowDiagnostic(
|
|
1299
|
+
result,
|
|
1300
|
+
request.config.providerName,
|
|
1301
|
+
request.config.apiKeyEnv
|
|
1302
|
+
);
|
|
1277
1303
|
outcome.operational ??= diagnostic;
|
|
1278
1304
|
if (stopsRun(result.code)) return "stop";
|
|
1279
1305
|
outcome.erroredTests += 1;
|
|
@@ -1543,7 +1569,7 @@ async function handleRunError(execution, error) {
|
|
|
1543
1569
|
if (error instanceof ReporterOutputError) return session.reporterFailure();
|
|
1544
1570
|
if (error instanceof ProgressWriterError)
|
|
1545
1571
|
return progressWriteFailure(session, error);
|
|
1546
|
-
const diagnostic = deadline.signal.aborted ? interruptionConclusion(deadline.timedOut).diagnostic : setupDiagnostic(error, config.providerName);
|
|
1572
|
+
const diagnostic = deadline.signal.aborted ? interruptionConclusion(deadline.timedOut).diagnostic : setupDiagnostic(error, config.providerName, config.apiKeyEnv);
|
|
1547
1573
|
return finishUnexpectedError(session, deadline, diagnostic);
|
|
1548
1574
|
}
|
|
1549
1575
|
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.18",
|
|
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-clef": "0.1.0-alpha.
|
|
48
|
-
"@sedum-dev/provider-typesafe": "0.1.0-alpha.
|
|
49
|
-
"@sedum-dev/reporters": "0.1.0-alpha.
|
|
46
|
+
"@sedum-dev/core": "0.1.0-alpha.18",
|
|
47
|
+
"@sedum-dev/provider-clef": "0.1.0-alpha.18",
|
|
48
|
+
"@sedum-dev/provider-typesafe": "0.1.0-alpha.18",
|
|
49
|
+
"@sedum-dev/reporters": "0.1.0-alpha.18"
|
|
50
50
|
},
|
|
51
51
|
"scripts": {
|
|
52
52
|
"build": "tsup src/index.ts src/cli.ts --format esm --dts --clean --out-dir dist",
|
package/dist/chunk-S7OB3JEF.js
DELETED
|
@@ -1,208 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
ProjectConfigError
|
|
3
|
-
} from "./chunk-FAGJCNV7.js";
|
|
4
|
-
|
|
5
|
-
// src/diagnostics.ts
|
|
6
|
-
import { BrowserDriverError, ProviderError } from "@sedum-dev/core";
|
|
7
|
-
function providerDiagnostic(providerName, code) {
|
|
8
|
-
if (providerName === "clef")
|
|
9
|
-
return code === "authentication" ? {
|
|
10
|
-
code: "provider_authentication",
|
|
11
|
-
message: "Cloudflare rejected the configured API token.",
|
|
12
|
-
fix: "Check CLOUDFLARE_ACCOUNT_ID, replace CLOUDFLARE_AUTH_TOKEN (or CLOUDFLARE_API_TOKEN) with a token for that account that has Workers AI Read and Edit permissions, run `sedum doctor`, then rerun."
|
|
13
|
-
} : {
|
|
14
|
-
code: "provider_configuration",
|
|
15
|
-
message: "The Cloudflare Clef provider is not configured correctly.",
|
|
16
|
-
fix: "Set CLOUDFLARE_ACCOUNT_ID and CLOUDFLARE_AUTH_TOKEN (or CLOUDFLARE_API_TOKEN), then check the account, Workers AI access, and model with `sedum doctor`."
|
|
17
|
-
};
|
|
18
|
-
return code === "authentication" ? {
|
|
19
|
-
code: "provider_authentication",
|
|
20
|
-
message: "The model provider rejected the API key.",
|
|
21
|
-
fix: "Set TYPESAFE_API_KEY to a valid key, check it with `sedum doctor`, then rerun."
|
|
22
|
-
} : {
|
|
23
|
-
code: "provider_configuration",
|
|
24
|
-
message: "The model provider is not configured correctly.",
|
|
25
|
-
fix: "Check TYPESAFE_API_KEY, TYPESAFE_BASE_URL and the model with `sedum doctor`, then rerun."
|
|
26
|
-
};
|
|
27
|
-
}
|
|
28
|
-
function setupDiagnostic(error, providerName = "typesafe") {
|
|
29
|
-
if (error instanceof ProjectConfigError) return configDiagnostic(error);
|
|
30
|
-
if (error instanceof ProviderError && error.code === "configuration")
|
|
31
|
-
return providerName === "clef" ? providerDiagnostic(providerName, "configuration") : {
|
|
32
|
-
code: "missing_key",
|
|
33
|
-
message: "The model provider is not configured.",
|
|
34
|
-
fix: "Set TYPESAFE_API_KEY for the configured endpoint, then rerun the command."
|
|
35
|
-
};
|
|
36
|
-
if (error instanceof BrowserDriverError && error.code === "browser-missing")
|
|
37
|
-
return {
|
|
38
|
-
code: "browser_missing",
|
|
39
|
-
message: "No supported browser binary was found.",
|
|
40
|
-
fix: "Run `sedum browsers install chromium`, then rerun the test."
|
|
41
|
-
};
|
|
42
|
-
return {
|
|
43
|
-
code: "setup_or_output_error",
|
|
44
|
-
message: "The run could not be prepared safely.",
|
|
45
|
-
fix: "Check the test path, provider key, browser installation, and write access, then rerun."
|
|
46
|
-
};
|
|
47
|
-
}
|
|
48
|
-
function configDiagnostic(error) {
|
|
49
|
-
const first = error.diagnostics[0];
|
|
50
|
-
if (!first)
|
|
51
|
-
return {
|
|
52
|
-
code: "invalid_config",
|
|
53
|
-
message: "The Sedum configuration is invalid.",
|
|
54
|
-
fix: "Correct sedum.config.yaml and rerun the command."
|
|
55
|
-
};
|
|
56
|
-
return {
|
|
57
|
-
code: first.code,
|
|
58
|
-
message: bounded(
|
|
59
|
-
`${first.file}:${first.line}:${first.col}: ${first.message} (key: ${first.key})`
|
|
60
|
-
),
|
|
61
|
-
fix: bounded(first.fix)
|
|
62
|
-
};
|
|
63
|
-
}
|
|
64
|
-
function outputDiagnostic(path) {
|
|
65
|
-
return {
|
|
66
|
-
code: "output_error",
|
|
67
|
-
message: `The run result could not be written to ${path}.`,
|
|
68
|
-
fix: "Make the configured output directory writable and rerun the command."
|
|
69
|
-
};
|
|
70
|
-
}
|
|
71
|
-
function bounded(value, maximum = 512) {
|
|
72
|
-
return [...value].slice(0, maximum).join("");
|
|
73
|
-
}
|
|
74
|
-
function canonicalDiagnosticError(diagnostic) {
|
|
75
|
-
return {
|
|
76
|
-
code: diagnostic.code,
|
|
77
|
-
message: diagnostic.code === "output_error" ? "The run result could not be written." : bounded(diagnostic.message)
|
|
78
|
-
};
|
|
79
|
-
}
|
|
80
|
-
function flowDiagnostic(result, providerName = "typesafe") {
|
|
81
|
-
if (result.code === "invalid_test" || result.code === "unsupported_test" || result.code === "invalid_data") {
|
|
82
|
-
const source = result.source ? `${result.source.file}:${result.source.line}:${result.source.col}: ` : "";
|
|
83
|
-
return {
|
|
84
|
-
code: result.code,
|
|
85
|
-
message: bounded(`${source}${result.message}`),
|
|
86
|
-
fix: bounded(
|
|
87
|
-
result.fix ?? "Fix the reported test input and rerun the command."
|
|
88
|
-
)
|
|
89
|
-
};
|
|
90
|
-
}
|
|
91
|
-
const known = {
|
|
92
|
-
"browser-missing": {
|
|
93
|
-
message: "No supported browser binary was found.",
|
|
94
|
-
fix: "Run `sedum browsers install chromium`, then rerun the test."
|
|
95
|
-
},
|
|
96
|
-
"browser-launch-failed": {
|
|
97
|
-
message: "The browser could not be started safely.",
|
|
98
|
-
fix: "Check the browser installation and permissions, then rerun the test."
|
|
99
|
-
},
|
|
100
|
-
"browser-disconnected": {
|
|
101
|
-
message: "The browser disconnected during the run.",
|
|
102
|
-
fix: "Restart the browser run and check browser stability if it repeats."
|
|
103
|
-
},
|
|
104
|
-
"context-closed": {
|
|
105
|
-
message: "The browser context closed during the run.",
|
|
106
|
-
fix: "Rerun the test and check browser stability if it repeats."
|
|
107
|
-
},
|
|
108
|
-
"page-closed": {
|
|
109
|
-
message: "The browser page closed during the run.",
|
|
110
|
-
fix: "Rerun the test and check whether the tested page closes itself."
|
|
111
|
-
},
|
|
112
|
-
"page-crashed": {
|
|
113
|
-
message: "The browser page crashed during the run.",
|
|
114
|
-
fix: "Rerun the test and check browser resource usage if it repeats."
|
|
115
|
-
},
|
|
116
|
-
"operation-failed": {
|
|
117
|
-
message: "A browser operation could not be completed safely.",
|
|
118
|
-
fix: "Check the named test step and rerun the test."
|
|
119
|
-
},
|
|
120
|
-
"script-missing": {
|
|
121
|
-
message: "The Sedum browser script was unavailable.",
|
|
122
|
-
fix: "Rebuild or reinstall Sedum, then rerun the test."
|
|
123
|
-
}
|
|
124
|
-
};
|
|
125
|
-
const diagnostic = known[result.code];
|
|
126
|
-
if (diagnostic) return { code: result.code, ...diagnostic };
|
|
127
|
-
if (result.code === "navigation_failed")
|
|
128
|
-
return {
|
|
129
|
-
code: result.code,
|
|
130
|
-
message: bounded(result.message),
|
|
131
|
-
fix: bounded(
|
|
132
|
-
result.fix ?? "Check the test's url (or baseUrl), your network or VPN, and that the site is up."
|
|
133
|
-
)
|
|
134
|
-
};
|
|
135
|
-
if (result.code === "provider_rate_limited")
|
|
136
|
-
return {
|
|
137
|
-
code: result.code,
|
|
138
|
-
message: "The model provider kept rate limiting requests for five minutes.",
|
|
139
|
-
fix: "Lower --parallel or --provider-concurrency, or retry later."
|
|
140
|
-
};
|
|
141
|
-
if (result.code === "provider_authentication")
|
|
142
|
-
return providerDiagnostic(providerName, "authentication");
|
|
143
|
-
if (result.code === "provider_configuration")
|
|
144
|
-
return providerDiagnostic(providerName, "configuration");
|
|
145
|
-
if (result.code.startsWith("provider_"))
|
|
146
|
-
return {
|
|
147
|
-
code: result.code,
|
|
148
|
-
message: "The model provider could not complete the run safely.",
|
|
149
|
-
fix: "Check provider availability and the test input, then rerun the test."
|
|
150
|
-
};
|
|
151
|
-
return {
|
|
152
|
-
code: "execution_error",
|
|
153
|
-
message: "The browser run could not be completed safely.",
|
|
154
|
-
fix: "Check the browser, provider, and test input, then rerun the test."
|
|
155
|
-
};
|
|
156
|
-
}
|
|
157
|
-
var RUN_STOPPING_CODES = /* @__PURE__ */ new Set([
|
|
158
|
-
"browser-missing",
|
|
159
|
-
"browser-launch-failed",
|
|
160
|
-
"script-missing",
|
|
161
|
-
"provider_configuration",
|
|
162
|
-
"provider_authentication",
|
|
163
|
-
"provider_rate_limited"
|
|
164
|
-
]);
|
|
165
|
-
function stopsRun(code) {
|
|
166
|
-
return RUN_STOPPING_CODES.has(code);
|
|
167
|
-
}
|
|
168
|
-
function renderDiagnostic(diagnostic) {
|
|
169
|
-
return `${diagnostic.message}
|
|
170
|
-
Fix: ${diagnostic.fix}
|
|
171
|
-
`;
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
// src/provider-factory.ts
|
|
175
|
-
import { ProviderGate } from "@sedum-dev/core";
|
|
176
|
-
async function createCliProvider(config, options = {}) {
|
|
177
|
-
const gate = options.gate ?? new ProviderGate(
|
|
178
|
-
options.concurrency === void 0 ? {} : { concurrency: options.concurrency }
|
|
179
|
-
);
|
|
180
|
-
if (config.providerName === "clef") {
|
|
181
|
-
const { ClefAdapter } = await import("@sedum-dev/provider-clef");
|
|
182
|
-
return new ClefAdapter({
|
|
183
|
-
accountId: config.cloudflareAccountId ?? "",
|
|
184
|
-
apiKey: config.apiKey ?? "",
|
|
185
|
-
model: config.providerModel,
|
|
186
|
-
gate
|
|
187
|
-
});
|
|
188
|
-
}
|
|
189
|
-
const { TypeSafeAdapter } = await import("@sedum-dev/provider-typesafe");
|
|
190
|
-
return new TypeSafeAdapter({
|
|
191
|
-
...config.apiKey ? { apiKey: config.apiKey } : {},
|
|
192
|
-
baseURL: config.providerBaseUrl,
|
|
193
|
-
model: config.providerModel,
|
|
194
|
-
gate
|
|
195
|
-
});
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
export {
|
|
199
|
-
providerDiagnostic,
|
|
200
|
-
setupDiagnostic,
|
|
201
|
-
configDiagnostic,
|
|
202
|
-
outputDiagnostic,
|
|
203
|
-
canonicalDiagnosticError,
|
|
204
|
-
flowDiagnostic,
|
|
205
|
-
stopsRun,
|
|
206
|
-
renderDiagnostic,
|
|
207
|
-
createCliProvider
|
|
208
|
-
};
|