sedum-cli 0.1.0-alpha.0 → 0.1.0-alpha.10

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,208 @@
1
+ import {
2
+ ProjectConfigError
3
+ } from "./chunk-VNGIF7AY.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
+ };
@@ -15,7 +15,7 @@ var ProjectConfigError = class extends Error {
15
15
  };
16
16
  var DEFAULTS = {
17
17
  testDirectory: "tests",
18
- include: ["**/*.test.yaml"],
18
+ include: ["**/*.test.ts", "**/*.test.yaml"],
19
19
  exclude: [],
20
20
  browser: "chrome",
21
21
  viewport: { width: 1280, height: 900 },
@@ -25,8 +25,15 @@ var DEFAULTS = {
25
25
  contradictionCutoff: 0.5
26
26
  },
27
27
  outputDir: ".sedum/runs",
28
- reporterDir: ".sedum/reports"
28
+ reporterDir: ".sedum/reports",
29
+ vision: {
30
+ enabled: false,
31
+ model: "google/gemini-3.8-flash",
32
+ timeoutMs: 1e4
33
+ }
29
34
  };
35
+ var DEFAULT_PROVIDER_BASE_URL = "https://api.typesafe.ai";
36
+ var DEFAULT_PROVIDER_MODEL = "jev-latest";
30
37
  var allowed = {
31
38
  root: /* @__PURE__ */ new Set([
32
39
  "tests",
@@ -38,12 +45,16 @@ var allowed = {
38
45
  "baseUrl",
39
46
  "environment",
40
47
  "variables",
41
- "environments"
48
+ "environments",
49
+ "vision",
50
+ "provider"
42
51
  ]),
43
52
  tests: /* @__PURE__ */ new Set(["directory", "include", "exclude"]),
44
53
  viewport: /* @__PURE__ */ new Set(["width", "height"]),
45
54
  thresholds: /* @__PURE__ */ new Set(["verify", "lowConfidenceBand", "contradiction"]),
46
- environment: /* @__PURE__ */ new Set(["baseUrl", "variables"])
55
+ environment: /* @__PURE__ */ new Set(["baseUrl", "variables"]),
56
+ vision: /* @__PURE__ */ new Set(["enabled", "model", "timeoutMs"]),
57
+ provider: /* @__PURE__ */ new Set(["name", "model"])
47
58
  };
48
59
  function source(file, counter, node) {
49
60
  const position = counter.linePos(node?.range?.[0] ?? 0);
@@ -71,10 +82,31 @@ function mapUnknownKeys(value, names, prefix, file, counter, diagnostics) {
71
82
  prefix ? `${prefix}.${key}` : key,
72
83
  "unknown_config_key",
73
84
  `Unknown configuration key \`${prefix ? `${prefix}.` : ""}${key}\`.`,
74
- "Remove the key or use one documented by `sedum run --help`."
85
+ keyFix(key, names)
75
86
  );
76
87
  }
77
88
  }
89
+ function distance(left, right) {
90
+ const row = Array.from({ length: right.length + 1 }, (_, i) => i);
91
+ for (let i = 1; i <= left.length; i++) {
92
+ let previous = row[0];
93
+ row[0] = i;
94
+ for (let j = 1; j <= right.length; j++) {
95
+ const saved = row[j];
96
+ row[j] = Math.min(
97
+ row[j] + 1,
98
+ row[j - 1] + 1,
99
+ previous + (left[i - 1] === right[j - 1] ? 0 : 1)
100
+ );
101
+ previous = saved;
102
+ }
103
+ }
104
+ return row[right.length];
105
+ }
106
+ function keyFix(key, names) {
107
+ const [closest] = [...names].map((known) => ({ known, score: distance(key, known) })).sort((a, b) => a.score - b.score || a.known.localeCompare(b.known));
108
+ return closest && closest.score <= 2 ? `Did you mean \`${closest.known}\`?` : "Remove the key or use one documented in docs/configuration.md.";
109
+ }
78
110
  function object(value) {
79
111
  return value !== null && typeof value === "object" && !Array.isArray(value);
80
112
  }
@@ -95,7 +127,7 @@ function scalarVariables(value, key, diagnostics, file, counter, node) {
95
127
  }
96
128
  const result = {};
