sedum-cli 0.1.0-alpha.17 → 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.
@@ -1,17 +1,15 @@
1
1
  import {
2
2
  discoverRunTests
3
- } from "./chunk-ZAACPFCW.js";
3
+ } from "./chunk-6ILFLNDI.js";
4
4
  import {
5
5
  createCliProvider
6
6
  } from "./chunk-N5CTUO2A.js";
7
- import {
8
- providerDiagnostic
9
- } from "./chunk-GJ5QI7JQ.js";
10
7
  import {
11
8
  affectedPathIgnored,
12
9
  loadProjectConfig,
10
+ providerDiagnostic,
13
11
  validAffectedGlob
14
- } from "./chunk-OKZ6VJKA.js";
12
+ } from "./chunk-KZF4NZ6M.js";
15
13
 
16
14
  // src/affected-selection.ts
17
15
  import { realpath } from "fs/promises";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  discoverConfiguredTests
3
- } from "./chunk-OKZ6VJKA.js";
3
+ } from "./chunk-KZF4NZ6M.js";
4
4
 
5
5
  // src/run-selection.ts
6
6
  import { lstat, realpath } from "fs/promises";
@@ -4,7 +4,7 @@ import {
4
4
  seedValue,
5
5
  startUrl,
6
6
  watchOrigin
7
- } from "./chunk-ACDJLEMS.js";
7
+ } from "./chunk-FG46OUHT.js";
8
8
  import {
9
9
  MAX_PARALLEL,
10
10
  clearLocatorCache,
@@ -13,16 +13,14 @@ import {
13
13
  import {
14
14
  createCliProvider
15
15
  } from "./chunk-N5CTUO2A.js";
16
- import {
17
- configDiagnostic,
18
- renderDiagnostic
19
- } from "./chunk-GJ5QI7JQ.js";
20
16
  import {
21
17
  ProjectConfigError,
18
+ configDiagnostic,
22
19
  discoverConfiguredTests,
23
20
  loadProjectConfig,
21
+ renderDiagnostic,
24
22
  validAffectedGlob
25
- } from "./chunk-OKZ6VJKA.js";
23
+ } from "./chunk-KZF4NZ6M.js";
26
24
 
27
25
  // src/invocation.ts
28
26
  function sedumCommand(env = process.env, script = process.argv[1] ?? "") {
@@ -858,7 +856,7 @@ async function runCli(args, version, runtime = {}) {
858
856
  const writeOut = (value) => rawOut(withCommand(value, command));
859
857
  const writeErr = (value) => rawErr(withCommand(value, command));
860
858
  const capabilities = runtime.capabilities ?? plainOutput;
861
- const executeRun = runtime.executeRun ?? (async (options) => (await import("./run-command-EVUWZI4F.js")).executeRunCommand(options));
859
+ const executeRun = runtime.executeRun ?? (async (options) => (await import("./run-command-P55TKTX3.js")).executeRunCommand(options));
862
860
  const cwd = runtime.cwd ?? process.cwd();
863
861
  let exitCode = 3;
864
862
  const program = new Command2().name("sedum").description(
@@ -876,7 +874,7 @@ async function runCli(args, version, runtime = {}) {
876
874
  "after",
877
875
  "\nCreates a config, a SauceDemo example, .env.example, and ignore rules.\nExisting files are never replaced.\n"
878
876
  ).action(async () => {
879
- const { executeInitCommand } = await import("./init-command-DEEVMROG.js");
877
+ const { executeInitCommand } = await import("./init-command-MBTLGU5J.js");
880
878
  const interactive = capabilities.stdoutIsTTY && (process.stdin.isTTY === true || runtime.confirmInit !== void 0);
881
879
  const confirm = runtime.confirmInit ?? (interactive ? async (question) => {
882
880
  const { createInterface } = await import("readline/promises");
@@ -1040,7 +1038,7 @@ async function runCli(args, version, runtime = {}) {
1040
1038
  return;
1041
1039
  }
1042
1040
  if (options.affected) {
1043
- const { selectAffectedTests, AffectedSelectionError } = await import("./affected-selection-KRK5HRF4.js");
1041
+ const { selectAffectedTests, AffectedSelectionError } = await import("./affected-selection-DAQPGKOZ.js");
1044
1042
  const { ProviderError: ProviderError2 } = await import("@sedum-dev/core");
1045
1043
  writeErr(
1046
1044
  "Experimental selection sends the committed Git diff and complete test/module sources to the configured provider. Tracked local edits are refused. Full CI is still recommended.\n"
@@ -1288,7 +1286,7 @@ No tests were run. Fix the selection error or run without --affected.
1288
1286
  "after",
1289
1287
  "\nGuided mode and --shrink make billable TypeSafe calls (TYPESAFE_API_KEY).\nSafety is off by default, for disposable staging: exploration clicks real buttons\nand completes forms. Use --safe on shared or production-like data.\n\nWrites trace.jsonl, result.json, report.md and report.html into --out/<run-id>/.\n\nExamples:\n sedum explore https://staging.example.com --steps 200 --seed 7 --replay\n sedum explore https://staging.example.com --safe --shrink\n sedum explore --rerun .sedum/explore/<run>/trace.jsonl\n\nExit codes:\n 0 no failures observed\n 1 console errors, page exceptions or HTTP 5xx observed\n 3 command or operational error\n"
1290
1288
  ).action(async (url, options) => {
1291
- const { exploreAction } = await import("./explore-command-NRRJADY4.js");
1289
+ const { exploreAction } = await import("./explore-command-QZCKFDYM.js");
1292
1290
  exitCode = await exploreAction(url, options, {
1293
1291
  cwd,
1294
1292
  write: writeOut,
@@ -1309,7 +1307,7 @@ No tests were run. Fix the selection error or run without --affected.
1309
1307
  "after",
1310
1308
  "\nThe authenticated API check makes one small, potentially billable request.\n\nExit codes:\n 0 all checks passed\n 3 one or more prerequisites failed\n"
1311
1309
  ).action(async (options) => {
1312
- const { executeDoctorCommand, renderDoctorText } = await import("./doctor-command-KIGPIDQA.js");
1310
+ const { executeDoctorCommand, renderDoctorText } = await import("./doctor-command-7IBKI5YO.js");
1313
1311
  const result = await executeDoctorCommand(
1314
1312
  cwd,
1315
1313
  runtime.doctorProbes,
@@ -1,6 +1,9 @@
1
1
  import {
2
+ ProjectConfigError,
3
+ configDiagnostic,
4
+ loadProjectConfig,
2
5
  readProjectEnvironment
3
- } from "./chunk-OKZ6VJKA.js";
6
+ } from "./chunk-KZF4NZ6M.js";
4
7
 
5
8
  // src/explore-command.ts
6
9
  import { randomInt } from "crypto";
@@ -186,15 +189,20 @@ async function advisor(mode, needed, provider = {}) {
186
189
  return new TypeSafeAdapter(provider);
187
190
  }
188
191
  async function exploreProvider(cwd, environment = process.env) {
189
- const file = await readProjectEnvironment(cwd);
192
+ const config = await loadProjectConfig(cwd, environment);
193
+ const file = await readProjectEnvironment(config.projectRoot);
190
194
  const value = (name) => environment[name]?.trim() || file[name]?.trim() || void 0;
191
- const apiKey = value("TYPESAFE_API_KEY");
195
+ const keyName = config.providerName === "typesafe" ? config.apiKeyEnv ?? "TYPESAFE_API_KEY" : "TYPESAFE_API_KEY";
196
+ const apiKey = value(keyName) ?? "";
192
197
  const baseURL = value("TYPESAFE_BASE_URL");
193
198
  const model = value("TYPESAFE_DEFAULT_MODEL");
194
199
  return {
195
- ...apiKey ? { apiKey } : {},
196
- ...baseURL ? { baseURL } : {},
197
- ...model ? { model } : {}
200
+ provider: {
201
+ apiKey,
202
+ ...baseURL ? { baseURL } : {},
203
+ ...model ? { model } : {}
204
+ },
205
+ keyName
198
206
  };
199
207
  }
200
208
  function traceEnd(result, step) {
@@ -331,9 +339,9 @@ async function openRun(options) {
331
339
  return { seed, id, directory, trace, startedAt: (/* @__PURE__ */ new Date()).toISOString() };
332
340
  }
333
341
  async function walk(page, place, frames, options) {
334
- const { explore } = await import("@sedum-dev/core");
342
+ const { explore: explore2 } = await import("@sedum-dev/core");
335
343
  const guide = await advisor(options.mode, false, options.provider);
336
- return explore(page, {
344
+ return explore2(page, {
337
345
  startUrl: options.url,
338
346
  steps: options.steps,
339
347
  seed: place.seed,
@@ -439,7 +447,7 @@ function safetyOf(safe) {
439
447
  if (safe === void 0) return "off";
440
448
  return safe === true ? "on" : safe;
441
449
  }
442
- async function run(url, flags, io) {
450
+ async function run(url, flags, io, provider) {
443
451
  return executeExploreCommand({
444
452
  url,
445
453
  steps: flags.steps,
@@ -457,7 +465,7 @@ async function run(url, flags, io) {
457
465
  detect: flags.detect,
458
466
  detectAllow: flags.detectAllow,
459
467
  ...flags.cookies ? { cookies: path3.resolve(io.cwd, flags.cookies) } : {},
460
- provider: await exploreProvider(io.cwd),
468
+ provider,
461
469
  ...io.signal ? { signal: io.signal } : {},
462
470
  write: io.write
463
471
  });
@@ -471,28 +479,50 @@ function usageProblem({
471
479
  return url ? null : "Missing start URL.\nFix: use `sedum explore <url>`.\n";
472
480
  }
473
481
  async function exploreAction(url, flags, io) {
482
+ if (flags.rerun)
483
+ return executeRerunCommand({
484
+ trace: path3.resolve(io.cwd, flags.rerun),
485
+ headed: flags.headed,
486
+ write: io.write
487
+ });
488
+ const problem = usageProblem({ url, flags });
489
+ if (problem) {
490
+ io.writeErr(problem);
491
+ return 3;
492
+ }
493
+ return explore(url, flags, io);
494
+ }
495
+ async function explore(url, flags, io) {
496
+ const credentials = await projectCredentials(io);
497
+ if (!credentials) return 3;
474
498
  const { ProviderError } = await import("@sedum-dev/core");
475
499
  try {
476
- if (flags.rerun)
477
- return await executeRerunCommand({
478
- trace: path3.resolve(io.cwd, flags.rerun),
479
- headed: flags.headed,
480
- write: io.write
481
- });
482
- const problem = usageProblem({ url, flags });
483
- if (!problem) return await run(url, flags, io);
484
- io.writeErr(problem);
500
+ return await run(url, flags, io, credentials.provider);
485
501
  } catch (error) {
486
502
  if (!(error instanceof ProviderError && error.code === "configuration"))
487
503
  throw error;
488
- io.writeErr(
489
- `${error.message}
490
- Fix: set TYPESAFE_API_KEY in the project-root .env or your shell, or use --mode random or --mode heuristic without --shrink.
491
- `
492
- );
504
+ io.writeErr(missingKeyMessage(credentials, error.message));
493
505
  }
494
506
  return 3;
495
507
  }
508
+ async function projectCredentials(io) {
509
+ try {
510
+ return await exploreProvider(io.cwd);
511
+ } catch (error) {
512
+ if (!(error instanceof ProjectConfigError)) throw error;
513
+ const diagnostic = configDiagnostic(error);
514
+ io.writeErr(`${diagnostic.message}
515
+ Fix: ${diagnostic.fix}
516
+ `);
517
+ return null;
518
+ }
519
+ }
520
+ function missingKeyMessage({ provider, keyName }, adapterMessage) {
521
+ const message = provider.apiKey ? adapterMessage : `Set ${keyName} to use the TypeSafe provider.`;
522
+ return `${message}
523
+ Fix: set ${keyName} in the project-root .env or your shell, or use --mode random or --mode heuristic without --shrink.
524
+ `;
525
+ }
496
526
 
497
527
  export {
498
528
  EXPLORE_MODES,
@@ -1026,6 +1026,199 @@ async function discoverConfiguredTests(config) {
1026
1026
  return files.sort((left, right) => left.localeCompare(right));
1027
1027
  }
1028
1028
 
1029
+ // src/diagnostics.ts
1030
+ import { BrowserDriverError, ProviderError } from "@sedum-dev/core";
1031
+ function providerDiagnostic(provider, code, apiKeyEnv) {
1032
+ const providerName = typeof provider === "string" ? provider : provider.providerName;
1033
+ if (typeof provider !== "string") apiKeyEnv = provider.apiKeyEnv;
1034
+ if (providerName === "openrouter")
1035
+ return {
1036
+ code: `provider_${code}`,
1037
+ message: code === "authentication" ? "OpenRouter rejected the configured API key." : "The OpenRouter decision provider is not configured correctly.",
1038
+ 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.`
1039
+ };
1040
+ if (providerName === "clef")
1041
+ return code === "authentication" ? {
1042
+ code: "provider_authentication",
1043
+ message: "Cloudflare rejected the configured API token.",
1044
+ 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.`
1045
+ } : {
1046
+ code: "provider_configuration",
1047
+ message: "The Cloudflare Clef provider is not configured correctly.",
1048
+ 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\`.`
1049
+ };
1050
+ return code === "authentication" ? {
1051
+ code: "provider_authentication",
1052
+ message: "The model provider rejected the API key.",
1053
+ fix: `Set ${apiKeyEnv ?? "TYPESAFE_API_KEY"} to a valid key, check it with \`sedum doctor\`, then rerun.`
1054
+ } : {
1055
+ code: "provider_configuration",
1056
+ message: "The model provider is not configured correctly.",
1057
+ fix: `Check ${apiKeyEnv ?? "TYPESAFE_API_KEY"}, TYPESAFE_BASE_URL and the model with \`sedum doctor\`, then rerun.`
1058
+ };
1059
+ }
1060
+ var DetectorUnsupportedError = class extends Error {
1061
+ constructor(providerName) {
1062
+ super(
1063
+ `--detect semantic is not supported by the ${providerName} provider.`
1064
+ );
1065
+ this.providerName = providerName;
1066
+ this.name = "DetectorUnsupportedError";
1067
+ }
1068
+ providerName;
1069
+ };
1070
+ function setupDiagnostic(error, providerName = "typesafe", apiKeyEnv) {
1071
+ if (error instanceof ProjectConfigError) return configDiagnostic(error);
1072
+ if (error instanceof DetectorUnsupportedError)
1073
+ return {
1074
+ code: "detect_unsupported",
1075
+ message: `--detect semantic needs a System One provider; ${error.providerName} cannot answer its page questions.`,
1076
+ fix: "Use --detect browser with this provider, or select the TypeSafe or OpenRouter provider."
1077
+ };
1078
+ if (error instanceof ProviderError && error.code === "configuration")
1079
+ return providerName !== "typesafe" ? providerDiagnostic(providerName, "configuration", apiKeyEnv) : {
1080
+ code: "missing_key",
1081
+ message: "The model provider is not configured.",
1082
+ fix: `Set ${apiKeyEnv ?? "TYPESAFE_API_KEY"} for the configured endpoint, then rerun the command.`
1083
+ };
1084
+ if (error instanceof BrowserDriverError && error.code === "browser-missing")
1085
+ return {
1086
+ code: "browser_missing",
1087
+ message: "No supported browser binary was found.",
1088
+ fix: "Run `sedum browsers install chromium`, then rerun the test."
1089
+ };
1090
+ return {
1091
+ code: "setup_or_output_error",
1092
+ message: "The run could not be prepared safely.",
1093
+ fix: "Check the test path, provider key, browser installation, and write access, then rerun."
1094
+ };
1095
+ }
1096
+ function configDiagnostic(error) {
1097
+ const first = error.diagnostics[0];
1098
+ if (!first)
1099
+ return {
1100
+ code: "invalid_config",
1101
+ message: "The Sedum configuration is invalid.",
1102
+ fix: "Correct sedum.config.yaml and rerun the command."
1103
+ };
1104
+ return {
1105
+ code: first.code,
1106
+ message: bounded(
1107
+ `${first.file}:${first.line}:${first.col}: ${first.message} (key: ${first.key})`
1108
+ ),
1109
+ fix: bounded(first.fix)
1110
+ };
1111
+ }
1112
+ function outputDiagnostic(path2) {
1113
+ return {
1114
+ code: "output_error",
1115
+ message: `The run result could not be written to ${path2}.`,
1116
+ fix: "Make the configured output directory writable and rerun the command."
1117
+ };
1118
+ }
1119
+ function bounded(value, maximum = 512) {
1120
+ return [...value].slice(0, maximum).join("");
1121
+ }
1122
+ function canonicalDiagnosticError(diagnostic2) {
1123
+ return {
1124
+ code: diagnostic2.code,
1125
+ message: diagnostic2.code === "output_error" ? "The run result could not be written." : bounded(diagnostic2.message)
1126
+ };
1127
+ }
1128
+ function flowDiagnostic(result, providerName = "typesafe", apiKeyEnv) {
1129
+ if (result.code === "invalid_test" || result.code === "unsupported_test" || result.code === "invalid_data") {
1130
+ const source2 = result.source ? `${result.source.file}:${result.source.line}:${result.source.col}: ` : "";
1131
+ return {
1132
+ code: result.code,
1133
+ message: bounded(`${source2}${result.message}`),
1134
+ fix: bounded(
1135
+ result.fix ?? "Fix the reported test input and rerun the command."
1136
+ )
1137
+ };
1138
+ }
1139
+ const known = {
1140
+ "browser-missing": {
1141
+ message: "No supported browser binary was found.",
1142
+ fix: "Run `sedum browsers install chromium`, then rerun the test."
1143
+ },
1144
+ "browser-launch-failed": {
1145
+ message: "The browser could not be started safely.",
1146
+ fix: "Check the browser installation and permissions, then rerun the test."
1147
+ },
1148
+ "browser-disconnected": {
1149
+ message: "The browser disconnected during the run.",
1150
+ fix: "Restart the browser run and check browser stability if it repeats."
1151
+ },
1152
+ "context-closed": {
1153
+ message: "The browser context closed during the run.",
1154
+ fix: "Rerun the test and check browser stability if it repeats."
1155
+ },
1156
+ "page-closed": {
1157
+ message: "The browser page closed during the run.",
1158
+ fix: "Rerun the test and check whether the tested page closes itself."
1159
+ },
1160
+ "page-crashed": {
1161
+ message: "The browser page crashed during the run.",
1162
+ fix: "Rerun the test and check browser resource usage if it repeats."
1163
+ },
1164
+ "operation-failed": {
1165
+ message: "A browser operation could not be completed safely.",
1166
+ fix: "Check the named test step and rerun the test."
1167
+ },
1168
+ "script-missing": {
1169
+ message: "The Sedum browser script was unavailable.",
1170
+ fix: "Rebuild or reinstall Sedum, then rerun the test."
1171
+ }
1172
+ };
1173
+ const diagnostic2 = known[result.code];
1174
+ if (diagnostic2) return { code: result.code, ...diagnostic2 };
1175
+ if (result.code === "navigation_failed")
1176
+ return {
1177
+ code: result.code,
1178
+ message: bounded(result.message),
1179
+ fix: bounded(
1180
+ result.fix ?? "Check the test's url (or baseUrl), your network or VPN, and that the site is up."
1181
+ )
1182
+ };
1183
+ if (result.code === "provider_rate_limited")
1184
+ return {
1185
+ code: result.code,
1186
+ message: "The model provider kept rate limiting requests for five minutes.",
1187
+ fix: "Lower --parallel or --provider-concurrency, or retry later."
1188
+ };
1189
+ if (result.code === "provider_authentication")
1190
+ return providerDiagnostic(providerName, "authentication", apiKeyEnv);
1191
+ if (result.code === "provider_configuration")
1192
+ return providerDiagnostic(providerName, "configuration", apiKeyEnv);
1193
+ if (result.code.startsWith("provider_"))
1194
+ return {
1195
+ code: result.code,
1196
+ message: "The model provider could not complete the run safely.",
1197
+ fix: "Check provider availability and the test input, then rerun the test."
1198
+ };
1199
+ return {
1200
+ code: "execution_error",
1201
+ message: "The browser run could not be completed safely.",
1202
+ fix: "Check the browser, provider, and test input, then rerun the test."
1203
+ };
1204
+ }
1205
+ var RUN_STOPPING_CODES = /* @__PURE__ */ new Set([
1206
+ "browser-missing",
1207
+ "browser-launch-failed",
1208
+ "script-missing",
1209
+ "provider_configuration",
1210
+ "provider_authentication",
1211
+ "provider_rate_limited"
1212
+ ]);
1213
+ function stopsRun(code) {
1214
+ return RUN_STOPPING_CODES.has(code);
1215
+ }
1216
+ function renderDiagnostic(diagnostic2) {
1217
+ return `${diagnostic2.message}
1218
+ Fix: ${diagnostic2.fix}
1219
+ `;
1220
+ }
1221
+
1029
1222
  export {
1030
1223
  validAffectedGlob,
1031
1224
  affectedPathIgnored,
@@ -1034,5 +1227,14 @@ export {
1034
1227
  DEFAULT_PROVIDER_MODEL,
1035
1228
  readProjectEnvironment,
1036
1229
  loadProjectConfig,
1037
- discoverConfiguredTests
1230
+ discoverConfiguredTests,
1231
+ providerDiagnostic,
1232
+ DetectorUnsupportedError,
1233
+ setupDiagnostic,
1234
+ configDiagnostic,
1235
+ outputDiagnostic,
1236
+ canonicalDiagnosticError,
1237
+ flowDiagnostic,
1238
+ stopsRun,
1239
+ renderDiagnostic
1038
1240
  };
@@ -1,11 +1,9 @@
1
- import {
2
- providerDiagnostic
3
- } from "./chunk-GJ5QI7JQ.js";
4
1
  import {
5
2
  DEFAULT_PROVIDER_BASE_URL,
6
3
  DEFAULT_PROVIDER_MODEL,
7
- loadProjectConfig
8
- } from "./chunk-OKZ6VJKA.js";
4
+ loadProjectConfig,
5
+ providerDiagnostic
6
+ } from "./chunk-KZF4NZ6M.js";
9
7
 
10
8
  // src/doctor-command.ts
11
9
  import { lstat, mkdir, mkdtemp, rm, rmdir, writeFile } from "fs/promises";
package/dist/cli.js CHANGED
@@ -2,12 +2,11 @@
2
2
  import {
3
3
  runCli,
4
4
  sedumCommand
5
- } from "./chunk-A7HBQLEM.js";
6
- import "./chunk-ACDJLEMS.js";
5
+ } from "./chunk-EPXLY5Q4.js";
6
+ import "./chunk-FG46OUHT.js";
7
7
  import "./chunk-EFRMSNBD.js";
8
8
  import "./chunk-N5CTUO2A.js";
9
- import "./chunk-GJ5QI7JQ.js";
10
- import "./chunk-OKZ6VJKA.js";
9
+ import "./chunk-KZF4NZ6M.js";
11
10
 
12
11
  // src/cli.ts
13
12
  import { createRequire } from "module";
@@ -5,9 +5,8 @@ import {
5
5
  keyPresent,
6
6
  renderDoctorText,
7
7
  supportedNode
8
- } from "./chunk-F4RD4S4P.js";
9
- import "./chunk-GJ5QI7JQ.js";
10
- import "./chunk-OKZ6VJKA.js";
8
+ } from "./chunk-SI2F6MBN.js";
9
+ import "./chunk-KZF4NZ6M.js";
11
10
  export {
12
11
  browserAvailable,
13
12
  checkOutputWritable,
@@ -9,8 +9,8 @@ import {
9
9
  seedValue,
10
10
  startUrl,
11
11
  watchOrigin
12
- } from "./chunk-ACDJLEMS.js";
13
- import "./chunk-OKZ6VJKA.js";
12
+ } from "./chunk-FG46OUHT.js";
13
+ import "./chunk-KZF4NZ6M.js";
14
14
  export {
15
15
  EXPLORE_MODES,
16
16
  collectText,
package/dist/index.js CHANGED
@@ -2,16 +2,15 @@ import {
2
2
  renderRunSummary,
3
3
  runCli,
4
4
  runExitCode
5
- } from "./chunk-A7HBQLEM.js";
6
- import "./chunk-ACDJLEMS.js";
5
+ } from "./chunk-EPXLY5Q4.js";
6
+ import "./chunk-FG46OUHT.js";
7
7
  import "./chunk-EFRMSNBD.js";
8
8
  import "./chunk-N5CTUO2A.js";
9
- import "./chunk-GJ5QI7JQ.js";
10
9
  import {
11
10
  ProjectConfigError,
12
11
  discoverConfiguredTests,
13
12
  loadProjectConfig
14
- } from "./chunk-OKZ6VJKA.js";
13
+ } from "./chunk-KZF4NZ6M.js";
15
14
 
16
15
  // src/index.ts
17
16
  import { test, expect, secret } from "@sedum-dev/core/script";
@@ -2,12 +2,11 @@ import {
2
2
  browserAvailable,
3
3
  keyPresent,
4
4
  supportedNode
5
- } from "./chunk-F4RD4S4P.js";
6
- import "./chunk-GJ5QI7JQ.js";
5
+ } from "./chunk-SI2F6MBN.js";
7
6
  import {
8
7
  ProjectConfigError,
9
8
  loadProjectConfig
10
- } from "./chunk-OKZ6VJKA.js";
9
+ } from "./chunk-KZF4NZ6M.js";
11
10
 
12
11
  // src/init-command.ts
13
12
  import { constants } from "fs";
@@ -5,22 +5,20 @@ import {
5
5
  } from "./chunk-EFRMSNBD.js";
6
6
  import {
7
7
  discoverRunTests
8
- } from "./chunk-ZAACPFCW.js";
8
+ } from "./chunk-6ILFLNDI.js";
9
9
  import {
10
10
  createCliProvider
11
11
  } from "./chunk-N5CTUO2A.js";
12
12
  import {
13
13
  DetectorUnsupportedError,
14
+ ProjectConfigError,
14
15
  canonicalDiagnosticError,
15
16
  flowDiagnostic,
17
+ loadProjectConfig,
16
18
  outputDiagnostic,
17
19
  setupDiagnostic,
18
20
  stopsRun
19
- } from "./chunk-GJ5QI7JQ.js";
20
- import {
21
- ProjectConfigError,
22
- loadProjectConfig
23
- } from "./chunk-OKZ6VJKA.js";
21
+ } from "./chunk-KZF4NZ6M.js";
24
22
 
25
23
  // src/run-command/implementation.ts
26
24
  import {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sedum-cli",
3
- "version": "0.1.0-alpha.17",
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.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"
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",
@@ -1,208 +0,0 @@
1
- import {
2
- ProjectConfigError
3
- } from "./chunk-OKZ6VJKA.js";
4
-
5
- // src/diagnostics.ts
6
- import { BrowserDriverError, ProviderError } from "@sedum-dev/core";
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
- };
16
- if (providerName === "clef")
17
- return code === "authentication" ? {
18
- code: "provider_authentication",
19
- message: "Cloudflare rejected the configured API token.",
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.`
21
- } : {
22
- code: "provider_configuration",
23
- message: "The Cloudflare Clef provider is not configured correctly.",
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\`.`
25
- };
26
- return code === "authentication" ? {
27
- code: "provider_authentication",
28
- message: "The model provider rejected the API key.",
29
- fix: `Set ${apiKeyEnv ?? "TYPESAFE_API_KEY"} to a valid key, check it with \`sedum doctor\`, then rerun.`
30
- } : {
31
- code: "provider_configuration",
32
- message: "The model provider is not configured correctly.",
33
- fix: `Check ${apiKeyEnv ?? "TYPESAFE_API_KEY"}, TYPESAFE_BASE_URL and the model with \`sedum doctor\`, then rerun.`
34
- };
35
- }
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) {
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
- };
54
- if (error instanceof ProviderError && error.code === "configuration")
55
- return providerName !== "typesafe" ? providerDiagnostic(providerName, "configuration", apiKeyEnv) : {
56
- code: "missing_key",
57
- message: "The model provider is not configured.",
58
- fix: `Set ${apiKeyEnv ?? "TYPESAFE_API_KEY"} for the configured endpoint, then rerun the command.`
59
- };
60
- if (error instanceof BrowserDriverError && error.code === "browser-missing")
61
- return {
62
- code: "browser_missing",
63
- message: "No supported browser binary was found.",
64
- fix: "Run `sedum browsers install chromium`, then rerun the test."
65
- };
66
- return {
67
- code: "setup_or_output_error",
68
- message: "The run could not be prepared safely.",
69
- fix: "Check the test path, provider key, browser installation, and write access, then rerun."
70
- };
71
- }
72
- function configDiagnostic(error) {
73
- const first = error.diagnostics[0];
74
- if (!first)
75
- return {
76
- code: "invalid_config",
77
- message: "The Sedum configuration is invalid.",
78
- fix: "Correct sedum.config.yaml and rerun the command."
79
- };
80
- return {
81
- code: first.code,
82
- message: bounded(
83
- `${first.file}:${first.line}:${first.col}: ${first.message} (key: ${first.key})`
84
- ),
85
- fix: bounded(first.fix)
86
- };
87
- }
88
- function outputDiagnostic(path) {
89
- return {
90
- code: "output_error",
91
- message: `The run result could not be written to ${path}.`,
92
- fix: "Make the configured output directory writable and rerun the command."
93
- };
94
- }
95
- function bounded(value, maximum = 512) {
96
- return [...value].slice(0, maximum).join("");
97
- }
98
- function canonicalDiagnosticError(diagnostic) {
99
- return {
100
- code: diagnostic.code,
101
- message: diagnostic.code === "output_error" ? "The run result could not be written." : bounded(diagnostic.message)
102
- };
103
- }
104
- function flowDiagnostic(result, providerName = "typesafe", apiKeyEnv) {
105
- if (result.code === "invalid_test" || result.code === "unsupported_test" || result.code === "invalid_data") {
106
- const source = result.source ? `${result.source.file}:${result.source.line}:${result.source.col}: ` : "";
107
- return {
108
- code: result.code,
109
- message: bounded(`${source}${result.message}`),
110
- fix: bounded(
111
- result.fix ?? "Fix the reported test input and rerun the command."
112
- )
113
- };
114
- }
115
- const known = {
116
- "browser-missing": {
117
- message: "No supported browser binary was found.",
118
- fix: "Run `sedum browsers install chromium`, then rerun the test."
119
- },
120
- "browser-launch-failed": {
121
- message: "The browser could not be started safely.",
122
- fix: "Check the browser installation and permissions, then rerun the test."
123
- },
124
- "browser-disconnected": {
125
- message: "The browser disconnected during the run.",
126
- fix: "Restart the browser run and check browser stability if it repeats."
127
- },
128
- "context-closed": {
129
- message: "The browser context closed during the run.",
130
- fix: "Rerun the test and check browser stability if it repeats."
131
- },
132
- "page-closed": {
133
- message: "The browser page closed during the run.",
134
- fix: "Rerun the test and check whether the tested page closes itself."
135
- },
136
- "page-crashed": {
137
- message: "The browser page crashed during the run.",
138
- fix: "Rerun the test and check browser resource usage if it repeats."
139
- },
140
- "operation-failed": {
141
- message: "A browser operation could not be completed safely.",
142
- fix: "Check the named test step and rerun the test."
143
- },
144
- "script-missing": {
145
- message: "The Sedum browser script was unavailable.",
146
- fix: "Rebuild or reinstall Sedum, then rerun the test."
147
- }
148
- };
149
- const diagnostic = known[result.code];
150
- if (diagnostic) return { code: result.code, ...diagnostic };
151
- if (result.code === "navigation_failed")
152
- return {
153
- code: result.code,
154
- message: bounded(result.message),
155
- fix: bounded(
156
- result.fix ?? "Check the test's url (or baseUrl), your network or VPN, and that the site is up."
157
- )
158
- };
159
- if (result.code === "provider_rate_limited")
160
- return {
161
- code: result.code,
162
- message: "The model provider kept rate limiting requests for five minutes.",
163
- fix: "Lower --parallel or --provider-concurrency, or retry later."
164
- };
165
- if (result.code === "provider_authentication")
166
- return providerDiagnostic(providerName, "authentication", apiKeyEnv);
167
- if (result.code === "provider_configuration")
168
- return providerDiagnostic(providerName, "configuration", apiKeyEnv);
169
- if (result.code.startsWith("provider_"))
170
- return {
171
- code: result.code,
172
- message: "The model provider could not complete the run safely.",
173
- fix: "Check provider availability and the test input, then rerun the test."
174
- };
175
- return {
176
- code: "execution_error",
177
- message: "The browser run could not be completed safely.",
178
- fix: "Check the browser, provider, and test input, then rerun the test."
179
- };
180
- }
181
- var RUN_STOPPING_CODES = /* @__PURE__ */ new Set([
182
- "browser-missing",
183
- "browser-launch-failed",
184
- "script-missing",
185
- "provider_configuration",
186
- "provider_authentication",
187
- "provider_rate_limited"
188
- ]);
189
- function stopsRun(code) {
190
- return RUN_STOPPING_CODES.has(code);
191
- }
192
- function renderDiagnostic(diagnostic) {
193
- return `${diagnostic.message}
194
- Fix: ${diagnostic.fix}
195
- `;
196
- }
197
-
198
- export {
199
- providerDiagnostic,
200
- DetectorUnsupportedError,
201
- setupDiagnostic,
202
- configDiagnostic,
203
- outputDiagnostic,
204
- canonicalDiagnosticError,
205
- flowDiagnostic,
206
- stopsRun,
207
- renderDiagnostic
208
- };