@testsprite/testsprite-cli 0.6.0 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +52 -31
- package/dist/commands/agent.js +91 -45
- package/dist/commands/ci.d.ts +88 -0
- package/dist/commands/ci.js +429 -0
- package/dist/commands/doctor.d.ts +1 -1
- package/dist/commands/doctor.js +104 -8
- package/dist/commands/init.js +8 -0
- package/dist/commands/project.d.ts +78 -0
- package/dist/commands/project.js +429 -5
- package/dist/commands/schedule.d.ts +120 -0
- package/dist/commands/schedule.js +487 -0
- package/dist/commands/test.d.ts +176 -2
- package/dist/commands/test.js +2235 -609
- package/dist/commands/testlist.d.ts +88 -0
- package/dist/commands/testlist.js +753 -0
- package/dist/commands/tunnel.d.ts +72 -0
- package/dist/commands/tunnel.js +367 -0
- package/dist/index.js +113 -40
- package/dist/lib/agent-targets.d.ts +13 -4
- package/dist/lib/agent-targets.js +11 -2
- package/dist/lib/conflict-reason.d.ts +30 -0
- package/dist/lib/conflict-reason.js +45 -0
- package/dist/lib/credentials.js +42 -1
- package/dist/lib/cron.d.ts +40 -0
- package/dist/lib/cron.js +190 -0
- package/dist/lib/dry-run/samples.d.ts +9 -0
- package/dist/lib/dry-run/samples.js +293 -55
- package/dist/lib/errors.d.ts +9 -0
- package/dist/lib/errors.js +11 -0
- package/dist/lib/gh-output.d.ts +33 -1
- package/dist/lib/gh-output.js +97 -27
- package/dist/lib/http.d.ts +119 -0
- package/dist/lib/http.js +243 -2
- package/dist/lib/interrupt.d.ts +38 -13
- package/dist/lib/interrupt.js +130 -15
- package/dist/lib/junit-report.d.ts +20 -2
- package/dist/lib/junit-report.js +38 -5
- package/dist/lib/local-target.d.ts +95 -0
- package/dist/lib/local-target.js +184 -0
- package/dist/lib/plan-poll.d.ts +171 -0
- package/dist/lib/plan-poll.js +442 -0
- package/dist/lib/plans.types.d.ts +130 -0
- package/dist/lib/plans.types.js +31 -0
- package/dist/lib/poll-support.d.ts +26 -0
- package/dist/lib/poll-support.js +65 -0
- package/dist/lib/poll.d.ts +1 -0
- package/dist/lib/poll.js +2 -40
- package/dist/lib/proxy.d.ts +16 -0
- package/dist/lib/proxy.js +19 -1
- package/dist/lib/response-schemas.d.ts +20 -0
- package/dist/lib/response-schemas.js +55 -1
- package/dist/lib/run-progress.d.ts +41 -0
- package/dist/lib/run-progress.js +56 -0
- package/dist/lib/runs.types.d.ts +32 -3
- package/dist/lib/secret-file.d.ts +15 -0
- package/dist/lib/secret-file.js +82 -0
- package/dist/lib/target-url-preflight.d.ts +91 -0
- package/dist/lib/target-url-preflight.js +259 -0
- package/dist/lib/target-url.d.ts +63 -9
- package/dist/lib/target-url.js +283 -62
- package/dist/lib/telemetry.d.ts +11 -0
- package/dist/lib/telemetry.js +1 -0
- package/dist/lib/testlist.types.d.ts +77 -0
- package/dist/lib/testlist.types.js +9 -0
- package/dist/lib/ticker.d.ts +8 -0
- package/dist/lib/ticker.js +3 -0
- package/dist/lib/tunnel-session.d.ts +129 -0
- package/dist/lib/tunnel-session.js +232 -0
- package/dist/lib/tunnel.types.d.ts +54 -0
- package/dist/lib/tunnel.types.js +8 -0
- package/dist/lib/v3-advisory.d.ts +35 -22
- package/dist/lib/v3-advisory.js +44 -24
- package/dist/lib/wait-exit.d.ts +29 -0
- package/dist/lib/wait-exit.js +103 -0
- package/dist/vendor/tunnel-client/client.d.ts +83 -0
- package/dist/vendor/tunnel-client/client.js +871 -0
- package/dist/vendor/tunnel-client/config.d.ts +41 -0
- package/dist/vendor/tunnel-client/config.js +42 -0
- package/dist/vendor/tunnel-client/index.d.ts +9 -0
- package/dist/vendor/tunnel-client/index.js +9 -0
- package/dist/vendor/tunnel-client/lodash-lite.d.ts +14 -0
- package/dist/vendor/tunnel-client/lodash-lite.js +24 -0
- package/dist/vendor/tunnel-client/protocol.d.ts +60 -0
- package/dist/vendor/tunnel-client/protocol.js +143 -0
- package/dist/vendor/tunnel-client/types.d.ts +96 -0
- package/dist/vendor/tunnel-client/types.js +10 -0
- package/dist/vendor/tunnel-client/ws-compat.d.ts +206 -0
- package/dist/vendor/tunnel-client/ws-compat.js +316 -0
- package/dist/version-guard.d.ts +10 -7
- package/dist/version-guard.js +37 -9
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +2 -1
- package/skills/testsprite-onboard.skill.md +60 -4
- package/skills/testsprite-verify.codex.md +22 -16
- package/skills/testsprite-verify.skill.md +27 -18
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared low-level helpers for the two polling loops (`poll.ts` for run
|
|
3
|
+
* polling, `plan-poll.ts` for the plan-generation ladder). These three were
|
|
4
|
+
* byte-identical copies in both files (#341 review); extracted here so a fix
|
|
5
|
+
* to the interrupt/abort contract lands in one place. Signal COMPOSITION is
|
|
6
|
+
* deliberately NOT here — each loop composes its own session signal with a
|
|
7
|
+
* shape specific to its lifetime (`poll.ts` inline, `plan-poll.ts` via
|
|
8
|
+
* `composeSessionSignal`), and folding those together would couple two
|
|
9
|
+
* unrelated lifetimes.
|
|
10
|
+
*/
|
|
11
|
+
/** Resolve after `ms`. The default injectable sleep; tests substitute a fake. */
|
|
12
|
+
export function defaultSleep(ms, signal) {
|
|
13
|
+
if (signal?.aborted)
|
|
14
|
+
return Promise.reject(signal.reason);
|
|
15
|
+
return new Promise((resolve, reject) => {
|
|
16
|
+
const timer = setTimeout(() => {
|
|
17
|
+
signal?.removeEventListener('abort', onAbort);
|
|
18
|
+
resolve();
|
|
19
|
+
}, ms);
|
|
20
|
+
const onAbort = () => {
|
|
21
|
+
clearTimeout(timer);
|
|
22
|
+
signal?.removeEventListener('abort', onAbort);
|
|
23
|
+
reject(signal?.reason);
|
|
24
|
+
};
|
|
25
|
+
signal?.addEventListener('abort', onAbort, { once: true });
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Race a sleep against the shutdown signal: rejects with the signal's
|
|
30
|
+
* `InterruptError` reason the moment it fires, so no backoff/retry/pacing wait
|
|
31
|
+
* can delay the honest-detach UX. The default sleep receives the signal and
|
|
32
|
+
* clears its pending timer when interrupted; the outer race remains necessary
|
|
33
|
+
* for injected sleeps that do not implement cancellation themselves.
|
|
34
|
+
*/
|
|
35
|
+
export function sleepUnlessInterrupted(sleep, ms, signal) {
|
|
36
|
+
if (signal == null)
|
|
37
|
+
return sleep(ms);
|
|
38
|
+
if (signal.aborted)
|
|
39
|
+
return Promise.reject(signal.reason);
|
|
40
|
+
return new Promise((resolve, reject) => {
|
|
41
|
+
const onAbort = () => reject(signal.reason);
|
|
42
|
+
signal.addEventListener('abort', onAbort, { once: true });
|
|
43
|
+
sleep(ms, signal).then(() => {
|
|
44
|
+
signal.removeEventListener('abort', onAbort);
|
|
45
|
+
resolve();
|
|
46
|
+
}, err => {
|
|
47
|
+
signal.removeEventListener('abort', onAbort);
|
|
48
|
+
reject(err instanceof Error ? err : new Error(String(err)));
|
|
49
|
+
});
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Detects an AbortError thrown when an AbortSignal fires. Works for native
|
|
54
|
+
* fetch AbortErrors as well as `AbortController.abort()` from Node 18+ stdlib
|
|
55
|
+
* (both set `name === 'AbortError'`).
|
|
56
|
+
*/
|
|
57
|
+
export function isAbortError(err) {
|
|
58
|
+
if (err instanceof Error && err.name === 'AbortError')
|
|
59
|
+
return true;
|
|
60
|
+
if (typeof err === 'object' && err !== null && 'name' in err) {
|
|
61
|
+
return err.name === 'AbortError';
|
|
62
|
+
}
|
|
63
|
+
return false;
|
|
64
|
+
}
|
|
65
|
+
//# sourceMappingURL=poll-support.js.map
|
package/dist/lib/poll.d.ts
CHANGED
|
@@ -22,6 +22,7 @@
|
|
|
22
22
|
*/
|
|
23
23
|
import type { ShutdownHandle } from './interrupt.js';
|
|
24
24
|
import type { RunResponse } from './runs.types.js';
|
|
25
|
+
export { isTerminalStatus } from './runs.types.js';
|
|
25
26
|
/**
|
|
26
27
|
* Minimal interface that `pollRunUntilTerminal` requires from the HTTP client.
|
|
27
28
|
* Using a structural interface (rather than the concrete `HttpClient`) makes
|
package/dist/lib/poll.js
CHANGED
|
@@ -21,7 +21,9 @@
|
|
|
21
21
|
* Deadline exceeded → throw `TimeoutError`.
|
|
22
22
|
*/
|
|
23
23
|
import { ApiError, InterruptError } from './errors.js';
|
|
24
|
+
import { defaultSleep, isAbortError, sleepUnlessInterrupted } from './poll-support.js';
|
|
24
25
|
import { isTerminalStatus } from './runs.types.js';
|
|
26
|
+
export { isTerminalStatus } from './runs.types.js';
|
|
25
27
|
/** Thrown when the polling deadline is hit. */
|
|
26
28
|
export class TimeoutError extends Error {
|
|
27
29
|
runId;
|
|
@@ -279,44 +281,4 @@ function backoffScheduleDelay(index) {
|
|
|
279
281
|
const jitter = base * 0.2 * (Math.random() * 2 - 1); // ±20%
|
|
280
282
|
return Math.max(0, Math.round(base + jitter));
|
|
281
283
|
}
|
|
282
|
-
function defaultSleep(ms) {
|
|
283
|
-
return new Promise(resolve => setTimeout(resolve, ms));
|
|
284
|
-
}
|
|
285
|
-
/**
|
|
286
|
-
* Race a sleep against the shutdown signal: rejects with the signal's
|
|
287
|
-
* `InterruptError` reason the moment it fires, so no backoff/retry wait can
|
|
288
|
-
* delay the honest-detach UX. Wraps the injected `sleep` (tests keep their
|
|
289
|
-
* deterministic fakes); the underlying timer is left to fire harmlessly —
|
|
290
|
-
* the interrupt path exits the process long before it matters.
|
|
291
|
-
*/
|
|
292
|
-
function sleepUnlessInterrupted(sleep, ms, signal) {
|
|
293
|
-
if (signal == null)
|
|
294
|
-
return sleep(ms);
|
|
295
|
-
if (signal.aborted)
|
|
296
|
-
return Promise.reject(signal.reason);
|
|
297
|
-
return new Promise((resolve, reject) => {
|
|
298
|
-
const onAbort = () => reject(signal.reason);
|
|
299
|
-
signal.addEventListener('abort', onAbort, { once: true });
|
|
300
|
-
sleep(ms).then(() => {
|
|
301
|
-
signal.removeEventListener('abort', onAbort);
|
|
302
|
-
resolve();
|
|
303
|
-
}, err => {
|
|
304
|
-
signal.removeEventListener('abort', onAbort);
|
|
305
|
-
reject(err instanceof Error ? err : new Error(String(err)));
|
|
306
|
-
});
|
|
307
|
-
});
|
|
308
|
-
}
|
|
309
|
-
/**
|
|
310
|
-
* Detects an AbortError thrown when an AbortSignal fires.
|
|
311
|
-
* Works for native fetch AbortErrors as well as `AbortController.abort()`
|
|
312
|
-
* from Node 18+ stdlib (both set `name === 'AbortError'`).
|
|
313
|
-
*/
|
|
314
|
-
function isAbortError(err) {
|
|
315
|
-
if (err instanceof Error && err.name === 'AbortError')
|
|
316
|
-
return true;
|
|
317
|
-
if (typeof err === 'object' && err !== null && 'name' in err) {
|
|
318
|
-
return err.name === 'AbortError';
|
|
319
|
-
}
|
|
320
|
-
return false;
|
|
321
|
-
}
|
|
322
284
|
//# sourceMappingURL=poll.js.map
|
package/dist/lib/proxy.d.ts
CHANGED
|
@@ -27,3 +27,19 @@ export interface ProxyDeps {
|
|
|
27
27
|
* Returns whether an agent was installed (observable for tests/debugging).
|
|
28
28
|
*/
|
|
29
29
|
export declare function maybeInstallProxyAgent(deps?: ProxyDeps): boolean;
|
|
30
|
+
/**
|
|
31
|
+
* Whether the currently-installed global dispatcher is the proxy-aware
|
|
32
|
+
* agent `maybeInstallProxyAgent` installs — i.e., whether a proxy is
|
|
33
|
+
* actually wired up for outgoing `fetch()` calls in this process, not
|
|
34
|
+
* merely whether an `HTTP(S)_PROXY` env var happens to be set.
|
|
35
|
+
*
|
|
36
|
+
* This distinction matters: a CI runner can export `HTTPS_PROXY` for
|
|
37
|
+
* unrelated registry/package-manager egress without that value ever
|
|
38
|
+
* reaching this CLI's proxy path (e.g. it ran before `maybeInstallProxyAgent`
|
|
39
|
+
* executed, or `install()` threw and fell back to the default dispatcher).
|
|
40
|
+
* Consumers that need to know "is my request actually going through a
|
|
41
|
+
* proxy" — the target-url reachability preflight's refuse→warn downgrade,
|
|
42
|
+
* specifically — must check this, not the env var, or an unrelated,
|
|
43
|
+
* unexercised proxy variable silently defangs their guard.
|
|
44
|
+
*/
|
|
45
|
+
export declare function isProxyAgentActive(): boolean;
|
package/dist/lib/proxy.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { EnvHttpProxyAgent, setGlobalDispatcher } from 'undici';
|
|
1
|
+
import { EnvHttpProxyAgent, getGlobalDispatcher, setGlobalDispatcher } from 'undici';
|
|
2
2
|
/**
|
|
3
3
|
* Install the env-driven proxy dispatcher when any proxy variable is set
|
|
4
4
|
* (both canonical upper-case and conventional lower-case spellings).
|
|
@@ -27,4 +27,22 @@ export function maybeInstallProxyAgent(deps = {}) {
|
|
|
27
27
|
return false;
|
|
28
28
|
}
|
|
29
29
|
}
|
|
30
|
+
/**
|
|
31
|
+
* Whether the currently-installed global dispatcher is the proxy-aware
|
|
32
|
+
* agent `maybeInstallProxyAgent` installs — i.e., whether a proxy is
|
|
33
|
+
* actually wired up for outgoing `fetch()` calls in this process, not
|
|
34
|
+
* merely whether an `HTTP(S)_PROXY` env var happens to be set.
|
|
35
|
+
*
|
|
36
|
+
* This distinction matters: a CI runner can export `HTTPS_PROXY` for
|
|
37
|
+
* unrelated registry/package-manager egress without that value ever
|
|
38
|
+
* reaching this CLI's proxy path (e.g. it ran before `maybeInstallProxyAgent`
|
|
39
|
+
* executed, or `install()` threw and fell back to the default dispatcher).
|
|
40
|
+
* Consumers that need to know "is my request actually going through a
|
|
41
|
+
* proxy" — the target-url reachability preflight's refuse→warn downgrade,
|
|
42
|
+
* specifically — must check this, not the env var, or an unrelated,
|
|
43
|
+
* unexercised proxy variable silently defangs their guard.
|
|
44
|
+
*/
|
|
45
|
+
export function isProxyAgentActive() {
|
|
46
|
+
return getGlobalDispatcher() instanceof EnvHttpProxyAgent;
|
|
47
|
+
}
|
|
30
48
|
//# sourceMappingURL=proxy.js.map
|
|
@@ -33,6 +33,8 @@
|
|
|
33
33
|
*/
|
|
34
34
|
import * as v from 'valibot';
|
|
35
35
|
import type { BatchRerunResponse, BatchRunFreshResponse, ListRunsResponse, RerunResponse, RunResponse, TriggerRunResponse } from './runs.types.js';
|
|
36
|
+
import type { CliTestListRunResponse } from './testlist.types.js';
|
|
37
|
+
import type { TunnelMintResponse, TunnelStatusResponse } from './tunnel.types.js';
|
|
36
38
|
/** Mirrors `RunResponse` (runs.types.ts): `GET /api/cli/v1/runs/{runId}`. */
|
|
37
39
|
export declare const RUN_RESPONSE_SCHEMA: v.GenericSchema<unknown, RunResponse>;
|
|
38
40
|
/** Mirrors `TriggerRunResponse` (runs.types.ts): `POST /tests/{testId}/runs`. */
|
|
@@ -43,6 +45,12 @@ export declare const RERUN_RESPONSE_SCHEMA: v.GenericSchema<unknown, RerunRespon
|
|
|
43
45
|
export declare const BATCH_RERUN_RESPONSE_SCHEMA: v.GenericSchema<unknown, BatchRerunResponse>;
|
|
44
46
|
/** Mirrors `BatchRunFreshResponse` (runs.types.ts): `POST /tests/batch/run`. */
|
|
45
47
|
export declare const BATCH_RUN_FRESH_RESPONSE_SCHEMA: v.GenericSchema<unknown, BatchRunFreshResponse>;
|
|
48
|
+
/**
|
|
49
|
+
* `POST /api/cli/v1/testlist/{listId}/run`. Mirrors the batch-run-fresh shape so
|
|
50
|
+
* the `--wait` fan-out reuses the same poll tail; `conflicts[]` additionally
|
|
51
|
+
* carry the in-flight `currentRunId`, and `reason` marks a nothing-dispatched run.
|
|
52
|
+
*/
|
|
53
|
+
export declare const TESTLIST_RUN_RESPONSE_SCHEMA: v.GenericSchema<unknown, CliTestListRunResponse>;
|
|
46
54
|
/** Mirrors `ListRunsResponse` (runs.types.ts): `GET /tests/{testId}/runs`. */
|
|
47
55
|
export declare const LIST_RUNS_RESPONSE_SCHEMA: v.GenericSchema<unknown, ListRunsResponse>;
|
|
48
56
|
/**
|
|
@@ -81,3 +89,15 @@ export interface MeIdentityWire {
|
|
|
81
89
|
}
|
|
82
90
|
/** Mirrors `MeIdentity` (commands/doctor.ts): `GET /api/cli/v1/me` core. */
|
|
83
91
|
export declare const ME_IDENTITY_SCHEMA: v.GenericSchema<unknown, MeIdentityWire>;
|
|
92
|
+
/**
|
|
93
|
+
* Mirrors `TunnelMintResponse` (tunnel.types.ts): `POST /tunnel`.
|
|
94
|
+
*
|
|
95
|
+
* Every field is required rather than nullish-defaulted, and that is
|
|
96
|
+
* deliberate on this one surface: a mint response missing `controlUrl` or
|
|
97
|
+
* `tunnelAddr` cannot be used for anything, and the client's failure mode
|
|
98
|
+
* for a bad endpoint (a control socket that closes) is indistinguishable
|
|
99
|
+
* from an auth failure. Refusing the response here names the real problem.
|
|
100
|
+
*/
|
|
101
|
+
export declare const TUNNEL_MINT_RESPONSE_SCHEMA: v.GenericSchema<unknown, TunnelMintResponse>;
|
|
102
|
+
/** Mirrors `TunnelStatusResponse` (tunnel.types.ts): `GET /tunnel/{clientId}`. */
|
|
103
|
+
export declare const TUNNEL_STATUS_RESPONSE_SCHEMA: v.GenericSchema<unknown, TunnelStatusResponse>;
|
|
@@ -69,6 +69,9 @@ const RUN_STEP_DTO_SCHEMA = v.looseObject({
|
|
|
69
69
|
export const RUN_RESPONSE_SCHEMA = v.looseObject({
|
|
70
70
|
runId: v.string(),
|
|
71
71
|
testId: v.string(),
|
|
72
|
+
// The test's human title (for CI output). Absent on older servers; the type
|
|
73
|
+
// keeps it optional and renderers fall back to `testId`.
|
|
74
|
+
testTitle: v.nullish(v.string(), null),
|
|
72
75
|
projectId: v.string(),
|
|
73
76
|
userId: v.string(),
|
|
74
77
|
status: openWireLiteral(),
|
|
@@ -121,6 +124,10 @@ export const RUN_RESPONSE_SCHEMA = v.looseObject({
|
|
|
121
124
|
// through untouched) and normalized at the consumer, not in the schema.
|
|
122
125
|
// Locked by tests in response-schemas.test.ts.
|
|
123
126
|
dashboardUrl: v.nullish(v.string(), undefined),
|
|
127
|
+
// Same absent-key-preserving contract as `dashboardUrl` (see the note above):
|
|
128
|
+
// the run-scoped execution-result link is present only for a V3-served run
|
|
129
|
+
// with the server flag on, absent otherwise, and never materialized as null.
|
|
130
|
+
executionUrl: v.nullish(v.string(), undefined),
|
|
124
131
|
// Absence means "steps not requested" and drives command branching, so no
|
|
125
132
|
// default is applied (rule 3, optional branch).
|
|
126
133
|
steps: v.optional(v.nullable(v.array(RUN_STEP_DTO_SCHEMA))),
|
|
@@ -220,11 +227,33 @@ export const BATCH_RUN_FRESH_RESPONSE_SCHEMA = v.looseObject({
|
|
|
220
227
|
enqueuedAt: v.string(),
|
|
221
228
|
dashboardUrl: v.optional(v.string()),
|
|
222
229
|
})),
|
|
223
|
-
conflicts: v.array(v.looseObject({
|
|
230
|
+
conflicts: v.array(v.looseObject({
|
|
231
|
+
testId: v.string(),
|
|
232
|
+
currentRunId: v.optional(v.string()),
|
|
233
|
+
reason: v.optional(v.string()),
|
|
234
|
+
message: v.optional(v.string()),
|
|
235
|
+
})),
|
|
224
236
|
deferred: v.array(v.looseObject({ testId: v.string() })),
|
|
225
237
|
skippedFrontend: v.array(v.string()),
|
|
226
238
|
skippedIntegration: v.array(v.looseObject({ testId: v.string() })),
|
|
227
239
|
});
|
|
240
|
+
/**
|
|
241
|
+
* `POST /api/cli/v1/testlist/{listId}/run`. Mirrors the batch-run-fresh shape so
|
|
242
|
+
* the `--wait` fan-out reuses the same poll tail; `conflicts[]` additionally
|
|
243
|
+
* carry the in-flight `currentRunId`, and `reason` marks a nothing-dispatched run.
|
|
244
|
+
*/
|
|
245
|
+
export const TESTLIST_RUN_RESPONSE_SCHEMA = v.looseObject({
|
|
246
|
+
accepted: v.array(v.looseObject({ testId: v.string(), runId: v.string(), enqueuedAt: v.string() })),
|
|
247
|
+
conflicts: v.array(v.looseObject({
|
|
248
|
+
testId: v.string(),
|
|
249
|
+
currentRunId: v.optional(v.string()),
|
|
250
|
+
reason: v.optional(v.string()),
|
|
251
|
+
message: v.optional(v.string()),
|
|
252
|
+
})),
|
|
253
|
+
deferred: v.array(v.looseObject({ testId: v.string() })),
|
|
254
|
+
notFound: v.optional(v.array(v.string())),
|
|
255
|
+
reason: v.optional(v.string()),
|
|
256
|
+
});
|
|
228
257
|
// ---------------------------------------------------------------------------
|
|
229
258
|
// GET /tests/{testId}/runs
|
|
230
259
|
// ---------------------------------------------------------------------------
|
|
@@ -279,4 +308,29 @@ export const ME_IDENTITY_SCHEMA = v.looseObject({
|
|
|
279
308
|
organizations: v.optional(v.array(ORG_SUMMARY_SCHEMA)),
|
|
280
309
|
org: v.optional(ORG_BINDING_SCHEMA),
|
|
281
310
|
});
|
|
311
|
+
// ---------------------------------------------------------------------------
|
|
312
|
+
// /tunnel — DEV-747 piece 1 facade
|
|
313
|
+
// ---------------------------------------------------------------------------
|
|
314
|
+
/**
|
|
315
|
+
* Mirrors `TunnelMintResponse` (tunnel.types.ts): `POST /tunnel`.
|
|
316
|
+
*
|
|
317
|
+
* Every field is required rather than nullish-defaulted, and that is
|
|
318
|
+
* deliberate on this one surface: a mint response missing `controlUrl` or
|
|
319
|
+
* `tunnelAddr` cannot be used for anything, and the client's failure mode
|
|
320
|
+
* for a bad endpoint (a control socket that closes) is indistinguishable
|
|
321
|
+
* from an auth failure. Refusing the response here names the real problem.
|
|
322
|
+
*/
|
|
323
|
+
export const TUNNEL_MINT_RESPONSE_SCHEMA = v.looseObject({
|
|
324
|
+
clientId: v.pipe(v.string(), v.minLength(1)),
|
|
325
|
+
secret: v.pipe(v.string(), v.minLength(1)),
|
|
326
|
+
controlUrl: v.pipe(v.string(), v.minLength(1)),
|
|
327
|
+
tunnelAddr: v.pipe(v.string(), v.minLength(1)),
|
|
328
|
+
expiresAt: v.string(),
|
|
329
|
+
});
|
|
330
|
+
/** Mirrors `TunnelStatusResponse` (tunnel.types.ts): `GET /tunnel/{clientId}`. */
|
|
331
|
+
export const TUNNEL_STATUS_RESPONSE_SCHEMA = v.looseObject({
|
|
332
|
+
clientId: v.string(),
|
|
333
|
+
status: openWireLiteral(),
|
|
334
|
+
expiresAt: v.string(),
|
|
335
|
+
});
|
|
282
336
|
//# sourceMappingURL=response-schemas.js.map
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { RunResponse } from './runs.types.js';
|
|
2
|
+
import type { Ticker } from './ticker.js';
|
|
3
|
+
/**
|
|
4
|
+
* The in-place progress line for a polled run.
|
|
5
|
+
*
|
|
6
|
+
* Deliberately NO `completed/total` counter: on both the V2 and V3 read paths
|
|
7
|
+
* `stepSummary.total` and `.completed` are computed from the same array of
|
|
8
|
+
* already-finished step rows (a row is inserted only once its step has a
|
|
9
|
+
* verdict), so the two can never differ — `0/0 steps` at the start and `N/N`
|
|
10
|
+
* thereafter carried no information. Show the recorded count, or nothing.
|
|
11
|
+
*
|
|
12
|
+
* `tag` is inserted verbatim after the run id — the caller picks the bracket
|
|
13
|
+
* style (`(testId)` for batch members, `[role]` for closure members) so the
|
|
14
|
+
* two kinds of tag stay visually distinct.
|
|
15
|
+
*/
|
|
16
|
+
export declare function formatRunProgressLine(run: RunResponse, elapsedMs: number, tag?: string): string;
|
|
17
|
+
export interface LiveRunProgress {
|
|
18
|
+
/** Feed a poll result; renders immediately and becomes the refresher's snapshot. */
|
|
19
|
+
onTick(run: RunResponse, elapsedMs: number): void;
|
|
20
|
+
/** Stop the 1s refresher. Idempotent; call before the ticker's final line. */
|
|
21
|
+
stop(): void;
|
|
22
|
+
}
|
|
23
|
+
export interface LiveRunProgressOptions {
|
|
24
|
+
/**
|
|
25
|
+
* Whether to run the between-polls refresher. Defaults to
|
|
26
|
+
* `ticker.redrawsInPlace` — a ticker that prints a NEW line per `update()`
|
|
27
|
+
* (non-TTY, NO_COLOR) must not be redrawn once a second.
|
|
28
|
+
*/
|
|
29
|
+
enabled?: boolean;
|
|
30
|
+
intervalMs?: number;
|
|
31
|
+
now?: () => number;
|
|
32
|
+
setIntervalFn?: (cb: () => void, ms: number) => NodeJS.Timeout;
|
|
33
|
+
clearIntervalFn?: (handle: NodeJS.Timeout) => void;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Wraps a {@link Ticker} so the elapsed counter keeps moving between polls.
|
|
37
|
+
* In long-poll mode a `getRun` returns every ~25s, so a ticker driven only by
|
|
38
|
+
* `onTick` freezes for the whole wait; this re-renders the LAST snapshot
|
|
39
|
+
* every second with the wall-clock time that has passed since it arrived.
|
|
40
|
+
*/
|
|
41
|
+
export declare function createLiveRunProgress(ticker: Ticker, opts?: LiveRunProgressOptions, tag?: string): LiveRunProgress;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The in-place progress line for a polled run.
|
|
3
|
+
*
|
|
4
|
+
* Deliberately NO `completed/total` counter: on both the V2 and V3 read paths
|
|
5
|
+
* `stepSummary.total` and `.completed` are computed from the same array of
|
|
6
|
+
* already-finished step rows (a row is inserted only once its step has a
|
|
7
|
+
* verdict), so the two can never differ — `0/0 steps` at the start and `N/N`
|
|
8
|
+
* thereafter carried no information. Show the recorded count, or nothing.
|
|
9
|
+
*
|
|
10
|
+
* `tag` is inserted verbatim after the run id — the caller picks the bracket
|
|
11
|
+
* style (`(testId)` for batch members, `[role]` for closure members) so the
|
|
12
|
+
* two kinds of tag stay visually distinct.
|
|
13
|
+
*/
|
|
14
|
+
export function formatRunProgressLine(run, elapsedMs, tag) {
|
|
15
|
+
const elapsed = Math.round(elapsedMs / 1000);
|
|
16
|
+
const total = run.stepSummary?.total ?? 0;
|
|
17
|
+
const head = tag === undefined ? `Run ${run.runId}` : `Run ${run.runId} ${tag}`;
|
|
18
|
+
const steps = total > 0 ? ` · ${total} step${total === 1 ? '' : 's'}` : '';
|
|
19
|
+
return `${head} — ${run.status}${steps} · ${elapsed}s`;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Wraps a {@link Ticker} so the elapsed counter keeps moving between polls.
|
|
23
|
+
* In long-poll mode a `getRun` returns every ~25s, so a ticker driven only by
|
|
24
|
+
* `onTick` freezes for the whole wait; this re-renders the LAST snapshot
|
|
25
|
+
* every second with the wall-clock time that has passed since it arrived.
|
|
26
|
+
*/
|
|
27
|
+
export function createLiveRunProgress(ticker, opts = {}, tag) {
|
|
28
|
+
const now = opts.now ?? Date.now;
|
|
29
|
+
const setIntervalFn = opts.setIntervalFn ?? setInterval;
|
|
30
|
+
const clearIntervalFn = opts.clearIntervalFn ?? clearInterval;
|
|
31
|
+
const enabled = opts.enabled ?? ticker.redrawsInPlace;
|
|
32
|
+
let snapshot;
|
|
33
|
+
let handle;
|
|
34
|
+
if (enabled) {
|
|
35
|
+
handle = setIntervalFn(() => {
|
|
36
|
+
if (!snapshot)
|
|
37
|
+
return;
|
|
38
|
+
ticker.update(formatRunProgressLine(snapshot.run, snapshot.elapsedMs + (now() - snapshot.at), tag));
|
|
39
|
+
}, opts.intervalMs ?? 1000);
|
|
40
|
+
// Never let the refresher keep the process alive on its own.
|
|
41
|
+
handle.unref?.();
|
|
42
|
+
}
|
|
43
|
+
return {
|
|
44
|
+
onTick(run, elapsedMs) {
|
|
45
|
+
snapshot = { run, elapsedMs, at: now() };
|
|
46
|
+
ticker.update(formatRunProgressLine(run, elapsedMs, tag));
|
|
47
|
+
},
|
|
48
|
+
stop() {
|
|
49
|
+
if (handle !== undefined) {
|
|
50
|
+
clearIntervalFn(handle);
|
|
51
|
+
handle = undefined;
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
//# sourceMappingURL=run-progress.js.map
|
package/dist/lib/runs.types.d.ts
CHANGED
|
@@ -4,12 +4,24 @@
|
|
|
4
4
|
* Extended by M3.4 piece-5 — `test result --history` command.
|
|
5
5
|
|
|
6
6
|
*/
|
|
7
|
+
import type { RunConflict } from './conflict-reason.js';
|
|
7
8
|
/** Literal body sent to `POST /api/cli/v1/tests/{testId}/runs`. */
|
|
8
9
|
export interface TriggerRunBody {
|
|
9
10
|
/** Fixed source literal for CLI-triggered runs. */
|
|
10
11
|
source: 'cli';
|
|
11
12
|
/** Optional override for the project's configured target URL. */
|
|
12
13
|
targetUrl?: string;
|
|
14
|
+
/**
|
|
15
|
+
* DEV-747: id of a tunnel client minted through `POST /api/cli/v1/tunnel`.
|
|
16
|
+
*
|
|
17
|
+
* An ID, never a proxy string — the caller does not choose the proxy host.
|
|
18
|
+
* The server loads the binding, checks it belongs to the calling principal
|
|
19
|
+
* and that the tunnel is connected, and only then builds the proxy string
|
|
20
|
+
* from its own configuration. Sent ONLY alongside a loopback `targetUrl`;
|
|
21
|
+
* the server refuses the pairing in every other combination rather than
|
|
22
|
+
* dropping the field.
|
|
23
|
+
*/
|
|
24
|
+
tunnelClientId?: string;
|
|
13
25
|
}
|
|
14
26
|
/**
|
|
15
27
|
* Body sent to `POST /api/cli/v1/tests/{testId}/runs/rerun`.
|
|
@@ -191,6 +203,11 @@ export interface RunStepDto {
|
|
|
191
203
|
export interface RunResponse {
|
|
192
204
|
runId: string;
|
|
193
205
|
testId: string;
|
|
206
|
+
/**
|
|
207
|
+
* The test's human title, for CI output. `null`/absent on older servers or
|
|
208
|
+
* when it can't be resolved — consumers fall back to `testId`.
|
|
209
|
+
*/
|
|
210
|
+
testTitle?: string | null;
|
|
194
211
|
projectId: string;
|
|
195
212
|
userId: string;
|
|
196
213
|
status: RunStatus;
|
|
@@ -236,6 +253,14 @@ export interface RunResponse {
|
|
|
236
253
|
* `withRunDashboardUrl` in `commands/test.ts`.
|
|
237
254
|
*/
|
|
238
255
|
dashboardUrl?: string | null;
|
|
256
|
+
/**
|
|
257
|
+
* Portal deep link to THIS RUN's result page (`…/projects/{pid}/execution/{eid}`),
|
|
258
|
+
* the run-scoped companion to `dashboardUrl` (which opens the test case). Same
|
|
259
|
+
* server-built / omit-not-null contract as `dashboardUrl`: **V3-served runs
|
|
260
|
+
* only** — a V2 run has no execution page, so the field is absent there and the
|
|
261
|
+
* CLI keeps `dashboardUrl` (the test-case link) for the run cell.
|
|
262
|
+
*/
|
|
263
|
+
executionUrl?: string | null;
|
|
239
264
|
/**
|
|
240
265
|
* Full ordered step list. Only present when the request includes
|
|
241
266
|
* `?includeSteps=true`. Absent (undefined) when the flag was not sent.
|
|
@@ -385,9 +410,13 @@ export interface BatchRunFreshAccepted {
|
|
|
385
410
|
*/
|
|
386
411
|
export interface BatchRunFreshResponse {
|
|
387
412
|
accepted: BatchRunFreshAccepted[];
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
413
|
+
/**
|
|
414
|
+
* A run-slot conflict. `currentRunId`, when present, is the id of the run
|
|
415
|
+
* ALREADY in flight for this test — under `--wait` the CLI polls it to a
|
|
416
|
+
* verdict (auto-resume) instead of failing the batch. Absent ⇒ a hard
|
|
417
|
+
* conflict with no resolvable in-flight run (still fails the batch).
|
|
418
|
+
*/
|
|
419
|
+
conflicts: RunConflict[];
|
|
391
420
|
deferred: Array<{
|
|
392
421
|
testId: string;
|
|
393
422
|
}>;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Read a secret from `path`, surfacing every filesystem failure as a typed
|
|
3
|
+
* `VALIDATION_ERROR` (exit 5) attributed to `flag`.
|
|
4
|
+
*
|
|
5
|
+
* The returned value is trimmed, matching what the unguarded call sites did.
|
|
6
|
+
* Trimming also drops a leading UTF-8 BOM: `U+FEFF` is ECMAScript whitespace,
|
|
7
|
+
* so a file written by PowerShell 5.1's default `Set-Content -Encoding utf8`
|
|
8
|
+
* no longer smuggles an invisible character into the secret.
|
|
9
|
+
*
|
|
10
|
+
* @param flag - Flag name without the leading dashes, e.g. `'password-file'`.
|
|
11
|
+
* @param path - Path as supplied by the user; may be relative.
|
|
12
|
+
* @throws {ApiError} `VALIDATION_ERROR` when the path is missing, unreadable,
|
|
13
|
+
* or not a regular file.
|
|
14
|
+
*/
|
|
15
|
+
export declare function readSecretFileGuarded(flag: string, path: string): string;
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Guarded reader for the `--*-file` secret flags.
|
|
3
|
+
*
|
|
4
|
+
* Every one of these flags exists so a secret stays out of shell history, and
|
|
5
|
+
* every one of them is a path the user types by hand — so a typo is the
|
|
6
|
+
* expected failure, not an exceptional one. A bare
|
|
7
|
+
* `readFileSync(path, 'utf8').trim()` turns that typo into an unhandled Node
|
|
8
|
+
* exception: exit `1` instead of `5`, an `--output json` payload whose `error`
|
|
9
|
+
* is a bare string rather than the `{ code, message, nextAction }` envelope the
|
|
10
|
+
* rest of the CLI emits, and the absolute path plus errno leaked to stderr.
|
|
11
|
+
*
|
|
12
|
+
* This maps those failures onto the same typed `VALIDATION_ERROR` envelope the
|
|
13
|
+
* already-guarded file flags produce, mirroring `readCodeFileGuarded` in
|
|
14
|
+
* `src/commands/test.ts`. The payload cap is deliberately not carried over:
|
|
15
|
+
* secrets are small, and a size ceiling would be a behaviour change on a
|
|
16
|
+
* shipped flag rather than part of fixing the crash.
|
|
17
|
+
*
|
|
18
|
+
* Callers pass the flag name so the envelope names the flag the user actually
|
|
19
|
+
* typed — one helper serves `--password-file` today and the remaining
|
|
20
|
+
* credential/auto-auth file flags once they are migrated.
|
|
21
|
+
*/
|
|
22
|
+
import { readFileSync, statSync } from 'node:fs';
|
|
23
|
+
import { isAbsolute, resolve } from 'node:path';
|
|
24
|
+
import { localValidationError } from './errors.js';
|
|
25
|
+
/**
|
|
26
|
+
* Read a secret from `path`, surfacing every filesystem failure as a typed
|
|
27
|
+
* `VALIDATION_ERROR` (exit 5) attributed to `flag`.
|
|
28
|
+
*
|
|
29
|
+
* The returned value is trimmed, matching what the unguarded call sites did.
|
|
30
|
+
* Trimming also drops a leading UTF-8 BOM: `U+FEFF` is ECMAScript whitespace,
|
|
31
|
+
* so a file written by PowerShell 5.1's default `Set-Content -Encoding utf8`
|
|
32
|
+
* no longer smuggles an invisible character into the secret.
|
|
33
|
+
*
|
|
34
|
+
* @param flag - Flag name without the leading dashes, e.g. `'password-file'`.
|
|
35
|
+
* @param path - Path as supplied by the user; may be relative.
|
|
36
|
+
* @throws {ApiError} `VALIDATION_ERROR` when the path is missing, unreadable,
|
|
37
|
+
* or not a regular file.
|
|
38
|
+
*/
|
|
39
|
+
export function readSecretFileGuarded(flag, path) {
|
|
40
|
+
const absolute = isAbsolute(path) ? path : resolve(process.cwd(), path);
|
|
41
|
+
let stat;
|
|
42
|
+
try {
|
|
43
|
+
// eslint-disable-next-line security/detect-non-literal-fs-filename -- this is the guard itself: `absolute` is the user-supplied `--*-file` path after isAbsolute()/resolve() normalization, and this statSync().isFile() check (below) plus the try/catch mapping every errno to a typed VALIDATION_ERROR is exactly the mitigation for a non-literal fs path here.
|
|
44
|
+
stat = statSync(absolute);
|
|
45
|
+
}
|
|
46
|
+
catch (err) {
|
|
47
|
+
throw secretFileError(flag, path, err, 'stat');
|
|
48
|
+
}
|
|
49
|
+
// A directory would otherwise reach readFileSync and throw EISDIR on Linux
|
|
50
|
+
// while resolving to an empty read on some platforms — reject it up front so
|
|
51
|
+
// the contract is the same everywhere.
|
|
52
|
+
if (!stat.isFile()) {
|
|
53
|
+
throw localValidationError(flag, `not a regular file: ${path}`);
|
|
54
|
+
}
|
|
55
|
+
try {
|
|
56
|
+
// eslint-disable-next-line security/detect-non-literal-fs-filename -- same guarded path as the statSync() above: `absolute` already passed the isFile() regular-file check, so this read is the guard's intended purpose (reading a user-supplied secret path), not an unvalidated pass-through.
|
|
57
|
+
return readFileSync(absolute, 'utf8').trim();
|
|
58
|
+
}
|
|
59
|
+
catch (err) {
|
|
60
|
+
throw secretFileError(flag, path, err, 'read');
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Translate a Node filesystem error into the CLI's validation envelope,
|
|
65
|
+
* reporting the path the user typed rather than the resolved absolute path so
|
|
66
|
+
* no directory layout leaks into output.
|
|
67
|
+
*/
|
|
68
|
+
function secretFileError(flag, path, err, verb) {
|
|
69
|
+
const code = err.code;
|
|
70
|
+
if (code === 'ENOENT') {
|
|
71
|
+
return localValidationError(flag, `file does not exist: ${path}`);
|
|
72
|
+
}
|
|
73
|
+
if (code === 'EACCES' || code === 'EPERM') {
|
|
74
|
+
return localValidationError(flag, `permission denied reading ${path}`);
|
|
75
|
+
}
|
|
76
|
+
if (code === 'EISDIR') {
|
|
77
|
+
return localValidationError(flag, `not a regular file: ${path}`);
|
|
78
|
+
}
|
|
79
|
+
const reason = err instanceof Error ? err.message : 'unknown error';
|
|
80
|
+
return localValidationError(flag, `cannot ${verb} ${path}: ${reason}`);
|
|
81
|
+
}
|
|
82
|
+
//# sourceMappingURL=secret-file.js.map
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pre-charge reachability preflight for a caller-supplied `--target-url`.
|
|
3
|
+
*
|
|
4
|
+
* A blocked-run analysis measured 1,003 blocked-with-URL CLI runs: 26%
|
|
5
|
+
* pointed at a third-party tunnel host (`*.trycloudflare.com`, `*.loca.lt`,
|
|
6
|
+
* ngrok), 55.5% of those were blocked, and every one of them was charged
|
|
7
|
+
* anyway — the run row and its credit spend happen before the Lambda ever
|
|
8
|
+
* discovers the target is dead. This probe runs BEFORE the trigger POST so
|
|
9
|
+
* an obviously-doomed run never gets a run row or a charge.
|
|
10
|
+
*
|
|
11
|
+
* **Honest limitation** (this must also be stated in `--help` and the PR
|
|
12
|
+
* body): the probe below runs from wherever this CLI process runs — the
|
|
13
|
+
* caller's laptop, a CI runner — while the actual test executes from a
|
|
14
|
+
* Lambda inside AWS. Reachability from one is not proof of reachability
|
|
15
|
+
* from the other. That asymmetry is why the refusal set is deliberately
|
|
16
|
+
* narrow (only the failure classes that analysis actually measured — a
|
|
17
|
+
* broader rule would not have prevented a single one of those 1,003 runs), why
|
|
18
|
+
* every ambiguous signal downgrades to a warning instead of a hard block,
|
|
19
|
+
* and why `--skip-preflight` exists as a full opt-out (zero network calls).
|
|
20
|
+
*
|
|
21
|
+
* Two injectable seams, mirroring the MCP plugin's `checkPortListening`
|
|
22
|
+
* shape (a cheap first check, then an HTTP-level fallback for the signal
|
|
23
|
+
* the first check can't see) rather than inventing a new one:
|
|
24
|
+
* - `dnsLookup` — a raw DNS resolution. Deliberately separate from the
|
|
25
|
+
* HTTP probe below: `proxy.ts` installs a proxy dispatcher that only
|
|
26
|
+
* `fetch()` honours, never a raw socket/DNS call, so behind a
|
|
27
|
+
* configured HTTP(S) proxy this step can fail locally (the real
|
|
28
|
+
* resolution happens at the proxy) even though the target is reachable
|
|
29
|
+
* — hence the proxy carve-out downgrades a negative *failure* result
|
|
30
|
+
* here. A resolved address landing in the private/loopback/link-local/
|
|
31
|
+
* metadata range is a different kind of signal (DNS rebinding, not
|
|
32
|
+
* ambiguity about where resolution happens) and always refuses — see
|
|
33
|
+
* the resolved-address check below.
|
|
34
|
+
* - `fetchImpl` — the actual HTTP probe (proxy-aware once a proxy
|
|
35
|
+
* dispatcher is installed), used for the 502/503/504 gateway-error
|
|
36
|
+
* signal a DNS/TCP-level check cannot see at all. Runs with
|
|
37
|
+
* `redirect: 'manual'`: a 3xx is treated as a live/reachable signal
|
|
38
|
+
* (a real app 302ing to a login page is healthy) but is never
|
|
39
|
+
* followed — the redirect target is unvalidated by everything above
|
|
40
|
+
* (`assertNotLocal` only ever inspected the literal `--target-url`
|
|
41
|
+
* string; the resolved-address check only covers *this* URL's host),
|
|
42
|
+
* so following it would hand an attacker-controlled Location header a
|
|
43
|
+
* live SSRF primitive running on the caller's machine or CI runner.
|
|
44
|
+
*/
|
|
45
|
+
export interface TargetUrlPreflightDeps {
|
|
46
|
+
/** DNS resolution hook. Defaults to `dns.promises.lookup`. Injectable for tests. */
|
|
47
|
+
dnsLookup?: (hostname: string) => Promise<unknown>;
|
|
48
|
+
/** HTTP probe hook. Defaults to the global `fetch`. Injectable for tests. */
|
|
49
|
+
fetchImpl?: typeof fetch;
|
|
50
|
+
/**
|
|
51
|
+
* Whether a proxy dispatcher is actually installed for this process.
|
|
52
|
+
* Defaults to `isProxyAgentActive()` (proxy.ts), which inspects the
|
|
53
|
+
* active global undici dispatcher — deliberately NOT an env-var check:
|
|
54
|
+
* an `HTTP(S)_PROXY` variable can be present in the environment (e.g. a
|
|
55
|
+
* CI runner exporting it for unrelated package-registry egress) without
|
|
56
|
+
* this CLI ever having installed a dispatcher for it, and gating the
|
|
57
|
+
* refuse→warn downgrade on the env var alone would silently soften every
|
|
58
|
+
* refusal in exactly that environment. Injectable for tests so they don't
|
|
59
|
+
* need to mutate the real global dispatcher to exercise the proxy path.
|
|
60
|
+
*/
|
|
61
|
+
proxyActive?: boolean;
|
|
62
|
+
}
|
|
63
|
+
export type TargetUrlPreflightOutcome = {
|
|
64
|
+
verdict: 'ok';
|
|
65
|
+
} | {
|
|
66
|
+
verdict: 'warn';
|
|
67
|
+
reason: string;
|
|
68
|
+
} | {
|
|
69
|
+
verdict: 'refuse';
|
|
70
|
+
reason: string;
|
|
71
|
+
};
|
|
72
|
+
/**
|
|
73
|
+
* Probe `rawUrl` for the narrow refusal set described in the module
|
|
74
|
+
* docstring. Pure decision function — never throws for a network failure
|
|
75
|
+
* (every reachable failure classifies to `warn` or `refuse`); a malformed
|
|
76
|
+
* URL degrades to `warn` rather than crashing (callers validate the URL
|
|
77
|
+
* shape via `assertNotLocal` before this runs).
|
|
78
|
+
*/
|
|
79
|
+
export declare function probeTargetUrl(rawUrl: string, deps?: TargetUrlPreflightDeps): Promise<TargetUrlPreflightOutcome>;
|
|
80
|
+
/**
|
|
81
|
+
* Run the preflight and either throw (refuse), print an `[advisory]` line
|
|
82
|
+
* (warn), or no-op (ok / skipped). This is the call-site integration point
|
|
83
|
+
* — wired at all four `--target-url` trigger paths, after `assertNotLocal`
|
|
84
|
+
* and before the trigger POST.
|
|
85
|
+
*
|
|
86
|
+
* `skipPreflight: true` makes this a pure no-op with ZERO network calls —
|
|
87
|
+
* neither `dnsLookup` nor `fetchImpl` is invoked.
|
|
88
|
+
*/
|
|
89
|
+
export declare function assertTargetUrlReachable(targetUrl: string, opts: {
|
|
90
|
+
skipPreflight?: boolean;
|
|
91
|
+
}, deps: TargetUrlPreflightDeps, stderrFn: (line: string) => void): Promise<void>;
|