97
129
  for (const [name, item] of Object.entries(value)) {
98
- if (name === "TYPESAFE_API_KEY") {
130
+ if (name === "TYPESAFE_API_KEY" || name === "OPEN_ROUTER_API_KEY" || name === "CLOUDFLARE_ACCOUNT_ID" || name === "CLOUDFLARE_AUTH_TOKEN" || name === "CLOUDFLARE_API_TOKEN") {
99
131
  diagnostic(
100
132
  diagnostics,
101
133
  file,
@@ -103,8 +135,8 @@ function scalarVariables(value, key, diagnostics, file, counter, node) {
103
135
  node,
104
136
  `${key}.${name}`,
105
137
  "api_key_in_config",
106
- "TYPESAFE_API_KEY must not be stored in sedum.config.yaml.",
107
- "Put TYPESAFE_API_KEY in the project-root .env or invoking process environment."
138
+ `${name} must not be stored in sedum.config.yaml.`,
139
+ `Put ${name} in the project-root .env or invoking process environment.`
108
140
  );
109
141
  continue;
110
142
  }
@@ -201,7 +233,7 @@ function stringList(value, fallback, key, diagnostics, file, counter, node) {
201
233
  key,
202
234
  "invalid_config_globs",
203
235
  `Configuration key \`${key}\` must be a list of nonempty glob strings.`,
204
- `Write \`${key}: ["**/*.test.yaml"]\`.`
236
+ `Write \`${key}: ["**/*.test.ts", "**/*.test.yaml"]\`.`
205
237
  );
206
238
  return [...fallback];
207
239
  }
@@ -273,6 +305,7 @@ function freeze(config) {
273
305
  Object.freeze(config.exclude);
274
306
  Object.freeze(config.viewport);
275
307
  Object.freeze(config.thresholds);
308
+ Object.freeze(config.vision);
276
309
  Object.freeze(config.variables);
277
310
  return Object.freeze(config);
278
311
  }
@@ -371,7 +404,9 @@ async function loadProjectConfig(start = process.cwd(), hostEnvironment = proces
371
404
  const maps = [
372
405
  ["tests", allowed.tests],
373
406
  ["viewport", allowed.viewport],
374
- ["thresholds", allowed.thresholds]
407
+ ["thresholds", allowed.thresholds],
408
+ ["vision", allowed.vision],
409
+ ["provider", allowed.provider]
375
410
  ];
376
411
  for (const [key, names] of maps)
377
412
  mapUnknownKeys(
@@ -410,7 +445,9 @@ async function loadProjectConfig(start = process.cwd(), hostEnvironment = proces
410
445
  for (const [key, value] of [
411
446
  ["viewport", raw.viewport],
412
447
  ["thresholds", raw.thresholds],
413
- ["environments", raw.environments]
448
+ ["environments", raw.environments],
449
+ ["vision", raw.vision],
450
+ ["provider", raw.provider]
414
451
  ])
415
452
  if (value !== void 0 && !object(value))
416
453
  diagnostic(
@@ -426,6 +463,8 @@ async function loadProjectConfig(start = process.cwd(), hostEnvironment = proces
426
463
  const viewport = object(raw.viewport) ? raw.viewport : {};
427
464
  const thresholds = object(raw.thresholds) ? raw.thresholds : {};
428
465
  const environments = object(raw.environments) ? raw.environments : {};
466
+ const vision = object(raw.vision) ? raw.vision : {};
467
+ const provider = object(raw.provider) ? raw.provider : {};
429
468
  for (const [name, value] of Object.entries(environments)) {
430
469
  if (!object(value)) {
431
470
  diagnostic(
@@ -597,7 +636,7 @@ async function loadProjectConfig(start = process.cwd(), hostEnvironment = proces
597
636
  "tests.include",
598
637
  "empty_config_globs",
599
638
  "Configuration key `tests.include` must select at least one pattern.",
600
- "Add `**/*.test.yaml` or another test glob."
639
+ "Add `**/*.test.ts` or another test glob."
601
640
  );
602
641
  const variables = {
603
642
  ...rootVariables,
@@ -605,7 +644,127 @@ async function loadProjectConfig(start = process.cwd(), hostEnvironment = proces
605
644
  ...fileEnvironment,
606
645
  ...hostEnvironment
607
646
  };
608
- const apiKey = hostEnvironment.TYPESAFE_API_KEY?.trim() || fileEnvironment.TYPESAFE_API_KEY?.trim() || void 0;
647
+ const providerValue = (name) => hostEnvironment[name]?.trim() || fileEnvironment[name]?.trim() || void 0;
648
+ const cloudflareTokenFrom = (environment2) => {
649
+ const authToken = environment2.CLOUDFLARE_AUTH_TOKEN?.trim();
650
+ const apiToken = environment2.CLOUDFLARE_API_TOKEN?.trim();
651
+ if (authToken && apiToken && authToken !== apiToken)
652
+ diagnostics.push({
653
+ code: "conflicting_cloudflare_api_tokens",
654
+ file: environmentFile,
655
+ line: 1,
656
+ col: 1,
657
+ key: "CLOUDFLARE_AUTH_TOKEN",
658
+ message: "CLOUDFLARE_AUTH_TOKEN and CLOUDFLARE_API_TOKEN contain different values at the same precedence level.",
659
+ fix: "Keep one token variable, or set both names to the same Workers AI API token."
660
+ });
661
+ return authToken || apiToken || void 0;
662
+ };
663
+ const providerNameValue = provider.name ?? "typesafe";
664
+ const providerName = providerNameValue === "typesafe" || providerNameValue === "clef" ? providerNameValue : "typesafe";
665
+ if (providerNameValue !== "typesafe" && providerNameValue !== "clef")
666
+ diagnostic(
667
+ diagnostics,
668
+ file,
669
+ counter,
670
+ node("provider.name"),
671
+ "provider.name",
672
+ "invalid_config_provider",
673
+ "Configuration key `provider.name` must be `typesafe` or `clef`.",
674
+ "Choose one of the supported provider names."
675
+ );
676
+ const configuredModel = provider.model;
677
+ const validClefModel = configuredModel === "clef" || configuredModel === "clef-flash";
678
+ if (configuredModel !== void 0 && (typeof configuredModel !== "string" || !configuredModel.trim() || providerName === "clef" && !validClefModel))
679
+ diagnostic(
680
+ diagnostics,
681
+ file,
682
+ counter,
683
+ node("provider.model"),
684
+ "provider.model",
685
+ "invalid_config_provider_model",
686
+ providerName === "clef" ? "Clef provider model must be `clef` or `clef-flash`." : "Provider model must be nonempty text.",
687
+ providerName === "clef" ? "Use `provider.model: clef`." : "Use a nonempty model name."
688
+ );
689
+ const customProvider = {
690
+ baseUrl: providerValue("TYPESAFE_BASE_URL"),
691
+ model: providerValue("TYPESAFE_DEFAULT_MODEL")
692
+ };
693
+ let providerBaseUrl = DEFAULT_PROVIDER_BASE_URL;
694
+ if (providerName === "typesafe" && customProvider.baseUrl) {
695
+ try {
696
+ const parsed = new URL(customProvider.baseUrl);
697
+ if (parsed.protocol !== "https:" || parsed.username || parsed.password || parsed.search || parsed.hash)
698
+ throw new Error("unsafe provider URL");
699
+ providerBaseUrl = parsed.href.replace(/\/$/u, "");
700
+ } catch {
701
+ diagnostics.push({
702
+ code: "invalid_provider_url",
703
+ file: environmentFile,
704
+ line: 1,
705
+ col: 1,
706
+ key: "TYPESAFE_BASE_URL",
707
+ message: "TYPESAFE_BASE_URL must be an absolute HTTPS URL without credentials, query, or fragment.",
708
+ fix: "Use a base URL such as https://api.typesafe.ai."
709
+ });
710
+ }
711
+ }
712
+ const providerModel = providerName === "clef" ? typeof configuredModel === "string" && validClefModel ? configuredModel : "clef" : typeof configuredModel === "string" && configuredModel.trim() ? configuredModel.trim() : customProvider.model ?? DEFAULT_PROVIDER_MODEL;
713
+ const apiKey = providerName === "clef" ? cloudflareTokenFrom(hostEnvironment) ?? cloudflareTokenFrom(fileEnvironment) : providerValue("TYPESAFE_API_KEY");
714
+ const cloudflareAccountId = providerName === "clef" ? providerValue("CLOUDFLARE_ACCOUNT_ID") : void 0;
715
+ if (providerName === "clef" && cloudflareAccountId !== void 0 && !/^[a-f\d]{32}$/iu.test(cloudflareAccountId))
716
+ diagnostics.push({
717
+ code: "invalid_cloudflare_account_id",
718
+ file: environmentFile,
719
+ line: 1,
720
+ col: 1,
721
+ key: "CLOUDFLARE_ACCOUNT_ID",
722
+ message: "CLOUDFLARE_ACCOUNT_ID must be exactly 32 hexadecimal characters.",
723
+ fix: "Copy the account ID from the Cloudflare dashboard."
724
+ });
725
+ const visionApiKey = providerValue("OPEN_ROUTER_API_KEY");
726
+ variables.OPEN_ROUTER_API_KEY = void 0;
727
+ variables.CLOUDFLARE_ACCOUNT_ID = void 0;
728
+ variables.CLOUDFLARE_AUTH_TOKEN = void 0;
729
+ variables.CLOUDFLARE_API_TOKEN = void 0;
730
+ const visionEnabledValue = overrides.vision?.enabled ?? vision.enabled;
731
+ const visionEnabled = visionEnabledValue ?? DEFAULTS.vision.enabled;
732
+ if (typeof visionEnabled !== "boolean")
733
+ diagnostic(
734
+ diagnostics,
735
+ file,
736
+ counter,
737
+ node("vision.enabled"),
738
+ "vision.enabled",
739
+ "invalid_config_type",
740
+ "Configuration key `vision.enabled` must be a boolean.",
741
+ "Use `vision.enabled: true` or `vision.enabled: false`."
742
+ );
743
+ const visionModelValue = overrides.vision?.model ?? vision.model;
744
+ const visionModel = visionModelValue ?? DEFAULTS.vision.model;
745
+ if (typeof visionModel !== "string" || !visionModel.trim())
746
+ diagnostic(
747
+ diagnostics,
748
+ file,
749
+ counter,
750
+ node("vision.model"),
751
+ "vision.model",
752
+ "invalid_config_type",
753
+ "Configuration key `vision.model` must be nonempty text.",
754
+ `Use a model such as \`${DEFAULTS.vision.model}\`.`
755
+ );
756
+ const visionTimeoutValue = vision.timeoutMs ?? DEFAULTS.vision.timeoutMs;
757
+ if (!Number.isSafeInteger(visionTimeoutValue) || visionTimeoutValue < 1)
758
+ diagnostic(
759
+ diagnostics,
760
+ file,
761
+ counter,
762
+ node("vision.timeoutMs"),
763
+ "vision.timeoutMs",
764
+ "invalid_config_type",
765
+ "Configuration key `vision.timeoutMs` must be a positive integer.",
766
+ "Use a timeout such as `10000`."
767
+ );
609
768
  const testDirectory = relativePath(
610
769
  found.root,
611
770
  tests.directory,
@@ -669,7 +828,17 @@ async function loadProjectConfig(start = process.cwd(), hostEnvironment = proces
669
828
  reporterDir,
670
829
  baseUrl,
671
830
  variables,
672
- apiKey
831
+ providerName,
832
+ apiKey,
833
+ cloudflareAccountId,
834
+ providerBaseUrl,
835
+ providerModel,
836
+ vision: {
837
+ enabled: visionEnabled === true,
838
+ model: typeof visionModel === "string" && visionModel.trim() ? visionModel : DEFAULTS.vision.model,
839
+ timeoutMs: Number.isSafeInteger(visionTimeoutValue) && visionTimeoutValue > 0 ? visionTimeoutValue : DEFAULTS.vision.timeoutMs
840
+ },
841
+ visionApiKey
673
842
  });
674
843
  }
675
844
  async function discoverConfiguredTests(config) {
@@ -688,7 +857,7 @@ async function discoverConfiguredTests(config) {
688
857
  if (entry.isDirectory()) await visit2(absolute);
689
858
  else if (entry.isFile()) {
690
859
  const relative = path.relative(config.testDirectory, absolute).split(path.sep).join("/");
691
- if (relative.endsWith(".test.yaml") && config.include.some((pattern) => minimatch(relative, pattern)) && !config.exclude.some((pattern) => minimatch(relative, pattern)))
860
+ if ((relative.endsWith(".test.ts") || relative.endsWith(".test.yaml")) && config.include.some((pattern) => minimatch(relative, pattern)) && !config.exclude.some((pattern) => minimatch(relative, pattern)))
692
861
  files.push(absolute);
693
862
  }
694
863
  }
@@ -699,6 +868,8 @@ async function discoverConfiguredTests(config) {
699
868
 
700
869
  export {
701
870
  ProjectConfigError,
871
+ DEFAULT_PROVIDER_BASE_URL,
872
+ DEFAULT_PROVIDER_MODEL,
702
873
  loadProjectConfig,
703
874
  discoverConfiguredTests
704
875
  };
package/dist/cli.js CHANGED
@@ -1,12 +1,15 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
- runCli
4
- } from "./chunk-TU5MIKGA.js";
5
- import "./chunk-BEV24G7S.js";
6
- import "./chunk-TZGSCV23.js";
3
+ runCli,
4
+ sedumCommand
5
+ } from "./chunk-4LEXNO2M.js";
6
+ import "./chunk-EFRMSNBD.js";
7
+ import "./chunk-NOGCXR4U.js";
8
+ import "./chunk-VNGIF7AY.js";
7
9
 
8
10
  // src/cli.ts
9
11
  import { createRequire } from "module";
12
+ import { fileURLToPath } from "url";
10
13
 
11
14
  // src/interrupts.ts
12
15
  function createInterruptState() {
@@ -35,10 +38,26 @@ function startDeadlineWatchdog(delayMs = 1e4, exit = (code) => process.exit(code
35
38
  }
36
39
 
37
40
  // src/cli.ts
41
+ import { describeRejection, RejectionRouter } from "@sedum-dev/core";
38
42
  var require2 = createRequire(import.meta.url);
39
43
  var pkg = require2("../package.json");
40
44
  var interrupts = createInterruptState();
41
45
  var deadlineWatchdog;
46
+ var strayRejection = false;
47
+ var reportStray = (message) => {
48
+ strayRejection = true;
49
+ process.stderr.write(
50
+ `${message}
51
+ Fix: Add \`await\` before the page, expect, API, and ai calls in your tests.
52
+ `
53
+ );
54
+ };
55
+ process.on("unhandledRejection", (reason) => {
56
+ if (RejectionRouter.routing) return;
57
+ reportStray(
58
+ `A promise nobody awaited rejected outside any running test: ${describeRejection(reason)}`
59
+ );
60
+ });
42
61
  var onSigint = () => interrupts.request("SIGINT");
43
62
  var onSigterm = () => interrupts.request("SIGTERM");
44
63
  process.on("SIGINT", onSigint);
@@ -46,6 +65,7 @@ process.on("SIGTERM", onSigterm);
46
65
  var output = await runCli(process.argv.slice(2), pkg.version, {
47
66
  signal: interrupts.signal,
48
67
  onRunCommitted: interrupts.commit,
68
+ onStrayRejection: reportStray,
49
69
  onRunDeadline: () => {
50
70
  deadlineWatchdog = startDeadlineWatchdog();
51
71
  },
@@ -55,6 +75,7 @@ var output = await runCli(process.argv.slice(2), pkg.version, {
55
75
  color: process.stdout.isTTY === true && !("NO_COLOR" in process.env),
56
76
  ...process.stdout.columns ? { columns: process.stdout.columns } : {}
57
77
  },
78
+ command: sedumCommand(process.env, fileURLToPath(import.meta.url)),
58
79
  stdout: (value) => process.stdout.write(value),
59
80
  stderr: (value) => process.stderr.write(value)
60
81
  });
@@ -63,4 +84,9 @@ process.off("SIGINT", onSigint);
63
84
  process.off("SIGTERM", onSigterm);
64
85
  if (output.stdout) process.stdout.write(output.stdout);
65
86
  if (output.stderr) process.stderr.write(output.stderr);
66
- process.exitCode = interrupts.exitCode(output.exitCode);
87
+ var exitCode = interrupts.exitCode(output.exitCode);
88
+ process.exitCode = strayRejection ? Math.max(exitCode, 3) : exitCode;
89
+ process.on("beforeExit", () => {
90
+ if (strayRejection)
91
+ process.exitCode = Math.max(Number(process.exitCode ?? 0), 3);
92
+ });
@@ -5,8 +5,8 @@ import {
5
5
  keyPresent,
6
6
  renderDoctorText,
7
7
  supportedNode
8
- } from "./chunk-OB6ZUJ6X.js";
9
- import "./chunk-TZGSCV23.js";
8
+ } from "./chunk-H4QXVVQI.js";
9
+ import "./chunk-VNGIF7AY.js";
10
10
  export {
11
11
  browserAvailable,
12
12
  checkOutputWritable,