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.
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;
@@ -60,7 +67,17 @@ interface ResolvedProjectConfig {
60
67
  readonly reporterDir: string;
61
68
  readonly baseUrl: string | null;
62
69
  readonly variables: Readonly<Record<string, string | undefined>>;
70
+ readonly providerName: "typesafe" | "clef";
63
71
  readonly apiKey: string | undefined;
72
+ readonly cloudflareAccountId: string | undefined;
73
+ readonly providerBaseUrl: string;
74
+ readonly providerModel: string;
75
+ readonly vision: {
76
+ readonly enabled: boolean;
77
+ readonly model: string;
78
+ readonly timeoutMs: number;
79
+ };
80
+ readonly visionApiKey: string | undefined;
64
81
  }
65
82
  interface ProjectConfigLoadOptions {
66
83
  /**
@@ -72,33 +89,40 @@ interface ProjectConfigLoadOptions {
72
89
  declare function loadProjectConfig(start?: string, hostEnvironment?: Readonly<Record<string, string | undefined>>, overrides?: ProjectConfigOverrides, loadOptions?: ProjectConfigLoadOptions): Promise<ResolvedProjectConfig>;
73
90
  declare function discoverConfiguredTests(config: ResolvedProjectConfig): Promise<readonly string[]>;
74
91
 
75
- interface CliDiagnostic {
76
- readonly code: string;
77
- readonly message: string;
78
- readonly fix: string;
79
- }
80
-
81
92
  interface RunFilters {
82
93
  readonly include?: readonly string[];
83
94
  readonly exclude?: readonly string[];
84
95
  readonly labels?: readonly string[];
85
96
  readonly names?: readonly string[];
97
+ /** Exact test ids; rerun commands use these to select one test. */
98
+ readonly ids?: readonly string[];
86
99
  }
87
100
 
88
- type ParallelRequest = number | "auto";
89
-
90
101
  interface ShardSpec {
91
102
  /** 1-based, as in Playwright's `--shard=current/total`. */
92
103
  readonly index: number;
93
104
  readonly count: number;
94
105
  }
95
106
 
