sedum-cli 0.1.0-alpha.18 → 0.1.0-alpha.21

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,329 @@
1
+ import {
2
+ AuthError
3
+ } from "./chunk-JYWNBHN7.js";
4
+
5
+ // src/cloud-command.ts
6
+ import { z } from "zod";
7
+ var sorts = [
8
+ "flaky-runs",
9
+ "flake-rate",
10
+ "failures",
11
+ "retry-overhead",
12
+ "duration-p95",
13
+ "duration-regression"
14
+ ];
15
+ var windowSchema = z.object({
16
+ since: z.iso.datetime({ offset: true }),
17
+ until: z.iso.datetime({ offset: true })
18
+ });
19
+ var count = z.number().int().nonnegative();
20
+ var duration = z.number().nonnegative().nullable();
21
+ var metrics = z.object({
22
+ test_id: z.string(),
23
+ observation_count: count,
24
+ passed_count: count,
25
+ failed_count: count,
26
+ unknown_count: count,
27
+ completed_count: count,
28
+ recovered_retry_count: count,
29
+ retry_count: count,
30
+ failure_rate: z.number().min(0).max(1).nullable(),
31
+ recovered_retry_rate: z.number().min(0).max(1).nullable(),
32
+ mixed_outcomes: z.boolean(),
33
+ duration_count: count,
34
+ mean_elapsed_ms: duration,
35
+ max_elapsed_ms: duration,
36
+ description: z.string().nullable(),
37
+ p50_elapsed_ms: duration,
38
+ p95_elapsed_ms: duration,
39
+ total_attempt_elapsed_ms: z.number().nonnegative(),
40
+ retry_elapsed_ms: z.number().nonnegative()
41
+ }).passthrough();
42
+ var row = metrics.extend({
43
+ previous: metrics.nullable().optional(),
44
+ p95_change_ms: z.number().nullable().optional(),
45
+ p95_change_ratio: z.number().nullable().optional()
46
+ });
47
+ var summary = z.object({
48
+ id: z.uuid(),
49
+ state: z.enum(["completed", "interrupted", "error"]),
50
+ verdict: z.enum(["passed", "failed"]).nullable(),
51
+ report: z.record(z.string(), z.unknown()).optional()
52
+ }).passthrough();
53
+ var page = z.object({
54
+ data: z.array(summary),
55
+ next_cursor: z.string().nullable(),
56
+ window: windowSchema
57
+ }).passthrough();
58
+ var history = page.extend({
59
+ data: z.array(
60
+ summary.extend({
61
+ tests: z.array(
62
+ z.object({
63
+ test_id: z.string(),
64
+ state: z.string(),
65
+ verdict: z.enum(["passed", "failed"]).nullable(),
66
+ retry_count: count
67
+ }).passthrough()
68
+ )
69
+ })
70
+ )
71
+ });
72
+ var stats = z.object({
73
+ data: z.array(row),
74
+ run_count: z.number().nonnegative(),
75
+ test_count: z.number().nonnegative(),
76
+ complete: z.literal(true),
77
+ window: windowSchema,
78
+ sort: z.enum(sorts),
79
+ limit: z.number(),
80
+ min_observations: z.number(),
81
+ comparison_window: windowSchema.optional(),
82
+ previous_run_count: count.optional(),
83
+ previous_test_count: count.optional()
84
+ }).passthrough();
85
+ function integer(value, name, max) {
86
+ if (!z.string().regex(/^\d+$/).pipe(z.coerce.number().int().min(1).max(max)).safeParse(value).success)
87
+ throw new AuthError(`${name} must be an integer from 1 to ${max}.`);
88
+ return String(Number(value));
89
+ }
90
+ function timestamp(value) {
91
+ if (!z.iso.datetime({ offset: true }).safeParse(value).success)
92
+ throw new AuthError(
93
+ "Use an ISO timestamp with timezone (for example 2026-10-20T12:00:00Z)."
94
+ );
95
+ return Date.parse(value);
96
+ }
97
+ function timeWindow(options) {
98
+ const until = options.until ? timestamp(options.until) : Date.now();
99
+ const sinceValue = options.since ?? "7d";
100
+ const relative = /^([1-9]\d*)([dh])$/.exec(sinceValue);
101
+ const since = relative ? until - Number(relative[1]) * (relative[2] === "d" ? 864e5 : 36e5) : timestamp(sinceValue);
102
+ if (!z.number().positive().max(31 * 864e5).safeParse(until - since).success)
103
+ throw new AuthError(
104
+ "Time window must be positive and at most 31 days. Narrow --since/--until."
105
+ );
106
+ return {
107
+ since: new Date(since).toISOString(),
108
+ until: new Date(until).toISOString()
109
+ };
110
+ }
111
+ function validateComparison(options, sort) {
112
+ if (!z.literal("previous").optional().safeParse(options.compare).success)
113
+ throw new AuthError("--compare must be previous.");
114
+ if (sort === "duration-regression" && !options.compare)
115
+ throw new AuthError(
116
+ "--sort duration-regression requires --compare previous."
117
+ );
118
+ }
119
+ function statsFilters(options, params) {
120
+ const parsed = z.enum(sorts).default("flaky-runs").safeParse(options.sort);
121
+ if (!parsed.success)
122
+ throw new AuthError(`--sort must be one of: ${sorts.join(", ")}.`);
123
+ const sort = parsed.data;
124
+ validateComparison(options, sort);
125
+ params.set("sort", sort);
126
+ params.set(
127
+ "min_observations",
128
+ integer(options.minObservations ?? "1", "--min-observations", 1e3)
129
+ );
130
+ if (options.compare !== void 0) params.set("compare", options.compare);
131
+ }
132
+ function validateTextFilters(options) {
133
+ const valid = z.object({
134
+ branch: z.string().min(1).max(512).optional(),
135
+ commitSha: z.string().regex(/^(?:[a-f0-9]{40}|[a-f0-9]{64})$/).optional(),
136
+ state: z.enum(["completed", "interrupted", "error"]).optional(),
137
+ verdict: z.enum(["passed", "failed"]).optional(),
138
+ testId: z.string().min(1).max(8192).optional(),
139
+ cursor: z.string().min(1).max(4096).optional()
140
+ }).safeParse(options);
141
+ if (!valid.success)
142
+ throw new AuthError(
143
+ "Invalid --branch, --commit-sha, --state, --verdict, --test-id or --cursor filter. See --help."
144
+ );
145
+ }
146
+ function filters(kind, options) {
147
+ if (kind === "show")
148
+ return new URLSearchParams({
149
+ include_report: String(options.report === true)
150
+ });
151
+ validateTextFilters(options);
152
+ const params = new URLSearchParams(timeWindow(options));
153
+ params.set("limit", integer(options.limit ?? "25", "--limit", 100));
154
+ for (const [key, value] of Object.entries({
155
+ branch: options.branch,
156
+ commit_sha: options.commitSha,
157
+ state: options.state,
158
+ verdict: options.verdict,
159
+ test_id: options.testId,
160
+ cursor: options.cursor
161
+ })) {
162
+ if (value !== void 0) params.set(key, value);
163
+ }
164
+ if (kind === "history" && !options.testId)
165
+ throw new AuthError("--test-id <exact-id> is required.");
166
+ if (kind === "stats") statsFilters(options, params);
167
+ return params;
168
+ }
169
+ function statusError(status) {
170
+ const messages = {
171
+ 401: "Session unavailable. Run `sedum auth login` again.",
172
+ 403: "Project or run unavailable to your current membership.",
173
+ 404: "Project or run unavailable to your current membership.",
174
+ 400: "Invalid Cloud filters. Check the command options.",
175
+ 422: "Cloud query exceeds its bounded sample. Narrow the time window or --branch.",
176
+ 429: "Cloud rate limit reached. Back off and retry later."
177
+ };
178
+ return new AuthError(
179
+ messages[status] ?? "Cloud read failed. Try again later."
180
+ );
181
+ }
182
+ function resultBody(kind, body) {
183
+ const parsed = { stats, show: summary, history, list: page }[kind].safeParse(
184
+ body
185
+ );
186
+ if (!parsed.success)
187
+ throw new AuthError("Cloud returned an invalid read response.");
188
+ return parsed.data;
189
+ }
190
+ function humanRow(value) {
191
+ const item = value;
192
+ const fields = [
193
+ "id",
194
+ "test_id",
195
+ "description",
196
+ "started_at",
197
+ "branch",
198
+ "state",
199
+ "verdict",
200
+ "observation_count",
201
+ "failed_count",
202
+ "failure_rate",
203
+ "retry_count",
204
+ "elapsed_ms",
205
+ "recovered_retry_count",
206
+ "recovered_retry_rate",
207
+ "retry_elapsed_ms",
208
+ "p95_elapsed_ms",
209
+ "p95_change_ms",
210
+ "p95_change_ratio"
211
+ ];
212
+ const text = fields.filter((key) => item[key] !== void 0).map((key) => `${key}=${JSON.stringify(item[key])}`).join(" ");
213
+ const tests = Array.isArray(item.tests) ? item.tests.map(humanRow).join("; ") : "";
214
+ return tests ? `${text} tests=[${tests}]` : text;
215
+ }
216
+ function human(scope, result) {
217
+ const { data, report, ...metadata } = result;
218
+ const rows = Array.isArray(data) ? data : [];
219
+ const lines = [scope, JSON.stringify(metadata, null, 2)];
220
+ if (Array.isArray(data))
221
+ lines.push(`Rows: ${rows.length}`, ...rows.map(humanRow));
222
+ if (report !== void 0) lines.push(JSON.stringify(report, null, 2));
223
+ if (typeof result.next_cursor === "string")
224
+ lines.push(
225
+ `Continue with --cursor ${JSON.stringify(result.next_cursor)} (reuse the same --since/--until and filters).`
226
+ );
227
+ return lines.join("\n") + "\n";
228
+ }
229
+ function publish(result, scope, options, output) {
230
+ if (!options.report) delete result.report;
231
+ if (options.json)
232
+ output.rawOut(
233
+ JSON.stringify({ ...result, schemaVersion: 1, ...scope }) + "\n"
234
+ );
235
+ else
236
+ output.rawOut(
237
+ human(
238
+ `${JSON.stringify(scope.organization.name)} / ${JSON.stringify(scope.project.name)}`,
239
+ result
240
+ )
241
+ );
242
+ }
243
+ function readRoute(kind, runId) {
244
+ if (kind === "show") {
245
+ if (!z.uuid().safeParse(runId).success)
246
+ throw new AuthError("Run ID must be a Cloud run UUID.");
247
+ return `runs/${encodeURIComponent(String(runId))}`;
248
+ }
249
+ return kind === "list" ? "runs" : `tests/${kind}`;
250
+ }
251
+ function queryOptions(command, kind) {
252
+ command.option("--since <time>", "positive Nd/Nh or ISO timestamp", "7d").option("--until <time>", "ISO timestamp; defaults to now").option("--branch <branch>").option("--commit-sha <sha>", "40 or 64 lowercase hexadecimal characters").option("--state <state>", "completed, interrupted, error").option("--verdict <verdict>", "passed, failed").option("--limit <count>", "maximum results (1..100)", "25");
253
+ if (kind !== "stats") command.option("--cursor <cursor>", "one page only");
254
+ if (kind !== "list")
255
+ command.option("--test-id <exact-id>", "exact test ID, across branches");
256
+ if (kind === "stats")
257
+ command.option("--sort <metric>", sorts.join(", ")).option(
258
+ "--min-observations <count>",
259
+ "minimum observations (1..1000)",
260
+ "1"
261
+ ).option("--compare <period>", "previous equal-length period");
262
+ }
263
+ async function execute(input, runtime, output) {
264
+ const { kind, runId, options } = input;
265
+ try {
266
+ const params = filters(kind, options);
267
+ const route = readRoute(kind, runId);
268
+ const { readCloudProject } = await import("./auth-command-TSTYIWGX.js");
269
+ await readCloudProject(
270
+ options,
271
+ runtime.auth ?? {},
272
+ runtime.signal ?? new AbortController().signal,
273
+ async ({ origin, organization, project, get }) => {
274
+ const response = await get(
275
+ `/api/projects/${encodeURIComponent(project.id)}/${route}?${params}`
276
+ );
277
+ if (kind === "show" && response.status === 404)
278
+ throw new AuthError(
279
+ "Run not found in this project. `runs show` takes the Cloud run UUID that the upload printed (`id` in `runs list`), not the local run ID."
280
+ );
281
+ if (!response.ok) throw statusError(response.status);
282
+ const result = resultBody(kind, response.body);
283
+ publish(
284
+ result,
285
+ {
286
+ origin,
287
+ organization: { id: organization.id, name: organization.name },
288
+ project
289
+ },
290
+ options,
291
+ output
292
+ );
293
+ }
294
+ );
295
+ output.setExitCode(0);
296
+ } catch (error) {
297
+ output.writeErr(
298
+ (error instanceof AuthError ? error.message : "Cloud read failed safely; no server details were printed.") + "\n"
299
+ );
300
+ output.setExitCode(3);
301
+ }
302
+ }
303
+ function registerCloudCommands(program, runtime, output) {
304
+ const runs = program.command("runs").description("read Cloud runs");
305
+ const tests = program.command("tests").description("read Cloud test history and ranked statistics");
306
+ for (const [parent, kind] of [
307
+ [runs, "list"],
308
+ [runs, "show"],
309
+ [tests, "history"],
310
+ [tests, "stats"]
311
+ ]) {
312
+ const command = parent.command(kind === "show" ? "show <run-id>" : kind).description(`Cloud ${kind}`).option("--json", "versioned machine-readable output").option("--url <origin>", "Cloud origin").option(
313
+ "--organization <id-or-name>",
314
+ "organization ID or unambiguous name"
315
+ ).option("--project <id-or-name>", "project ID or unambiguous name");
316
+ if (kind === "show") command.option("--report", "include the full report");
317
+ else queryOptions(command, kind);
318
+ command.action(
319
+ async (...args) => execute(
320
+ { kind, runId: args[0], options: command.opts() },
321
+ runtime,
322
+ output
323
+ )
324
+ );
325
+ }
326
+ }
327
+ export {
328
+ registerCloudCommands
329
+ };
@@ -0,0 +1,243 @@
1
+ import {
2
+ gitRead
3
+ } from "./chunk-NIUOM3FA.js";
4
+ import {
5
+ readProjectEnvironment
6
+ } from "./chunk-J7CLCLHW.js";
7
+
8
+ // src/cloud-upload.ts
9
+ import { setTimeout as delay } from "timers/promises";
10
+ import { parseRetryAfter } from "@sedum-dev/core";
11
+ import { z } from "zod";
12
+ var UploadSkipped = class extends Error {
13
+ };
14
+ var settingsSchema = z.object({
15
+ SEDUM_CLOUD_URL: z.string().refine((value) => URL.canParse(value)).transform((value) => new URL(value)).refine(isCloudBaseUrl),
16
+ SEDUM_PROJECT_ID: z.uuid().transform((value) => value.toLowerCase()),
17
+ SEDUM_UPLOAD_TOKEN: z.string().regex(/^sdu_[a-z0-9_-]{43}$/iu)
18
+ });
19
+ var settingProblems = {
20
+ SEDUM_CLOUD_URL: "SEDUM_CLOUD_URL must be an https:// base URL without credentials, query or fragment (http:// only for localhost)",
21
+ SEDUM_PROJECT_ID: "SEDUM_PROJECT_ID must be the Cloud project UUID",
22
+ SEDUM_UPLOAD_TOKEN: "SEDUM_UPLOAD_TOKEN must be the project's sdu_ upload credential"
23
+ };
24
+ var gitProblems = {
25
+ branch: "no source branch detected (for example a detached checkout); set SEDUM_BRANCH",
26
+ sha: "no commit detected; set SEDUM_COMMIT_SHA to the full lowercase commit hash"
27
+ };
28
+ var sourceSchema = z.object({
29
+ branch: z.string().trim().min(1).max(512),
30
+ sha: z.string().regex(/^(?:[a-f0-9]{40}|[a-f0-9]{64})$/u),
31
+ url: z.url({ protocol: /^https$/u }).max(2048).transform((value) => new URL(value)).refine((url) => ![url.username, url.password].some(Boolean)).optional().catch(void 0)
32
+ });
33
+ async function prepareCloudUpload(cwd) {
34
+ const env = await readProjectEnvironment(cwd).then(
35
+ (file) => ({ ...file, ...process.env }),
36
+ () => void 0
37
+ );
38
+ if (!env) return skipped("the project-root .env could not be read or parsed");
39
+ const values = [
40
+ env.SEDUM_CLOUD_URL,
41
+ env.SEDUM_PROJECT_ID,
42
+ env.SEDUM_UPLOAD_TOKEN
43
+ ];
44
+ if (!values.some(Boolean)) return void 0;
45
+ try {
46
+ const target = await uploadTarget(cwd, env);
47
+ return (execution) => uploadReport(target, execution);
48
+ } catch (error) {
49
+ return skipped(
50
+ error instanceof UploadSkipped ? error.message : "the source branch cannot be sent as an HTTP header; set SEDUM_BRANCH"
51
+ );
52
+ }
53
+ }
54
+ function skipped(reason) {
55
+ return async () => `Cloud upload skipped: ${reason}. Local reporting is unchanged.
56
+ `;
57
+ }
58
+ function parseOrSkip(schema, value, messages) {
59
+ const parsed = schema.safeParse(value);
60
+ if (parsed.success) return parsed.data;
61
+ const keys = new Set(
62
+ parsed.error.issues.map((issue) => String(issue.path[0]))
63
+ );
64
+ throw new UploadSkipped([...keys].map((key) => messages[key]).join("; "));
65
+ }
66
+ async function uploadTarget(cwd, env) {
67
+ const unset = Object.keys(settingProblems).filter((key) => !env[key]);
68
+ if (unset.length) throw new UploadSkipped(`${unset.join(", ")} not set`);
69
+ const {
70
+ SEDUM_CLOUD_URL: url,
71
+ SEDUM_PROJECT_ID: projectId,
72
+ SEDUM_UPLOAD_TOKEN: token
73
+ } = parseOrSkip(settingsSchema, env, settingProblems);
74
+ url.pathname = `${url.pathname.replace(/\/$/u, "")}/api/projects/${projectId}/runs`;
75
+ return {
76
+ url,
77
+ projectId,
78
+ headers: {
79
+ "content-type": "application/json",
80
+ authorization: `Bearer ${token}`,
81
+ ...await sourceHeaders(cwd, env)
82
+ }
83
+ };
84
+ }
85
+ function isCloudBaseUrl(url) {
86
+ if ([url.username, url.password, url.search, url.hash].some(Boolean))
87
+ return false;
88
+ if (url.protocol === "https:") return true;
89
+ const loopback = ["localhost", "127.0.0.1", "[::1]"].includes(url.hostname);
90
+ return url.protocol === "http:" && loopback;
91
+ }
92
+ function ciContext(env) {
93
+ if (env.GITHUB_ACTIONS === "true") {
94
+ const branchRef = env.GITHUB_REF?.startsWith("refs/heads/") ? env.GITHUB_REF.slice(11) : void 0;
95
+ return {
96
+ branch: env.GITHUB_HEAD_REF || branchRef,
97
+ sha: env.GITHUB_SHA,
98
+ url: githubRunUrl(env)
99
+ };
100
+ }
101
+ if (env.GITLAB_CI === "true")
102
+ return {
103
+ branch: env.CI_MERGE_REQUEST_SOURCE_BRANCH_NAME || env.CI_COMMIT_BRANCH,
104
+ sha: env.CI_COMMIT_SHA,
105
+ url: env.CI_JOB_URL || void 0
106
+ };
107
+ return { branch: void 0, sha: void 0, url: void 0 };
108
+ }
109
+ function githubRunUrl(env) {
110
+ if (![env.GITHUB_SERVER_URL, env.GITHUB_REPOSITORY, env.GITHUB_RUN_ID].every(
111
+ Boolean
112
+ ))
113
+ return void 0;
114
+ return `${env.GITHUB_SERVER_URL}/${env.GITHUB_REPOSITORY}/actions/runs/${env.GITHUB_RUN_ID}`;
115
+ }
116
+ async function gitValue(cwd, args) {
117
+ try {
118
+ const value = (await gitRead(
119
+ cwd,
120
+ ["rev-parse", ...args],
121
+ AbortSignal.timeout(1e3),
122
+ 1024
123
+ )).trim();
124
+ return value === "HEAD" ? void 0 : value;
125
+ } catch {
126
+ return void 0;
127
+ }
128
+ }
129
+ async function sourceHeaders(cwd, env) {
130
+ const [gitBranch, gitSha] = await Promise.all([
131
+ env.SEDUM_BRANCH ? void 0 : gitValue(cwd, ["--abbrev-ref", "HEAD"]),
132
+ env.SEDUM_COMMIT_SHA ? void 0 : gitValue(cwd, ["HEAD"])
133
+ ]);
134
+ const ci = ciContext(env);
135
+ const source = parseOrSkip(
136
+ sourceSchema,
137
+ {
138
+ branch: env.SEDUM_BRANCH || ci.branch || gitBranch,
139
+ sha: env.SEDUM_COMMIT_SHA || gitSha || ci.sha,
140
+ url: ci.url
141
+ },
142
+ gitProblems
143
+ );
144
+ const headers = {
145
+ // Fetch takes ByteString header values; Cloud reads the raw UTF-8 bytes.
146
+ "x-sedum-branch": Buffer.from(source.branch, "utf8").toString("latin1"),
147
+ "x-sedum-commit-sha": source.sha,
148
+ ...source.url ? { "x-sedum-ci-url": source.url.href } : {}
149
+ };
150
+ new Headers(headers);
151
+ return headers;
152
+ }
153
+ async function uploadReport(target, execution) {
154
+ const warning = (reason) => `Cloud upload warning: ${reason}. Local report: ${execution.artifacts.resultPath}
155
+ `;
156
+ if (!execution.artifacts.authoritative || execution.result.state === "running")
157
+ return warning(
158
+ "no authoritative terminal report was saved; nothing uploaded"
159
+ );
160
+ const body = JSON.stringify(execution.result);
161
+ if (Buffer.byteLength(body) > 8e6)
162
+ return warning("report exceeds Cloud's 8 MB limit; nothing uploaded");
163
+ const outcome = await deliverReport({
164
+ target,
165
+ body,
166
+ runId: execution.result.runId
167
+ });
168
+ return outcome.cloudRunId ? `Cloud upload: accepted run ${outcome.cloudRunId} (local run ${execution.result.runId}). View it with \`sedum runs show ${outcome.cloudRunId}\`.
169
+ ` : warning(outcome.reason);
170
+ }
171
+ async function deliverReport(request) {
172
+ const signal = AbortSignal.timeout(5e3);
173
+ let reason = "delivery failed after retries";
174
+ for (let attempt = 0; attempt < 3; attempt++) {
175
+ let wait = 250 * 2 ** attempt;
176
+ try {
177
+ const outcome = await sendReport(request, signal);
178
+ if (outcome.retryAfter === null) return outcome;
179
+ reason = outcome.reason;
180
+ wait = outcome.retryAfter ?? wait;
181
+ } catch (error) {
182
+ if (error instanceof TypeError)
183
+ reason = unreachable(request.target.url, error);
184
+ }
185
+ if (attempt < 2) {
186
+ try {
187
+ await delay(Math.min(wait, 5e3), void 0, { signal });
188
+ } catch {
189
+ break;
190
+ }
191
+ }
192
+ }
193
+ return {
194
+ reason: signal.aborted ? `delivery to ${request.target.url.origin} exceeded the 5 second budget` : reason
195
+ };
196
+ }
197
+ function unreachable(url, error) {
198
+ const code = String(Object(error.cause).code);
199
+ const detail = /^[A-Z0-9_]{1,64}$/u.test(code) ? ` (${code})` : "";
200
+ return `could not reach ${url.origin}${detail}; check SEDUM_CLOUD_URL and the network`;
201
+ }
202
+ function httpReason(status, request) {
203
+ const hints = {
204
+ 401: `SEDUM_UPLOAD_TOKEN is revoked or is not an upload credential for SEDUM_PROJECT_ID ${request.target.projectId}`,
205
+ 404: `no Sedum Cloud upload endpoint at ${request.target.url.href}; check SEDUM_CLOUD_URL`,
206
+ 409: `Cloud already has a different report for run ${request.runId}`
207
+ };
208
+ const hint = status >= 300 && status < 400 ? "Cloud redirected; set SEDUM_CLOUD_URL to the final https:// address" : hints[status];
209
+ return hint ? `HTTP ${status} (${hint})` : `HTTP ${status}`;
210
+ }
211
+ async function sendReport(request, signal) {
212
+ const response = await fetch(request.target.url, {
213
+ method: "POST",
214
+ headers: request.target.headers,
215
+ body: request.body,
216
+ signal,
217
+ redirect: "manual"
218
+ });
219
+ if (response.ok) {
220
+ const receipt = z.object({
221
+ id: z.uuid(),
222
+ status: z.literal("accepted"),
223
+ project_id: z.literal(request.target.projectId),
224
+ run_id: z.literal(request.runId)
225
+ }).safeParse(await response.json());
226
+ return {
227
+ cloudRunId: receipt.data?.id,
228
+ reason: "Cloud returned an invalid upload receipt",
229
+ retryAfter: null
230
+ };
231
+ }
232
+ const retryable = [408, 429].includes(response.status) || response.status >= 500;
233
+ const wait = parseRetryAfter(response.headers, Date.now());
234
+ await response.body?.cancel();
235
+ return {
236
+ reason: httpReason(response.status, request),
237
+ // null stops delivery; undefined uses this attempt's exponential backoff.
238
+ retryAfter: retryable ? wait ?? void 0 : null
239
+ };
240
+ }
241
+ export {
242
+ prepareCloudUpload
243
+ };
@@ -1,15 +1,18 @@
1
1
  import {
2
2
  browserAvailable,
3
3
  checkOutputWritable,
4
+ doctorOptions,
4
5
  executeDoctorCommand,
5
6
  keyPresent,
6
7
  renderDoctorText,
7
8
  supportedNode
8
- } from "./chunk-SI2F6MBN.js";
9
- import "./chunk-KZF4NZ6M.js";
9
+ } from "./chunk-DXNJ3PGB.js";
10
+ import "./chunk-CGDXQY2Y.js";
11
+ import "./chunk-J7CLCLHW.js";
10
12
  export {
11
13
  browserAvailable,
12
14
  checkOutputWritable,
15
+ doctorOptions,
13
16
  executeDoctorCommand,
14
17
  keyPresent,
15
18
  renderDoctorText,
@@ -9,8 +9,9 @@ import {
9
9
  seedValue,
10
10
  startUrl,
11
11
  watchOrigin
12
- } from "./chunk-FG46OUHT.js";
13
- import "./chunk-KZF4NZ6M.js";
12
+ } from "./chunk-FOGLJA3Z.js";
13
+ import "./chunk-CGDXQY2Y.js";
14
+ import "./chunk-J7CLCLHW.js";
14
15
  export {
15
16
  EXPLORE_MODES,
16
17
  collectText,
package/dist/index.d.ts CHANGED
@@ -61,6 +61,8 @@ interface ResolvedProjectConfig {
61
61
  readonly ignore: readonly string[];
62
62
  };
63
63
  readonly browser: BrowserKind;
64
+ /** Where `browser` came from: `--browser`, `SEDUM_BROWSER`, a config key, or `default`. */
65
+ readonly browserSource: BrowserSource;
64
66
  readonly viewport: {
65
67
  readonly width: number;
66
68
  readonly height: number;
@@ -88,7 +90,10 @@ interface ResolvedProjectConfig {
88
90
  * On by default for the direct TypeSafe endpoint only.
89
91
  */
90
92
  readonly screenshots: boolean;
93
+ /** How long a step waits for the page: a verify, a missing or busy target. */
94
+ readonly stepTimeoutMs: number;
91
95
  }
96
+ type BrowserSource = "--browser" | "SEDUM_BROWSER" | `environments.${string}.browser` | "browser" | "default";
92
97
  interface ProjectConfigLoadOptions {
93
98
  /**
94
99
  * False for commands that must not touch secrets (`validate`, `list`): the
@@ -130,6 +135,11 @@ interface RunCommandOptions {
130
135
  readonly file?: string;
131
136
  readonly paths?: readonly string[];
132
137
  readonly filters?: RunFilters;
138
+ /**
139
+ * `--non-blocking-labels`: tests with any of these tags run and are
140
+ * reported, but their failures and errors do not decide the run.
141
+ */
142
+ readonly nonBlockingLabels?: readonly string[];
133
143
  readonly environment?: string;
134
144
  readonly browser?: string;
135
145
  readonly vision?: boolean;
@@ -191,6 +201,16 @@ interface DoctorProbes {
191
201
  readonly output?: (config: ResolvedProjectConfig) => Promise<void>;
192
202
  }
193
203
 
204
+ type Choice = {
205
+ id: string;
206
+ name: string;
207
+ };
208
+ interface AuthRuntime {
209
+ configDirectory?: string;
210
+ choose?: (kind: string, choices: readonly Choice[], signal: AbortSignal) => Promise<string>;
211
+ openBrowser?: (url: string) => void;
212
+ }
213
+
194
214
  type ClassificationProviderFactory = (options: {
195
215
  readonly apiKey?: string;
196
216
  readonly baseURL: string;
@@ -205,6 +225,7 @@ interface CliOutput {
205
225
  readonly exitCode: number;
206
226
  }
207
227
  interface CliRuntime {
228
+ readonly auth?: AuthRuntime;
208
229
  readonly capabilities?: OutputCapabilities;
209
230
  readonly stdout?: (value: string) => void;
210
231
  readonly stderr?: (value: string) => void;
package/dist/index.js CHANGED
@@ -2,15 +2,17 @@ import {
2
2
  renderRunSummary,
3
3
  runCli,
4
4
  runExitCode
5
- } from "./chunk-EPXLY5Q4.js";
6
- import "./chunk-FG46OUHT.js";
5
+ } from "./chunk-PX6PJ7U2.js";
6
+ import "./chunk-JYWNBHN7.js";
7
+ import "./chunk-FOGLJA3Z.js";
7
8
  import "./chunk-EFRMSNBD.js";
8
9
  import "./chunk-N5CTUO2A.js";
10
+ import "./chunk-CGDXQY2Y.js";
9
11
  import {
10
12
  ProjectConfigError,
11
13
  discoverConfiguredTests,
12
14
  loadProjectConfig
13
- } from "./chunk-KZF4NZ6M.js";
15
+ } from "./chunk-J7CLCLHW.js";
14
16
 
15
17
  // src/index.ts
16
18
  import { test, expect, secret } from "@sedum-dev/core/script";
@@ -2,11 +2,12 @@ import {
2
2
  browserAvailable,
3
3
  keyPresent,
4
4
  supportedNode
5
- } from "./chunk-SI2F6MBN.js";
5
+ } from "./chunk-DXNJ3PGB.js";
6
+ import "./chunk-CGDXQY2Y.js";
6
7
  import {
7
8
  ProjectConfigError,
8
9
  loadProjectConfig
9
- } from "./chunk-KZF4NZ6M.js";
10
+ } from "./chunk-J7CLCLHW.js";
10
11
 
11
12
  // src/init-command.ts
12
13
  import { constants } from "fs";