@testsprite/testsprite-cli 0.9.0 → 0.11.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 (43) hide show
  1. package/README.md +64 -41
  2. package/dist/commands/auth.d.ts +5 -1
  3. package/dist/commands/auth.js +17 -5
  4. package/dist/commands/init.d.ts +6 -1
  5. package/dist/commands/init.js +13 -5
  6. package/dist/commands/project.d.ts +30 -0
  7. package/dist/commands/project.js +193 -27
  8. package/dist/commands/test.d.ts +14 -2
  9. package/dist/commands/test.js +141 -33
  10. package/dist/commands/tunnel.d.ts +2 -2
  11. package/dist/commands/tunnel.js +139 -31
  12. package/dist/index.js +29 -11
  13. package/dist/lib/client-factory.d.ts +4 -1
  14. package/dist/lib/client-factory.js +12 -4
  15. package/dist/lib/credentials.d.ts +4 -0
  16. package/dist/lib/credentials.js +43 -4
  17. package/dist/lib/dry-run/samples.js +16 -9
  18. package/dist/lib/http.d.ts +14 -2
  19. package/dist/lib/http.js +38 -6
  20. package/dist/lib/response-schemas.d.ts +5 -2
  21. package/dist/lib/response-schemas.js +21 -1
  22. package/dist/lib/runs.types.d.ts +11 -0
  23. package/dist/lib/target-url.d.ts +1 -1
  24. package/dist/lib/target-url.js +4 -0
  25. package/dist/lib/telemetry.d.ts +6 -2
  26. package/dist/lib/telemetry.js +12 -0
  27. package/dist/lib/tunnel-session.d.ts +13 -2
  28. package/dist/lib/tunnel-session.js +92 -23
  29. package/dist/lib/tunnel.types.d.ts +3 -1
  30. package/dist/vendor/tunnel-client/client.d.ts +11 -0
  31. package/dist/vendor/tunnel-client/client.js +383 -56
  32. package/dist/vendor/tunnel-client/config.d.ts +11 -3
  33. package/dist/vendor/tunnel-client/config.js +11 -3
  34. package/dist/vendor/tunnel-client/types.d.ts +26 -1
  35. package/dist/vendor/tunnel-client/types.js +1 -0
  36. package/dist/vendor/tunnel-client/ws-compat.d.ts +3 -2
  37. package/dist/vendor/tunnel-client/ws-compat.js +3 -2
  38. package/dist/version.d.ts +1 -1
  39. package/dist/version.js +1 -1
  40. package/package.json +2 -1
  41. package/skills/testsprite-onboard.skill.md +80 -59
  42. package/skills/testsprite-verify.codex.md +82 -97
  43. package/skills/testsprite-verify.skill.md +67 -16
@@ -4,14 +4,46 @@ import { basename, extname } from 'node:path';
4
4
  import { Readable } from 'node:stream';
5
5
  import { Command } from 'commander';
6
6
  import { emitDryRunBanner, makeHttpClient, parseRequestTimeoutFlag, resolveRequestTimeoutMs, } from '../lib/client-factory.js';
7
- import { ApiError, InterruptError, RequestTimeoutError } from '../lib/errors.js';
7
+ import { ApiError, InterruptError, RequestTimeoutError, localValidationError as flagValidationError, } from '../lib/errors.js';
8
8
  import { globalShutdown } from '../lib/interrupt.js';
9
+ import { buildLocalTargetUrl, DEFAULT_LOCAL_HOST, normalizeLocalHost, parseLocalPort, probeLocalPort, } from '../lib/local-target.js';
9
10
  import { GLOBAL_OPTS_HINT, Output, resolveOutputMode } from '../lib/output.js';
10
11
  import { readSecretFileGuarded } from '../lib/secret-file.js';
11
12
  import { assertNotLocal } from '../lib/target-url.js';
12
13
  import { renderTextTable, resolveTextColumns } from '../lib/text-table.js';
