sedum-cli 0.1.0-alpha.3 → 0.1.0-alpha.4

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,9 +1,9 @@
1
1
  import {
2
2
  discoverRunTests
3
- } from "./chunk-3MCSCE7X.js";
3
+ } from "./chunk-UVCFRFDV.js";
4
4
  import {
5
5
  loadProjectConfig
6
- } from "./chunk-YXSAX7E3.js";
6
+ } from "./chunk-W2BEUHUB.js";
7
7
 
8
8
  // src/affected-selection.ts
9
9
  import { execFile } from "child_process";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  ProjectConfigError
3
- } from "./chunk-YXSAX7E3.js";
3
+ } from "./chunk-W2BEUHUB.js";
4
4
 
5
5
  // src/diagnostics.ts
6
6
  import { BrowserDriverError, ProviderError } from "@sedum-dev/core";
@@ -2,7 +2,7 @@ import {
2
2
  DEFAULT_PROVIDER_BASE_URL,
3
3
  DEFAULT_PROVIDER_MODEL,
4
4
  loadProjectConfig
5
- } from "./chunk-YXSAX7E3.js";
5
+ } from "./chunk-W2BEUHUB.js";
6
6
 
7
7
  // src/doctor-command.ts
8
8
  import { lstat, mkdir, mkdtemp, rm, rmdir, writeFile } from "fs/promises";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  discoverConfiguredTests
3
- } from "./chunk-YXSAX7E3.js";
3
+ } from "./chunk-W2BEUHUB.js";
4
4
 
5
5
  // src/run-selection.ts
6
6
  import { lstat, realpath } from "fs/promises";
@@ -3,12 +3,12 @@ import {
3
3
  clearLocatorCache,
4
4
  parseParallel,
5
5
  renderDiagnostic
6
- } from "./chunk-BI32AXS7.js";
6
+ } from "./chunk-72CYPRWT.js";
7
7
  import {
8
8
  ProjectConfigError,
9
9
  discoverConfiguredTests,
10
10
  loadProjectConfig
11
- } from "./chunk-YXSAX7E3.js";
11
+ } from "./chunk-W2BEUHUB.js";
12
12
 
13
13
  // src/exit-policy.ts
