@testsprite/testsprite-cli 0.3.0 → 0.5.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 +55 -29
- package/dist/commands/agent.js +17 -6
- package/dist/commands/auth.d.ts +51 -0
- package/dist/commands/auth.js +46 -2
- package/dist/commands/completion.d.ts +36 -0
- package/dist/commands/completion.js +111 -0
- package/dist/commands/doctor.js +56 -16
- package/dist/commands/init.d.ts +32 -1
- package/dist/commands/init.js +40 -10
- package/dist/commands/project.d.ts +102 -4
- package/dist/commands/project.js +250 -47
- package/dist/commands/test.d.ts +253 -11
- package/dist/commands/test.js +1822 -390
- package/dist/commands/usage.d.ts +56 -17
- package/dist/commands/usage.js +144 -29
- package/dist/index.js +172 -29
- package/dist/lib/browser.d.ts +6 -0
- package/dist/lib/browser.js +54 -0
- package/dist/lib/bundle.d.ts +32 -31
- package/dist/lib/bundle.js +144 -84
- package/dist/lib/client-factory.d.ts +29 -0
- package/dist/lib/client-factory.js +49 -1
- package/dist/lib/config.js +7 -3
- package/dist/lib/credentials.d.ts +17 -1
- package/dist/lib/credentials.js +175 -16
- package/dist/lib/dry-run/samples.js +51 -1
- package/dist/lib/errors.d.ts +33 -1
- package/dist/lib/errors.js +110 -19
- package/dist/lib/failing-fe-resolver.d.ts +15 -0
- package/dist/lib/failing-fe-resolver.js +49 -1
- package/dist/lib/flaky.d.ts +12 -1
- package/dist/lib/flaky.js +7 -12
- package/dist/lib/gh-output.d.ts +62 -0
- package/dist/lib/gh-output.js +99 -0
- package/dist/lib/http.d.ts +86 -16
- package/dist/lib/http.js +181 -11
- package/dist/lib/interrupt.d.ts +65 -10
- package/dist/lib/interrupt.js +94 -9
- package/dist/lib/org-render.d.ts +52 -0
- package/dist/lib/org-render.js +59 -0
- package/dist/lib/poll.d.ts +11 -0
- package/dist/lib/poll.js +71 -6
- package/dist/lib/render-error.d.ts +14 -0
- package/dist/lib/render-error.js +30 -0
- package/dist/lib/response-schemas.d.ts +83 -0
- package/dist/lib/response-schemas.js +272 -0
- package/dist/lib/runs.types.d.ts +62 -8
- package/dist/lib/skill-nudge.d.ts +17 -0
- package/dist/lib/skill-nudge.js +19 -0
- package/dist/lib/telemetry.d.ts +90 -0
- package/dist/lib/telemetry.js +171 -0
- package/dist/lib/text-table.d.ts +14 -0
- package/dist/lib/text-table.js +45 -0
- package/dist/lib/v3-advisory.d.ts +22 -0
- package/dist/lib/v3-advisory.js +32 -0
- package/dist/lib/version-notice.d.ts +37 -0
- package/dist/lib/version-notice.js +87 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +16 -5
- package/schemas/plan.schema.json +61 -0
- package/skills/testsprite-verify.codex.md +8 -2
- package/skills/testsprite-verify.skill.md +18 -7
package/dist/lib/flaky.d.ts
CHANGED
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
* (deterministic, no network / credentials), matching the repo's mock-based
|
|
9
9
|
* test convention.
|
|
10
10
|
*/
|
|
11
|
+
import type { RerunAdvisory } from './runs.types.js';
|
|
11
12
|
/**
|
|
12
13
|
* Outcome of a single flaky-detector attempt. The first four mirror the
|
|
13
14
|
* terminal `RunStatus` values; `timeout` and `error` are orchestration
|
|
@@ -55,6 +56,16 @@ export interface FlakyReport {
|
|
|
55
56
|
verdict: FlakyVerdict;
|
|
56
57
|
/** Non-passing attempts, in attempt order. */
|
|
57
58
|
failures: FlakyFailure[];
|
|
59
|
+
/**
|
|
60
|
+
* Server-side advisories collected across all replay attempts and deduped
|
|
61
|
+
* (by `feature`+`message`) — surfaced ONCE per probe, not once per attempt.
|
|
62
|
+
* Empty when the server sent none, which is the common case: absent on
|
|
63
|
+
* every V2 response and every V3 response that isn't a V3-routed rerun
|
|
64
|
+
* with an explicit `autoHeal:false` opt-out (see `RerunAdvisory`). `test
|
|
65
|
+
* flaky` always sends `autoHeal:false`, so this is populated whenever the
|
|
66
|
+
* probe's reruns are routed to V3.
|
|
67
|
+
*/
|
|
68
|
+
advisories: RerunAdvisory[];
|
|
58
69
|
}
|
|
59
70
|
/**
|
|
60
71
|
* Aggregate per-attempt outcomes into a stability report.
|
|
@@ -66,7 +77,7 @@ export interface FlakyReport {
|
|
|
66
77
|
* An empty attempt list (no runs observed) is reported as `failing` with a
|
|
67
78
|
* `0` ratio — there is no evidence the test is stable.
|
|
68
79
|
*/
|
|
69
|
-
export declare function summarizeFlaky(testId: string, attempts: FlakyAttempt[]): FlakyReport;
|
|
80
|
+
export declare function summarizeFlaky(testId: string, attempts: FlakyAttempt[], advisories?: RerunAdvisory[]): FlakyReport;
|
|
70
81
|
/**
|
|
71
82
|
* Exit code for the command: `0` only when the verdict is `stable` (every
|
|
72
83
|
* observed attempt passed). Anything else is non-zero so CI can gate a merge
|
package/dist/lib/flaky.js
CHANGED
|
@@ -1,13 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Pure aggregation + rendering for `test flaky` — the repeat-run flaky-test
|
|
3
|
-
* detector. This module performs no I/O: the orchestrator in
|
|
4
|
-
* `commands/test.ts` feeds it the per-attempt outcomes, and it returns a
|
|
5
|
-
* machine-readable stability report plus the text rendering and exit code.
|
|
6
|
-
*
|
|
7
|
-
* Keeping the scoring logic pure makes it trivially unit-testable in isolation
|
|
8
|
-
* (deterministic, no network / credentials), matching the repo's mock-based
|
|
9
|
-
* test convention.
|
|
10
|
-
*/
|
|
11
1
|
/**
|
|
12
2
|
* Aggregate per-attempt outcomes into a stability report.
|
|
13
3
|
*
|
|
@@ -18,7 +8,7 @@
|
|
|
18
8
|
* An empty attempt list (no runs observed) is reported as `failing` with a
|
|
19
9
|
* `0` ratio — there is no evidence the test is stable.
|
|
20
10
|
*/
|
|
21
|
-
export function summarizeFlaky(testId, attempts) {
|
|
11
|
+
export function summarizeFlaky(testId, attempts, advisories = []) {
|
|
22
12
|
const runs = attempts.length;
|
|
23
13
|
const passed = attempts.filter(a => a.outcome === 'passed').length;
|
|
24
14
|
const failed = runs - passed;
|
|
@@ -32,7 +22,7 @@ export function summarizeFlaky(testId, attempts) {
|
|
|
32
22
|
outcome: a.outcome,
|
|
33
23
|
failureKind: a.failureKind ?? null,
|
|
34
24
|
}));
|
|
35
|
-
return { testId, runs, passed, failed, stableRatio, verdict, failures };
|
|
25
|
+
return { testId, runs, passed, failed, stableRatio, verdict, failures, advisories };
|
|
36
26
|
}
|
|
37
27
|
/**
|
|
38
28
|
* Exit code for the command: `0` only when the verdict is `stable` (every
|
|
@@ -71,6 +61,11 @@ export function renderFlakyText(report) {
|
|
|
71
61
|
lines.push(` #${f.attempt} ${rid} ${f.outcome}${kind}`);
|
|
72
62
|
}
|
|
73
63
|
}
|
|
64
|
+
if (report.advisories.length > 0) {
|
|
65
|
+
for (const advisory of report.advisories) {
|
|
66
|
+
lines.push(` [advisory] ${advisory.message}`);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
74
69
|
return lines.join('\n');
|
|
75
70
|
}
|
|
76
71
|
//# sourceMappingURL=flaky.js.map
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CI-native output layer for the batch run path (issue #99, reshaped from
|
|
3
|
+
* the withdrawn top-level `ci` command per the #264 review).
|
|
4
|
+
*
|
|
5
|
+
* `test run --all --wait` presents its result in the formats CI consumes:
|
|
6
|
+
* (a) a stable machine summary `{total, passed, failed, timedOut, runs[]}`
|
|
7
|
+
* written to `--summary-file <path>` when requested,
|
|
8
|
+
* (b) a Markdown results table appended to `$GITHUB_STEP_SUMMARY` when
|
|
9
|
+
* running under GitHub Actions,
|
|
10
|
+
* (c) one `::error::` workflow-command line per non-passed run so failures
|
|
11
|
+
* annotate the PR checks tab.
|
|
12
|
+
* Activation: `GITHUB_ACTIONS=true` in the environment, or the explicit
|
|
13
|
+
* `--gh-output` flag (which forces the annotations even off-Actions, so the
|
|
14
|
+
* behavior is previewable locally). All writes are best-effort: a broken
|
|
15
|
+
* summary file must never mask the batch gate's exit code.
|
|
16
|
+
*/
|
|
17
|
+
export interface CiRunRow {
|
|
18
|
+
testId: string;
|
|
19
|
+
runId?: string;
|
|
20
|
+
status: string;
|
|
21
|
+
dashboardUrl?: string;
|
|
22
|
+
error?: string;
|
|
23
|
+
}
|
|
24
|
+
export interface CiSummary {
|
|
25
|
+
total: number;
|
|
26
|
+
passed: number;
|
|
27
|
+
failed: number;
|
|
28
|
+
timedOut: number;
|
|
29
|
+
runs: CiRunRow[];
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Reduce the batch command's JSON payload into the CI summary. The parse is
|
|
33
|
+
* defensive: it reads the same `accepted[]` rows the automation contract
|
|
34
|
+
* documents, and anything unparseable (dry-run envelope, partial output
|
|
35
|
+
* after a timeout) reduces to an empty run list rather than a crash.
|
|
36
|
+
*/
|
|
37
|
+
export declare function summarizeAcceptedPayload(capturedJson: string): CiSummary;
|
|
38
|
+
/** Markdown table for the GitHub job summary. */
|
|
39
|
+
export declare function renderJobSummaryMarkdown(summary: CiSummary): string;
|
|
40
|
+
/**
|
|
41
|
+
* Emit the GitHub-native surfaces. Self-gating on the standard env vars:
|
|
42
|
+
* `$GITHUB_STEP_SUMMARY` (a file path Actions provides) receives the Markdown
|
|
43
|
+
* table; `GITHUB_ACTIONS=true` enables one `::error::` workflow command per
|
|
44
|
+
* non-passed run on stdout (Actions parses workflow commands from stdout).
|
|
45
|
+
* `force` (the `--gh-output` flag) emits the annotations even off-Actions;
|
|
46
|
+
* the step summary still requires the env-provided file path to exist.
|
|
47
|
+
* Both writes are best-effort: a broken summary file must not mask the gate.
|
|
48
|
+
*/
|
|
49
|
+
export declare function emitGithubOutputs(summary: CiSummary, env: NodeJS.ProcessEnv, sinks: {
|
|
50
|
+
stdout: (line: string) => void;
|
|
51
|
+
stderr: (line: string) => void;
|
|
52
|
+
appendFile: (path: string, content: string) => void;
|
|
53
|
+
/**
|
|
54
|
+
* Where `::error::` workflow-command lines go. Defaults to `stdout`; the
|
|
55
|
+
* caller passes stderr under `--output json` so the machine envelope on
|
|
56
|
+
* stdout stays parseable (the Actions runner processes workflow commands
|
|
57
|
+
* on both streams).
|
|
58
|
+
*/
|
|
59
|
+
annotations?: (line: string) => void;
|
|
60
|
+
}, opts?: {
|
|
61
|
+
force?: boolean;
|
|
62
|
+
}): void;
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CI-native output layer for the batch run path (issue #99, reshaped from
|
|
3
|
+
* the withdrawn top-level `ci` command per the #264 review).
|
|
4
|
+
*
|
|
5
|
+
* `test run --all --wait` presents its result in the formats CI consumes:
|
|
6
|
+
* (a) a stable machine summary `{total, passed, failed, timedOut, runs[]}`
|
|
7
|
+
* written to `--summary-file <path>` when requested,
|
|
8
|
+
* (b) a Markdown results table appended to `$GITHUB_STEP_SUMMARY` when
|
|
9
|
+
* running under GitHub Actions,
|
|
10
|
+
* (c) one `::error::` workflow-command line per non-passed run so failures
|
|
11
|
+
* annotate the PR checks tab.
|
|
12
|
+
* Activation: `GITHUB_ACTIONS=true` in the environment, or the explicit
|
|
13
|
+
* `--gh-output` flag (which forces the annotations even off-Actions, so the
|
|
14
|
+
* behavior is previewable locally). All writes are best-effort: a broken
|
|
15
|
+
* summary file must never mask the batch gate's exit code.
|
|
16
|
+
*/
|
|
17
|
+
/**
|
|
18
|
+
* Reduce the batch command's JSON payload into the CI summary. The parse is
|
|
19
|
+
* defensive: it reads the same `accepted[]` rows the automation contract
|
|
20
|
+
* documents, and anything unparseable (dry-run envelope, partial output
|
|
21
|
+
* after a timeout) reduces to an empty run list rather than a crash.
|
|
22
|
+
*/
|
|
23
|
+
export function summarizeAcceptedPayload(capturedJson) {
|
|
24
|
+
let parsed;
|
|
25
|
+
try {
|
|
26
|
+
parsed = JSON.parse(capturedJson);
|
|
27
|
+
}
|
|
28
|
+
catch {
|
|
29
|
+
// Not JSON at all (dry-run banner path or truncated output): no rows.
|
|
30
|
+
parsed = undefined;
|
|
31
|
+
}
|
|
32
|
+
// `JSON.parse('null')` and non-object payloads are valid JSON but carry no
|
|
33
|
+
// batch envelope — treat them like unparseable input instead of crashing.
|
|
34
|
+
const payload = parsed !== null && typeof parsed === 'object' ? parsed : {};
|
|
35
|
+
const rows = Array.isArray(payload.accepted)
|
|
36
|
+
? payload.accepted
|
|
37
|
+
.filter((entry) => entry !== null && typeof entry === 'object')
|
|
38
|
+
.map(row => {
|
|
39
|
+
const errorMessage = row.error !== null && typeof row.error === 'object'
|
|
40
|
+
? row.error.message
|
|
41
|
+
: undefined;
|
|
42
|
+
return {
|
|
43
|
+
testId: String(row.testId ?? ''),
|
|
44
|
+
...(typeof row.runId === 'string' ? { runId: row.runId } : {}),
|
|
45
|
+
status: String(row.status ?? 'unknown'),
|
|
46
|
+
...(typeof row.dashboardUrl === 'string' ? { dashboardUrl: row.dashboardUrl } : {}),
|
|
47
|
+
...(typeof errorMessage === 'string' ? { error: errorMessage } : {}),
|
|
48
|
+
};
|
|
49
|
+
})
|
|
50
|
+
: [];
|
|
51
|
+
const passed = rows.filter(row => row.status === 'passed').length;
|
|
52
|
+
const timedOut = rows.filter(row => row.status === 'timeout').length;
|
|
53
|
+
const failed = rows.length - passed - timedOut;
|
|
54
|
+
return { total: rows.length, passed, failed, timedOut, runs: rows };
|
|
55
|
+
}
|
|
56
|
+
/** Markdown table for the GitHub job summary. */
|
|
57
|
+
export function renderJobSummaryMarkdown(summary) {
|
|
58
|
+
return [
|
|
59
|
+
'## TestSprite results',
|
|
60
|
+
'',
|
|
61
|
+
`**${summary.passed}/${summary.total} passed** (${summary.failed} failed, ${summary.timedOut} timed out)`,
|
|
62
|
+
'',
|
|
63
|
+
'| Test | Status | Run |',
|
|
64
|
+
'| --- | --- | --- |',
|
|
65
|
+
...summary.runs.map(row => `| ${row.testId} | ${row.status} | ${row.dashboardUrl ? `[dashboard](${row.dashboardUrl})` : (row.runId ?? '')} |`),
|
|
66
|
+
'',
|
|
67
|
+
].join('\n');
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Emit the GitHub-native surfaces. Self-gating on the standard env vars:
|
|
71
|
+
* `$GITHUB_STEP_SUMMARY` (a file path Actions provides) receives the Markdown
|
|
72
|
+
* table; `GITHUB_ACTIONS=true` enables one `::error::` workflow command per
|
|
73
|
+
* non-passed run on stdout (Actions parses workflow commands from stdout).
|
|
74
|
+
* `force` (the `--gh-output` flag) emits the annotations even off-Actions;
|
|
75
|
+
* the step summary still requires the env-provided file path to exist.
|
|
76
|
+
* Both writes are best-effort: a broken summary file must not mask the gate.
|
|
77
|
+
*/
|
|
78
|
+
export function emitGithubOutputs(summary, env, sinks, opts = {}) {
|
|
79
|
+
const summaryPath = env.GITHUB_STEP_SUMMARY;
|
|
80
|
+
if (typeof summaryPath === 'string' && summaryPath.length > 0) {
|
|
81
|
+
try {
|
|
82
|
+
sinks.appendFile(summaryPath, renderJobSummaryMarkdown(summary));
|
|
83
|
+
}
|
|
84
|
+
catch {
|
|
85
|
+
sinks.stderr('[run] could not append to GITHUB_STEP_SUMMARY; continuing');
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
if (env.GITHUB_ACTIONS === 'true' || opts.force === true) {
|
|
89
|
+
const annotate = sinks.annotations ?? sinks.stdout;
|
|
90
|
+
for (const row of summary.runs) {
|
|
91
|
+
if (row.status === 'passed')
|
|
92
|
+
continue;
|
|
93
|
+
const detail = row.error !== undefined ? ` ${row.error}` : '';
|
|
94
|
+
const link = row.dashboardUrl !== undefined ? ` ${row.dashboardUrl}` : '';
|
|
95
|
+
annotate(`::error title=TestSprite ${row.testId}::status=${row.status}${detail}${link}`);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
//# sourceMappingURL=gh-output.js.map
|
package/dist/lib/http.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import * as v from 'valibot';
|
|
1
2
|
import type { ErrorCode } from './errors.js';
|
|
2
3
|
import { ApiError } from './errors.js';
|
|
3
|
-
import type { TriggerRunBody, TriggerRunResponse, RunResponse, RerunRequest, RerunResponse, BatchRerunRequest, BatchRerunResponse, BatchRunFreshRequest, BatchRunFreshResponse, ListRunsQuery, ListRunsResponse } from './runs.types.js';
|
|
4
|
+
import type { TriggerRunBody, TriggerRunResponse, RunResponse, RerunRequest, RerunResponse, BatchRerunRequest, BatchRerunResponse, BatchRunFreshRequest, BatchRunFreshResponse, ListRunsQuery, ListRunsResponse, CancelRunResponse } from './runs.types.js';
|
|
4
5
|
export type FetchImpl = typeof globalThis.fetch;
|
|
5
6
|
export type DebugEventKind = 'request' | 'response' | 'retry' | 'error';
|
|
6
7
|
export interface DebugEvent {
|
|
@@ -53,6 +54,16 @@ export interface HttpClientOptions {
|
|
|
53
54
|
* Stays silent when absent; wired to stderr at `--verbose` level.
|
|
54
55
|
*/
|
|
55
56
|
onTransition?: (msg: string) => void;
|
|
57
|
+
/**
|
|
58
|
+
* Optional callback fired with the backend's supported-floor header
|
|
59
|
+
* (`X-TestSprite-CLI-Min-Version`) when present on a response. Fires on both
|
|
60
|
+
* success and error responses. The client forwards the value verbatim — it
|
|
61
|
+
* applies no policy itself; the caller (client-factory) decides whether to
|
|
62
|
+
* warn the user.
|
|
63
|
+
*/
|
|
64
|
+
onServerVersion?: (info: {
|
|
65
|
+
minVersion?: string;
|
|
66
|
+
}) => void;
|
|
56
67
|
/**
|
|
57
68
|
* Per-request wall-clock timeout in milliseconds applied to every outgoing
|
|
58
69
|
* fetch. The signal fires independently of any caller-supplied signal — the
|
|
@@ -66,11 +77,37 @@ export interface HttpClientOptions {
|
|
|
66
77
|
* request is well within the 120s default.
|
|
67
78
|
*/
|
|
68
79
|
requestTimeoutMs?: number;
|
|
80
|
+
/**
|
|
81
|
+
* Process-lifetime shutdown signal (DEV-331 piece 1). Composed into every
|
|
82
|
+
* outgoing fetch so an armed SIGINT/SIGTERM aborts an in-flight request
|
|
83
|
+
* (a `--wait` long-poll can sit inside a single fetch for minutes) instead
|
|
84
|
+
* of waiting out its window. Aborts with an `InterruptError` reason, which
|
|
85
|
+
* is classified before the timeout-vs-caller logic and is never retried or
|
|
86
|
+
* re-wrapped as `TransportError`. Defaults off; production wiring passes
|
|
87
|
+
* `globalShutdown.signal` via the client factory.
|
|
88
|
+
*/
|
|
89
|
+
shutdownSignal?: AbortSignal;
|
|
69
90
|
}
|
|
70
|
-
export interface RequestOptions {
|
|
91
|
+
export interface RequestOptions<T = unknown> {
|
|
71
92
|
query?: Record<string, string | number | boolean | undefined>;
|
|
72
93
|
signal?: AbortSignal;
|
|
73
94
|
requestId?: string;
|
|
95
|
+
/**
|
|
96
|
+
* Optional valibot schema for the parsed 2xx response body (issue #102).
|
|
97
|
+
*
|
|
98
|
+
* When present, `requestWithMeta` runs `v.safeParse` on the OK-path JSON:
|
|
99
|
+
* success returns the parsed output (unknown extra keys preserved via
|
|
100
|
+
* `looseObject`); failure throws an INTERNAL `ApiError` envelope naming the
|
|
101
|
+
* request path and the first {@link MAX_SCHEMA_ISSUES_IN_DETAILS} mismatched
|
|
102
|
+
* field paths (never the body itself). When absent, behavior is unchanged:
|
|
103
|
+
* the body is returned via the historical blind `as T` cast.
|
|
104
|
+
*
|
|
105
|
+
* Wired by the typed run helpers only (`triggerRun`, `triggerRunWithMeta`,
|
|
106
|
+
* `triggerRerun`, `triggerBatchRerun`, `triggerBatchRunFresh`, `getRun`,
|
|
107
|
+
* `listTestRuns`); generic `get`/`post`/... callers stay opt-in.
|
|
108
|
+
* sourceRef: response-schemas.ts.
|
|
109
|
+
*/
|
|
110
|
+
schema?: v.GenericSchema<unknown, T>;
|
|
74
111
|
/**
|
|
75
112
|
* Optional JSON body for non-GET requests. Serialized with
|
|
76
113
|
* `JSON.stringify`; `Content-Type: application/json` is auto-attached
|
|
@@ -126,23 +163,33 @@ export declare class HttpClient {
|
|
|
126
163
|
private readonly random;
|
|
127
164
|
private readonly onDebug?;
|
|
128
165
|
private readonly onTransition?;
|
|
166
|
+
private readonly onServerVersion?;
|
|
129
167
|
private readonly requestTimeoutMs;
|
|
168
|
+
private readonly shutdownSignal?;
|
|
130
169
|
constructor(options: HttpClientOptions);
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
170
|
+
/**
|
|
171
|
+
* Read the backend's supported-floor header off a response and forward it to
|
|
172
|
+
* `onServerVersion` when present. Never throws — a bad header must not break
|
|
173
|
+
* the request. Called on every response (success or error) so the advisory
|
|
174
|
+
* covers all paths. (The backend advertises only the floor; "latest" is
|
|
175
|
+
* resolved client-side via the npm update-notice.)
|
|
176
|
+
*/
|
|
177
|
+
private captureServerVersion;
|
|
178
|
+
get<T>(path: string, options?: RequestOptions<T>): Promise<T>;
|
|
179
|
+
post<T>(path: string, options?: RequestOptions<T>): Promise<T>;
|
|
180
|
+
put<T>(path: string, options?: RequestOptions<T>): Promise<T>;
|
|
181
|
+
patch<T>(path: string, options?: RequestOptions<T>): Promise<T>;
|
|
182
|
+
delete<T>(path: string, options?: RequestOptions<T>): Promise<T>;
|
|
136
183
|
/**
|
|
137
184
|
* Like `get` / `post` / etc. but returns the full `RequestResult` including
|
|
138
185
|
* `requestId` and `status`, so callers can surface the requestId in
|
|
139
186
|
* happy-path output (dogfood item 1).
|
|
140
187
|
*/
|
|
141
|
-
getWithMeta<T>(path: string, options?: RequestOptions): Promise<RequestResult<T>>;
|
|
142
|
-
postWithMeta<T>(path: string, options?: RequestOptions): Promise<RequestResult<T>>;
|
|
143
|
-
putWithMeta<T>(path: string, options?: RequestOptions): Promise<RequestResult<T>>;
|
|
144
|
-
patchWithMeta<T>(path: string, options?: RequestOptions): Promise<RequestResult<T>>;
|
|
145
|
-
deleteWithMeta<T>(path: string, options?: RequestOptions): Promise<RequestResult<T>>;
|
|
188
|
+
getWithMeta<T>(path: string, options?: RequestOptions<T>): Promise<RequestResult<T>>;
|
|
189
|
+
postWithMeta<T>(path: string, options?: RequestOptions<T>): Promise<RequestResult<T>>;
|
|
190
|
+
putWithMeta<T>(path: string, options?: RequestOptions<T>): Promise<RequestResult<T>>;
|
|
191
|
+
patchWithMeta<T>(path: string, options?: RequestOptions<T>): Promise<RequestResult<T>>;
|
|
192
|
+
deleteWithMeta<T>(path: string, options?: RequestOptions<T>): Promise<RequestResult<T>>;
|
|
146
193
|
/**
|
|
147
194
|
* POST /api/cli/v1/tests/{testId}/runs
|
|
148
195
|
* Trigger a run and return the queued-run envelope.
|
|
@@ -172,8 +219,9 @@ export declare class HttpClient {
|
|
|
172
219
|
}): Promise<RequestResult<TriggerRunResponse>>;
|
|
173
220
|
/**
|
|
174
221
|
* POST /api/cli/v1/tests/{testId}/runs/rerun
|
|
175
|
-
* Trigger a rerun (replay) for a single test. FE: verbatim script replay
|
|
176
|
-
*
|
|
222
|
+
* Trigger a rerun (replay) for a single test. FE: verbatim script replay, billed at
|
|
223
|
+
* 0.5 credits (same as a fresh run; legacy V2 accounts: free). BE: dependency-closure
|
|
224
|
+
* re-run, billed at 0.2 credits. Returns `runId` + optional `closure` (BE).
|
|
177
225
|
*
|
|
178
226
|
* `retryOnConflict: false` — 409 on rerun means the test is already in-flight,
|
|
179
227
|
* a persistent condition. Retrying would race against the running test.
|
|
@@ -232,6 +280,20 @@ export declare class HttpClient {
|
|
|
232
280
|
includeSteps?: boolean;
|
|
233
281
|
signal?: AbortSignal;
|
|
234
282
|
}): Promise<RunResponse>;
|
|
283
|
+
/**
|
|
284
|
+
* POST /api/cli/v1/runs/{runId}/cancel
|
|
285
|
+
* User-initiated cancel of a queued/running run (DEV-331 piece 3). No
|
|
286
|
+
* body, no `Idempotency-Key` — the endpoint is naturally idempotent (D10):
|
|
287
|
+
* re-cancel → 200 `alreadyCancelled: true`; already-terminal (passed/
|
|
288
|
+
* failed/blocked) → 409 CONFLICT; unknown/cross-tenant runId → 404.
|
|
289
|
+
*
|
|
290
|
+
* `retryOnConflict: false` — same rationale as `triggerRun`: a 409 here is
|
|
291
|
+
* a truthful terminal answer ("already finished"), not a transient
|
|
292
|
+
* snapshot conflict to paper over with a retry.
|
|
293
|
+
*/
|
|
294
|
+
cancelRun(runId: string, options?: {
|
|
295
|
+
signal?: AbortSignal;
|
|
296
|
+
}): Promise<CancelRunResponse>;
|
|
235
297
|
/**
|
|
236
298
|
* Classify an error thrown while issuing OR reading a request. When it is an
|
|
237
299
|
* abort/timeout and our per-request timeout signal fired (and the caller had
|
|
@@ -241,8 +303,16 @@ export declare class HttpClient {
|
|
|
241
303
|
* continue its own error handling (transport retry / envelope parse).
|
|
242
304
|
*/
|
|
243
305
|
private rethrowIfAbort;
|
|
244
|
-
requestWithMeta<T>(method: string, path: string, options?: RequestOptions): Promise<RequestResult<T>>;
|
|
306
|
+
requestWithMeta<T>(method: string, path: string, options?: RequestOptions<T>): Promise<RequestResult<T>>;
|
|
245
307
|
private buildHeaders;
|
|
308
|
+
/**
|
|
309
|
+
* Retry-delay sleep that bails the moment the shutdown signal fires
|
|
310
|
+
* (DEV-331, codex finding 1): a RATE_LIMITED `Retry-After: 60` or a
|
|
311
|
+
* transport backoff must not delay the honest-detach exit by up to a
|
|
312
|
+
* minute — reject with the InterruptError reason immediately. Mirrors
|
|
313
|
+
* poll.ts::sleepUnlessInterrupted.
|
|
314
|
+
*/
|
|
315
|
+
private sleepBeforeRetry;
|
|
246
316
|
private debug;
|
|
247
317
|
private transition;
|
|
248
318
|
/**
|
|
@@ -250,7 +320,7 @@ export declare class HttpClient {
|
|
|
250
320
|
* `client.request(...)` directly. New callers should use
|
|
251
321
|
* `requestWithMeta` or the typed helpers (`get`, `post`, etc.).
|
|
252
322
|
*/
|
|
253
|
-
request<T>(method: string, path: string, options?: RequestOptions): Promise<T>;
|
|
323
|
+
request<T>(method: string, path: string, options?: RequestOptions<T>): Promise<T>;
|
|
254
324
|
}
|
|
255
325
|
export declare function buildUrl(baseUrl: string, path: string, query?: Record<string, string | number | boolean | undefined>): string;
|
|
256
326
|
/**
|