@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/skill-nudge.js
CHANGED
|
@@ -78,7 +78,15 @@ export function isVerifySkillInstalled(dir, deps = {}) {
|
|
|
78
78
|
if (hasCompleteManagedSection(read(full)))
|
|
79
79
|
return true;
|
|
80
80
|
}
|
|
81
|
-
catch {
|
|
81
|
+
catch (error) {
|
|
82
|
+
// A diagnostic callback must not change this best-effort probe's
|
|
83
|
+
// behavior, even if the caller's stderr sink itself is unavailable.
|
|
84
|
+
try {
|
|
85
|
+
deps.onReadError?.(full, error);
|
|
86
|
+
}
|
|
87
|
+
catch {
|
|
88
|
+
// ignore diagnostic delivery failures
|
|
89
|
+
}
|
|
82
90
|
// unreadable AGENTS.md → treat this target as absent, keep checking
|
|
83
91
|
}
|
|
84
92
|
continue;
|
|
@@ -105,9 +113,11 @@ function hasCompleteManagedSection(content) {
|
|
|
105
113
|
* not `--dry-run`, the command is in {@link SKILL_NUDGE_COMMANDS}, the opt-out
|
|
106
114
|
* env is unset, the active profile has an api key (un-configured callers hit an
|
|
107
115
|
* auth error that already points at setup), and the skill is not already
|
|
108
|
-
* installed. Never throws and never blocks the command — any error is swallowed
|
|
116
|
+
* installed. Never throws and never blocks the command — any error is swallowed;
|
|
117
|
+
* `--debug` callers receive the swallowed reason on stderr.
|
|
109
118
|
*/
|
|
110
119
|
export function maybeEmitSkillNudge(ctx) {
|
|
120
|
+
const write = ctx.stderr ?? ((line) => process.stderr.write(`${line}\n`));
|
|
111
121
|
try {
|
|
112
122
|
if (ctx.output !== 'text')
|
|
113
123
|
return;
|
|
@@ -122,7 +132,13 @@ export function maybeEmitSkillNudge(ctx) {
|
|
|
122
132
|
const profile = lookup(ctx.profile, { path: credsPath });
|
|
123
133
|
if (!profile?.apiKey)
|
|
124
134
|
return;
|
|
125
|
-
const presence = {
|
|
135
|
+
const presence = {
|
|
136
|
+
existsSync: ctx.existsSync,
|
|
137
|
+
readFileSync: ctx.readFileSync,
|
|
138
|
+
onReadError: ctx.debug
|
|
139
|
+
? (path, error) => emitDebug(write, `skill nudge could not read ${path}; treating target as absent`, error)
|
|
140
|
+
: undefined,
|
|
141
|
+
};
|
|
126
142
|
// When the environment names the calling agent, only that agent's skill
|
|
127
143
|
// counts — an install for a different agent is one this caller cannot read.
|
|
128
144
|
//
|
|
@@ -142,7 +158,6 @@ export function maybeEmitSkillNudge(ctx) {
|
|
|
142
158
|
// No identified caller: the any-target answer is all this can support.
|
|
143
159
|
return;
|
|
144
160
|
}
|
|
145
|
-
const write = ctx.stderr ?? ((line) => process.stderr.write(`${line}\n`));
|
|
146
161
|
// Names the callers actually missing a skill, not every caller detected —
|
|
147
162
|
// with one of two satisfied, "not for cursor" is the actionable half and
|
|
148
163
|
// "not for claude or cursor" would be wrong about claude.
|
|
@@ -154,9 +169,21 @@ export function maybeEmitSkillNudge(ctx) {
|
|
|
154
169
|
'TestSprite. Run `testsprite setup` (or `testsprite agent install`) to set it up. ' +
|
|
155
170
|
`Silence: ${SKILL_NUDGE_OPT_OUT_ENV}=1`);
|
|
156
171
|
}
|
|
157
|
-
catch {
|
|
172
|
+
catch (error) {
|
|
158
173
|
// A nudge must never break, delay, or alter the exit status of a real
|
|
159
174
|
// command. Swallow everything (missing creds file, fs races, etc.).
|
|
175
|
+
if (ctx.debug)
|
|
176
|
+
emitDebug(write, 'skill nudge skipped', error);
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
/** Emit a diagnostic without letting the diagnostic path break the command. */
|
|
180
|
+
function emitDebug(write, context, error) {
|
|
181
|
+
try {
|
|
182
|
+
const reason = error instanceof Error ? error.message : String(error);
|
|
183
|
+
write(`[debug] ${context}: ${reason}`);
|
|
184
|
+
}
|
|
185
|
+
catch {
|
|
186
|
+
// A broken stderr sink must not turn a best-effort nudge into a failure.
|
|
160
187
|
}
|
|
161
188
|
}
|
|
162
189
|
/** Interpret common env-var spellings for an enabled opt-out flag. */
|
|
@@ -42,11 +42,14 @@
|
|
|
42
42
|
* so following it would hand an attacker-controlled Location header a
|
|
43
43
|
* live SSRF primitive running on the caller's machine or CI runner.
|
|
44
44
|
*/
|
|
45
|
+
import { type ShutdownHandle } from './interrupt.js';
|
|
45
46
|
export interface TargetUrlPreflightDeps {
|
|
46
47
|
/** DNS resolution hook. Defaults to `dns.promises.lookup`. Injectable for tests. */
|
|
47
48
|
dnsLookup?: (hostname: string) => Promise<unknown>;
|
|
48
49
|
/** HTTP probe hook. Defaults to the global `fetch`. Injectable for tests. */
|
|
49
50
|
fetchImpl?: typeof fetch;
|
|
51
|
+
shutdownSignal?: AbortSignal;
|
|
52
|
+
shutdown?: Pick<ShutdownHandle, 'runCriticalOperation'>;
|
|
50
53
|
/**
|
|
51
54
|
* Whether a proxy dispatcher is actually installed for this process.
|
|
52
55
|
* Defaults to `isProxyAgentActive()` (proxy.ts), which inspects the
|
|
@@ -71,10 +74,9 @@ export type TargetUrlPreflightOutcome = {
|
|
|
71
74
|
};
|
|
72
75
|
/**
|
|
73
76
|
* Probe `rawUrl` for the narrow refusal set described in the module
|
|
74
|
-
* docstring.
|
|
75
|
-
*
|
|
76
|
-
*
|
|
77
|
-
* shape via `assertNotLocal` before this runs).
|
|
77
|
+
* docstring. Network failures classify to `warn` or `refuse`, while a process
|
|
78
|
+
* interruption propagates. A malformed URL degrades to `warn` rather than
|
|
79
|
+
* crashing (callers validate the URL shape via `assertNotLocal` before this runs).
|
|
78
80
|
*/
|
|
79
81
|
export declare function probeTargetUrl(rawUrl: string, deps?: TargetUrlPreflightDeps): Promise<TargetUrlPreflightOutcome>;
|
|
80
82
|
/**
|
|
@@ -44,7 +44,8 @@
|
|
|
44
44
|
*/
|
|
45
45
|
import * as dns from 'node:dns';
|
|
46
46
|
import { isIP } from 'node:net';
|
|
47
|
-
import { ApiError } from './errors.js';
|
|
47
|
+
import { ApiError, InterruptError } from './errors.js';
|
|
48
|
+
import { globalShutdown } from './interrupt.js';
|
|
48
49
|
import { isProxyAgentActive } from './proxy.js';
|
|
49
50
|
import { disallowedIpReason } from './target-url.js';
|
|
50
51
|
/** ~8s, matching the MCP plugin's `checkPortListening` TCP-probe budget. */
|
|
@@ -93,10 +94,9 @@ function bareHost(hostname) {
|
|
|
93
94
|
}
|
|
94
95
|
/**
|
|
95
96
|
* Probe `rawUrl` for the narrow refusal set described in the module
|
|
96
|
-
* docstring.
|
|
97
|
-
*
|
|
98
|
-
*
|
|
99
|
-
* shape via `assertNotLocal` before this runs).
|
|
97
|
+
* docstring. Network failures classify to `warn` or `refuse`, while a process
|
|
98
|
+
* interruption propagates. A malformed URL degrades to `warn` rather than
|
|
99
|
+
* crashing (callers validate the URL shape via `assertNotLocal` before this runs).
|
|
100
100
|
*/
|
|
101
101
|
export async function probeTargetUrl(rawUrl, deps = {}) {
|
|
102
102
|
const proxied = deps.proxyActive ?? isProxyAgentActive();
|
|
@@ -162,64 +162,77 @@ export async function probeTargetUrl(rawUrl, deps = {}) {
|
|
|
162
162
|
// configured — so this step (unlike the DNS step above) is proxy-aware
|
|
163
163
|
// by construction, not just proxy-tolerant.
|
|
164
164
|
const fetchImpl = deps.fetchImpl ?? fetch;
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
//
|
|
179
|
-
|
|
180
|
-
|
|
165
|
+
const shutdownSignal = deps.shutdownSignal ?? globalShutdown.signal;
|
|
166
|
+
const shutdown = deps.shutdown ?? globalShutdown;
|
|
167
|
+
return shutdown.runCriticalOperation(async () => {
|
|
168
|
+
try {
|
|
169
|
+
const resp = await fetchImpl(rawUrl, {
|
|
170
|
+
method: 'GET',
|
|
171
|
+
// Never follow — see the module docstring. A 3xx is reachability
|
|
172
|
+
// proof on its own (handled immediately below); the redirect target
|
|
173
|
+
// is unvalidated and must not be dereferenced.
|
|
174
|
+
redirect: 'manual',
|
|
175
|
+
signal: AbortSignal.any([AbortSignal.timeout(PREFLIGHT_TIMEOUT_MS), shutdownSignal]),
|
|
176
|
+
});
|
|
177
|
+
// Never read the body — only the status matters here. Cancel it so the
|
|
178
|
+
// connection is released promptly instead of buffering a full page.
|
|
179
|
+
await resp.body?.cancel().catch(() => undefined);
|
|
180
|
+
if (shutdownSignal.aborted)
|
|
181
|
+
throw shutdownSignal.reason;
|
|
182
|
+
if (resp.status >= 300 && resp.status < 400) {
|
|
183
|
+
// A redirect is a live-server signal (e.g. a real app 302ing an
|
|
184
|
+
// unauthenticated GET to a login page) — reachable, not refused. The
|
|
185
|
+
// Location header is deliberately never inspected or dereferenced.
|
|
186
|
+
return { verdict: 'ok' };
|
|
187
|
+
}
|
|
188
|
+
if (GATEWAY_ERROR_STATUSES.has(resp.status)) {
|
|
189
|
+
if (proxied) {
|
|
190
|
+
return {
|
|
191
|
+
verdict: 'warn',
|
|
192
|
+
reason: `--target-url responded HTTP ${resp.status} — not conclusive behind a configured proxy`,
|
|
193
|
+
};
|
|
194
|
+
}
|
|
195
|
+
return {
|
|
196
|
+
verdict: 'refuse',
|
|
197
|
+
reason: `--target-url responded HTTP ${resp.status} (gateway error — the target is unreachable)`,
|
|
198
|
+
};
|
|
199
|
+
}
|
|
200
|
+
if (resp.status >= 400) {
|
|
201
|
+
return { verdict: 'warn', reason: `--target-url responded HTTP ${resp.status}` };
|
|
202
|
+
}
|
|
181
203
|
return { verdict: 'ok' };
|
|
182
204
|
}
|
|
183
|
-
|
|
184
|
-
if (
|
|
205
|
+
catch (err) {
|
|
206
|
+
if (shutdownSignal.aborted)
|
|
207
|
+
throw shutdownSignal.reason;
|
|
208
|
+
if (err instanceof InterruptError)
|
|
209
|
+
throw err;
|
|
210
|
+
if (errorHasCode(err, ['ECONNREFUSED'])) {
|
|
211
|
+
if (proxied) {
|
|
212
|
+
return {
|
|
213
|
+
verdict: 'warn',
|
|
214
|
+
reason: 'connection to --target-url was refused — not conclusive behind a configured proxy',
|
|
215
|
+
};
|
|
216
|
+
}
|
|
185
217
|
return {
|
|
186
|
-
verdict: '
|
|
187
|
-
reason:
|
|
218
|
+
verdict: 'refuse',
|
|
219
|
+
reason: 'connection to --target-url was refused (ECONNREFUSED)',
|
|
188
220
|
};
|
|
189
221
|
}
|
|
190
|
-
|
|
191
|
-
verdict: 'refuse',
|
|
192
|
-
reason: `--target-url responded HTTP ${resp.status} (gateway error — the target is unreachable)`,
|
|
193
|
-
};
|
|
194
|
-
}
|
|
195
|
-
if (resp.status >= 400) {
|
|
196
|
-
return { verdict: 'warn', reason: `--target-url responded HTTP ${resp.status}` };
|
|
197
|
-
}
|
|
198
|
-
return { verdict: 'ok' };
|
|
199
|
-
}
|
|
200
|
-
catch (err) {
|
|
201
|
-
if (errorHasCode(err, ['ECONNREFUSED'])) {
|
|
202
|
-
if (proxied) {
|
|
222
|
+
if (isTimeoutError(err)) {
|
|
203
223
|
return {
|
|
204
224
|
verdict: 'warn',
|
|
205
|
-
reason:
|
|
225
|
+
reason: `--target-url did not respond within ${PREFLIGHT_TIMEOUT_MS / 1000}s`,
|
|
206
226
|
};
|
|
207
227
|
}
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
if (isTimeoutError(err)) {
|
|
228
|
+
// TLS errors and anything else unclassified: warn only — the refusal
|
|
229
|
+
// set stays narrow to exactly what that analysis measured.
|
|
211
230
|
return {
|
|
212
231
|
verdict: 'warn',
|
|
213
|
-
reason:
|
|
232
|
+
reason: `could not reach --target-url (${err instanceof Error ? err.message : String(err)})`,
|
|
214
233
|
};
|
|
215
234
|
}
|
|
216
|
-
|
|
217
|
-
// set stays narrow to exactly what that analysis measured.
|
|
218
|
-
return {
|
|
219
|
-
verdict: 'warn',
|
|
220
|
-
reason: `could not reach --target-url (${err instanceof Error ? err.message : String(err)})`,
|
|
221
|
-
};
|
|
222
|
-
}
|
|
235
|
+
});
|
|
223
236
|
}
|
|
224
237
|
/** Shared wording so `--help` and every refuse/warn message agree on the escape hatch. */
|
|
225
238
|
const SKIP_HINT = 'Skip this check entirely with --skip-preflight.';
|
|
@@ -240,7 +253,7 @@ export async function assertTargetUrlReachable(targetUrl, opts, deps, stderrFn)
|
|
|
240
253
|
throw ApiError.fromEnvelope({
|
|
241
254
|
error: {
|
|
242
255
|
code: 'VALIDATION_ERROR',
|
|
243
|
-
message: `--target-url is not reachable: ${outcome.reason}.`,
|
|
256
|
+
message: `--target-url is not reachable: ${outcome.reason}. Retry with --skip-preflight if the preview is still warming up.`,
|
|
244
257
|
nextAction: 'This CLI probes reachability from where the CLI runs, not from the Lambda that ' +
|
|
245
258
|
'executes the test — a false positive is possible (e.g. an IP allowlist that permits ' +
|
|
246
259
|
`the Lambda but not this machine). If you're confident the target is reachable from the ` +
|
package/dist/lib/target-url.js
CHANGED
|
@@ -33,7 +33,7 @@ import { ApiError } from './errors.js';
|
|
|
33
33
|
// on `127.0.0.1`/`::1`, so `--local`'s default dial reaches it) — NOT for
|
|
34
34
|
// the rest of `127.0.0.0/8`, which `--local` cannot dial by name at all. See
|
|
35
35
|
// `'loopback-other'` below for that distinction.
|
|
36
|
-
const LOCAL_DEV_RUNTIME_HINT = "This looks like a local-dev target.
|
|
36
|
+
const LOCAL_DEV_RUNTIME_HINT = "This looks like a local-dev target. Save `--url http://localhost:<port>` on an environment, then run `testsprite test run <test-id> --env <name>` — it tunnels this machine's loopback address to the test runner (frontend tests only; requires an API key with the `run:tunnel` scope).";
|
|
37
37
|
// Creation-time callers that take a per-run target (`test create
|
|
38
38
|
// --target-url`, which only applies with `--run`). A project or environment
|
|
39
39
|
// that names an app on this machine is created with `--local <port>`, so this
|
|
@@ -42,15 +42,15 @@ const LOCAL_DEV_RUNTIME_HINT = "This looks like a local-dev target. Run it with
|
|
|
42
42
|
// loopback and are refused everywhere.
|
|
43
43
|
const LOCAL_DEV_BOOTSTRAP_HINT = 'TestSprite executes tests from the cloud, so the runner needs an address it can reach: ' +
|
|
44
44
|
'a deployed or staging URL. For an app that only runs on this machine, create the project ' +
|
|
45
|
-
'or environment with `--
|
|
46
|
-
'`testsprite test run <test-id> --
|
|
45
|
+
'or environment with `--url http://localhost:<port>`, then run with ' +
|
|
46
|
+
'`testsprite test run <test-id> --env <name>`.';
|
|
47
47
|
/**
|
|
48
48
|
* `0.0.0.0` / `::` bind every interface, so an app listening there IS reachable
|
|
49
49
|
* on loopback — but the address itself is not loopback and the server refuses
|
|
50
50
|
* it as a stored URL. Naming the remedy is the whole point of the message.
|
|
51
51
|
*/
|
|
52
52
|
const UNSPECIFIED_ADDRESS_REASON = 'the unspecified address (0.0.0.0 / ::) is not allowed — use 127.0.0.1 or ::1 instead';
|
|
53
|
-
const LOCAL_PROJECT_CREATE_HINT = 'Use --
|
|
53
|
+
const LOCAL_PROJECT_CREATE_HINT = 'Use --url http://localhost:<port> for an app on this machine. ' +
|
|
54
54
|
'Local projects are frontend-only and require the V3 project platform.';
|
|
55
55
|
const DEFAULT_TARGET_URL_CALLER = {
|
|
56
56
|
field: 'target-url',
|
|
@@ -160,12 +160,12 @@ export function disallowedIpReason(host) {
|
|
|
160
160
|
}
|
|
161
161
|
function disallowedIpv4Reason(address) {
|
|
162
162
|
// Unspecified — binds every interface, including loopback. Named precisely
|
|
163
|
-
// rather than lumped in as "localhost"
|
|
164
|
-
//
|
|
165
|
-
//
|
|
166
|
-
//
|
|
167
|
-
//
|
|
168
|
-
//
|
|
163
|
+
// rather than lumped in as "localhost": since a loopback URL is now a
|
|
164
|
+
// legitimate STORED target, calling `0.0.0.0` a localhost target produced a
|
|
165
|
+
// self-contradicting refusal — "localhost targets are not allowed" above a
|
|
166
|
+
// hint saying to use `localhost`. It is also simply not loopback: the
|
|
167
|
+
// server refuses it as a stored URL, so the accurate remedy is the loopback
|
|
168
|
+
// address the app is also reachable on.
|
|
169
169
|
if (address === '0.0.0.0') {
|
|
170
170
|
return { reason: UNSPECIFIED_ADDRESS_REASON, hintKind: 'loopback' };
|
|
171
171
|
}
|
|
@@ -228,7 +228,7 @@ function disallowedIpv4Reason(address) {
|
|
|
228
228
|
*
|
|
229
229
|
* This is the SAME primitive `src/vendor/tunnel-client/client.ts`'s
|
|
230
230
|
* `blockedTargetReason` already uses for the identical problem (see its
|
|
231
|
-
* VENDOR.md
|
|
231
|
+
* VENDOR.md upstreamed entries #7/#10) — the two host classifiers in this repo now
|
|
232
232
|
* share one mechanism instead of two independently maintained spelling
|
|
233
233
|
* lists, so a future NAT64-shaped bypass can't reopen only one of them.
|
|
234
234
|
*
|
package/dist/lib/telemetry.d.ts
CHANGED
|
@@ -42,12 +42,8 @@ export interface TelemetryOutcomeInput extends Partial<WaitTimeoutTelemetry> {
|
|
|
42
42
|
output?: string;
|
|
43
43
|
dryRun?: boolean;
|
|
44
44
|
/**
|
|
45
|
-
* True when
|
|
46
|
-
*
|
|
47
|
-
* host. Reported regardless of outcome, including a zero-network refusal
|
|
48
|
-
* (dead port, `--local` combined with an incompatible flag): those are
|
|
49
|
-
* exactly the attempts nothing server-side ever sees, which is why this
|
|
50
|
-
* field is not redundant with a backend-side mint/attach analytics event.
|
|
45
|
+
* True when --local was present, including refusals and borrowed tunnels,
|
|
46
|
+
* or when this invocation automatically opened a saved-environment tunnel.
|
|
51
47
|
*/
|
|
52
48
|
local?: boolean;
|
|
53
49
|
}
|
|
@@ -104,13 +100,14 @@ export declare function buildCiContext(env: NodeJS.ProcessEnv): {
|
|
|
104
100
|
* `conflict-reason.ts`'s rendering type: `tunnel-required` is a server reason
|
|
105
101
|
* this CLI has no label for yet, and `not_found` is rendered but not counted.
|
|
106
102
|
*/
|
|
107
|
-
export type TelemetryConflictReason = 'in_flight' | 'insufficient_credits' | 'billing_hold' | 'mcp_view_only' | 'local_address' | 'tunnel-required' | 'error';
|
|
103
|
+
export type TelemetryConflictReason = 'in_flight' | 'insufficient_credits' | 'paused' | 'billing_hold' | 'mcp_view_only' | 'local_address' | 'tunnel-required' | 'error';
|
|
108
104
|
/**
|
|
109
105
|
* Low-cardinality facts a command records about its own outcome before it
|
|
110
106
|
* returns, merged into the one event `index.ts` fires. Counts are non-negative
|
|
111
107
|
* integers; enums are closed. Nothing here can carry an id, a URL, or a message.
|
|
112
108
|
*/
|
|
113
109
|
export interface TelemetryExtras {
|
|
110
|
+
local?: boolean;
|
|
114
111
|
/** Batch dispatch accounting (`test run --all`, `testlist run`). */
|
|
115
112
|
accepted?: number;
|
|
116
113
|
conflicts?: number;
|
|
@@ -121,6 +118,9 @@ export interface TelemetryExtras {
|
|
|
121
118
|
failed?: number;
|
|
122
119
|
blocked?: number;
|
|
123
120
|
timedOut?: number;
|
|
121
|
+
/** Local tunnel pool limit (1–10) and observed peak, without ids or target details. */
|
|
122
|
+
localConcurrencyLimit?: number;
|
|
123
|
+
localPeakInFlight?: number;
|
|
124
124
|
/** The most frequent conflict reason of the batch. */
|
|
125
125
|
conflictReason?: TelemetryConflictReason;
|
|
126
126
|
/** `ci init` facts. */
|
|
@@ -145,6 +145,8 @@ export declare function sanitizeTelemetryExtras(partial: TelemetryExtrasInput):
|
|
|
145
145
|
* never widen the wire contract from here.
|
|
146
146
|
*/
|
|
147
147
|
export declare function recordTelemetryExtras(partial: TelemetryExtrasInput): void;
|
|
148
|
+
/** Extend explicit --local telemetry to commands that automatically open a tunnel. */
|
|
149
|
+
export declare function recordTelemetryTunnelOpened(opened: boolean): void;
|
|
148
150
|
/** Return everything recorded so far and clear the sink (one event per process). */
|
|
149
151
|
export declare function takeTelemetryExtras(): TelemetryExtras;
|
|
150
152
|
/**
|
|
@@ -190,7 +192,7 @@ export interface TelemetryEvent extends Partial<WaitTimeoutTelemetry>, Telemetry
|
|
|
190
192
|
nodeVersion?: string;
|
|
191
193
|
output?: string;
|
|
192
194
|
ci?: boolean;
|
|
193
|
-
/** Present (always `true`)
|
|
195
|
+
/** Present (always `true`) for --local attempts or automatically opened tunnels. */
|
|
194
196
|
local?: boolean;
|
|
195
197
|
/** The validated `TESTSPRITE_CLIENT` tag (e.g. `github-action/v1`); absent when unset/invalid. */
|
|
196
198
|
client?: string;
|
package/dist/lib/telemetry.js
CHANGED
|
@@ -23,17 +23,11 @@
|
|
|
23
23
|
* repository names — `errorCode` is a stable machine code, never the human
|
|
24
24
|
* message, and the CI repository is reduced to a salted, truncated hash so
|
|
25
25
|
* runs from one repo can be grouped without the slug ever leaving the runner.
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
* than `exitCode` or `durationMs` already do, and is included so a `--wait`
|
|
32
|
-
* timeout is distinguishable from a genuinely slow backend (see `errorOrigin`
|
|
33
|
-
* below). Anyone auditing this allowlist can verify that reasoning against
|
|
34
|
-
* the two call sites that set it (`RequestTimeoutError.timeoutMs`, and the
|
|
35
|
-
* `ApiError` `details.timeoutSeconds` a `--wait` deadline conversion stamps)
|
|
36
|
-
* without having to trust a one-off exception.
|
|
26
|
+
* Flag-derived values are limited to bounded numeric controls:
|
|
27
|
+
* `timeoutSeconds` is the operator's timeout (not a URL or free text) and
|
|
28
|
+
* distinguishes a wait deadline from a slow backend; `localConcurrencyLimit`
|
|
29
|
+
* is an integer 1–10 and lets local batch outcomes be grouped by load.
|
|
30
|
+
* `localPeakInFlight` is the observed count, also bounded by that limit.
|
|
37
31
|
*
|
|
38
32
|
* `errorOrigin` ('client' | 'server') and `timeoutSeconds` are sent by this
|
|
39
33
|
* revision of the CLI. The telemetry endpoint validates against an allowlist
|
|
@@ -126,12 +120,15 @@ const COUNT_KEYS = [
|
|
|
126
120
|
'failed',
|
|
127
121
|
'blocked',
|
|
128
122
|
'timedOut',
|
|
123
|
+
'localConcurrencyLimit',
|
|
124
|
+
'localPeakInFlight',
|
|
129
125
|
];
|
|
130
|
-
const BOOLEAN_KEYS = ['force', 'workflowExisted'];
|
|
126
|
+
const BOOLEAN_KEYS = ['force', 'workflowExisted', 'local'];
|
|
131
127
|
const ENUM_KEYS = {
|
|
132
128
|
conflictReason: new Set([
|
|
133
129
|
'in_flight',
|
|
134
130
|
'insufficient_credits',
|
|
131
|
+
'paused',
|
|
135
132
|
'billing_hold',
|
|
136
133
|
'mcp_view_only',
|
|
137
134
|
'local_address',
|
|
@@ -179,6 +176,11 @@ let pendingExtras = {};
|
|
|
179
176
|
export function recordTelemetryExtras(partial) {
|
|
180
177
|
pendingExtras = { ...pendingExtras, ...sanitizeTelemetryExtras(partial) };
|
|
181
178
|
}
|
|
179
|
+
/** Extend explicit --local telemetry to commands that automatically open a tunnel. */
|
|
180
|
+
export function recordTelemetryTunnelOpened(opened) {
|
|
181
|
+
if (opened)
|
|
182
|
+
recordTelemetryExtras({ local: true });
|
|
183
|
+
}
|
|
182
184
|
/** Return everything recorded so far and clear the sink (one event per process). */
|
|
183
185
|
export function takeTelemetryExtras() {
|
|
184
186
|
const taken = pendingExtras;
|
|
@@ -330,6 +332,8 @@ function isTruthyEnv(v) {
|
|
|
330
332
|
*/
|
|
331
333
|
export function buildTelemetryEvent(input, env, isTTY, extras = {}) {
|
|
332
334
|
const client = resolveClientTag(env);
|
|
335
|
+
const { local: runtimeLocal, ...sanitizedExtras } = sanitizeTelemetryExtras(extras);
|
|
336
|
+
const local = input.local === true || runtimeLocal === true;
|
|
333
337
|
return {
|
|
334
338
|
command: input.command,
|
|
335
339
|
outcome: input.outcome,
|
|
@@ -345,11 +349,11 @@ export function buildTelemetryEvent(input, env, isTTY, extras = {}) {
|
|
|
345
349
|
ci: isTruthyEnv(env.CI) || !isTTY,
|
|
346
350
|
...(client !== undefined ? { client } : {}),
|
|
347
351
|
...buildCiContext(env),
|
|
348
|
-
...(
|
|
352
|
+
...(local ? { local: true } : {}),
|
|
349
353
|
...(input.outcome === 'error' && input.reason === 'wait_timeout'
|
|
350
354
|
? {
|
|
351
355
|
reason: 'wait_timeout',
|
|
352
|
-
...(
|
|
356
|
+
...(local &&
|
|
353
357
|
(input.cancelOutcome === 'cancelled' ||
|
|
354
358
|
input.cancelOutcome === 'already_terminal' ||
|
|
355
359
|
input.cancelOutcome === 'failed' ||
|
|
@@ -358,7 +362,7 @@ export function buildTelemetryEvent(input, env, isTTY, extras = {}) {
|
|
|
358
362
|
: {}),
|
|
359
363
|
}
|
|
360
364
|
: {}),
|
|
361
|
-
...
|
|
365
|
+
...sanitizedExtras,
|
|
362
366
|
};
|
|
363
367
|
}
|
|
364
368
|
/**
|
|
@@ -370,8 +374,11 @@ export function buildTelemetryEvent(input, env, isTTY, extras = {}) {
|
|
|
370
374
|
* opted-out call never reads the credentials file.
|
|
371
375
|
*/
|
|
372
376
|
export function resolveTelemetryAuth(opts, deps = {}) {
|
|
377
|
+
// No `?? 'default'`: `loadConfig` resolves the documented
|
|
378
|
+
// flag > TESTSPRITE_PROFILE > default order from the same env, and a
|
|
379
|
+
// pre-collapsed string here would hide the env var from it.
|
|
373
380
|
const config = loadConfig({
|
|
374
|
-
profile: opts.profile
|
|
381
|
+
profile: opts.profile,
|
|
375
382
|
endpointUrl: opts.endpointUrl,
|
|
376
383
|
env: deps.env ?? process.env,
|
|
377
384
|
credentialsPath: deps.credentialsPath ?? defaultCredentialsPath(),
|
|
@@ -406,7 +413,7 @@ export async function recordOutcome(input, deps = {}) {
|
|
|
406
413
|
// `auth remove` could delete the profile); fall back to a fresh read.
|
|
407
414
|
const config = deps.resolvedAuth ??
|
|
408
415
|
loadConfig({
|
|
409
|
-
profile: input.profile
|
|
416
|
+
profile: input.profile,
|
|
410
417
|
endpointUrl: input.endpointUrl,
|
|
411
418
|
env,
|
|
412
419
|
credentialsPath: deps.credentialsPath ?? defaultCredentialsPath(),
|
|
@@ -67,6 +67,7 @@ export interface CliTestListRunAccepted {
|
|
|
67
67
|
* is a 404). `reason` is set only when nothing dispatched (empty list).
|
|
68
68
|
*/
|
|
69
69
|
export interface CliTestListRunResponse {
|
|
70
|
+
tunnelClientId?: string;
|
|
70
71
|
accepted: CliTestListRunAccepted[];
|
|
71
72
|
conflicts: RunConflict[];
|
|
72
73
|
deferred: Array<{
|
package/dist/lib/ticker.d.ts
CHANGED
|
@@ -25,6 +25,15 @@ export interface Ticker {
|
|
|
25
25
|
* doesn't run into the result block). No-op on non-TTY.
|
|
26
26
|
*/
|
|
27
27
|
finalize(line?: string): void;
|
|
28
|
+
/**
|
|
29
|
+
* Print a standalone line while the ticker is live: on a TTY the
|
|
30
|
+
* in-place progress line is cleared first so the note lands on its own
|
|
31
|
+
* row (a plain `stderr.write` would be appended to the tail of the
|
|
32
|
+
* progress line, whose writer never emits a newline). On a non-TTY the
|
|
33
|
+
* line is written as is. Use this for every stderr line a command prints
|
|
34
|
+
* between `update()` calls (hints, advisories, stage transitions).
|
|
35
|
+
*/
|
|
36
|
+
note(line: string): void;
|
|
28
37
|
/**
|
|
29
38
|
* True only when `update()` redraws the SAME terminal line (TTY, ANSI
|
|
30
39
|
* allowed). False on a non-TTY (updates are no-ops) and under NO_COLOR
|