@testsprite/testsprite-cli 0.13.0 → 0.14.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 (58) hide show
  1. package/README.md +51 -48
  2. package/dist/commands/doctor.js +12 -11
  3. package/dist/commands/project-env.d.ts +11 -1
  4. package/dist/commands/project-env.js +399 -61
  5. package/dist/commands/project-sign-in.d.ts +60 -0
  6. package/dist/commands/project-sign-in.js +289 -0
  7. package/dist/commands/project.d.ts +9 -0
  8. package/dist/commands/project.js +68 -28
  9. package/dist/commands/schedule.d.ts +12 -0
  10. package/dist/commands/schedule.js +175 -5
  11. package/dist/commands/test.d.ts +53 -20
  12. package/dist/commands/test.js +1356 -342
  13. package/dist/commands/testlist.d.ts +10 -5
  14. package/dist/commands/testlist.js +170 -30
  15. package/dist/commands/tunnel.js +11 -5
  16. package/dist/index.js +12 -37
  17. package/dist/lib/client-factory.d.ts +12 -1
  18. package/dist/lib/client-factory.js +14 -4
  19. package/dist/lib/dry-run/samples.js +53 -0
  20. package/dist/lib/environment-tunnel.d.ts +109 -0
  21. package/dist/lib/environment-tunnel.js +465 -0
  22. package/dist/lib/errors.js +12 -1
  23. package/dist/lib/gh-output.js +3 -0
  24. package/dist/lib/http.d.ts +2 -0
  25. package/dist/lib/junit-report.d.ts +11 -7
  26. package/dist/lib/junit-report.js +13 -7
  27. package/dist/lib/local-target.d.ts +13 -3
  28. package/dist/lib/local-target.js +47 -12
  29. package/dist/lib/output.js +15 -1
  30. package/dist/lib/plan-poll.js +3 -4
  31. package/dist/lib/redact.d.ts +38 -0
  32. package/dist/lib/redact.js +140 -0
  33. package/dist/lib/render-error.d.ts +19 -5
  34. package/dist/lib/render-error.js +31 -0
  35. package/dist/lib/runs.types.d.ts +9 -1
  36. package/dist/lib/target-url.js +5 -5
  37. package/dist/lib/telemetry.d.ts +6 -7
  38. package/dist/lib/telemetry.js +11 -4
  39. package/dist/lib/testlist.types.d.ts +1 -0
  40. package/dist/lib/ticker.d.ts +9 -0
  41. package/dist/lib/ticker.js +18 -0
  42. package/dist/lib/tunnel-session.d.ts +3 -4
  43. package/dist/lib/tunnel-session.js +3 -4
  44. package/dist/lib/v3-advisory.js +0 -1
  45. package/dist/vendor/tunnel-client/client.d.ts +15 -8
  46. package/dist/vendor/tunnel-client/client.js +477 -407
  47. package/dist/vendor/tunnel-client/config.d.ts +5 -5
  48. package/dist/vendor/tunnel-client/config.js +5 -5
  49. package/dist/vendor/tunnel-client/index.d.ts +4 -4
  50. package/dist/vendor/tunnel-client/index.js +4 -4
  51. package/dist/vendor/tunnel-client/types.d.ts +19 -34
  52. package/dist/vendor/tunnel-client/types.js +1 -0
  53. package/dist/vendor/tunnel-client/ws-compat.d.ts +13 -3
  54. package/dist/vendor/tunnel-client/ws-compat.js +70 -12
  55. package/dist/version.d.ts +1 -1
  56. package/dist/version.js +1 -1
  57. package/package.json +1 -1
  58. package/skills/testsprite-onboard.skill.md +4 -4
@@ -123,7 +123,7 @@ const COUNT_KEYS = [
123
123
  'localConcurrencyLimit',
124
124
  'localPeakInFlight',
125
125
  ];
