@testsprite/testsprite-cli 0.13.0 → 0.15.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (81) hide show
  1. package/README.md +54 -49
  2. package/dist/commands/ci.d.ts +66 -17
  3. package/dist/commands/ci.js +466 -104
  4. package/dist/commands/doctor.d.ts +3 -0
  5. package/dist/commands/doctor.js +62 -20
  6. package/dist/commands/init.js +17 -3
  7. package/dist/commands/project-env.d.ts +11 -1
  8. package/dist/commands/project-env.js +399 -61
  9. package/dist/commands/project-sign-in.d.ts +60 -0
  10. package/dist/commands/project-sign-in.js +289 -0
  11. package/dist/commands/project.d.ts +9 -0
  12. package/dist/commands/project.js +82 -28
  13. package/dist/commands/schedule.d.ts +12 -0
  14. package/dist/commands/schedule.js +175 -5
  15. package/dist/commands/test.d.ts +126 -30
  16. package/dist/commands/test.js +1928 -447
  17. package/dist/commands/testlist.d.ts +10 -5
  18. package/dist/commands/testlist.js +170 -30
  19. package/dist/commands/tunnel.js +11 -5
  20. package/dist/index.js +17 -38
  21. package/dist/lib/agent-targets.d.ts +8 -3
  22. package/dist/lib/agent-targets.js +15 -4
  23. package/dist/lib/ci-run.d.ts +11 -0
  24. package/dist/lib/ci-run.js +34 -0
  25. package/dist/lib/client-factory.d.ts +35 -1
  26. package/dist/lib/client-factory.js +21 -10
  27. package/dist/lib/config.d.ts +1 -0
  28. package/dist/lib/config.js +1 -1
  29. package/dist/lib/credentials.d.ts +0 -1
  30. package/dist/lib/credentials.js +51 -14
  31. package/dist/lib/dry-run/samples.js +95 -1
  32. package/dist/lib/environment-tunnel.d.ts +109 -0
  33. package/dist/lib/environment-tunnel.js +465 -0
  34. package/dist/lib/errors.js +12 -1
  35. package/dist/lib/first-suite-hint.d.ts +55 -0
  36. package/dist/lib/first-suite-hint.js +101 -0
  37. package/dist/lib/gh-output.d.ts +62 -4
  38. package/dist/lib/gh-output.js +152 -7
  39. package/dist/lib/github-context.d.ts +21 -0
  40. package/dist/lib/github-context.js +153 -0
  41. package/dist/lib/http.d.ts +12 -1
  42. package/dist/lib/http.js +9 -1
  43. package/dist/lib/junit-report.d.ts +11 -7
  44. package/dist/lib/junit-report.js +13 -7
  45. package/dist/lib/local-target.d.ts +13 -3
  46. package/dist/lib/local-target.js +47 -12
  47. package/dist/lib/output.js +15 -1
  48. package/dist/lib/plan-poll.js +3 -4
  49. package/dist/lib/plans.types.d.ts +1 -1
  50. package/dist/lib/redact.d.ts +38 -0
  51. package/dist/lib/redact.js +140 -0
  52. package/dist/lib/render-error.d.ts +19 -5
  53. package/dist/lib/render-error.js +31 -0
  54. package/dist/lib/response-schemas.d.ts +5 -1
  55. package/dist/lib/response-schemas.js +54 -0
  56. package/dist/lib/runs.types.d.ts +115 -1
  57. package/dist/lib/target-url.js +5 -5
  58. package/dist/lib/telemetry.d.ts +31 -8
  59. package/dist/lib/telemetry.js +55 -7
  60. package/dist/lib/testlist.types.d.ts +1 -0
  61. package/dist/lib/ticker.d.ts +9 -0
  62. package/dist/lib/ticker.js +18 -0
  63. package/dist/lib/tunnel-session.d.ts +3 -4
  64. package/dist/lib/tunnel-session.js +3 -4
  65. package/dist/lib/v3-advisory.js +0 -1
  66. package/dist/vendor/tunnel-client/client.d.ts +15 -8
  67. package/dist/vendor/tunnel-client/client.js +477 -407
  68. package/dist/vendor/tunnel-client/config.d.ts +5 -5
  69. package/dist/vendor/tunnel-client/config.js +5 -5
  70. package/dist/vendor/tunnel-client/index.d.ts +4 -4
  71. package/dist/vendor/tunnel-client/index.js +4 -4
  72. package/dist/vendor/tunnel-client/types.d.ts +19 -34
  73. package/dist/vendor/tunnel-client/types.js +1 -0
  74. package/dist/vendor/tunnel-client/ws-compat.d.ts +13 -3
  75. package/dist/vendor/tunnel-client/ws-compat.js +70 -12
  76. package/dist/version.d.ts +1 -1
  77. package/dist/version.js +1 -1
  78. package/package.json +1 -1
  79. package/schemas/plan.schema.json +2 -2
  80. package/skills/testsprite-ci.skill.md +154 -0
  81. package/skills/testsprite-onboard.skill.md +4 -4
@@ -2,7 +2,7 @@ import { randomUUID } from 'node:crypto';
2
2
  import { Command } from 'commander';
3
3
  import { emitDryRunBanner, makeHttpClient, parseRequestTimeoutFlag, } from '../lib/client-factory.js';
4
4
  import { resolveProfileName } from '../lib/config.js';
