sedum-cli 0.1.0-alpha.11 → 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
|
@@ -1,37 +1,61 @@
|
|
|
1
1
|
import {
|
|
2
2
|
ProjectConfigError
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-OKZ6VJKA.js";
|
|
4
4
|
|
|
5
5
|
// src/diagnostics.ts
|
|
6
6
|
import { BrowserDriverError, ProviderError } from "@sedum-dev/core";
|
|
7
|
-
function providerDiagnostic(
|
|
7
|
+
function providerDiagnostic(provider, code, apiKeyEnv) {
|
|
8
|
+
const providerName = typeof provider === "string" ? provider : provider.providerName;
|
|
9
|
+
if (typeof provider !== "string") apiKeyEnv = provider.apiKeyEnv;
|
|
10
|
+
if (providerName === "openrouter")
|
|
11
|
+
return {
|
|
12
|
+
code: `provider_${code}`,
|
|
13
|
+
message: code === "authentication" ? "OpenRouter rejected the configured API key." : "The OpenRouter decision provider is not configured correctly.",
|
|
14
|
+
fix: `Set ${apiKeyEnv ?? "OPENROUTER_API_KEY (or OPEN_ROUTER_API_KEY)"} to a valid OpenRouter key, check account credits and provider.model with \`sedum doctor\`, then rerun.`
|
|
15
|
+
};
|
|
8
16
|
if (providerName === "clef")
|
|
9
17
|
return code === "authentication" ? {
|
|
10
18
|
code: "provider_authentication",
|
|
11
19
|
message: "Cloudflare rejected the configured API token.",
|
|
12
|
-
fix:
|
|
20
|
+
fix: `Check CLOUDFLARE_ACCOUNT_ID, replace ${apiKeyEnv ?? "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
21
|
} : {
|
|
14
22
|
code: "provider_configuration",
|
|
15
23
|
message: "The Cloudflare Clef provider is not configured correctly.",
|
|
16
|
-
fix:
|
|
24
|
+
fix: `Set CLOUDFLARE_ACCOUNT_ID and ${apiKeyEnv ?? "CLOUDFLARE_AUTH_TOKEN (or CLOUDFLARE_API_TOKEN)"}, then check the account, Workers AI access, and model with \`sedum doctor\`.`
|
|
17
25
|
};
|
|
18
26
|
return code === "authentication" ? {
|
|
19
27
|
code: "provider_authentication",
|
|
20
28
|
message: "The model provider rejected the API key.",
|
|
21
|
-
fix:
|
|
29
|
+
fix: `Set ${apiKeyEnv ?? "TYPESAFE_API_KEY"} to a valid key, check it with \`sedum doctor\`, then rerun.`
|
|
22
30
|
} : {
|
|
23
31
|
code: "provider_configuration",
|
|
24
32
|
message: "The model provider is not configured correctly.",
|
|
25
|
-
fix:
|
|
33
|
+
fix: `Check ${apiKeyEnv ?? "TYPESAFE_API_KEY"}, TYPESAFE_BASE_URL and the model with \`sedum doctor\`, then rerun.`
|
|
26
34
|
};
|
|
27
35
|
}
|
|
28
|
-
|
|
36
|
+
var DetectorUnsupportedError = class extends Error {
|
|
37
|
+
constructor(providerName) {
|
|
38
|
+
super(
|
|
39
|
+
`--detect semantic is not supported by the ${providerName} provider.`
|
|
40
|
+
);
|
|
41
|
+
this.providerName = providerName;
|
|
42
|
+
this.name = "DetectorUnsupportedError";
|
|
43
|
+
}
|
|
44
|
+
providerName;
|
|
45
|
+
};
|
|
46
|
+
function setupDiagnostic(error, providerName = "typesafe", apiKeyEnv) {
|
|
29
47
|
if (error instanceof ProjectConfigError) return configDiagnostic(error);
|
|
48
|
+
if (error instanceof DetectorUnsupportedError)
|
|
49
|
+
return {
|
|
50
|
+
code: "detect_unsupported",
|
|
51
|
+
message: `--detect semantic needs a System One provider; ${error.providerName} cannot answer its page questions.`,
|
|
52
|
+
fix: "Use --detect browser with this provider, or select the TypeSafe or OpenRouter provider."
|
|
53
|
+
};
|
|
30
54
|
if (error instanceof ProviderError && error.code === "configuration")
|
|
31
|
-
return providerName
|
|
55
|
+
return providerName !== "typesafe" ? providerDiagnostic(providerName, "configuration", apiKeyEnv) : {
|
|
32
56
|
code: "missing_key",
|
|
33
57
|
message: "The model provider is not configured.",
|
|
34
|
-
fix:
|
|
58
|
+
fix: `Set ${apiKeyEnv ?? "TYPESAFE_API_KEY"} for the configured endpoint, then rerun the command.`
|
|
35
59
|
};
|
|
36
60
|
if (error instanceof BrowserDriverError && error.code === "browser-missing")
|
|
37
61
|
return {
|
|
@@ -77,7 +101,7 @@ function canonicalDiagnosticError(diagnostic) {
|
|
|
77
101
|
message: diagnostic.code === "output_error" ? "The run result could not be written." : bounded(diagnostic.message)
|
|
78
102
|
};
|
|
79
103
|
}
|
|
80
|
-
function flowDiagnostic(result, providerName = "typesafe") {
|
|
104
|
+
function flowDiagnostic(result, providerName = "typesafe", apiKeyEnv) {
|
|
81
105
|
if (result.code === "invalid_test" || result.code === "unsupported_test" || result.code === "invalid_data") {
|
|
82
106
|
const source = result.source ? `${result.source.file}:${result.source.line}:${result.source.col}: ` : "";
|
|
83
107
|
return {
|
|
@@ -139,9 +163,9 @@ function flowDiagnostic(result, providerName = "typesafe") {
|
|
|
139
163
|
fix: "Lower --parallel or --provider-concurrency, or retry later."
|
|
140
164
|
};
|
|
141
165
|
if (result.code === "provider_authentication")
|
|
142
|
-
return providerDiagnostic(providerName, "authentication");
|
|
166
|
+
return providerDiagnostic(providerName, "authentication", apiKeyEnv);
|
|
143
167
|
if (result.code === "provider_configuration")
|
|
144
|
-
return providerDiagnostic(providerName, "configuration");
|
|
168
|
+
return providerDiagnostic(providerName, "configuration", apiKeyEnv);
|
|
145
169
|
if (result.code.startsWith("provider_"))
|
|
146
170
|
return {
|
|
147
171
|
code: result.code,
|
|
@@ -171,38 +195,14 @@ Fix: ${diagnostic.fix}
|
|
|
171
195
|
`;
|
|
172
196
|
}
|
|
173
197
|
|
|
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
198
|
export {
|
|
199
199
|
providerDiagnostic,
|
|
200
|
+
DetectorUnsupportedError,
|
|
200
201
|
setupDiagnostic,
|
|
201
202
|
configDiagnostic,
|
|
202
203
|
outputDiagnostic,
|
|
203
204
|
canonicalDiagnosticError,
|
|
204
205
|
flowDiagnostic,
|
|
205
206
|
stopsRun,
|
|
206
|
-
renderDiagnostic
|
|
207
|
-
createCliProvider
|
|
207
|
+
renderDiagnostic
|
|
208
208
|
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
// src/provider-factory.ts
|
|
2
|
+
import { ProviderGate } from "@sedum-dev/core";
|
|
3
|
+
async function createCliProvider(config, options = {}) {
|
|
4
|
+
const gate = options.gate ?? new ProviderGate(
|
|
5
|
+
options.concurrency === void 0 ? {} : { concurrency: options.concurrency }
|
|
6
|
+
);
|
|
7
|
+
if (config.providerName === "clef") {
|
|
8
|
+
const { ClefAdapter } = await import("@sedum-dev/provider-clef");
|
|
9
|
+
return new ClefAdapter({
|
|
10
|
+
accountId: config.cloudflareAccountId ?? "",
|
|
11
|
+
apiKey: config.apiKey ?? "",
|
|
12
|
+
model: config.providerModel,
|
|
13
|
+
gate
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
const { TypeSafeAdapter } = await import("@sedum-dev/provider-typesafe");
|
|
17
|
+
return new TypeSafeAdapter({
|
|
18
|
+
apiKey: config.apiKey ?? "",
|
|
19
|
+
baseURL: config.providerBaseUrl,
|
|
20
|
+
model: config.providerModel,
|
|
21
|
+
gate
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export {
|
|
26
|
+
createCliProvider
|
|
27
|
+
};
|
|
@@ -62,11 +62,7 @@ var DEFAULTS = {
|
|
|
62
62
|
},
|
|
63
63
|
outputDir: ".sedum/runs",
|
|
64
64
|
reporterDir: ".sedum/reports",
|
|
65
|
-
vision: {
|
|
66
|
-
enabled: false,
|
|
67
|
-
model: "google/gemini-3.8-flash",
|
|
68
|
-
timeoutMs: 1e4
|
|
69
|
-
}
|
|
65
|
+
vision: { enabled: false }
|
|
70
66
|
};
|
|
71
67
|
var DEFAULT_PROVIDER_BASE_URL = "https://api.typesafe.ai";
|
|
72
68
|
var DEFAULT_PROVIDER_MODEL = "jev-latest";
|
|
@@ -84,15 +80,16 @@ var allowed = {
|
|
|
84
80
|
"variables",
|
|
85
81
|
"environments",
|
|
86
82
|
"vision",
|
|
87
|
-
"provider"
|
|
83
|
+
"provider",
|
|
84
|
+
"screenshots"
|
|
88
85
|
]),
|
|
89
86
|
tests: /* @__PURE__ */ new Set(["directory", "include", "exclude"]),
|
|
90
87
|
affected: /* @__PURE__ */ new Set(["ignore"]),
|
|
91
88
|
viewport: /* @__PURE__ */ new Set(["width", "height"]),
|
|
92
89
|
thresholds: /* @__PURE__ */ new Set(["verify", "lowConfidenceBand", "contradiction"]),
|
|
93
|
-
environment: /* @__PURE__ */ new Set(["baseUrl", "variables"]),
|
|
94
|
-
vision: /* @__PURE__ */ new Set(["enabled"
|
|
95
|
-
provider: /* @__PURE__ */ new Set(["name", "model"])
|
|
90
|
+
environment: /* @__PURE__ */ new Set(["baseUrl", "variables", "provider"]),
|
|
91
|
+
vision: /* @__PURE__ */ new Set(["enabled"]),
|
|
92
|
+
provider: /* @__PURE__ */ new Set(["name", "model", "apiKeyEnv"])
|
|
96
93
|
};
|
|
97
94
|
function source(file, counter, node) {
|
|
98
95
|
const position = counter.linePos(node?.range?.[0] ?? 0);
|
|
@@ -107,20 +104,40 @@ function diagnostic(diagnostics, file, counter, node, key, code, message, fix) {
|
|
|
107
104
|
fix
|
|
108
105
|
});
|
|
109
106
|
}
|
|
107
|
+
var REMOVED_KEYS = {
|
|
108
|
+
"vision.model": "Vision fallback now uses the TypeSafe provider's image model.",
|
|
109
|
+
"vision.timeoutMs": "Vision fallback now uses the TypeSafe provider's request deadline.",
|
|
110
|
+
"vision.apiKeyEnv": "Vision fallback now uses the TypeSafe provider's API key."
|
|
111
|
+
};
|
|
112
|
+
function keyProblem(path2, key, names) {
|
|
113
|
+
const removed = Object.hasOwn(REMOVED_KEYS, path2) ? REMOVED_KEYS[path2] : void 0;
|
|
114
|
+
if (removed)
|
|
115
|
+
return [
|
|
116
|
+
"removed_config_key",
|
|
117
|
+
`Configuration key \`${path2}\` was removed. ${removed}`,
|
|
118
|
+
`Delete \`${path2}\` from ${CONFIG_FILE}.`
|
|
119
|
+
];
|
|
120
|
+
if (names.has(key)) return null;
|
|
121
|
+
return [
|
|
122
|
+
"unknown_config_key",
|
|
123
|
+
`Unknown configuration key \`${path2}\`.`,
|
|
124
|
+
keyFix(key, names)
|
|
125
|
+
];
|
|
126
|
+
}
|
|
110
127
|
function mapUnknownKeys(value, names, prefix, file, counter, diagnostics) {
|
|
111
128
|
if (!isMap(value)) return;
|
|
112
129
|
for (const pair of value.items) {
|
|
113
130
|
const key = String(pair.key);
|
|
114
|
-
|
|
131
|
+
const path2 = prefix ? `${prefix}.${key}` : key;
|
|
132
|
+
const problem = keyProblem(path2, key, names);
|
|
133
|
+
if (problem)
|
|
115
134
|
diagnostic(
|
|
116
135
|
diagnostics,
|
|
117
136
|
file,
|
|
118
137
|
counter,
|
|
119
138
|
pair.key,
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
`Unknown configuration key \`${prefix ? `${prefix}.` : ""}${key}\`.`,
|
|
123
|
-
keyFix(key, names)
|
|
139
|
+
path2,
|
|
140
|
+
...problem
|
|
124
141
|
);
|
|
125
142
|
}
|
|
126
143
|
}
|
|
@@ -165,7 +182,14 @@ function scalarVariables(value, key, diagnostics, file, counter, node) {
|
|
|
165
182
|
}
|
|
166
183
|
const result = {};
|
|
167
184
|
for (const [name, item] of Object.entries(value)) {
|
|
168
|
-
if (
|
|
185
|
+
if ([
|
|
186
|
+
"TYPESAFE_API_KEY",
|
|
187
|
+
"OPENROUTER_API_KEY",
|
|
188
|
+
"OPEN_ROUTER_API_KEY",
|
|
189
|
+
"CLOUDFLARE_ACCOUNT_ID",
|
|
190
|
+
"CLOUDFLARE_AUTH_TOKEN",
|
|
191
|
+
"CLOUDFLARE_API_TOKEN"
|
|
192
|
+
].includes(name)) {
|
|
169
193
|
diagnostic(
|
|
170
194
|
diagnostics,
|
|
171
195
|
file,
|
|
@@ -338,6 +362,15 @@ async function findConfig(start) {
|
|
|
338
362
|
current = parent;
|
|
339
363
|
}
|
|
340
364
|
}
|
|
365
|
+
async function readProjectEnvironment(start) {
|
|
366
|
+
const { root } = await findConfig(start);
|
|
367
|
+
try {
|
|
368
|
+
return parseEnv(await readFile(path.join(root, ".env"), "utf8"));
|
|
369
|
+
} catch (error) {
|
|
370
|
+
if (error.code === "ENOENT") return {};
|
|
371
|
+
throw error;
|
|
372
|
+
}
|
|
373
|
+
}
|
|
341
374
|
function freeze(config) {
|
|
342
375
|
Object.freeze(config.include);
|
|
343
376
|
Object.freeze(config.exclude);
|
|
@@ -347,6 +380,7 @@ function freeze(config) {
|
|
|
347
380
|
Object.freeze(config.thresholds);
|
|
348
381
|
Object.freeze(config.vision);
|
|
349
382
|
Object.freeze(config.variables);
|
|
383
|
+
Object.freeze(config.credentialValues);
|
|
350
384
|
return Object.freeze(config);
|
|
351
385
|
}
|
|
352
386
|
async function loadProjectConfig(start = process.cwd(), hostEnvironment = process.env, overrides = {}, loadOptions = {}) {
|
|
@@ -528,6 +562,7 @@ async function loadProjectConfig(start = process.cwd(), hostEnvironment = proces
|
|
|
528
562
|
const environments = object(raw.environments) ? raw.environments : {};
|
|
529
563
|
const vision = object(raw.vision) ? raw.vision : {};
|
|
530
564
|
const provider = object(raw.provider) ? raw.provider : {};
|
|
565
|
+
const credentialSettings = [["provider", provider]];
|
|
531
566
|
for (const [name, value] of Object.entries(environments)) {
|
|
532
567
|
if (!object(value)) {
|
|
533
568
|
diagnostic(
|
|
@@ -542,6 +577,28 @@ async function loadProjectConfig(start = process.cwd(), hostEnvironment = proces
|
|
|
542
577
|
);
|
|
543
578
|
continue;
|
|
544
579
|
}
|
|
580
|
+
const key = `environments.${name}.provider`;
|
|
581
|
+
const settings = value.provider;
|
|
582
|
+
mapUnknownKeys(
|
|
583
|
+
node(key),
|
|
584
|
+
/* @__PURE__ */ new Set(["apiKeyEnv"]),
|
|
585
|
+
key,
|
|
586
|
+
file,
|
|
587
|
+
counter,
|
|
588
|
+
diagnostics
|
|
589
|
+
);
|
|
590
|
+
if (settings !== void 0 && !object(settings))
|
|
591
|
+
diagnostic(
|
|
592
|
+
diagnostics,
|
|
593
|
+
file,
|
|
594
|
+
counter,
|
|
595
|
+
node(key),
|
|
596
|
+
key,
|
|
597
|
+
"invalid_config_type",
|
|
598
|
+
`Configuration key \`${key}\` must be a mapping.`,
|
|
599
|
+
`Write \`${key}: { apiKeyEnv: MY_API_KEY }\`.`
|
|
600
|
+
);
|
|
601
|
+
if (object(settings)) credentialSettings.push([key, settings]);
|
|
545
602
|
scalarVariables(
|
|
546
603
|
value.variables,
|
|
547
604
|
`environments.${name}.variables`,
|
|
@@ -577,6 +634,22 @@ async function loadProjectConfig(start = process.cwd(), hostEnvironment = proces
|
|
|
577
634
|
`Add \`environments.${selected}\` or choose an existing environment.`
|
|
578
635
|
);
|
|
579
636
|
const environment = object(selectedRaw) ? selectedRaw : {};
|
|
637
|
+
for (const [prefix, settings] of credentialSettings) {
|
|
638
|
+
const value = settings.apiKeyEnv;
|
|
639
|
+
if (value !== void 0 && (typeof value !== "string" || !/^[A-Za-z_][A-Za-z0-9_]*$/u.test(value)))
|
|
640
|
+
diagnostic(
|
|
641
|
+
diagnostics,
|
|
642
|
+
file,
|
|
643
|
+
counter,
|
|
644
|
+
node(`${prefix}.apiKeyEnv`),
|
|
645
|
+
`${prefix}.apiKeyEnv`,
|
|
646
|
+
"invalid_config_env_name",
|
|
647
|
+
`Configuration key \`${prefix}.apiKeyEnv\` must be a valid environment variable name.`,
|
|
648
|
+
"Use letters, digits, and underscores, starting with a letter or underscore."
|
|
649
|
+
);
|
|
650
|
+
}
|
|
651
|
+
const selectedProvider = object(environment.provider) ? environment.provider : {};
|
|
652
|
+
const apiKeyEnv = selectedProvider.apiKeyEnv ?? provider.apiKeyEnv;
|
|
580
653
|
const browserValue = overrides.browser ?? raw.browser ?? DEFAULTS.browser;
|
|
581
654
|
const browser = browserValue === "chrome" || browserValue === "chromium" ? browserValue : DEFAULTS.browser;
|
|
582
655
|
if (browserValue !== "chrome" && browserValue !== "chromium")
|
|
@@ -707,7 +780,11 @@ async function loadProjectConfig(start = process.cwd(), hostEnvironment = proces
|
|
|
707
780
|
...fileEnvironment,
|
|
708
781
|
...hostEnvironment
|
|
709
782
|
};
|
|
710
|
-
const
|
|
783
|
+
const providerEnvironment = new Map([
|
|
784
|
+
...Object.entries(fileEnvironment),
|
|
785
|
+
...Object.entries(hostEnvironment).filter(([, value]) => value?.trim())
|
|
786
|
+
]);
|
|
787
|
+
const providerValue = (name) => providerEnvironment.get(name)?.trim() || void 0;
|
|
711
788
|
const cloudflareTokenFrom = (environment2) => {
|
|
712
789
|
const authToken = environment2.CLOUDFLARE_AUTH_TOKEN?.trim();
|
|
713
790
|
const apiToken = environment2.CLOUDFLARE_API_TOKEN?.trim();
|
|
@@ -724,8 +801,8 @@ async function loadProjectConfig(start = process.cwd(), hostEnvironment = proces
|
|
|
724
801
|
return authToken || apiToken || void 0;
|
|
725
802
|
};
|
|
726
803
|
const providerNameValue = provider.name ?? "typesafe";
|
|
727
|
-
const providerName = providerNameValue === "typesafe" || providerNameValue === "clef" ? providerNameValue : "typesafe";
|
|
728
|
-
if (
|
|
804
|
+
const providerName = providerNameValue === "typesafe" || providerNameValue === "clef" || providerNameValue === "openrouter" ? providerNameValue : "typesafe";
|
|
805
|
+
if (providerName !== providerNameValue)
|
|
729
806
|
diagnostic(
|
|
730
807
|
diagnostics,
|
|
731
808
|
file,
|
|
@@ -733,7 +810,7 @@ async function loadProjectConfig(start = process.cwd(), hostEnvironment = proces
|
|
|
733
810
|
node("provider.name"),
|
|
734
811
|
"provider.name",
|
|
735
812
|
"invalid_config_provider",
|
|
736
|
-
"Configuration key `provider.name` must be `typesafe` or `
|
|
813
|
+
"Configuration key `provider.name` must be `typesafe`, `clef`, or `openrouter`.",
|
|
737
814
|
"Choose one of the supported provider names."
|
|
738
815
|
);
|
|
739
816
|
const configuredModel = provider.model;
|
|
@@ -753,7 +830,7 @@ async function loadProjectConfig(start = process.cwd(), hostEnvironment = proces
|
|
|
753
830
|
baseUrl: providerValue("TYPESAFE_BASE_URL"),
|
|
754
831
|
model: providerValue("TYPESAFE_DEFAULT_MODEL")
|
|
755
832
|
};
|
|
756
|
-
let providerBaseUrl = DEFAULT_PROVIDER_BASE_URL;
|
|
833
|
+
let providerBaseUrl = providerName === "openrouter" ? "https://openrouter.ai/api" : DEFAULT_PROVIDER_BASE_URL;
|
|
757
834
|
if (providerName === "typesafe" && customProvider.baseUrl) {
|
|
758
835
|
try {
|
|
759
836
|
const parsed = new URL(customProvider.baseUrl);
|
|
@@ -772,8 +849,10 @@ async function loadProjectConfig(start = process.cwd(), hostEnvironment = proces
|
|
|
772
849
|
});
|
|
773
850
|
}
|
|
774
851
|
}
|
|
775
|
-
const providerModel = providerName === "clef" ? typeof configuredModel === "string" && validClefModel ? configuredModel : "clef" : typeof configuredModel === "string" && configuredModel.trim() ? configuredModel.trim() : customProvider.model ?? DEFAULT_PROVIDER_MODEL;
|
|
776
|
-
const
|
|
852
|
+
const providerModel = providerName === "clef" ? typeof configuredModel === "string" && validClefModel ? configuredModel : "clef" : typeof configuredModel === "string" && configuredModel.trim() ? configuredModel.trim() : providerName === "openrouter" ? "typesafe/jev-1.13" : customProvider.model ?? DEFAULT_PROVIDER_MODEL;
|
|
853
|
+
const openRouterKeyFrom = (environment2) => environment2.OPENROUTER_API_KEY?.trim() || environment2.OPEN_ROUTER_API_KEY?.trim() || void 0;
|
|
854
|
+
const openRouterKey = openRouterKeyFrom(hostEnvironment) ?? openRouterKeyFrom(fileEnvironment);
|
|
855
|
+
const apiKey = typeof apiKeyEnv === "string" ? providerValue(apiKeyEnv) : providerName === "clef" ? cloudflareTokenFrom(hostEnvironment) ?? cloudflareTokenFrom(fileEnvironment) : providerName === "openrouter" ? openRouterKey : providerValue("TYPESAFE_API_KEY");
|
|
777
856
|
const cloudflareAccountId = providerName === "clef" ? providerValue("CLOUDFLARE_ACCOUNT_ID") : void 0;
|
|
778
857
|
if (providerName === "clef" && cloudflareAccountId !== void 0 && !/^[a-f\d]{32}$/iu.test(cloudflareAccountId))
|
|
779
858
|
diagnostics.push({
|
|
@@ -785,7 +864,38 @@ async function loadProjectConfig(start = process.cwd(), hostEnvironment = proces
|
|
|
785
864
|
message: "CLOUDFLARE_ACCOUNT_ID must be exactly 32 hexadecimal characters.",
|
|
786
865
|
fix: "Copy the account ID from the Cloudflare dashboard."
|
|
787
866
|
});
|
|
788
|
-
const
|
|
867
|
+
const credentialValues = [apiKey].filter((value) => value !== void 0);
|
|
868
|
+
for (const [, settings] of credentialSettings) {
|
|
869
|
+
if (typeof settings.apiKeyEnv !== "string") continue;
|
|
870
|
+
const name = settings.apiKeyEnv;
|
|
871
|
+
for (const source2 of [hostEnvironment, fileEnvironment]) {
|
|
872
|
+
const value = Object.hasOwn(source2, name) ? source2[name] : void 0;
|
|
873
|
+
if (value?.trim()) credentialValues.push(value, value.trim());
|
|
874
|
+
}
|
|
875
|
+
variables[name] = void 0;
|
|
876
|
+
for (const [prefix, values] of [
|
|
877
|
+
["variables", rootVariables],
|
|
878
|
+
...Object.entries(environments).filter(([, value]) => object(value)).map(
|
|
879
|
+
([key, value]) => [
|
|
880
|
+
`environments.${key}.variables`,
|
|
881
|
+
value.variables
|
|
882
|
+
]
|
|
883
|
+
)
|
|
884
|
+
]) {
|
|
885
|
+
if (object(values) && Object.hasOwn(values, name))
|
|
886
|
+
diagnostic(
|
|
887
|
+
diagnostics,
|
|
888
|
+
file,
|
|
889
|
+
counter,
|
|
890
|
+
node(prefix),
|
|
891
|
+
`${prefix}.${name}`,
|
|
892
|
+
"api_key_in_config",
|
|
893
|
+
`${name} must not be stored in sedum.config.yaml.`,
|
|
894
|
+
`Put ${name} in the project-root .env or invoking process environment.`
|
|
895
|
+
);
|
|
896
|
+
}
|
|
897
|
+
}
|
|
898
|
+
variables["OPENROUTER_API_KEY"] = void 0;
|
|
789
899
|
variables.OPEN_ROUTER_API_KEY = void 0;
|
|
790
900
|
variables.CLOUDFLARE_ACCOUNT_ID = void 0;
|
|
791
901
|
variables.CLOUDFLARE_AUTH_TOKEN = void 0;
|
|
@@ -803,31 +913,19 @@ async function loadProjectConfig(start = process.cwd(), hostEnvironment = proces
|
|
|
803
913
|
"Configuration key `vision.enabled` must be a boolean.",
|
|
804
914
|
"Use `vision.enabled: true` or `vision.enabled: false`."
|
|
805
915
|
);
|
|
806
|
-
const
|
|
807
|
-
|
|
808
|
-
if (typeof visionModel !== "string" || !visionModel.trim())
|
|
809
|
-
diagnostic(
|
|
810
|
-
diagnostics,
|
|
811
|
-
file,
|
|
812
|
-
counter,
|
|
813
|
-
node("vision.model"),
|
|
814
|
-
"vision.model",
|
|
815
|
-
"invalid_config_type",
|
|
816
|
-
"Configuration key `vision.model` must be nonempty text.",
|
|
817
|
-
`Use a model such as \`${DEFAULTS.vision.model}\`.`
|
|
818
|
-
);
|
|
819
|
-
const visionTimeoutValue = vision.timeoutMs ?? DEFAULTS.vision.timeoutMs;
|
|
820
|
-
if (!Number.isSafeInteger(visionTimeoutValue) || visionTimeoutValue < 1)
|
|
916
|
+
const screenshotsValue = overrides.screenshots ?? raw.screenshots;
|
|
917
|
+
if (screenshotsValue !== void 0 && typeof screenshotsValue !== "boolean")
|
|
821
918
|
diagnostic(
|
|
822
919
|
diagnostics,
|
|
823
920
|
file,
|
|
824
921
|
counter,
|
|
825
|
-
node("
|
|
826
|
-
"
|
|
922
|
+
node("screenshots"),
|
|
923
|
+
"screenshots",
|
|
827
924
|
"invalid_config_type",
|
|
828
|
-
"Configuration key `
|
|
829
|
-
"Use
|
|
925
|
+
"Configuration key `screenshots` must be a boolean.",
|
|
926
|
+
"Use `screenshots: true` or `screenshots: false`."
|
|
830
927
|
);
|
|
928
|
+
const screenshots = typeof screenshotsValue === "boolean" ? screenshotsValue : providerName === "typesafe" && providerBaseUrl === DEFAULT_PROVIDER_BASE_URL;
|
|
831
929
|
const testDirectory = relativePath(
|
|
832
930
|
found.root,
|
|
833
931
|
tests.directory,
|
|
@@ -894,15 +992,13 @@ async function loadProjectConfig(start = process.cwd(), hostEnvironment = proces
|
|
|
894
992
|
variables,
|
|
895
993
|
providerName,
|
|
896
994
|
apiKey,
|
|
995
|
+
credentialValues,
|
|
996
|
+
...typeof apiKeyEnv === "string" ? { apiKeyEnv } : {},
|
|
897
997
|
cloudflareAccountId,
|
|
898
998
|
providerBaseUrl,
|
|
899
999
|
providerModel,
|
|
900
|
-
vision: {
|
|
901
|
-
|
|
902
|
-
model: typeof visionModel === "string" && visionModel.trim() ? visionModel : DEFAULTS.vision.model,
|
|
903
|
-
timeoutMs: Number.isSafeInteger(visionTimeoutValue) && visionTimeoutValue > 0 ? visionTimeoutValue : DEFAULTS.vision.timeoutMs
|
|
904
|
-
},
|
|
905
|
-
visionApiKey
|
|
1000
|
+
vision: { enabled: visionEnabled === true },
|
|
1001
|
+
screenshots: screenshots && providerName !== "clef"
|
|
906
1002
|
});
|
|
907
1003
|
}
|
|
908
1004
|
async function discoverConfiguredTests(config) {
|
|
@@ -936,6 +1032,7 @@ export {
|
|
|
936
1032
|
ProjectConfigError,
|
|
937
1033
|
DEFAULT_PROVIDER_BASE_URL,
|
|
938
1034
|
DEFAULT_PROVIDER_MODEL,
|
|
1035
|
+
readProjectEnvironment,
|
|
939
1036
|
loadProjectConfig,
|
|
940
1037
|
discoverConfiguredTests
|
|
941
1038
|
};
|
|
@@ -1,14 +1,19 @@
|
|
|
1
1
|
import {
|
|
2
2
|
discoverConfiguredTests
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-OKZ6VJKA.js";
|
|
4
4
|
|
|
5
5
|
// src/run-selection.ts
|
|
6
6
|
import { lstat, realpath } from "fs/promises";
|
|
7
7
|
import path from "path";
|
|
8
8
|
import { minimatch } from "minimatch";
|
|
9
9
|
import {
|
|
10
|
+
classifyParsedFlow,
|
|
11
|
+
displayPath,
|
|
12
|
+
FileClassificationCache,
|
|
10
13
|
listTests,
|
|
11
14
|
loadListingEntries,
|
|
15
|
+
NOT_CHECKED_OFFLINE_CODE,
|
|
16
|
+
resolveFlowModules,
|
|
12
17
|
TEST_SUFFIXES,
|
|
13
18
|
walkSuiteFiles
|
|
14
19
|
} from "@sedum-dev/core";
|
|
@@ -122,10 +127,53 @@ async function discoverRunTests(config, paths, filters = {}) {
|
|
|
122
127
|
const listing = listTests(parsed, { repoRoot: root });
|
|
123
128
|
return {
|
|
124
129
|
tests: selectRunTests(listing.tests, filters),
|
|
125
|
-
invalid: listing.invalid,
|
|
130
|
+
invalid: await withSentenceErrors(listing.invalid, parsed, {
|
|
131
|
+
root,
|
|
132
|
+
cache: await FileClassificationCache.load(
|
|
133
|
+
path.join(root, ".sedum", "classifications.json"),
|
|
134
|
+
config.providerModel,
|
|
135
|
+
config.providerName
|
|
136
|
+
)
|
|
137
|
+
}),
|
|
126
138
|
problems
|
|
127
139
|
};
|
|
128
140
|
}
|
|
141
|
+
var diagnosticKey = (item) => `${item.code}:${item.line}:${item.col}`;
|
|
142
|
+
async function withSentenceErrors(invalid, parsed, options) {
|
|
143
|
+
return Promise.all(
|
|
144
|
+
invalid.map(async (entry) => {
|
|
145
|
+
const found = parsed.find(
|
|
146
|
+
(item) => item.result.candidate !== void 0 && displayPath(options.root, item.file) === entry.file
|
|
147
|
+
);
|
|
148
|
+
if (!found) return entry;
|
|
149
|
+
const resolved = await resolveFlowModules(found.result, {
|
|
150
|
+
repoRoot: options.root,
|
|
151
|
+
partial: true
|
|
152
|
+
});
|
|
153
|
+
const classified = await classifyParsedFlow(resolved, {
|
|
154
|
+
mode: "offline",
|
|
155
|
+
cache: options.cache
|
|
156
|
+
});
|
|
157
|
+
const seen = new Set(entry.diagnostics.map(diagnosticKey));
|
|
158
|
+
const extra = classified.diagnostics.filter(
|
|
159
|
+
(item) => item.severity === "error" && item.code !== NOT_CHECKED_OFFLINE_CODE && item.source.file === found.file
|
|
160
|
+
).map((item) => ({
|
|
161
|
+
severity: item.severity,
|
|
162
|
+
code: item.code,
|
|
163
|
+
line: item.source.line,
|
|
164
|
+
col: item.source.col,
|
|
165
|
+
message: item.message,
|
|
166
|
+
fix: item.fix
|
|
167
|
+
})).filter((item) => !seen.has(diagnosticKey(item)));
|
|
168
|
+
return {
|
|
169
|
+
file: entry.file,
|
|
170
|
+
diagnostics: [...entry.diagnostics, ...extra].sort(
|
|
171
|
+
(a, b) => a.line - b.line || a.col - b.col
|
|
172
|
+
)
|
|
173
|
+
};
|
|
174
|
+
})
|
|
175
|
+
);
|
|
176
|
+
}
|
|
129
177
|
|
|
130
178
|
export {
|
|
131
179
|
discoverRunTests
|
package/dist/cli.js
CHANGED
|
@@ -2,10 +2,12 @@
|
|
|
2
2
|
import {
|
|
3
3
|
runCli,
|
|
4
4
|
sedumCommand
|
|
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-
|
|
8
|
+
import "./chunk-N5CTUO2A.js";
|
|
9
|
+
import "./chunk-GJ5QI7JQ.js";
|
|
10
|
+
import "./chunk-OKZ6VJKA.js";
|
|
9
11
|
|
|
10
12
|
// src/cli.ts
|
|
11
13
|
import { createRequire } from "module";
|
|
@@ -5,8 +5,9 @@ import {
|
|
|
5
5
|
keyPresent,
|
|
6
6
|
renderDoctorText,
|
|
7
7
|
supportedNode
|
|
8
|
-
} from "./chunk-
|
|
9
|
-
import "./chunk-
|
|
8
|
+
} from "./chunk-F4RD4S4P.js";
|
|
9
|
+
import "./chunk-GJ5QI7JQ.js";
|
|
10
|
+
import "./chunk-OKZ6VJKA.js";
|
|
10
11
|
export {
|
|
11
12
|
browserAvailable,
|
|
12
13
|
checkOutputWritable,
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import {
|
|
2
|
+
EXPLORE_MODES,
|
|
3
|
+
collectText,
|
|
4
|
+
executeExploreCommand,
|
|
5
|
+
executeRerunCommand,
|
|
6
|
+
exploreAction,
|
|
7
|
+
exploreMode,
|
|
8
|
+
exploreProvider,
|
|
9
|
+
seedValue,
|
|
10
|
+
startUrl,
|
|
11
|
+
watchOrigin
|
|
12
|
+
} from "./chunk-ACDJLEMS.js";
|
|
13
|
+
import "./chunk-OKZ6VJKA.js";
|
|
14
|
+
export {
|
|
15
|
+
EXPLORE_MODES,
|
|
16
|
+
collectText,
|
|
17
|
+
executeExploreCommand,
|
|
18
|
+
executeRerunCommand,
|
|
19
|
+
exploreAction,
|
|
20
|
+
exploreMode,
|
|
21
|
+
exploreProvider,
|
|
22
|
+
seedValue,
|
|
23
|
+
startUrl,
|
|
24
|
+
watchOrigin
|
|
25
|
+
};
|