107
+ interface CliDiagnostic {
108
+ readonly code: string;
109
+ readonly message: string;
110
+ readonly fix: string;
111
+ }
112
+
96
113
  interface RunCommandOptions {
114
+ /**
115
+ * Receives a stray rejection from test code that arrived after the run was
116
+ * reported; the `sedum` binary prints it and fails the exit code.
117
+ */
118
+ readonly onStrayRejection?: (message: string) => void;
97
119
  readonly file?: string;
98
120
  readonly paths?: readonly string[];
99
121
  readonly filters?: RunFilters;
100
122
  readonly environment?: string;
101
123
  readonly browser?: string;
124
+ readonly vision?: boolean;
125
+ readonly visionModel?: string;
102
126
  readonly urlOverride?: string;
103
127
  readonly outputDir?: string;
104
128
  readonly reporterDir?: string;
@@ -117,12 +141,16 @@ interface RunCommandOptions {
117
141
  readonly providerConcurrency?: number;
118
142
  /** Injected for tests; defaults to `os.availableParallelism()`. */
119
143
  readonly availableParallelism?: number;
144
+ /** Injected for tests; defaults to OpenRouter's unbilled key endpoint. */
145
+ readonly probeVisionKey?: (apiKey: string) => Promise<VisionKeyProbe>;
120
146
  readonly replay: boolean;
121
147
  readonly evidence: boolean;
122
148
  readonly sensitiveOrigins: readonly string[];
123
149
  readonly locatorCacheDisabled?: boolean;
124
150
  readonly locatorCacheCi?: boolean;
125
151
  readonly signal?: AbortSignal;
152
+ /** How to invoke sedum in report rerun hints, e.g. `npx sedum`. */
153
+ readonly command?: string;
126
154
  readonly onSnapshot?: (snapshot: RunResult, artifacts: RunArtifactPaths) => void;
127
155
  readonly onCommitted?: () => void;
128
156
  readonly onDeadline?: () => void;
@@ -135,17 +163,27 @@ interface RunCommandExecution {
135
163
  readonly onReporterFailure?: () => Promise<RunCommandExecution>;
136
164
  }
137
165
 
166
+ type RelevanceProviderFactory = (config: ResolvedProjectConfig) => RelevanceProvider | Promise<RelevanceProvider>;
167
+
138
168
  interface DoctorProbes {
139
169
  readonly nodeVersion?: string;
140
170
  readonly loadConfig?: (cwd: string) => Promise<ResolvedProjectConfig>;
141
171
  readonly browser?: (kind: BrowserKind) => boolean;
142
- readonly network?: () => Promise<boolean>;
143
- readonly auth?: (apiKey: string) => Promise<AuthProbeResult>;
172
+ readonly network?: (baseURL: string) => Promise<boolean>;
173
+ readonly auth?: (apiKey: string, options: {
174
+ readonly baseURL: string;
175
+ readonly model: string;
176
+ }) => Promise<AuthProbeResult>;
144
177
  readonly output?: (config: ResolvedProjectConfig) => Promise<void>;
178
+ readonly visionAuth?: (apiKey: string) => Promise<VisionKeyProbe>;
145
179
  }
146
180
 
147
181
  type ClassificationProviderFactory = (options: {
148
182
  readonly apiKey?: string;
183
+ readonly baseURL: string;
184
+ readonly model: string;
185
+ readonly providerName?: "typesafe" | "clef";
186
+ readonly accountId?: string;
149
187
  }) => ClassificationProvider | Promise<ClassificationProvider>;
150
188
 
151
189
  interface CliOutput {
@@ -160,13 +198,18 @@ interface CliRuntime {
160
198
  readonly signal?: AbortSignal;
161
199
  readonly onRunCommitted?: () => void;
162
200
  readonly onRunDeadline?: () => void;
201
+ /** A stray rejection from test code after the run was reported. */
202
+ readonly onStrayRejection?: (message: string) => void;
163
203
  readonly executeRun?: (options: RunCommandOptions) => Promise<RunCommandExecution>;
164
204
  readonly installChromium?: (withDependencies: boolean) => BrowserInstallResult;
165
205
  /** Project root for `validate` and `list`; defaults to the process cwd. */
166
206
  readonly cwd?: string;
167
207
  /** Used only by `validate --online`. */
168
208
  readonly createClassificationProvider?: ClassificationProviderFactory;
209
+ readonly createRelevanceProvider?: RelevanceProviderFactory;
169
210
  readonly doctorProbes?: DoctorProbes;
211
+ /** How the user invokes sedum, for hints; the entry point detects it. */
212
+ readonly command?: "sedum" | "npx sedum";
170
213
  readonly confirmInit?: (question: string) => Promise<boolean>;
171
214
  }
172
215
  /** 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-4LEXNO2M.js";
6
+ import "./chunk-EFRMSNBD.js";
7
+ import "./chunk-NOGCXR4U.js";
7
8
  import {
8
9
  ProjectConfigError,
9
10
  discoverConfiguredTests,
10
11
  loadProjectConfig
11
- } from "./chunk-TZGSCV23.js";
12
+ } from "./chunk-VNGIF7AY.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
  };
@@ -2,11 +2,11 @@ import {
2
2
  browserAvailable,
3
3
  keyPresent,
4
4
  supportedNode
5
- } from "./chunk-OB6ZUJ6X.js";
5
+ } from "./chunk-H4QXVVQI.js";
6
6
  import {
7
7
  ProjectConfigError,
8
8
  loadProjectConfig
9
- } from "./chunk-TZGSCV23.js";
9
+ } from "./chunk-VNGIF7AY.js";
10
10
 
11
11
  // src/init-command.ts
12
12
  import { constants } from "fs";
@@ -19,23 +19,36 @@ browser: chromium
19
19
  outputDir: .sedum/runs
20
20
  reporterDir: .sedum/reports
21
21
  `;
22
- var EXAMPLE = `description: Sign in to the SauceDemo sample store
23
- url: https://www.saucedemo.com/
24
- data:
25
- user: standard_user
26
- password: $SAUCE_PASSWORD
27
- steps:
28
- - type {{user}} in the username field
29
- - type {{password}} in the password field
30
- - click the login button
31
- - verify a list of products with prices is shown
22
+ var EXAMPLE = `import { test, secret } from "sedum-cli";
23
+
24
+ test(
25
+ "a customer signs in to the SauceDemo sample store",
26
+ { url: "https://www.saucedemo.com/" },
27
+ async ({ ai, env }) => {
28
+ await ai("type {{user}} in the username field", { user: "standard_user" });
29
+ await ai("type {{password}} in the password field", {
30
+ password: secret(env.SAUCE_PASSWORD ?? ""),
31
+ });
32
+ await ai("click the login button");
33
+ await ai("verify a list of products with prices is shown");
34
+ },
35
+ );
32
36
  `;
33
37
  var ENV_EXAMPLE = `# Get a TypeSafe key and put it in .env, or set it in your shell.
38
+ # For a compatible provider, also set TYPESAFE_BASE_URL and optionally TYPESAFE_DEFAULT_MODEL.
34
39
  TYPESAFE_API_KEY=
40
+ # If provider.name is clef, use these instead (never commit .env).
41
+ # CLOUDFLARE_ACCOUNT_ID=
42
+ # CLOUDFLARE_AUTH_TOKEN=
35
43
  # Public SauceDemo sample account; no Sauce Labs account is required.
36
44
  SAUCE_PASSWORD=secret_sauce
37
45
  `;
38
- var IGNORE = [".env", ".sedum/runs/", ".sedum/reports/"];
46
+ var IGNORE = [
47
+ "node_modules/",
48
+ ".env",
49
+ ".sedum/runs/",
50
+ ".sedum/reports/"
51
+ ];
39
52
  var WORDMARK = [
40
53
  " \u2588\u2588\u2588\u2588 \u2588\u2588\u2588\u2588\u2588 \u2588\u2588\u2588\u2588 \u2588 \u2588 \u2588 \u2588 \u2588\u2588\u2588\u2588 \u2588\u2588\u2588\u2588\u2588 \u2588 \u2588",
41
54
  "\u2588 \u2591\u2591\u2591\u2591\u2588\u2591\u2591\u2591\u2591\u2591\u2588\u2591\u2591\u2591\u2588 \u2588\u2591 \u2588\u2591\u2588\u2588 \u2588\u2588\u2591 \u2588\u2591\u2591\u2591\u2588 \u2588\u2591\u2591\u2591\u2591\u2591\u2588\u2591 \u2588\u2591",
@@ -152,12 +165,12 @@ async function executeInitCommand(options) {
152
165
  await regularDirectory(path.join(root, "tests"));
153
166
  for (const [name, contents] of [
154
167
  ["sedum.config.yaml", CONFIG],
155
- ["tests/example.test.yaml", EXAMPLE],
168
+ ["tests/example.test.ts", EXAMPLE],
156
169
  [".env.example", ENV_EXAMPLE]
157
170
  ]) {
158
171
  const result = await createOrKeep(path.join(root, name), contents);
159
172
  if (name === ".env.example" && result === "kept") keptEnvExample = true;
160
- if (name === "tests/example.test.yaml" && result === "created")
173
+ if (name === "tests/example.test.ts" && result === "created")
161
174
  createdExample = true;
162
175
  say(`${result} ${name}
163
176
  `);
@@ -165,7 +178,7 @@ async function executeInitCommand(options) {
165
178
  say(await updateIgnore(root, options));
166
179
  say("\nSedum runs plain-language tests in a browser.\n");
167
180
  if (createdExample) {
168
- const title = "\u2500\u2500 tests/example.test.yaml ";
181
+ const title = "\u2500\u2500 tests/example.test.ts ";
169
182
  const divider = "\u2500".repeat(54);
170
183
  say(`
171
184
  ${title}${divider.slice(title.length)}
@@ -189,10 +202,15 @@ ${++step}. ${title}
189
202
  const hasBrowser = (options.browser ?? browserAvailable)(config.browser);
190
203
  const hasEnv = await pathExists(path.join(root, ".env"));
191
204
  if (!keyPresent(config))
192
- next("Add your TypeSafe API key", [
193
- "Get a key at https://typesafe.ai/.",
205
+ next("Add a provider API key", [
206
+ ...config.providerName === "clef" ? ["Create a scoped Workers AI token in the Cloudflare dashboard."] : ["Get a key at https://typesafe.ai/."],
194
207
  ...hasEnv ? [] : ["cp .env.example .env"],
195
- "Open .env and set TYPESAFE_API_KEY to your key (or set it in your shell)."
208
+ ...config.providerName === "clef" ? [
209
+ "Open .env and set CLOUDFLARE_ACCOUNT_ID and CLOUDFLARE_AUTH_TOKEN (or set them in your shell)."
210
+ ] : [
211
+ "Open .env and set TYPESAFE_API_KEY to your key (or set it in your shell).",
212
+ "For a compatible provider, also set TYPESAFE_BASE_URL and use that provider's key as TYPESAFE_API_KEY."
213
+ ]
196
214
  ]);
197
215
  if (!hasBrowser)
198
216
  next(
@@ -217,7 +235,7 @@ ${++step}. ${title}
217
235
  ]);
218
236
  }
219
237
  next("Run the example", [
220
- "sedum run tests/example.test.yaml --headed",
238
+ "sedum run tests/example.test.ts --headed",
221
239
  "This calls the TypeSafe API and may incur a charge."
222
240
  ]);
223
241
  return { stdout: output.join(""), stderr: "", exitCode: 0 };