5
- import { ApiError } from '../lib/errors.js';
5
+ import { ApiError, InterruptError } from '../lib/errors.js';
6
6
  import { GLOBAL_OPTS_HINT, Output, resolveOutputMode } from '../lib/output.js';
7
7
  import { formatScheduleFrequencyAdvisory, runsPerMonth } from '../lib/cron.js';
8
8
  import { renderTextTable } from '../lib/text-table.js';
@@ -54,10 +54,17 @@ export async function runCreate(opts, deps = {}) {
54
54
  }
55
55
  const targetType = opts.targetType;
56
56
  const cron = opts.cron.trim();
57
+ const environment = normalizeScheduleEnvironmentName(opts.env);
58
+ if (targetType === 'testList' && environment !== undefined) {
59
+ throw environmentValidationError('not_supported_for_target', `Test-list schedules inherit their list's environment bindings. ` +
60
+ `Use testsprite testlist update ${opts.targetId} ` +
61
+ '--project-env <projectId>:<environmentName> instead.');
62
+ }
57
63
  const body = {
58
64
  name: opts.name,
59
65
  targetType,
60
66
  targetId: opts.targetId,
67
+ ...(environment !== undefined ? { environment } : {}),
61
68
  cron,
62
69
  ...(opts.timezone !== undefined ? { timezone: opts.timezone } : {}),
63
70
  ...(opts.start !== undefined ? { startAt: opts.start } : {}),
@@ -73,23 +80,63 @@ export async function runCreate(opts, deps = {}) {
73
80
  if (opts.dryRun) {
74
81
  emitDryRunBanner(stderr);
75
82
  // Carries a cost figure so the advisory below is exercised offline too.
83
+ // There is no real server round trip to confirm here, so the mode is
84
+ // synthesized straight from the flags being previewed, same as a
85
+ // compliant server would echo back.
76
86
  const sample = {
77
87
  scheduleId: 'sch_dryrun_2026',
78
88
  estimatedCreditsPerRun: 5,
89
+ ...(targetType === 'project'
90
+ ? { environment: environment ?? null, environmentMode: environment ? 'pinned' : 'inherit' }
91
+ : {}),
79
92
  };
80
93
  emitCostAdvisory(sample, cron, stderr);
81
94
  out.print(sample, data => renderCreateScheduleText(data));
82
95
  return sample;
83
96
  }
84
97
  const client = makeClient(opts, deps);
98
+ if (environment !== undefined) {
99
+ await checkScheduleEnvironmentSupport(client);
100
+ }
85
101
  const created = await client.post('/schedules', {
86
102
  body,
87
103
  headers: { 'idempotency-key': idempotencyKey },
88
104
  });
105
+ if (targetType === 'project' && environment !== undefined) {
106
+ await confirmCreateEnvironmentPin(created, environment, client);
107
+ }
89
108
  emitCostAdvisory(created, cron, stderr);
90
109
  out.print(created, data => renderCreateScheduleText(data));
91
110
  return created;
92
111
  }
112
+ /**
113
+ * `--env` on create asks the server to pin the new schedule. An old server
114
+ * without this feature drops the field silently and echoes back a schedule
115
+ * with no environment mode at all — printing a confirmation on top of that
116
+ * would claim a pin that was never applied. Instead, best-effort undo the
117
+ * create (this command's own write, seconds old) and refuse.
118
+ */
119
+ async function confirmCreateEnvironmentPin(created, environment, client) {
120
+ if (created.environmentMode === 'pinned' && created.environment === environment)
121
+ return;
122
+ let rolledBack = false;
123
+ try {
124
+ await client.delete(`/schedules/${encodeURIComponent(created.scheduleId)}`, {
125
+ headers: { 'idempotency-key': `cli-sched-create-rollback-${randomUUID()}` },
126
+ });
127
+ rolledBack = true;
128
+ }
129
+ catch (err) {
130
+ if (err instanceof InterruptError)
131
+ throw err;
132
+ }
133
+ throw unsupportedEnvironmentError(rolledBack
134
+ ? `Schedule ${created.scheduleId} was created and then removed because this server did ` +
135
+ 'not apply the requested environment.'
136
+ : `Schedule ${created.scheduleId} was created without a confirmed environment pin, and ` +
137
+ 'the CLI could not remove it; remove it with: ' +
138
+ `testsprite schedule delete ${created.scheduleId} --confirm`, { scheduleId: created.scheduleId, rolledBack });
139
+ }
93
140
  /**
94
141
  * Cost advisory for a schedule that was just created.
95
142
  *
@@ -126,8 +173,10 @@ export async function runUpdate(opts, deps = {}) {
126
173
  if (opts.pause && opts.resume) {
127
174
  throw localValidationError('--pause and --resume cannot be combined');
128
175
  }
176
+ const environment = normalizeScheduleEnvironmentName(opts.env);
129
177
  const body = {
130
178
  ...(opts.name !== undefined ? { name: opts.name } : {}),
179
+ ...(environment !== undefined ? { environment } : {}),
131
180
  ...(opts.cron !== undefined ? { cron: opts.cron } : {}),
132
181
  ...(opts.timezone !== undefined ? { timezone: opts.timezone } : {}),
133
182
  ...(opts.start !== undefined ? { startAt: opts.start } : {}),
@@ -151,7 +200,24 @@ export async function runUpdate(opts, deps = {}) {
151
200
  stderr(formatScheduleFrequencyAdvisory(opts.cron));
152
201
  }
153
202
  const client = makeClient(opts, deps);
203
+ if (environment !== undefined && !opts.dryRun) {
204
+ await checkScheduleEnvironmentSupport(client, opts.scheduleId);
205
+ }
154
206
  const updated = await client.patch(`/schedules/${encodeURIComponent(opts.scheduleId)}`, { body, headers: { 'idempotency-key': idempotencyKey } });
207
+ // `--env` on update pins an existing schedule. An old server drops the
208
+ // field silently and echoes back no environment mode; unlike create there
209
+ // is nothing to roll back (the schedule pre-existed this command), so this
210
+ // just refuses rather than confirming a pin that was never applied. Other
211
+ // fields in the same request may still have gone through.
212
+ if (environment !== undefined &&
213
+ !(updated.environmentMode === 'pinned' && updated.environment === environment)) {
214
+ throw unsupportedEnvironmentError(`The server updated schedule ${updated.scheduleId} without confirming the environment ` +
215
+ `pin. Other requested fields (${Object.keys(body)
216
+ .filter(key => key !== 'environment')
217
+ .join(', ') || 'none'}) ` +
218
+ 'may have been applied; inspect it with: ' +
219
+ `testsprite schedule get ${updated.scheduleId}`, { scheduleId: updated.scheduleId, requestedFields: Object.keys(body) });
220
+ }
155
221
  out.print(updated, data => renderScheduleText(data));
156
222
  return updated;
157
223
  }
@@ -238,7 +304,16 @@ const SCHEDULE_LIST_COLUMNS = [
238
304
  width: rows => Math.max(2, ...rows.map(s => (s.timezone ?? '').length)),
239
305
  render: s => s.timezone ?? '',
240
306
  },
241
- { header: 'LAST RUN', width: 0, render: s => s.lastRunId ?? '' },
307
+ {
308
+ header: 'LAST RUN',
309
+ width: rows => Math.max(8, ...rows.map(s => (s.lastRunId ?? '').length)),
310
+ render: s => s.lastRunId ?? '',
311
+ },
312
+ {
313
+ header: 'ENVIRONMENT',
314
+ width: rows => Math.max(11, ...rows.map(s => scheduleEnvironmentText(s).length)),
315
+ render: scheduleEnvironmentText,
316
+ },
242
317
  ];
243
318
  function renderScheduleListText(schedules, options = {}) {
244
319
  if (schedules.length === 0)
@@ -266,10 +341,99 @@ function renderScheduleText(s) {
266
341
  ];
267
342
  if (s.autoPausedAt)
268
343
  lines.push(`autoPaused: ${s.autoPausedAt}`);
344
+ if (s.environmentMode !== undefined) {
345
+ lines.push(`environment: ${scheduleEnvironmentText(s)}`);
346
+ }
269
347
  return lines.join('\n');
270
348
  }
349
+ /**
350
+ * Renders the environment/mode strictly from the server's response — never
351
+ * from what the command asked for. When the response omits `environmentMode`
352
+ * altogether (an old server that has never heard of schedule environments),
353
+ * this stays silent about it, matching the confirmation text from before the
354
+ * feature existed rather than fabricating a claim the server never made.
355
+ * (A request that explicitly asked to pin and got no confirmation never
356
+ * reaches this renderer — `confirmCreateEnvironmentPin` refuses first.)
357
+ */
271
358
  function renderCreateScheduleText(r) {
272
- return `id: ${r.scheduleId}`;
359
+ if (r.environmentMode === undefined)
360
+ return `id: ${r.scheduleId}`;
361
+ return `id: ${r.scheduleId}\nenvironment: ${scheduleEnvironmentText(r)}`;
362
+ }
363
+ function scheduleEnvironmentText(schedule) {
364
+ if (schedule.environmentMode === 'inherit')
365
+ return 'project default (inherits)';
366
+ if (schedule.environmentMode === 'pinned' && schedule.environment) {
367
+ return `${schedule.environment} (pinned)`;
368
+ }
369
+ return '-';
370
+ }
371
+ function normalizeScheduleEnvironmentName(raw) {
372
+ if (raw === undefined)
373
+ return undefined;
374
+ const name = raw.trim();
375
+ if (name.length === 0) {
376
+ throw environmentValidationError('blank_value', '--env must be a non-empty environment name');
377
+ }
378
+ return name;
379
+ }
380
+ /** A missing mode on a project schedule proves that the server predates pins. */
381
+ async function checkScheduleEnvironmentSupport(client, scheduleId) {
382
+ let schedules;
383
+ try {
384
+ schedules =
385
+ scheduleId === undefined
386
+ ? ((await client.get('/schedules', { retry: false })).schedules ?? [])
387
+ : [
388
+ await client.get(`/schedules/${encodeURIComponent(scheduleId)}`, {
389
+ retry: false,
390
+ }),
391
+ ];
392
+ }
393
+ catch (err) {
394
+ if (err instanceof InterruptError)
395
+ throw err;
396
+ // A write-scoped key may not read schedules. Keep response confirmation
397
+ // for inconclusive probes and for a server with no existing schedules.
398
+ return;
399
+ }
400
+ if (schedules.some(schedule => schedule.targetType === 'project' && schedule.environmentMode === undefined)) {
401
+ throw unsupportedEnvironmentError(scheduleId === undefined
402
+ ? 'No schedule was created. Upgrade the server before using schedule --env.'
403
+ : `No schedule changes were sent. Upgrade the server before using schedule --env on ${scheduleId}.`, {
404
+ ...(scheduleId !== undefined ? { scheduleId } : {}),
405
+ reason: 'schedule-environments-unsupported',
406
+ });
407
+ }
408
+ }
409
+ /**
410
+ * Local validation failures on `--env` — mirrors the field the API itself
411
+ * uses (`environment`, the wire name) rather than the flag name, so a caller
412
+ * inspecting `details.field` sees the same value whether the rejection was
413
+ * caught locally or came back from the server.
414
+ */
415
+ function environmentValidationError(reason, nextAction) {
416
+ return ApiError.fromEnvelope({
417
+ error: {
418
+ code: 'VALIDATION_ERROR',
419
+ message: 'Invalid request.',
420
+ nextAction,
421
+ requestId: 'local',
422
+ details: { field: 'environment', reason },
423
+ },
424
+ });
425
+ }
426
+ /** Exit 7 — a server that doesn't (yet) support schedule environments. */
427
+ function unsupportedEnvironmentError(nextAction, details) {
428
+ return ApiError.fromEnvelope({
429
+ error: {
430
+ code: 'UNSUPPORTED',
431
+ message: 'This server does not support schedule environments yet.',
432
+ nextAction,
433
+ requestId: 'local',
434
+ details,
435
+ },
436
+ });
273
437
  }
274
438
  const RUN_LIST_COLUMNS = [
275
439
  {
@@ -351,12 +515,14 @@ export function createScheduleCommand(deps = {}) {
351
515
  ' 4 target not found\n' +
352
516
  ' 5 validation error (e.g., missing --cron)\n' +
353
517
  ' 6 idempotency conflict\n' +
354
- ' 7 schedules are not available on this account\n' +
518
+ ' 7 schedules are not available on this account, or (with --env) the server does ' +
519
+ 'not support schedule environments yet\n' +
355
520
  ' 10 transport/network failure (UNAVAILABLE) — retry the command\n' +
356
521
  ' 13 not available on your plan, or the plan limit is reached')
357
522
  .option('--name <name>', 'schedule name (required)')
358
523
  .option('--target-type <project|testList>', 'what to run (required)')
359
524
  .option('--target-id <id>', 'project id or test-list id (required)')
525
+ .option('--env <name>', "Pin this project schedule to an environment; omit to always use the project's default environment")
360
526
  .option('--cron <expr>', 'standard 5-field cron (minute hour day-of-month month day-of-week), ' +
361
527
  'e.g. "0 3 * * *". Day-of-week is 0-7, with both 0 and 7 = Sunday. ' +
362
528
  'Constrain ' +
@@ -373,6 +539,7 @@ export function createScheduleCommand(deps = {}) {
373
539
  name: cmdOpts.name,
374
540
  targetType: cmdOpts.targetType,
375
541
  targetId: cmdOpts.targetId,
542
+ env: cmdOpts.env,
376
543
  cron: cmdOpts.cron,
377
544
  timezone: cmdOpts.timezone,
378
545
  start: cmdOpts.start,
@@ -390,10 +557,12 @@ export function createScheduleCommand(deps = {}) {
390
557
  ' 4 not found\n' +
391
558
  ' 5 validation error (e.g., no fields given)\n' +
392
559
  ' 6 idempotency conflict\n' +
393
- ' 7 schedules are not available on this account\n' +
560
+ ' 7 schedules are not available on this account, or (with --env) the server does ' +
561
+ 'not support schedule environments yet\n' +
394
562
  ' 10 transport/network failure (UNAVAILABLE) — retry the command\n' +
395
563
  ' 13 not available on your plan')
396
564
  .option('--name <name>', 'new schedule name')
565
+ .option('--env <name>', "Pin this project schedule to an environment; omit to always use the project's default environment")
397
566
  .option('--cron <expr>', 'new standard 5-field cron, as printed by `schedule get`. Day-of-week is ' +
398
567
  '0-7, with both 0 and 7 = Sunday. Constrain day-of-month or day-of-week, not both.')
399
568
  .option('--timezone <tz>', 'new IANA timezone')
@@ -409,6 +578,7 @@ export function createScheduleCommand(deps = {}) {
409
578
  ...resolveCommonOptions(command, deps.env),
410
579
  scheduleId,
411
580
  name: cmdOpts.name,
581
+ env: cmdOpts.env,
412
582
  cron: cmdOpts.cron,
413
583
  timezone: cmdOpts.timezone,
414
584
  start: cmdOpts.start,
@@ -1,3 +1,4 @@
1
+ import { resolveEnvironmentRunTarget, type EnvironmentTunnelContext, type ResolvedRunTarget, type RunTargetTest } from '../lib/environment-tunnel.js';
1
2
  import { Command } from 'commander';
2
3
  import { type CommonOptions as FactoryCommonOptions } from '../lib/client-factory.js';
3
4
  import { type WriteBundleResult } from '../lib/bundle.js';
@@ -7,8 +8,8 @@ import { type ShutdownHandle } from '../lib/interrupt.js';
7
8
  import type { FetchImpl } from '../lib/http.js';
8
9
  import { type Page } from '../lib/pagination.js';
9
10
  import { type WaitTimeoutTelemetry } from '../lib/telemetry.js';
10
- import type { CliGetPlansResponse } from '../lib/plans.types.js';
11
- import type { RunResponse, RunStatus, TriggerRunResponse, RerunResponse, BatchRerunResponse, ListRunsResponse, RunSource, BatchRunFreshResponse, CancelRunResponse, RunEnvironmentRef } from '../lib/runs.types.js';
11
+ import type { CliGetPlansResponse, CliGenerationStage } from '../lib/plans.types.js';
12
+ import type { RunResponse, RunStatus, TriggerRunResponse, RerunResponse, BatchRerunResponse, ListRunsResponse, RunSource, BatchRunFreshResponse, CancelRunResponse, CiGithubTrigger, RunEnvironmentRef } from '../lib/runs.types.js';
12
13
  import { type LoopbackHost } from '../lib/local-target.js';
13
14
  import { type TunnelClientHandle } from '../lib/tunnel-session.js';
14
15
  import { type TunnelClientOptions } from '../vendor/tunnel-client/index.js';
@@ -48,8 +49,22 @@ export interface CliTest {
48
49
  projectName?: string | null;
49
50
  name: string;
50
51
  type: 'frontend' | 'backend';
52
+ /**
53
+ * Assembled integration test (backend). Absent on older backends — treated
54
+ * as false. Listed as `backend/int` so it is not mistaken for a plain test.
55
+ */
56
+ isIntegration?: boolean;
51
57
  createdFrom: 'portal' | 'mcp' | 'cli';
52
58
  status: CliPublicStatus;
59
+ statusByEnvironment?: Array<{
60
+ environmentId: string | null;
61
+ environmentName: string | null;
62
+ status: CliPublicStatus;
63
+ }>;
64
+ headlineEnvironment?: {
65
+ id: string | null;
66
+ name: string | null;
67
+ } | null;
53
68
  createdAt: string;
54
69
  updatedAt: string;
55
70
  /**
@@ -75,7 +90,7 @@ export interface CliTest {
75
90
  */
76
91
  details?: Partial<CliTestStatusDetails>;
77
92
  /**
78
- * G1a — test priority label, e.g. "p0" | "p1" | "p2" | "p3".
93
+ * G1a — test priority label as stored ("High" | "Medium" | "Low").
79
94
  * Optional on the wire: pre-G1a backends omit the field; `null` means
80
95
  * no priority has been set. Text mode surfaces it only when truthy.
81
96
  */
@@ -321,6 +336,10 @@ export interface CliFailureContext {
321
336
  failure: CliFailureBlock;
322
337
  }
323
338
  export interface TestDeps {
339
+ environmentCache?: Parameters<typeof resolveEnvironmentRunTarget>[0]['cache'];
340
+ creationTargets?: ReadonlyMap<string, ResolvedRunTarget>;
341
+ createdTests?: ReadonlyMap<string, RunTargetTest>;
342
+ environmentTunnel?: EnvironmentTunnelContext;
324
343
  /** Report an exhausted poll deadline without changing the public output/error shape. */
325
344
  onWaitTimeout?: (context: WaitTimeoutTelemetry) => void;
326
345
  env?: NodeJS.ProcessEnv;
@@ -368,6 +387,8 @@ export interface TunnelDetach {
368
387
  testId: string;
369
388
  localPort: number;
370
389
  localHost: LoopbackHost;
390
+ automatic?: boolean;
391
+ environment?: string;
371
392
  reason: TunnelDetachReason;
372
393
  /** The borrowed tunnel owner disappeared while this run was non-terminal. */
373
394
  ownerGone?: boolean;
@@ -392,6 +413,7 @@ export declare function tunnelInterruptNextAction(detach: TunnelDetach, err: Int
392
413
  type CommonOptions = FactoryCommonOptions;
393
414
  interface ListOptions extends CommonOptions {
394
415
  projectId?: string;
416
+ environment?: string;
395
417
  type?: 'frontend' | 'backend';
396
418
  createdFrom?: 'portal' | 'mcp' | 'cli';
397
419
  /**
@@ -439,13 +461,22 @@ export interface CliCreateTestResponse {
439
461
  }
440
462
  export declare const CLI_CREATE_PRIORITIES: readonly ["p0", "p1", "p2", "p3"];
441
463
  export type CliCreatePriority = (typeof CLI_CREATE_PRIORITIES)[number];
464
+ /** Priority spellings accepted as input; reads return High/Medium/Low. */
465
+ export declare const CLI_PRIORITY_INPUTS: readonly ["p0", "p1", "p2", "p3", "high", "medium", "low"];
466
+ /**
467
+ * Normalise a priority input (p0-p3 or high/medium/low, any case) to the
468
+ * p0/p1/p2 wire value every backend accepts; p3 folds into p2 (Low).
469
+ * Returns undefined for anything else.
470
+ */
471
+ export declare function normalizePriority(raw: unknown): 'p0' | 'p1' | 'p2' | undefined;
442
472
  interface CreateOptions extends CommonOptions {
473
+ noWait?: boolean;
443
474
  environment?: string;
444
475
  projectId?: string;
445
476
  type: 'frontend' | 'backend';
446
477
  name: string;
447
478
  description?: string;
448
- priority?: CliCreatePriority;
479
+ priority?: string;
449
480
  /** Per-test timeout applied by the execution engine to every step. */
450
481
  stepTimeoutMs?: number;
451
482
  /** Source path to the test code. Read into memory; capped at 350 KB. */
@@ -526,6 +557,12 @@ interface PlanPutOptions extends CommonOptions {
526
557
  * `codeVersion`, so this is the only consistency knob.
527
558
  */
528
559
  expectedStepCount?: number;
560
+ /**
561
+ * Replace even when the server would drop structured fields
562
+ * (action / selector / inputValue) from steps whose text changed. Also
563
+ * skips the default step-count fence.
564
+ */
565
+ force?: boolean;
529
566
  /** Caller-supplied idempotency token; UUIDv4 minted client-side if absent. */
530
567
  idempotencyKey?: string;
531
568
  /**
@@ -549,10 +586,9 @@ interface PlanPutOptions extends CommonOptions {
549
586
  * trip and matches the piece-6 spec's "server-side routing" decision.
550
587
  *
551
588
  * Concurrency: FE has no `codeVersion`, so updates are last-writer-
552
- * wins by default. Pass `--expected-step-count <N>` to set
553
- * `If-Match-Step-Count`; the server rejects with 412 if the current
554
- * array length differs. Useful for defensive callers who want to
555
- * detect concurrent edits without a separate read.
589
+ * wins unless `--expected-step-count <N>` is passed, which sets
590
+ * `If-Match-Step-Count`; the server rejects with 412 if the array length
591
+ * differs.
556
592
  *
557
593
  * Idempotency: `cli-plan-put-<uuid>` is the default key, surfaced to
558
594
  * stderr so a transport retry can pin it.
@@ -576,7 +612,7 @@ interface UpdateOptions extends CommonOptions {
576
612
  /** Optional new description (`null` is reserved for "clear"; CLI surfaces both). */
577
613
  description?: string;
578
614
  /** Optional new priority. Enum-validated CLI-side. */
579
- priority?: CliCreatePriority;
615
+ priority?: string;
580
616
  /** Set the per-test timeout applied by the execution engine to every step. */
581
617
  stepTimeoutMs?: number;
582
618
  /** Clear the per-test step timeout and restore execution engine defaults. */
@@ -703,6 +739,15 @@ export declare function runDeleteBatch(opts: DeleteBatchOptions, deps?: TestDeps
703
739
  export interface CliPlanStep {
704
740
  type: 'action' | 'assertion';
705
741
  description: string;
742
+ /**
743
+ * Read-only view fields: structured steps carry the engine-level action
744
+ * the Portal recorded. Optional because older backends omit them; they are
745
+ * never part of a create / `plan put` request body.
746
+ */
747
+ action?: string;
748
+ selector?: string;
749
+ inputValue?: string;
750
+ structured?: boolean;
706
751
  }
707
752
  /**
708
753
  * Plan-from input file shape. Mirrors the body the controller accepts
@@ -719,7 +764,7 @@ export interface CliPlanInput {
719
764
  type: 'frontend' | 'backend';
720
765
  name: string;
721
766
  description?: string;
722
- priority?: CliCreatePriority;
767
+ priority?: string;
723
768
  planSteps: CliPlanStep[];
724
769
  }
725
770
  /**
@@ -757,7 +802,7 @@ export interface CliCreateFromPlanResponse extends CliCreateTestResponse {
757
802
  * Caveat: the pinned tag only resolves once that version is actually
758
803
  * released — a locally-built/pre-release checkout may see a 404 until then.
759
804
  */
760
- export declare const PLAN_SCHEMA_URL = "https://raw.githubusercontent.com/TestSprite/testsprite-cli/v0.13.0/schemas/plan.schema.json";
805
+ export declare const PLAN_SCHEMA_URL = "https://raw.githubusercontent.com/TestSprite/testsprite-cli/v0.15.0/schemas/plan.schema.json";
761
806
  /**
762
807
  * The SINGLE canonical example plan. This
763
808
  * exact value (via `PLAN_TEMPLATE_TEXT` below) is:
@@ -842,6 +887,7 @@ export interface CliBatchRunResult {
842
887
  code: string;
843
888
  message: string;
844
889
  exitCode: number;
890
+ details?: Record<string, unknown>;
845
891
  };
846
892
  /**
847
893
  * Portal deep link (R3b), threaded through from the SAME per-item
@@ -972,6 +1018,7 @@ export declare const DEFERRED_RETRY_DEFAULT_SLEEP_MS = 61000;
972
1018
  */
973
1019
  export declare function isTransientRateLimit(err: ApiError): boolean;
974
1020
  interface CreateFromPlanOptions extends CommonOptions {
1021
+ noWait?: boolean;
975
1022
  environment?: string;
976
1023
  /** Path to the JSON file containing one `CliPlanInput`. */
977
1024
  planFrom: string;
@@ -1027,6 +1074,7 @@ interface CreateFromPlanOptions extends CommonOptions {
1027
1074
  */
1028
1075
  export declare function runCreateFromPlan(opts: CreateFromPlanOptions, deps?: TestDeps): Promise<CliCreateFromPlanResponse>;
1029
1076
  interface CreateBatchOptions extends CommonOptions {
1077
+ noWait?: boolean;
1030
1078
  environment?: string;
1031
1079
  /** Path to the JSONL file containing one `CliPlanInput` per line. */
1032
1080
  plans: string;
@@ -1483,6 +1531,8 @@ export interface FailureGetResult {
1483
1531
  */
1484
1532
  export declare function runFailureGet(opts: FailureGetOptions, deps?: TestDeps): Promise<FailureGetResult>;
1485
1533
  interface RunTestRunOptions extends CommonOptions {
1534
+ knownTest?: RunTargetTest;
1535
+ noWait?: boolean;
1486
1536
  testId: string;
1487
1537
  targetUrl?: string;
1488
1538
  /**
@@ -1577,6 +1627,11 @@ interface RunTestWaitOptions extends CommonOptions {
1577
1627
  timeoutSeconds: number;
1578
1628
  }
1579
1629
  interface RunTestRerunOptions extends CommonOptions {
1630
+ knownTests?: ReadonlyMap<string, Pick<CliTest, 'type' | 'projectId'>>;
1631
+ noWait?: boolean;
1632
+ skipPreflight?: boolean;
1633
+ concurrencyIsDefault?: boolean;
1634
+ batchResolved?: boolean;
1580
1635
  /** One or more testIds to rerun. Empty + all=false → validation error (exit 5). */
1581
1636
  testIds: string[];
1582
1637
  /** --all: resolve all tests in the project and batch-rerun them. */
@@ -1697,6 +1752,17 @@ export declare function makeBackendWaitFallback(args: {
1697
1752
  resolveNotBefore: (run: RunResponse) => string | undefined;
1698
1753
  onResolved?: (testId: string, status: CliPublicStatus) => void;
1699
1754
  }): (run: RunResponse, elapsedMs: number, signal: AbortSignal) => Promise<RunResponse | null>;
1755
+ /**
1756
+ * Render a `RunResponse` to human-readable text. JSON mode callers get
1757
+ * the wire envelope via `out.print`.
1758
+ *
1759
+ * Pass `isBackend: true` to suppress the per-step breakdown (BE tests are
1760
+ * atomic — no per-step breakdown exists; showing `0/0 (passed=0, failed=0)`
1761
+ * reads like a no-op rather than a passing/failing atomic result).
1762
+ */
1763
+ export declare function renderRunResponseText(run: RunResponse, { isBackend }?: {
1764
+ isBackend?: boolean;
1765
+ }): string;
1700
1766
  export declare function runTestRun(opts: RunTestRunOptions, deps?: TestDeps): Promise<TriggerRunResponse | RunResponse>;
1701
1767
  /** One row of the `test wait <run-id...>` multi-run payload. */
1702
1768
  export interface CliMultiWaitResult {
@@ -1784,7 +1850,12 @@ export declare function createTestCancelCommand(deps: TestDeps): Command;
1784
1850
  * codes match the `--wait` behavior matrix in the spec.
1785
1851
  */
1786
1852
  export declare function runTestWait(opts: RunTestWaitOptions, deps?: TestDeps): Promise<RunResponse>;
1787
- interface RunTestRunAllOptions extends CommonOptions {
1853
+ export interface RunTestRunAllOptions extends CommonOptions {
1854
+ environmentResolutionComplete?: boolean;
1855
+ cancelOnInterrupt?: boolean;
1856
+ timeoutIsDefault?: boolean;
1857
+ noWait?: boolean;
1858
+ concurrencyIsDefault?: boolean;
1788
1859
  /** projectId to run all tests in; may be resolved from --project or TESTSPRITE_PROJECT_ID. */
1789
1860
  projectId?: string;
1790
1861
  /** --filter <substr>: only run tests whose name contains this substring (case-insensitive). */
@@ -1795,6 +1866,14 @@ interface RunTestRunAllOptions extends CommonOptions {
1795
1866
  timeoutSeconds: number;
1796
1867
  /** --max-concurrency: bounds the --wait poll fan-out. */
1797
1868
  maxConcurrency: number;
1869
+ /** Internal CI policy. The public `ci run` entry point always enables wait. */
1870
+ ci?: {
1871
+ failOnSkipped?: boolean;
1872
+ /** How long `ci run` waits for the execution report before falling back to the local table. */
1873
+ executionReportTimeoutSeconds?: number;
1874
+ /** `--no-execution-report`: never read the report; the job summary is the local table. */
1875
+ executionReport?: boolean;
1876
+ };
1798
1877
  /** Caller-supplied idempotency token; auto-minted if absent. */
1799
1878
  idempotencyKey?: string;
1800
1879
  /** --report junit: write a JUnit XML sidecar after batch --wait completes. */
@@ -1820,6 +1899,18 @@ interface RunTestRunAllOptions extends CommonOptions {
1820
1899
  environment?: string;
1821
1900
  /** Per-run URL override for every frontend test in the batch. */
1822
1901
  targetUrl?: string;
1902
+ /**
1903
+ * `ci run`: `'all'` asks the server to seed every selected case into one
1904
+ * execution and pace dispatch itself, so a CI run is one execution (and,
1905
+ * with `previewName`, one environment row) instead of a first batch plus a
1906
+ * client-side retry. A backend that read the field echoes it; a missing
1907
+ * echo is refused the way an unconfirmed `targetUrl` is.
1908
+ */
1909
+ admission?: 'budget' | 'all';
1910
+ /** `ci run` in a pull request: run in a temporary clone of `environment` at `targetUrl`. */
1911
+ previewName?: string;
1912
+ /** `ci run` in GitHub Actions: where the run came from, for the Portal's PR link. */
1913
+ githubTrigger?: CiGithubTrigger;
1823
1914
  /** Skip the pre-charge target URL reachability probe. */
1824
1915
  skipPreflight?: boolean;
1825
1916
  }
@@ -1829,6 +1920,7 @@ export declare function writeBatchJUnitReportIfRequested(opts: {
1829
1920
  reportSuiteName?: string;
1830
1921
  projectId?: string;
1831
1922
  }, results: readonly (JUnitTestResult & {
1923
+ createdAt?: string | null;
1832
1924
  startedAt?: string | null;
1833
1925
  finishedAt?: string | null;
1834
1926
  testTitle?: string | null;
@@ -1842,12 +1934,17 @@ export declare function writeBatchJUnitReportIfRequested(opts: {
1842
1934
  */
1843
1935
  export declare function runTestRunAll(opts: RunTestRunAllOptions, deps?: TestDeps): Promise<BatchRunFreshResponse | undefined>;
1844
1936
  interface RunTestRunLocalBatchOptions extends CommonOptions {
1937
+ wait?: boolean;
1938
+ targetUrl?: string;
1939
+ noWait?: boolean;
1940
+ concurrencyIsDefault?: boolean;
1941
+ resolvedTarget?: ResolvedRunTarget;
1845
1942
  testIds: string[];
1846
1943
  all: boolean;
1847
1944
  projectId?: string;
1848
1945
  nameFilter?: string;
1849
- localPort: number;
1850
- localHost: LoopbackHost;
1946
+ localPort?: number;
1947
+ localHost?: LoopbackHost;
1851
1948
  skipPreflight: boolean;
1852
1949
  tunnelClientId?: string;
1853
1950
  cancelOnInterrupt: boolean;
@@ -1865,20 +1962,6 @@ interface RunTestRunLocalBatchOptions extends CommonOptions {
1865
1962
  }
1866
1963
  /** One bounded trigger-and-wait pool shares one local tunnel for its full lifetime. */
1867
1964
  export declare function runTestRunLocalBatch(opts: RunTestRunLocalBatchOptions, deps?: TestDeps): Promise<void>;
1868
- /**
1869
- * `test rerun` — M3.4 piece-3.
1870
- *
1871
- * FE: `POST /tests/{id}/runs/rerun` → verbatim replay, billed at 0.5 credits
1872
- * (same as a fresh run; legacy V2 accounts: free). With `--wait`, polls
1873
- * `GET /runs/{runId}` until terminal.
1874
- *
1875
- * BE: same route → closure + per-member runIds. With `--wait`, polls every
1876
- * closure-member runId; exits on the named test's verdict; failed closure
1877
- * members surface as warnings + `closureFailures[]` in JSON.
1878
- *
1879
- * Batch / `--all`: `POST /tests/batch/rerun` → per-test runIds. With
1880
- * `--wait`, fan-out poll under `--max-concurrency`. `deferred[]` → exit 7.
1881
- */
1882
1965
  export declare function runTestRerun(opts: RunTestRerunOptions, deps?: TestDeps): Promise<RerunResponse | BatchRerunResponse | undefined>;
1883
1966
  export interface ArtifactGetOptions extends CommonOptions {
1884
1967
  runId: string;
@@ -1963,6 +2046,11 @@ export declare function resolveWaitRequestTimeoutMs(opts: {
1963
2046
  }): number | undefined;
1964
2047
  /** A presigned `code` body is any `https://` URL — never anything else. */
1965
2048
  export declare function isPresignedCodeUrl(code: string): boolean;
2049
+ export declare function renderTestListText(page: Page<CliTest>, options?: {
2050
+ columns?: string;
2051
+ noHeader?: boolean;
2052
+ environment?: string;
2053
+ }): string;
1966
2054
  interface PlanGenerateOptions extends CommonOptions {
1967
2055
  projectId?: string;
1968
2056
  timeoutSeconds: number;
@@ -1979,6 +2067,13 @@ interface PlanAcceptOptions extends CommonOptions {
1979
2067
  * reachable through `runGenerationLadder` today (after the proposals rung it
1980
2068
  * polls until staged/failed/timeout), so it is pinned directly. */
1981
2069
  export declare function renderPlanGenerateResultText(plans: CliGetPlansResponse, projectId: string, creditsUsed: number | null, skippedCategories?: number | null): string;
2070
+ /** Plan-generate interrupt outcome consumed by the top-level JSON renderer
2071
+ * (`buildInterruptEnvelope`), the way `TunnelInterruptDetach` is for tunnels. */
2072
+ export interface PlanInterruptDetach {
2073
+ projectId: string;
2074
+ stagesRemaining: CliGenerationStage[] | null;
2075
+ nextAction: string;
2076
+ }
1982
2077
  /**
1983
2078
  * `test plan generate --project <id>`.
1984
2079
  *
@@ -1986,8 +2081,9 @@ export declare function renderPlanGenerateResultText(plans: CliGetPlansResponse,
1986
2081
  * proposals) through `runGenerationLadder` and renders the staged
1987
2082
  * proposals. Exit 0 on staged proposals, 1 on a server-side stage failure,
1988
2083
  * 7 on timeout (typed `UNSUPPORTED` envelope — the raw ladder timeout is
1989
- * not a CLI error), 130/143 on Ctrl-C detach (honest: work and charges
1990
- * continue server-side), plus the usual catalog exits for trigger errors
2084
+ * not a CLI error), 130/143 on Ctrl-C (the running stage finishes server-side;
2085
+ * nothing after it starts until a re-run, see PlanStageTracker), plus the
2086
+ * usual catalog exits for trigger errors
1991
2087
  * (412 → 6 with the exact fix command, 402 → 12, 404 → 4, 429 → 11).
1992
2088
  */
1993
2089
  export declare function runPlanGenerate(opts: PlanGenerateOptions, deps?: TestDeps): Promise<unknown>;