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

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,14 +1,20 @@
1
1
  import {
2
+ DEFAULT_PROVIDER_BASE_URL,
3
+ DEFAULT_PROVIDER_MODEL,
2
4
  loadProjectConfig
3
- } from "./chunk-TZGSCV23.js";
5
+ } from "./chunk-FAGJCNV7.js";
4
6
 
5
7
  // src/doctor-command.ts
6
8
  import { lstat, mkdir, mkdtemp, rm, rmdir, writeFile } from "fs/promises";
7
9
  import path from "path";
8
- import { findBrowserExecutable } from "@sedum-dev/core";
10
+ import {
11
+ findBrowserExecutable,
12
+ probeOpenRouterKey
13
+ } from "@sedum-dev/core";
9
14
  import {
10
15
  probeTypeSafeApiKey
11
16
  } from "@sedum-dev/provider-typesafe";
17
+ var CLOUDFLARE_API = "https://api.cloudflare.com";
12
18
  var pass = (id, message) => ({
13
19
  id,
14
20
  status: "pass",
@@ -29,11 +35,13 @@ function browserAvailable(kind) {
29
35
  return findBrowserExecutable(kind) !== null;
30
36
  }
31
37
  function keyPresent(config) {
32
- return Boolean(config.apiKey?.trim());
38
+ return Boolean(
39
+ config.apiKey?.trim() && (config.providerName !== "clef" || config.cloudflareAccountId?.trim())
40
+ );
33
41
  }
34
- async function networkReachable() {
42
+ async function networkReachable(baseURL) {
35
43
  try {
36
- await fetch("https://api.typesafe.ai/", {
44
+ await fetch(baseURL, {
37
45
  method: "GET",
38
46
  redirect: "manual",
39
47
  signal: AbortSignal.timeout(5e3)
@@ -77,7 +85,7 @@ async function checkOutputWritable(config) {
77
85
  }
78
86
  }
79
87
  }
80
- async function executeDoctorCommand(cwd, probes = {}) {
88
+ async function executeDoctorCommand(cwd, probes = {}, options = {}) {
81
89
  const checks = [];
82
90
  const version = probes.nodeVersion ?? process.versions.node;
83
91
  checks.push(
@@ -128,17 +136,19 @@ async function executeDoctorCommand(cwd, probes = {}) {
128
136
  )
129
137
  );
130
138
  }
139
+ const providerBaseUrl = config?.providerName === "clef" ? CLOUDFLARE_API : config?.providerBaseUrl ?? DEFAULT_PROVIDER_BASE_URL;
140
+ const providerModel = config?.providerModel ?? DEFAULT_PROVIDER_MODEL;
131
141
  let network = false;
132
142
  try {
133
- network = await (probes.network ?? networkReachable)();
143
+ network = await (probes.network ?? networkReachable)(providerBaseUrl);
134
144
  } catch {
135
145
  network = false;
136
146
  }
137
147
  checks.push(
138
- network ? pass("api_network", "TypeSafe API is reachable.") : fail(
148
+ network ? pass("api_network", "Model provider API is reachable.") : fail(
139
149
  "api_network",
140
- "TypeSafe API could not be reached.",
141
- "Check DNS, TLS, proxy, firewall, and access to https://api.typesafe.ai."
150
+ "Model provider API could not be reached.",
151
+ `Check DNS, TLS, proxy, firewall, and access to ${providerBaseUrl}.`
142
152
  )
143
153
  );
144
154
  const key = config && keyPresent(config) ? config.apiKey?.trim() : void 0;
@@ -147,10 +157,10 @@ async function executeDoctorCommand(cwd, probes = {}) {
147
157
  "api_key",
148
158
  "API key source could not be read.",
149
159
  "Fix project configuration, then rerun doctor."
150
- ) : key ? pass("api_key", "TYPESAFE_API_KEY is present.") : fail(
160
+ ) : key ? pass("api_key", "Provider API key is present.") : fail(
151
161
  "api_key",
152
- "TYPESAFE_API_KEY is missing.",
153
- "Set TYPESAFE_API_KEY in the process environment or project-root .env."
162
+ "Provider API key is missing.",
163
+ config.providerName === "clef" ? "Set CLOUDFLARE_ACCOUNT_ID and CLOUDFLARE_AUTH_TOKEN (or CLOUDFLARE_API_TOKEN)." : "Set TYPESAFE_API_KEY for the configured endpoint."
154
164
  )
155
165
  );
156
166
  if (!config)
@@ -166,7 +176,7 @@ async function executeDoctorCommand(cwd, probes = {}) {
166
176
  fail(
167
177
  "api_auth",
168
178
  "API authentication could not be checked without a key.",
169
- "Set TYPESAFE_API_KEY, then rerun doctor."
179
+ config.providerName === "clef" ? "Set CLOUDFLARE_ACCOUNT_ID and CLOUDFLARE_AUTH_TOKEN (or CLOUDFLARE_API_TOKEN), then rerun doctor." : "Set TYPESAFE_API_KEY, then rerun doctor."
170
180
  )
171
181
  );
172
182
  else if (!network)
@@ -174,31 +184,82 @@ async function executeDoctorCommand(cwd, probes = {}) {
174
184
  fail(
175
185
  "api_auth",
176
186
  "API authentication could not be checked without API access.",
177
- "Restore TypeSafe API network access, then rerun doctor."
187
+ "Restore model provider API network access, then rerun doctor."
178
188
  )
179
189
  );
180
190
  else {
181
191
  let result;
182
192
  try {
183
- result = await (probes.auth ?? probeTypeSafeApiKey)(key);
193
+ if (config.providerName === "clef") {
194
+ result = probes.auth ? await probes.auth(key, {
195
+ baseURL: providerBaseUrl,
196
+ model: providerModel
197
+ }) : await (await import("@sedum-dev/provider-clef")).probeClefApiKey(key, {
198
+ accountId: config.cloudflareAccountId,
199
+ model: providerModel
200
+ });
201
+ } else
202
+ result = await (probes.auth ?? probeTypeSafeApiKey)(key, {
203
+ baseURL: providerBaseUrl,
204
+ model: providerModel
205
+ });
184
206
  } catch {
185
207
  result = "unavailable";
186
208
  }
187
209
  checks.push(
188
- result === "accepted" ? pass("api_auth", "TypeSafe API accepted the key.") : result === "rejected" ? fail(
210
+ result === "accepted" ? pass(
189
211
  "api_auth",
190
- "TypeSafe API rejected the key.",
191
- "Replace TYPESAFE_API_KEY with a valid key and rerun doctor."
212
+ config.providerName === "clef" ? "Cloudflare completed the explicitly billable inference probe." : "Model provider API accepted the key."
213
+ ) : result === "rejected" ? fail(
214
+ "api_auth",
215
+ config.providerName === "clef" ? "Cloudflare rejected the configured API token." : "Model provider API rejected the key.",
216
+ config.providerName === "clef" ? "Check CLOUDFLARE_ACCOUNT_ID, then replace CLOUDFLARE_AUTH_TOKEN (or CLOUDFLARE_API_TOKEN) with a token for that account that has Workers AI Read and Edit permissions." : "Replace TYPESAFE_API_KEY with a valid key and rerun doctor."
192
217
  ) : result === "unreachable" ? fail(
193
218
  "api_auth",
194
- "Authenticated TypeSafe request could not reach the API.",
219
+ "Authenticated provider request could not reach the API.",
195
220
  "Check the API connection and retry."
196
221
  ) : fail(
197
222
  "api_auth",
198
- "TypeSafe could not complete the authentication probe.",
199
- "Check API availability and account access, then retry."
223
+ "The model provider could not complete the authentication probe.",
224
+ config.providerName === "clef" ? "Check Cloudflare API availability, CLOUDFLARE_ACCOUNT_ID, and Workers AI access, then retry." : "Check API availability and account access, then retry."
225
+ )
226
+ );
227
+ }
228
+ if (config && (options.vision || config.vision.enabled)) {
229
+ const visionKey = config.visionApiKey?.trim();
230
+ checks.push(
231
+ visionKey ? pass(
232
+ "vision_key",
233
+ "OpenRouter API key for vision fallback is present."
234
+ ) : fail(
235
+ "vision_key",
236
+ "Vision fallback is enabled but OPEN_ROUTER_API_KEY is missing.",
237
+ "Set OPEN_ROUTER_API_KEY in the environment or the project-root .env."
200
238
  )
201
239
  );
240
+ if (visionKey) {
241
+ const result = await (probes.visionAuth ?? probeOpenRouterKey)(
242
+ visionKey
243
+ ).catch(() => "unreachable");
244
+ checks.push(
245
+ result === "accepted" ? pass("vision_auth", "OpenRouter accepted the vision key.") : result === "rejected" ? fail(
246
+ "vision_auth",
247
+ "OpenRouter rejected OPEN_ROUTER_API_KEY.",
248
+ "Replace OPEN_ROUTER_API_KEY with a valid OpenRouter key and rerun doctor."
249
+ ) : fail(
250
+ "vision_auth",
251
+ "OpenRouter could not be reached to check the vision key.",
252
+ "Check access to https://openrouter.ai and retry."
253
+ )
254
+ );
255
+ } else
256
+ checks.push(
257
+ fail(
258
+ "vision_auth",
259
+ "The vision key could not be checked without a key.",
260
+ "Set OPEN_ROUTER_API_KEY, then rerun doctor."
261
+ )
262
+ );
202
263
  }
203
264
  if (config) {
204
265
  try {
@@ -0,0 +1,208 @@
1
+ import {
2
+ ProjectConfigError
3
+ } from "./chunk-FAGJCNV7.js";
4
+
5
+ // src/diagnostics.ts
6
+ import { BrowserDriverError, ProviderError } from "@sedum-dev/core";
7
+ function providerDiagnostic(providerName, code) {
8
+ if (providerName === "clef")
9
+ return code === "authentication" ? {
10
+ code: "provider_authentication",
11
+ message: "Cloudflare rejected the configured API token.",
12
+ fix: "Check CLOUDFLARE_ACCOUNT_ID, replace CLOUDFLARE_AUTH_TOKEN (or CLOUDFLARE_API_TOKEN) with a token for that account that has Workers AI Read and Edit permissions, run `sedum doctor`, then rerun."
13
+ } : {
14
+ code: "provider_configuration",
15
+ message: "The Cloudflare Clef provider is not configured correctly.",
16
+ fix: "Set CLOUDFLARE_ACCOUNT_ID and CLOUDFLARE_AUTH_TOKEN (or CLOUDFLARE_API_TOKEN), then check the account, Workers AI access, and model with `sedum doctor`."
17
+ };
18
+ return code === "authentication" ? {
19
+ code: "provider_authentication",
20
+ message: "The model provider rejected the API key.",
21
+ fix: "Set TYPESAFE_API_KEY to a valid key, check it with `sedum doctor`, then rerun."
22
+ } : {
23
+ code: "provider_configuration",
24
+ message: "The model provider is not configured correctly.",
25
+ fix: "Check TYPESAFE_API_KEY, TYPESAFE_BASE_URL and the model with `sedum doctor`, then rerun."
26
+ };
27
+ }
28
+ function setupDiagnostic(error, providerName = "typesafe") {
29
+ if (error instanceof ProjectConfigError) return configDiagnostic(error);
30
+ if (error instanceof ProviderError && error.code === "configuration")
31
+ return providerName === "clef" ? providerDiagnostic(providerName, "configuration") : {
32
+ code: "missing_key",
33
+ message: "The model provider is not configured.",
34
+ fix: "Set TYPESAFE_API_KEY for the configured endpoint, then rerun the command."
35
+ };
36
+ if (error instanceof BrowserDriverError && error.code === "browser-missing")
37
+ return {
38
+ code: "browser_missing",
39
+ message: "No supported browser binary was found.",
40
+ fix: "Run `sedum browsers install chromium`, then rerun the test."
41
+ };
42
+ return {
43
+ code: "setup_or_output_error",
44
+ message: "The run could not be prepared safely.",
45
+ fix: "Check the test path, provider key, browser installation, and write access, then rerun."
46
+ };
47
+ }
48
+ function configDiagnostic(error) {
49
+ const first = error.diagnostics[0];
50
+ if (!first)
51
+ return {
52
+ code: "invalid_config",
53
+ message: "The Sedum configuration is invalid.",
54
+ fix: "Correct sedum.config.yaml and rerun the command."
55
+ };
56
+ return {
57
+ code: first.code,
58
+ message: bounded(
59
+ `${first.file}:${first.line}:${first.col}: ${first.message} (key: ${first.key})`
60
+ ),
61
+ fix: bounded(first.fix)
62
+ };
63
+ }
64
+ function outputDiagnostic(path) {
65
+ return {
66
+ code: "output_error",
67
+ message: `The run result could not be written to ${path}.`,
68
+ fix: "Make the configured output directory writable and rerun the command."
69
+ };
70
+ }
71
+ function bounded(value, maximum = 512) {
72
+ return [...value].slice(0, maximum).join("");
73
+ }
74
+ function canonicalDiagnosticError(diagnostic) {
75
+ return {
76
+ code: diagnostic.code,
77
+ message: diagnostic.code === "output_error" ? "The run result could not be written." : bounded(diagnostic.message)
78
+ };
79
+ }
80
+ function flowDiagnostic(result, providerName = "typesafe") {
81
+ if (result.code === "invalid_test" || result.code === "unsupported_test" || result.code === "invalid_data") {
82
+ const source = result.source ? `${result.source.file}:${result.source.line}:${result.source.col}: ` : "";
83
+ return {
84
+ code: result.code,
85
+ message: bounded(`${source}${result.message}`),
86
+ fix: bounded(
87
+ result.fix ?? "Fix the reported test input and rerun the command."
88
+ )
89
+ };
90
+ }
91
+ const known = {
92
+ "browser-missing": {
93
+ message: "No supported browser binary was found.",
94
+ fix: "Run `sedum browsers install chromium`, then rerun the test."
95
+ },
96
+ "browser-launch-failed": {
97
+ message: "The browser could not be started safely.",
98
+ fix: "Check the browser installation and permissions, then rerun the test."
99
+ },
100
+ "browser-disconnected": {
101
+ message: "The browser disconnected during the run.",
102
+ fix: "Restart the browser run and check browser stability if it repeats."
103
+ },
104
+ "context-closed": {
105
+ message: "The browser context closed during the run.",
106
+ fix: "Rerun the test and check browser stability if it repeats."
107
+ },
108
+ "page-closed": {
109
+ message: "The browser page closed during the run.",
110
+ fix: "Rerun the test and check whether the tested page closes itself."
111
+ },
112
+ "page-crashed": {
113
+ message: "The browser page crashed during the run.",
114
+ fix: "Rerun the test and check browser resource usage if it repeats."
115
+ },
116
+ "operation-failed": {
117
+ message: "A browser operation could not be completed safely.",
118
+ fix: "Check the named test step and rerun the test."
119
+ },
120
+ "script-missing": {
121
+ message: "The Sedum browser script was unavailable.",
122
+ fix: "Rebuild or reinstall Sedum, then rerun the test."
123
+ }
124
+ };
125
+ const diagnostic = known[result.code];
126
+ if (diagnostic) return { code: result.code, ...diagnostic };
127
+ if (result.code === "navigation_failed")
128
+ return {
129
+ code: result.code,
130
+ message: bounded(result.message),
131
+ fix: bounded(
132
+ result.fix ?? "Check the test's url (or baseUrl), your network or VPN, and that the site is up."
133
+ )
134
+ };
135
+ if (result.code === "provider_rate_limited")
136
+ return {
137
+ code: result.code,
138
+ message: "The model provider kept rate limiting requests for five minutes.",
139
+ fix: "Lower --parallel or --provider-concurrency, or retry later."
140
+ };
141
+ if (result.code === "provider_authentication")
142
+ return providerDiagnostic(providerName, "authentication");
143
+ if (result.code === "provider_configuration")
144
+ return providerDiagnostic(providerName, "configuration");
145
+ if (result.code.startsWith("provider_"))
146
+ return {
147
+ code: result.code,
148
+ message: "The model provider could not complete the run safely.",
149
+ fix: "Check provider availability and the test input, then rerun the test."
150
+ };
151
+ return {
152
+ code: "execution_error",
153
+ message: "The browser run could not be completed safely.",
154
+ fix: "Check the browser, provider, and test input, then rerun the test."
155
+ };
156
+ }
157
+ var RUN_STOPPING_CODES = /* @__PURE__ */ new Set([
158
+ "browser-missing",
159
+ "browser-launch-failed",
160
+ "script-missing",
161
+ "provider_configuration",
162
+ "provider_authentication",
163
+ "provider_rate_limited"
164
+ ]);
165
+ function stopsRun(code) {
166
+ return RUN_STOPPING_CODES.has(code);
167
+ }
168
+ function renderDiagnostic(diagnostic) {
169
+ return `${diagnostic.message}
170
+ Fix: ${diagnostic.fix}
171
+ `;
172
+ }
173
+
174
+ // src/provider-factory.ts
175
+ import { ProviderGate } from "@sedum-dev/core";
176
+ async function createCliProvider(config, options = {}) {
177
+ const gate = options.gate ?? new ProviderGate(
178
+ options.concurrency === void 0 ? {} : { concurrency: options.concurrency }
179
+ );
180
+ if (config.providerName === "clef") {
181
+ const { ClefAdapter } = await import("@sedum-dev/provider-clef");
182
+ return new ClefAdapter({
183
+ accountId: config.cloudflareAccountId ?? "",
184
+ apiKey: config.apiKey ?? "",
185
+ model: config.providerModel,
186
+ gate
187
+ });
188
+ }
189
+ const { TypeSafeAdapter } = await import("@sedum-dev/provider-typesafe");
190
+ return new TypeSafeAdapter({
191
+ ...config.apiKey ? { apiKey: config.apiKey } : {},
192
+ baseURL: config.providerBaseUrl,
193
+ model: config.providerModel,
194
+ gate
195
+ });
196
+ }
197
+
198
+ export {
199
+ providerDiagnostic,
200
+ setupDiagnostic,
201
+ configDiagnostic,
202
+ outputDiagnostic,
203
+ canonicalDiagnosticError,
204
+ flowDiagnostic,
205
+ stopsRun,
206
+ renderDiagnostic,
207
+ createCliProvider
208
+ };
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-HT6BIET2.js";
6
+ import "./chunk-EFRMSNBD.js";
7
+ import "./chunk-S7OB3JEF.js";
8
+ import "./chunk-FAGJCNV7.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-HXQDSNLL.js";
9
+ import "./chunk-FAGJCNV7.js";
10
10
  export {
11
11
  browserAvailable,
12
12
  checkOutputWritable,
package/dist/index.d.ts CHANGED
@@ -1,5 +1,6 @@
1
- import { RunResult, BrowserKind, VerifyPolicy, ClassificationProvider, BrowserInstallResult } from '@sedum-dev/core';
1
+ import { RunResult, BrowserKind, VerifyPolicy, VisionKeyProbe, RelevanceProvider, ClassificationProvider, BrowserInstallResult } from '@sedum-dev/core';
2
2
  import { AuthProbeResult } from '@sedum-dev/provider-typesafe';
3
+ export { Ai, AiValue, AiValues, BrowserContext, Locator, Page, Parser, SecretValue, TestBody, TestContext, TestInfo, TestOptions, expect, secret, test } from '@sedum-dev/core/script';
3
4
 
4
5
  interface OutputCapabilities {
5
6
  readonly stdoutIsTTY: boolean;
@@ -18,6 +19,8 @@ interface RunArtifactPaths {
18
19
  }
19
20
  declare function renderRunSummary(result: RunResult, capabilities: OutputCapabilities, artifacts: RunArtifactPaths, showCosts: boolean): string;
20
21
 
22
+ type ParallelRequest = number | "auto";
23
+
21
24
  interface ConfigDiagnostic {
22
25
  readonly code: string;
23
26
  readonly file: string;
@@ -42,6 +45,10 @@ interface ProjectConfigOverrides {
42
45
  readonly outputDir?: string;
43
46
  readonly reporterDir?: string;
44
47
  readonly baseUrl?: string;
48
+ readonly vision?: {
49
+ readonly enabled?: boolean;
50
+ readonly model?: string;
51
+ };
45
52
  }
46
53
  interface ResolvedProjectConfig {
47
54
  readonly projectRoot: string;
@@ -50,6 +57,9 @@ interface ResolvedProjectConfig {
50
57
  readonly testDirectory: string;
51
58
  readonly include: readonly string[];
52
59
  readonly exclude: readonly string[];
60
+ readonly affected: {
61
+ readonly ignore: readonly string[];
62
+ };
53
63
  readonly browser: BrowserKind;
54
64
  readonly viewport: {
55
65
  readonly width: number;
@@ -60,7 +70,17 @@ interface ResolvedProjectConfig {
60
70
  readonly reporterDir: string;
61
71
  readonly baseUrl: string | null;
62
72
  readonly variables: Readonly<Record<string, string | undefined>>;
73
+ readonly providerName: "typesafe" | "clef";
63
74
  readonly apiKey: string | undefined;
75
+ readonly cloudflareAccountId: string | undefined;
76
+ readonly providerBaseUrl: string;
77
+ readonly providerModel: string;
78
+ readonly vision: {
79
+ readonly enabled: boolean;
80
+ readonly model: string;
81
+ readonly timeoutMs: number;
82
+ };
83
+ readonly visionApiKey: string | undefined;
64
84
  }
65
85
  interface ProjectConfigLoadOptions {
66
86
  /**
@@ -72,33 +92,40 @@ interface ProjectConfigLoadOptions {
72
92
  declare function loadProjectConfig(start?: string, hostEnvironment?: Readonly<Record<string, string | undefined>>, overrides?: ProjectConfigOverrides, loadOptions?: ProjectConfigLoadOptions): Promise<ResolvedProjectConfig>;
73
93
  declare function discoverConfiguredTests(config: ResolvedProjectConfig): Promise<readonly string[]>;
74
94
 
75
- interface CliDiagnostic {
76
- readonly code: string;
77
- readonly message: string;
78
- readonly fix: string;
79
- }
80
-
81
95
  interface RunFilters {
82
96
  readonly include?: readonly string[];
83
97
  readonly exclude?: readonly string[];
84
98
  readonly labels?: readonly string[];
85
99
  readonly names?: readonly string[];
100
+ /** Exact test ids; rerun commands use these to select one test. */
101
+ readonly ids?: readonly string[];
86
102
  }
87
103
 
88
- type ParallelRequest = number | "auto";
89
-
90
104
  interface ShardSpec {
91
105
  /** 1-based, as in Playwright's `--shard=current/total`. */
92
106
  readonly index: number;
93
107
  readonly count: number;
94
108
  }
95
109
 
110
+ interface CliDiagnostic {
111
+ readonly code: string;
112
+ readonly message: string;
113
+ readonly fix: string;
114
+ }
115
+
96
116
  interface RunCommandOptions {
117
+ /**
118
+ * Receives a stray rejection from test code that arrived after the run was
119
+ * reported; the `sedum` binary prints it and fails the exit code.
120
+ */
121
+ readonly onStrayRejection?: (message: string) => void;
97
122
  readonly file?: string;
98
123
  readonly paths?: readonly string[];
99
124
  readonly filters?: RunFilters;
100
125
  readonly environment?: string;
101
126
  readonly browser?: string;
127
+ readonly vision?: boolean;
128
+ readonly visionModel?: string;
102
129
  readonly urlOverride?: string;
103
130
  readonly outputDir?: string;
104
131
  readonly reporterDir?: string;
@@ -117,12 +144,16 @@ interface RunCommandOptions {
117
144
  readonly providerConcurrency?: number;
118
145
  /** Injected for tests; defaults to `os.availableParallelism()`. */
119
146
  readonly availableParallelism?: number;
147
+ /** Injected for tests; defaults to OpenRouter's unbilled key endpoint. */
148
+ readonly probeVisionKey?: (apiKey: string) => Promise<VisionKeyProbe>;
120
149
  readonly replay: boolean;
121
150
  readonly evidence: boolean;
122
151
  readonly sensitiveOrigins: readonly string[];
123
152
  readonly locatorCacheDisabled?: boolean;
124
153
  readonly locatorCacheCi?: boolean;
125
154
  readonly signal?: AbortSignal;
155
+ /** How to invoke sedum in report rerun hints, e.g. `npx sedum`. */
156
+ readonly command?: string;
126
157
  readonly onSnapshot?: (snapshot: RunResult, artifacts: RunArtifactPaths) => void;
127
158
  readonly onCommitted?: () => void;
128
159
  readonly onDeadline?: () => void;
@@ -135,17 +166,27 @@ interface RunCommandExecution {
135
166
  readonly onReporterFailure?: () => Promise<RunCommandExecution>;
136
167
  }
137
168
 
169
+ type RelevanceProviderFactory = (config: ResolvedProjectConfig) => RelevanceProvider | Promise<RelevanceProvider>;
170
+
138
171
  interface DoctorProbes {
139
172
  readonly nodeVersion?: string;
140
173
  readonly loadConfig?: (cwd: string) => Promise<ResolvedProjectConfig>;
141
174
  readonly browser?: (kind: BrowserKind) => boolean;
142
- readonly network?: () => Promise<boolean>;
143
- readonly auth?: (apiKey: string) => Promise<AuthProbeResult>;
175
+ readonly network?: (baseURL: string) => Promise<boolean>;
176
+ readonly auth?: (apiKey: string, options: {
177
+ readonly baseURL: string;
178
+ readonly model: string;
179
+ }) => Promise<AuthProbeResult>;
144
180
  readonly output?: (config: ResolvedProjectConfig) => Promise<void>;
181
+ readonly visionAuth?: (apiKey: string) => Promise<VisionKeyProbe>;
145
182
  }
146
183
 
147
184
  type ClassificationProviderFactory = (options: {
148
185
  readonly apiKey?: string;
186
+ readonly baseURL: string;
187
+ readonly model: string;
188
+ readonly providerName?: "typesafe" | "clef";
189
+ readonly accountId?: string;
149
190
  }) => ClassificationProvider | Promise<ClassificationProvider>;
150
191
 
151
192
  interface CliOutput {
@@ -160,13 +201,18 @@ interface CliRuntime {
160
201
  readonly signal?: AbortSignal;
161
202
  readonly onRunCommitted?: () => void;
162
203
  readonly onRunDeadline?: () => void;
204
+ /** A stray rejection from test code after the run was reported. */
205
+ readonly onStrayRejection?: (message: string) => void;
163
206
  readonly executeRun?: (options: RunCommandOptions) => Promise<RunCommandExecution>;
164
207
  readonly installChromium?: (withDependencies: boolean) => BrowserInstallResult;
165
208
  /** Project root for `validate` and `list`; defaults to the process cwd. */
166
209
  readonly cwd?: string;
167
210
  /** Used only by `validate --online`. */
168
211
  readonly createClassificationProvider?: ClassificationProviderFactory;
212
+ readonly createRelevanceProvider?: RelevanceProviderFactory;
169
213
  readonly doctorProbes?: DoctorProbes;
214
+ /** How the user invokes sedum, for hints; the entry point detects it. */
215
+ readonly command?: "sedum" | "npx sedum";
170
216
  readonly confirmInit?: (question: string) => Promise<boolean>;
171
217
  }
172
218
  /** Parse and execute explicit argv without reading or exiting the process. */
package/dist/index.js CHANGED
@@ -2,18 +2,25 @@ import {
2
2
  renderRunSummary,
3
3
  runCli,
4
4
  runExitCode
5
- } from "./chunk-TU5MIKGA.js";
6
- import "./chunk-BEV24G7S.js";
5
+ } from "./chunk-HT6BIET2.js";
6
+ import "./chunk-EFRMSNBD.js";
7
+ import "./chunk-S7OB3JEF.js";
7
8
  import {
8
9
  ProjectConfigError,
9
10
  discoverConfiguredTests,
10
11
  loadProjectConfig
11
- } from "./chunk-TZGSCV23.js";
12
+ } from "./chunk-FAGJCNV7.js";
13
+
14
+ // src/index.ts
15
+ import { test, expect, secret } from "@sedum-dev/core/script";
12
16
  export {
13
17
  ProjectConfigError,
14
18
  discoverConfiguredTests,
19
+ expect,
15
20
  loadProjectConfig,
16
21
  renderRunSummary,
17
22
  runCli,
18
- runExitCode
23
+ runExitCode,
24
+ secret,
25
+ test
19
26
  };