14
14
  import {
@@ -33,6 +33,7 @@ function listExitCode(listing, failedBeforeListing) {
33
33
 
34
34
  // src/output.ts
35
35
  import { validateRunResult as validateRunResult2 } from "@sedum-dev/core";
36
+ import { usageLines, visionSummary } from "@sedum-dev/reporters";
36
37
  var ansi = {
37
38
  green: "\x1B[32m",
38
39
  red: "\x1B[31m",
@@ -128,6 +129,20 @@ function renderRunSummary(result, capabilities, artifacts, showCosts) {
128
129
  `flags ${value.totals.flaggedSteps} flagged step(s), low_confidence ${flagCounts.low_confidence}, contradiction ${flagCounts.contradiction}`
129
130
  );
130
131
  lines.push(...executionLines(value));
132
+ for (const test of value.tests)
133
+ for (const attempt of test.attempts)
134
+ for (const step of attempt.steps) {
135
+ const vision = visionSummary(step);
136
+ if (vision)
137
+ lines.push(
138
+ `${test.file} \xB7 attempt ${attempt.ordinal} \xB7 step ${step.index}: ${vision}`.replace(
139
+ // Strip terminal control characters from provider metadata.
140
+ // eslint-disable-next-line no-control-regex
141
+ /[\u0000-\u001f\u007f-\u009f]/g,
142
+ " "
143
+ )
144
+ );
145
+ }
131
146
  if (artifacts.authoritative) {
132
147
  lines.push(`progress ${artifacts.progressPath}`);
133
148
  lines.push(`result ${artifacts.resultPath}`);
@@ -141,6 +156,7 @@ function renderRunSummary(result, capabilities, artifacts, showCosts) {
141
156
  lines.push(`result unavailable (intended ${artifacts.resultPath})`);
142
157
  }
143
158
  if (capabilities.stdoutIsTTY || showCosts) {
159
+ lines.push(...usageLines(value));
144
160
  lines.push(
145
161
  `model ${value.totals.modelCalls} call(s), ${value.totals.inputTokens} input tokens, ${value.totals.outputTokens} output tokens`
146
162
  );
@@ -595,7 +611,7 @@ async function runCli(args, version, runtime = {}) {
595
611
  const writeOut = runtime.stdout ?? ((value) => stdout.push(value));
596
612
  const writeErr = runtime.stderr ?? ((value) => stderr.push(value));
597
613
  const capabilities = runtime.capabilities ?? plainOutput;
598
- const executeRun = runtime.executeRun ?? (async (options) => (await import("./run-command-P72XF5MI.js")).executeRunCommand(options));
614
+ const executeRun = runtime.executeRun ?? (async (options) => (await import("./run-command-SUPJIEY5.js")).executeRunCommand(options));
599
615
  const cwd = runtime.cwd ?? process.cwd();
600
616
  let exitCode = 3;
601
617
  const program = new Command().name("sedum").description(
@@ -613,7 +629,7 @@ async function runCli(args, version, runtime = {}) {
613
629
  "after",
614
630
  "\nCreates a config, a SauceDemo example, .env.example, and ignore rules.\nExisting files are never replaced.\n"
615
631
  ).action(async () => {
616
- const { executeInitCommand } = await import("./init-command-EOS2MSWW.js");
632
+ const { executeInitCommand } = await import("./init-command-4RYOB737.js");
617
633
  const interactive = capabilities.stdoutIsTTY && (process.stdin.isTTY === true || runtime.confirmInit !== void 0);
618
634
  const confirm = runtime.confirmInit ?? (interactive ? async (question) => {
619
635
  const { createInterface } = await import("readline/promises");
@@ -674,7 +690,7 @@ async function runCli(args, version, runtime = {}) {
674
690
  "match id or description substring (repeatable)",
675
691
  collectValue,
676
692
  []
677
- ).option("--env <name>", "select a named environment").option("--browser <kind>", "chrome or chromium").option(
693
+ ).option("--env <name>", "select a named environment").option("--browser <kind>", "chrome or chromium").option("--vision", "enable vision fallback for ambiguous clicks").option("--no-vision", "disable vision fallback").option("--vision-model <model>", "override the OpenRouter vision model").option(
678
694
  "--url-override <url>",
679
695
  "replace entry URL origin for preview deployments"
680
696
  ).option("--output-dir <path>", "run output directory").option("--reporter-dir <path>", "reporter artifact directory").option("--headed", "show the browser", false).option(
@@ -755,7 +771,7 @@ async function runCli(args, version, runtime = {}) {
755
771
  return;
756
772
  }
757
773
  if (options.affected) {
758
- const { selectAffectedTests, AffectedSelectionError } = await import("./affected-selection-YIHBKUST.js");
774
+ const { selectAffectedTests, AffectedSelectionError } = await import("./affected-selection-5YF7ZHKG.js");
759
775
  const { ProviderError: ProviderError2 } = await import("@sedum-dev/core");
760
776
  writeErr(
761
777
  "Experimental selection sends the tracked Git diff and test/module sources to the configured TypeSafe provider. Full CI is still recommended.\n"
@@ -852,6 +868,8 @@ No tests were run. Fix the selection error or run without --affected.
852
868
  },
853
869
  ...options.env ? { environment: options.env } : {},
854
870
  ...options.browser ? { browser: options.browser } : {},
871
+ ...options.vision !== void 0 ? { vision: options.vision } : {},
872
+ ...options.visionModel !== void 0 ? { visionModel: options.visionModel } : {},
855
873
  ...options.urlOverride ? { urlOverride: options.urlOverride } : {},
856
874
  ...options.outputDir ? { outputDir: options.outputDir } : {},
857
875
  ...options.reporterDir ? { reporterDir: options.reporterDir } : {},
@@ -937,7 +955,7 @@ No tests were run. Fix the selection error or run without --affected.
937
955
  "after",
938
956
  "\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"
939
957
  ).action(async (options) => {
940
- const { executeDoctorCommand, renderDoctorText } = await import("./doctor-command-A4FTFRUH.js");
958
+ const { executeDoctorCommand, renderDoctorText } = await import("./doctor-command-EU5OJJ5P.js");
941
959
  const result = await executeDoctorCommand(cwd, runtime.doctorProbes);
942
960
  writeOut(
943
961
  options.json ? `${JSON.stringify(result)}
@@ -25,7 +25,12 @@ 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
  };
30
35
  var DEFAULT_PROVIDER_BASE_URL = "https://api.typesafe.ai";
31
36
  var DEFAULT_PROVIDER_MODEL = "jev-latest";
@@ -40,12 +45,14 @@ var allowed = {
40
45
  "baseUrl",
41
46
  "environment",
42
47
  "variables",
43
- "environments"
48
+ "environments",
49
+ "vision"
44
50
  ]),
45
51
  tests: /* @__PURE__ */ new Set(["directory", "include", "exclude"]),
46
52
  viewport: /* @__PURE__ */ new Set(["width", "height"]),
47
53
  thresholds: /* @__PURE__ */ new Set(["verify", "lowConfidenceBand", "contradiction"]),
48
- environment: /* @__PURE__ */ new Set(["baseUrl", "variables"])
54
+ environment: /* @__PURE__ */ new Set(["baseUrl", "variables"]),
55
+ vision: /* @__PURE__ */ new Set(["enabled", "model", "timeoutMs"])
49
56
  };
50
57
  function source(file, counter, node) {
51
58
  const position = counter.linePos(node?.range?.[0] ?? 0);
@@ -97,7 +104,7 @@ function scalarVariables(value, key, diagnostics, file, counter, node) {
97
104
  }
98
105
  const result = {};
99
106
  for (const [name, item] of Object.entries(value)) {
100
- if (name === "TYPESAFE_API_KEY") {
107
+ if (name === "TYPESAFE_API_KEY" || name === "OPEN_ROUTER_API_KEY") {
101
108
  diagnostic(
102
109
  diagnostics,
103
110
  file,
@@ -275,6 +282,7 @@ function freeze(config) {
275
282
  Object.freeze(config.exclude);
276
283
  Object.freeze(config.viewport);
277
284
  Object.freeze(config.thresholds);
285
+ Object.freeze(config.vision);
278
286
  Object.freeze(config.variables);
279
287
  return Object.freeze(config);
280
288
  }
@@ -373,7 +381,8 @@ async function loadProjectConfig(start = process.cwd(), hostEnvironment = proces
373
381
  const maps = [
374
382
  ["tests", allowed.tests],
375
383
  ["viewport", allowed.viewport],
376
- ["thresholds", allowed.thresholds]
384
+ ["thresholds", allowed.thresholds],
385
+ ["vision", allowed.vision]
377
386
  ];
378
387
  for (const [key, names] of maps)
379
388
  mapUnknownKeys(
@@ -412,7 +421,8 @@ async function loadProjectConfig(start = process.cwd(), hostEnvironment = proces
412
421
  for (const [key, value] of [
413
422
  ["viewport", raw.viewport],
414
423
  ["thresholds", raw.thresholds],
415
- ["environments", raw.environments]
424
+ ["environments", raw.environments],
425
+ ["vision", raw.vision]
416
426
  ])
417
427
  if (value !== void 0 && !object(value))
418
428
  diagnostic(
@@ -428,6 +438,7 @@ async function loadProjectConfig(start = process.cwd(), hostEnvironment = proces
428
438
  const viewport = object(raw.viewport) ? raw.viewport : {};
429
439
  const thresholds = object(raw.thresholds) ? raw.thresholds : {};
430
440
  const environments = object(raw.environments) ? raw.environments : {};
441
+ const vision = object(raw.vision) ? raw.vision : {};
431
442
  for (const [name, value] of Object.entries(environments)) {
432
443
  if (!object(value)) {
433
444
  diagnostic(
@@ -633,6 +644,46 @@ async function loadProjectConfig(start = process.cwd(), hostEnvironment = proces
633
644
  }
634
645
  const providerModel = customProvider.model ?? DEFAULT_PROVIDER_MODEL;
635
646
  const apiKey = providerValue("TYPESAFE_API_KEY");
647
+ const visionApiKey = providerValue("OPEN_ROUTER_API_KEY");
648
+ variables.OPEN_ROUTER_API_KEY = void 0;
649
+ const visionEnabledValue = overrides.vision?.enabled ?? vision.enabled;
650
+ const visionEnabled = visionEnabledValue ?? DEFAULTS.vision.enabled;
651
+ if (typeof visionEnabled !== "boolean")
652
+ diagnostic(
653
+ diagnostics,
654
+ file,
655
+ counter,
656
+ node("vision.enabled"),
657
+ "vision.enabled",
658
+ "invalid_config_type",
659
+ "Configuration key `vision.enabled` must be a boolean.",
660
+ "Use `vision.enabled: true` or `vision.enabled: false`."
661
+ );
662
+ const visionModelValue = overrides.vision?.model ?? vision.model;
663
+ const visionModel = visionModelValue ?? DEFAULTS.vision.model;
664
+ if (typeof visionModel !== "string" || !visionModel.trim())
665
+ diagnostic(
666
+ diagnostics,
667
+ file,
668
+ counter,
669
+ node("vision.model"),
670
+ "vision.model",
671
+ "invalid_config_type",
672
+ "Configuration key `vision.model` must be nonempty text.",
673
+ `Use a model such as \`${DEFAULTS.vision.model}\`.`
674
+ );
675
+ const visionTimeoutValue = vision.timeoutMs ?? DEFAULTS.vision.timeoutMs;
676
+ if (!Number.isSafeInteger(visionTimeoutValue) || visionTimeoutValue < 1)
677
+ diagnostic(
678
+ diagnostics,
679
+ file,
680
+ counter,
681
+ node("vision.timeoutMs"),
682
+ "vision.timeoutMs",
683
+ "invalid_config_type",
684
+ "Configuration key `vision.timeoutMs` must be a positive integer.",
685
+ "Use a timeout such as `10000`."
686
+ );
636
687
  const testDirectory = relativePath(
637
688
  found.root,
638
689
  tests.directory,
@@ -698,7 +749,13 @@ async function loadProjectConfig(start = process.cwd(), hostEnvironment = proces
698
749
  variables,
699
750
  apiKey,
700
751
  providerBaseUrl,
701
- providerModel
752
+ providerModel,
753
+ vision: {
754
+ enabled: visionEnabled === true,
755
+ model: typeof visionModel === "string" && visionModel.trim() ? visionModel : DEFAULTS.vision.model,
756
+ timeoutMs: Number.isSafeInteger(visionTimeoutValue) && visionTimeoutValue > 0 ? visionTimeoutValue : DEFAULTS.vision.timeoutMs
757
+ },
758
+ visionApiKey
702
759
  });
703
760
  }
704
761
  async function discoverConfiguredTests(config) {
package/dist/cli.js CHANGED
@@ -1,9 +1,9 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  runCli
4
- } from "./chunk-AZJ7JJ6P.js";
5
- import "./chunk-BI32AXS7.js";
6
- import "./chunk-YXSAX7E3.js";
4
+ } from "./chunk-V4JF5CPE.js";
5
+ import "./chunk-72CYPRWT.js";
6
+ import "./chunk-W2BEUHUB.js";
7
7
 
8
8
  // src/cli.ts
9
9
  import { createRequire } from "module";
@@ -5,8 +5,8 @@ import {
5
5
  keyPresent,
6
6
  renderDoctorText,
7
7
  supportedNode
8
- } from "./chunk-CZDCGWWD.js";
9
- import "./chunk-YXSAX7E3.js";
8
+ } from "./chunk-UACA6VAM.js";
9
+ import "./chunk-W2BEUHUB.js";
10
10
  export {
11
11
  browserAvailable,
12
12
  checkOutputWritable,
package/dist/index.d.ts CHANGED
@@ -42,6 +42,10 @@ interface ProjectConfigOverrides {
42
42
  readonly outputDir?: string;
43
43
  readonly reporterDir?: string;
44
44
  readonly baseUrl?: string;
45
+ readonly vision?: {
46
+ readonly enabled?: boolean;
47
+ readonly model?: string;
48
+ };
45
49
  }
46
50
  interface ResolvedProjectConfig {
47
51
  readonly projectRoot: string;
@@ -63,6 +67,12 @@ interface ResolvedProjectConfig {
63
67
  readonly apiKey: string | undefined;
64
68
  readonly providerBaseUrl: string;
65
69
  readonly providerModel: string;
70
+ readonly vision: {
71
+ readonly enabled: boolean;
72
+ readonly model: string;
73
+ readonly timeoutMs: number;
74
+ };
75
+ readonly visionApiKey: string | undefined;
66
76
  }
67
77
  interface ProjectConfigLoadOptions {
68
78
  /**
@@ -101,6 +111,8 @@ interface RunCommandOptions {
101
111
  readonly filters?: RunFilters;
102
112
  readonly environment?: string;
103
113
  readonly browser?: string;
114
+ readonly vision?: boolean;
115
+ readonly visionModel?: string;
104
116
  readonly urlOverride?: string;
105
117
  readonly outputDir?: string;
106
118
  readonly reporterDir?: string;
package/dist/index.js CHANGED
@@ -2,13 +2,13 @@ import {
2
2
  renderRunSummary,
3
3
  runCli,
4
4
  runExitCode
5
- } from "./chunk-AZJ7JJ6P.js";
6
- import "./chunk-BI32AXS7.js";
5
+ } from "./chunk-V4JF5CPE.js";
6
+ import "./chunk-72CYPRWT.js";
7
7
  import {
8
8
  ProjectConfigError,
9
9
  discoverConfiguredTests,
10
10
  loadProjectConfig
11
- } from "./chunk-YXSAX7E3.js";
11
+ } from "./chunk-W2BEUHUB.js";
12
12
  export {
13
13
  ProjectConfigError,
14
14
  discoverConfiguredTests,
@@ -2,11 +2,11 @@ import {
2
2
  browserAvailable,
3
3
  keyPresent,
4
4
  supportedNode
5
- } from "./chunk-CZDCGWWD.js";
5
+ } from "./chunk-UACA6VAM.js";
6
6
  import {
7
7
  ProjectConfigError,
8
8
  loadProjectConfig
9
- } from "./chunk-YXSAX7E3.js";
9
+ } from "./chunk-W2BEUHUB.js";
10
10
 
11
11
  // src/init-command.ts
12
12
  import { constants } from "fs";
@@ -6,14 +6,14 @@ import {
6
6
  planLanes,
7
7
  runPool,
8
8
  setupDiagnostic
9
- } from "./chunk-BI32AXS7.js";
9
+ } from "./chunk-72CYPRWT.js";
10
10
  import {
11
11
  discoverRunTests
12
- } from "./chunk-3MCSCE7X.js";
12
+ } from "./chunk-UVCFRFDV.js";
13
13
  import {
14
14
  ProjectConfigError,
15
15
  loadProjectConfig
16
- } from "./chunk-YXSAX7E3.js";
16
+ } from "./chunk-W2BEUHUB.js";
17
17
 
18
18
  // src/run-command.ts
19
19
  import {
@@ -21,6 +21,7 @@ import {
21
21
  PlaywrightBrowserDriver,
22
22
  ReusableBrowserDriver,
23
23
  RunRecorder,
24
+ OpenRouterVisionResolver,
24
25
  runFlow,
25
26
  safeText,
26
27
  validateRunResult as validateRunResult2
@@ -641,8 +642,26 @@ async function executeRunCommand(options) {
641
642
  ...options.environment ? { environment: options.environment } : {},
642
643
  ...options.browser ? { browser: options.browser } : {},
643
644
  ...options.outputDir ? { outputDir: options.outputDir } : {},
644
- ...options.reporterDir ? { reporterDir: options.reporterDir } : {}
645
+ ...options.reporterDir ? { reporterDir: options.reporterDir } : {},
646
+ ...options.vision !== void 0 || options.visionModel !== void 0 ? {
647
+ vision: {
648
+ ...options.vision !== void 0 ? { enabled: options.vision } : {},
649
+ ...options.visionModel !== void 0 ? { model: options.visionModel } : {}
650
+ }
651
+ } : {}
645
652
  });
653
+ if (config.vision.enabled && !config.visionApiKey)
654
+ throw new ProjectConfigError([
655
+ {
656
+ code: "missing_vision_api_key",
657
+ file: path3.join(config.projectRoot, ".env"),
658
+ line: 1,
659
+ col: 1,
660
+ key: "OPEN_ROUTER_API_KEY",
661
+ message: "Vision fallback requires OPEN_ROUTER_API_KEY.",
662
+ fix: "Set OPEN_ROUTER_API_KEY in the invoking process or project-root .env, or disable vision."
663
+ }
664
+ ]);
646
665
  } catch (error) {
647
666
  const diagnostic = setupDiagnostic(error);
648
667
  const fallbackRoot = error instanceof ProjectConfigError && error.diagnostics[0]?.file ? path3.dirname(error.diagnostics[0].file) : invocationRoot;
@@ -984,6 +1003,11 @@ async function executeRunCommand(options) {
984
1003
  ciOptIn: options.locatorCacheCi ?? false,
985
1004
  env: process.env
986
1005
  });
1006
+ const visionResolver = config.vision.enabled ? new OpenRouterVisionResolver({
1007
+ apiKey: config.visionApiKey,
1008
+ model: config.vision.model,
1009
+ timeoutMs: config.vision.timeoutMs
1010
+ }) : void 0;
987
1011
  let operational = null;
988
1012
  const driver = new PlaywrightBrowserDriver();
989
1013
  const browsers = Array.from(
@@ -1006,6 +1030,7 @@ async function executeRunCommand(options) {
1006
1030
  provider,
1007
1031
  classificationCache: cache,
1008
1032
  locatorCache,
1033
+ ...visionResolver ? { visionResolver } : {},
1009
1034
  // Per-attempt values let tests keep backend data apart, like
1010
1035
  // Playwright's TEST_PARALLEL_INDEX. They are env-derived, so
1011
1036
  // they stay opaque in model input and reports.
@@ -1043,7 +1068,8 @@ async function executeRunCommand(options) {
1043
1068
  operational ??= flowDiagnostic(result);
1044
1069
  return "stop";
1045
1070
  }
1046
- if (result.status === "passed") break;
1071
+ if (result.status === "passed" || result.retryable === false)
1072
+ break;
1047
1073
  }
1048
1074
  return "continue";
1049
1075
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sedum-cli",
3
- "version": "0.1.0-alpha.3",
3
+ "version": "0.1.0-alpha.4",
4
4
  "repository": "https://github.com/sedum-dev/sedum",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -25,9 +25,9 @@
25
25
  "commander": "14.0.2",
26
26
  "minimatch": "10.2.6",
27
27
  "yaml": "2.9.1",
28
- "@sedum-dev/core": "0.1.0-alpha.3",
29
- "@sedum-dev/provider-typesafe": "0.1.0-alpha.3",
30
- "@sedum-dev/reporters": "0.1.0-alpha.3"
28
+ "@sedum-dev/core": "0.1.0-alpha.4",
29
+ "@sedum-dev/provider-typesafe": "0.1.0-alpha.4",
30
+ "@sedum-dev/reporters": "0.1.0-alpha.4"
31
31
  },
32
32
  "scripts": {
33
33
  "build": "tsup src/index.ts src/cli.ts --format esm --dts --clean --out-dir dist",