@testsprite/testsprite-cli 0.12.0 → 0.14.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 +59 -49
- package/dist/commands/agent.js +16 -13
- package/dist/commands/auth.d.ts +19 -0
- package/dist/commands/auth.js +60 -24
- package/dist/commands/ci.d.ts +86 -1
- package/dist/commands/ci.js +436 -5
- package/dist/commands/doctor.d.ts +2 -0
- package/dist/commands/doctor.js +34 -20
- package/dist/commands/init.js +14 -11
- package/dist/commands/project-env.d.ts +11 -1
- package/dist/commands/project-env.js +408 -70
- package/dist/commands/project-sign-in.d.ts +60 -0
- package/dist/commands/project-sign-in.js +289 -0
- package/dist/commands/project.d.ts +14 -5
- package/dist/commands/project.js +110 -70
- package/dist/commands/schedule.d.ts +14 -0
- package/dist/commands/schedule.js +193 -15
- package/dist/commands/test.d.ts +123 -44
- package/dist/commands/test.js +2993 -636
- package/dist/commands/testlist.d.ts +10 -5
- package/dist/commands/testlist.js +217 -47
- package/dist/commands/tunnel.d.ts +26 -3
- package/dist/commands/tunnel.js +221 -18
- package/dist/commands/usage.d.ts +3 -0
- package/dist/commands/usage.js +12 -5
- package/dist/index.js +39 -50
- package/dist/lib/agent-targets.d.ts +3 -3
- package/dist/lib/agent-targets.js +2 -2
- package/dist/lib/billing-refusal.d.ts +43 -0
- package/dist/lib/billing-refusal.js +171 -0
- package/dist/lib/bundle.d.ts +5 -0
- package/dist/lib/bundle.js +43 -13
- package/dist/lib/ci-linkage.d.ts +90 -0
- package/dist/lib/ci-linkage.js +181 -0
- package/dist/lib/client-factory.d.ts +16 -2
- package/dist/lib/client-factory.js +37 -6
- package/dist/lib/config.d.ts +17 -0
- package/dist/lib/config.js +20 -1
- package/dist/lib/conflict-reason.d.ts +27 -3
- package/dist/lib/conflict-reason.js +53 -4
- package/dist/lib/credentials.js +56 -14
- package/dist/lib/dry-run/samples.d.ts +13 -1
- package/dist/lib/dry-run/samples.js +104 -7
- package/dist/lib/environment-tunnel.d.ts +109 -0
- package/dist/lib/environment-tunnel.js +465 -0
- package/dist/lib/errors.d.ts +18 -11
- package/dist/lib/errors.js +123 -14
- package/dist/lib/failing-fe-resolver.d.ts +1 -1
- package/dist/lib/failing-fe-resolver.js +3 -3
- package/dist/lib/gh-output.d.ts +1 -0
- package/dist/lib/gh-output.js +16 -4
- package/dist/lib/history-retention.d.ts +8 -0
- package/dist/lib/history-retention.js +24 -0
- package/dist/lib/http.d.ts +39 -19
- package/dist/lib/http.js +46 -24
- package/dist/lib/interrupt.d.ts +21 -13
- package/dist/lib/interrupt.js +32 -21
- package/dist/lib/junit-report.d.ts +18 -4
- package/dist/lib/junit-report.js +23 -5
- package/dist/lib/local-target.d.ts +14 -4
- package/dist/lib/local-target.js +48 -13
- package/dist/lib/output.js +15 -1
- package/dist/lib/plan-poll.d.ts +11 -11
- package/dist/lib/plan-poll.js +15 -16
- package/dist/lib/plans.types.d.ts +9 -9
- package/dist/lib/plans.types.js +3 -3
- package/dist/lib/poll.d.ts +2 -2
- package/dist/lib/poll.js +9 -3
- package/dist/lib/redact.d.ts +38 -0
- package/dist/lib/redact.js +140 -0
- package/dist/lib/render-error.d.ts +21 -5
- package/dist/lib/render-error.js +44 -0
- package/dist/lib/response-schemas.d.ts +54 -12
- package/dist/lib/response-schemas.js +88 -7
- package/dist/lib/runs.types.d.ts +68 -11
- package/dist/lib/secret-file.js +72 -14
- package/dist/lib/skill-nudge.d.ts +6 -1
- package/dist/lib/skill-nudge.js +32 -5
- package/dist/lib/target-url-preflight.d.ts +6 -4
- package/dist/lib/target-url-preflight.js +64 -51
- package/dist/lib/target-url.js +11 -11
- package/dist/lib/telemetry.d.ts +10 -8
- package/dist/lib/telemetry.js +24 -17
- package/dist/lib/testlist.types.d.ts +1 -0
- package/dist/lib/ticker.d.ts +9 -0
- package/dist/lib/ticker.js +111 -4
- package/dist/lib/tunnel-session.d.ts +16 -4
- package/dist/lib/tunnel-session.js +7 -5
- package/dist/lib/tunnel.types.d.ts +12 -2
- package/dist/lib/tunnel.types.js +2 -2
- package/dist/lib/v3-advisory.js +0 -1
- package/dist/lib/wait-exit.d.ts +8 -0
- package/dist/lib/wait-exit.js +76 -4
- package/dist/lib/workspace-status.d.ts +23 -0
- package/dist/lib/workspace-status.js +15 -0
- package/dist/vendor/tunnel-client/client.d.ts +15 -8
- package/dist/vendor/tunnel-client/client.js +477 -407
- package/dist/vendor/tunnel-client/config.d.ts +5 -5
- package/dist/vendor/tunnel-client/config.js +5 -5
- package/dist/vendor/tunnel-client/index.d.ts +4 -4
- package/dist/vendor/tunnel-client/index.js +4 -4
- package/dist/vendor/tunnel-client/types.d.ts +19 -34
- package/dist/vendor/tunnel-client/types.js +1 -0
- package/dist/vendor/tunnel-client/ws-compat.d.ts +13 -3
- package/dist/vendor/tunnel-client/ws-compat.js +70 -12
- package/dist/version-guard.d.ts +7 -1
- package/dist/version-guard.js +19 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +4 -4
- package/skills/testsprite-onboard.skill.md +8 -8
- package/skills/testsprite-verify.codex.md +59 -57
- package/skills/testsprite-verify.skill.md +53 -38
package/dist/lib/errors.js
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { resolvePortalBase } from './facade.js';
|
|
2
|
+
import { redactDeep } from './redact.js';
|
|
3
|
+
import { classifyBillingRefusal, gateRefusalOf } from './billing-refusal.js';
|
|
2
4
|
/**
|
|
3
5
|
* Error codes shared with the backend facade and the MCP plugin.
|
|
4
6
|
* Must stay in sync across all three.
|
|
@@ -165,10 +167,9 @@ export const TERMINATION_EXIT_CODES = {
|
|
|
165
167
|
SIGHUP: 129, // 128 + 1
|
|
166
168
|
};
|
|
167
169
|
/**
|
|
168
|
-
* User-initiated interrupt (SIGINT/SIGTERM/SIGHUP) observed
|
|
169
|
-
*
|
|
170
|
-
*
|
|
171
|
-
* honest partial envelope + re-attach hint, then rethrow to `index.ts`.
|
|
170
|
+
* User-initiated interrupt (SIGINT/SIGTERM/SIGHUP) observed during an armed
|
|
171
|
+
* wait or a disarmed request. Run/wait paths mark the error so `index.ts` can give
|
|
172
|
+
* recovery guidance only when there is a run to re-attach to.
|
|
172
173
|
*
|
|
173
174
|
* Deliberately NOT in `ERROR_CODES` — on a signal the CLI
|
|
174
175
|
* exits 130/143 without consulting the error catalog. The JSON-mode stderr
|
|
@@ -177,6 +178,7 @@ export const TERMINATION_EXIT_CODES = {
|
|
|
177
178
|
*/
|
|
178
179
|
export class InterruptError extends CLIError {
|
|
179
180
|
signal;
|
|
181
|
+
runWaitContext = false;
|
|
180
182
|
constructor(signal) {
|
|
181
183
|
super(`Interrupted by ${signal}.`, TERMINATION_EXIT_CODES[signal], 'INTERRUPTED');
|
|
182
184
|
this.name = 'InterruptError';
|
|
@@ -190,11 +192,9 @@ export class NotImplementedError extends CLIError {
|
|
|
190
192
|
}
|
|
191
193
|
}
|
|
192
194
|
/**
|
|
193
|
-
* Server-returned API error. The CLI
|
|
194
|
-
*
|
|
195
|
-
*
|
|
196
|
-
* constructs an envelope with the same shape so the user sees identical
|
|
197
|
-
* wording across paths).
|
|
195
|
+
* Server-returned API error. The CLI preserves the facade's nonempty
|
|
196
|
+
* `nextAction` and synthesizes one for billing refusals that omit it.
|
|
197
|
+
* Locally-detected pre-flight conditions use the same envelope shape.
|
|
198
198
|
*/
|
|
199
199
|
export class ApiError extends CLIError {
|
|
200
200
|
// `override`: CLIError now declares its own `code: string` (defaulting
|
|
@@ -209,8 +209,10 @@ export class ApiError extends CLIError {
|
|
|
209
209
|
code;
|
|
210
210
|
requestId;
|
|
211
211
|
nextAction;
|
|
212
|
+
serverNextAction;
|
|
212
213
|
details;
|
|
213
214
|
httpStatus;
|
|
215
|
+
apiUrl;
|
|
214
216
|
/**
|
|
215
217
|
* Parsed `Retry-After` header value in milliseconds, when present on the
|
|
216
218
|
* HTTP response. Only set for `RATE_LIMITED` (429) responses where the
|
|
@@ -219,14 +221,26 @@ export class ApiError extends CLIError {
|
|
|
219
221
|
* absent or unparseable.
|
|
220
222
|
*/
|
|
221
223
|
retryAfterMs;
|
|
222
|
-
constructor(envelope, httpStatus, retryAfterMs) {
|
|
224
|
+
constructor(envelope, httpStatus, retryAfterMs, apiUrl, serverNextAction) {
|
|
223
225
|
super(envelope.message, exitCodeFor(envelope.code));
|
|
224
226
|
this.name = 'ApiError';
|
|
225
227
|
this.code = envelope.code;
|
|
226
228
|
this.requestId = envelope.requestId;
|
|
227
229
|
this.nextAction = envelope.nextAction;
|
|
228
|
-
this.
|
|
230
|
+
this.serverNextAction = serverNextAction ?? envelope.nextAction;
|
|
231
|
+
// Redact at the single point every ApiError is constructed — server
|
|
232
|
+
// envelopes (fromEnvelope), locally-fabricated ones (authRequired,
|
|
233
|
+
// localValidationError), and any future direct `new ApiError(...)` — so
|
|
234
|
+
// `.details` and `.getDetail(...)` are already clean everywhere they are
|
|
235
|
+
// read: `Output.error`'s JSON envelope, `index.ts`'s hand-built ApiError
|
|
236
|
+
// envelope, and the AUTH_FORBIDDEN/CLIENT_TOO_OLD/AMBIGUOUS_ORG text-mode
|
|
237
|
+
// blocks in `index.ts` that print specific detail keys directly (those
|
|
238
|
+
// never go through `Output.error` at all, so redacting only at the
|
|
239
|
+
// render call sites would miss them). Server envelopes are already
|
|
240
|
+
// redacted server-side; this is defence in depth, not the only layer.
|
|
241
|
+
this.details = redactDeep(envelope.details);
|
|
229
242
|
this.httpStatus = httpStatus;
|
|
243
|
+
this.apiUrl = apiUrl;
|
|
230
244
|
this.retryAfterMs = retryAfterMs;
|
|
231
245
|
}
|
|
232
246
|
/**
|
|
@@ -236,7 +250,17 @@ export class ApiError extends CLIError {
|
|
|
236
250
|
*/
|
|
237
251
|
static fromEnvelope(raw, httpStatus, retryAfterMs, apiUrl) {
|
|
238
252
|
const envelope = parseEnvelopeBody(raw, httpStatus, apiUrl);
|
|
239
|
-
|
|
253
|
+
const serverNextAction = envelope.nextAction;
|
|
254
|
+
if (!envelope.nextAction) {
|
|
255
|
+
const refusal = classifyBillingRefusal({ ...envelope, apiUrl });
|
|
256
|
+
if (refusal) {
|
|
257
|
+
envelope.nextAction =
|
|
258
|
+
envelope.code === 'INSUFFICIENT_CREDITS'
|
|
259
|
+
? insufficientCreditsNextAction(apiUrl)
|
|
260
|
+
: refusal.nextAction;
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
return new ApiError(envelope, httpStatus, retryAfterMs, apiUrl, serverNextAction);
|
|
240
264
|
}
|
|
241
265
|
/**
|
|
242
266
|
* Type-safe accessor for a single key inside `details`. Avoids the
|
|
@@ -270,7 +294,31 @@ export class ApiError extends CLIError {
|
|
|
270
294
|
* AUTH_REQUIRED template so the user sees the same thing whether the
|
|
271
295
|
* miss was detected before or after sending the request.
|
|
272
296
|
*/
|
|
273
|
-
|
|
297
|
+
/**
|
|
298
|
+
* `profile` is supplied only when a NON-default profile was selected — by
|
|
299
|
+
* `--profile` or by `TESTSPRITE_PROFILE`. Naming it matters because the
|
|
300
|
+
* selection is invisible otherwise: a typo in either one picks a profile
|
|
301
|
+
* that has no credentials, and the generic message sends the reader off to
|
|
302
|
+
* configure the default profile they already have.
|
|
303
|
+
*/
|
|
304
|
+
static authRequired(requestId = 'local', profile) {
|
|
305
|
+
if (profile !== undefined) {
|
|
306
|
+
return new ApiError({
|
|
307
|
+
code: 'AUTH_REQUIRED',
|
|
308
|
+
// `message` stays byte-identical to the default-profile case: the
|
|
309
|
+
// wording is stable per error code, so callers can pattern-match on it.
|
|
310
|
+
// The profile belongs in the remediation and in `details`, which are
|
|
311
|
+
// the per-error context.
|
|
312
|
+
message: 'Authentication is required.',
|
|
313
|
+
nextAction: `No credentials are stored for profile "${profile}". Run \`testsprite setup --profile ${profile}\`` +
|
|
314
|
+
' to configure it, or drop the profile selection if you did not mean to use one' +
|
|
315
|
+
' (`--profile` flag, TESTSPRITE_PROFILE env var). `testsprite doctor` prints the profile in use.',
|
|
316
|
+
requestId,
|
|
317
|
+
// Safe to echo: every credential read passes the profile name through
|
|
318
|
+
// `assertValidProfileName` first, so it matches /^[A-Za-z0-9._-]+$/.
|
|
319
|
+
details: { profile },
|
|
320
|
+
});
|
|
321
|
+
}
|
|
274
322
|
return new ApiError({
|
|
275
323
|
code: 'AUTH_REQUIRED',
|
|
276
324
|
message: 'Authentication is required.',
|
|
@@ -462,6 +510,67 @@ function parseEnvelopeBody(raw, httpStatus, apiUrl) {
|
|
|
462
510
|
};
|
|
463
511
|
}
|
|
464
512
|
const obj = raw;
|
|
513
|
+
const wireCode = typeof obj.code === 'string' ? obj.code : '';
|
|
514
|
+
// The exact wire codes the workspace-gate body can send — checked on their
|
|
515
|
+
// own (not just the open-ended `_limit_exceeded` suffix) so a body with no
|
|
516
|
+
// HTTP status attached still has something narrow to match against.
|
|
517
|
+
const isKnownGateWireCode = wireCode === 'feature_not_entitled' ||
|
|
518
|
+
wireCode === 'workspace_paused' ||
|
|
519
|
+
wireCode === 'environment_limit_exceeded' ||
|
|
520
|
+
wireCode === 'testlist_limit_exceeded' ||
|
|
521
|
+
wireCode === 'schedule_limit_exceeded' ||
|
|
522
|
+
wireCode === 'github_repo_limit_exceeded' ||
|
|
523
|
+
wireCode === 'fixture_limit_exceeded' ||
|
|
524
|
+
wireCode === 'project_limit_exceeded';
|
|
525
|
+
// Only take this raw shape for the HTTP statuses the gate actually answers
|
|
526
|
+
// with (402/403) — matching purely on `code` let an unrelated 429 body that
|
|
527
|
+
// happens to end in `_limit_exceeded` (e.g. a future `rate_limit_exceeded`)
|
|
528
|
+
// get reclassified as a non-retriable FEATURE_GATED and stop being retried.
|
|
529
|
+
// With no status at all, only the exact known codes above qualify: the
|
|
530
|
+
// open-ended suffix match is too permissive without a status to corroborate it.
|
|
531
|
+
const takesRawGateShape = httpStatus === 402 || httpStatus === 403
|
|
532
|
+
? isKnownGateWireCode || /_limit_exceeded$/.test(wireCode)
|
|
533
|
+
: httpStatus === undefined && isKnownGateWireCode;
|
|
534
|
+
if (takesRawGateShape) {
|
|
535
|
+
// A `reason` on the body is the server's and passes through as-is.
|
|
536
|
+
// Otherwise the wire code says which gate refusal it is, named as the
|
|
537
|
+
// gate names it.
|
|
538
|
+
const reason = typeof obj.reason === 'string' && obj.reason !== ''
|
|
539
|
+
? obj.reason
|
|
540
|
+
: wireCode.endsWith('_limit_exceeded')
|
|
541
|
+
? 'limit_exceeded'
|
|
542
|
+
: wireCode === 'workspace_paused'
|
|
543
|
+
? 'paused'
|
|
544
|
+
: 'not_entitled';
|
|
545
|
+
const details = { reason };
|
|
546
|
+
for (const key of [
|
|
547
|
+
'feature',
|
|
548
|
+
'plan',
|
|
549
|
+
'limit',
|
|
550
|
+
'current',
|
|
551
|
+
'requiredPlan',
|
|
552
|
+
'orgId',
|
|
553
|
+
'billingUrl',
|
|
554
|
+
'action',
|
|
555
|
+
'pauseKind',
|
|
556
|
+
'pauseTarget',
|
|
557
|
+
]) {
|
|
558
|
+
if (obj[key] !== undefined && obj[key] !== null)
|
|
559
|
+
details[key] = obj[key];
|
|
560
|
+
}
|
|
561
|
+
if (gateRefusalOf(reason) === 'limit_exceeded' && details.feature === undefined) {
|
|
562
|
+
details.feature = wireCode.slice(0, -'_limit_exceeded'.length);
|
|
563
|
+
}
|
|
564
|
+
return {
|
|
565
|
+
code: 'FEATURE_GATED',
|
|
566
|
+
message: typeof obj.message === 'string'
|
|
567
|
+
? obj.message
|
|
568
|
+
: 'This action is unavailable on the current plan.',
|
|
569
|
+
nextAction: typeof obj.nextAction === 'string' ? obj.nextAction : '',
|
|
570
|
+
requestId: typeof obj.requestId === 'string' ? obj.requestId : 'unknown',
|
|
571
|
+
details,
|
|
572
|
+
};
|
|
573
|
+
}
|
|
465
574
|
// Raw Nest/Express 404 shape: `{ message, error: "Not Found", statusCode }`.
|
|
466
575
|
// The current parser was matching `obj.error` (a string) and falling to
|
|
467
576
|
// `Server error.` while losing the actual `message` from the body
|
|
@@ -478,7 +587,7 @@ function parseEnvelopeBody(raw, httpStatus, apiUrl) {
|
|
|
478
587
|
? `${message} — endpoint not available on the current backend deployment.`
|
|
479
588
|
: message,
|
|
480
589
|
nextAction: isRouteMissing404
|
|
481
|
-
? 'Verify the CLI is targeting the right environment (check `testsprite auth status` for `env`), and confirm
|
|
590
|
+
? 'Verify the CLI is targeting the right environment (check `testsprite auth status` for `env`), and confirm that backend deployment includes this endpoint — it may need a newer backend release.'
|
|
482
591
|
: '',
|
|
483
592
|
requestId: 'unknown',
|
|
484
593
|
details: { statusCode: obj.statusCode },
|
|
@@ -44,7 +44,7 @@ export interface ResolverOptions {
|
|
|
44
44
|
*/
|
|
45
45
|
maxPages?: number;
|
|
46
46
|
/**
|
|
47
|
-
*
|
|
47
|
+
* The operator's pinned `failingFrontendTestId` (the static value
|
|
48
48
|
* from fixtures.local.json). "Freshest failed" alone is fragile in a shared
|
|
49
49
|
* project: any OTHER FE test that fails more recently than a dedicated,
|
|
50
50
|
* permanently-red fixture silently steals the slot (live-reproduced
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
export async function resolveFailingFrontendTestId(opts) {
|
|
27
27
|
const { baseUrl, apiKey, projectId, maxPages = 5, preferredId } = opts;
|
|
28
28
|
const fetchImpl = opts.fetchImpl ?? fetch;
|
|
29
|
-
//
|
|
29
|
+
// Probe the pinned fixture directly first, so the
|
|
30
30
|
// preference cannot be defeated by the maxPages list-scan cap (a pinned
|
|
31
31
|
// fixture beyond page `maxPages` would otherwise silently lose the slot to
|
|
32
32
|
// an incidental fresher failure). Any probe error or non-failed status
|
|
@@ -44,7 +44,7 @@ export async function resolveFailingFrontendTestId(opts) {
|
|
|
44
44
|
});
|
|
45
45
|
if (resp.ok) {
|
|
46
46
|
const test = (await resp.json());
|
|
47
|
-
// The probe must honor the resolver's project scope
|
|
47
|
+
// The probe must honor the resolver's project scope:
|
|
48
48
|
// the list path filters by projectId server-side, so a pin that
|
|
49
49
|
// points at a failed FE test in a DIFFERENT project must not win
|
|
50
50
|
// here either. A response without a matching projectId (absent or
|
|
@@ -118,7 +118,7 @@ export async function resolveFailingFrontendTestId(opts) {
|
|
|
118
118
|
reason: 'No frontend tests with status=failed found in project; falling back to static fixture',
|
|
119
119
|
};
|
|
120
120
|
}
|
|
121
|
-
//
|
|
121
|
+
// A pinned, dedicated "always red" fixture wins over freshest
|
|
122
122
|
// whenever it is still in the failed set — see the doc comment on
|
|
123
123
|
// ResolverOptions.preferredId for why "freshest" alone is not enough.
|
|
124
124
|
if (preferredId) {
|
package/dist/lib/gh-output.d.ts
CHANGED
|
@@ -43,6 +43,7 @@ export interface CiSummary {
|
|
|
43
43
|
timedOut: number;
|
|
44
44
|
runs: CiRunRow[];
|
|
45
45
|
}
|
|
46
|
+
export declare function isNonDispatchedStatus(status: string): boolean;
|
|
46
47
|
/**
|
|
47
48
|
* Reduce the batch command's JSON payload into the CI summary. The parse is
|
|
48
49
|
* defensive: it reads the same `accepted[]` rows the automation contract
|
package/dist/lib/gh-output.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { appendFileSync, writeFileSync } from 'node:fs';
|
|
2
|
+
import { describeConflict } from './conflict-reason.js';
|
|
2
3
|
/**
|
|
3
4
|
* Row statuses that mean "this test never ran" as opposed to "this run did not
|
|
4
5
|
* pass". They count as `skipped` in the summary (not `failed`) and annotate as
|
|
@@ -12,6 +13,9 @@ const NON_DISPATCHED_STATUSES = new Set([
|
|
|
12
13
|
'skipped',
|
|
13
14
|
'no_tests',
|
|
14
15
|
]);
|
|
16
|
+
export function isNonDispatchedStatus(status) {
|
|
17
|
+
return NON_DISPATCHED_STATUSES.has(status);
|
|
18
|
+
}
|
|
15
19
|
/**
|
|
16
20
|
* Reduce a non-dispatched bucket (`deferred` / `conflicts` / `notFound`) into
|
|
17
21
|
* CI rows. Items are either bare testId strings (`notFound`) or
|
|
@@ -29,7 +33,7 @@ function bucketRows(bucket, status, note) {
|
|
|
29
33
|
testId,
|
|
30
34
|
status,
|
|
31
35
|
...(currentRunId ? { runId: currentRunId } : {}),
|
|
32
|
-
error: note,
|
|
36
|
+
error: typeof note === 'string' ? note : note(item),
|
|
33
37
|
};
|
|
34
38
|
});
|
|
35
39
|
}
|
|
@@ -80,8 +84,16 @@ export function summarizeAcceptedPayload(capturedJson, opts = {}) {
|
|
|
80
84
|
: [];
|
|
81
85
|
const rows = [
|
|
82
86
|
...acceptedRows,
|
|
87
|
+
...bucketRows(payload.skipped, 'skipped', item => typeof item?.reason === 'string'
|
|
88
|
+
? item.reason
|
|
89
|
+
: 'not dispatched'),
|
|
83
90
|
...bucketRows(payload.deferred, 'deferred', 'rate-deferred (not dispatched)'),
|
|
84
|
-
...bucketRows(payload.conflicts, 'conflict',
|
|
91
|
+
...bucketRows(payload.conflicts, 'conflict', item => {
|
|
92
|
+
const conflict = item;
|
|
93
|
+
return conflict && typeof conflict.testId === 'string' && conflict.reason
|
|
94
|
+
? `${describeConflict(conflict)} (not dispatched)`
|
|
95
|
+
: 'already in flight (not dispatched)';
|
|
96
|
+
}),
|
|
85
97
|
// Default note is `test rerun`'s cause (a not-found id has no replayable
|
|
86
98
|
// run). `testlist run` passes its own — a not-found `--case` id is one that
|
|
87
99
|
// is not a member of the list — so the annotation/artifact don't state the
|
|
@@ -90,7 +102,7 @@ export function summarizeAcceptedPayload(capturedJson, opts = {}) {
|
|
|
90
102
|
];
|
|
91
103
|
const passed = rows.filter(row => row.status === 'passed').length;
|
|
92
104
|
const timedOut = rows.filter(row => row.status === 'timeout').length;
|
|
93
|
-
const skipped = rows.filter(row =>
|
|
105
|
+
const skipped = rows.filter(row => isNonDispatchedStatus(row.status)).length;
|
|
94
106
|
const failed = rows.length - passed - timedOut - skipped;
|
|
95
107
|
return { total: rows.length, passed, failed, skipped, timedOut, runs: rows };
|
|
96
108
|
}
|
|
@@ -113,7 +125,7 @@ export function summarizeSingleRun(run) {
|
|
|
113
125
|
};
|
|
114
126
|
const passed = row.status === 'passed' ? 1 : 0;
|
|
115
127
|
const timedOut = row.status === 'timeout' ? 1 : 0;
|
|
116
|
-
const skipped =
|
|
128
|
+
const skipped = isNonDispatchedStatus(row.status) ? 1 : 0;
|
|
117
129
|
const failed = 1 - passed - timedOut - skipped;
|
|
118
130
|
return { total: 1, passed, failed, skipped, timedOut, runs: [row] };
|
|
119
131
|
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export interface HistoryRetentionMeta {
|
|
2
|
+
tier?: string;
|
|
3
|
+
retentionDays?: number | null;
|
|
4
|
+
hiddenCount?: number;
|
|
5
|
+
billingUrl?: string;
|
|
6
|
+
}
|
|
7
|
+
/** Returns no text for older backends, unlimited history, or an unhidden page. */
|
|
8
|
+
export declare function historyRetentionNote(meta: HistoryRetentionMeta | undefined, apiUrl: string, derived?: boolean): string | undefined;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { resolveBillingLinks } from './billing-refusal.js';
|
|
2
|
+
/** Returns no text for older backends, unlimited history, or an unhidden page. */
|
|
3
|
+
export function historyRetentionNote(meta, apiUrl, derived = false) {
|
|
4
|
+
if (!meta || !Number.isFinite(meta.hiddenCount) || !meta.hiddenCount || meta.hiddenCount <= 0) {
|
|
5
|
+
return undefined;
|
|
6
|
+
}
|
|
7
|
+
if (meta.retentionDays == null || !Number.isFinite(meta.retentionDays))
|
|
8
|
+
return undefined;
|
|
9
|
+
const { pricing, billing } = resolveBillingLinks({
|
|
10
|
+
apiUrl,
|
|
11
|
+
billingUrl: meta.billingUrl,
|
|
12
|
+
});
|
|
13
|
+
const count = meta.hiddenCount;
|
|
14
|
+
const runs = `${count} run${count === 1 ? '' : 's'}`;
|
|
15
|
+
const plan = meta.tier ? `the ${meta.tier} plan` : 'your plan';
|
|
16
|
+
const prefix = derived ? "This suggestion only covers the plan's visible history. " : '';
|
|
17
|
+
// Paused is a plan tier whose window is zero days: every run is hidden, not
|
|
18
|
+
// just older ones, and "keeps 0 days" would read oddly.
|
|
19
|
+
const reason = meta.tier === 'Paused' || meta.retentionDays === 0
|
|
20
|
+
? `${runs} hidden — this workspace is on the Paused plan, which keeps no run history.`
|
|
21
|
+
: `${count} older run${count === 1 ? '' : 's'} hidden — ${plan} keeps ${meta.retentionDays} day${meta.retentionDays === 1 ? '' : 's'} of run history.`;
|
|
22
|
+
return `${prefix}${reason}\n` + ` upgrade: ${pricing}\n` + ` billing: ${billing}`;
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=history-retention.js.map
|
package/dist/lib/http.d.ts
CHANGED
|
@@ -4,7 +4,8 @@ import { ApiError } from './errors.js';
|
|
|
4
4
|
import type { CliTestListRunResponse } from './testlist.types.js';
|
|
5
5
|
import type { TriggerRunBody, TriggerRunResponse, RunResponse, RerunRequest, RerunResponse, BatchRerunRequest, BatchRerunResponse, BatchRunFreshRequest, BatchRunFreshResponse, ListRunsQuery, ListRunsResponse, CancelRunResponse } from './runs.types.js';
|
|
6
6
|
import type { CliAcceptPlansResponse, CliGeneratePlansResponse, CliGetPlansResponse } from './plans.types.js';
|
|
7
|
-
import type { MintTunnelBody, TunnelMintResponse, TunnelStatusResponse } from './tunnel.types.js';
|
|
7
|
+
import type { MintTunnelBody, TunnelListResponse, TunnelMintResponse, TunnelStatusResponse } from './tunnel.types.js';
|
|
8
|
+
import type { ShutdownHandle } from './interrupt.js';
|
|
8
9
|
export type FetchImpl = typeof globalThis.fetch;
|
|
9
10
|
export type DebugEventKind = 'request' | 'response' | 'retry' | 'error';
|
|
10
11
|
export interface DebugEvent {
|
|
@@ -87,7 +88,7 @@ export interface HttpClientOptions {
|
|
|
87
88
|
*/
|
|
88
89
|
requestTimeoutMs?: number;
|
|
89
90
|
/**
|
|
90
|
-
* Process-lifetime shutdown signal
|
|
91
|
+
* Process-lifetime shutdown signal. Composed into every
|
|
91
92
|
* outgoing fetch so an armed SIGINT/SIGTERM aborts an in-flight request
|
|
92
93
|
* (a `--wait` long-poll can sit inside a single fetch for minutes) instead
|
|
93
94
|
* of waiting out its window. Aborts with an `InterruptError` reason, which
|
|
@@ -96,6 +97,13 @@ export interface HttpClientOptions {
|
|
|
96
97
|
* `globalShutdown.signal` via the client factory.
|
|
97
98
|
*/
|
|
98
99
|
shutdownSignal?: AbortSignal;
|
|
100
|
+
/**
|
|
101
|
+
* Tracks the request through dispatch, body reading, and retries so a
|
|
102
|
+
* disarmed signal can let it drain.
|
|
103
|
+
* Unlike `shutdownSignal`, this does not cancel the request. Omit it for
|
|
104
|
+
* requests that should remain untracked.
|
|
105
|
+
*/
|
|
106
|
+
shutdown?: Pick<ShutdownHandle, 'runCriticalOperation'>;
|
|
99
107
|
/**
|
|
100
108
|
* Upper bound (bytes) on a successful JSON response body the client will
|
|
101
109
|
* buffer before parsing. A response whose declared `Content-Length` — or
|
|
@@ -183,9 +191,11 @@ export interface RequestOptions<T = unknown> {
|
|
|
183
191
|
}
|
|
184
192
|
/**
|
|
185
193
|
* 429 reasons that name a STANDING condition rather than a passing throttle —
|
|
186
|
-
* e.g. the per-user cap on live tunnel bindings
|
|
187
|
-
*
|
|
188
|
-
* server's nextAction (e.g.
|
|
194
|
+
* e.g. the per-user cap on live tunnel bindings, or already having the maximum
|
|
195
|
+
* number of runs in flight. Retrying cannot succeed until the caller frees the
|
|
196
|
+
* resource, so the retry budget is skipped and the server's nextAction (e.g.
|
|
197
|
+
* `testsprite tunnel stop`) surfaces immediately. `Retry-After` on these says
|
|
198
|
+
* when a retry COULD first succeed, not that the condition clears on its own.
|
|
189
199
|
*/
|
|
190
200
|
export declare const STANDING_RATE_LIMIT_REASONS: ReadonlySet<string>;
|
|
191
201
|
/** True for a RATE_LIMITED error whose envelope names a standing condition. */
|
|
@@ -210,13 +220,13 @@ export declare class HttpClient {
|
|
|
210
220
|
private readonly onServerVersion?;
|
|
211
221
|
private readonly requestTimeoutMs;
|
|
212
222
|
private readonly shutdownSignal?;
|
|
223
|
+
private readonly shutdown?;
|
|
213
224
|
private readonly maxResponseBytes;
|
|
214
225
|
private readonly userAgent;
|
|
215
226
|
constructor(options: HttpClientOptions);
|
|
216
227
|
/** The resolved facade base URL (trailing slash trimmed). Read-only —
|
|
217
228
|
* callers that bypass the client for a side-channel request (e.g. the
|
|
218
|
-
* presigned S3 PUT) use it to reason about the facade's locality
|
|
219
|
-
* (DEV-384 review F3). */
|
|
229
|
+
* presigned S3 PUT) use it to reason about the facade's locality. */
|
|
220
230
|
get resolvedBaseUrl(): string;
|
|
221
231
|
/**
|
|
222
232
|
* Read the backend's supported-floor header off a response and forward it to
|
|
@@ -234,7 +244,7 @@ export declare class HttpClient {
|
|
|
234
244
|
/**
|
|
235
245
|
* Like `get` / `post` / etc. but returns the full `RequestResult` including
|
|
236
246
|
* `requestId` and `status`, so callers can surface the requestId in
|
|
237
|
-
* happy-path output
|
|
247
|
+
* happy-path output.
|
|
238
248
|
*/
|
|
239
249
|
getWithMeta<T>(path: string, options?: RequestOptions<T>): Promise<RequestResult<T>>;
|
|
240
250
|
postWithMeta<T>(path: string, options?: RequestOptions<T>): Promise<RequestResult<T>>;
|
|
@@ -315,6 +325,8 @@ export declare class HttpClient {
|
|
|
315
325
|
*/
|
|
316
326
|
triggerTestListRun(listId: string, body: {
|
|
317
327
|
testIds?: string[];
|
|
328
|
+
tunnelClientId?: string;
|
|
329
|
+
targetUrl?: string;
|
|
318
330
|
}, options: {
|
|
319
331
|
idempotencyKey: string;
|
|
320
332
|
signal?: AbortSignal;
|
|
@@ -365,6 +377,13 @@ export declare class HttpClient {
|
|
|
365
377
|
mintTunnel(body: MintTunnelBody, options?: {
|
|
366
378
|
signal?: AbortSignal;
|
|
367
379
|
}): Promise<TunnelMintResponse>;
|
|
380
|
+
/**
|
|
381
|
+
* GET /api/cli/v1/tunnel — list this account's live bindings.
|
|
382
|
+
* Secret-free, partition-scoped by the server; requires `run:tunnel`.
|
|
383
|
+
*/
|
|
384
|
+
listTunnels(options?: {
|
|
385
|
+
signal?: AbortSignal;
|
|
386
|
+
}): Promise<TunnelListResponse>;
|
|
368
387
|
/**
|
|
369
388
|
* GET /api/cli/v1/tunnel/{clientId} — is this binding's client connected?
|
|
370
389
|
*
|
|
@@ -372,7 +391,8 @@ export declare class HttpClient {
|
|
|
372
391
|
* deliberately not an existence oracle for client ids. Callers must not
|
|
373
392
|
* translate a transport failure or a non-200 into `offline` — "the tunnel is
|
|
374
393
|
* down" and "we could not reach TestSprite to ask" are different answers,
|
|
375
|
-
* and collapsing them
|
|
394
|
+
* and collapsing them would misreport a transient network failure as a
|
|
395
|
+
* dead tunnel.
|
|
376
396
|
*/
|
|
377
397
|
getTunnelStatus(clientId: string, options?: {
|
|
378
398
|
signal?: AbortSignal;
|
|
@@ -390,8 +410,8 @@ export declare class HttpClient {
|
|
|
390
410
|
}): Promise<void>;
|
|
391
411
|
/**
|
|
392
412
|
* POST /api/cli/v1/runs/{runId}/cancel
|
|
393
|
-
* User-initiated cancel of a queued/running run
|
|
394
|
-
* body, no `Idempotency-Key` — the endpoint is naturally idempotent
|
|
413
|
+
* User-initiated cancel of a queued/running run. No
|
|
414
|
+
* body, no `Idempotency-Key` — the endpoint is naturally idempotent:
|
|
395
415
|
* re-cancel → 200 `alreadyCancelled: true`; already-terminal (passed/
|
|
396
416
|
* failed/blocked) → 409 CONFLICT; unknown/cross-tenant runId → 404.
|
|
397
417
|
*
|
|
@@ -403,7 +423,7 @@ export declare class HttpClient {
|
|
|
403
423
|
signal?: AbortSignal;
|
|
404
424
|
}): Promise<CancelRunResponse>;
|
|
405
425
|
/**
|
|
406
|
-
* POST /api/cli/v1/projects/{projectId}/plans/generate
|
|
426
|
+
* POST /api/cli/v1/projects/{projectId}/plans/generate
|
|
407
427
|
* Start whichever generation stage the project is missing next. The body
|
|
408
428
|
* is empty by contract — the server decides which rung fires. 202 both
|
|
409
429
|
* for `accepted` (a stage started) and `nothing_to_start` (proposals are
|
|
@@ -419,7 +439,7 @@ export declare class HttpClient {
|
|
|
419
439
|
signal?: AbortSignal;
|
|
420
440
|
}): Promise<CliGeneratePlansResponse>;
|
|
421
441
|
/**
|
|
422
|
-
* GET /api/cli/v1/projects/{projectId}/plans
|
|
442
|
+
* GET /api/cli/v1/projects/{projectId}/plans
|
|
423
443
|
* Pure read: the facade-synthesized generation status, the staged
|
|
424
444
|
* proposal list (stable proposalIds — what `accept --only` consumes),
|
|
425
445
|
* and a best-effort credits block. When `waitSeconds` (1–25) is
|
|
@@ -431,7 +451,7 @@ export declare class HttpClient {
|
|
|
431
451
|
signal?: AbortSignal;
|
|
432
452
|
}): Promise<CliGetPlansResponse>;
|
|
433
453
|
/**
|
|
434
|
-
* POST /api/cli/v1/projects/{projectId}/plans/accept
|
|
454
|
+
* POST /api/cli/v1/projects/{projectId}/plans/accept
|
|
435
455
|
* Convert staged proposals into real test cases. `only` is ALWAYS an
|
|
436
456
|
* explicit, non-empty id list — the caller enforces the two §3.3 safety
|
|
437
457
|
* rules (full list when the user didn't subset; an empty selection is a
|
|
@@ -452,13 +472,13 @@ export declare class HttpClient {
|
|
|
452
472
|
*/
|
|
453
473
|
private rethrowIfAbort;
|
|
454
474
|
requestWithMeta<T>(method: string, path: string, options?: RequestOptions<T>): Promise<RequestResult<T>>;
|
|
475
|
+
private requestWithMetaUntracked;
|
|
455
476
|
private buildHeaders;
|
|
456
477
|
/**
|
|
457
|
-
* Retry-delay sleep that bails the moment the shutdown signal fires
|
|
458
|
-
*
|
|
459
|
-
*
|
|
460
|
-
*
|
|
461
|
-
* poll.ts::sleepUnlessInterrupted.
|
|
478
|
+
* Retry-delay sleep that bails the moment the shutdown signal fires: a
|
|
479
|
+
* RATE_LIMITED `Retry-After: 60` or a transport backoff must not delay the
|
|
480
|
+
* honest-detach exit by up to a minute — reject with the InterruptError
|
|
481
|
+
* reason immediately. Mirrors poll.ts::sleepUnlessInterrupted.
|
|
462
482
|
*/
|
|
463
483
|
private sleepBeforeRetry;
|
|
464
484
|
private debug;
|