@testsprite/testsprite-cli 0.16.0 → 0.18.0
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/README.md +52 -147
- package/dist/commands/agent.d.ts +12 -4
- package/dist/commands/agent.js +48 -63
- package/dist/commands/auth.d.ts +6 -10
- package/dist/commands/auth.js +40 -56
- package/dist/commands/ci.d.ts +23 -100
- package/dist/commands/ci.js +293 -487
- package/dist/commands/conversation.d.ts +27 -0
- package/dist/commands/conversation.js +741 -0
- package/dist/commands/doctor.d.ts +5 -1
- package/dist/commands/doctor.js +129 -34
- package/dist/commands/init.d.ts +4 -45
- package/dist/commands/init.js +108 -66
- package/dist/commands/project-env.d.ts +62 -2
- package/dist/commands/project-env.js +434 -43
- package/dist/commands/project-sign-in.d.ts +0 -48
- package/dist/commands/project-sign-in.js +1 -229
- package/dist/commands/project.d.ts +19 -186
- package/dist/commands/project.js +108 -926
- package/dist/commands/result.d.ts +10 -0
- package/dist/commands/result.js +216 -0
- package/dist/commands/schedule.d.ts +0 -29
- package/dist/commands/schedule.js +28 -87
- package/dist/commands/test.d.ts +301 -1838
- package/dist/commands/test.js +1880 -13917
- package/dist/commands/testlist.d.ts +130 -5
- package/dist/commands/testlist.js +300 -342
- package/dist/commands/tunnel.d.ts +3 -3
- package/dist/commands/tunnel.js +23 -20
- package/dist/commands/usage.d.ts +12 -45
- package/dist/commands/usage.js +50 -131
- package/dist/index.js +191 -110
- package/dist/lib/agent-detect.js +9 -5
- package/dist/lib/agent-targets.d.ts +21 -2
- package/dist/lib/agent-targets.js +88 -11
- package/dist/lib/args.d.ts +13 -0
- package/dist/lib/args.js +49 -0
- package/dist/lib/basic-auth.d.ts +3 -0
- package/dist/lib/basic-auth.js +15 -0
- package/dist/lib/billing-refusal.js +4 -3
- package/dist/lib/ci-linkage.d.ts +4 -82
- package/dist/lib/ci-linkage.js +4 -157
- package/dist/lib/ci-run.js +1 -1
- package/dist/lib/client-factory.d.ts +12 -4
- package/dist/lib/client-factory.js +41 -30
- package/dist/lib/commit-signal.d.ts +65 -0
- package/dist/lib/commit-signal.js +305 -0
- package/dist/lib/concurrency-limiter.d.ts +6 -0
- package/dist/lib/concurrency-limiter.js +29 -0
- package/dist/lib/config.js +10 -5
- package/dist/lib/conflict-reason.d.ts +9 -3
- package/dist/lib/conflict-reason.js +6 -3
- package/dist/lib/conversation/answers.d.ts +9 -0
- package/dist/lib/conversation/answers.js +49 -0
- package/dist/lib/conversation/api.d.ts +75 -0
- package/dist/lib/conversation/api.js +151 -0
- package/dist/lib/conversation/change.d.ts +31 -0
- package/dist/lib/conversation/change.js +124 -0
- package/dist/lib/conversation/context.d.ts +29 -0
- package/dist/lib/conversation/context.js +82 -0
- package/dist/lib/conversation/environment.d.ts +16 -0
- package/dist/lib/conversation/environment.js +21 -0
- package/dist/lib/conversation/follow.d.ts +24 -0
- package/dist/lib/conversation/follow.js +42 -0
- package/dist/lib/conversation/render.d.ts +33 -0
- package/dist/lib/conversation/render.js +318 -0
- package/dist/lib/conversation/title.d.ts +2 -0
- package/dist/lib/conversation/title.js +18 -0
- package/dist/lib/conversation/types.d.ts +158 -0
- package/dist/lib/conversation/types.js +6 -0
- package/dist/lib/credentials.js +67 -11
- package/dist/lib/cron.d.ts +1 -1
- package/dist/lib/cron.js +2 -2
- package/dist/lib/dispatch-stop.d.ts +20 -0
- package/dist/lib/dispatch-stop.js +30 -0
- package/dist/lib/download.d.ts +100 -0
- package/dist/lib/download.js +408 -0
- package/dist/lib/dry-run/fetch.d.ts +10 -0
- package/dist/lib/dry-run/fetch.js +20 -0
- package/dist/lib/dry-run/samples.d.ts +6 -34
- package/dist/lib/dry-run/samples.js +375 -747
- package/dist/lib/environment-tunnel.d.ts +19 -30
- package/dist/lib/environment-tunnel.js +168 -202
- package/dist/lib/errors.d.ts +20 -4
- package/dist/lib/errors.js +36 -16
- package/dist/lib/facade.d.ts +7 -29
- package/dist/lib/facade.js +7 -36
- package/dist/lib/failing-fe-resolver.d.ts +13 -58
- package/dist/lib/failing-fe-resolver.js +47 -132
- package/dist/lib/first-suite-hint.d.ts +20 -30
- package/dist/lib/first-suite-hint.js +57 -72
- package/dist/lib/gh-output.d.ts +76 -21
- package/dist/lib/gh-output.js +171 -90
- package/dist/lib/git-utils.d.ts +56 -0
- package/dist/lib/git-utils.js +212 -0
- package/dist/lib/github-context.d.ts +2 -0
- package/dist/lib/github-context.js +40 -8
- package/dist/lib/history-retention.d.ts +6 -2
- package/dist/lib/history-retention.js +10 -7
- package/dist/lib/http.d.ts +58 -134
- package/dist/lib/http.js +354 -291
- package/dist/lib/interrupt.d.ts +14 -8
- package/dist/lib/interrupt.js +28 -10
- package/dist/lib/junit-report.d.ts +57 -4
- package/dist/lib/junit-report.js +202 -32
- package/dist/lib/local-target.d.ts +8 -7
- package/dist/lib/local-target.js +14 -13
- package/dist/lib/output.d.ts +2 -41
- package/dist/lib/output.js +13 -51
- package/dist/lib/pagination.d.ts +2 -5
- package/dist/lib/pagination.js +2 -5
- package/dist/lib/presigned-url.d.ts +22 -0
- package/dist/lib/presigned-url.js +90 -0
- package/dist/lib/prompt.js +36 -2
- package/dist/lib/proxy.js +2 -1
- package/dist/lib/redact.d.ts +2 -2
- package/dist/lib/redact.js +3 -4
- package/dist/lib/removed-commands.d.ts +18 -0
- package/dist/lib/removed-commands.js +170 -0
- package/dist/lib/render-error.d.ts +31 -6
- package/dist/lib/render-error.js +88 -25
- package/dist/lib/response-schemas.d.ts +38 -30
- package/dist/lib/response-schemas.js +207 -207
- package/dist/lib/result/api.d.ts +24 -0
- package/dist/lib/result/api.js +28 -0
- package/dist/lib/result/evidence.d.ts +73 -0
- package/dist/lib/result/evidence.js +422 -0
- package/dist/lib/result/render.d.ts +20 -0
- package/dist/lib/result/render.js +194 -0
- package/dist/lib/result/types.d.ts +122 -0
- package/dist/lib/result/types.js +19 -0
- package/dist/lib/run-output.d.ts +275 -0
- package/dist/lib/run-output.js +227 -0
- package/dist/lib/run-render.d.ts +101 -0
- package/dist/lib/run-render.js +183 -0
- package/dist/lib/run-wait.d.ts +192 -0
- package/dist/lib/run-wait.js +452 -0
- package/dist/lib/runs.types.d.ts +118 -367
- package/dist/lib/runs.types.js +0 -14
- package/dist/lib/secret-file.d.ts +1 -1
- package/dist/lib/secret-file.js +11 -2
- package/dist/lib/skill-nudge.d.ts +7 -27
- package/dist/lib/skill-nudge.js +9 -37
- package/dist/lib/target-path.d.ts +15 -0
- package/dist/lib/target-path.js +35 -0
- package/dist/lib/target-url-advisory.d.ts +19 -0
- package/dist/lib/target-url-advisory.js +31 -0
- package/dist/lib/target-url-preflight.d.ts +9 -0
- package/dist/lib/target-url-preflight.js +214 -106
- package/dist/lib/target-url.d.ts +8 -8
- package/dist/lib/target-url.js +14 -24
- package/dist/lib/telemetry.d.ts +35 -15
- package/dist/lib/telemetry.js +38 -9
- package/dist/lib/terminal-text.d.ts +41 -0
- package/dist/lib/terminal-text.js +127 -0
- package/dist/lib/testlist.types.d.ts +16 -8
- package/dist/lib/testlist.types.js +1 -1
- package/dist/lib/text-equality.d.ts +2 -0
- package/dist/lib/text-equality.js +5 -0
- package/dist/lib/text-file.d.ts +16 -0
- package/dist/lib/text-file.js +41 -0
- package/dist/lib/text-table.d.ts +46 -0
- package/dist/lib/text-table.js +72 -4
- package/dist/lib/ticker.d.ts +9 -2
- package/dist/lib/ticker.js +16 -3
- package/dist/lib/transport-failure.d.ts +22 -0
- package/dist/lib/transport-failure.js +126 -0
- package/dist/lib/tunnel-session.d.ts +8 -2
- package/dist/lib/tunnel-session.js +24 -11
- package/dist/lib/update-check.js +3 -2
- package/dist/lib/url-template.d.ts +43 -0
- package/dist/lib/url-template.js +151 -0
- package/dist/lib/validate.d.ts +0 -64
- package/dist/lib/validate.js +2 -131
- package/dist/lib/version-notice.js +4 -3
- package/dist/lib/wait-exit.d.ts +37 -2
- package/dist/lib/wait-exit.js +88 -30
- package/dist/lib/workspace-status.js +10 -2
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +2 -3
- package/skills/testsprite-ci.skill.md +52 -23
- package/skills/testsprite-onboard.skill.md +70 -153
- package/skills/testsprite-verify.codex.md +54 -58
- package/skills/testsprite-verify.skill.md +189 -358
- package/dist/lib/browser.d.ts +0 -6
- package/dist/lib/browser.js +0 -54
- package/dist/lib/bundle.d.ts +0 -234
- package/dist/lib/bundle.js +0 -781
- package/dist/lib/deprecate.d.ts +0 -32
- package/dist/lib/deprecate.js +0 -39
- package/dist/lib/flaky.d.ts +0 -91
- package/dist/lib/flaky.js +0 -71
- package/dist/lib/plan-poll.d.ts +0 -171
- package/dist/lib/plan-poll.js +0 -441
- package/dist/lib/plans.types.d.ts +0 -130
- package/dist/lib/plans.types.js +0 -31
- package/dist/lib/poll.d.ts +0 -100
- package/dist/lib/poll.js +0 -290
- package/dist/lib/rate-throttle.d.ts +0 -49
- package/dist/lib/rate-throttle.js +0 -75
- package/dist/lib/run-progress.d.ts +0 -41
- package/dist/lib/run-progress.js +0 -56
- package/dist/lib/v3-advisory.d.ts +0 -55
- package/dist/lib/v3-advisory.js +0 -74
- package/schemas/plan.schema.json +0 -61
package/dist/lib/credentials.js
CHANGED
|
@@ -4,6 +4,7 @@ import { randomUUID } from 'node:crypto';
|
|
|
4
4
|
import { homedir } from 'node:os';
|
|
5
5
|
import { dirname, join } from 'node:path';
|
|
6
6
|
import { localValidationError } from './errors.js';
|
|
7
|
+
import { readTextFileBomAware } from './text-file.js';
|
|
7
8
|
export const DEFAULT_PROFILE = 'default';
|
|
8
9
|
/**
|
|
9
10
|
* Allowed profile-name characters. A profile name is written verbatim as an
|
|
@@ -65,8 +66,33 @@ const CREDENTIALS_LOCK_TRANSIENT_WAIT_MS = 1_000;
|
|
|
65
66
|
const CREDENTIALS_LOCK_STALE_MS = 30_000;
|
|
66
67
|
// How long a transient Windows error on replacing the credentials file is retried.
|
|
67
68
|
const CREDENTIALS_RENAME_TRANSIENT_WAIT_MS = 2_000;
|
|
69
|
+
/**
|
|
70
|
+
* Section names that are never a profile. Used as a key on an ordinary object,
|
|
71
|
+
* `__proto__` and `constructor` reach the object's prototype and the shared
|
|
72
|
+
* `Object` function instead of naming an entry, so the key/value lines under
|
|
73
|
+
* such a header would be written onto a built-in the whole process shares
|
|
74
|
+
* (for `__proto__`, onto every object). Neither ever worked as a profile name.
|
|
75
|
+
* `prototype` is not among them: an ordinary object has no such member, and a
|
|
76
|
+
* profile by that name has always read and written normally. The parser drops
|
|
77
|
+
* these sections, the serialiser never writes them, and `writeProfile` refuses
|
|
78
|
+
* them, so the three agree on what can be stored.
|
|
79
|
+
*/
|
|
80
|
+
const RESERVED_SECTION_NAMES = new Set(['__proto__', 'constructor']);
|
|
81
|
+
/**
|
|
82
|
+
* Look a profile up by name without consulting the prototype chain. A name
|
|
83
|
+
* that comes from the file, a flag or an environment variable can spell an
|
|
84
|
+
* inherited member (`toString`, `hasOwnProperty`, `__proto__`); a plain
|
|
85
|
+
* `file[name]` would then hand back that built-in as if it were a profile.
|
|
86
|
+
*/
|
|
87
|
+
function ownProfile(file, profile) {
|
|
88
|
+
return Object.hasOwn(file, profile) ? file[profile] : undefined;
|
|
89
|
+
}
|
|
68
90
|
export function parseCredentials(content) {
|
|
69
|
-
|
|
91
|
+
// Sections are collected on an object with no prototype, so a name read from
|
|
92
|
+
// the file can only ever find a section this loop stored itself. On an
|
|
93
|
+
// ordinary object `[toString]` would find the inherited function and the
|
|
94
|
+
// lines under it would be written onto that shared built-in.
|
|
95
|
+
const sections = Object.create(null);
|
|
70
96
|
let currentEntry = null;
|
|
71
97
|
for (const rawLine of content.split('\n')) {
|
|
72
98
|
const line = rawLine.trim();
|
|
@@ -75,13 +101,19 @@ export function parseCredentials(content) {
|
|
|
75
101
|
const sectionMatch = /^\[([^\]]+)\]$/.exec(line);
|
|
76
102
|
if (sectionMatch) {
|
|
77
103
|
const sectionName = sectionMatch[1].trim();
|
|
78
|
-
|
|
104
|
+
if (RESERVED_SECTION_NAMES.has(sectionName)) {
|
|
105
|
+
// Not a profile: leave no current section, so the key/value lines under
|
|
106
|
+
// this header are skipped rather than applied to the section above it.
|
|
107
|
+
currentEntry = null;
|
|
108
|
+
continue;
|
|
109
|
+
}
|
|
110
|
+
const existing = sections[sectionName];
|
|
79
111
|
if (existing) {
|
|
80
112
|
currentEntry = existing;
|
|
81
113
|
}
|
|
82
114
|
else {
|
|
83
115
|
const newEntry = {};
|
|
84
|
-
|
|
116
|
+
sections[sectionName] = newEntry;
|
|
85
117
|
currentEntry = newEntry;
|
|
86
118
|
}
|
|
87
119
|
continue;
|
|
@@ -93,14 +125,22 @@ export function parseCredentials(content) {
|
|
|
93
125
|
continue;
|
|
94
126
|
const rawKey = line.slice(0, eqIndex).trim();
|
|
95
127
|
const rawValue = line.slice(eqIndex + 1).trim();
|
|
96
|
-
|
|
128
|
+
// Own-property lookup: a key such as `constructor` must not match the
|
|
129
|
+
// inherited `Object` function and be taken for a known field.
|
|
130
|
+
const field = Object.hasOwn(FILE_KEY_TO_FIELD, rawKey) ? FILE_KEY_TO_FIELD[rawKey] : undefined;
|
|
97
131
|
if (field)
|
|
98
132
|
currentEntry[field] = rawValue;
|
|
99
133
|
}
|
|
100
|
-
|
|
134
|
+
// Callers and test matchers expect ordinary objects, so hand the sections
|
|
135
|
+
// back on one. `Object.fromEntries` defines each as an own property.
|
|
136
|
+
return Object.fromEntries(Object.entries(sections));
|
|
101
137
|
}
|
|
102
138
|
export function serializeCredentials(file) {
|
|
103
|
-
const orderedSections = Object.keys(file)
|
|
139
|
+
const orderedSections = Object.keys(file)
|
|
140
|
+
// The parser drops these sections, so writing one would store a profile
|
|
141
|
+
// that can never be read back.
|
|
142
|
+
.filter(section => !RESERVED_SECTION_NAMES.has(section))
|
|
143
|
+
.sort((a, b) => {
|
|
104
144
|
if (a === DEFAULT_PROFILE)
|
|
105
145
|
return -1;
|
|
106
146
|
if (b === DEFAULT_PROFILE)
|
|
@@ -115,6 +155,11 @@ export function serializeCredentials(file) {
|
|
|
115
155
|
lines.push(`[${section}]`);
|
|
116
156
|
const fields = Object.keys(entry).sort();
|
|
117
157
|
for (const field of fields) {
|
|
158
|
+
// Own-property lookup: an entry key the file format does not know has no
|
|
159
|
+
// line to be written as, and one that spells an inherited member
|
|
160
|
+
// (`constructor`) would otherwise print that built-in as the key.
|
|
161
|
+
if (!Object.hasOwn(FIELD_TO_FILE_KEY, field))
|
|
162
|
+
continue;
|
|
118
163
|
const value = entry[field];
|
|
119
164
|
if (value === undefined || value === '')
|
|
120
165
|
continue;
|
|
@@ -137,18 +182,26 @@ export function readCredentialsFile(options = {}) {
|
|
|
137
182
|
const path = resolvePath(options);
|
|
138
183
|
if (!existsSync(path))
|
|
139
184
|
return {};
|
|
140
|
-
|
|
185
|
+
// Shared BOM sniff (UTF-8, UTF-16LE, UTF-16BE). Writes stay UTF-8 with no BOM,
|
|
186
|
+
// so a UTF-16 file is normalised on the next save. The parser is unchanged.
|
|
187
|
+
return parseCredentials(readTextFileBomAware(path));
|
|
141
188
|
}
|
|
142
189
|
export function readProfile(profile, options = {}) {
|
|
143
190
|
assertValidProfileName(profile);
|
|
144
|
-
|
|
145
|
-
return file[profile];
|
|
191
|
+
return ownProfile(readCredentialsFile(options), profile);
|
|
146
192
|
}
|
|
147
193
|
export function writeProfile(profile, entry, options = {}) {
|
|
148
194
|
assertValidProfileName(profile);
|
|
195
|
+
// Refused before the directory, lock or file is touched: the parser drops a
|
|
196
|
+
// section with one of these names, so the profile could never be read back,
|
|
197
|
+
// and assigning to `__proto__` would swap the file object's prototype
|
|
198
|
+
// instead of adding an entry.
|
|
199
|
+
if (RESERVED_SECTION_NAMES.has(profile)) {
|
|
200
|
+
throw localValidationError('profile', 'must not be __proto__ or constructor (reserved names that cannot be stored)', undefined, 'flag');
|
|
201
|
+
}
|
|
149
202
|
const path = resolvePath(options);
|
|
150
203
|
mutateCredentialsFile(path, file => {
|
|
151
|
-
file[profile] = { ...file
|
|
204
|
+
file[profile] = { ...ownProfile(file, profile), ...entry };
|
|
152
205
|
return file;
|
|
153
206
|
});
|
|
154
207
|
}
|
|
@@ -159,7 +212,10 @@ export function deleteProfile(profile, options = {}) {
|
|
|
159
212
|
return false;
|
|
160
213
|
let removed = false;
|
|
161
214
|
mutateCredentialsFile(path, file => {
|
|
162
|
-
|
|
215
|
+
// Own-property check: `in` also sees inherited members, so a name such as
|
|
216
|
+
// `__proto__` or `toString` would be reported as removed and the file
|
|
217
|
+
// rewritten although no such profile was ever stored.
|
|
218
|
+
if (!Object.hasOwn(file, profile))
|
|
163
219
|
return undefined;
|
|
164
220
|
removed = true;
|
|
165
221
|
delete file[profile];
|
package/dist/lib/cron.d.ts
CHANGED
|
@@ -26,7 +26,7 @@ export declare function runsPerMonth(cron: string): number | null;
|
|
|
26
26
|
export declare function describeCron(cron: string): string;
|
|
27
27
|
/**
|
|
28
28
|
* Advisory shown before a schedule is created: how often it will run, and that
|
|
29
|
-
* each run is a full
|
|
29
|
+
* each run is a full run.
|
|
30
30
|
*
|
|
31
31
|
* States frequency only. Credit cost is deliberately not quoted — the API does
|
|
32
32
|
* not expose a per-action rate for the workspace wallet, and a figure derived
|
package/dist/lib/cron.js
CHANGED
|
@@ -162,7 +162,7 @@ function frequencyClause(runs) {
|
|
|
162
162
|
}
|
|
163
163
|
/**
|
|
164
164
|
* Advisory shown before a schedule is created: how often it will run, and that
|
|
165
|
-
* each run is a full
|
|
165
|
+
* each run is a full run.
|
|
166
166
|
*
|
|
167
167
|
* States frequency only. Credit cost is deliberately not quoted — the API does
|
|
168
168
|
* not expose a per-action rate for the workspace wallet, and a figure derived
|
|
@@ -174,7 +174,7 @@ function frequencyClause(runs) {
|
|
|
174
174
|
* schedule we are about to create would be worse than saying less.
|
|
175
175
|
*/
|
|
176
176
|
export function formatScheduleFrequencyAdvisory(cron) {
|
|
177
|
-
const tail = 'Each run is a full
|
|
177
|
+
const tail = 'Each run is a full run. Check your balance with `testsprite usage`.';
|
|
178
178
|
const runs = runsPerMonth(cron);
|
|
179
179
|
if (runs === null) {
|
|
180
180
|
return `This schedule will run on the cron \`${cron.trim()}\`. ${tail}`;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What a batch dispatch that stopped part-way says on stderr: the stop lines
|
|
3
|
+
* and the hint naming the tests it never sent. `run`'s batch uses them
|
|
4
|
+
* all; its local (tunnel) batch shares the hint and the line for a stop that
|
|
5
|
+
* still awaits accepted runs, so the two cannot drift there.
|
|
6
|
+
*
|
|
7
|
+
* The reports differ. {@link NOT_SENT_REASON} is the cloud batch's reason for
|
|
8
|
+
* a test it never sent while it awaited the runs already accepted, or after
|
|
9
|
+
* an unconfirmed first request. A stop it does not await (a first request
|
|
10
|
+
* that failed, say) gives the error instead (`not dispatched: <error>`), and
|
|
11
|
+
* the local batch lists such a test as skipped with no reason.
|
|
12
|
+
*/
|
|
13
|
+
/** `N tests were not dispatched: <ids>`, the hint for the tests a stopped dispatch never sent. */
|
|
14
|
+
export declare function notDispatchedHint(testIds: readonly string[]): string;
|
|
15
|
+
/** The stderr line of a dispatch that stopped part-way: why, then each hint given, as sentences. */
|
|
16
|
+
export declare function dispatchStoppedLine(reason: string, hints: ReadonlyArray<string | undefined>): string;
|
|
17
|
+
/** The cloud batch's reason for a test it never sent, in the summary file and the report. */
|
|
18
|
+
export declare const NOT_SENT_REASON = "not dispatched: the dispatch stopped before this test was sent";
|
|
19
|
+
/** The stderr line of a dispatch that stopped while it still awaits the runs already accepted. */
|
|
20
|
+
export declare function awaitingStoppedLine(reason: string, neverSent: readonly string[]): string;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What a batch dispatch that stopped part-way says on stderr: the stop lines
|
|
3
|
+
* and the hint naming the tests it never sent. `run`'s batch uses them
|
|
4
|
+
* all; its local (tunnel) batch shares the hint and the line for a stop that
|
|
5
|
+
* still awaits accepted runs, so the two cannot drift there.
|
|
6
|
+
*
|
|
7
|
+
* The reports differ. {@link NOT_SENT_REASON} is the cloud batch's reason for
|
|
8
|
+
* a test it never sent while it awaited the runs already accepted, or after
|
|
9
|
+
* an unconfirmed first request. A stop it does not await (a first request
|
|
10
|
+
* that failed, say) gives the error instead (`not dispatched: <error>`), and
|
|
11
|
+
* the local batch lists such a test as skipped with no reason.
|
|
12
|
+
*/
|
|
13
|
+
import { terminalSafeLine } from './terminal-text.js';
|
|
14
|
+
/** `N tests were not dispatched: <ids>`, the hint for the tests a stopped dispatch never sent. */
|
|
15
|
+
export function notDispatchedHint(testIds) {
|
|
16
|
+
return (`${testIds.length} test${testIds.length !== 1 ? 's were' : ' was'} not dispatched: ` +
|
|
17
|
+
testIds.map(terminalSafeLine).join(' '));
|
|
18
|
+
}
|
|
19
|
+
/** The stderr line of a dispatch that stopped part-way: why, then each hint given, as sentences. */
|
|
20
|
+
export function dispatchStoppedLine(reason, hints) {
|
|
21
|
+
return `[run] Dispatch stopped (${terminalSafeLine(reason)}). ${hints.filter(Boolean).join('. ')}.`;
|
|
22
|
+
}
|
|
23
|
+
/** The cloud batch's reason for a test it never sent, in the summary file and the report. */
|
|
24
|
+
export const NOT_SENT_REASON = 'not dispatched: the dispatch stopped before this test was sent';
|
|
25
|
+
/** The stderr line of a dispatch that stopped while it still awaits the runs already accepted. */
|
|
26
|
+
export function awaitingStoppedLine(reason, neverSent) {
|
|
27
|
+
return (`[run] Dispatch stopped (${terminalSafeLine(reason)}); awaiting the runs already accepted. ` +
|
|
28
|
+
`${notDispatchedHint(neverSent)}.`);
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=dispatch-stop.js.map
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Downloads to the user's disk: a signed storage link streamed to a file, and
|
|
3
|
+
* the guards on where files land (the `--out` directory the user chose, and
|
|
4
|
+
* every name composed under it).
|
|
5
|
+
*/
|
|
6
|
+
import { Writable } from 'node:stream';
|
|
7
|
+
import { type FetchImpl } from './http.js';
|
|
8
|
+
import { type ShutdownHandle } from './interrupt.js';
|
|
9
|
+
/** Max fetch attempts for each presigned URL (initial + retries). */
|
|
10
|
+
export declare const STREAM_URL_MAX_RETRIES = 3;
|
|
11
|
+
/** Delay between retries for transient transport failures (ms). */
|
|
12
|
+
export declare const STREAM_URL_RETRY_DELAY_MS = 1000;
|
|
13
|
+
/** Recording container extensions trusted from a video link. */
|
|
14
|
+
export declare const KNOWN_VIDEO_EXTENSIONS: Set<string>;
|
|
15
|
+
/**
|
|
16
|
+
* Resolve the user-supplied `--out` path into an absolute directory.
|
|
17
|
+
* Empty strings are rejected with `VALIDATION_ERROR`.
|
|
18
|
+
* Nothing is created here: the writer makes
|
|
19
|
+
* the directory once the response has been read, so a failed read never
|
|
20
|
+
* modifies the operator's filesystem.
|
|
21
|
+
*/
|
|
22
|
+
export declare function resolveOutDir(rawPath: string): string;
|
|
23
|
+
/**
|
|
24
|
+
* Validate the `--out` directory before any request goes out. Surfaces
|
|
25
|
+
* `VALIDATION_ERROR` (exit 5) — matches the convention from `closeOutputFile`
|
|
26
|
+
* for single-file `--out` flags.
|
|
27
|
+
*
|
|
28
|
+
* Missing parent directories are fine: the writer creates the whole tree
|
|
29
|
+
* with `mkdir(dir, { recursive: true })` once the response has been read,
|
|
30
|
+
* so a failed read still leaves nothing on disk. What is refused here is a
|
|
31
|
+
* path that can never become a directory: `--out` pointing at an existing
|
|
32
|
+
* file, or a file where one of its parent directories should be.
|
|
33
|
+
*
|
|
34
|
+
* The directory itself (`resolvedDir`) may or may not exist; the writer
|
|
35
|
+
* creates it if absent.
|
|
36
|
+
*/
|
|
37
|
+
export declare function assertOutDirParentExists(resolvedDir: string): Promise<void>;
|
|
38
|
+
/**
|
|
39
|
+
* Pick the on-disk extension for `video.<ext>` from the actual video link,
|
|
40
|
+
* instead of hardcoding `mp4` (the recording is sometimes a `.webm`
|
|
41
|
+
* container; saving it under a `video.mp4` name misleads strict-extension
|
|
42
|
+
* consumers). Falls back to `mp4` when the URL is malformed or its extension
|
|
43
|
+
* isn't a recognized container, so a response-controlled field can never
|
|
44
|
+
* smuggle an arbitrary suffix onto disk.
|
|
45
|
+
*/
|
|
46
|
+
export declare function pickVideoExtension(url: string): string;
|
|
47
|
+
/**
|
|
48
|
+
* Refuse a composed artifact path that escapes `baseDir`. This is the final
|
|
49
|
+
* containment check before any write. Returns the validated absolute path.
|
|
50
|
+
*/
|
|
51
|
+
export declare function assertNoEscape(baseDir: string, segment: string): string;
|
|
52
|
+
/**
|
|
53
|
+
* Stream a presigned URL into a file with bounded retry on transport
|
|
54
|
+
* failures. 4xx (presigned URL expired or unauthorized) is NOT
|
|
55
|
+
* retried — the URL won't recover on its own; an upstream re-fetch
|
|
56
|
+
* is the only fix. Maps to `UNAVAILABLE` so `index.ts` exits 10.
|
|
57
|
+
*
|
|
58
|
+
* Streaming uses `pipeline` to honor backpressure: a slow disk pauses
|
|
59
|
+
* the upstream reader rather than buffering chunks in V8 heap. This
|
|
60
|
+
* matters for video files (multi-MB) and for very large HTML
|
|
61
|
+
* snapshots.
|
|
62
|
+
*
|
|
63
|
+
* Transport failures (network reset, DNS blip, mid-stream EOF) are
|
|
64
|
+
* retried up to STREAM_URL_MAX_RETRIES times with a fixed delay, well
|
|
65
|
+
* inside a signed link's lifetime. A file whose last attempt broke off
|
|
66
|
+
* mid-stream is left as far as it got: the caller removes it.
|
|
67
|
+
*
|
|
68
|
+
* Only an `https` link to a host that is not a literal local or private
|
|
69
|
+
* address is fetched; any other link is refused before a request is made.
|
|
70
|
+
*
|
|
71
|
+
* `stallTimeoutMs` bounds each wait for data: for the response to start, and
|
|
72
|
+
* between two chunks of its body. It does not bound the whole download, so a
|
|
73
|
+
* large file that keeps arriving is never cut off. A stalled download is not
|
|
74
|
+
* retried.
|
|
75
|
+
*/
|
|
76
|
+
export declare function streamUrlToFile(url: string, filePath: string, fetchImpl: FetchImpl, deps?: {
|
|
77
|
+
sleep?: (ms: number) => Promise<void>;
|
|
78
|
+
shutdownSignal?: AbortSignal;
|
|
79
|
+
shutdown?: Pick<ShutdownHandle, 'runCriticalOperation'>;
|
|
80
|
+
stallTimeoutMs?: number;
|
|
81
|
+
}): Promise<void>;
|
|
82
|
+
/**
|
|
83
|
+
* Why a link is not downloaded, or `undefined` when it may be. The host is
|
|
84
|
+
* judged as written: a name is not resolved, so a proxy or a private storage
|
|
85
|
+
* endpoint reached by name keeps working.
|
|
86
|
+
*/
|
|
87
|
+
export declare function refusedDownloadUrl(url: string): string | undefined;
|
|
88
|
+
/** One attempt's stall clock: `signal` aborts when `arm` is not called again in time. */
|
|
89
|
+
export declare function stallClock(stallTimeoutMs: number): {
|
|
90
|
+
signal: AbortSignal;
|
|
91
|
+
arm: () => void;
|
|
92
|
+
stop: () => void;
|
|
93
|
+
};
|
|
94
|
+
/**
|
|
95
|
+
* A sink that writes each chunk to `file` with the stall clock stopped, and
|
|
96
|
+
* starts it again once the write is done: the clock runs only while the next
|
|
97
|
+
* chunk is awaited, so time the disk takes is not time the link was silent.
|
|
98
|
+
* A failed write is the stream's error, and no further write is started.
|
|
99
|
+
*/
|
|
100
|
+
export declare function stallTimedSink(file: Writable, clock: ReturnType<typeof stallClock>): Writable;
|