@testsprite/testsprite-cli 0.6.0 → 0.7.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.
Files changed (50) hide show
  1. package/README.md +38 -30
  2. package/dist/commands/agent.js +44 -42
  3. package/dist/commands/doctor.d.ts +1 -1
  4. package/dist/commands/doctor.js +4 -7
  5. package/dist/commands/project.js +3 -2
  6. package/dist/commands/schedule.d.ts +120 -0
  7. package/dist/commands/schedule.js +487 -0
  8. package/dist/commands/test.d.ts +15 -1
  9. package/dist/commands/test.js +460 -256
  10. package/dist/commands/testlist.d.ts +88 -0
  11. package/dist/commands/testlist.js +747 -0
  12. package/dist/index.js +6 -2
  13. package/dist/lib/agent-targets.d.ts +13 -4
  14. package/dist/lib/agent-targets.js +11 -2
  15. package/dist/lib/conflict-reason.d.ts +30 -0
  16. package/dist/lib/conflict-reason.js +45 -0
  17. package/dist/lib/credentials.js +42 -1
  18. package/dist/lib/cron.d.ts +40 -0
  19. package/dist/lib/cron.js +190 -0
  20. package/dist/lib/dry-run/samples.js +177 -55
  21. package/dist/lib/errors.d.ts +9 -0
  22. package/dist/lib/errors.js +11 -0
  23. package/dist/lib/gh-output.d.ts +26 -1
  24. package/dist/lib/gh-output.js +47 -20
  25. package/dist/lib/http.d.ts +25 -0
  26. package/dist/lib/http.js +128 -2
  27. package/dist/lib/junit-report.d.ts +20 -2
  28. package/dist/lib/junit-report.js +38 -5
  29. package/dist/lib/proxy.d.ts +16 -0
  30. package/dist/lib/proxy.js +19 -1
  31. package/dist/lib/response-schemas.d.ts +7 -0
  32. package/dist/lib/response-schemas.js +23 -1
  33. package/dist/lib/runs.types.d.ts +8 -3
  34. package/dist/lib/secret-file.d.ts +15 -0
  35. package/dist/lib/secret-file.js +82 -0
  36. package/dist/lib/target-url-preflight.d.ts +91 -0
  37. package/dist/lib/target-url-preflight.js +259 -0
  38. package/dist/lib/target-url.d.ts +22 -5
  39. package/dist/lib/target-url.js +60 -28
  40. package/dist/lib/testlist.types.d.ts +77 -0
  41. package/dist/lib/testlist.types.js +9 -0
  42. package/dist/lib/v3-advisory.d.ts +35 -22
  43. package/dist/lib/v3-advisory.js +44 -24
  44. package/dist/lib/wait-exit.d.ts +29 -0
  45. package/dist/lib/wait-exit.js +103 -0
  46. package/dist/version-guard.d.ts +10 -7
  47. package/dist/version-guard.js +37 -9
  48. package/dist/version.d.ts +1 -1
  49. package/dist/version.js +1 -1
  50. package/package.json +1 -1
@@ -7,6 +7,12 @@ const SAMPLE_TEST_ID_FAILED = 'test_8f2a4d10';
7
7
  const SAMPLE_TEST_ID_PASSED = 'test_3a91bb02';
8
8
  const SAMPLE_TEST_ID_BLOCKED = 'test_blocked_4f7a';
9
9
  export const SAMPLE_RUN_ID = 'run_abc';
10
+ const SAMPLE_SCHEDULE_ID = 'sch_7d21ac48';
11
+ const SAMPLE_SCHEDULE_RUN_ID = 'exec_5c08f1b2';
12
+ // Documented sentinel for `test steps --run-id run_failed_sample --dry-run`:
13
+ // keeps wait flows on the default passed sample while still demonstrating a
14
+ // run-scoped failed step offline.
15
+ const SAMPLE_FAILED_RUN_ID = 'run_failed_sample';
10
16
  // M3.4 rerun dry-run sample IDs
11
17
  const SAMPLE_RERUN_ID_BE_NAMED = 'run_rerun_be_named';
12
18
  const SAMPLE_RERUN_ID_BE_PRODUCER = 'run_rerun_be_producer';
@@ -87,6 +93,34 @@ const projects = [
87
93
  updatedAt: '2026-05-04T19:30:00.000Z',
88
94
  },
