@testsprite/testsprite-cli 0.13.0 → 0.15.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 +54 -49
- package/dist/commands/ci.d.ts +66 -17
- package/dist/commands/ci.js +466 -104
- package/dist/commands/doctor.d.ts +3 -0
- package/dist/commands/doctor.js +62 -20
- package/dist/commands/init.js +17 -3
- package/dist/commands/project-env.d.ts +11 -1
- package/dist/commands/project-env.js +399 -61
- 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 +9 -0
- package/dist/commands/project.js +82 -28
- package/dist/commands/schedule.d.ts +12 -0
- package/dist/commands/schedule.js +175 -5
- package/dist/commands/test.d.ts +126 -30
- package/dist/commands/test.js +1928 -447
- package/dist/commands/testlist.d.ts +10 -5
- package/dist/commands/testlist.js +170 -30
- package/dist/commands/tunnel.js +11 -5
- package/dist/index.js +17 -38
- package/dist/lib/agent-targets.d.ts +8 -3
- package/dist/lib/agent-targets.js +15 -4
- package/dist/lib/ci-run.d.ts +11 -0
- package/dist/lib/ci-run.js +34 -0
- package/dist/lib/client-factory.d.ts +35 -1
- package/dist/lib/client-factory.js +21 -10
- package/dist/lib/config.d.ts +1 -0
- package/dist/lib/config.js +1 -1
- package/dist/lib/credentials.d.ts +0 -1
- package/dist/lib/credentials.js +51 -14
- package/dist/lib/dry-run/samples.js +95 -1
- package/dist/lib/environment-tunnel.d.ts +109 -0
- package/dist/lib/environment-tunnel.js +465 -0
- package/dist/lib/errors.js +12 -1
- package/dist/lib/first-suite-hint.d.ts +55 -0
- package/dist/lib/first-suite-hint.js +101 -0
- package/dist/lib/gh-output.d.ts +62 -4
- package/dist/lib/gh-output.js +152 -7
- package/dist/lib/github-context.d.ts +21 -0
- package/dist/lib/github-context.js +153 -0
- package/dist/lib/http.d.ts +12 -1
- package/dist/lib/http.js +9 -1
- package/dist/lib/junit-report.d.ts +11 -7
- package/dist/lib/junit-report.js +13 -7
- package/dist/lib/local-target.d.ts +13 -3
- package/dist/lib/local-target.js +47 -12
- package/dist/lib/output.js +15 -1
- package/dist/lib/plan-poll.js +3 -4
- package/dist/lib/plans.types.d.ts +1 -1
- package/dist/lib/redact.d.ts +38 -0
- package/dist/lib/redact.js +140 -0
- package/dist/lib/render-error.d.ts +19 -5
- package/dist/lib/render-error.js +31 -0
- package/dist/lib/response-schemas.d.ts +5 -1
- package/dist/lib/response-schemas.js +54 -0
- package/dist/lib/runs.types.d.ts +115 -1
- package/dist/lib/target-url.js +5 -5
- package/dist/lib/telemetry.d.ts +31 -8
- package/dist/lib/telemetry.js +55 -7
- package/dist/lib/testlist.types.d.ts +1 -0
- package/dist/lib/ticker.d.ts +9 -0
- package/dist/lib/ticker.js +18 -0
- package/dist/lib/tunnel-session.d.ts +3 -4
- package/dist/lib/tunnel-session.js +3 -4
- package/dist/lib/v3-advisory.js +0 -1
- 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.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
- package/schemas/plan.schema.json +2 -2
- package/skills/testsprite-ci.skill.md +154 -0
- package/skills/testsprite-onboard.skill.md +4 -4
package/dist/lib/runs.types.d.ts
CHANGED
|
@@ -55,10 +55,13 @@ export interface RunEnvironmentRef {
|
|
|
55
55
|
}
|
|
56
56
|
/**
|
|
57
57
|
* Body sent to `POST /api/cli/v1/tests/{testId}/runs/rerun`.
|
|
58
|
-
*
|
|
58
|
+
* Tunnel replay includes the saved environment URL verbatim; ordinary replay
|
|
59
|
+
* uses the configured URL.
|
|
59
60
|
* `source` must be "cli" (not "cli-rerun" — that is not a valid RUN_SOURCES value).
|
|
60
61
|
*/
|
|
61
62
|
export interface RerunRequest {
|
|
63
|
+
tunnelClientId?: string;
|
|
64
|
+
targetUrl?: string;
|
|
62
65
|
source: 'cli';
|
|
63
66
|
/** Opt into AI heal-on-drift. Paid + FE only. Server tier-gates and echoes effective value. */
|
|
64
67
|
autoHeal?: boolean;
|
|
@@ -101,6 +104,7 @@ export interface RerunAdvisory {
|
|
|
101
104
|
* `runId` is always non-null (minted synchronously before async invoke).
|
|
102
105
|
*/
|
|
103
106
|
export interface RerunResponse {
|
|
107
|
+
tunnelClientId?: string;
|
|
104
108
|
/** The named test's runId (minted synchronously before async Lambda invoke). */
|
|
105
109
|
runId: string;
|
|
106
110
|
status: 'queued';
|
|
@@ -131,6 +135,8 @@ export interface RerunResponse {
|
|
|
131
135
|
* Mixed FE/BE testIds allowed; BE closure deduped server-side per project.
|
|
132
136
|
*/
|
|
133
137
|
export interface BatchRerunRequest {
|
|
138
|
+
tunnelClientId?: string;
|
|
139
|
+
targetUrl?: string;
|
|
134
140
|
source: 'cli';
|
|
135
141
|
testIds: string[];
|
|
136
142
|
autoHeal?: boolean;
|
|
@@ -188,6 +194,7 @@ export interface BatchRerunClosure {
|
|
|
188
194
|
* chunked dispatch requests (see `dedupeRerunAdvisories` in `commands/test.ts`).
|
|
189
195
|
*/
|
|
190
196
|
export interface BatchRerunResponse {
|
|
197
|
+
tunnelClientId?: string;
|
|
191
198
|
accepted: BatchRerunAccepted[];
|
|
192
199
|
deferred: BatchRerunDeferred[];
|
|
193
200
|
conflicts: BatchRerunConflict[];
|
|
@@ -200,6 +207,7 @@ export interface BatchRerunResponse {
|
|
|
200
207
|
* All fields are stamped at trigger time and cannot change for this runId.
|
|
201
208
|
*/
|
|
202
209
|
export interface TriggerRunResponse {
|
|
210
|
+
tunnelClientId?: string;
|
|
203
211
|
runId: string;
|
|
204
212
|
status: 'queued';
|
|
205
213
|
enqueuedAt: string;
|
|
@@ -312,6 +320,16 @@ export interface RunResponse {
|
|
|
312
320
|
error: string | null;
|
|
313
321
|
videoUrl: string | null;
|
|
314
322
|
stepSummary: RunStepSummary;
|
|
323
|
+
/**
|
|
324
|
+
* How the stored code was routed. `path: 'refused'` means the run was
|
|
325
|
+
* blocked before dispatch because the stored code could not be replayed;
|
|
326
|
+
* `reason` names why. Absent on older backends.
|
|
327
|
+
*/
|
|
328
|
+
replay?: {
|
|
329
|
+
path: string;
|
|
330
|
+
reason?: string | null;
|
|
331
|
+
caveat?: string | null;
|
|
332
|
+
};
|
|
315
333
|
/** Optional hint from the server; honored by the polling loop. */
|
|
316
334
|
retryAfterSeconds?: number;
|
|
317
335
|
/**
|
|
@@ -474,6 +492,18 @@ export interface ListRunsQuery {
|
|
|
474
492
|
* BE-only engine — FE tests in the set are skipped server-side (advisory only).
|
|
475
493
|
* `testIds` absent / empty → run ALL BE tests in the project.
|
|
476
494
|
*/
|
|
495
|
+
/**
|
|
496
|
+
* Where a `ci run` came from on GitHub, read off the Actions event. Stamped on
|
|
497
|
+
* the execution so the Portal can link the run back to its pull request.
|
|
498
|
+
*/
|
|
499
|
+
export interface CiGithubTrigger {
|
|
500
|
+
repoOwner: string;
|
|
501
|
+
repoName: string;
|
|
502
|
+
branchName?: string;
|
|
503
|
+
/** 40-hex commit the preview was built from. */
|
|
504
|
+
commitSha?: string;
|
|
505
|
+
prNumber: number;
|
|
506
|
+
}
|
|
477
507
|
export interface BatchRunFreshRequest {
|
|
478
508
|
projectId: string;
|
|
479
509
|
testIds?: string[];
|
|
@@ -484,9 +514,25 @@ export interface BatchRunFreshRequest {
|
|
|
484
514
|
environment?: string;
|
|
485
515
|
/** Per-run URL override for the batch; echoed when the backend honors it. */
|
|
486
516
|
targetUrl?: string;
|
|
517
|
+
/**
|
|
518
|
+
* `'all'`: the server seeds every selected case into one execution and
|
|
519
|
+
* paces dispatch itself (as for a GitHub App run) instead of cutting the
|
|
520
|
+
* selection to the per-key budget and returning the rest as `deferred`.
|
|
521
|
+
* Default `'budget'` is today's behaviour. Echoed when honored.
|
|
522
|
+
*/
|
|
523
|
+
admission?: 'budget' | 'all';
|
|
524
|
+
/** `github-pr-<N>`: run in a temporary clone of `environment` at `targetUrl`. Echoed when honored. */
|
|
525
|
+
previewName?: string;
|
|
526
|
+
githubTrigger?: CiGithubTrigger;
|
|
487
527
|
}
|
|
488
528
|
/** One accepted run in the batch fresh-run response. */
|
|
489
529
|
export interface BatchRunFreshAccepted {
|
|
530
|
+
/**
|
|
531
|
+
* The `test_execution.id` this run was dispatched under (V3-served runs
|
|
532
|
+
* only; absent on a V2 backend). One execution usually covers the whole
|
|
533
|
+
* batch — `ci run` de-duplicates it to read the execution report.
|
|
534
|
+
*/
|
|
535
|
+
executionId?: string;
|
|
490
536
|
testId: string;
|
|
491
537
|
/**
|
|
492
538
|
* runId minted synchronously by `claimRunSlotOrThrow`. The backend partitions
|
|
@@ -531,6 +577,17 @@ export interface BatchRunFreshResponse {
|
|
|
531
577
|
skippedIntegration: Array<{
|
|
532
578
|
testId: string;
|
|
533
579
|
}>;
|
|
580
|
+
/**
|
|
581
|
+
* Backend projects only: the integration phase that follows the wave.
|
|
582
|
+
* `existing` integration tests run after it (0.2 credits each);
|
|
583
|
+
* `mayGenerate` means a first run may also generate new ones. Absent on
|
|
584
|
+
* older backends and for frontend projects.
|
|
585
|
+
*/
|
|
586
|
+
integration?: {
|
|
587
|
+
existing: number;
|
|
588
|
+
runsAfterWave: boolean;
|
|
589
|
+
mayGenerate: boolean;
|
|
590
|
+
};
|
|
534
591
|
/**
|
|
535
592
|
* Project-level portal link the batch closes with ("watch it here"). Same
|
|
536
593
|
* absent-vs-present contract as the per-run `dashboardUrl`: ABSENT ⇒ an older
|
|
@@ -547,4 +604,61 @@ export interface BatchRunFreshResponse {
|
|
|
547
604
|
* report a verdict for an unconfirmed target.
|
|
548
605
|
*/
|
|
549
606
|
targetUrl?: string;
|
|
607
|
+
/** Echoes, same contract as `targetUrl`: absent means this backend never read the field. */
|
|
608
|
+
admission?: 'budget' | 'all';
|
|
609
|
+
previewName?: string;
|
|
610
|
+
}
|
|
611
|
+
/** One row of an execution report — one `test_result` of that execution. */
|
|
612
|
+
export interface ExecutionReportTest {
|
|
613
|
+
/** The `test_result.id` (the CLI's run id). */
|
|
614
|
+
id: string;
|
|
615
|
+
title: string;
|
|
616
|
+
/** Display id of the case (e.g. `AUTH-002`); null when unresolved. */
|
|
617
|
+
slug: string | null;
|
|
618
|
+
status: 'PASSED' | 'FAILED' | 'BLOCKED' | (string & {});
|
|
619
|
+
/** Presigned PNG of a step snapshot; null when unavailable. */
|
|
620
|
+
screenshotUrl: string | null;
|
|
621
|
+
/** Raw failure text; set for FAILED rows. */
|
|
622
|
+
error: string | null;
|
|
623
|
+
/** Suggested fix prompt; set for FAILED rows. */
|
|
624
|
+
fix: string | null;
|
|
625
|
+
/** This result's own Portal page (`…/execution/{eid}/test/{rid}`). */
|
|
626
|
+
resultUrl?: string;
|
|
627
|
+
}
|
|
628
|
+
/**
|
|
629
|
+
* The execution report the GitHub App posts as its PR comment — the server's
|
|
630
|
+
* content model, returned verbatim so a later CI step can shape it itself.
|
|
631
|
+
*/
|
|
632
|
+
export interface ExecutionReport {
|
|
633
|
+
projectId: string;
|
|
634
|
+
executionId: string;
|
|
635
|
+
projectName: string;
|
|
636
|
+
orgId: string | null;
|
|
637
|
+
stats: {
|
|
638
|
+
passed: number;
|
|
639
|
+
failed: number;
|
|
640
|
+
blocked: number;
|
|
641
|
+
total: number;
|
|
642
|
+
};
|
|
643
|
+
allPassed: boolean;
|
|
644
|
+
/** Narrative run summary from the analyze pass; null when unavailable. */
|
|
645
|
+
narrative: string | null;
|
|
646
|
+
whatCouldBeBetter: string | null;
|
|
647
|
+
recommendedNextStep: string | null;
|
|
648
|
+
/** Ordered failed → blocked → passed. */
|
|
649
|
+
tests: ExecutionReportTest[];
|
|
650
|
+
/** The execution's Portal page. */
|
|
651
|
+
resultUrl: string;
|
|
652
|
+
}
|
|
653
|
+
/**
|
|
654
|
+
* `ready: false` means the execution is still running or its report is still
|
|
655
|
+
* being built (the build waits for the analyze pass); poll again after
|
|
656
|
+
* `retryAfterSeconds`. `report` and `markdown` are present only when ready.
|
|
657
|
+
*/
|
|
658
|
+
export interface ExecutionReportResponse {
|
|
659
|
+
ready: boolean;
|
|
660
|
+
retryAfterSeconds?: number;
|
|
661
|
+
report?: ExecutionReport;
|
|
662
|
+
/** The report rendered as GitHub-flavoured Markdown — the PR comment body. */
|
|
663
|
+
markdown?: string;
|
|
550
664
|
}
|
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',
|
|
@@ -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
|
}
|
|
@@ -108,9 +104,12 @@ export type TelemetryConflictReason = 'in_flight' | 'insufficient_credits' | 'pa
|
|
|
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
|
-
* integers; enums are closed. Nothing here can carry
|
|
107
|
+
* integers; enums are closed. Nothing here can carry a URL, a message, or an
|
|
108
|
+
* id that names a person or a repository — `executionId` is the server's own
|
|
109
|
+
* opaque UUID for the run, so the event can be joined to the execution's report.
|
|
112
110
|
*/
|
|
113
111
|
export interface TelemetryExtras {
|
|
112
|
+
local?: boolean;
|
|
114
113
|
/** Batch dispatch accounting (`test run --all`, `testlist run`). */
|
|
115
114
|
accepted?: number;
|
|
116
115
|
conflicts?: number;
|
|
@@ -131,7 +130,29 @@ export interface TelemetryExtras {
|
|
|
131
130
|
force?: boolean;
|
|
132
131
|
workflowExisted?: boolean;
|
|
133
132
|
projectResolved?: 'flag' | 'auto';
|
|
133
|
+
/** `ci run` facts: what the gate did, which execution it was, whether the report arrived. */
|
|
134
|
+
ciRunOutcome?: CiRunTelemetryOutcome;
|
|
135
|
+
executionId?: string;
|
|
136
|
+
reportReady?: boolean;
|
|
134
137
|
}
|
|
138
|
+
/**
|
|
139
|
+
* What a `ci run` invocation ended up doing. `gated` = tests were dispatched
|
|
140
|
+
* and the exit code is the verdict; `skipped_*` = nothing to gate (exit 0, no
|
|
141
|
+
* summary); `refused_*` = refused before or at dispatch; `empty` = nothing
|
|
142
|
+
* selected. The funnel step "`ci init` → first gated run" is computed from it.
|
|
143
|
+
*/
|
|
144
|
+
export type CiRunTelemetryOutcome = 'gated' | 'skipped_draft' | 'skipped_no_pr' | 'refused_admission' | 'refused_env' | 'refused_preview_name' | 'refused_loopback' | 'refused_billing' | 'refused_other' | 'empty';
|
|
145
|
+
/**
|
|
146
|
+
* The `ci run` outcome for an API refusal — at the environment pre-check or at
|
|
147
|
+
* the batch dispatch. Every refusal gets a value, so `refused_other` really is
|
|
148
|
+
* "any other refusal": a validation error is split by the server's
|
|
149
|
+
* `details.reason`; a 402/403 (credits, a feature gate) is `refused_billing`;
|
|
150
|
+
* a 401, 429 or anything else is `refused_other`.
|
|
151
|
+
*/
|
|
152
|
+
export declare function ciRefusalOutcome(err: {
|
|
153
|
+
code: string;
|
|
154
|
+
details?: Record<string, unknown>;
|
|
155
|
+
}): CiRunTelemetryOutcome;
|
|
135
156
|
/** What callers may hand the sanitizer: the typed shape, or an arbitrary bag it filters. */
|
|
136
157
|
export type TelemetryExtrasInput = TelemetryExtras | Readonly<Record<string, unknown>>;
|
|
137
158
|
/**
|
|
@@ -148,6 +169,8 @@ export declare function sanitizeTelemetryExtras(partial: TelemetryExtrasInput):
|
|
|
148
169
|
* never widen the wire contract from here.
|
|
149
170
|
*/
|
|
150
171
|
export declare function recordTelemetryExtras(partial: TelemetryExtrasInput): void;
|
|
172
|
+
/** Extend explicit --local telemetry to commands that automatically open a tunnel. */
|
|
173
|
+
export declare function recordTelemetryTunnelOpened(opened: boolean): void;
|
|
151
174
|
/** Return everything recorded so far and clear the sink (one event per process). */
|
|
152
175
|
export declare function takeTelemetryExtras(): TelemetryExtras;
|
|
153
176
|
/**
|
|
@@ -193,7 +216,7 @@ export interface TelemetryEvent extends Partial<WaitTimeoutTelemetry>, Telemetry
|
|
|
193
216
|
nodeVersion?: string;
|
|
194
217
|
output?: string;
|
|
195
218
|
ci?: boolean;
|
|
196
|
-
/** Present (always `true`)
|
|
219
|
+
/** Present (always `true`) for --local attempts or automatically opened tunnels. */
|
|
197
220
|
local?: boolean;
|
|
198
221
|
/** The validated `TESTSPRITE_CLIENT` tag (e.g. `github-action/v1`); absent when unset/invalid. */
|
|
199
222
|
client?: string;
|
package/dist/lib/telemetry.js
CHANGED
|
@@ -14,9 +14,10 @@
|
|
|
14
14
|
* - Opt-out: skipped when `TESTSPRITE_NO_TELEMETRY` or the cross-tool
|
|
15
15
|
* `DO_NOT_TRACK` is set. Also skipped under `--dry-run` (no network) and
|
|
16
16
|
* when no leaf command actually ran (bare `--help` / parse errors).
|
|
17
|
-
* -
|
|
18
|
-
*
|
|
19
|
-
*
|
|
17
|
+
* - On abort (SIGINT/SIGTERM) the event is still sent — `outcome: 'abort'`,
|
|
18
|
+
* through the same bounded flush `index.ts` runs before setting the exit
|
|
19
|
+
* code — and the extras the command recorded before the signal ride along
|
|
20
|
+
* (a cancelled CI gate keeps its `gated` outcome and execution id).
|
|
20
21
|
*
|
|
21
22
|
* Privacy: the event is a fixed allowlist of low-cardinality, PII-free fields.
|
|
22
23
|
* It NEVER carries target URLs, api keys, arg values, error messages, or
|
|
@@ -111,6 +112,26 @@ export function buildCiContext(env) {
|
|
|
111
112
|
...(typeof repo === 'string' && repo !== '' ? { repoHash: hashRepository(repo) } : {}),
|
|
112
113
|
};
|
|
113
114
|
}
|
|
115
|
+
/**
|
|
116
|
+
* The `ci run` outcome for an API refusal — at the environment pre-check or at
|
|
117
|
+
* the batch dispatch. Every refusal gets a value, so `refused_other` really is
|
|
118
|
+
* "any other refusal": a validation error is split by the server's
|
|
119
|
+
* `details.reason`; a 402/403 (credits, a feature gate) is `refused_billing`;
|
|
120
|
+
* a 401, 429 or anything else is `refused_other`.
|
|
121
|
+
*/
|
|
122
|
+
export function ciRefusalOutcome(err) {
|
|
123
|
+
if (err.code === 'VALIDATION_ERROR') {
|
|
124
|
+
const reason = err.details?.reason;
|
|
125
|
+
if (reason === 'preview-name-taken')
|
|
126
|
+
return 'refused_preview_name';
|
|
127
|
+
if (reason === 'private-or-local')
|
|
128
|
+
return 'refused_loopback';
|
|
129
|
+
return 'refused_other';
|
|
130
|
+
}
|
|
131
|
+
if (err.code === 'INSUFFICIENT_CREDITS' || err.code === 'FEATURE_GATED')
|
|
132
|
+
return 'refused_billing';
|
|
133
|
+
return 'refused_other';
|
|
134
|
+
}
|
|
114
135
|
const COUNT_KEYS = [
|
|
115
136
|
'accepted',
|
|
116
137
|
'conflicts',
|
|
@@ -123,7 +144,10 @@ const COUNT_KEYS = [
|
|
|
123
144
|
'localConcurrencyLimit',
|
|
124
145
|
'localPeakInFlight',
|
|
125
146
|
];
|
|
126
|
-
const BOOLEAN_KEYS = ['force', 'workflowExisted'];
|
|
147
|
+
const BOOLEAN_KEYS = ['force', 'workflowExisted', 'local', 'reportReady'];
|
|
148
|
+
/** Opaque server ids the beacon accepts — a UUID, nothing free-form. */
|
|
149
|
+
const UUID_KEYS = ['executionId'];
|
|
150
|
+
const UUID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/;
|
|
127
151
|
const ENUM_KEYS = {
|
|
128
152
|
conflictReason: new Set([
|
|
129
153
|
'in_flight',
|
|
@@ -137,6 +161,18 @@ const ENUM_KEYS = {
|
|
|
137
161
|
]),
|
|
138
162
|
platform: new Set(['github']),
|
|
139
163
|
projectResolved: new Set(['flag', 'auto']),
|
|
164
|
+
ciRunOutcome: new Set([
|
|
165
|
+
'gated',
|
|
166
|
+
'skipped_draft',
|
|
167
|
+
'skipped_no_pr',
|
|
168
|
+
'refused_admission',
|
|
169
|
+
'refused_env',
|
|
170
|
+
'refused_preview_name',
|
|
171
|
+
'refused_loopback',
|
|
172
|
+
'refused_billing',
|
|
173
|
+
'refused_other',
|
|
174
|
+
'empty',
|
|
175
|
+
]),
|
|
140
176
|
};
|
|
141
177
|
/**
|
|
142
178
|
* Keep only the allowlisted keys with a value of the right shape. Pure: this is
|
|
@@ -156,6 +192,11 @@ export function sanitizeTelemetryExtras(partial) {
|
|
|
156
192
|
if (typeof v === 'boolean')
|
|
157
193
|
out[key] = v;
|
|
158
194
|
}
|
|
195
|
+
for (const key of UUID_KEYS) {
|
|
196
|
+
const v = rec[key];
|
|
197
|
+
if (typeof v === 'string' && UUID_RE.test(v))
|
|
198
|
+
out[key] = v;
|
|
199
|
+
}
|
|
159
200
|
for (const key of Object.keys(ENUM_KEYS)) {
|
|
160
201
|
const v = rec[key];
|
|
161
202
|
if (typeof v === 'string' && ENUM_KEYS[key].has(v)) {
|
|
@@ -176,6 +217,11 @@ let pendingExtras = {};
|
|
|
176
217
|
export function recordTelemetryExtras(partial) {
|
|
177
218
|
pendingExtras = { ...pendingExtras, ...sanitizeTelemetryExtras(partial) };
|
|
178
219
|
}
|
|
220
|
+
/** Extend explicit --local telemetry to commands that automatically open a tunnel. */
|
|
221
|
+
export function recordTelemetryTunnelOpened(opened) {
|
|
222
|
+
if (opened)
|
|
223
|
+
recordTelemetryExtras({ local: true });
|
|
224
|
+
}
|
|
179
225
|
/** Return everything recorded so far and clear the sink (one event per process). */
|
|
180
226
|
export function takeTelemetryExtras() {
|
|
181
227
|
const taken = pendingExtras;
|
|
@@ -327,6 +373,8 @@ function isTruthyEnv(v) {
|
|
|
327
373
|
*/
|
|
328
374
|
export function buildTelemetryEvent(input, env, isTTY, extras = {}) {
|
|
329
375
|
const client = resolveClientTag(env);
|
|
376
|
+
const { local: runtimeLocal, ...sanitizedExtras } = sanitizeTelemetryExtras(extras);
|
|
377
|
+
const local = input.local === true || runtimeLocal === true;
|
|
330
378
|
return {
|
|
331
379
|
command: input.command,
|
|
332
380
|
outcome: input.outcome,
|
|
@@ -342,11 +390,11 @@ export function buildTelemetryEvent(input, env, isTTY, extras = {}) {
|
|
|
342
390
|
ci: isTruthyEnv(env.CI) || !isTTY,
|
|
343
391
|
...(client !== undefined ? { client } : {}),
|
|
344
392
|
...buildCiContext(env),
|
|
345
|
-
...(
|
|
393
|
+
...(local ? { local: true } : {}),
|
|
346
394
|
...(input.outcome === 'error' && input.reason === 'wait_timeout'
|
|
347
395
|
? {
|
|
348
396
|
reason: 'wait_timeout',
|
|
349
|
-
...(
|
|
397
|
+
...(local &&
|
|
350
398
|
(input.cancelOutcome === 'cancelled' ||
|
|
351
399
|
input.cancelOutcome === 'already_terminal' ||
|
|
352
400
|
input.cancelOutcome === 'failed' ||
|
|
@@ -355,7 +403,7 @@ export function buildTelemetryEvent(input, env, isTTY, extras = {}) {
|
|
|
355
403
|
: {}),
|
|
356
404
|
}
|
|
357
405
|
: {}),
|
|
358
|
-
...
|
|
406
|
+
...sanitizedExtras,
|
|
359
407
|
};
|
|
360
408
|
}
|
|
361
409
|
/**
|
|
@@ -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
|
package/dist/lib/ticker.js
CHANGED
|
@@ -141,6 +141,7 @@ export function createTicker(stderrWrite, isTTY, stderrRaw, noColor) {
|
|
|
141
141
|
redrawsInPlace: false,
|
|
142
142
|
update: () => undefined,
|
|
143
143
|
finalize: () => undefined,
|
|
144
|
+
note: (line) => stderrWrite(line),
|
|
144
145
|
};
|
|
145
146
|
}
|
|
146
147
|
if (suppressAnsi) {
|
|
@@ -160,6 +161,11 @@ export function createTicker(stderrWrite, isTTY, stderrRaw, noColor) {
|
|
|
160
161
|
}
|
|
161
162
|
void stderrWrite;
|
|
162
163
|
},
|
|
164
|
+
note(line) {
|
|
165
|
+
// Every update is already its own line here; nothing to clear.
|
|
166
|
+
stderrWrite(line);
|
|
167
|
+
lastLength = 0;
|
|
168
|
+
},
|
|
163
169
|
};
|
|
164
170
|
}
|
|
165
171
|
return {
|
|
@@ -179,9 +185,21 @@ export function createTicker(stderrWrite, isTTY, stderrRaw, noColor) {
|
|
|
179
185
|
if (lastLength > 0) {
|
|
180
186
|
// Move to a fresh line so the result block doesn't run into the ticker.
|
|
181
187
|
rawWrite('\n');
|
|
188
|
+
// The live line is gone: a second finalize() (e.g. the failed-stage
|
|
189
|
+
// branch, then the catch-all) must not emit a stray blank line.
|
|
190
|
+
lastLength = 0;
|
|
182
191
|
}
|
|
183
192
|
void stderrWrite; // reference to suppress unused warning
|
|
184
193
|
},
|
|
194
|
+
note(line) {
|
|
195
|
+
// Clear the live progress line (same ESC[2K + \r as update), then
|
|
196
|
+
// print the note with its own newline through the SAME raw writer so
|
|
197
|
+
// ordering is preserved. The next update() redraws below it.
|
|
198
|
+
if (lastLength > 0)
|
|
199
|
+
rawWrite('\x1b[2K\r');
|
|
200
|
+
rawWrite(`${line}\n`);
|
|
201
|
+
lastLength = 0;
|
|
202
|
+
},
|
|
185
203
|
};
|
|
186
204
|
}
|
|
187
205
|
//# sourceMappingURL=ticker.js.map
|
|
@@ -45,10 +45,9 @@ import type { TunnelMintResponse } from './tunnel.types.js';
|
|
|
45
45
|
* How long to wait for the control plane's first successful connection.
|
|
46
46
|
*
|
|
47
47
|
* The vendored client resolves `start()` only on the first
|
|
48
|
-
* `control-
|
|
49
|
-
*
|
|
50
|
-
* control plane
|
|
51
|
-
* command an agent might be driving unattended.
|
|
48
|
+
* `control-authenticated` event. The client also bounds authentication at
|
|
49
|
+
* 10 seconds; this outer deadline bounds the complete connection attempt so an
|
|
50
|
+
* unreachable control plane cannot leave an unattended command hanging.
|
|
52
51
|
*/
|
|
53
52
|
export declare const DEFAULT_TUNNEL_CONNECT_TIMEOUT_MS = 20000;
|
|
54
53
|
/** Maximum time teardown lets a wedged client delay credential deletion. */
|
|
@@ -45,10 +45,9 @@ import { DEFAULT_DATA_PLANE_RETRY_DEADLINE_MS } from '../vendor/tunnel-client/co
|
|
|
45
45
|
* How long to wait for the control plane's first successful connection.
|
|
46
46
|
*
|
|
47
47
|
* The vendored client resolves `start()` only on the first
|
|
48
|
-
* `control-
|
|
49
|
-
*
|
|
50
|
-
* control plane
|
|
51
|
-
* command an agent might be driving unattended.
|
|
48
|
+
* `control-authenticated` event. The client also bounds authentication at
|
|
49
|
+
* 10 seconds; this outer deadline bounds the complete connection attempt so an
|
|
50
|
+
* unreachable control plane cannot leave an unattended command hanging.
|
|
52
51
|
*/
|
|
53
52
|
export const DEFAULT_TUNNEL_CONNECT_TIMEOUT_MS = 20_000;
|
|
54
53
|
/** Maximum time teardown lets a wedged client delay credential deletion. */
|
package/dist/lib/v3-advisory.js
CHANGED
|
@@ -28,7 +28,6 @@ export function routingLabel(v3Enabled) {
|
|
|
28
28
|
*/
|
|
29
29
|
export const V3_ROUTING_ADVISORY = [
|
|
30
30
|
'[advisory] V3 routing is on for this account. While these gaps are open:',
|
|
31
|
-
' - `--target-url` is ignored on frontend runs (the run uses the project environment)',
|
|
32
31
|
' - a frontend rerun replays the run it was pointed at, not necessarily the latest saved code',
|
|
33
32
|
];
|
|
34
33
|
/** Write the advisory to a stderr sink, one line per call. */
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { EventEmitter } from "node:events";
|
|
2
|
-
import { TunnelClientOptions } from "./types.js";
|
|
2
|
+
import { ErrCode, TunnelClientOptions, TunnelTransport } from "./types.js";
|
|
3
3
|
export declare class TunnelClient extends EventEmitter {
|
|
4
4
|
#private;
|
|
5
5
|
private readonly options;
|
|
@@ -11,28 +11,31 @@ export declare class TunnelClient extends EventEmitter {
|
|
|
11
11
|
private controlConnectionGeneration;
|
|
12
12
|
private allowTunnelReconnect;
|
|
13
13
|
private dataPlaneTerminalErrorReported;
|
|
14
|
+
private clientUnknownEpisodeStartedAt?;
|
|
15
|
+
private clientUnknownDeadline?;
|
|
14
16
|
private readonly tunnelRuntimes;
|
|
15
|
-
private
|
|
17
|
+
private lifecycleController;
|
|
18
|
+
private targetDialController;
|
|
16
19
|
private readonly activeTargetSockets;
|
|
17
20
|
constructor(options: TunnelClientOptions);
|
|
18
|
-
get transport():
|
|
21
|
+
get transport(): TunnelTransport;
|
|
19
22
|
start(): Promise<void>;
|
|
20
23
|
stop(): Promise<void>;
|
|
21
24
|
private runControlLoop;
|
|
25
|
+
private openClientUnknownEpisode;
|
|
26
|
+
private clearClientUnknownEpisode;
|
|
22
27
|
private runTunnelLoop;
|
|
23
28
|
private connectControl;
|
|
24
29
|
private sendControlMessage;
|
|
25
30
|
private parseControlMessage;
|
|
26
31
|
private ensureTunnelRuntime;
|
|
27
32
|
private connectTunnel;
|
|
28
|
-
private
|
|
29
|
-
private
|
|
33
|
+
private connectDataPlane;
|
|
34
|
+
private openDataPlaneFailureEpisode;
|
|
30
35
|
private expireDataPlaneFailureEpisode;
|
|
31
|
-
private markDataPlaneEstablished;
|
|
32
|
-
private clearDataPlaneAttemptTimers;
|
|
33
36
|
private clearDataPlaneFailureEpisode;
|
|
37
|
+
private clearAttemptTimers;
|
|
34
38
|
private stopAllTunnelRuntimes;
|
|
35
|
-
private beginStop;
|
|
36
39
|
private handleIncomingStream;
|
|
37
40
|
private proxyStreams;
|
|
38
41
|
private copyOneWay;
|
|
@@ -84,6 +87,10 @@ export declare function ensureTargetAllowed(host: string, port: number, candidat
|
|
|
84
87
|
host: string;
|
|
85
88
|
port: number;
|
|
86
89
|
}>, allowPrivateNetwork: boolean): void;
|
|
90
|
+
export declare class ClientUnknownError extends Error {
|
|
91
|
+
readonly code = ErrCode.ClientUnknown;
|
|
92
|
+
constructor(deadlineMs: number);
|
|
93
|
+
}
|
|
87
94
|
/**
|
|
88
95
|
* Thrown by {@link ensureTargetAllowed} when a proxied target resolves into a blocked
|
|
89
96
|
* (private/internal) range. Mirrors the Rust client's `ensure_candidates_allowed` error.
|