@testsprite/testsprite-cli 0.1.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/LICENSE +201 -0
- package/README.md +190 -0
- package/dist/assets/agent-skill/testsprite-verify.codex.md +119 -0
- package/dist/assets/agent-skill/testsprite-verify.skill.md +423 -0
- package/dist/commands/agent.d.ts +51 -0
- package/dist/commands/agent.js +552 -0
- package/dist/commands/auth.d.ts +38 -0
- package/dist/commands/auth.js +247 -0
- package/dist/commands/init.d.ts +63 -0
- package/dist/commands/init.js +350 -0
- package/dist/commands/project.d.ts +72 -0
- package/dist/commands/project.js +400 -0
- package/dist/commands/test.d.ts +1245 -0
- package/dist/commands/test.js +6214 -0
- package/dist/commands/usage.d.ts +63 -0
- package/dist/commands/usage.js +156 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +146 -0
- package/dist/lib/agent-targets.d.ts +50 -0
- package/dist/lib/agent-targets.js +99 -0
- package/dist/lib/bundle.d.ts +178 -0
- package/dist/lib/bundle.js +600 -0
- package/dist/lib/client-factory.d.ts +72 -0
- package/dist/lib/client-factory.js +120 -0
- package/dist/lib/config.d.ts +24 -0
- package/dist/lib/config.js +30 -0
- package/dist/lib/credentials.d.ts +17 -0
- package/dist/lib/credentials.js +122 -0
- package/dist/lib/dry-run/fetch.d.ts +18 -0
- package/dist/lib/dry-run/fetch.js +52 -0
- package/dist/lib/dry-run/samples.d.ts +50 -0
- package/dist/lib/dry-run/samples.js +676 -0
- package/dist/lib/errors.d.ts +118 -0
- package/dist/lib/errors.js +388 -0
- package/dist/lib/facade.d.ts +48 -0
- package/dist/lib/facade.js +104 -0
- package/dist/lib/failing-fe-resolver.d.ts +60 -0
- package/dist/lib/failing-fe-resolver.js +103 -0
- package/dist/lib/http.d.ts +255 -0
- package/dist/lib/http.js +608 -0
- package/dist/lib/output.d.ts +55 -0
- package/dist/lib/output.js +70 -0
- package/dist/lib/pagination.d.ts +56 -0
- package/dist/lib/pagination.js +81 -0
- package/dist/lib/poll.d.ts +88 -0
- package/dist/lib/poll.js +221 -0
- package/dist/lib/prompt.d.ts +8 -0
- package/dist/lib/prompt.js +97 -0
- package/dist/lib/rate-throttle.d.ts +49 -0
- package/dist/lib/rate-throttle.js +75 -0
- package/dist/lib/render-error.d.ts +15 -0
- package/dist/lib/render-error.js +44 -0
- package/dist/lib/runs.types.d.ts +344 -0
- package/dist/lib/runs.types.js +25 -0
- package/dist/lib/target-url.d.ts +25 -0
- package/dist/lib/target-url.js +127 -0
- package/dist/lib/ticker.d.ts +37 -0
- package/dist/lib/ticker.js +63 -0
- package/dist/lib/validate.d.ts +82 -0
- package/dist/lib/validate.js +165 -0
- package/dist/version.d.ts +1 -0
- package/dist/version.js +2 -0
- package/package.json +65 -0
|
@@ -0,0 +1,1245 @@
|
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
import { type CommonOptions as FactoryCommonOptions } from '../lib/client-factory.js';
|
|
3
|
+
import { type WriteBundleResult } from '../lib/bundle.js';
|
|
4
|
+
import { ApiError } from '../lib/errors.js';
|
|
5
|
+
import type { FetchImpl } from '../lib/http.js';
|
|
6
|
+
import { type Page } from '../lib/pagination.js';
|
|
7
|
+
import type { RunResponse, TriggerRunResponse, RerunResponse, BatchRerunResponse, ListRunsResponse, RunSource, BatchRunFreshResponse } from '../lib/runs.types.js';
|
|
8
|
+
/**
|
|
9
|
+
* `details` debug block per the CLI OpenAPI `Test` schema
|
|
10
|
+
* (M2.1 amendment). `processingStatus` / `testStatus` are the
|
|
11
|
+
* structured pair; either may be `null` when the source row has no
|
|
12
|
+
* analog (MCP rows have no separate processStatus). `rawStatus` is
|
|
13
|
+
* the deprecated pre-M2.1 mirror, kept one minor for callers that
|
|
14
|
+
* already parse it. All three are debug-only — automation depends on
|
|
15
|
+
* the typed top-level `status` field.
|
|
16
|
+
*/
|
|
17
|
+
export interface CliTestStatusDetails {
|
|
18
|
+
processingStatus: string | null;
|
|
19
|
+
testStatus: string | null;
|
|
20
|
+
rawStatus: string;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Public Test shape per the CLI OpenAPI `Test` schema.
|
|
24
|
+
* `details` is optional debug context — automation must depend only on
|
|
25
|
+
* the typed top-level fields. `createdFrom` takes one of the three
|
|
26
|
+
* documented values (`portal` | `mcp` | `cli`); anything else is a
|
|
27
|
+
* contract violation worth surfacing rather than silently coercing.
|
|
28
|
+
*/
|
|
29
|
+
export interface CliTest {
|
|
30
|
+
id: string;
|
|
31
|
+
projectId: string;
|
|
32
|
+
/**
|
|
33
|
+
* §6.2 / M2.1 piece 4 — human-friendly project name. `null` when
|
|
34
|
+
* project lookup wasn't possible (record missing, ownership
|
|
35
|
+
* boundary, or pre-M2.1 backend that never populated the field).
|
|
36
|
+
* Optional on the wire so older facades that don't ship the field
|
|
37
|
+
* still type-check; the renderer falls back to `projectId` when
|
|
38
|
+
* absent.
|
|
39
|
+
*/
|
|
40
|
+
projectName?: string | null;
|
|
41
|
+
name: string;
|
|
42
|
+
type: 'frontend' | 'backend';
|
|
43
|
+
createdFrom: 'portal' | 'mcp' | 'cli';
|
|
44
|
+
status: CliPublicStatus;
|
|
45
|
+
createdAt: string;
|
|
46
|
+
updatedAt: string;
|
|
47
|
+
/**
|
|
48
|
+
* M3.4 — number of FE plan steps, or `null` for BE tests and rows
|
|
49
|
+
* without plan steps. Optional on the wire so pre-M3.4 facades that
|
|
50
|
+
* don't ship it still type-check; text mode shows it only when present
|
|
51
|
+
* and non-null. The dedicated read path for recovering the current
|
|
52
|
+
* count after a `test plan put --expected-step-count` 412.
|
|
53
|
+
*/
|
|
54
|
+
planStepCount?: number | null;
|
|
55
|
+
/**
|
|
56
|
+
* M2.1: structured `processingStatus` / `testStatus` pair plus the
|
|
57
|
+
* deprecated `rawStatus` mirror. Pre-M2.1 servers may still emit
|
|
58
|
+
* `{ rawStatus }` only — keep the structured fields optional on
|
|
59
|
+
* the wire even though M2.1 servers always populate them. The CLI
|
|
60
|
+
* accepts both shapes.
|
|
61
|
+
*/
|
|
62
|
+
details?: Partial<CliTestStatusDetails>;
|
|
63
|
+
/**
|
|
64
|
+
* G1a — test priority label, e.g. "p0" | "p1" | "p2" | "p3".
|
|
65
|
+
* Optional on the wire: pre-G1a backends omit the field; `null` means
|
|
66
|
+
* no priority has been set. Text mode surfaces it only when truthy.
|
|
67
|
+
*/
|
|
68
|
+
priority?: string | null;
|
|
69
|
+
}
|
|
70
|
+
export type CliPublicStatus = 'draft' | 'ready' | 'queued' | 'running' | 'passed' | 'failed' | 'blocked' | 'cancelled' | 'unknown';
|
|
71
|
+
/**
|
|
72
|
+
* §6.3 TestCode wire shape. `code` is either the inline source body
|
|
73
|
+
* (when < 100 KB) or a presigned `https://` URL (when >= 100 KB). The
|
|
74
|
+
* caller distinguishes via {@link isPresignedCodeUrl}.
|
|
75
|
+
*/
|
|
76
|
+
export interface CliTestCode {
|
|
77
|
+
testId: string;
|
|
78
|
+
language: 'typescript' | 'javascript' | 'python';
|
|
79
|
+
framework: 'playwright' | 'pytest';
|
|
80
|
+
code: string;
|
|
81
|
+
codeVersion: string | null;
|
|
82
|
+
etag?: string | null;
|
|
83
|
+
}
|
|
84
|
+
/** §6.4 TestStep wire shape. `null` is "not known", not "absent". */
|
|
85
|
+
export interface CliTestStep {
|
|
86
|
+
testId: string;
|
|
87
|
+
stepIndex: number;
|
|
88
|
+
action: string;
|
|
89
|
+
description: string;
|
|
90
|
+
status: 'passed' | 'failed' | null;
|
|
91
|
+
screenshotUrl: string | null;
|
|
92
|
+
htmlSnapshotUrl: string | null;
|
|
93
|
+
runIdIfAvailable: string | null;
|
|
94
|
+
codeVersion: string | null;
|
|
95
|
+
capturedAt: string | null;
|
|
96
|
+
updatedAt: string;
|
|
97
|
+
/**
|
|
98
|
+
* §6.4 / M2.1 piece 4 — derived flag the facade owns. `true` only on
|
|
99
|
+
* step(s) that actually contributed to the test failure. `null`
|
|
100
|
+
* when the underlying backend row hasn't been classified yet (pre-
|
|
101
|
+
* M2.1 persistence). Optional on the wire so pre-M2.1 servers
|
|
102
|
+
* that don't emit the field still type-check.
|
|
103
|
+
*/
|
|
104
|
+
outcomeContributesToFailure?: boolean | null;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* §6.5 failureKind enum (M2.1 piece 4 widened from six to nine values).
|
|
108
|
+
* The CLI accepts unrecognized strings from the wire as `unknown` so
|
|
109
|
+
* adding a future enum value (e.g. `quota_exceeded`) is non-breaking
|
|
110
|
+
* — agents must not switch on raw strings outside the enumerated set.
|
|
111
|
+
*/
|
|
112
|
+
export type CliFailureKind = 'assertion' | 'assertion_blocked' | 'routing_404' | 'network_timeout' | 'network' | 'timeout' | 'browser_crash' | 'infra' | 'unknown' | null;
|
|
113
|
+
export interface CliResultSummary {
|
|
114
|
+
passed: number;
|
|
115
|
+
failed: number;
|
|
116
|
+
skipped: number;
|
|
117
|
+
}
|
|
118
|
+
/** §6.5 LatestResult wire shape. All correlation fields are required. */
|
|
119
|
+
export interface CliLatestResult {
|
|
120
|
+
testId: string;
|
|
121
|
+
status: CliPublicStatus;
|
|
122
|
+
startedAt: string | null;
|
|
123
|
+
finishedAt: string | null;
|
|
124
|
+
videoUrl: string | null;
|
|
125
|
+
failureAnalysisUrl: string | null;
|
|
126
|
+
snapshotId: string;
|
|
127
|
+
runIdIfAvailable: string | null;
|
|
128
|
+
codeVersion: string | null;
|
|
129
|
+
/**
|
|
130
|
+
* The target URL used for this run. May be `null` when `targetUrlSource`
|
|
131
|
+
* is `'unresolved'` (the stored run row had no target URL and the backend
|
|
132
|
+
* did not fall back to the project default).
|
|
133
|
+
*/
|
|
134
|
+
targetUrl: string | null;
|
|
135
|
+
/**
|
|
136
|
+
* D1 — provenance of `targetUrl`. Present on backends that have shipped
|
|
137
|
+
* the D1 fix; omitted on older backends (treat as unknown when absent).
|
|
138
|
+
*
|
|
139
|
+
* - `'run'` — URL was stored explicitly on the TestRun row.
|
|
140
|
+
* - `'project-default'` — URL came from the project's configured default.
|
|
141
|
+
* - `'unresolved'` — no URL on the run row AND no project default;
|
|
142
|
+
* `targetUrl` will be `null`.
|
|
143
|
+
* - `null` — backend sent the field explicitly as null
|
|
144
|
+
* (semantically equivalent to `'unresolved'`).
|
|
145
|
+
*/
|
|
146
|
+
targetUrlSource?: 'run' | 'project-default' | 'unresolved' | null;
|
|
147
|
+
failedStepIndex: number | null;
|
|
148
|
+
failureKind: CliFailureKind;
|
|
149
|
+
summary: CliResultSummary;
|
|
150
|
+
/**
|
|
151
|
+
* §6.5.1 (M2.1 piece 3) — inline failure analysis. Present when the
|
|
152
|
+
* caller passed `--include-analysis` (`?includeAnalysis=true` on
|
|
153
|
+
* the wire); absent on the byte-identical-to-pre-M2.1 default.
|
|
154
|
+
*/
|
|
155
|
+
analysis?: CliAnalysisBlock;
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* §6.5.1 (M2.1 piece 3) — analysis fields surfaced inline on
|
|
159
|
+
* `/result?includeAnalysis=true` and as the body of `/failure/summary`.
|
|
160
|
+
*
|
|
161
|
+
* Stable shape: ships even on passing/in-flight runs with every field
|
|
162
|
+
* inside `null`. `recommendedFixTarget` is `null` (not the always-
|
|
163
|
+
* `unknown` wrapper) when the analysis pipeline didn't fill it.
|
|
164
|
+
* `failureKind` mirrors `LatestResult.failureKind` for caller
|
|
165
|
+
* convenience. `snapshotId` mirrors the outer snapshot, so a caller
|
|
166
|
+
* comparing the inline analysis with a later `/failure` bundle can
|
|
167
|
+
* detect drift without a second round-trip.
|
|
168
|
+
*/
|
|
169
|
+
export interface CliAnalysisBlock {
|
|
170
|
+
rootCauseHypothesis: string | null;
|
|
171
|
+
recommendedFixTarget: CliFixTarget | null;
|
|
172
|
+
failureKind: CliFailureKind;
|
|
173
|
+
snapshotId: string;
|
|
174
|
+
/**
|
|
175
|
+
* L141 — set to `true` (JSON output only) when `rootCauseHypothesis`
|
|
176
|
+
* ends with `…` (U+2026), indicating the server truncated the text.
|
|
177
|
+
* Omitted when the field is null or untouched. This is a CLI-side
|
|
178
|
+
* observation; the server does not send this field. Full untruncated
|
|
179
|
+
* text requires backend support (backend follow-up).
|
|
180
|
+
*/
|
|
181
|
+
rootCauseHypothesisTruncated?: true;
|
|
182
|
+
/**
|
|
183
|
+
* L141 — set to `true` (JSON output only) when
|
|
184
|
+
* `recommendedFixTarget.rationale` ends with `…` (U+2026), indicating
|
|
185
|
+
* the server truncated the rationale. Omitted when not truncated.
|
|
186
|
+
*/
|
|
187
|
+
recommendedFixRationaleTruncated?: true;
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* §5.2 (M2.1 piece 3) — body of `GET /tests/{testId}/failure/summary`.
|
|
191
|
+
* One-screen agent triage answer: status + failureKind + analysis,
|
|
192
|
+
* no bundle. Sibling of `failure get` for cases where the agent's
|
|
193
|
+
* first pass doesn't need video / screenshots / DOM snapshots.
|
|
194
|
+
*/
|
|
195
|
+
export interface CliFailureSummary {
|
|
196
|
+
testId: string;
|
|
197
|
+
status: CliPublicStatus;
|
|
198
|
+
failureKind: CliFailureKind;
|
|
199
|
+
snapshotId: string;
|
|
200
|
+
rootCauseHypothesis: string | null;
|
|
201
|
+
recommendedFixTarget: CliFixTarget | null;
|
|
202
|
+
}
|
|
203
|
+
/** §6.7 narrow fix-target enum. Agents route on this; M2 emits 'unknown'. */
|
|
204
|
+
export type CliFixKind = 'code' | 'selector' | 'data' | 'env' | 'unknown';
|
|
205
|
+
export type CliEvidenceKind = 'screenshot' | 'snapshot' | 'log' | 'network' | 'console';
|
|
206
|
+
export interface CliFixTarget {
|
|
207
|
+
kind: CliFixKind;
|
|
208
|
+
reference: string | null;
|
|
209
|
+
rationale: string | null;
|
|
210
|
+
}
|
|
211
|
+
export interface CliEvidence {
|
|
212
|
+
kind: CliEvidenceKind;
|
|
213
|
+
/** 1-based step index — matches portal display. */
|
|
214
|
+
stepIndex: number;
|
|
215
|
+
/** Presigned S3 URL with shared 15-min TTL. */
|
|
216
|
+
url: string;
|
|
217
|
+
/**
|
|
218
|
+
* LLM-generated transcription per §6.1. The CLI emits whatever the
|
|
219
|
+
* facade returned — never edited or generated client-side.
|
|
220
|
+
*/
|
|
221
|
+
summary: string;
|
|
222
|
+
}
|
|
223
|
+
export interface CliFailureBlock {
|
|
224
|
+
rootCauseHypothesis: string | null;
|
|
225
|
+
/**
|
|
226
|
+
* §6.7 / M2.1 piece 3 visibility policy: `null` when the analysis
|
|
227
|
+
* pipeline didn't fill any of `kind` / `reference` / `rationale`.
|
|
228
|
+
* Pre-M2.1 the facade always emitted an `unknown` wrapper here;
|
|
229
|
+
* M2.1 drops it so agents route on `null` rather than parsing the
|
|
230
|
+
* always-unknown shape.
|
|
231
|
+
*/
|
|
232
|
+
recommendedFixTarget: CliFixTarget | null;
|
|
233
|
+
evidence: CliEvidence[];
|
|
234
|
+
}
|
|
235
|
+
/** §6.7 wire shape — one atomic snapshot of the latest failing run. */
|
|
236
|
+
export interface CliFailureContext {
|
|
237
|
+
snapshotId: string;
|
|
238
|
+
testId: string;
|
|
239
|
+
projectId: string;
|
|
240
|
+
result: CliLatestResult;
|
|
241
|
+
steps: CliTestStep[];
|
|
242
|
+
code: CliTestCode;
|
|
243
|
+
failure: CliFailureBlock;
|
|
244
|
+
}
|
|
245
|
+
export interface TestDeps {
|
|
246
|
+
env?: NodeJS.ProcessEnv;
|
|
247
|
+
credentialsPath?: string;
|
|
248
|
+
fetchImpl?: FetchImpl;
|
|
249
|
+
stdout?: (line: string) => void;
|
|
250
|
+
stderr?: (line: string) => void;
|
|
251
|
+
/**
|
|
252
|
+
* Raw stdout writer for streaming code bodies in `test code get`. No
|
|
253
|
+
* implicit newline; each call writes verbatim. Defaults to
|
|
254
|
+
* `process.stdout.write`. See `Output.writeChunk` for rationale.
|
|
255
|
+
*/
|
|
256
|
+
rawStdout?: (text: string) => void;
|
|
257
|
+
/**
|
|
258
|
+
* Injectable sleep function for the polling loop. Defaults to the
|
|
259
|
+
* `defaultSleep` in `poll.ts` (`setTimeout`-based). Inject an instant
|
|
260
|
+
* no-op in tests to avoid real delays.
|
|
261
|
+
*/
|
|
262
|
+
sleep?: (ms: number) => Promise<void>;
|
|
263
|
+
}
|
|
264
|
+
type CommonOptions = FactoryCommonOptions;
|
|
265
|
+
interface ListOptions extends CommonOptions {
|
|
266
|
+
projectId: string;
|
|
267
|
+
type?: 'frontend' | 'backend';
|
|
268
|
+
createdFrom?: 'portal' | 'mcp' | 'cli';
|
|
269
|
+
/**
|
|
270
|
+
* §6.6 / M2.1 piece 2 — comma-separated list of public status
|
|
271
|
+
* values (e.g. `failed,blocked`). The CLI passes the raw string to
|
|
272
|
+
* the facade which validates token-by-token. Pre-validating client-
|
|
273
|
+
* side gives a friendlier error for typos like `--status fail`.
|
|
274
|
+
*/
|
|
275
|
+
status?: string;
|
|
276
|
+
pageSize?: number;
|
|
277
|
+
startingToken?: string;
|
|
278
|
+
maxItems?: number;
|
|
279
|
+
}
|
|
280
|
+
export declare function runList(opts: ListOptions, deps?: TestDeps): Promise<Page<CliTest>>;
|
|
281
|
+
/**
|
|
282
|
+
* §6.X / M3.2 piece-2 `CreateTestResponse` shape. `codeVersion` is the
|
|
283
|
+
* monotonic stamp piece-1 added to FE/BE Portal rows; the CLI re-uses
|
|
284
|
+
* it as the `If-Match` etag on `test code put` (piece-4).
|
|
285
|
+
*/
|
|
286
|
+
export interface CliCreateTestResponse {
|
|
287
|
+
testId: string;
|
|
288
|
+
type: 'frontend' | 'backend';
|
|
289
|
+
codeVersion: string;
|
|
290
|
+
createdAt: string;
|
|
291
|
+
}
|
|
292
|
+
export declare const CLI_CREATE_PRIORITIES: readonly ["p0", "p1", "p2", "p3"];
|
|
293
|
+
export type CliCreatePriority = (typeof CLI_CREATE_PRIORITIES)[number];
|
|
294
|
+
interface CreateOptions extends CommonOptions {
|
|
295
|
+
projectId: string;
|
|
296
|
+
type: 'frontend' | 'backend';
|
|
297
|
+
name: string;
|
|
298
|
+
description?: string;
|
|
299
|
+
priority?: CliCreatePriority;
|
|
300
|
+
/** Source path to the test code. Read into memory; capped at 350 KB. */
|
|
301
|
+
codeFile: string;
|
|
302
|
+
/** Caller-supplied idempotency token; UUIDv4 minted client-side if absent. */
|
|
303
|
+
idempotencyKey?: string;
|
|
304
|
+
/** M3.3 chain: trigger a run after create. */
|
|
305
|
+
run?: boolean;
|
|
306
|
+
/** M3.3 chain: poll until terminal when `run` is true. */
|
|
307
|
+
wait?: boolean;
|
|
308
|
+
/** M3.3 chain: per-run timeout in seconds. */
|
|
309
|
+
timeout?: number;
|
|
310
|
+
/**
|
|
311
|
+
* M4 piece-2 — BE dependency authoring flags.
|
|
312
|
+
* `--produces <var>` (repeatable): variable names this test captures.
|
|
313
|
+
* Maps to wire field `produces` → backend serialises as `captures` JSON.
|
|
314
|
+
* Backend-only; supplying with --type frontend → exit 5 (FE has no wave model).
|
|
315
|
+
*/
|
|
316
|
+
produces?: string[];
|
|
317
|
+
/**
|
|
318
|
+
* `--needs <var>` (repeatable): variable names this test consumes.
|
|
319
|
+
* Maps to wire field `consumes`. Backend-only.
|
|
320
|
+
*/
|
|
321
|
+
needs?: string[];
|
|
322
|
+
/**
|
|
323
|
+
* `--category <str>`: free-text category. Use `teardown`/`cleanup` to mark
|
|
324
|
+
* a last-wave cleanup test in the wave planner. Backend-only.
|
|
325
|
+
*/
|
|
326
|
+
category?: string;
|
|
327
|
+
/**
|
|
328
|
+
* B2(c): true when --timeout was NOT explicitly set (the default is in
|
|
329
|
+
* effect). Threaded into RunTestRunOptions so the first-run hint fires.
|
|
330
|
+
*/
|
|
331
|
+
timeoutIsDefault?: boolean;
|
|
332
|
+
/** M3.3 chain: per-run target URL override. */
|
|
333
|
+
targetUrl?: string;
|
|
334
|
+
}
|
|
335
|
+
/**
|
|
336
|
+
* `test create --code-file <path>` — M3.2 piece-2 first mutation.
|
|
337
|
+
*
|
|
338
|
+
* Reads the file (with the same 350 KB pre-flight the server enforces)
|
|
339
|
+
* and POSTs to `/api/cli/v1/tests` with an `Idempotency-Key` header.
|
|
340
|
+
* Default key is `cli-create-<uuidv4>`; a caller-supplied
|
|
341
|
+
* `--idempotency-key` lets retry tooling pin the same key across
|
|
342
|
+
* attempts so a network blip doesn't double-create. The exact key sent
|
|
343
|
+
* is echoed to stderr at `--debug` so an operator can reuse it.
|
|
344
|
+
*
|
|
345
|
+
* Dry-run: the request still goes through `HttpClient.post`, but the
|
|
346
|
+
* `client-factory` swaps in `createDryRunFetch` so no network call
|
|
347
|
+
* happens — the caller sees the canned response shape from
|
|
348
|
+
* `src/lib/dry-run/samples.ts`. The `--debug` events emit the canonical
|
|
349
|
+
* request envelope (URL, method, headers including Idempotency-Key)
|
|
350
|
+
* so the user can verify what would be sent. Matches the M2 P6
|
|
351
|
+
* convention; no separate "envelope-only" output mode.
|
|
352
|
+
*/
|
|
353
|
+
export declare function runCreate(opts: CreateOptions, deps?: TestDeps): Promise<CliCreateTestResponse>;
|
|
354
|
+
/**
|
|
355
|
+
* §6.X / M3.2 piece-6 — response from `PUT /tests/{id}/plan-steps`.
|
|
356
|
+
* `planStepsHash` is a sha256 over the canonicalized new array so
|
|
357
|
+
* agents can detect their own no-op replays without an extra read.
|
|
358
|
+
* `stepCount` is the post-update array length.
|
|
359
|
+
*/
|
|
360
|
+
export interface CliPutPlanStepsResponse {
|
|
361
|
+
testId: string;
|
|
362
|
+
planStepsHash: string;
|
|
363
|
+
stepCount: number;
|
|
364
|
+
updatedAt: string;
|
|
365
|
+
}
|
|
366
|
+
interface PlanPutOptions extends CommonOptions {
|
|
367
|
+
testId: string;
|
|
368
|
+
/** Source path to the new plan-step JSON file (`{ planSteps: [...] }`). */
|
|
369
|
+
stepsFile: string;
|
|
370
|
+
/**
|
|
371
|
+
* Optional defensive concurrency check. Server rejects with 412
|
|
372
|
+
* when the current entity's `planSteps.length !== N`. FE has no
|
|
373
|
+
* `codeVersion`, so this is the only consistency knob.
|
|
374
|
+
*/
|
|
375
|
+
expectedStepCount?: number;
|
|
376
|
+
/** Caller-supplied idempotency token; UUIDv4 minted client-side if absent. */
|
|
377
|
+
idempotencyKey?: string;
|
|
378
|
+
/**
|
|
379
|
+
* When set alongside `--dry-run`, synthesises a 412 error envelope
|
|
380
|
+
* so the user can preview the retry-hint output and exit code without
|
|
381
|
+
* a real API key. Only `PRECONDITION_FAILED` is supported today.
|
|
382
|
+
*/
|
|
383
|
+
dryRunSimulateError?: 'PRECONDITION_FAILED';
|
|
384
|
+
}
|
|
385
|
+
/**
|
|
386
|
+
* `test plan put <test-id> --steps <plan.json>` — M3.2 piece-6.
|
|
387
|
+
*
|
|
388
|
+
* Replace an FE test's `planSteps[]` with the array in `--steps`. The
|
|
389
|
+
* file is a single JSON object `{ planSteps: [...] }`; we don't echo
|
|
390
|
+
* the full `CliPlanInput` shape here because `projectId` / `name` etc.
|
|
391
|
+
* are not mutable from this endpoint.
|
|
392
|
+
*
|
|
393
|
+
* FE-only. BE tests get a 400 `VALIDATION_ERROR` from the server with
|
|
394
|
+
* a `nextAction` pointing at `test code put`. The CLI does **not**
|
|
395
|
+
* pre-fetch the test type — letting the server route saves a round
|
|
396
|
+
* trip and matches the piece-6 spec's "server-side routing" decision.
|
|
397
|
+
*
|
|
398
|
+
* Concurrency: FE has no `codeVersion`, so updates are last-writer-
|
|
399
|
+
* wins by default. Pass `--expected-step-count <N>` to set
|
|
400
|
+
* `If-Match-Step-Count`; the server rejects with 412 if the current
|
|
401
|
+
* array length differs. Useful for defensive callers who want to
|
|
402
|
+
* detect concurrent edits without a separate read.
|
|
403
|
+
*
|
|
404
|
+
* Idempotency: `cli-plan-put-<uuid>` is the default key, surfaced to
|
|
405
|
+
* stderr so a transport retry can pin it.
|
|
406
|
+
*/
|
|
407
|
+
export declare function runPlanPut(opts: PlanPutOptions, deps?: TestDeps): Promise<CliPutPlanStepsResponse>;
|
|
408
|
+
/**
|
|
409
|
+
* §6.X / M3.2 piece-3 `UpdateTestResponse` shape. `updatedFields` is
|
|
410
|
+
* the array of top-level fields that changed in this call so JSON
|
|
411
|
+
* consumers know what landed — useful when the agent passed all three
|
|
412
|
+
* flags but the server normalized one to a no-op.
|
|
413
|
+
*/
|
|
414
|
+
export interface CliUpdateTestResponse {
|
|
415
|
+
testId: string;
|
|
416
|
+
updatedFields: string[];
|
|
417
|
+
updatedAt: string;
|
|
418
|
+
}
|
|
419
|
+
interface UpdateOptions extends CommonOptions {
|
|
420
|
+
testId: string;
|
|
421
|
+
/** Optional new name; at least one of `name`/`description`/`priority` must be set. */
|
|
422
|
+
name?: string;
|
|
423
|
+
/** Optional new description (`null` is reserved for "clear"; CLI surfaces both). */
|
|
424
|
+
description?: string;
|
|
425
|
+
/** Optional new priority. Enum-validated CLI-side. */
|
|
426
|
+
priority?: CliCreatePriority;
|
|
427
|
+
/** Caller-supplied idempotency token; UUIDv4 minted client-side if absent. */
|
|
428
|
+
idempotencyKey?: string;
|
|
429
|
+
}
|
|
430
|
+
/**
|
|
431
|
+
* `test update <test-id>` — M3.2 piece-3.
|
|
432
|
+
*
|
|
433
|
+
* Metadata-only update: `name?`, `description?`, `priority?`. Code and
|
|
434
|
+
* plan-steps are not part of this surface (`test code put` and
|
|
435
|
+
* `test plan put` are the dedicated paths). The CLI does not even
|
|
436
|
+
* expose `--code` / `--plan-steps` flags here so a caller cannot
|
|
437
|
+
* accidentally try; the server would also reject those keys, but
|
|
438
|
+
* keeping the surface narrow is the cheaper guard.
|
|
439
|
+
*
|
|
440
|
+
* Refuses no-op invocations (none of the three set) with a typed
|
|
441
|
+
* `VALIDATION_ERROR` so a careless `test update <id>` doesn't burn a
|
|
442
|
+
* request. The error includes the accepted field set so an agent
|
|
443
|
+
* can self-correct without reading the help text.
|
|
444
|
+
*
|
|
445
|
+
* Idempotency-Key default is `cli-update-<uuid>`; a caller-supplied
|
|
446
|
+
* `--idempotency-key` lets retry tooling pin the key. The generated
|
|
447
|
+
* value is echoed to stderr so an operator who hits a transport
|
|
448
|
+
* retry-budget exhaustion can re-run with the same key. Surfacing
|
|
449
|
+
* matches piece-2's pattern.
|
|
450
|
+
*/
|
|
451
|
+
export declare function runUpdate(opts: UpdateOptions, deps?: TestDeps): Promise<CliUpdateTestResponse>;
|
|
452
|
+
/**
|
|
453
|
+
* §6.X / M3.2 piece-3 `DeleteTestResponse` shape. `deletedAt` is the
|
|
454
|
+
* delete timestamp (an ack) — hard-delete is immediate, so there is no
|
|
455
|
+
* restore window.
|
|
456
|
+
*/
|
|
457
|
+
export interface CliDeleteTestResponse {
|
|
458
|
+
testId: string;
|
|
459
|
+
deletedAt: string;
|
|
460
|
+
}
|
|
461
|
+
interface DeleteOptions extends CommonOptions {
|
|
462
|
+
testId: string;
|
|
463
|
+
/** Hard gate — required (unless `--dry-run` is set). No interactive prompts. */
|
|
464
|
+
confirm: boolean;
|
|
465
|
+
/** Caller-supplied idempotency token; UUIDv4 minted client-side if absent. */
|
|
466
|
+
idempotencyKey?: string;
|
|
467
|
+
}
|
|
468
|
+
/**
|
|
469
|
+
* `test delete <test-id> --confirm` — M3.2 piece-3.
|
|
470
|
+
*
|
|
471
|
+
* Permanent hard-delete via DELETE /tests/{id}. The server removes the
|
|
472
|
+
* test row plus its steps and code object immediately — matching the
|
|
473
|
+
* Portal's own delete behavior — so the test disappears everywhere at
|
|
474
|
+
* once. There is no restore window.
|
|
475
|
+
*
|
|
476
|
+
* **`--confirm` is required** (unless `--dry-run`). Without either,
|
|
477
|
+
* the CLI exits 5 `VALIDATION_ERROR` with a typed envelope explaining
|
|
478
|
+
* the convention. The CLI never prompts interactively — matches the
|
|
479
|
+
* CI-friendly contract from the CLI error spec §2.
|
|
480
|
+
*
|
|
481
|
+
* Re-delete on an already-deleted (or missing) row returns 404 from the
|
|
482
|
+
* server. The CLI surfaces the envelope as-is; no client-side branching.
|
|
483
|
+
*/
|
|
484
|
+
export declare function runDelete(opts: DeleteOptions, deps?: TestDeps): Promise<CliDeleteTestResponse>;
|
|
485
|
+
/**
|
|
486
|
+
* Per-test outcome record for `test delete-batch` and `test delete --all`.
|
|
487
|
+
*/
|
|
488
|
+
export interface CliBulkDeleteResult {
|
|
489
|
+
testId: string;
|
|
490
|
+
status: 'deleted' | 'skipped' | 'error';
|
|
491
|
+
/**
|
|
492
|
+
* Present when `status === 'deleted'`. ISO 8601 timestamp from the server.
|
|
493
|
+
*/
|
|
494
|
+
deletedAt?: string;
|
|
495
|
+
/** Present when `status === 'error'`. Short error description. */
|
|
496
|
+
error?: string;
|
|
497
|
+
}
|
|
498
|
+
export interface CliBulkDeleteSummary {
|
|
499
|
+
results: CliBulkDeleteResult[];
|
|
500
|
+
summary: {
|
|
501
|
+
total: number;
|
|
502
|
+
deleted: number;
|
|
503
|
+
skipped: number;
|
|
504
|
+
failed: number;
|
|
505
|
+
};
|
|
506
|
+
}
|
|
507
|
+
interface DeleteBatchOptions extends CommonOptions {
|
|
508
|
+
/** Explicit list of testIds to delete. */
|
|
509
|
+
testIds: string[];
|
|
510
|
+
/** --all: resolve all tests in the project and delete them. */
|
|
511
|
+
all: boolean;
|
|
512
|
+
/** --project <id>: required with --all. */
|
|
513
|
+
projectId?: string;
|
|
514
|
+
/**
|
|
515
|
+
* --status <list>: with --all, only delete tests whose status matches.
|
|
516
|
+
* Uses the same validated set as `test list --status`.
|
|
517
|
+
*/
|
|
518
|
+
statusFilter?: string;
|
|
519
|
+
/** Hard gate — required (unless --dry-run). */
|
|
520
|
+
confirm: boolean;
|
|
521
|
+
}
|
|
522
|
+
/**
|
|
523
|
+
* `test delete-batch <test-ids...>` and `test delete --all --project <id>` — dogfood L1800.
|
|
524
|
+
*
|
|
525
|
+
* Deletes tests sequentially (to avoid hammering the server) and aggregates
|
|
526
|
+
* results into a single summary. Gated on `--confirm` (same convention as
|
|
527
|
+
* `test delete`). Prints a summary line to stderr and the per-test results
|
|
528
|
+
* object to stdout.
|
|
529
|
+
*
|
|
530
|
+
* Exit code: 0 if all targets were deleted (or `--dry-run`); 1 if any
|
|
531
|
+
* deletion failed (server error); 5 if `--confirm` is missing.
|
|
532
|
+
*/
|
|
533
|
+
export declare function runDeleteBatch(opts: DeleteBatchOptions, deps?: TestDeps): Promise<CliBulkDeleteSummary>;
|
|
534
|
+
/**
|
|
535
|
+
* §6.X / M3.2 piece-5 — plan-step structure. `description` is the
|
|
536
|
+
* natural-language instruction the browser-use Lambda interprets at
|
|
537
|
+
* run time. `type` is the action/assertion binary the FE pipeline
|
|
538
|
+
* uses to decide whether a step is mutating UI or verifying state.
|
|
539
|
+
*/
|
|
540
|
+
export interface CliPlanStep {
|
|
541
|
+
type: 'action' | 'assertion';
|
|
542
|
+
description: string;
|
|
543
|
+
}
|
|
544
|
+
/**
|
|
545
|
+
* Plan-from input file shape. Mirrors the body the controller accepts
|
|
546
|
+
* at `POST /api/cli/v1/tests` with `planSteps[]` (use-cases.md UC1).
|
|
547
|
+
* `priority` and `description` are optional metadata; everything else
|
|
548
|
+
* is required.
|
|
549
|
+
*
|
|
550
|
+
* FE-only after the 2026-05-13 scope cut. `type: "backend"` plans are
|
|
551
|
+
* rejected pre-flight by the CLI with a `nextAction` pointing at
|
|
552
|
+
* `test create --type backend --code-file <path>`.
|
|
553
|
+
*/
|
|
554
|
+
export interface CliPlanInput {
|
|
555
|
+
projectId: string;
|
|
556
|
+
type: 'frontend' | 'backend';
|
|
557
|
+
name: string;
|
|
558
|
+
description?: string;
|
|
559
|
+
priority?: CliCreatePriority;
|
|
560
|
+
planSteps: CliPlanStep[];
|
|
561
|
+
}
|
|
562
|
+
/**
|
|
563
|
+
* §6.X / M3.2 piece-5 — response from POST /tests with planSteps[].
|
|
564
|
+
* Same wire shape as the code-based create (piece-2) plus an optional
|
|
565
|
+
* `planSteps` echo so the agent doesn't have to keep its own copy
|
|
566
|
+
* between create and run. `planSteps` is absent in dry-run mode
|
|
567
|
+
* because the sampler doesn't inspect the request body.
|
|
568
|
+
*/
|
|
569
|
+
export interface CliCreateFromPlanResponse extends CliCreateTestResponse {
|
|
570
|
+
planSteps?: CliPlanStep[];
|
|
571
|
+
}
|
|
572
|
+
/** Per-spec result from `POST /tests/batch`. */
|
|
573
|
+
export interface CliBatchSpecResult {
|
|
574
|
+
/** Position of the spec in the input JSONL, preserved across the response. */
|
|
575
|
+
specIndex: number;
|
|
576
|
+
/** Spec outcome. Mirrors the server's per-spec status enum. */
|
|
577
|
+
status: 'created' | 'validation_error' | 'not_found';
|
|
578
|
+
/** Set on success. */
|
|
579
|
+
testId?: string;
|
|
580
|
+
/** Set on non-success. Carries the same envelope an `ApiError` would. */
|
|
581
|
+
error?: {
|
|
582
|
+
code: string;
|
|
583
|
+
message: string;
|
|
584
|
+
field?: string;
|
|
585
|
+
};
|
|
586
|
+
}
|
|
587
|
+
export interface CliCreateBatchResponse {
|
|
588
|
+
results: CliBatchSpecResult[];
|
|
589
|
+
summary: {
|
|
590
|
+
total: number;
|
|
591
|
+
created: number;
|
|
592
|
+
failed: number;
|
|
593
|
+
};
|
|
594
|
+
}
|
|
595
|
+
/**
|
|
596
|
+
* Per-run result from the `--run` fan-out on `test create-batch`.
|
|
597
|
+
* Each entry mirrors the shape of a single `test run --wait` JSON output
|
|
598
|
+
* so automation can process the array the same way it processes a single run.
|
|
599
|
+
*/
|
|
600
|
+
export interface CliBatchRunResult {
|
|
601
|
+
/** Test that was triggered. */
|
|
602
|
+
testId: string;
|
|
603
|
+
/** Run ID minted by the trigger call (or the in-flight runId on CONFLICT resume). */
|
|
604
|
+
runId: string;
|
|
605
|
+
/** Terminal status if `--wait`; `queued` if no `--wait`. */
|
|
606
|
+
status: string;
|
|
607
|
+
/** Code version resolved at trigger time. */
|
|
608
|
+
codeVersion: string;
|
|
609
|
+
/** Resolved target URL. */
|
|
610
|
+
videoUrl?: string | null;
|
|
611
|
+
/** Failure kind if status is `failed` or `blocked`. */
|
|
612
|
+
failureKind?: string | null;
|
|
613
|
+
/** Error envelope when the trigger itself failed (network/auth/validation). */
|
|
614
|
+
error?: {
|
|
615
|
+
code: string;
|
|
616
|
+
message: string;
|
|
617
|
+
exitCode: number;
|
|
618
|
+
};
|
|
619
|
+
}
|
|
620
|
+
/** Envelope emitted by `test create-batch --run` in JSON mode. */
|
|
621
|
+
export interface CliCreateBatchRunResponse {
|
|
622
|
+
results: CliBatchRunResult[];
|
|
623
|
+
}
|
|
624
|
+
/**
|
|
625
|
+
* Default max in-flight run-triggers for `create-batch --run`.
|
|
626
|
+
*
|
|
627
|
+
* Rationale: the server caps run-triggers at 60/min/key
|
|
628
|
+
* (`CLI_RUN_RATE_LIMIT_PER_MIN`, default 60 → `RATE_LIMITED` / exit 11).
|
|
629
|
+
* A `create-batch` holds at most MAX_BATCH_SPECS (50) specs, so a default
|
|
630
|
+
* of 50 lets a full batch dispatch all of its runs at once and finish
|
|
631
|
+
* launching within a single window. With async Lambda invoke each trigger
|
|
632
|
+
* returns in ~1s, so this bound mainly smooths the dispatch burst.
|
|
633
|
+
*
|
|
634
|
+
* NOTE: because 50 == MAX_BATCH_SPECS, a single `create-batch --run` can
|
|
635
|
+
* never trip the client-side `BATCH_RUN_RATE_LIMIT` token bucket (also
|
|
636
|
+
* 50/min) — the server's 60/min/key is the real backstop. The client
|
|
637
|
+
* throttle still guards repeated runs within a window from one process.
|
|
638
|
+
*
|
|
639
|
+
* Callers can override this default via `--max-concurrency` (raising it
|
|
640
|
+
* cannot lift the effective rate above the server cap).
|
|
641
|
+
*/
|
|
642
|
+
export declare const DEFAULT_BATCH_RUN_CONCURRENCY = 50;
|
|
643
|
+
/** Hard upper bound for --max-concurrency. Values above this are rejected with exit 5 (VALIDATION_ERROR). */
|
|
644
|
+
export declare const MAX_BATCH_CONCURRENCY = 100;
|
|
645
|
+
/** Client-side run-trigger throttle: 50 triggers per 60-second rolling window per key (sits just under the server's 60/min/key cap). */
|
|
646
|
+
export declare const BATCH_RUN_RATE_LIMIT = 50;
|
|
647
|
+
/** Rolling window duration (ms) for the client-side trigger rate throttle. */
|
|
648
|
+
export declare const BATCH_RUN_RATE_WINDOW_MS = 60000;
|
|
649
|
+
/** Maximum number of outer RATE_LIMITED retries inside the batch fan-out (beyond HTTP-layer retries). */
|
|
650
|
+
export declare const BATCH_RUN_RATE_MAX_OUTER_RETRIES = 5;
|
|
651
|
+
/**
|
|
652
|
+
* D3: max automatic retry attempts for deferred tests under `--wait`.
|
|
653
|
+
* Each attempt is preceded by a Retry-After-aware sleep (server value if
|
|
654
|
+
* present, else 61s default), clamped to the remaining `--timeout` budget.
|
|
655
|
+
* Only active under `--wait`; the non-wait path is unchanged.
|
|
656
|
+
*/
|
|
657
|
+
export declare const MAX_DEFERRED_RETRIES = 3;
|
|
658
|
+
/** D3: default deferred-retry sleep when no Retry-After is available (ms). */
|
|
659
|
+
export declare const DEFERRED_RETRY_DEFAULT_SLEEP_MS = 61000;
|
|
660
|
+
/**
|
|
661
|
+
* Returns `true` when a `RATE_LIMITED` error is the **transient per-minute**
|
|
662
|
+
* rate limit from `RunRateLimiterGuard` — the one worth retrying.
|
|
663
|
+
*
|
|
664
|
+
* The backend surfaces two distinct situations as `RATE_LIMITED` (429):
|
|
665
|
+
*
|
|
666
|
+
* 1. **Per-minute trigger cap** (RunRateLimiterGuard):
|
|
667
|
+
* message = `"Run trigger rate limit exceeded: N triggers per minute per key."`
|
|
668
|
+
* Has `Retry-After` header + `details.retryAfterSeconds`.
|
|
669
|
+
* → TRANSIENT — safe to retry once the window expires.
|
|
670
|
+
*
|
|
671
|
+
* 2. **Insufficient credits** (InsufficientCreditsException):
|
|
672
|
+
* message starts with `"Insufficient credits: N credit(s) required."`
|
|
673
|
+
* No `Retry-After` header, no `details.retryAfterSeconds`.
|
|
674
|
+
* → PERMANENT — retrying cannot succeed; only a top-up will fix it.
|
|
675
|
+
*
|
|
676
|
+
* We prefer a structural match (presence of `retryAfterMs` on the thrown
|
|
677
|
+
* `ApiError`, which is set only when the HTTP response carried a `Retry-After`
|
|
678
|
+
* header) as the primary discriminator, with the per-minute message wording as
|
|
679
|
+
* a secondary guard. If both fields are absent we treat the error as permanent
|
|
680
|
+
* to avoid silently burning the entire retry budget on a non-recoverable state.
|
|
681
|
+
*
|
|
682
|
+
* Limitation: a hypothetical future backend that emits `RATE_LIMITED` for a
|
|
683
|
+
* third reason without a `Retry-After` header AND without the per-minute
|
|
684
|
+
* wording would be classified as permanent here. Document this if it occurs.
|
|
685
|
+
*/
|
|
686
|
+
export declare function isTransientRateLimit(err: ApiError): boolean;
|
|
687
|
+
interface CreateFromPlanOptions extends CommonOptions {
|
|
688
|
+
/** Path to the JSON file containing one `CliPlanInput`. */
|
|
689
|
+
planFrom: string;
|
|
690
|
+
/** Caller-supplied idempotency token; UUIDv4 minted client-side if absent. */
|
|
691
|
+
idempotencyKey?: string;
|
|
692
|
+
/**
|
|
693
|
+
* Reserved for the M3.3 chain. When `true`, the CLI will (once M3.3
|
|
694
|
+
* lands) call `POST /tests/{id}/runs` after the create returns. For
|
|
695
|
+
* v0.1.0 piece-5 this is wired but emits exit 7 `UNSUPPORTED`
|
|
696
|
+
* pointing at the Portal trigger.
|
|
697
|
+
*/
|
|
698
|
+
run?: boolean;
|
|
699
|
+
/** Reserved for the M3.3 chain. Honored when `--run` is set. */
|
|
700
|
+
wait?: boolean;
|
|
701
|
+
/** Reserved for the M3.3 chain. Per-run timeout in seconds. */
|
|
702
|
+
timeout?: number;
|
|
703
|
+
/**
|
|
704
|
+
* B2(c): true when --timeout was NOT explicitly set (the default is in
|
|
705
|
+
* effect). Threaded into RunTestRunOptions so the first-run hint fires.
|
|
706
|
+
*/
|
|
707
|
+
timeoutIsDefault?: boolean;
|
|
708
|
+
/** Reserved for the M3.3 chain. Per-run target URL override. */
|
|
709
|
+
targetUrl?: string;
|
|
710
|
+
/**
|
|
711
|
+
* Names of `test create` flags the caller supplied that `--plan-from`
|
|
712
|
+
* ignores (identity lives in the JSON). Surfaced as a stderr advisory
|
|
713
|
+
* AFTER the plan validates, so a malformed plan (e.g. missing
|
|
714
|
+
* `projectId`) fails fast with a clear field error instead of the
|
|
715
|
+
* misleading "ignoring --project" line landing first (dogfood L1778).
|
|
716
|
+
*/
|
|
717
|
+
ignoredFlags?: string[];
|
|
718
|
+
}
|
|
719
|
+
/**
|
|
720
|
+
* `test create --plan-from <plan.json>` — M3.2 piece-5.
|
|
721
|
+
*
|
|
722
|
+
* FE-only path: agent writes a `planSteps[]` JSON file describing the
|
|
723
|
+
* test in natural language; CLI ships it to the backend; backend
|
|
724
|
+
* stores it on `FrontendTestEntity` for the browser-use Lambda to
|
|
725
|
+
* interpret at run time. The plan is the test definition — no
|
|
726
|
+
* server-side LLM compile happens at create time (that was the
|
|
727
|
+
* 2026-05-13 BE codegen scope cut; FE was never on that path).
|
|
728
|
+
*
|
|
729
|
+
* BE plans rejected pre-flight: if `plan.json` has `type: "backend"`,
|
|
730
|
+
* exit 5 `VALIDATION_ERROR` with a `nextAction` pointing at
|
|
731
|
+
* `test create --type backend --code-file <path>`. Same envelope the
|
|
732
|
+
* server would return, just emitted without burning a round trip.
|
|
733
|
+
*
|
|
734
|
+
* `--run` is reserved for the M3.3 chain — currently exits 7
|
|
735
|
+
* `UNSUPPORTED` per piece-5 spec; rewires to a real `POST /runs` call
|
|
736
|
+
* when M3.3 lands.
|
|
737
|
+
*/
|
|
738
|
+
export declare function runCreateFromPlan(opts: CreateFromPlanOptions, deps?: TestDeps): Promise<CliCreateFromPlanResponse>;
|
|
739
|
+
interface CreateBatchOptions extends CommonOptions {
|
|
740
|
+
/** Path to the JSONL file containing one `CliPlanInput` per line. */
|
|
741
|
+
plans: string;
|
|
742
|
+
/**
|
|
743
|
+
* Path to a directory containing `*.json` plan files. Globs all `*.json`
|
|
744
|
+
* files (sorted by name for determinism), assembles them in-process into the
|
|
745
|
+
* same spec array as `--plans`, then runs the existing create-batch path.
|
|
746
|
+
* Mutually exclusive with `--plans`.
|
|
747
|
+
*/
|
|
748
|
+
planFromDir?: string;
|
|
749
|
+
/** Caller-supplied idempotency token; UUIDv4 minted client-side if absent. */
|
|
750
|
+
idempotencyKey?: string;
|
|
751
|
+
/** When true, trigger a run for each created test after the batch create. */
|
|
752
|
+
run?: boolean;
|
|
753
|
+
/** With `--run`, max number of in-flight triggers at once (default: `DEFAULT_BATCH_RUN_CONCURRENCY` = 50). */
|
|
754
|
+
maxConcurrency?: number;
|
|
755
|
+
/** With `--run`, poll each run until terminal status before returning. */
|
|
756
|
+
wait?: boolean;
|
|
757
|
+
/** With `--run --wait`, per-run max seconds to wait (1..3600, default 600). */
|
|
758
|
+
timeoutSeconds?: number;
|
|
759
|
+
/** With `--run`, override the project default env URL for each triggered run. */
|
|
760
|
+
targetUrl?: string;
|
|
761
|
+
}
|
|
762
|
+
/**
|
|
763
|
+
* `test create-batch --plans <plans.jsonl>` — M3.2 piece-5.
|
|
764
|
+
*
|
|
765
|
+
* Reads one `CliPlanInput` per line of the JSONL file, ships them as
|
|
766
|
+
* a single `POST /tests/batch` request, returns per-spec results.
|
|
767
|
+
* The endpoint is FE-only; any spec with `type: "backend"` returns
|
|
768
|
+
* `validation_error` per-spec without aborting siblings.
|
|
769
|
+
*
|
|
770
|
+
* Caps:
|
|
771
|
+
* - 50 specs per batch (CLI rejects locally before sending)
|
|
772
|
+
* - 5 MB total body (CLI checks after stringify)
|
|
773
|
+
* - 200 steps + 256 KB per individual plan (per-line validation)
|
|
774
|
+
*
|
|
775
|
+
* BE specs in the batch are flagged on stderr with their `specIndex`
|
|
776
|
+
* so the operator can see what will fail server-side, but the batch
|
|
777
|
+
* still proceeds — the FE specs are perfectly valid. No interactive
|
|
778
|
+
* prompt (the CLI is CI-friendly per piece-3's convention).
|
|
779
|
+
*
|
|
780
|
+
* Exit code: `0` if **any** spec succeeded (POSIX partial-success
|
|
781
|
+
* convention per use-cases.md UC2 item 6). Non-zero only when zero
|
|
782
|
+
* specs succeeded — in which case the underlying API failure is
|
|
783
|
+
* surfaced via the normal exit-code mapper.
|
|
784
|
+
*
|
|
785
|
+
* `--run` triggers each successfully-created test after the batch
|
|
786
|
+
* create completes. `--max-concurrency` bounds the in-flight trigger
|
|
787
|
+
* count. `--wait` polls each run until terminal. `--timeout` is
|
|
788
|
+
* per-run (not aggregate). Output in JSON mode is
|
|
789
|
+
* `{ results: CliBatchRunResult[] }`. Exit code: 0 if every run
|
|
790
|
+
* passed; 1 if any failed/blocked/cancelled; 7 if ALL runs timed out;
|
|
791
|
+
* falls back to 1 for mixed outcomes.
|
|
792
|
+
*/
|
|
793
|
+
export declare function runCreateBatch(opts: CreateBatchOptions, deps?: TestDeps): Promise<CliCreateBatchResponse>;
|
|
794
|
+
interface GetOptions extends CommonOptions {
|
|
795
|
+
testId: string;
|
|
796
|
+
}
|
|
797
|
+
export declare function runGet(opts: GetOptions, deps?: TestDeps): Promise<CliTest>;
|
|
798
|
+
interface CodeGetOptions extends CommonOptions {
|
|
799
|
+
testId: string;
|
|
800
|
+
/**
|
|
801
|
+
* Optional output file path. When set, the source body (text mode) or
|
|
802
|
+
* the JSON envelope (json mode) is written to this file instead of
|
|
803
|
+
* stdout. Streaming + backpressure are preserved: presigned downloads
|
|
804
|
+
* pipe straight into the file's write stream so a multi-MB body never
|
|
805
|
+
* sits in memory waiting for the full download. Per
|
|
806
|
+
* the CLI validation spec §4 P4: "the CLI streams the body to stdout
|
|
807
|
+
* (or `--out`) without buffering the whole thing in memory."
|
|
808
|
+
*/
|
|
809
|
+
out?: string;
|
|
810
|
+
}
|
|
811
|
+
/**
|
|
812
|
+
* `test code get` — fetches §6.3 `TestCode`. JSON mode prints the wire
|
|
813
|
+
* shape verbatim (the caller decides whether to follow `code` as a URL).
|
|
814
|
+
* Text mode prints the source body itself: inline bodies pass through
|
|
815
|
+
* directly; presigned URLs are dereferenced via the same fetch impl
|
|
816
|
+
* (without API-key headers — the URL is the bearer of authority).
|
|
817
|
+
*
|
|
818
|
+
* `--out <path>` redirects the same bytes into a file. We open the file
|
|
819
|
+
* before issuing the network request so a permission/dir error fails
|
|
820
|
+
* fast (exit 5 / VALIDATION_ERROR) without spending an API call. On
|
|
821
|
+
* any error after open we tear down the sink so we don't leak a
|
|
822
|
+
* half-written artifact.
|
|
823
|
+
*/
|
|
824
|
+
export declare function runCodeGet(opts: CodeGetOptions, deps?: TestDeps): Promise<CliTestCode>;
|
|
825
|
+
/**
|
|
826
|
+
* §6.X / M3.2 piece-4 `PutTestCodeResponse` shape. `codeVersion` is
|
|
827
|
+
* the freshly bumped value the server stamped on the entity. Used as
|
|
828
|
+
* the next call's `If-Match` so an agent can chain put → put without
|
|
829
|
+
* round-tripping through `test get` between writes.
|
|
830
|
+
*/
|
|
831
|
+
export interface CliPutTestCodeResponse {
|
|
832
|
+
testId: string;
|
|
833
|
+
codeVersion: string;
|
|
834
|
+
updatedAt: string;
|
|
835
|
+
}
|
|
836
|
+
type CodePutLanguage = CliTestCode['language'];
|
|
837
|
+
interface CodePutOptions extends CommonOptions {
|
|
838
|
+
testId: string;
|
|
839
|
+
/** Source path to the new code body. Read into memory; capped at 350 KB. */
|
|
840
|
+
codeFile: string;
|
|
841
|
+
/**
|
|
842
|
+
* `If-Match: <codeVersion>` value. Mutually exclusive with `force`.
|
|
843
|
+
* When neither is set, the CLI auto-fetches the current
|
|
844
|
+
* `codeVersion` via `GET /tests/{id}/code` and uses that — a
|
|
845
|
+
* convenience for human callers; agents should set this explicitly.
|
|
846
|
+
*/
|
|
847
|
+
expectedVersion?: string;
|
|
848
|
+
/** `--force` → sends `If-Match: *`. Audit-logged with `force: true`. */
|
|
849
|
+
force?: boolean;
|
|
850
|
+
/** Optional language override; server defaults from the test's existing language otherwise. */
|
|
851
|
+
language?: CodePutLanguage;
|
|
852
|
+
/** Caller-supplied idempotency token; UUIDv4 minted client-side if absent. */
|
|
853
|
+
idempotencyKey?: string;
|
|
854
|
+
/**
|
|
855
|
+
* When set alongside `--dry-run`, synthesises an error envelope and
|
|
856
|
+
* runs through the error-handler path so the user can preview the
|
|
857
|
+
* retry-hint output and exit code without a real API key.
|
|
858
|
+
* Only `PRECONDITION_FAILED` is supported today.
|
|
859
|
+
*/
|
|
860
|
+
dryRunSimulateError?: 'PRECONDITION_FAILED';
|
|
861
|
+
}
|
|
862
|
+
/**
|
|
863
|
+
* `test code put <test-id> --code-file <path>` — M3.2 piece-4.
|
|
864
|
+
*
|
|
865
|
+
* Replace the test's code body with optimistic concurrency. Backend
|
|
866
|
+
* checks `If-Match: <codeVersion>` against the current entity row; on
|
|
867
|
+
* match, bumps to `v(N+1)` and writes the new body via
|
|
868
|
+
* `StorageService.saveCodeContent`. On mismatch, returns 412
|
|
869
|
+
* `PRECONDITION_FAILED` with `currentCodeVersion` in the error body so
|
|
870
|
+
* the caller can retry without an extra `GET`.
|
|
871
|
+
*
|
|
872
|
+
* Concurrency flag negotiation (CLI side):
|
|
873
|
+
*
|
|
874
|
+
* --expected-version <v> → If-Match: <v> (preferred for agents)
|
|
875
|
+
* --force → If-Match: * (audit-logged with force)
|
|
876
|
+
* (neither) → auto-fetch via GET, then If-Match: <fetched>
|
|
877
|
+
*
|
|
878
|
+
* The auto-fetch path is **a convenience for human callers**. Agents
|
|
879
|
+
* should always pass `--expected-version` explicitly because the
|
|
880
|
+
* auto-fetch introduces a TOCTOU window: a concurrent writer can bump
|
|
881
|
+
* the version between our GET and our PUT. The CLI emits a stderr
|
|
882
|
+
* advisory whenever it takes the auto-fetch path so an operator
|
|
883
|
+
* watching the run can see what `If-Match` value was used.
|
|
884
|
+
*
|
|
885
|
+
* `--force` and `--expected-version` are mutually exclusive — passing
|
|
886
|
+
* both is a caller bug and we reject locally (exit 5) rather than
|
|
887
|
+
* silently picking one. Same is true for missing `--code-file`.
|
|
888
|
+
*
|
|
889
|
+
* 412 handling: the CLI extracts `currentCodeVersion` from the error
|
|
890
|
+
* envelope's `details` block (server populates it per piece-1's
|
|
891
|
+
* `CliPreconditionFailedError`) and prints a typed retry hint. The
|
|
892
|
+
* underlying `ApiError` is re-thrown so the exit-code mapper in
|
|
893
|
+
* `index.ts` lands on exit 6 — the CLI does not auto-retry.
|
|
894
|
+
*
|
|
895
|
+
* Dry-run skips all I/O including the auto-fetch — we substitute the
|
|
896
|
+
* dry-run sample's `codeVersion` (`v3`) so the canned response makes
|
|
897
|
+
* sense (v3 → v4 bump). Matches piece-2's pattern.
|
|
898
|
+
*/
|
|
899
|
+
export declare function runCodePut(opts: CodePutOptions, deps?: TestDeps): Promise<CliPutTestCodeResponse>;
|
|
900
|
+
interface StepsOptions extends CommonOptions {
|
|
901
|
+
testId: string;
|
|
902
|
+
pageSize?: number;
|
|
903
|
+
startingToken?: string;
|
|
904
|
+
maxItems?: number;
|
|
905
|
+
/**
|
|
906
|
+
* When set, fetch per-run steps from the authoritative run-scoped endpoint
|
|
907
|
+
* `GET /runs/{runId}?includeSteps=true` instead of client-filtering the
|
|
908
|
+
* cumulative `/tests/{id}/steps` response.
|
|
909
|
+
*
|
|
910
|
+
* Background: FE Portal step rows in `FrontendTestStepEntity` don't reliably
|
|
911
|
+
* carry per-run `runIdIfAvailable`, so client-side filtering of the cumulative
|
|
912
|
+
* list returns an empty result for every runId (even completed runs). The
|
|
913
|
+
* run-scoped endpoint reads from `TestRunStepEntity` directly and returns
|
|
914
|
+
* only the steps for that specific run.
|
|
915
|
+
*
|
|
916
|
+
* Pagination flags (`--page-size`, `--starting-token`, `--max-items`) are
|
|
917
|
+
* ignored when `--run-id` is supplied — the run-scoped endpoint returns all
|
|
918
|
+
* steps in a single response.
|
|
919
|
+
*/
|
|
920
|
+
runId?: string;
|
|
921
|
+
}
|
|
922
|
+
export declare function runSteps(opts: StepsOptions, deps?: TestDeps): Promise<Page<CliTestStep>>;
|
|
923
|
+
interface ResultOptions extends CommonOptions {
|
|
924
|
+
testId: string;
|
|
925
|
+
/**
|
|
926
|
+
* §6.5.1 (M2.1 piece 3) — when set, the CLI requests the inline
|
|
927
|
+
* `analysis` block from the facade and renders it under the result
|
|
928
|
+
* summary in text mode. JSON mode prints the wire envelope as
|
|
929
|
+
* received (the `analysis` block lives under the `analysis` key).
|
|
930
|
+
* Optional with default `false` so pre-M2.1 callers don't have to
|
|
931
|
+
* thread the flag through every call site.
|
|
932
|
+
*/
|
|
933
|
+
includeAnalysis?: boolean;
|
|
934
|
+
}
|
|
935
|
+
export declare function runResult(opts: ResultOptions, deps?: TestDeps): Promise<CliLatestResult>;
|
|
936
|
+
/**
|
|
937
|
+
* Parse a duration string (`24h`, `7d`) or ISO timestamp to an absolute
|
|
938
|
+
* ISO string for use as the `?since=` query parameter.
|
|
939
|
+
*
|
|
940
|
+
* - `24h` → `now - 24 hours`
|
|
941
|
+
* - `7d` → `now - 7 days`
|
|
942
|
+
* - Any other value is returned verbatim (assumed to be an ISO timestamp
|
|
943
|
+
* or epoch ms string that the server will validate).
|
|
944
|
+
*
|
|
945
|
+
* Translation is done client-side per piece-5 design decision #3.
|
|
946
|
+
*/
|
|
947
|
+
export declare function parseDuration(raw: string, now?: Date): string;
|
|
948
|
+
interface ResultHistoryOptions extends CommonOptions {
|
|
949
|
+
testId: string;
|
|
950
|
+
/** Filter by trigger source. */
|
|
951
|
+
source?: RunSource;
|
|
952
|
+
/**
|
|
953
|
+
* Lower bound for `createdAt`. Accepts `24h`, `7d`, or an ISO timestamp.
|
|
954
|
+
* Translated client-side to an absolute ISO string before the request.
|
|
955
|
+
*/
|
|
956
|
+
since?: string;
|
|
957
|
+
/** Page size 1–100 (default 20). */
|
|
958
|
+
pageSize?: number;
|
|
959
|
+
/** Opaque cursor from a prior page's `nextCursor`. */
|
|
960
|
+
cursor?: string;
|
|
961
|
+
}
|
|
962
|
+
/**
|
|
963
|
+
* `test result <test-id> --history [options]`
|
|
964
|
+
*
|
|
965
|
+
* List a test's prior runs (M3.4 piece-5). Complements the M2 `test result`
|
|
966
|
+
* "latest result" mode (unchanged). Branches on `--history` inside the shared
|
|
967
|
+
* action handler — the function exposed here is the `--history` branch only;
|
|
968
|
+
* bare `test result <id>` continues to call `runResult`.
|
|
969
|
+
*/
|
|
970
|
+
export declare function runResultHistory(opts: ResultHistoryOptions, deps?: TestDeps): Promise<ListRunsResponse>;
|
|
971
|
+
interface FailureSummaryOptions extends CommonOptions {
|
|
972
|
+
testId: string;
|
|
973
|
+
}
|
|
974
|
+
/**
|
|
975
|
+
* `test failure summary <test-id>` — M2.1 piece 3.
|
|
976
|
+
*
|
|
977
|
+
* Sibling of `test failure get`. Returns one-screen failure triage
|
|
978
|
+
* info (status, failureKind, root-cause hypothesis, suggested fix
|
|
979
|
+
* target if the analysis pipeline produced one) without downloading
|
|
980
|
+
* video, screenshots, or DOM snapshots. The command an agent should
|
|
981
|
+
* reach for first when investigating a reported failure.
|
|
982
|
+
*
|
|
983
|
+
* 404 NOT_FOUND propagates as exit 4. The facade's `details.reason`
|
|
984
|
+
* (`not_found` / `no_failing_run`) reaches the user via the
|
|
985
|
+
* `nextAction` template.
|
|
986
|
+
*/
|
|
987
|
+
export declare function runFailureSummary(opts: FailureSummaryOptions, deps?: TestDeps): Promise<CliFailureSummary>;
|
|
988
|
+
interface FailureGetOptions extends CommonOptions {
|
|
989
|
+
testId: string;
|
|
990
|
+
/**
|
|
991
|
+
* Directory to write the §7 disk layout into. When unset, the CLI
|
|
992
|
+
* prints the wire envelope (`--output json`) or a human summary
|
|
993
|
+
* (`--output text`) to stdout — useful for an agent piping straight
|
|
994
|
+
* to a vision-aware LLM. When set, stdout is silent on success
|
|
995
|
+
* (the on-disk artifact is the contract).
|
|
996
|
+
*/
|
|
997
|
+
out?: string;
|
|
998
|
+
/** §7.4 — keep only the failed step ± 1 in `steps[]` and `evidence[]`. */
|
|
999
|
+
failedOnly: boolean;
|
|
1000
|
+
}
|
|
1001
|
+
export interface FailureGetResult {
|
|
1002
|
+
/** The wire envelope as returned by the facade. */
|
|
1003
|
+
context: CliFailureContext;
|
|
1004
|
+
/** Set when `--out` was used; otherwise undefined. */
|
|
1005
|
+
bundle?: WriteBundleResult;
|
|
1006
|
+
}
|
|
1007
|
+
/**
|
|
1008
|
+
* `test failure get` — the agent-facing entry point. Fetches the §6.7
|
|
1009
|
+
* `FailureContext` for `<test-id>` and either writes the §7 disk
|
|
1010
|
+
* layout (when `--out` is set) or prints the wire envelope to stdout
|
|
1011
|
+
* (default).
|
|
1012
|
+
*
|
|
1013
|
+
* Without `--out`:
|
|
1014
|
+
* - `--output json` (the agent default) — full wire envelope on
|
|
1015
|
+
* stdout. Presigned URLs left intact for the agent to fetch on
|
|
1016
|
+
* its own.
|
|
1017
|
+
* - `--output text` — human summary block (status, failureKind,
|
|
1018
|
+
* failedStepIndex, hypothesis, fix target, evidence count).
|
|
1019
|
+
*
|
|
1020
|
+
* With `--out <dir>`:
|
|
1021
|
+
* - Atomic write under `<dir>/.tmp/...` → `rename()`. `meta.json`
|
|
1022
|
+
* renames last; its presence implies "bundle complete and
|
|
1023
|
+
* self-consistent." On any failure, `<dir>/.partial` is written
|
|
1024
|
+
* and the CLI exits non-zero with the underlying error code.
|
|
1025
|
+
* - stdout prints one line per output mode after the bundle is
|
|
1026
|
+
* written, matching the rest of M2's `--out` ergonomics.
|
|
1027
|
+
*
|
|
1028
|
+
* 404 NOT_FOUND propagates as exit 4. The facade's `details.reason`
|
|
1029
|
+
* (`not_found` / `no_failing_run` / `no_code`) reaches the user via
|
|
1030
|
+
* the `nextAction` template — the CLI doesn't re-derive its own
|
|
1031
|
+
* remediation text per §5.4.
|
|
1032
|
+
*/
|
|
1033
|
+
export declare function runFailureGet(opts: FailureGetOptions, deps?: TestDeps): Promise<FailureGetResult>;
|
|
1034
|
+
interface RunTestRunOptions extends CommonOptions {
|
|
1035
|
+
testId: string;
|
|
1036
|
+
targetUrl?: string;
|
|
1037
|
+
wait: boolean;
|
|
1038
|
+
timeoutSeconds: number;
|
|
1039
|
+
/**
|
|
1040
|
+
* B2(c): true when --timeout was not explicitly set by the user (the default
|
|
1041
|
+
* is in effect). Used to decide whether to emit the first-run hint.
|
|
1042
|
+
* Defaults to false (no hint) when not set; only the `test run` / `test
|
|
1043
|
+
* create --run` command wiring sets this to `cmdOpts.timeout === undefined`.
|
|
1044
|
+
*/
|
|
1045
|
+
timeoutIsDefault?: boolean;
|
|
1046
|
+
idempotencyKey?: string;
|
|
1047
|
+
/**
|
|
1048
|
+
* Per codex round-1 P1: when chained from `test create --run`, the caller
|
|
1049
|
+
* passes the create response here so `runTestRun` can emit a single merged
|
|
1050
|
+
* envelope `{ ...createContext, run: <trigger|final> }` on stdout. Without
|
|
1051
|
+
* this, `test create --run --output json` produces two JSON objects back-to-
|
|
1052
|
+
* back and agents cannot `JSON.parse` the result.
|
|
1053
|
+
*/
|
|
1054
|
+
createContext?: CliCreateTestResponse | CliCreateFromPlanResponse;
|
|
1055
|
+
/**
|
|
1056
|
+
* Optional type hint supplied by the caller when the type is already known
|
|
1057
|
+
* client-side (e.g. the `test create --run` chain knows `opts.type`).
|
|
1058
|
+
* Used to derive `isBackend` for the step-summary renderer BEFORE the
|
|
1059
|
+
* `beFallbackUsed` fallback fires, so fast backend runs that are terminal
|
|
1060
|
+
* on the first poll still render `steps: n/a (backend)` correctly.
|
|
1061
|
+
* Leave unset for `test run <id>` where the type is only discoverable via
|
|
1062
|
+
* the `resolveAlternate` probe (an extra round-trip we deliberately avoid).
|
|
1063
|
+
*/
|
|
1064
|
+
type?: 'frontend' | 'backend';
|
|
1065
|
+
}
|
|
1066
|
+
interface RunTestWaitOptions extends CommonOptions {
|
|
1067
|
+
runId: string;
|
|
1068
|
+
timeoutSeconds: number;
|
|
1069
|
+
}
|
|
1070
|
+
interface RunTestRerunOptions extends CommonOptions {
|
|
1071
|
+
/** One or more testIds to rerun. Empty + all=false → validation error (exit 5). */
|
|
1072
|
+
testIds: string[];
|
|
1073
|
+
/** --all: resolve all tests in the project and batch-rerun them. */
|
|
1074
|
+
all: boolean;
|
|
1075
|
+
/** --project: used with --all to resolve the project's tests. */
|
|
1076
|
+
projectId?: string;
|
|
1077
|
+
/** --wait: block until terminal (or --timeout). */
|
|
1078
|
+
wait: boolean;
|
|
1079
|
+
/** Polling / overall deadline. Default 600, max 3600. */
|
|
1080
|
+
timeoutSeconds: number;
|
|
1081
|
+
/**
|
|
1082
|
+
* Auto-heal: defaults true for FE reruns (use --no-auto-heal to opt out).
|
|
1083
|
+
* Backend ignores the server-side tier gate for CLI callers — Free + paid
|
|
1084
|
+
* both get auto-heal; charged 0.2 credits per engage when Phase-2 runs.
|
|
1085
|
+
*/
|
|
1086
|
+
autoHeal: boolean;
|
|
1087
|
+
/**
|
|
1088
|
+
* Whether the user explicitly requested a specific auto-heal state via a
|
|
1089
|
+
* flag (as opposed to the default-on value). Used to suppress the BE-test
|
|
1090
|
+
* "ignoring auto-heal" warning when the value was never explicitly set.
|
|
1091
|
+
*
|
|
1092
|
+
* With `--no-auto-heal` as the only flag (no `--auto-heal`), this is always
|
|
1093
|
+
* false — the default-on value is never an explicit user request, so the BE
|
|
1094
|
+
* warning is suppressed on every default-on rerun. Only future addition of
|
|
1095
|
+
* an explicit `--auto-heal` flag would set this to true.
|
|
1096
|
+
*/
|
|
1097
|
+
autoHealExplicit: boolean;
|
|
1098
|
+
/** --skip-dependencies: BE only. Don't expand the producer/teardown closure. */
|
|
1099
|
+
skipDependencies: boolean;
|
|
1100
|
+
/** --max-concurrency: bounds the --wait poll fan-out (batch / BE closure). */
|
|
1101
|
+
maxConcurrency: number;
|
|
1102
|
+
/** --idempotency-key: caller-supplied; auto-minted UUID when absent. */
|
|
1103
|
+
idempotencyKey?: string;
|
|
1104
|
+
/**
|
|
1105
|
+
* --skip-terminal: with --all, exclude tests already in a terminal status
|
|
1106
|
+
* (passed|failed|blocked|cancelled) before dispatch so an interrupted sweep
|
|
1107
|
+
* doesn't re-replay finished tests.
|
|
1108
|
+
*/
|
|
1109
|
+
skipTerminal?: boolean;
|
|
1110
|
+
/**
|
|
1111
|
+
* --status <list>: comma-separated list of public status values. With --all,
|
|
1112
|
+
* only tests whose status matches one of the listed values are dispatched.
|
|
1113
|
+
* Reuses the same validated set as `test list --status`.
|
|
1114
|
+
*/
|
|
1115
|
+
statusFilter?: string;
|
|
1116
|
+
/**
|
|
1117
|
+
* --filter <substr>: with --all, only rerun tests whose name contains this
|
|
1118
|
+
* substring (case-insensitive). Applied after --skip-terminal and --status
|
|
1119
|
+
* filters. Client-side only.
|
|
1120
|
+
*/
|
|
1121
|
+
nameFilter?: string;
|
|
1122
|
+
}
|
|
1123
|
+
/**
|
|
1124
|
+
* Decide whether a testId-scoped result belongs to THIS run (vs a stale
|
|
1125
|
+
* verdict from a prior run of the same test). Backend serializes runs per
|
|
1126
|
+
* testId, so the next terminal verdict after our trigger is ours — but a
|
|
1127
|
+
* just-finished prior run could still be showing. Gate:
|
|
1128
|
+
* - result names our runId → accept (strongest signal);
|
|
1129
|
+
* - result names a different runId → reject (a different run);
|
|
1130
|
+
* - result has no runId (legacy) → accept iff finishedAt >= notBefore.
|
|
1131
|
+
*/
|
|
1132
|
+
export declare function backendResultIsForThisRun(result: CliLatestResult, runId: string, notBefore: string | undefined): boolean;
|
|
1133
|
+
/**
|
|
1134
|
+
* `test run <test-id>` — M3.3 piece-3.
|
|
1135
|
+
*
|
|
1136
|
+
* Triggers a run via `POST /api/cli/v1/tests/{testId}/runs`. With
|
|
1137
|
+
* `--wait`, polls until terminal status (via `pollRunUntilTerminal`).
|
|
1138
|
+
* Exit code is 0 on `passed`, 1 on `failed`/`blocked`/`cancelled`,
|
|
1139
|
+
* 7 on timeout.
|
|
1140
|
+
*/
|
|
1141
|
+
export declare function runTestRun(opts: RunTestRunOptions, deps?: TestDeps): Promise<TriggerRunResponse | RunResponse>;
|
|
1142
|
+
/**
|
|
1143
|
+
* `test wait <run-id>` — M3.3 piece-3.
|
|
1144
|
+
*
|
|
1145
|
+
* Polls `GET /api/cli/v1/runs/{runId}` until terminal status. Exit
|
|
1146
|
+
* codes match the `--wait` behavior matrix in the spec.
|
|
1147
|
+
*/
|
|
1148
|
+
export declare function runTestWait(opts: RunTestWaitOptions, deps?: TestDeps): Promise<RunResponse>;
|
|
1149
|
+
interface RunTestRunAllOptions extends CommonOptions {
|
|
1150
|
+
/** projectId to run all BE tests in. */
|
|
1151
|
+
projectId: string;
|
|
1152
|
+
/** --filter <substr>: only run tests whose name contains this substring (case-insensitive). */
|
|
1153
|
+
nameFilter?: string;
|
|
1154
|
+
/** --wait: block until terminal or --timeout. */
|
|
1155
|
+
wait: boolean;
|
|
1156
|
+
/** Polling / overall deadline in seconds. Default 600, max 3600. */
|
|
1157
|
+
timeoutSeconds: number;
|
|
1158
|
+
/** --max-concurrency: bounds the --wait poll fan-out. */
|
|
1159
|
+
maxConcurrency: number;
|
|
1160
|
+
/** Caller-supplied idempotency token; auto-minted if absent. */
|
|
1161
|
+
idempotencyKey?: string;
|
|
1162
|
+
}
|
|
1163
|
+
/**
|
|
1164
|
+
* `test run --all --project <id>` — M4 piece-2.
|
|
1165
|
+
*
|
|
1166
|
+
* Triggers a fresh wave-ordered batch run via `POST /tests/batch/run`.
|
|
1167
|
+
* FE tests in the project are skipped by the BE-only engine (advisory).
|
|
1168
|
+
* With `--wait`, polls each accepted runId.
|
|
1169
|
+
*/
|
|
1170
|
+
export declare function runTestRunAll(opts: RunTestRunAllOptions, deps?: TestDeps): Promise<BatchRunFreshResponse | undefined>;
|
|
1171
|
+
/**
|
|
1172
|
+
* `test rerun` — M3.4 piece-3.
|
|
1173
|
+
*
|
|
1174
|
+
* FE: `POST /tests/{id}/runs/rerun` → verbatim replay (no credit). With
|
|
1175
|
+
* `--wait`, polls `GET /runs/{runId}` until terminal.
|
|
1176
|
+
*
|
|
1177
|
+
* BE: same route → closure + per-member runIds. With `--wait`, polls every
|
|
1178
|
+
* closure-member runId; exits on the named test's verdict; failed closure
|
|
1179
|
+
* members surface as warnings + `closureFailures[]` in JSON.
|
|
1180
|
+
*
|
|
1181
|
+
* Batch / `--all`: `POST /tests/batch/rerun` → per-test runIds. With
|
|
1182
|
+
* `--wait`, fan-out poll under `--max-concurrency`. `deferred[]` → exit 7.
|
|
1183
|
+
*/
|
|
1184
|
+
export declare function runTestRerun(opts: RunTestRerunOptions, deps?: TestDeps): Promise<RerunResponse | BatchRerunResponse | undefined>;
|
|
1185
|
+
export interface ArtifactGetOptions extends CommonOptions {
|
|
1186
|
+
runId: string;
|
|
1187
|
+
/**
|
|
1188
|
+
* Directory to write the §7 disk layout into. When absent, defaults to
|
|
1189
|
+
* `./.testsprite/runs/<run-id>/` (computed at action time from `process.cwd()`).
|
|
1190
|
+
* The default is intentionally not stored here to ensure it is computed freshly
|
|
1191
|
+
* at action time; pass the resolved path when you want an explicit directory.
|
|
1192
|
+
*/
|
|
1193
|
+
out?: string;
|
|
1194
|
+
/** §7.4 — keep only the failed step ± 1 in `steps[]` and `evidence[]`. */
|
|
1195
|
+
failedOnly: boolean;
|
|
1196
|
+
}
|
|
1197
|
+
export interface ArtifactGetResult {
|
|
1198
|
+
/** The wire envelope as returned by the facade. */
|
|
1199
|
+
context: CliFailureContext;
|
|
1200
|
+
/** Set when bundle was written to disk. */
|
|
1201
|
+
bundle?: WriteBundleResult;
|
|
1202
|
+
}
|
|
1203
|
+
/**
|
|
1204
|
+
* Validate that the parent directory of `resolvedDir` exists and is a
|
|
1205
|
+
* directory. Surfaces `VALIDATION_ERROR` (exit 5) — matches the convention
|
|
1206
|
+
* from `closeOutputFile` for single-file `--out` flags (P4 D4 convention).
|
|
1207
|
+
*
|
|
1208
|
+
* The bundle directory itself (`resolvedDir`) may or may not exist;
|
|
1209
|
+
* `writeBundle` creates it if absent.
|
|
1210
|
+
*/
|
|
1211
|
+
export declare function assertOutDirParentExists(resolvedDir: string): Promise<void>;
|
|
1212
|
+
/**
|
|
1213
|
+
* `test artifact get <run-id>` — run-scoped failure-bundle download.
|
|
1214
|
+
*
|
|
1215
|
+
* Downloads `GET /api/cli/v1/runs/{runId}/failure` and either:
|
|
1216
|
+
* - Writes the §7 disk layout under `<dir>` (default `./.testsprite/runs/<run-id>/`)
|
|
1217
|
+
* - Or prints the wire envelope / human summary to stdout when `--out` is absent.
|
|
1218
|
+
*
|
|
1219
|
+
* Differences from M2 `test failure get`:
|
|
1220
|
+
* - Addresses the bundle by `runId` (exact run) not `testId` (latest).
|
|
1221
|
+
* - Enforces `meta.runId === <run-id>` as a cross-check against backend bugs.
|
|
1222
|
+
* - Passes `{ requireRunId: true }` to `assertContextIntegrity`.
|
|
1223
|
+
*/
|
|
1224
|
+
export declare function runArtifactGet(opts: ArtifactGetOptions, deps?: TestDeps): Promise<ArtifactGetResult>;
|
|
1225
|
+
export declare function createTestCommand(deps?: TestDeps): Command;
|
|
1226
|
+
/**
|
|
1227
|
+
* D4 (dogfood CoderCup 2026-06-05): under `--wait` the user opts into a
|
|
1228
|
+
* long-running operation bounded by `--timeout`. The default 120s per-request
|
|
1229
|
+
* timeout can falsely cut a single trigger or long-poll request when the
|
|
1230
|
+
* backend is slow under load (e.g. a large concurrent batch) — failing the
|
|
1231
|
+
* command even though `--timeout` is large and the run finishes fine
|
|
1232
|
+
* server-side. Raise the per-request window to cover `--timeout` (capped at
|
|
1233
|
+
* {@link REQUEST_TIMEOUT_MAX_MS}, floored at the resolved default so we never
|
|
1234
|
+
* lower it). The poll loop's own deadline-aware `AbortSignal` (poll.ts) still
|
|
1235
|
+
* bounds the TOTAL wait to `--timeout`; non-wait callers are unchanged.
|
|
1236
|
+
*/
|
|
1237
|
+
export declare function resolveWaitRequestTimeoutMs(opts: {
|
|
1238
|
+
wait?: boolean;
|
|
1239
|
+
timeoutSeconds?: number;
|
|
1240
|
+
requestTimeoutMs?: number;
|
|
1241
|
+
}): number | undefined;
|
|
1242
|
+
/** A presigned `code` body is any `https://` URL — never anything else. */
|
|
1243
|
+
export declare function isPresignedCodeUrl(code: string): boolean;
|
|
1244
|
+
export declare function createTestArtifactCommand(deps: TestDeps): Command;
|
|
1245
|
+
export {};
|