13
14
  import { assertIdempotencyKey } from '../lib/validate.js';
14
15
  import { fetchSinglePage, paginate, validatePaginationFlags, } from '../lib/pagination.js';
16
+ /** Attribute names are interpolated into CSS selectors by the engine — keep them plain. */
17
+ const TEST_ID_ATTRIBUTE_NAME = /^[A-Za-z_][\w.:-]*$/;
18
+ const TEST_ID_ATTRIBUTES_MAX = 10;
19
+ /**
20
+ * Parse `--test-id-attributes <list>`: a comma-separated, ordered list of DOM
21
+ * attribute names. Trims, drops empties and duplicates (first occurrence
22
+ * wins — order is the priority), rejects invalid names. Exported for tests.
23
+ */
24
+ export function parseTestIdAttributesFlag(raw, flagName) {
25
+ const seen = new Set();
26
+ const attrs = [];
27
+ for (const part of raw.split(',')) {
28
+ const name = part.trim();
29
+ if (!name)
30
+ continue;
31
+ if (name.length > 64 || !TEST_ID_ATTRIBUTE_NAME.test(name)) {
32
+ throw localValidationError(`--${flagName}: '${name}' is not a valid attribute name (letters, digits, '_', '-', '.', ':'; must not start with a digit).`);
33
+ }
34
+ if (!seen.has(name)) {
35
+ seen.add(name);
36
+ attrs.push(name);
37
+ }
38
+ }
39
+ if (attrs.length === 0) {
40
+ throw localValidationError(`--${flagName} needs at least one attribute name, e.g. --${flagName} data-element,data-testid`);
41
+ }
42
+ if (attrs.length > TEST_ID_ATTRIBUTES_MAX) {
43
+ throw localValidationError(`--${flagName} accepts at most ${TEST_ID_ATTRIBUTES_MAX} attribute names.`);
44
+ }
45
+ return attrs;
46
+ }
15
47
  export async function runList(opts, deps = {}) {
16
48
  const out = makeOutput(opts.output, deps);
17
49
  const paginationFlags = validatePaginationFlags({
@@ -53,6 +85,17 @@ export async function runGet(opts, deps = {}) {
53
85
  export function resolveCreatedProjectId(r) {
54
86
  return r.projectId ?? r.id;
55
87
  }
88
+ function normalizeProjectLocalHost(raw) {
89
+ try {
90
+ return normalizeLocalHost(raw);
91
+ }
92
+ catch (err) {
93
+ if (err instanceof ApiError && typeof err.details?.reason === 'string') {
94
+ throw flagValidationError('local-host', err.details.reason.replace('--target-url', '--url'), err.details.accepted);
95
+ }
96
+ throw err;
97
+ }
98
+ }
56
99
  export async function runCreate(opts, deps = {}) {
57
100
  const out = makeOutput(opts.output, deps);
58
101
  const stderr = deps.stderr ?? ((line) => process.stderr.write(`${line}\n`));
@@ -78,16 +121,34 @@ export async function runCreate(opts, deps = {}) {
78
121
  if (opts.description !== undefined) {
79
122
  throw localValidationError('--description is not supported for projects; omit it (test-level descriptions are set on `test create`)');
80
123
  }
124
+ if (opts.local !== undefined && opts.targetUrl !== undefined) {
125
+ throw localValidationError('--local and --url are mutually exclusive');
126
+ }
127
+ if (opts.local !== undefined && opts.type !== 'frontend') {
128
+ throw localValidationError('--local projects are frontend-only');
129
+ }
130
+ if (opts.localHost !== undefined && opts.local === undefined) {
131
+ throw localValidationError('--local-host requires --local');
132
+ }
133
+ if (opts.local !== undefined && !/^\d+$/.test(opts.local)) {
134
+ throw localValidationError('--local must be a port number between 1 and 65535');
135
+ }
136
+ const localTarget = opts.local !== undefined
137
+ ? { host: normalizeProjectLocalHost(opts.localHost), port: parseLocalPort(opts.local) }
138
+ : undefined;
139
+ const targetUrl = localTarget
140
+ ? buildLocalTargetUrl(localTarget.host, localTarget.port)
141
+ : opts.targetUrl;
81
142
  // P2-7: guard --url against localhost/RFC1918/non-http(s) (same rules as
82
143
  // `test create --target-url`). Applies to both FE (required) and BE (optional).
83
144
  if (opts.targetUrl !== undefined) {
84
145
  assertNotLocal(opts.targetUrl, {
85
146
  field: 'url',
86
147
  helpCommand: 'testsprite project create',
87
- hintContext: 'bootstrap',
148
+ hintContext: 'local-project-create',
88
149
  });
89
150
  }
90
- if (opts.type === 'frontend' && !opts.targetUrl) {
151
+ if (opts.type === 'frontend' && !targetUrl) {
91
152
  throw localValidationError('--url is required for --type frontend');
92
153
  }
93
154
  if (opts.dryRun) {
@@ -110,7 +171,8 @@ export async function runCreate(opts, deps = {}) {
110
171
  id: 'p_dryrun_2026',
111
172
  type: opts.type,
112
173
  name: opts.name,
113
- targetUrl: opts.targetUrl ?? '',
174
+ targetUrl: targetUrl ?? '',
175
+ ...(localTarget ? { originMode: 'local' } : {}),
114
176
  createdFrom: 'cli',
115
177
  createdAt: '2026-05-16T00:00:00.000Z',
116
178
  updatedAt: '2026-05-16T00:00:00.000Z',
@@ -118,6 +180,26 @@ export async function runCreate(opts, deps = {}) {
118
180
  out.print(sample, data => renderCreateProjectText(data));
119
181
  return sample;
120
182
  }
183
+ if (localTarget && !opts.skipPreflight) {
184
+ const outcome = await probeLocalPort(localTarget.host, localTarget.port, deps.localPortProbeDeps);
185
+ if (outcome.verdict === 'refuse') {
186
+ throw ApiError.fromEnvelope({
187
+ error: {
188
+ code: 'VALIDATION_ERROR',
189
+ message: `Nothing is listening on ${targetUrl}. Start your app first, or pass --skip-preflight.`,
190
+ nextAction: 'Verify --local and --local-host match the app you want to test.',
191
+ requestId: 'local',
192
+ details: {
193
+ field: 'local',
194
+ reason: 'local-port-not-listening',
195
+ host: localTarget.host,
196
+ port: localTarget.port,
197
+ probeReason: outcome.reason,
198
+ },
199
+ },
200
+ });
201
+ }
202
+ }
121
203
  // Resolve password: flag > file > none
122
204
  let password = opts.password;
123
205
  if (password === undefined && opts.passwordFile !== undefined) {
@@ -130,16 +212,24 @@ export async function runCreate(opts, deps = {}) {
130
212
  const body = {
131
213
  type: opts.type,
132
214
  name: opts.name,
133
- ...(opts.targetUrl !== undefined ? { targetUrl: opts.targetUrl } : {}),
215
+ ...(targetUrl !== undefined ? { targetUrl } : {}),
216
+ ...(localTarget ? { originMode: 'local' } : {}),
134
217
  ...(opts.username !== undefined ? { username: opts.username } : {}),
135
218
  ...(password !== undefined ? { password } : {}),
136
219
  ...(opts.instruction !== undefined ? { instruction: opts.instruction } : {}),
220
+ ...(opts.testIdAttributes !== undefined ? { testIdAttributes: opts.testIdAttributes } : {}),
137
221
  };
138
222
  const client = makeClient(opts, deps);
139
- const rawCreated = await client.post('/projects', {
140
- body,
141
- headers: { 'idempotency-key': idempotencyKey },
142
- });
223
+ let rawCreated;
224
+ try {
225
+ rawCreated = await client.post('/projects', {
226
+ body,
227
+ headers: { 'idempotency-key': idempotencyKey },
228
+ });
229
+ }
230
+ catch (err) {
231
+ throw translateUnsupportedTestIdAttributes(err, body.testIdAttributes !== undefined);
232
+ }
143
233
  // Normalize whichever id field name the backend actually
144
234
  // sent onto BOTH `projectId` and `id`, so JSON consumers keyed on either
145
235
  // name keep working regardless of which one the live response used.
@@ -148,7 +238,7 @@ export async function runCreate(opts, deps = {}) {
148
238
  ...rawCreated,
149
239
  ...(resolvedId !== undefined ? { projectId: resolvedId, id: resolvedId } : {}),
150
240
  };
151
- out.print(created, data => renderCreateProjectText(data));
241
+ out.print(created, data => renderCreateProjectText(data, localTarget));
152
242
  // A backend project created without --url has no default environment URL.
153
243
  // On the V3 execution path, the shared admission guard (`runProjectGuarded`
154
244
  // -> `assertProjectEnvNotLocal`, called by every V3 run/rerun/batch entry
@@ -219,6 +309,9 @@ export async function runUpdate(opts, deps = {}) {
219
309
  hintContext: 'bootstrap',
220
310
  });
221
311
  }
312
+ if (opts.testIdAttributes !== undefined && opts.clearTestIdAttributes) {
313
+ throw localValidationError('--test-id-attributes and --clear-test-id-attributes are mutually exclusive.');
314
+ }
222
315
  const passwordSupplied = opts.password !== undefined || opts.passwordFile !== undefined;
223
316
  const mutableFields = {
224
317
  name: opts.name !== undefined,
@@ -226,12 +319,14 @@ export async function runUpdate(opts, deps = {}) {
226
319
  username: opts.username !== undefined,
227
320
  password: passwordSupplied,
228
321
  instruction: opts.instruction !== undefined,
322
+ testIdAttributes: opts.testIdAttributes !== undefined || opts.clearTestIdAttributes === true,
229
323
  };
230
324
  const presentFieldNames = Object.entries(mutableFields)
231
325
  .filter(([, present]) => present)
232
326
  .map(([field]) => field);
233
327
  if (presentFieldNames.length === 0) {
234
- throw localValidationError('At least one mutable flag is required: --name, --url, --username, --password/--password-file, or --instruction.');
328
+ throw localValidationError('At least one mutable flag is required: --name, --url, --username, --password/--password-file, ' +
329
+ '--instruction, --test-id-attributes, or --clear-test-id-attributes.');
235
330
  }
236
331
  if (opts.dryRun) {
237
332
  // DEV-247: emit the banner here (this path returns before makeClient() does).
@@ -269,13 +364,21 @@ export async function runUpdate(opts, deps = {}) {
269
364
  username: opts.username,
270
365
  password,
271
366
  instruction: opts.instruction,
367
+ // `null` clears the list server-side (same convention as `test update --clear-step-timeout`).
368
+ testIdAttributes: opts.clearTestIdAttributes ? null : opts.testIdAttributes,
272
369
  };
273
370
  const body = Object.fromEntries(Object.entries(bodyFields).filter(([, v]) => v !== undefined));
274
371
  const client = makeClient(opts, deps);
275
- const rawUpdated = await client.patch(`/projects/${encodeURIComponent(opts.projectId)}`, {
276
- body,
277
- headers: { 'idempotency-key': idempotencyKey },
278
- });
372
+ let rawUpdated;
373
+ try {
374
+ rawUpdated = await client.patch(`/projects/${encodeURIComponent(opts.projectId)}`, {
375
+ body,
376
+ headers: { 'idempotency-key': idempotencyKey },
377
+ });
378
+ }
379
+ catch (err) {
380
+ throw translateUnsupportedTestIdAttributes(err, 'testIdAttributes' in body);
381
+ }
279
382
  // Normalize whichever id field name the backend actually
280
383
  // sent onto BOTH `projectId` and `id`, so JSON consumers keyed on either
281
384
  // name keep working regardless of which one the live response used.
@@ -886,13 +989,18 @@ export function createProjectCommand(deps = {}) {
886
989
  .description('Create a new project')
887
990
  .option('--type <frontend|backend>', 'project type (required)')
888
991
  .option('--name <name>', 'project name (required)')
889
- .option('--url <url>', 'target URL (required for frontend; also required for backend on the V3 execution ' +
992
+ .option('--url <url>', 'target URL (required for frontend unless --local is used; also required for backend on the V3 execution ' +
890
993
  'path — see `auth status` for your routing)')
994
+ .option('--local <port>', 'create a frontend project for an app on this machine (1-65535; excludes --url)')
995
+ .option('--local-host <host>', 'loopback host: localhost, 127.0.0.1 (default), or ::1; requires --local')
996
+ .option('--skip-preflight', 'skip the local TCP listener check before project creation')
891
997
  .option('--description <text>', 'not supported — projects have no description (test-level descriptions are set on `test create`)')
892
998
  .option('--username <user>', 'optional auth username')
893
999
  .option('--password <pw>', 'optional auth password (use --password-file for non-interactive)')
894
1000
  .option('--password-file <path>', 'read password from file instead of inline flag')
895
1001
  .option('--instruction <text>', 'optional FE plan-gen instruction hint')
1002
+ .option('--test-id-attributes <list>', 'comma-separated DOM attributes the engine should prefer as locators, highest priority first ' +
1003
+ '(e.g. data-element,data-testid). Unique values are exported as page.locator(\'[attr="…"]\').')
896
1004
  .option('--idempotency-key <token>', 'opaque idempotency token. Defaults to a UUIDv4 minted per invocation.')
897
1005
  .addHelpText('after', GLOBAL_OPTS_HINT)
898
1006
  .action(async (cmdOpts, command) => {
@@ -904,19 +1012,22 @@ export function createProjectCommand(deps = {}) {
904
1012
  if (type !== 'frontend' && type !== 'backend') {
905
1013
  throw localValidationError('--type must be frontend or backend');
906
1014
  }
907
- if (type === 'frontend' && !cmdOpts.url) {
908
- throw localValidationError('--url is required for --type frontend');
909
- }
910
1015
  await runCreate({
911
1016
  ...resolveCommonOptions(command),
912
1017
  type,
913
1018
  name: cmdOpts.name,
914
1019
  targetUrl: cmdOpts.url,
1020
+ local: cmdOpts.local,
1021
+ localHost: cmdOpts.localHost,
1022
+ skipPreflight: cmdOpts.skipPreflight,
915
1023
  description: cmdOpts.description,
916
1024
  username: cmdOpts.username,
917
1025
  password: cmdOpts.password,
918
1026
  passwordFile: cmdOpts.passwordFile,
919
1027
  instruction: cmdOpts.instruction,
1028
+ testIdAttributes: cmdOpts.testIdAttributes !== undefined
1029
+ ? parseTestIdAttributesFlag(cmdOpts.testIdAttributes, 'test-id-attributes')
1030
+ : undefined,
920
1031
  idempotencyKey: cmdOpts.idempotencyKey,
921
1032
  }, deps);
922
1033
  });
@@ -929,6 +1040,9 @@ export function createProjectCommand(deps = {}) {
929
1040
  .option('--password <pw>', 'new auth password')
930
1041
  .option('--password-file <path>', 'read new password from file')
931
1042
  .option('--instruction <text>', 'new FE plan-gen instruction hint')
1043
+ .option('--test-id-attributes <list>', 'comma-separated DOM attributes the engine should prefer as locators, highest priority first ' +
1044
+ '(e.g. data-element,data-testid); replaces the current list')
1045
+ .option('--clear-test-id-attributes', 'remove the test-id attribute list (engine falls back to data-testid)', false)
932
1046
  .option('--idempotency-key <token>', 'opaque idempotency token. Defaults to a UUIDv4 minted per invocation.')
933
1047
  .addHelpText('after', GLOBAL_OPTS_HINT)
934
1048
  .action(async (projectId, cmdOpts, command) => {
@@ -941,6 +1055,10 @@ export function createProjectCommand(deps = {}) {
941
1055
  password: cmdOpts.password,
942
1056
  passwordFile: cmdOpts.passwordFile,
943
1057
  instruction: cmdOpts.instruction,
1058
+ testIdAttributes: cmdOpts.testIdAttributes !== undefined
1059
+ ? parseTestIdAttributesFlag(cmdOpts.testIdAttributes, 'test-id-attributes')
1060
+ : undefined,
1061
+ clearTestIdAttributes: cmdOpts.clearTestIdAttributes,
944
1062
  idempotencyKey: cmdOpts.idempotencyKey,
945
1063
  }, deps);
946
1064
  });
@@ -1138,19 +1256,26 @@ const PROJECT_LIST_COLUMNS = [
1138
1256
  width: rows => Math.max(3, ...rows.map(project => (project.orgName ?? project.orgId ?? '').length)),
1139
1257
  render: project => project.orgName ?? project.orgId ?? '',
1140
1258
  },
1259
+ {
1260
+ header: 'URL',
1261
+ width: rows => Math.max(3, ...rows.map(project => renderProjectUrl(project).length)),
1262
+ render: renderProjectUrl,
1263
+ },
1141
1264
  { header: 'CREATED', width: 0, render: project => project.createdAt },
1142
1265
  ];
1143
- const PROJECT_LIST_ORG_COLUMN = PROJECT_LIST_COLUMNS.find(c => c.header === 'ORG');
1266
+ function renderProjectUrl(project) {
1267
+ const url = project.targetUrl ?? '';
1268
+ return project.originMode === 'local' ? `${url ? `${url} ` : ''}(Local)` : url;
1269
+ }
1144
1270
  /**
1145
1271
  * Default (no explicit `--columns`) column set. ORG is included only when
1146
- * at least one row in this page carries `orgId` — avoids widening the table
1147
- * for callers whose projects have no org attribution at all.
1272
+ * at least one row carries `orgId`; URL is included when a row is local.
1273
+ * Older responses retain the existing default table columns.
1148
1274
  */
1149
1275
  function defaultProjectListColumns(rows) {
1150
1276
  const hasOrgInfo = rows.some(project => project.orgId !== undefined);
1151
- return hasOrgInfo
1152
- ? PROJECT_LIST_COLUMNS
1153
- : PROJECT_LIST_COLUMNS.filter(c => c !== PROJECT_LIST_ORG_COLUMN);
1277
+ const hasLocalProject = rows.some(project => project.originMode === 'local');
1278
+ return PROJECT_LIST_COLUMNS.filter(column => (column.header !== 'ORG' || hasOrgInfo) && (column.header !== 'URL' || hasLocalProject));
1154
1279
  }
1155
1280
  function renderProjectListText(page, options = {}) {
1156
1281
  if (page.items.length === 0) {
@@ -1189,9 +1314,18 @@ function renderProjectText(p) {
1189
1314
  // hint) from "this endpoint doesn't report it" (say nothing).
1190
1315
  if ('targetUrl' in p) {
1191
1316
  lines.push(p.targetUrl
1192
- ? `targetUrl: ${p.targetUrl}`
1317
+ ? `targetUrl: ${renderProjectUrl(p)}`
1193
1318
  : `targetUrl: (not set — set one with: testsprite project update ${p.id} --url <url>)`);
1194
1319
  }
1320
+ if (p.originMode === 'local' && !p.targetUrl) {
1321
+ lines.push('originMode: local (Local)');
1322
+ }
1323
+ // Presence-keyed like targetUrl: older backends don't report the field at all.
1324
+ if ('testIdAttributes' in p) {
1325
+ lines.push(p.testIdAttributes && p.testIdAttributes.length > 0
1326
+ ? `testIdAttrs: ${p.testIdAttributes.join(', ')} (locator priority, highest first)`
1327
+ : `testIdAttrs: (not set — engine default data-testid; set with: testsprite project update ${p.id} --test-id-attributes <list>)`);
1328
+ }
1195
1329
  return lines.join('\n');
1196
1330
  }
1197
1331
  /**
@@ -1200,7 +1334,7 @@ function renderProjectText(p) {
1200
1334
  * field is proven reliable) because the create response's id field name and
1201
1335
  * `updatedAt` presence are not guaranteed — see `CliCreateProjectResponse`.
1202
1336
  */
1203
- function renderCreateProjectText(p) {
1337
+ function renderCreateProjectText(p, localTarget) {
1204
1338
  const lines = [
1205
1339
  `id: ${resolveCreatedProjectId(p) ?? '(unknown)'}`,
1206
1340
  `name: ${p.name}`,
@@ -1210,6 +1344,12 @@ function renderCreateProjectText(p) {
1210
1344
  ];
1211
1345
  if (p.updatedAt !== undefined)
1212
1346
  lines.push(`updatedAt: ${p.updatedAt}`);
1347
+ if (localTarget) {
1348
+ const projectId = resolveCreatedProjectId(p) ?? '<project-id>';
1349
+ const url = buildLocalTargetUrl(localTarget.host, localTarget.port);
1350
+ const hostFlag = localTarget.host === DEFAULT_LOCAL_HOST ? '' : ` --local-host ${localTarget.host}`;
1351
+ lines.push(`Local project: TestSprite will reach ${url} only through a tunnel from this machine.`, 'Next: write a plan and run it locally:', ` In plan.json, set projectId to ${projectId}.`, ` testsprite test create --project ${projectId} --plan-from plan.json`, ` testsprite test run <test-id> --local ${localTarget.port}${hostFlag}`, `Portal runs of this project stay blocked (free) until you set a public URL with: testsprite project update ${projectId} --url https://...`);
1352
+ }
1213
1353
  return lines.join('\n');
1214
1354
  }
1215
1355
  function renderUpdateText(r) {
@@ -1238,6 +1378,32 @@ function requireDocsProjectId(projectId, deps) {
1238
1378
  return envValue;
1239
1379
  throw localValidationError('--project <id> is required; pass --project <id> or set TESTSPRITE_PROJECT_ID');
1240
1380
  }
1381
+ /**
1382
+ * A backend that predates the testIdAttributes field answers a PATCH/POST that
1383
+ * carries it with a generic 400 whose `details.accepted` list omits the field
1384
+ * ("at least one field must be provided …" — misleading, since a field WAS
1385
+ * provided). Translate that into an honest UNSUPPORTED so the user learns the
1386
+ * real cause instead of re-reading their own command.
1387
+ */
1388
+ function translateUnsupportedTestIdAttributes(err, sentTestIdAttributes) {
1389
+ if (!sentTestIdAttributes || !(err instanceof ApiError) || err.code !== 'VALIDATION_ERROR')
1390
+ return err;
1391
+ const accepted = err.details?.accepted;
1392
+ if (!Array.isArray(accepted) || accepted.includes('testIdAttributes'))
1393
+ return err;
1394
+ return ApiError.fromEnvelope({
1395
+ error: {
1396
+ code: 'UNSUPPORTED',
1397
+ message: 'This backend does not support test-id attributes yet.',
1398
+ nextAction: 'The server accepted fields: ' +
1399
+ accepted.join(', ') +
1400
+ '. `--test-id-attributes` / `--clear-test-id-attributes` need a backend that knows the ' +
1401
+ '`testIdAttributes` field; retry once it is deployed, or drop the flag.',
1402
+ requestId: err.requestId,
1403
+ details: { reason: 'test_id_attributes_unsupported_backend', accepted },
1404
+ },
1405
+ });
1406
+ }
1241
1407
  function localValidationError(message) {
1242
1408
  return ApiError.fromEnvelope({
1243
1409
  error: {
@@ -6,6 +6,7 @@ import { ApiError, InterruptError } from '../lib/errors.js';
6
6
  import { type ShutdownHandle } from '../lib/interrupt.js';
7
7
  import type { FetchImpl } from '../lib/http.js';
8
8
  import { type Page } from '../lib/pagination.js';
9
+ import type { WaitTimeoutTelemetry } from '../lib/telemetry.js';
9
10
  import type { CliGetPlansResponse } from '../lib/plans.types.js';
10
11
  import type { RunResponse, RunStatus, TriggerRunResponse, RerunResponse, BatchRerunResponse, ListRunsResponse, RunSource, BatchRunFreshResponse, CancelRunResponse } from '../lib/runs.types.js';
11
12
  import { type LoopbackHost } from '../lib/local-target.js';
@@ -315,6 +316,8 @@ export interface CliFailureContext {
315
316
  failure: CliFailureBlock;
316
317
  }
317
318
  export interface TestDeps {
319
+ /** Report an exhausted poll deadline without changing the public output/error shape. */
320
+ onWaitTimeout?: (context: WaitTimeoutTelemetry) => void;
318
321
  env?: NodeJS.ProcessEnv;
319
322
  credentialsPath?: string;
320
323
  fetchImpl?: FetchImpl;
@@ -359,7 +362,10 @@ export interface TunnelDetach {
359
362
  runId: string;
360
363
  testId: string;
361
364
  localPort: number;
365
+ localHost: LoopbackHost;
362
366
  reason: TunnelDetachReason;
367
+ /** The borrowed tunnel owner disappeared while this run was non-terminal. */
368
+ ownerGone?: boolean;
363
369
  cancel: TunnelCancelOutcome;
364
370
  terminalStatus?: RunStatus;
365
371
  }
@@ -745,7 +751,7 @@ export interface CliCreateFromPlanResponse extends CliCreateTestResponse {
745
751
  * Caveat: the pinned tag only resolves once that version is actually
746
752
  * released — a locally-built/pre-release checkout may see a 404 until then.
747
753
  */
748
- export declare const PLAN_SCHEMA_URL = "https://raw.githubusercontent.com/TestSprite/testsprite-cli/v0.9.0/schemas/plan.schema.json";
754
+ export declare const PLAN_SCHEMA_URL = "https://raw.githubusercontent.com/TestSprite/testsprite-cli/v0.11.0/schemas/plan.schema.json";
749
755
  /**
750
756
  * The SINGLE canonical example plan. This
751
757
  * exact value (via `PLAN_TEMPLATE_TEXT` below) is:
@@ -934,8 +940,14 @@ export declare const DEFERRED_RETRY_DEFAULT_SLEEP_MS = 61000;
934
940
  * a secondary guard. If both fields are absent we treat the error as permanent
935
941
  * to avoid silently burning the entire retry budget on a non-recoverable state.
936
942
  *
943
+ * A 429 whose `details.reason` names a standing condition (see
944
+ * `STANDING_RATE_LIMIT_REASONS` in `lib/http.ts` — e.g. the live
945
+ * tunnel-binding cap) is also permanent, even though it now carries a real
946
+ * `Retry-After`: that header says when a retry COULD first succeed if the
947
+ * caller frees the resource, not that the condition clears on its own.
948
+ *
937
949
  * Limitation: a hypothetical future backend that emits `RATE_LIMITED` for a
938
- * third reason without a `Retry-After` header AND without the per-minute
950
+ * new reason without a `Retry-After` header AND without the per-minute
939
951
  * wording would be classified as permanent here. Document this if it occurs.
940
952
  */
941
953
  export declare function isTransientRateLimit(err: ApiError): boolean;