@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/local-target.js
CHANGED
|
@@ -34,8 +34,8 @@ import { resolveDialCandidates } from '../vendor/tunnel-client/index.js';
|
|
|
34
34
|
* value this rejects but the server accepts is a capability silently withheld.
|
|
35
35
|
*/
|
|
36
36
|
export const LOOPBACK_HOSTS = ['localhost', '127.0.0.1', '::1'];
|
|
37
|
-
/** Default
|
|
38
|
-
export const DEFAULT_LOCAL_HOST = '
|
|
37
|
+
/** Default host for a new `--local <port>` shorthand target. */
|
|
38
|
+
export const DEFAULT_LOCAL_HOST = 'localhost';
|
|
39
39
|
/**
|
|
40
40
|
* Per-candidate dial budget. Deliberately short: this is a loopback connect on
|
|
41
41
|
* the caller's own machine, where a live listener answers in microseconds. A
|
|
@@ -60,12 +60,21 @@ export function parseLocalPort(raw) {
|
|
|
60
60
|
* caller's own machine and nothing else, so a non-loopback value here is a
|
|
61
61
|
* misunderstanding to correct immediately, not a request to forward.
|
|
62
62
|
*/
|
|
63
|
+
/**
|
|
64
|
+
* The loopback spelling a host string names, or `undefined` when it names
|
|
65
|
+
* anything else. Accepts bracketed IPv6 (`[::1]`, as `URL.hostname` renders
|
|
66
|
+
* it) and any letter case. This is the membership question; callers that
|
|
67
|
+
* need a refusal on a miss use {@link normalizeLocalHost}.
|
|
68
|
+
*/
|
|
69
|
+
export function loopbackHost(raw) {
|
|
70
|
+
const unbracketed = raw.startsWith('[') && raw.endsWith(']') ? raw.slice(1, -1) : raw;
|
|
71
|
+
const candidate = unbracketed.trim().toLowerCase();
|
|
72
|
+
return LOOPBACK_HOSTS.find(host => host === candidate);
|
|
73
|
+
}
|
|
63
74
|
export function normalizeLocalHost(raw) {
|
|
64
75
|
if (raw === undefined)
|
|
65
76
|
return DEFAULT_LOCAL_HOST;
|
|
66
|
-
const
|
|
67
|
-
const candidate = unbracketed.trim().toLowerCase();
|
|
68
|
-
const match = LOOPBACK_HOSTS.find(host => host === candidate);
|
|
77
|
+
const match = loopbackHost(raw);
|
|
69
78
|
if (match === undefined) {
|
|
70
79
|
throw localValidationError('local-host', `must name your own machine — one of ${LOOPBACK_HOSTS.join(', ')}. ` +
|
|
71
80
|
'A tunnel only reaches the machine running this CLI; to test a reachable ' +
|
|
@@ -89,13 +98,34 @@ export function normalizeStoredLocalHost(raw) {
|
|
|
89
98
|
throw err;
|
|
90
99
|
}
|
|
91
100
|
}
|
|
101
|
+
/** Parse a loopback origin that the stored-target API and tunnel can reach. */
|
|
102
|
+
export function parseLoopbackTargetUrl(raw, field = 'target-url') {
|
|
103
|
+
let parsed;
|
|
104
|
+
try {
|
|
105
|
+
parsed = new URL(raw);
|
|
106
|
+
}
|
|
107
|
+
catch {
|
|
108
|
+
return undefined;
|
|
109
|
+
}
|
|
110
|
+
const host = loopbackHost(parsed.hostname);
|
|
111
|
+
if (host === undefined)
|
|
112
|
+
return undefined;
|
|
113
|
+
// Read the explicit port from the input: URL.port drops the default :80.
|
|
114
|
+
const match = /^http:\/\/(localhost|127\.0\.0\.1|\[::1\]):([0-9]+)\/?$/.exec(raw);
|
|
115
|
+
const port = match === null ? 0 : Number(match[2]);
|
|
116
|
+
if (match === null || !Number.isInteger(port) || port < 1 || port > 65535) {
|
|
117
|
+
throw localValidationError(field, 'loopback URLs must use http://localhost:<port>, http://127.0.0.1:<port>, or http://[::1]:<port>, with a port between 1 and 65535 and no path ' +
|
|
118
|
+
'(an optional trailing / is allowed), query, fragment, or credentials');
|
|
119
|
+
}
|
|
120
|
+
return { host, port };
|
|
121
|
+
}
|
|
92
122
|
/**
|
|
93
123
|
* Parse the `--local` / `--local-host` / `--url` trio a stored-target write
|
|
94
124
|
* takes. `--local` and `--url` are two spellings of one field, so both is a
|
|
95
125
|
* contradiction; `--local-host` only means something next to `--local`; the
|
|
96
126
|
* port is validated strictly because it becomes part of a URL runs are billed
|
|
97
|
-
* against. Returns the local target
|
|
98
|
-
*
|
|
127
|
+
* against. Returns the local target for either shorthand or loopback URL input,
|
|
128
|
+
* or `undefined` for a public URL (or no target).
|
|
99
129
|
*/
|
|
100
130
|
export function parseStoredLocalTarget(opts) {
|
|
101
131
|
if (opts.local !== undefined && opts.url !== undefined) {
|
|
@@ -104,8 +134,9 @@ export function parseStoredLocalTarget(opts) {
|
|
|
104
134
|
if (opts.localHost !== undefined && opts.local === undefined) {
|
|
105
135
|
throw flagPairError('--local-host requires --local');
|
|
106
136
|
}
|
|
107
|
-
if (opts.local === undefined)
|
|
108
|
-
return undefined;
|
|
137
|
+
if (opts.local === undefined) {
|
|
138
|
+
return opts.url === undefined ? undefined : parseLoopbackTargetUrl(opts.url, 'url');
|
|
139
|
+
}
|
|
109
140
|
if (!/^\d+$/.test(opts.local)) {
|
|
110
141
|
throw flagPairError('--local must be a port number between 1 and 65535');
|
|
111
142
|
}
|
|
@@ -226,7 +257,7 @@ const SKIP_HINT = 'Skip this check with --skip-preflight.';
|
|
|
226
257
|
/**
|
|
227
258
|
* Run {@link probeLocalPort} and either throw (refuse) or no-op (ok / skipped).
|
|
228
259
|
*
|
|
229
|
-
* Call this BEFORE minting a tunnel. That ordering is the feature:
|
|
260
|
+
* Call this BEFORE minting a tunnel. That ordering is the feature: telemetry
|
|
230
261
|
* measured 1,003 blocked-with-URL CLI runs, 55.5% of the third-party-tunnel
|
|
231
262
|
* ones blocked, every one of them charged, because the run row and its credit
|
|
232
263
|
* spend happen before the Lambda ever discovers the target is dead. A dev
|
|
@@ -243,9 +274,13 @@ export async function assertLocalPortListening(host, port, opts, _stderrFn, deps
|
|
|
243
274
|
throw ApiError.fromEnvelope({
|
|
244
275
|
error: {
|
|
245
276
|
code: 'VALIDATION_ERROR',
|
|
246
|
-
message:
|
|
247
|
-
|
|
248
|
-
`
|
|
277
|
+
message: opts.environmentName !== undefined
|
|
278
|
+
? `Nothing is listening on ${host}:${port} (environment "${opts.environmentName}"). Start your app or run with --skip-preflight.`
|
|
279
|
+
: `Nothing is listening on ${host}:${port}, so a tunnel run would fail after being billed.`,
|
|
280
|
+
nextAction: opts.environmentName !== undefined
|
|
281
|
+
? `Start your app on ${host}:${port} (environment "${opts.environmentName}") or run with --skip-preflight.`
|
|
282
|
+
: `Start your app on port ${port} first, or point --local at the port it is actually ` +
|
|
283
|
+
`serving. ${SKIP_HINT}`,
|
|
249
284
|
requestId: 'local',
|
|
250
285
|
details: {
|
|
251
286
|
field: 'local',
|
package/dist/lib/output.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { localValidationError } from './errors.js';
|
|
2
|
+
import { redactDeep } from './redact.js';
|
|
2
3
|
/**
|
|
3
4
|
* Help-text footer pointing at the global options surface so users
|
|
4
5
|
* looking at any subcommand `--help` don't miss `--dry-run`, `--output`,
|
|
@@ -50,6 +51,15 @@ export class Output {
|
|
|
50
51
|
this.rawStdoutWrite = streams.rawStdout ?? defaultRawStdout;
|
|
51
52
|
}
|
|
52
53
|
print(data, textRenderer) {
|
|
54
|
+
// Success data is the caller's OWN content — generated test code, plans,
|
|
55
|
+
// backend-test fixtures — and must round-trip byte-identical (`test code
|
|
56
|
+
// get --output json` -> edit -> `test code put`), even when it
|
|
57
|
+
// legitimately contains a literal `Authorization: Bearer …` header or a
|
|
58
|
+
// `password` fixture key. Never redacted here, in either mode. Secret
|
|
59
|
+
// redaction (see `redact.ts`) applies only at error and request-trace
|
|
60
|
+
// boundaries — `Output.error` below, the ApiError envelope in
|
|
61
|
+
// `index.ts`, and `--debug` tracing in `client-factory.ts` — never to a
|
|
62
|
+
// success payload.
|
|
53
63
|
if (this.mode === 'json' || !textRenderer) {
|
|
54
64
|
this.stdoutWrite(JSON.stringify(data, null, 2));
|
|
55
65
|
return;
|
|
@@ -84,7 +94,11 @@ export class Output {
|
|
|
84
94
|
message: input.message,
|
|
85
95
|
nextAction: input.nextAction ?? '',
|
|
86
96
|
requestId: input.requestId ?? 'local',
|
|
87
|
-
|
|
97
|
+
// Defence in depth: `details` from a server envelope is already
|
|
98
|
+
// redacted server-side and (for an ApiError) at construction — see
|
|
99
|
+
// `errors.ts` — but this render boundary redacts again so no path
|
|
100
|
+
// that builds an envelope by hand here can ever skip it.
|
|
101
|
+
details: redactDeep(input.details ?? {}),
|
|
88
102
|
},
|
|
89
103
|
};
|
|
90
104
|
this.stderrWrite(JSON.stringify(envelope, null, 2));
|
package/dist/lib/plan-poll.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Generation-ladder driver for `test plan generate
|
|
2
|
+
* Generation-ladder driver for `test plan generate`.
|
|
3
3
|
*
|
|
4
4
|
* This is a NEW loop, deliberately not a reuse of `poll.ts`: the run poller
|
|
5
5
|
* is hard-typed to runs (its `RunClient` contract, `isTerminalStatus` check,
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
* - **The shutdown handle is armed here** for the whole ladder (first POST
|
|
15
15
|
* included). Arm/disarm lives inside the run poller, not for free in the
|
|
16
16
|
* harness — without arming, Ctrl-C during a generate wait would hard-kill
|
|
17
|
-
* the process instead of running the honest-detach UX
|
|
17
|
+
* the process instead of running the honest-detach UX.
|
|
18
18
|
* - Long-poll preferred (`?waitSeconds = min(remaining, 25)`), with a
|
|
19
19
|
* plain-GET + fixed-sleep fallback when the server rejects `waitSeconds`
|
|
20
20
|
* with VALIDATION_ERROR (older deployment).
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
* a single `.any()` per session (it still calls it); only http.ts
|
|
28
28
|
* eliminated it outright (`composeAbortSignals`). This module composes
|
|
29
29
|
* explicitly, like http.ts — don't go hunting for a poll.ts replacement
|
|
30
|
-
* that isn't there
|
|
30
|
+
* that isn't there.
|
|
31
31
|
* A hung fetch can never overrun `--timeout` and an interrupt aborts the
|
|
32
32
|
* in-flight request instantly.
|
|
33
33
|
* - Every sleep is clamped to the remaining deadline and bails on interrupt.
|
|
@@ -102,7 +102,7 @@ export interface PlanLadderOptions {
|
|
|
102
102
|
/** Injectable sleep (tests use an instant fake). */
|
|
103
103
|
sleep?: (ms: number) => Promise<void>;
|
|
104
104
|
/**
|
|
105
|
-
* Graceful-detach coordinator
|
|
105
|
+
* Graceful-detach coordinator. The ladder arms it for its whole
|
|
106
106
|
* duration; a SIGINT/SIGTERM surfaces as `InterruptError` out of this
|
|
107
107
|
* function and the caller renders the honest detach.
|
|
108
108
|
*/
|
|
@@ -133,11 +133,11 @@ export interface PlanLadderResult {
|
|
|
133
133
|
/** How many trigger POSTs were accepted (stages this invocation started). */
|
|
134
134
|
acceptedPosts: number;
|
|
135
135
|
/**
|
|
136
|
-
*
|
|
137
|
-
*
|
|
138
|
-
*
|
|
139
|
-
*
|
|
140
|
-
*
|
|
136
|
+
* `skippedCategories` from the accepted trigger that carried it (the
|
|
137
|
+
* proposals rung), or `null` when no accepted trigger did. Read from the
|
|
138
|
+
* LAST such trigger, not `firstTrigger`: on a fresh backend project the
|
|
139
|
+
* first accepted POST starts strategy, and the field rides only on the
|
|
140
|
+
* proposals POST that follows.
|
|
141
141
|
*/
|
|
142
142
|
skippedCategories: number | null;
|
|
143
143
|
}
|
|
@@ -151,8 +151,8 @@ export declare const MAX_ACCEPTED_TRIGGER_POSTS: 3;
|
|
|
151
151
|
/**
|
|
152
152
|
* Companion cap on TOTAL trigger POSTs (attaches included), so an
|
|
153
153
|
* attach-dominated pathological sequence also fails fast instead of
|
|
154
|
-
* silently burning the whole `--timeout
|
|
155
|
-
*
|
|
154
|
+
* silently burning the whole `--timeout`: the accepted rungs + headroom for
|
|
155
|
+
* an attach per rung.
|
|
156
156
|
*/
|
|
157
157
|
export declare const MAX_TRIGGER_POSTS_TOTAL: number;
|
|
158
158
|
/**
|
package/dist/lib/plan-poll.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Generation-ladder driver for `test plan generate
|
|
2
|
+
* Generation-ladder driver for `test plan generate`.
|
|
3
3
|
*
|
|
4
4
|
* This is a NEW loop, deliberately not a reuse of `poll.ts`: the run poller
|
|
5
5
|
* is hard-typed to runs (its `RunClient` contract, `isTerminalStatus` check,
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
* - **The shutdown handle is armed here** for the whole ladder (first POST
|
|
15
15
|
* included). Arm/disarm lives inside the run poller, not for free in the
|
|
16
16
|
* harness — without arming, Ctrl-C during a generate wait would hard-kill
|
|
17
|
-
* the process instead of running the honest-detach UX
|
|
17
|
+
* the process instead of running the honest-detach UX.
|
|
18
18
|
* - Long-poll preferred (`?waitSeconds = min(remaining, 25)`), with a
|
|
19
19
|
* plain-GET + fixed-sleep fallback when the server rejects `waitSeconds`
|
|
20
20
|
* with VALIDATION_ERROR (older deployment).
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
* a single `.any()` per session (it still calls it); only http.ts
|
|
28
28
|
* eliminated it outright (`composeAbortSignals`). This module composes
|
|
29
29
|
* explicitly, like http.ts — don't go hunting for a poll.ts replacement
|
|
30
|
-
* that isn't there
|
|
30
|
+
* that isn't there.
|
|
31
31
|
* A hung fetch can never overrun `--timeout` and an interrupt aborts the
|
|
32
32
|
* in-flight request instantly.
|
|
33
33
|
* - Every sleep is clamped to the remaining deadline and bails on interrupt.
|
|
@@ -98,8 +98,8 @@ export const MAX_ACCEPTED_TRIGGER_POSTS = PLAN_GENERATION_STAGES.length;
|
|
|
98
98
|
/**
|
|
99
99
|
* Companion cap on TOTAL trigger POSTs (attaches included), so an
|
|
100
100
|
* attach-dominated pathological sequence also fails fast instead of
|
|
101
|
-
* silently burning the whole `--timeout
|
|
102
|
-
*
|
|
101
|
+
* silently burning the whole `--timeout`: the accepted rungs + headroom for
|
|
102
|
+
* an attach per rung.
|
|
103
103
|
*/
|
|
104
104
|
export const MAX_TRIGGER_POSTS_TOTAL = PLAN_GENERATION_STAGES.length * 2;
|
|
105
105
|
/**
|
|
@@ -206,10 +206,10 @@ async function ladderLoop(client, projectId, options) {
|
|
|
206
206
|
}
|
|
207
207
|
};
|
|
208
208
|
const doTrigger = async () => {
|
|
209
|
-
// Fresh idempotency namespace per POST attempt — ATTACHES INCLUDED
|
|
210
|
-
//
|
|
211
|
-
//
|
|
212
|
-
//
|
|
209
|
+
// Fresh idempotency namespace per POST attempt — ATTACHES INCLUDED: a
|
|
210
|
+
// 409's key is never committed server-side, but reusing it would
|
|
211
|
+
// silently depend on that; a fresh key never can. Transport-level
|
|
212
|
+
// retries inside one POST still share the header.
|
|
213
213
|
const key = state.triggerPosts === 0
|
|
214
214
|
? options.idempotencyKey
|
|
215
215
|
: `${options.idempotencyKey}:post${state.triggerPosts + 1}`;
|
|
@@ -312,8 +312,8 @@ async function ladderLoop(client, projectId, options) {
|
|
|
312
312
|
if (isActiveGenerationStatus(status)) {
|
|
313
313
|
state.observedActiveSinceTrigger = true;
|
|
314
314
|
// Seeing the proposals stage RUN arms billing guard #1 regardless of
|
|
315
|
-
// who started it
|
|
316
|
-
//
|
|
315
|
+
// who started it — the 409-attach path has no trigger response to
|
|
316
|
+
// arm it from.
|
|
317
317
|
if (status === 'proposing')
|
|
318
318
|
state.proposalsObserved = true;
|
|
319
319
|
state.consecutiveIdleGaps = 0;
|
|
@@ -341,7 +341,7 @@ async function ladderLoop(client, projectId, options) {
|
|
|
341
341
|
// waitSeconds hold for an ACTIVE generation status (`getPlans` guards
|
|
342
342
|
// its wait loop with `waitSeconds && isActiveGenerationStatus(...)`),
|
|
343
343
|
// so an idle read returns immediately and an unpaced loop here would
|
|
344
|
-
// hammer the facade
|
|
344
|
+
// hammer the facade.
|
|
345
345
|
//
|
|
346
346
|
// Billing guard #1: once the proposals rung is known to have started —
|
|
347
347
|
// our own trigger said so (`stagesRemaining: []`) OR we watched it run
|
|
@@ -370,10 +370,9 @@ async function ladderLoop(client, projectId, options) {
|
|
|
370
370
|
throw ApiError.fromEnvelope({
|
|
371
371
|
error: {
|
|
372
372
|
code: 'INTERNAL',
|
|
373
|
-
message: `Plan generation
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
nextAction: 'Retry later or check the project in the Portal. If this persists, report the requestId to support@testsprite.com.',
|
|
373
|
+
message: `Plan generation is not making progress after ${state.triggerPosts} ` +
|
|
374
|
+
`${state.triggerPosts === 1 ? 'try' : 'tries'}: nothing new is staged and no stage is running.`,
|
|
375
|
+
nextAction: 'Wait a few minutes, then run the same command again. If this keeps happening, check the project in the Portal or contact support@testsprite.com.',
|
|
377
376
|
requestId: 'local',
|
|
378
377
|
details: {
|
|
379
378
|
projectId,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Wire types for the
|
|
2
|
+
* Wire types for the plan-generation surface:
|
|
3
3
|
*
|
|
4
4
|
* `POST /api/cli/v1/projects/{id}/plans/generate` — start the next missing
|
|
5
5
|
* pipeline stage (202)
|
|
@@ -9,8 +9,8 @@
|
|
|
9
9
|
* `POST /api/cli/v1/projects/{id}/plans/accept` — staged proposals → real
|
|
10
10
|
* test cases
|
|
11
11
|
*
|
|
12
|
-
* These mirror the backend facade's `cli-plans.types.ts`
|
|
13
|
-
*
|
|
12
|
+
* These mirror the backend facade's `cli-plans.types.ts` shape-for-shape.
|
|
13
|
+
* The generation `status` is FACADE-SYNTHESIZED — no such enum exists
|
|
14
14
|
* on the V3 pipeline itself (design-doc v3.1 §7, DR-31) — so the CLI treats
|
|
15
15
|
* it as the complete truth and never tries to derive state from anything
|
|
16
16
|
* else.
|
|
@@ -108,12 +108,12 @@ export interface CliGeneratePlansResponse {
|
|
|
108
108
|
stagesRemaining: CliGenerationStage[];
|
|
109
109
|
enqueuedAt: string;
|
|
110
110
|
/**
|
|
111
|
-
*
|
|
112
|
-
*
|
|
113
|
-
*
|
|
114
|
-
*
|
|
115
|
-
*
|
|
116
|
-
*
|
|
111
|
+
* `stage: proposals` on a backend project only. Strategy categories the
|
|
112
|
+
* proposals stage was NOT asked for because they carry no endpoint to
|
|
113
|
+
* attach a test case to (cross-cutting themes such as authorization or
|
|
114
|
+
* pagination). Absent when nothing was skipped and on every other stage.
|
|
115
|
+
* The stage is charged flat, so this is the only signal that the plan
|
|
116
|
+
* covers fewer categories than the strategy lists.
|
|
117
117
|
*/
|
|
118
118
|
skippedCategories?: number;
|
|
119
119
|
}
|
package/dist/lib/plans.types.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Wire types for the
|
|
2
|
+
* Wire types for the plan-generation surface:
|
|
3
3
|
*
|
|
4
4
|
* `POST /api/cli/v1/projects/{id}/plans/generate` — start the next missing
|
|
5
5
|
* pipeline stage (202)
|
|
@@ -9,8 +9,8 @@
|
|
|
9
9
|
* `POST /api/cli/v1/projects/{id}/plans/accept` — staged proposals → real
|
|
10
10
|
* test cases
|
|
11
11
|
*
|
|
12
|
-
* These mirror the backend facade's `cli-plans.types.ts`
|
|
13
|
-
*
|
|
12
|
+
* These mirror the backend facade's `cli-plans.types.ts` shape-for-shape.
|
|
13
|
+
* The generation `status` is FACADE-SYNTHESIZED — no such enum exists
|
|
14
14
|
* on the V3 pipeline itself (design-doc v3.1 §7, DR-31) — so the CLI treats
|
|
15
15
|
* it as the complete truth and never tries to derive state from anything
|
|
16
16
|
* else.
|
package/dist/lib/poll.d.ts
CHANGED
|
@@ -61,7 +61,7 @@ export interface PollOptions {
|
|
|
61
61
|
* Lets the caller resolve a terminal `RunResponse` from an alternate
|
|
62
62
|
* source when the run-surface row itself will never finalize.
|
|
63
63
|
*
|
|
64
|
-
* The motivating case
|
|
64
|
+
* The motivating case: backend-test run rows are written
|
|
65
65
|
* `queued` then orphaned server-side (`finalizeRun` is FE-only), so the
|
|
66
66
|
* run-row poll would always hit `--timeout` → exit 7 even on a passing BE
|
|
67
67
|
* test. The handler supplies a fallback that reads the testId-scoped
|
|
@@ -78,7 +78,7 @@ export interface PollOptions {
|
|
|
78
78
|
*/
|
|
79
79
|
resolveAlternate?: (run: RunResponse, elapsedMs: number, signal: AbortSignal) => Promise<RunResponse | null>;
|
|
80
80
|
/**
|
|
81
|
-
* Graceful-detach coordinator
|
|
81
|
+
* Graceful-detach coordinator. While the poll runs, the
|
|
82
82
|
* scope is armed: a SIGINT/SIGTERM aborts `shutdown.signal` with an
|
|
83
83
|
* `InterruptError` instead of killing the process, and this loop surfaces
|
|
84
84
|
* it immediately — the in-flight long-poll fetch aborts (composed into the
|
package/dist/lib/poll.js
CHANGED
|
@@ -46,13 +46,19 @@ const BACKOFF_SCHEDULE_MS = [2000, 4000, 8000, 15000];
|
|
|
46
46
|
* and unrecoverable server errors.
|
|
47
47
|
*/
|
|
48
48
|
export async function pollRunUntilTerminal(client, runId, options) {
|
|
49
|
-
// Arm the graceful-detach scope for the duration of the poll
|
|
49
|
+
// Arm the graceful-detach scope for the duration of the poll:
|
|
50
50
|
// while armed, a termination signal aborts instead of hard-killing the
|
|
51
51
|
// process, and the wait-path catch blocks own the honest detach UX.
|
|
52
52
|
const disarm = options.shutdown?.arm();
|
|
53
53
|
try {
|
|
54
54
|
return await pollLoop(client, runId, options);
|
|
55
55
|
}
|
|
56
|
+
catch (err) {
|
|
57
|
+
if (err instanceof InterruptError && options.shutdown?.signal.aborted) {
|
|
58
|
+
err.runWaitContext = true;
|
|
59
|
+
}
|
|
60
|
+
throw err;
|
|
61
|
+
}
|
|
56
62
|
finally {
|
|
57
63
|
disarm?.();
|
|
58
64
|
}
|
|
@@ -225,11 +231,11 @@ async function pollIterations(client, runId, options, ctx) {
|
|
|
225
231
|
}
|
|
226
232
|
// Non-terminal run tick. Give the caller a chance to resolve a terminal
|
|
227
233
|
// verdict from an alternate source (e.g. the backend testId-scoped
|
|
228
|
-
// result when the run-surface row never finalizes
|
|
234
|
+
// result when the run-surface row never finalizes).
|
|
229
235
|
if (resolveAlternate) {
|
|
230
236
|
// Bound the alternate lookup by the REMAINING --timeout (not the much
|
|
231
237
|
// larger per-request HTTP timeout) so a stalled fallback read can't
|
|
232
|
-
// overrun the user's deadline
|
|
238
|
+
// overrun the user's deadline.
|
|
233
239
|
const altRemainingMs = deadlineMs - Date.now();
|
|
234
240
|
if (altRemainingMs <= 0) {
|
|
235
241
|
throw new TimeoutError(runId, timeoutSeconds);
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Recursive, key-based secret redaction for CLI output.
|
|
3
|
+
*
|
|
4
|
+
* Before this module, the only redaction anywhere in the codebase was
|
|
5
|
+
* `tunnel-session.ts`'s `redactTunnelSecret` — a literal `String.replaceAll`
|
|
6
|
+
* of an ALREADY-KNOWN secret value out of a single log line. That only works
|
|
7
|
+
* when the caller already holds the plaintext to search for; it does nothing
|
|
8
|
+
* for an arbitrary server error `details` blob or a `--debug` trace, where
|
|
9
|
+
* the secret has to be found by its KEY name (`password`, `apiKey`, …), not
|
|
10
|
+
* by a value the caller can search for. This module fills that gap.
|
|
11
|
+
*
|
|
12
|
+
* Deliberately NOT applied to `Output.print`'s success data: generated test
|
|
13
|
+
* code, plans and backend-test fixtures are the user's OWN content and must
|
|
14
|
+
* round-trip byte-identical (`test code get --output json` -> edit ->
|
|
15
|
+
* `test code put`), even when they legitimately contain a literal
|
|
16
|
+
* `Authorization: Bearer …` header or a `password` fixture key — that is
|
|
17
|
+
* not a secret the CLI is leaking, it is the value the user is asking to see
|
|
18
|
+
* back. Applied instead at `Output.error`'s `details`, the hand-built
|
|
19
|
+
* ApiError envelope in `index.ts`, and the `--debug` / dry-run request
|
|
20
|
+
* tracing in `client-factory.ts` — server/error prose and request traces,
|
|
21
|
+
* never the user's stored data — and never at request-construction time (the
|
|
22
|
+
* real secret still has to go out on the wire). `--dry-run` previews that
|
|
23
|
+
* commands print are built from non-secret shapes (booleans such as
|
|
24
|
+
* `hasCredentials`, field names), so they never carry a secret to redact.
|
|
25
|
+
*/
|
|
26
|
+
export declare const REDACTED = "[REDACTED]";
|
|
27
|
+
/**
|
|
28
|
+
* Deep-walk `value`, replacing:
|
|
29
|
+
* - the string value of any object key matching {@link isSecretKey}, at any
|
|
30
|
+
* depth, arrays included, with {@link REDACTED};
|
|
31
|
+
* - a `Bearer <token>` substring inside any other string, wherever it
|
|
32
|
+
* appears (key name irrelevant).
|
|
33
|
+
*
|
|
34
|
+
* Never mutates its input — returns a new tree. Plain data only (the values
|
|
35
|
+
* that ever reach here are parsed JSON or plain option objects); a `Date`,
|
|
36
|
+
* `Map`, etc. is returned unchanged rather than walked.
|
|
37
|
+
*/
|
|
38
|
+
export declare function redactDeep<T>(value: T): T;
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Recursive, key-based secret redaction for CLI output.
|
|
3
|
+
*
|
|
4
|
+
* Before this module, the only redaction anywhere in the codebase was
|
|
5
|
+
* `tunnel-session.ts`'s `redactTunnelSecret` — a literal `String.replaceAll`
|
|
6
|
+
* of an ALREADY-KNOWN secret value out of a single log line. That only works
|
|
7
|
+
* when the caller already holds the plaintext to search for; it does nothing
|
|
8
|
+
* for an arbitrary server error `details` blob or a `--debug` trace, where
|
|
9
|
+
* the secret has to be found by its KEY name (`password`, `apiKey`, …), not
|
|
10
|
+
* by a value the caller can search for. This module fills that gap.
|
|
11
|
+
*
|
|
12
|
+
* Deliberately NOT applied to `Output.print`'s success data: generated test
|
|
13
|
+
* code, plans and backend-test fixtures are the user's OWN content and must
|
|
14
|
+
* round-trip byte-identical (`test code get --output json` -> edit ->
|
|
15
|
+
* `test code put`), even when they legitimately contain a literal
|
|
16
|
+
* `Authorization: Bearer …` header or a `password` fixture key — that is
|
|
17
|
+
* not a secret the CLI is leaking, it is the value the user is asking to see
|
|
18
|
+
* back. Applied instead at `Output.error`'s `details`, the hand-built
|
|
19
|
+
* ApiError envelope in `index.ts`, and the `--debug` / dry-run request
|
|
20
|
+
* tracing in `client-factory.ts` — server/error prose and request traces,
|
|
21
|
+
* never the user's stored data — and never at request-construction time (the
|
|
22
|
+
* real secret still has to go out on the wire). `--dry-run` previews that
|
|
23
|
+
* commands print are built from non-secret shapes (booleans such as
|
|
24
|
+
* `hasCredentials`, field names), so they never carry a secret to redact.
|
|
25
|
+
*/
|
|
26
|
+
export const REDACTED = '[REDACTED]';
|
|
27
|
+
/**
|
|
28
|
+
* Key-name suffixes (case-insensitive, separators ignored) whose STRING
|
|
29
|
+
* value is replaced by {@link REDACTED}. A suffix match, not a substring or
|
|
30
|
+
* exact match: it has to catch the realistic compound names a server or a
|
|
31
|
+
* future field could use (`refreshToken`, `clientSecret`, `x-api-key`,
|
|
32
|
+
* `Set-Cookie`) while still excluding names that merely contain the word,
|
|
33
|
+
* such as `credentialsPath` (a filesystem path, ends in "path") or
|
|
34
|
+
* `tokenEndpoint` (a URL, ends in "endpoint").
|
|
35
|
+
*
|
|
36
|
+
* Only applied when the value is a `string`. Two real shapes in this
|
|
37
|
+
* codebase would otherwise break under a type-blind rule:
|
|
38
|
+
* - `ci init`'s JSON output has a top-level `secret: {name, attempted, set,
|
|
39
|
+
* reason}` object describing metadata ABOUT a GitHub secret, never the
|
|
40
|
+
* secret's value.
|
|
41
|
+
* - `CliProjectEnvironment.hasCredentials` is a boolean PRESENCE flag, not
|
|
42
|
+
* a credential.
|
|
43
|
+
* Both keys are left untouched by the string-only guard below, and their
|
|
44
|
+
* children are still walked recursively (so an object nested under a
|
|
45
|
+
* matching key can carry its own, separately-matched, leaf secret).
|
|
46
|
+
*/
|
|
47
|
+
const SECRET_KEY_SUFFIXES = [
|
|
48
|
+
'password',
|
|
49
|
+
'secret',
|
|
50
|
+
'apikey',
|
|
51
|
+
'authorization',
|
|
52
|
+
'cookie',
|
|
53
|
+
'credential',
|
|
54
|
+
'credentials',
|
|
55
|
+
];
|
|
56
|
+
/**
|
|
57
|
+
* Exact (post-normalization) key names treated as an auth token — NOT a
|
|
58
|
+
* suffix rule like the list above. This CLI's own pagination continuation
|
|
59
|
+
* handles are also literally named "...Token" (`nextToken`, `startingToken`)
|
|
60
|
+
* and are opaque cursors, not secrets; a suffix match on "token" would blank
|
|
61
|
+
* them (`test result --history`'s `nextToken`, `project list`'s
|
|
62
|
+
* `startingToken`/`nextToken`). Add a new compound auth-token name here, not
|
|
63
|
+
* to the suffix list above.
|
|
64
|
+
*/
|
|
65
|
+
const SECRET_TOKEN_KEYS = new Set([
|
|
66
|
+
'token',
|
|
67
|
+
'apitoken',
|
|
68
|
+
'authtoken',
|
|
69
|
+
'accesstoken',
|
|
70
|
+
'refreshtoken',
|
|
71
|
+
'bearertoken',
|
|
72
|
+
'idtoken',
|
|
73
|
+
'sessiontoken',
|
|
74
|
+
]);
|
|
75
|
+
/** Lowercase and strip every non-alphanumeric character for key matching. */
|
|
76
|
+
function normalizeKey(key) {
|
|
77
|
+
return key.replace(/[^a-z0-9]/gi, '').toLowerCase();
|
|
78
|
+
}
|
|
79
|
+
function isSecretKey(key) {
|
|
80
|
+
const normalized = normalizeKey(key);
|
|
81
|
+
if (SECRET_TOKEN_KEYS.has(normalized))
|
|
82
|
+
return true;
|
|
83
|
+
return SECRET_KEY_SUFFIXES.some(suffix => normalized.endsWith(suffix));
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* A conservative check for a secret-shaped string VALUE regardless of its
|
|
87
|
+
* key name — a bearer token embedded in server/error prose (e.g. inside a
|
|
88
|
+
* free-form `message`/`nextAction` string) has no key to match on.
|
|
89
|
+
* Deliberately narrow: only the `Bearer <token>` wire form, and only when
|
|
90
|
+
* the run of token characters contains an actual DIGIT, so an ordinary
|
|
91
|
+
* hyphenated or dotted phrase — "a Bearer authentication header", "Bearer
|
|
92
|
+
* token-based auth" — is left alone. A separator alone used to be enough
|
|
93
|
+
* (any of `._~+/=-`), which let the `{8,}` scan's greedy, position-blind
|
|
94
|
+
* match swallow a whole compound word merely because it contained a hyphen
|
|
95
|
+
* — a broader entropy/length heuristic would also flag long environment
|
|
96
|
+
* names, test ids, or UUIDs, which must never be redacted.
|
|
97
|
+
*/
|
|
98
|
+
const BEARER_TOKEN_RE = /\bBearer\s+(?=[A-Za-z0-9._~+/=-]*[0-9])[A-Za-z0-9._~+/=-]{8,}/gi;
|
|
99
|
+
/**
|
|
100
|
+
* Keys whose object value is user-authored data shown back on purpose:
|
|
101
|
+
* environment `variables` are plaintext by design (a variable named
|
|
102
|
+
* `DB_PASSWORD` is the user's own fixture value), so they are never masked.
|
|
103
|
+
*/
|
|
104
|
+
const VERBATIM_KEYS = new Set(['variables']);
|
|
105
|
+
/** Replace any `Bearer <token>` substring inside a free-form string. */
|
|
106
|
+
function redactSecretLookingSubstrings(value) {
|
|
107
|
+
return value.replace(BEARER_TOKEN_RE, `Bearer ${REDACTED}`);
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Deep-walk `value`, replacing:
|
|
111
|
+
* - the string value of any object key matching {@link isSecretKey}, at any
|
|
112
|
+
* depth, arrays included, with {@link REDACTED};
|
|
113
|
+
* - a `Bearer <token>` substring inside any other string, wherever it
|
|
114
|
+
* appears (key name irrelevant).
|
|
115
|
+
*
|
|
116
|
+
* Never mutates its input — returns a new tree. Plain data only (the values
|
|
117
|
+
* that ever reach here are parsed JSON or plain option objects); a `Date`,
|
|
118
|
+
* `Map`, etc. is returned unchanged rather than walked.
|
|
119
|
+
*/
|
|
120
|
+
export function redactDeep(value) {
|
|
121
|
+
if (Array.isArray(value)) {
|
|
122
|
+
return value.map(item => redactDeep(item));
|
|
123
|
+
}
|
|
124
|
+
if (typeof value === 'string') {
|
|
125
|
+
return redactSecretLookingSubstrings(value);
|
|
126
|
+
}
|
|
127
|
+
if (value !== null && typeof value === 'object' && value.constructor === Object) {
|
|
128
|
+
const result = {};
|
|
129
|
+
for (const [key, v] of Object.entries(value)) {
|
|
130
|
+
if (VERBATIM_KEYS.has(key) && v !== null && typeof v === 'object' && !Array.isArray(v)) {
|
|
131
|
+
result[key] = v;
|
|
132
|
+
continue;
|
|
133
|
+
}
|
|
134
|
+
result[key] = isSecretKey(key) && typeof v === 'string' ? REDACTED : redactDeep(v);
|
|
135
|
+
}
|
|
136
|
+
return result;
|
|
137
|
+
}
|
|
138
|
+
return value;
|
|
139
|
+
}
|
|
140
|
+
//# sourceMappingURL=redact.js.map
|
|
@@ -1,10 +1,24 @@
|
|
|
1
|
+
import type { InterruptError } from './errors.js';
|
|
2
|
+
import type { OutputMode } from './output.js';
|
|
3
|
+
/** The JSON-mode stderr envelope for a signal detach (errors.md §8.1). */
|
|
4
|
+
export interface InterruptEnvelope {
|
|
5
|
+
error: {
|
|
6
|
+
code: 'INTERRUPTED';
|
|
7
|
+
message: string;
|
|
8
|
+
nextAction: string;
|
|
9
|
+
requestId: 'local';
|
|
10
|
+
details: Record<string, unknown>;
|
|
11
|
+
};
|
|
12
|
+
}
|
|
1
13
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
14
|
+
* Build the `INTERRUPTED` envelope from whatever the interrupted command
|
|
15
|
+
* attached to the error. A tunnel run attaches `tunnelDetach` and
|
|
16
|
+
* `test plan generate` attaches `planDetach`; each carries its own
|
|
17
|
+
* `nextAction` so the envelope never contradicts the text line the catch
|
|
18
|
+
* block already printed. Otherwise a run wait gets the run-detach story
|
|
19
|
+
* (`test wait`) and any other request gets the generic check-state hint.
|
|
6
20
|
*/
|
|
7
|
-
|
|
21
|
+
export declare function buildInterruptEnvelope(err: InterruptError): InterruptEnvelope;
|
|
8
22
|
/**
|
|
9
23
|
* Rephrase Commander's "unknown option '--foo'" error when `--foo` is
|
|
10
24
|
* a known global flag that was placed after the subcommand.
|
|
@@ -39,4 +53,6 @@ export declare function renderCommanderError(pendingMsg: string | null, fallback
|
|
|
39
53
|
* shape change must never crash the CLI's error path.
|
|
40
54
|
*/
|
|
41
55
|
export declare function renderAmbiguousOrgCandidates(candidates: unknown): string[];
|
|
56
|
+
/** Text-mode recovery handles for the account's tunnel binding limit. */
|
|
57
|
+
export declare function renderTunnelBindingLimitIds(details: unknown): string[];
|
|
42
58
|
export declare function rephraseUnknownOption(raw: string): string | null;
|