126
- const BOOLEAN_KEYS = ['force', 'workflowExisted'];
126
+ const BOOLEAN_KEYS = ['force', 'workflowExisted', 'local'];
127
127
  const ENUM_KEYS = {
128
128
  conflictReason: new Set([
129
129
  'in_flight',
@@ -176,6 +176,11 @@ let pendingExtras = {};
176
176
  export function recordTelemetryExtras(partial) {
177
177
  pendingExtras = { ...pendingExtras, ...sanitizeTelemetryExtras(partial) };
178
178
  }
179
+ /** Extend explicit --local telemetry to commands that automatically open a tunnel. */
180
+ export function recordTelemetryTunnelOpened(opened) {
181
+ if (opened)
182
+ recordTelemetryExtras({ local: true });
183
+ }
179
184
  /** Return everything recorded so far and clear the sink (one event per process). */
180
185
  export function takeTelemetryExtras() {
181
186
  const taken = pendingExtras;
@@ -327,6 +332,8 @@ function isTruthyEnv(v) {
327
332
  */
328
333
  export function buildTelemetryEvent(input, env, isTTY, extras = {}) {
329
334
  const client = resolveClientTag(env);
335
+ const { local: runtimeLocal, ...sanitizedExtras } = sanitizeTelemetryExtras(extras);
336
+ const local = input.local === true || runtimeLocal === true;
330
337
  return {
331
338
  command: input.command,
332
339
  outcome: input.outcome,
@@ -342,11 +349,11 @@ export function buildTelemetryEvent(input, env, isTTY, extras = {}) {
342
349
  ci: isTruthyEnv(env.CI) || !isTTY,
343
350
  ...(client !== undefined ? { client } : {}),
344
351
  ...buildCiContext(env),
345
- ...(input.local ? { local: true } : {}),
352
+ ...(local ? { local: true } : {}),
346
353
  ...(input.outcome === 'error' && input.reason === 'wait_timeout'
347
354
  ? {
348
355
  reason: 'wait_timeout',
349
- ...(input.local &&
356
+ ...(local &&
350
357
  (input.cancelOutcome === 'cancelled' ||
351
358
  input.cancelOutcome === 'already_terminal' ||
352
359
  input.cancelOutcome === 'failed' ||
@@ -355,7 +362,7 @@ export function buildTelemetryEvent(input, env, isTTY, extras = {}) {
355
362
  : {}),
356
363
  }
357
364
  : {}),
358
- ...sanitizeTelemetryExtras(extras),
365
+ ...sanitizedExtras,
359
366
  };
360
367
  }
361
368
  /**
@@ -67,6 +67,7 @@ export interface CliTestListRunAccepted {
67
67
  * is a 404). `reason` is set only when nothing dispatched (empty list).
68
68
  */
69
69
  export interface CliTestListRunResponse {
70
+ tunnelClientId?: string;
70
71
  accepted: CliTestListRunAccepted[];
71
72
  conflicts: RunConflict[];
72
73
  deferred: Array<{
@@ -25,6 +25,15 @@ export interface Ticker {
25
25
  * doesn't run into the result block). No-op on non-TTY.
26
26
  */
27
27
  finalize(line?: string): void;
28
+ /**
29
+ * Print a standalone line while the ticker is live: on a TTY the
30
+ * in-place progress line is cleared first so the note lands on its own
31
+ * row (a plain `stderr.write` would be appended to the tail of the
32
+ * progress line, whose writer never emits a newline). On a non-TTY the
33
+ * line is written as is. Use this for every stderr line a command prints
34
+ * between `update()` calls (hints, advisories, stage transitions).
35
+ */
36
+ note(line: string): void;
28
37
  /**
29
38
  * True only when `update()` redraws the SAME terminal line (TTY, ANSI
30
39
  * allowed). False on a non-TTY (updates are no-ops) and under NO_COLOR
@@ -141,6 +141,7 @@ export function createTicker(stderrWrite, isTTY, stderrRaw, noColor) {
141
141
  redrawsInPlace: false,
142
142
  update: () => undefined,
143
143
  finalize: () => undefined,
144
+ note: (line) => stderrWrite(line),
144
145
  };
145
146
  }
146
147
  if (suppressAnsi) {
@@ -160,6 +161,11 @@ export function createTicker(stderrWrite, isTTY, stderrRaw, noColor) {
160
161
  }
161
162
  void stderrWrite;
162
163
  },
164
+ note(line) {
165
+ // Every update is already its own line here; nothing to clear.
166
+ stderrWrite(line);
167
+ lastLength = 0;
168
+ },
163
169
  };
164
170
  }
165
171
  return {
@@ -179,9 +185,21 @@ export function createTicker(stderrWrite, isTTY, stderrRaw, noColor) {
179
185
  if (lastLength > 0) {
180
186
  // Move to a fresh line so the result block doesn't run into the ticker.
181
187
  rawWrite('\n');
188
+ // The live line is gone: a second finalize() (e.g. the failed-stage
189
+ // branch, then the catch-all) must not emit a stray blank line.
190
+ lastLength = 0;
182
191
  }
183
192
  void stderrWrite; // reference to suppress unused warning
184
193
  },
194
+ note(line) {
195
+ // Clear the live progress line (same ESC[2K + \r as update), then
196
+ // print the note with its own newline through the SAME raw writer so
197
+ // ordering is preserved. The next update() redraws below it.
198
+ if (lastLength > 0)
199
+ rawWrite('\x1b[2K\r');
200
+ rawWrite(`${line}\n`);
201
+ lastLength = 0;
202
+ },
185
203
  };
186
204
  }
187
205
  //# sourceMappingURL=ticker.js.map
@@ -45,10 +45,9 @@ import type { TunnelMintResponse } from './tunnel.types.js';
45
45
  * How long to wait for the control plane's first successful connection.
46
46
  *
47
47
  * The vendored client resolves `start()` only on the first
48
- * `control-connected` event, and its control loop retries every non-auth
49
- * failure forever. Without a deadline, `--local` against an unreachable
50
- * control plane hangs with no output at all — the worst possible shape for a
51
- * command an agent might be driving unattended.
48
+ * `control-authenticated` event. The client also bounds authentication at
49
+ * 10 seconds; this outer deadline bounds the complete connection attempt so an
50
+ * unreachable control plane cannot leave an unattended command hanging.
52
51
  */
53
52
  export declare const DEFAULT_TUNNEL_CONNECT_TIMEOUT_MS = 20000;
54
53
  /** Maximum time teardown lets a wedged client delay credential deletion. */
@@ -45,10 +45,9 @@ import { DEFAULT_DATA_PLANE_RETRY_DEADLINE_MS } from '../vendor/tunnel-client/co
45
45
  * How long to wait for the control plane's first successful connection.
46
46
  *
47
47
  * The vendored client resolves `start()` only on the first
48
- * `control-connected` event, and its control loop retries every non-auth
49
- * failure forever. Without a deadline, `--local` against an unreachable
50
- * control plane hangs with no output at all — the worst possible shape for a
51
- * command an agent might be driving unattended.
48
+ * `control-authenticated` event. The client also bounds authentication at
49
+ * 10 seconds; this outer deadline bounds the complete connection attempt so an
50
+ * unreachable control plane cannot leave an unattended command hanging.
52
51
  */
53
52
  export const DEFAULT_TUNNEL_CONNECT_TIMEOUT_MS = 20_000;
54
53
  /** Maximum time teardown lets a wedged client delay credential deletion. */
@@ -28,7 +28,6 @@ export function routingLabel(v3Enabled) {
28
28
  */
29
29
  export const V3_ROUTING_ADVISORY = [
30
30
  '[advisory] V3 routing is on for this account. While these gaps are open:',
31
- ' - `--target-url` is ignored on frontend runs (the run uses the project environment)',
32
31
  ' - a frontend rerun replays the run it was pointed at, not necessarily the latest saved code',
33
32
  ];
34
33
  /** Write the advisory to a stderr sink, one line per call. */
@@ -1,5 +1,5 @@
1
1
  import { EventEmitter } from "node:events";
2
- import { TunnelClientOptions } from "./types.js";
2
+ import { ErrCode, TunnelClientOptions, TunnelTransport } from "./types.js";
3
3
  export declare class TunnelClient extends EventEmitter {
4
4
  #private;
5
5
  private readonly options;
@@ -11,28 +11,31 @@ export declare class TunnelClient extends EventEmitter {
11
11
  private controlConnectionGeneration;
12
12
  private allowTunnelReconnect;
13
13
  private dataPlaneTerminalErrorReported;
14
+ private clientUnknownEpisodeStartedAt?;
15
+ private clientUnknownDeadline?;
14
16
  private readonly tunnelRuntimes;
15
- private reconnectDelayController;
17
+ private lifecycleController;
18
+ private targetDialController;
16
19
  private readonly activeTargetSockets;
17
20
  constructor(options: TunnelClientOptions);
18
- get transport(): "tls" | "plaintext";
21
+ get transport(): TunnelTransport;
19
22
  start(): Promise<void>;
20
23
  stop(): Promise<void>;
21
24
  private runControlLoop;
25
+ private openClientUnknownEpisode;
26
+ private clearClientUnknownEpisode;
22
27
  private runTunnelLoop;
23
28
  private connectControl;
24
29
  private sendControlMessage;
25
30
  private parseControlMessage;
26
31
  private ensureTunnelRuntime;
27
32
  private connectTunnel;
28
- private recordDataPlaneFailure;
29
- private armDataPlaneFailureDeadline;
33
+ private connectDataPlane;
34
+ private openDataPlaneFailureEpisode;
30
35
  private expireDataPlaneFailureEpisode;
31
- private markDataPlaneEstablished;
32
- private clearDataPlaneAttemptTimers;
33
36
  private clearDataPlaneFailureEpisode;
37
+ private clearAttemptTimers;
34
38
  private stopAllTunnelRuntimes;
35
- private beginStop;
36
39
  private handleIncomingStream;
37
40
  private proxyStreams;
38
41
  private copyOneWay;
@@ -84,6 +87,10 @@ export declare function ensureTargetAllowed(host: string, port: number, candidat
84
87
  host: string;
85
88
  port: number;
86
89
  }>, allowPrivateNetwork: boolean): void;
90
+ export declare class ClientUnknownError extends Error {
91
+ readonly code = ErrCode.ClientUnknown;
92
+ constructor(deadlineMs: number);
93
+ }
87
94
  /**
88
95
  * Thrown by {@link ensureTargetAllowed} when a proxied target resolves into a blocked
89
96
  * (private/internal) range. Mirrors the Rust client's `ensure_candidates_allowed` error.