89
95
  ];
96
+ const schedule = {
97
+ scheduleId: SAMPLE_SCHEDULE_ID,
98
+ name: 'Nightly checkout',
99
+ enabled: true,
100
+ targetType: 'project',
101
+ targetId: SAMPLE_PROJECT_ID,
102
+ cron: '0 3 * * *',
103
+ timezone: 'UTC',
104
+ startAt: '2026-05-01T00:00:00.000Z',
105
+ endAt: null,
106
+ sendTo: null,
107
+ autoPausedAt: null,
108
+ lastRunId: SAMPLE_SCHEDULE_RUN_ID,
109
+ createdAt: '2026-05-01T00:00:00.000Z',
110
+ updatedAt: '2026-05-02T00:00:00.000Z',
111
+ };
112
+ // A finished run with one failure — more instructive for a dry-run learner than
113
+ // an all-green one, since it shows how the per-status counts relate to `status`.
114
+ const scheduleRun = {
115
+ runId: SAMPLE_SCHEDULE_RUN_ID,
116
+ scheduleId: SAMPLE_SCHEDULE_ID,
117
+ status: 'failed',
118
+ projectId: SAMPLE_PROJECT_ID,
119
+ testListId: null,
120
+ stats: { total: 4, passed: 3, failed: 1, blocked: 0, running: 0, cancelled: 0 },
121
+ createdAt: '2026-05-02T03:00:00.000Z',
122
+ updatedAt: '2026-05-02T03:06:41.000Z',
123
+ };
90
124
  const tests = [
91
125
  {
92
126
  id: SAMPLE_TEST_ID_FAILED,
@@ -293,6 +327,116 @@ const failureSummary = {
293
327
  rootCauseHypothesis: failureContext.failure.rootCauseHypothesis,
294
328
  recommendedFixTarget: failureContext.failure.recommendedFixTarget,
295
329
  };
330
+ const passedRunSample = {
331
+ runId: SAMPLE_RUN_ID,
332
+ testId: SAMPLE_TEST_ID_PASSED,
333
+ projectId: SAMPLE_PROJECT_ID,
334
+ userId: SAMPLE_USER_ID,
335
+ status: 'passed',
336
+ source: 'cli',
337
+ createdAt: '2026-05-15T19:32:00.000Z',
338
+ startedAt: '2026-05-15T19:32:05.000Z',
339
+ finishedAt: '2026-05-15T19:34:00.000Z',
340
+ codeVersion: 'v1',
341
+ targetUrl: SAMPLE_TARGET_URL,
342
+ createdFrom: null,
343
+ failedStepIndex: null,
344
+ failureKind: null,
345
+ error: null,
346
+ videoUrl: null,
347
+ stepSummary: {
348
+ total: 2,
349
+ completed: 2,
350
+ passedCount: 2,
351
+ failedCount: 0,
352
+ },
353
+ // Representative per-run steps so `test steps --run-id <id> --dry-run`
354
+ // demonstrates real output instead of an empty list (the generic
355
+ // `/runs/{runId}` sample is also used by `test wait`, which ignores steps).
356
+ steps: [
357
+ {
358
+ stepIndex: '0001',
359
+ type: 'action',
360
+ action: 'navigate',
361
+ status: 'passed',
362
+ description: 'Open the target URL',
363
+ error: null,
364
+ screenshotUrl: null,
365
+ htmlSnapshotUrl: null,
366
+ createdAt: '2026-05-15T19:32:10.000Z',
367
+ },
368
+ {
369
+ stepIndex: '0002',
370
+ type: 'assertion',
371
+ action: 'assert_visible',
372
+ status: 'passed',
373
+ description: 'Dashboard heading is visible',
374
+ error: null,
375
+ screenshotUrl: null,
376
+ htmlSnapshotUrl: null,
377
+ createdAt: '2026-05-15T19:32:20.000Z',
378
+ },
379
+ ],
380
+ };
381
+ const failedRunSample = {
382
+ runId: SAMPLE_FAILED_RUN_ID,
383
+ testId: SAMPLE_TEST_ID_FAILED,
384
+ projectId: SAMPLE_PROJECT_ID,
385
+ userId: SAMPLE_USER_ID,
386
+ status: 'failed',
387
+ source: 'cli',
388
+ createdAt: '2026-05-15T19:32:00.000Z',
389
+ startedAt: '2026-05-15T19:32:05.000Z',
390
+ finishedAt: '2026-05-15T19:34:00.000Z',
391
+ codeVersion: 'v1',
392
+ targetUrl: SAMPLE_TARGET_URL,
393
+ createdFrom: null,
394
+ failedStepIndex: 3,
395
+ failureKind: 'assertion',
396
+ error: 'Expected billing status badge to be visible, but it was not found.',
397
+ videoUrl: null,
398
+ stepSummary: {
399
+ total: 3,
400
+ completed: 3,
401
+ passedCount: 2,
402
+ failedCount: 1,
403
+ },
404
+ steps: [
405
+ {
406
+ stepIndex: '0001',
407
+ type: 'action',
408
+ action: 'navigate',
409
+ status: 'passed',
410
+ description: 'Open the target URL',
411
+ error: null,
412
+ screenshotUrl: null,
413
+ htmlSnapshotUrl: null,
414
+ createdAt: '2026-05-15T19:32:10.000Z',
415
+ },
416
+ {
417
+ stepIndex: '0002',
418
+ type: 'assertion',
419
+ action: 'assert_visible',
420
+ status: 'passed',
421
+ description: 'Dashboard heading is visible',
422
+ error: null,
423
+ screenshotUrl: null,
424
+ htmlSnapshotUrl: null,
425
+ createdAt: '2026-05-15T19:32:20.000Z',
426
+ },
427
+ {
428
+ stepIndex: '0003',
429
+ type: 'assertion',
430
+ action: 'assert_visible',
431
+ status: 'failed',
432
+ description: 'Billing status badge is visible',
433
+ error: 'Expected billing status badge to be visible, but it was not found.',
434
+ screenshotUrl: null,
435
+ htmlSnapshotUrl: null,
436
+ createdAt: '2026-05-15T19:32:30.000Z',
437
+ },
438
+ ],
439
+ };
296
440
  const PATH_PREFIX = '/api/cli/v1';
297
441
  const ENTRIES = [
298
442
  entry('whoami', 'GET', '/me', me),
@@ -623,57 +767,8 @@ const ENTRIES = [
623
767
  // fix(2026-05-21): a duplicate failed-shape entry that appeared before
624
768
  // this entry was removed; findSample first-match-wins was always
625
769
  // returning status: "failed" for `test wait --dry-run`.
626
- entry('getRun', 'GET', '/runs/{runId}', {
627
- runId: SAMPLE_RUN_ID,
628
- testId: SAMPLE_TEST_ID_PASSED,
629
- projectId: SAMPLE_PROJECT_ID,
630
- userId: SAMPLE_USER_ID,
631
- status: 'passed',
632
- source: 'cli',
633
- createdAt: '2026-05-15T19:32:00.000Z',
634
- startedAt: '2026-05-15T19:32:05.000Z',
635
- finishedAt: '2026-05-15T19:34:00.000Z',
636
- codeVersion: 'v1',
637
- targetUrl: SAMPLE_TARGET_URL,
638
- createdFrom: null,
639
- failedStepIndex: null,
640
- failureKind: null,
641
- error: null,
642
- videoUrl: null,
643
- stepSummary: {
644
- total: 8,
645
- completed: 8,
646
- passedCount: 8,
647
- failedCount: 0,
648
- },
649
- // Representative per-run steps so `test steps --run-id <id> --dry-run`
650
- // demonstrates real output instead of an empty list (the generic
651
- // `/runs/{runId}` sample is also used by `test wait`, which ignores steps).
652
- steps: [
653
- {
654
- stepIndex: '0001',
655
- type: 'action',
656
- action: 'navigate',
657
- status: 'passed',
658
- description: 'Open the target URL',
659
- error: null,
660
- screenshotUrl: null,
661
- htmlSnapshotUrl: null,
662
- createdAt: '2026-05-15T19:32:10.000Z',
663
- },
664
- {
665
- stepIndex: '0002',
666
- type: 'assertion',
667
- action: 'assert_visible',
668
- status: 'passed',
669
- description: 'Dashboard heading is visible',
670
- error: null,
671
- screenshotUrl: null,
672
- htmlSnapshotUrl: null,
673
- createdAt: '2026-05-15T19:32:20.000Z',
674
- },
675
- ],
676
- }),
770
+ entry('getRun', 'GET', `/runs/${SAMPLE_FAILED_RUN_ID}`, failedRunSample),
771
+ entry('getRun', 'GET', '/runs/{runId}', passedRunSample),
677
772
  // DEV-331 piece 3 — POST /runs/{runId}/cancel. Method-guarded in
678
773
  // `findSample` (POST vs `getRun`'s GET), so this can't be shadowed by the
679
774
  // broader `/runs/{runId}` pattern above despite sharing its path prefix.
@@ -704,6 +799,35 @@ const ENTRIES = [
704
799
  },
705
800
  alreadyCancelled: false,
706
801
  }),
802
+ // Schedules. The `/schedules/{id}/runs` entry MUST come before the
803
+ // `/schedules/{id}` entries so the more specific path wins the regex match
804
+ // (first-match-wins).
805
+ entry('listScheduleRuns', 'GET', '/schedules/{scheduleId}/runs', {
806
+ runs: [scheduleRun],
807
+ }),
808
+ entry('listSchedules', 'GET', '/schedules', { schedules: [schedule] }),
809
+ // `schedule create --dry-run` exits before the HTTP client is built, so this
810
+ // sample is not fetched. Registered as a shape-guard only, same as
811
+ // `deleteBatch` above.
812
+ entry('createSchedule', 'POST', '/schedules', { scheduleId: 'sch_dryrun_2026' }),
813
+ entry('getSchedule', 'GET', '/schedules/{scheduleId}', schedule),
814
+ // Echoes the requested change so a caller can confirm the flags they passed
815
+ // reached the body, rather than showing an unrelated canned schedule.
816
+ entry('updateSchedule', 'PATCH', '/schedules/{scheduleId}', (req) => {
817
+ const patch = req != null && typeof req === 'object' ? req : {};
818
+ return {
819
+ ...schedule,
820
+ ...(typeof patch.name === 'string' ? { name: patch.name } : {}),
821
+ ...(typeof patch.enabled === 'boolean' ? { enabled: patch.enabled } : {}),
822
+ ...(typeof patch.cron === 'string' ? { cron: patch.cron } : {}),
823
+ ...(typeof patch.timezone === 'string' ? { timezone: patch.timezone } : {}),
824
+ ...(typeof patch.sendTo === 'string' ? { sendTo: patch.sendTo } : {}),
825
+ updatedAt: '2026-05-16T00:00:00.000Z',
826
+ };
827
+ }),
828
+ entry('deleteSchedule', 'DELETE', '/schedules/{scheduleId}', {
829
+ scheduleId: SAMPLE_SCHEDULE_ID,
830
+ }),
707
831
  ];
708
832
  function entry(operationId, method, pathTemplate, body) {
709
833
  // Convert `/tests/{testId}/code` → /^\/tests\/[^/]+\/code$/
@@ -742,10 +866,8 @@ export function findSample(method, url, requestBody) {
742
866
  const pathOnly = extractPath(url);
743
867
  for (const e of ENTRIES) {
744
868
  if (e.method === upper && e.pattern.test(pathOnly)) {
745
- // Rebind body so callers get the resolved value, not the factory.
746
- // We return a new object with `body` already applied so downstream
747
- // code can keep calling `e.body` as-before (no API break for tests
748
- // that call `findSample` directly).
869
+ // Rebind body so downstream code can call `e.body` as before while
870
+ // still preserving the original lazy factory semantics.
749
871
  return { ...e, body: () => e.body(requestBody) };
750
872
  }
751
873
  }
@@ -11,6 +11,15 @@ export declare function isErrorCode(value: unknown): value is ErrorCode;
11
11
  * not by exit code.
12
12
  */
13
13
  export declare function exitCodeFor(code: ErrorCode): number;
14
+ /**
15
+ * Whether an error code is an authentication failure. DERIVED from the single
16
+ * `exitCodeFor` mapping (auth === exit 3) rather than a second hand-maintained
17
+ * list of code strings: a future `AUTH_*` code gets classified as auth the
18
+ * moment it is given an exit-3 row, so it can never be present in one place and
19
+ * missing in the other. The `ERROR_CODES` membership check keeps `exitCodeFor`
20
+ * off unknown/out-of-contract strings (its switch has no default).
21
+ */
22
+ export declare function isAuthCode(code: string): boolean;
14
23
  export declare class CLIError extends Error {
15
24
  readonly exitCode: number;
16
25
  constructor(message: string, exitCode?: number);
@@ -102,6 +102,17 @@ export function exitCodeFor(code) {
102
102
  return 1;
103
103
  }
104
104
  }
105
+ /**
106
+ * Whether an error code is an authentication failure. DERIVED from the single
107
+ * `exitCodeFor` mapping (auth === exit 3) rather than a second hand-maintained
108
+ * list of code strings: a future `AUTH_*` code gets classified as auth the
109
+ * moment it is given an exit-3 row, so it can never be present in one place and
110
+ * missing in the other. The `ERROR_CODES` membership check keeps `exitCodeFor`
111
+ * off unknown/out-of-contract strings (its switch has no default).
112
+ */
113
+ export function isAuthCode(code) {
114
+ return ERROR_CODES.includes(code) && exitCodeFor(code) === 3;
115
+ }
105
116
  export class CLIError extends Error {
106
117
  exitCode;
107
118
  constructor(message, exitCode = 1) {
@@ -42,7 +42,9 @@ export interface CiSummary {
42
42
  * with no annotation. (`skippedFrontend` / `skippedIntegration` are NOT folded
43
43
  * in — they exit 0 and are the Action layer's allow-partial concern.)
44
44
  */
45
- export declare function summarizeAcceptedPayload(capturedJson: string): CiSummary;
45
+ export declare function summarizeAcceptedPayload(capturedJson: string, opts?: {
46
+ notFoundNote?: string;
47
+ }): CiSummary;
46
48
  /**
47
49
  * Reduce a single `test run <test-id> --wait` result into the same CI summary
48
50
  * shape as the batch path, so `--gh-output` / `--summary-file` behave
@@ -81,4 +83,27 @@ export declare function emitGithubOutputs(summary: CiSummary, env: NodeJS.Proces
81
83
  annotations?: (line: string) => void;
82
84
  }, opts?: {
83
85
  force?: boolean;
86
+ label?: string;
84
87
  }): void;
88
+ /**
89
+ * Emit the CI artifacts for a `--wait` run: the machine summary file (when
90
+ * `--summary-file` is set) and the GitHub-native annotations + job-summary table
91
+ * (when `--gh-output` or `GITHUB_ACTIONS=true`). One shared implementation for
92
+ * every `--wait` command — `test run` (single + `--all`), `test rerun`, and
93
+ * `testlist run` — so the four copies of this block can no longer drift (a
94
+ * per-copy fix like the `notFound` fold reaching only one of them is what this
95
+ * consolidates away). The caller reduces its own envelope to a `CiSummary` first
96
+ * (`summarizeAcceptedPayload` for a batch, `summarizeSingleRun` for one run);
97
+ * this owns only the two sinks and their best-effort writes. `label` names the
98
+ * command in the failure messages (`[run]` / `[rerun]` / `[testlist run]`).
99
+ * Both writes are best-effort — a sink throwing must never change the exit code.
100
+ */
101
+ export declare function emitCiArtifacts(summary: CiSummary, opts: {
102
+ ghOutput?: boolean;
103
+ summaryFile?: string;
104
+ output?: string;
105
+ }, io: {
106
+ env: NodeJS.ProcessEnv;
107
+ stdout: (line: string) => void;
108
+ stderr: (line: string) => void;
109
+ }, label: string): void;
@@ -1,20 +1,4 @@
1
- /**
2
- * CI-native output layer for the run path (issue #99, reshaped from
3
- * the withdrawn top-level `ci` command per the #264 review). Covers both a
4
- * single `test run <test-id> --wait` and the `test run --all --wait` batch.
5
- *
6
- * A `--wait` run presents its result in the formats CI consumes:
7
- * (a) a stable machine summary `{total, passed, failed, timedOut, runs[]}`
8
- * written to `--summary-file <path>` when requested,
9
- * (b) a Markdown results table appended to `$GITHUB_STEP_SUMMARY` when
10
- * running under GitHub Actions,
11
- * (c) one `::error::` workflow-command line per non-passed run so failures
12
- * annotate the PR checks tab.
13
- * Activation: `GITHUB_ACTIONS=true` in the environment, or the explicit
14
- * `--gh-output` flag (which forces the annotations even off-Actions, so the
15
- * behavior is previewable locally). All writes are best-effort: a broken
16
- * summary file must never mask the batch gate's exit code.
17
- */
1
+ import { appendFileSync, writeFileSync } from 'node:fs';
18
2
  /**
19
3
  * Reduce a non-dispatched bucket (`deferred` / `conflicts` / `notFound`) into
20
4
  * CI rows. Items are either bare testId strings (`notFound`) or
@@ -49,7 +33,7 @@ function bucketRows(bucket, status, note) {
49
33
  * with no annotation. (`skippedFrontend` / `skippedIntegration` are NOT folded
50
34
  * in — they exit 0 and are the Action layer's allow-partial concern.)
51
35
  */
52
- export function summarizeAcceptedPayload(capturedJson) {
36
+ export function summarizeAcceptedPayload(capturedJson, opts = {}) {
53
37
  let parsed;
54
38
  try {
55
39
  parsed = JSON.parse(capturedJson);
@@ -81,7 +65,11 @@ export function summarizeAcceptedPayload(capturedJson) {
81
65
  ...acceptedRows,
82
66
  ...bucketRows(payload.deferred, 'deferred', 'rate-deferred (not dispatched)'),
83
67
  ...bucketRows(payload.conflicts, 'conflict', 'already in flight (not dispatched)'),
84
- ...bucketRows(payload.notFound, 'not_found', 'no replayable run (not dispatched)'),
68
+ // Default note is `test rerun`'s cause (a not-found id has no replayable
69
+ // run). `testlist run` passes its own — a not-found `--case` id is one that
70
+ // is not a member of the list — so the annotation/artifact don't state the
71
+ // wrong reason on the surface this whole layer exists to serve.
72
+ ...bucketRows(payload.notFound, 'not_found', opts.notFoundNote ?? 'no replayable run (not dispatched)'),
85
73
  ];
86
74
  const passed = rows.filter(row => row.status === 'passed').length;
87
75
  const timedOut = rows.filter(row => row.status === 'timeout').length;
@@ -175,13 +163,14 @@ function escapeCommandProperty(value) {
175
163
  * Both writes are best-effort: a broken summary file must not mask the gate.
176
164
  */
177
165
  export function emitGithubOutputs(summary, env, sinks, opts = {}) {
166
+ const label = opts.label ?? 'run';
178
167
  const summaryPath = env.GITHUB_STEP_SUMMARY;
179
168
  if (typeof summaryPath === 'string' && summaryPath.length > 0) {
180
169
  try {
181
170
  sinks.appendFile(summaryPath, renderJobSummaryMarkdown(summary));
182
171
  }
183
172
  catch {
184
- sinks.stderr('[run] could not append to GITHUB_STEP_SUMMARY; continuing');
173
+ sinks.stderr(`[${label}] could not append to GITHUB_STEP_SUMMARY; continuing`);
185
174
  }
186
175
  }
187
176
  if (env.GITHUB_ACTIONS === 'true' || opts.force === true) {
@@ -199,4 +188,42 @@ export function emitGithubOutputs(summary, env, sinks, opts = {}) {
199
188
  }
200
189
  }
201
190
  }
191
+ /**
192
+ * Emit the CI artifacts for a `--wait` run: the machine summary file (when
193
+ * `--summary-file` is set) and the GitHub-native annotations + job-summary table
194
+ * (when `--gh-output` or `GITHUB_ACTIONS=true`). One shared implementation for
195
+ * every `--wait` command — `test run` (single + `--all`), `test rerun`, and
196
+ * `testlist run` — so the four copies of this block can no longer drift (a
197
+ * per-copy fix like the `notFound` fold reaching only one of them is what this
198
+ * consolidates away). The caller reduces its own envelope to a `CiSummary` first
199
+ * (`summarizeAcceptedPayload` for a batch, `summarizeSingleRun` for one run);
200
+ * this owns only the two sinks and their best-effort writes. `label` names the
201
+ * command in the failure messages (`[run]` / `[rerun]` / `[testlist run]`).
202
+ * Both writes are best-effort — a sink throwing must never change the exit code.
203
+ */
204
+ export function emitCiArtifacts(summary, opts, io, label) {
205
+ const ghEnabled = opts.ghOutput === true || io.env.GITHUB_ACTIONS === 'true';
206
+ if (!ghEnabled && opts.summaryFile === undefined)
207
+ return;
208
+ if (opts.summaryFile !== undefined) {
209
+ try {
210
+ // eslint-disable-next-line security/detect-non-literal-fs-filename -- `--summary-file` is an explicit operator-supplied CI-artifact output path; best-effort in try/catch.
211
+ writeFileSync(opts.summaryFile, `${JSON.stringify(summary, null, 2)}\n`, 'utf8');
212
+ }
213
+ catch {
214
+ io.stderr(`[${label}] could not write --summary-file ${opts.summaryFile}; continuing`);
215
+ }
216
+ }
217
+ if (ghEnabled) {
218
+ emitGithubOutputs(summary, io.env, {
219
+ stdout: io.stdout,
220
+ stderr: io.stderr,
221
+ // eslint-disable-next-line security/detect-non-literal-fs-filename -- `path` is the CI-provided `$GITHUB_STEP_SUMMARY` env path, never external input.
222
+ appendFile: (path, content) => appendFileSync(path, content, 'utf8'),
223
+ // Under --output json the run envelope owns stdout; workflow commands go
224
+ // to stderr instead (the Actions runner parses both streams).
225
+ annotations: opts.output === 'json' ? io.stderr : io.stdout,
226
+ }, { force: opts.ghOutput === true, label });
227
+ }
228
+ }
202
229
  //# sourceMappingURL=gh-output.js.map
@@ -1,6 +1,7 @@
1
1
  import * as v from 'valibot';
2
2
  import type { ErrorCode } from './errors.js';
3
3
  import { ApiError } from './errors.js';
4
+ import type { CliTestListRunResponse } from './testlist.types.js';
4
5
  import type { TriggerRunBody, TriggerRunResponse, RunResponse, RerunRequest, RerunResponse, BatchRerunRequest, BatchRerunResponse, BatchRunFreshRequest, BatchRunFreshResponse, ListRunsQuery, ListRunsResponse, CancelRunResponse } from './runs.types.js';
5
6
  export type FetchImpl = typeof globalThis.fetch;
6
7
  export type DebugEventKind = 'request' | 'response' | 'retry' | 'error';
@@ -87,6 +88,14 @@ export interface HttpClientOptions {
87
88
  * `globalShutdown.signal` via the client factory.
88
89
  */
89
90
  shutdownSignal?: AbortSignal;
91
+ /**
92
+ * Upper bound (bytes) on a successful JSON response body the client will
93
+ * buffer before parsing. A response whose declared `Content-Length` — or
94
+ * actual streamed size — exceeds this fails fast with a typed
95
+ * `PAYLOAD_TOO_LARGE` error instead of growing the heap without limit.
96
+ * Defaults to {@link MAX_RESPONSE_BYTES_DEFAULT} (64 MiB).
97
+ */
98
+ maxResponseBytes?: number;
90
99
  }
91
100
  export interface RequestOptions<T = unknown> {
92
101
  query?: Record<string, string | number | boolean | undefined>;
@@ -166,6 +175,7 @@ export declare class HttpClient {
166
175
  private readonly onServerVersion?;
167
176
  private readonly requestTimeoutMs;
168
177
  private readonly shutdownSignal?;
178
+ private readonly maxResponseBytes;
169
179
  constructor(options: HttpClientOptions);
170
180
  /**
171
181
  * Read the backend's supported-floor header off a response and forward it to
@@ -253,6 +263,21 @@ export declare class HttpClient {
253
263
  idempotencyKey: string;
254
264
  signal?: AbortSignal;
255
265
  }): Promise<BatchRunFreshResponse>;
266
+ /**
267
+ * POST /api/cli/v1/testlist/{listId}/run
268
+ * Dispatch a test list's cases (optionally a `testIds` subset) per project
269
+ * with their configured environments; returns pollable runIds. `--wait` polls
270
+ * each `accepted[].runId`.
271
+ *
272
+ * `retryOnConflict: false` — a 409 here (every dispatched project is an
273
+ * MCP-mirrored view-only mirror) is a permanent condition, not a transient one.
274
+ */
275
+ triggerTestListRun(listId: string, body: {
276
+ testIds?: string[];
277
+ }, options: {
278
+ idempotencyKey: string;
279
+ signal?: AbortSignal;
280
+ }): Promise<CliTestListRunResponse>;
256
281
  /**
257
282
  * GET /api/cli/v1/tests/{testId}/runs
258
283
  * List a test's prior run history, newest-first.