@testsprite/testsprite-cli 0.7.0 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +62 -45
- package/dist/commands/agent.d.ts +3 -0
- package/dist/commands/agent.js +79 -10
- package/dist/commands/ci.d.ts +88 -0
- package/dist/commands/ci.js +432 -0
- package/dist/commands/doctor.js +100 -1
- package/dist/commands/init.d.ts +45 -2
- package/dist/commands/init.js +198 -29
- package/dist/commands/project.d.ts +78 -0
- package/dist/commands/project.js +439 -5
- package/dist/commands/test.d.ts +193 -4
- package/dist/commands/test.js +1948 -398
- package/dist/commands/testlist.js +15 -9
- package/dist/commands/tunnel.d.ts +72 -0
- package/dist/commands/tunnel.js +367 -0
- package/dist/index.js +107 -38
- package/dist/lib/agent-detect.d.ts +53 -0
- package/dist/lib/agent-detect.js +198 -0
- package/dist/lib/dry-run/samples.d.ts +9 -0
- package/dist/lib/dry-run/samples.js +116 -0
- package/dist/lib/gh-output.d.ts +7 -0
- package/dist/lib/gh-output.js +50 -7
- package/dist/lib/http.d.ts +104 -0
- package/dist/lib/http.js +126 -7
- package/dist/lib/interrupt.d.ts +38 -13
- package/dist/lib/interrupt.js +130 -15
- package/dist/lib/local-target.d.ts +95 -0
- package/dist/lib/local-target.js +184 -0
- package/dist/lib/plan-poll.d.ts +171 -0
- package/dist/lib/plan-poll.js +442 -0
- package/dist/lib/plans.types.d.ts +130 -0
- package/dist/lib/plans.types.js +31 -0
- package/dist/lib/poll-support.d.ts +26 -0
- package/dist/lib/poll-support.js +65 -0
- package/dist/lib/poll.d.ts +1 -0
- package/dist/lib/poll.js +2 -40
- package/dist/lib/response-schemas.d.ts +13 -0
- package/dist/lib/response-schemas.js +46 -0
- package/dist/lib/run-progress.d.ts +41 -0
- package/dist/lib/run-progress.js +56 -0
- package/dist/lib/runs.types.d.ts +50 -0
- package/dist/lib/skill-nudge.d.ts +13 -5
- package/dist/lib/skill-nudge.js +40 -14
- package/dist/lib/target-url-preflight.js +3 -3
- package/dist/lib/target-url.d.ts +54 -8
- package/dist/lib/target-url.js +274 -68
- package/dist/lib/telemetry.d.ts +11 -0
- package/dist/lib/telemetry.js +1 -0
- package/dist/lib/ticker.d.ts +8 -0
- package/dist/lib/ticker.js +3 -0
- package/dist/lib/tunnel-session.d.ts +138 -0
- package/dist/lib/tunnel-session.js +249 -0
- package/dist/lib/tunnel.types.d.ts +54 -0
- package/dist/lib/tunnel.types.js +8 -0
- package/dist/vendor/tunnel-client/client.d.ts +82 -0
- package/dist/vendor/tunnel-client/client.js +924 -0
- package/dist/vendor/tunnel-client/config.d.ts +49 -0
- package/dist/vendor/tunnel-client/config.js +50 -0
- package/dist/vendor/tunnel-client/index.d.ts +9 -0
- package/dist/vendor/tunnel-client/index.js +9 -0
- package/dist/vendor/tunnel-client/lodash-lite.d.ts +14 -0
- package/dist/vendor/tunnel-client/lodash-lite.js +24 -0
- package/dist/vendor/tunnel-client/protocol.d.ts +60 -0
- package/dist/vendor/tunnel-client/protocol.js +143 -0
- package/dist/vendor/tunnel-client/types.d.ts +101 -0
- package/dist/vendor/tunnel-client/types.js +10 -0
- package/dist/vendor/tunnel-client/ws-compat.d.ts +206 -0
- package/dist/vendor/tunnel-client/ws-compat.js +316 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +2 -1
- package/skills/testsprite-onboard.skill.md +60 -4
- package/skills/testsprite-verify.codex.md +22 -16
- package/skills/testsprite-verify.skill.md +27 -18
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Wire types for the DEV-384 plan-generation surface:
|
|
3
|
+
*
|
|
4
|
+
* `POST /api/cli/v1/projects/{id}/plans/generate` — start the next missing
|
|
5
|
+
* pipeline stage (202)
|
|
6
|
+
* `GET /api/cli/v1/projects/{id}/plans` — synthesized generation
|
|
7
|
+
* status + staged proposals + best-effort credits (long-polls via
|
|
8
|
+
* `?waitSeconds=1..25`)
|
|
9
|
+
* `POST /api/cli/v1/projects/{id}/plans/accept` — staged proposals → real
|
|
10
|
+
* test cases
|
|
11
|
+
*
|
|
12
|
+
* These mirror the backend facade's `cli-plans.types.ts` (V3-A) shape-for-
|
|
13
|
+
* shape. The generation `status` is FACADE-SYNTHESIZED — no such enum exists
|
|
14
|
+
* on the V3 pipeline itself (design-doc v3.1 §7, DR-31) — so the CLI treats
|
|
15
|
+
* it as the complete truth and never tries to derive state from anything
|
|
16
|
+
* else.
|
|
17
|
+
*/
|
|
18
|
+
/** Pipeline stages the trigger can start, in ladder order. */
|
|
19
|
+
export declare const PLAN_GENERATION_STAGES: readonly ["exploration", "strategy", "proposals"];
|
|
20
|
+
export type CliGenerationStage = (typeof PLAN_GENERATION_STAGES)[number];
|
|
21
|
+
/**
|
|
22
|
+
* Facade-synthesized generation status. `exploring`/`strategizing`/
|
|
23
|
+
* `proposing` are the active (keep-polling) states; `idle` means nothing is
|
|
24
|
+
* running (proposals present = staged batch ready, proposals empty = nothing
|
|
25
|
+
* staged yet); `failed` carries `errorCode`/`errorMessage`.
|
|
26
|
+
*/
|
|
27
|
+
export type CliGenerationStatus = 'exploring' | 'strategizing' | 'proposing' | 'idle' | 'failed';
|
|
28
|
+
/**
|
|
29
|
+
* `generation.errorCode` values a `failed` status can carry. Kept as an open
|
|
30
|
+
* string union on the wire (`string | null` in {@link CliGenerationBlock})
|
|
31
|
+
* so a future backend adding a code is non-breaking — the CLI renders the
|
|
32
|
+
* message text and never switches on codes outside this set.
|
|
33
|
+
*/
|
|
34
|
+
export type CliGenerationErrorCode = 'exploration_failed' | 'strategy_generation_stale' | 'proposal_generation_aborted';
|
|
35
|
+
/** Exploration progress: resources SETTLED (process AND embedding terminal). */
|
|
36
|
+
export interface CliGenerationProgress {
|
|
37
|
+
resourcesReady: number;
|
|
38
|
+
resourcesTotal: number;
|
|
39
|
+
}
|
|
40
|
+
export interface CliGenerationBlock {
|
|
41
|
+
status: CliGenerationStatus;
|
|
42
|
+
/** Present only while `exploring`. */
|
|
43
|
+
progress?: CliGenerationProgress;
|
|
44
|
+
errorCode: string | null;
|
|
45
|
+
errorMessage: string | null;
|
|
46
|
+
}
|
|
47
|
+
/** One FE plan step inside a staged proposal. */
|
|
48
|
+
export interface CliPlanProposalStep {
|
|
49
|
+
type: 'action' | 'assertion';
|
|
50
|
+
description: string;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* One staged proposal. `proposalId` is the stable id `accept --only`
|
|
54
|
+
* consumes — every listed proposal carries it, which is why the CLI table
|
|
55
|
+
* prints it.
|
|
56
|
+
*/
|
|
57
|
+
export interface CliPlanProposal {
|
|
58
|
+
proposalId: string;
|
|
59
|
+
title: string;
|
|
60
|
+
description: string;
|
|
61
|
+
/** CLI priority vocabulary (`p1`..`p3`, mapped from V3 High/Medium/Low). */
|
|
62
|
+
priority: string;
|
|
63
|
+
category: string;
|
|
64
|
+
feature: string;
|
|
65
|
+
type: 'frontend' | 'backend';
|
|
66
|
+
/** Frontend proposals: action/assertion steps. */
|
|
67
|
+
steps?: CliPlanProposalStep[];
|
|
68
|
+
/** Backend proposals: the endpoint under test (when resolvable). */
|
|
69
|
+
endpointPath?: string | null;
|
|
70
|
+
/** Backend proposals: variable names this test captures for consumers. */
|
|
71
|
+
captures?: string[];
|
|
72
|
+
/** Backend proposals: variable names this test consumes from producers. */
|
|
73
|
+
consumes?: string[];
|
|
74
|
+
}
|
|
75
|
+
export interface CliPlanCreditsCharged {
|
|
76
|
+
action: string;
|
|
77
|
+
amount: number;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Best-effort billing summary — the facade degrades this to an empty block
|
|
81
|
+
* on any billing-read failure, so the CLI must render fine without it
|
|
82
|
+
* (design-doc §5: "filled in best-effort and never able to fail the
|
|
83
|
+
* command").
|
|
84
|
+
*/
|
|
85
|
+
export interface CliPlanCreditsBlock {
|
|
86
|
+
charged: CliPlanCreditsCharged[];
|
|
87
|
+
balance: number | null;
|
|
88
|
+
}
|
|
89
|
+
/** `GET /projects/{id}/plans` response. */
|
|
90
|
+
export interface CliGetPlansResponse {
|
|
91
|
+
generation: CliGenerationBlock;
|
|
92
|
+
proposals: CliPlanProposal[];
|
|
93
|
+
/** Optional-safe on the wire: treat an absent block like an empty one. */
|
|
94
|
+
credits?: CliPlanCreditsBlock;
|
|
95
|
+
}
|
|
96
|
+
/** `POST /projects/{id}/plans/generate` response (HTTP 202 both ways). */
|
|
97
|
+
export interface CliGeneratePlansResponse {
|
|
98
|
+
/**
|
|
99
|
+
* `accepted` — one stage was started; poll `GET /plans`.
|
|
100
|
+
* `nothing_to_start` — proposals are already staged (the facade's
|
|
101
|
+
* no-restart guard: a duplicate append would wipe the staged batch and
|
|
102
|
+
* re-bill 2 credits, so the trigger refuses and points at the batch).
|
|
103
|
+
*/
|
|
104
|
+
status: 'accepted' | 'nothing_to_start';
|
|
105
|
+
/** The resolved V3 project id (the id `GET /plans` should be polled with). */
|
|
106
|
+
projectId: string;
|
|
107
|
+
stage: CliGenerationStage | null;
|
|
108
|
+
stagesRemaining: CliGenerationStage[];
|
|
109
|
+
enqueuedAt: string;
|
|
110
|
+
/**
|
|
111
|
+
* DEV-1008 — `stage: proposals` on a backend project only. Strategy
|
|
112
|
+
* categories the proposals stage was NOT asked for because they carry no
|
|
113
|
+
* endpoint to attach a test case to (cross-cutting themes such as
|
|
114
|
+
* authorization or pagination). Absent when nothing was skipped and on
|
|
115
|
+
* every other stage. The stage is charged flat, so this is the only
|
|
116
|
+
* signal that the plan covers fewer categories than the strategy lists.
|
|
117
|
+
*/
|
|
118
|
+
skippedCategories?: number;
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* `POST /projects/{id}/plans/accept` response — the server's real shape.
|
|
122
|
+
* No code-generation field: accept does not generate code (API test code
|
|
123
|
+
* generates at first run — DR-29).
|
|
124
|
+
*/
|
|
125
|
+
export interface CliAcceptPlansResponse {
|
|
126
|
+
acceptedCount: number;
|
|
127
|
+
caseKeys: string[];
|
|
128
|
+
}
|
|
129
|
+
/** The active (keep-polling) statuses. `idle`/`failed` are settled. */
|
|
130
|
+
export declare function isActiveGenerationStatus(status: CliGenerationStatus): boolean;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Wire types for the DEV-384 plan-generation surface:
|
|
3
|
+
*
|
|
4
|
+
* `POST /api/cli/v1/projects/{id}/plans/generate` — start the next missing
|
|
5
|
+
* pipeline stage (202)
|
|
6
|
+
* `GET /api/cli/v1/projects/{id}/plans` — synthesized generation
|
|
7
|
+
* status + staged proposals + best-effort credits (long-polls via
|
|
8
|
+
* `?waitSeconds=1..25`)
|
|
9
|
+
* `POST /api/cli/v1/projects/{id}/plans/accept` — staged proposals → real
|
|
10
|
+
* test cases
|
|
11
|
+
*
|
|
12
|
+
* These mirror the backend facade's `cli-plans.types.ts` (V3-A) shape-for-
|
|
13
|
+
* shape. The generation `status` is FACADE-SYNTHESIZED — no such enum exists
|
|
14
|
+
* on the V3 pipeline itself (design-doc v3.1 §7, DR-31) — so the CLI treats
|
|
15
|
+
* it as the complete truth and never tries to derive state from anything
|
|
16
|
+
* else.
|
|
17
|
+
*/
|
|
18
|
+
/** Pipeline stages the trigger can start, in ladder order. */
|
|
19
|
+
export const PLAN_GENERATION_STAGES = ['exploration', 'strategy', 'proposals'];
|
|
20
|
+
// A local `PLAN_STAGE_COSTS` price table used to live here, feeding the
|
|
21
|
+
// `--help` credits block and the pre-run hint. Both were removed: the command
|
|
22
|
+
// no longer quotes a price up front (matching `test run`), and actual spend is
|
|
23
|
+
// reported after the fact from `credits.charged` / `credits.balance` on the
|
|
24
|
+
// wire. Deliberately NOT kept as an unused constant — a hardcoded copy of the
|
|
25
|
+
// backend's rate card that nothing reads is a silent drift risk against
|
|
26
|
+
// `billing-pricing.ts`, which is the only billing authority.
|
|
27
|
+
/** The active (keep-polling) statuses. `idle`/`failed` are settled. */
|
|
28
|
+
export function isActiveGenerationStatus(status) {
|
|
29
|
+
return status === 'exploring' || status === 'strategizing' || status === 'proposing';
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=plans.types.js.map
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared low-level helpers for the two polling loops (`poll.ts` for run
|
|
3
|
+
* polling, `plan-poll.ts` for the plan-generation ladder). These three were
|
|
4
|
+
* byte-identical copies in both files (#341 review); extracted here so a fix
|
|
5
|
+
* to the interrupt/abort contract lands in one place. Signal COMPOSITION is
|
|
6
|
+
* deliberately NOT here — each loop composes its own session signal with a
|
|
7
|
+
* shape specific to its lifetime (`poll.ts` inline, `plan-poll.ts` via
|
|
8
|
+
* `composeSessionSignal`), and folding those together would couple two
|
|
9
|
+
* unrelated lifetimes.
|
|
10
|
+
*/
|
|
11
|
+
/** Resolve after `ms`. The default injectable sleep; tests substitute a fake. */
|
|
12
|
+
export declare function defaultSleep(ms: number, signal?: AbortSignal): Promise<void>;
|
|
13
|
+
/**
|
|
14
|
+
* Race a sleep against the shutdown signal: rejects with the signal's
|
|
15
|
+
* `InterruptError` reason the moment it fires, so no backoff/retry/pacing wait
|
|
16
|
+
* can delay the honest-detach UX. The default sleep receives the signal and
|
|
17
|
+
* clears its pending timer when interrupted; the outer race remains necessary
|
|
18
|
+
* for injected sleeps that do not implement cancellation themselves.
|
|
19
|
+
*/
|
|
20
|
+
export declare function sleepUnlessInterrupted(sleep: (ms: number, signal?: AbortSignal) => Promise<void>, ms: number, signal: AbortSignal | undefined): Promise<void>;
|
|
21
|
+
/**
|
|
22
|
+
* Detects an AbortError thrown when an AbortSignal fires. Works for native
|
|
23
|
+
* fetch AbortErrors as well as `AbortController.abort()` from Node 18+ stdlib
|
|
24
|
+
* (both set `name === 'AbortError'`).
|
|
25
|
+
*/
|
|
26
|
+
export declare function isAbortError(err: unknown): boolean;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared low-level helpers for the two polling loops (`poll.ts` for run
|
|
3
|
+
* polling, `plan-poll.ts` for the plan-generation ladder). These three were
|
|
4
|
+
* byte-identical copies in both files (#341 review); extracted here so a fix
|
|
5
|
+
* to the interrupt/abort contract lands in one place. Signal COMPOSITION is
|
|
6
|
+
* deliberately NOT here — each loop composes its own session signal with a
|
|
7
|
+
* shape specific to its lifetime (`poll.ts` inline, `plan-poll.ts` via
|
|
8
|
+
* `composeSessionSignal`), and folding those together would couple two
|
|
9
|
+
* unrelated lifetimes.
|
|
10
|
+
*/
|
|
11
|
+
/** Resolve after `ms`. The default injectable sleep; tests substitute a fake. */
|
|
12
|
+
export function defaultSleep(ms, signal) {
|
|
13
|
+
if (signal?.aborted)
|
|
14
|
+
return Promise.reject(signal.reason);
|
|
15
|
+
return new Promise((resolve, reject) => {
|
|
16
|
+
const timer = setTimeout(() => {
|
|
17
|
+
signal?.removeEventListener('abort', onAbort);
|
|
18
|
+
resolve();
|
|
19
|
+
}, ms);
|
|
20
|
+
const onAbort = () => {
|
|
21
|
+
clearTimeout(timer);
|
|
22
|
+
signal?.removeEventListener('abort', onAbort);
|
|
23
|
+
reject(signal?.reason);
|
|
24
|
+
};
|
|
25
|
+
signal?.addEventListener('abort', onAbort, { once: true });
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Race a sleep against the shutdown signal: rejects with the signal's
|
|
30
|
+
* `InterruptError` reason the moment it fires, so no backoff/retry/pacing wait
|
|
31
|
+
* can delay the honest-detach UX. The default sleep receives the signal and
|
|
32
|
+
* clears its pending timer when interrupted; the outer race remains necessary
|
|
33
|
+
* for injected sleeps that do not implement cancellation themselves.
|
|
34
|
+
*/
|
|
35
|
+
export function sleepUnlessInterrupted(sleep, ms, signal) {
|
|
36
|
+
if (signal == null)
|
|
37
|
+
return sleep(ms);
|
|
38
|
+
if (signal.aborted)
|
|
39
|
+
return Promise.reject(signal.reason);
|
|
40
|
+
return new Promise((resolve, reject) => {
|
|
41
|
+
const onAbort = () => reject(signal.reason);
|
|
42
|
+
signal.addEventListener('abort', onAbort, { once: true });
|
|
43
|
+
sleep(ms, signal).then(() => {
|
|
44
|
+
signal.removeEventListener('abort', onAbort);
|
|
45
|
+
resolve();
|
|
46
|
+
}, err => {
|
|
47
|
+
signal.removeEventListener('abort', onAbort);
|
|
48
|
+
reject(err instanceof Error ? err : new Error(String(err)));
|
|
49
|
+
});
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Detects an AbortError thrown when an AbortSignal fires. Works for native
|
|
54
|
+
* fetch AbortErrors as well as `AbortController.abort()` from Node 18+ stdlib
|
|
55
|
+
* (both set `name === 'AbortError'`).
|
|
56
|
+
*/
|
|
57
|
+
export function isAbortError(err) {
|
|
58
|
+
if (err instanceof Error && err.name === 'AbortError')
|
|
59
|
+
return true;
|
|
60
|
+
if (typeof err === 'object' && err !== null && 'name' in err) {
|
|
61
|
+
return err.name === 'AbortError';
|
|
62
|
+
}
|
|
63
|
+
return false;
|
|
64
|
+
}
|
|
65
|
+
//# sourceMappingURL=poll-support.js.map
|
package/dist/lib/poll.d.ts
CHANGED
|
@@ -22,6 +22,7 @@
|
|
|
22
22
|
*/
|
|
23
23
|
import type { ShutdownHandle } from './interrupt.js';
|
|
24
24
|
import type { RunResponse } from './runs.types.js';
|
|
25
|
+
export { isTerminalStatus } from './runs.types.js';
|
|
25
26
|
/**
|
|
26
27
|
* Minimal interface that `pollRunUntilTerminal` requires from the HTTP client.
|
|
27
28
|
* Using a structural interface (rather than the concrete `HttpClient`) makes
|
package/dist/lib/poll.js
CHANGED
|
@@ -21,7 +21,9 @@
|
|
|
21
21
|
* Deadline exceeded → throw `TimeoutError`.
|
|
22
22
|
*/
|
|
23
23
|
import { ApiError, InterruptError } from './errors.js';
|
|
24
|
+
import { defaultSleep, isAbortError, sleepUnlessInterrupted } from './poll-support.js';
|
|
24
25
|
import { isTerminalStatus } from './runs.types.js';
|
|
26
|
+
export { isTerminalStatus } from './runs.types.js';
|
|
25
27
|
/** Thrown when the polling deadline is hit. */
|
|
26
28
|
export class TimeoutError extends Error {
|
|
27
29
|
runId;
|
|
@@ -279,44 +281,4 @@ function backoffScheduleDelay(index) {
|
|
|
279
281
|
const jitter = base * 0.2 * (Math.random() * 2 - 1); // ±20%
|
|
280
282
|
return Math.max(0, Math.round(base + jitter));
|
|
281
283
|
}
|
|
282
|
-
function defaultSleep(ms) {
|
|
283
|
-
return new Promise(resolve => setTimeout(resolve, ms));
|
|
284
|
-
}
|
|
285
|
-
/**
|
|
286
|
-
* Race a sleep against the shutdown signal: rejects with the signal's
|
|
287
|
-
* `InterruptError` reason the moment it fires, so no backoff/retry wait can
|
|
288
|
-
* delay the honest-detach UX. Wraps the injected `sleep` (tests keep their
|
|
289
|
-
* deterministic fakes); the underlying timer is left to fire harmlessly —
|
|
290
|
-
* the interrupt path exits the process long before it matters.
|
|
291
|
-
*/
|
|
292
|
-
function sleepUnlessInterrupted(sleep, ms, signal) {
|
|
293
|
-
if (signal == null)
|
|
294
|
-
return sleep(ms);
|
|
295
|
-
if (signal.aborted)
|
|
296
|
-
return Promise.reject(signal.reason);
|
|
297
|
-
return new Promise((resolve, reject) => {
|
|
298
|
-
const onAbort = () => reject(signal.reason);
|
|
299
|
-
signal.addEventListener('abort', onAbort, { once: true });
|
|
300
|
-
sleep(ms).then(() => {
|
|
301
|
-
signal.removeEventListener('abort', onAbort);
|
|
302
|
-
resolve();
|
|
303
|
-
}, err => {
|
|
304
|
-
signal.removeEventListener('abort', onAbort);
|
|
305
|
-
reject(err instanceof Error ? err : new Error(String(err)));
|
|
306
|
-
});
|
|
307
|
-
});
|
|
308
|
-
}
|
|
309
|
-
/**
|
|
310
|
-
* Detects an AbortError thrown when an AbortSignal fires.
|
|
311
|
-
* Works for native fetch AbortErrors as well as `AbortController.abort()`
|
|
312
|
-
* from Node 18+ stdlib (both set `name === 'AbortError'`).
|
|
313
|
-
*/
|
|
314
|
-
function isAbortError(err) {
|
|
315
|
-
if (err instanceof Error && err.name === 'AbortError')
|
|
316
|
-
return true;
|
|
317
|
-
if (typeof err === 'object' && err !== null && 'name' in err) {
|
|
318
|
-
return err.name === 'AbortError';
|
|
319
|
-
}
|
|
320
|
-
return false;
|
|
321
|
-
}
|
|
322
284
|
//# sourceMappingURL=poll.js.map
|
|
@@ -34,6 +34,7 @@
|
|
|
34
34
|
import * as v from 'valibot';
|
|
35
35
|
import type { BatchRerunResponse, BatchRunFreshResponse, ListRunsResponse, RerunResponse, RunResponse, TriggerRunResponse } from './runs.types.js';
|
|
36
36
|
import type { CliTestListRunResponse } from './testlist.types.js';
|
|
37
|
+
import type { TunnelMintResponse, TunnelStatusResponse } from './tunnel.types.js';
|
|
37
38
|
/** Mirrors `RunResponse` (runs.types.ts): `GET /api/cli/v1/runs/{runId}`. */
|
|
38
39
|
export declare const RUN_RESPONSE_SCHEMA: v.GenericSchema<unknown, RunResponse>;
|
|
39
40
|
/** Mirrors `TriggerRunResponse` (runs.types.ts): `POST /tests/{testId}/runs`. */
|
|
@@ -88,3 +89,15 @@ export interface MeIdentityWire {
|
|
|
88
89
|
}
|
|
89
90
|
/** Mirrors `MeIdentity` (commands/doctor.ts): `GET /api/cli/v1/me` core. */
|
|
90
91
|
export declare const ME_IDENTITY_SCHEMA: v.GenericSchema<unknown, MeIdentityWire>;
|
|
92
|
+
/**
|
|
93
|
+
* Mirrors `TunnelMintResponse` (tunnel.types.ts): `POST /tunnel`.
|
|
94
|
+
*
|
|
95
|
+
* Every field is required rather than nullish-defaulted, and that is
|
|
96
|
+
* deliberate on this one surface: a mint response missing `controlUrl` or
|
|
97
|
+
* `tunnelAddr` cannot be used for anything, and the client's failure mode
|
|
98
|
+
* for a bad endpoint (a control socket that closes) is indistinguishable
|
|
99
|
+
* from an auth failure. Refusing the response here names the real problem.
|
|
100
|
+
*/
|
|
101
|
+
export declare const TUNNEL_MINT_RESPONSE_SCHEMA: v.GenericSchema<unknown, TunnelMintResponse>;
|
|
102
|
+
/** Mirrors `TunnelStatusResponse` (tunnel.types.ts): `GET /tunnel/{clientId}`. */
|
|
103
|
+
export declare const TUNNEL_STATUS_RESPONSE_SCHEMA: v.GenericSchema<unknown, TunnelStatusResponse>;
|
|
@@ -69,6 +69,9 @@ const RUN_STEP_DTO_SCHEMA = v.looseObject({
|
|
|
69
69
|
export const RUN_RESPONSE_SCHEMA = v.looseObject({
|
|
70
70
|
runId: v.string(),
|
|
71
71
|
testId: v.string(),
|
|
72
|
+
// The test's human title (for CI output). Absent on older servers; the type
|
|
73
|
+
// keeps it optional and renderers fall back to `testId`.
|
|
74
|
+
testTitle: v.nullish(v.string(), null),
|
|
72
75
|
projectId: v.string(),
|
|
73
76
|
userId: v.string(),
|
|
74
77
|
status: openWireLiteral(),
|
|
@@ -121,6 +124,10 @@ export const RUN_RESPONSE_SCHEMA = v.looseObject({
|
|
|
121
124
|
// through untouched) and normalized at the consumer, not in the schema.
|
|
122
125
|
// Locked by tests in response-schemas.test.ts.
|
|
123
126
|
dashboardUrl: v.nullish(v.string(), undefined),
|
|
127
|
+
// Same absent-key-preserving contract as `dashboardUrl` (see the note above):
|
|
128
|
+
// the run-scoped execution-result link is present only for a V3-served run
|
|
129
|
+
// with the server flag on, absent otherwise, and never materialized as null.
|
|
130
|
+
executionUrl: v.nullish(v.string(), undefined),
|
|
124
131
|
// Absence means "steps not requested" and drives command branching, so no
|
|
125
132
|
// default is applied (rule 3, optional branch).
|
|
126
133
|
steps: v.optional(v.nullable(v.array(RUN_STEP_DTO_SCHEMA))),
|
|
@@ -135,6 +142,12 @@ export const TRIGGER_RUN_RESPONSE_SCHEMA = v.looseObject({
|
|
|
135
142
|
enqueuedAt: v.string(),
|
|
136
143
|
codeVersion: v.string(),
|
|
137
144
|
targetUrl: v.string(),
|
|
145
|
+
// Server-built portal links (backend ≥ the run-links change). Optional
|
|
146
|
+
// with no default (rule 3): an older backend omits them, and a V3 run
|
|
147
|
+
// the server could not link stays ABSENT — the renderer prints a
|
|
148
|
+
// `dashboard` line only when the key is present.
|
|
149
|
+
dashboardUrl: v.optional(v.string()),
|
|
150
|
+
executionUrl: v.optional(v.string()),
|
|
138
151
|
});
|
|
139
152
|
// ---------------------------------------------------------------------------
|
|
140
153
|
// POST /tests/{testId}/runs/rerun
|
|
@@ -178,6 +191,9 @@ export const RERUN_RESPONSE_SCHEMA = v.looseObject({
|
|
|
178
191
|
// survives validation byte-identically). Older backends that predate the
|
|
179
192
|
// field simply omit it — never fails validation.
|
|
180
193
|
advisories: v.optional(v.array(RERUN_ADVISORY_SCHEMA)),
|
|
194
|
+
// Same present-or-absent portal links as TRIGGER_RUN_RESPONSE_SCHEMA.
|
|
195
|
+
dashboardUrl: v.optional(v.string()),
|
|
196
|
+
executionUrl: v.optional(v.string()),
|
|
181
197
|
});
|
|
182
198
|
// ---------------------------------------------------------------------------
|
|
183
199
|
// POST /tests/batch/rerun
|
|
@@ -229,6 +245,11 @@ export const BATCH_RUN_FRESH_RESPONSE_SCHEMA = v.looseObject({
|
|
|
229
245
|
deferred: v.array(v.looseObject({ testId: v.string() })),
|
|
230
246
|
skippedFrontend: v.array(v.string()),
|
|
231
247
|
skippedIntegration: v.array(v.looseObject({ testId: v.string() })),
|
|
248
|
+
// Project-level closing link. Absent-key-preserving like `RUN_RESPONSE_SCHEMA`'s
|
|
249
|
+
// `dashboardUrl` (see the note there): omitted stays ABSENT so the client
|
|
250
|
+
// keeps computing its legacy template for an older backend / the V2 engine;
|
|
251
|
+
// `null` passes through as a present key meaning "no correct page".
|
|
252
|
+
dashboardUrl: v.nullish(v.string(), undefined),
|
|
232
253
|
});
|
|
233
254
|
/**
|
|
234
255
|
* `POST /api/cli/v1/testlist/{listId}/run`. Mirrors the batch-run-fresh shape so
|
|
@@ -301,4 +322,29 @@ export const ME_IDENTITY_SCHEMA = v.looseObject({
|
|
|
301
322
|
organizations: v.optional(v.array(ORG_SUMMARY_SCHEMA)),
|
|
302
323
|
org: v.optional(ORG_BINDING_SCHEMA),
|
|
303
324
|
});
|
|
325
|
+
// ---------------------------------------------------------------------------
|
|
326
|
+
// /tunnel — DEV-747 piece 1 facade
|
|
327
|
+
// ---------------------------------------------------------------------------
|
|
328
|
+
/**
|
|
329
|
+
* Mirrors `TunnelMintResponse` (tunnel.types.ts): `POST /tunnel`.
|
|
330
|
+
*
|
|
331
|
+
* Every field is required rather than nullish-defaulted, and that is
|
|
332
|
+
* deliberate on this one surface: a mint response missing `controlUrl` or
|
|
333
|
+
* `tunnelAddr` cannot be used for anything, and the client's failure mode
|
|
334
|
+
* for a bad endpoint (a control socket that closes) is indistinguishable
|
|
335
|
+
* from an auth failure. Refusing the response here names the real problem.
|
|
336
|
+
*/
|
|
337
|
+
export const TUNNEL_MINT_RESPONSE_SCHEMA = v.looseObject({
|
|
338
|
+
clientId: v.pipe(v.string(), v.minLength(1)),
|
|
339
|
+
secret: v.pipe(v.string(), v.minLength(1)),
|
|
340
|
+
controlUrl: v.pipe(v.string(), v.minLength(1)),
|
|
341
|
+
tunnelAddr: v.pipe(v.string(), v.minLength(1)),
|
|
342
|
+
expiresAt: v.string(),
|
|
343
|
+
});
|
|
344
|
+
/** Mirrors `TunnelStatusResponse` (tunnel.types.ts): `GET /tunnel/{clientId}`. */
|
|
345
|
+
export const TUNNEL_STATUS_RESPONSE_SCHEMA = v.looseObject({
|
|
346
|
+
clientId: v.string(),
|
|
347
|
+
status: openWireLiteral(),
|
|
348
|
+
expiresAt: v.string(),
|
|
349
|
+
});
|
|
304
350
|
//# sourceMappingURL=response-schemas.js.map
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { RunResponse } from './runs.types.js';
|
|
2
|
+
import type { Ticker } from './ticker.js';
|
|
3
|
+
/**
|
|
4
|
+
* The in-place progress line for a polled run.
|
|
5
|
+
*
|
|
6
|
+
* Deliberately NO `completed/total` counter: on both the V2 and V3 read paths
|
|
7
|
+
* `stepSummary.total` and `.completed` are computed from the same array of
|
|
8
|
+
* already-finished step rows (a row is inserted only once its step has a
|
|
9
|
+
* verdict), so the two can never differ — `0/0 steps` at the start and `N/N`
|
|
10
|
+
* thereafter carried no information. Show the recorded count, or nothing.
|
|
11
|
+
*
|
|
12
|
+
* `tag` is inserted verbatim after the run id — the caller picks the bracket
|
|
13
|
+
* style (`(testId)` for batch members, `[role]` for closure members) so the
|
|
14
|
+
* two kinds of tag stay visually distinct.
|
|
15
|
+
*/
|
|
16
|
+
export declare function formatRunProgressLine(run: RunResponse, elapsedMs: number, tag?: string): string;
|
|
17
|
+
export interface LiveRunProgress {
|
|
18
|
+
/** Feed a poll result; renders immediately and becomes the refresher's snapshot. */
|
|
19
|
+
onTick(run: RunResponse, elapsedMs: number): void;
|
|
20
|
+
/** Stop the 1s refresher. Idempotent; call before the ticker's final line. */
|
|
21
|
+
stop(): void;
|
|
22
|
+
}
|
|
23
|
+
export interface LiveRunProgressOptions {
|
|
24
|
+
/**
|
|
25
|
+
* Whether to run the between-polls refresher. Defaults to
|
|
26
|
+
* `ticker.redrawsInPlace` — a ticker that prints a NEW line per `update()`
|
|
27
|
+
* (non-TTY, NO_COLOR) must not be redrawn once a second.
|
|
28
|
+
*/
|
|
29
|
+
enabled?: boolean;
|
|
30
|
+
intervalMs?: number;
|
|
31
|
+
now?: () => number;
|
|
32
|
+
setIntervalFn?: (cb: () => void, ms: number) => NodeJS.Timeout;
|
|
33
|
+
clearIntervalFn?: (handle: NodeJS.Timeout) => void;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Wraps a {@link Ticker} so the elapsed counter keeps moving between polls.
|
|
37
|
+
* In long-poll mode a `getRun` returns every ~25s, so a ticker driven only by
|
|
38
|
+
* `onTick` freezes for the whole wait; this re-renders the LAST snapshot
|
|
39
|
+
* every second with the wall-clock time that has passed since it arrived.
|
|
40
|
+
*/
|
|
41
|
+
export declare function createLiveRunProgress(ticker: Ticker, opts?: LiveRunProgressOptions, tag?: string): LiveRunProgress;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The in-place progress line for a polled run.
|
|
3
|
+
*
|
|
4
|
+
* Deliberately NO `completed/total` counter: on both the V2 and V3 read paths
|
|
5
|
+
* `stepSummary.total` and `.completed` are computed from the same array of
|
|
6
|
+
* already-finished step rows (a row is inserted only once its step has a
|
|
7
|
+
* verdict), so the two can never differ — `0/0 steps` at the start and `N/N`
|
|
8
|
+
* thereafter carried no information. Show the recorded count, or nothing.
|
|
9
|
+
*
|
|
10
|
+
* `tag` is inserted verbatim after the run id — the caller picks the bracket
|
|
11
|
+
* style (`(testId)` for batch members, `[role]` for closure members) so the
|
|
12
|
+
* two kinds of tag stay visually distinct.
|
|
13
|
+
*/
|
|
14
|
+
export function formatRunProgressLine(run, elapsedMs, tag) {
|
|
15
|
+
const elapsed = Math.round(elapsedMs / 1000);
|
|
16
|
+
const total = run.stepSummary?.total ?? 0;
|
|
17
|
+
const head = tag === undefined ? `Run ${run.runId}` : `Run ${run.runId} ${tag}`;
|
|
18
|
+
const steps = total > 0 ? ` · ${total} step${total === 1 ? '' : 's'}` : '';
|
|
19
|
+
return `${head} — ${run.status}${steps} · ${elapsed}s`;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Wraps a {@link Ticker} so the elapsed counter keeps moving between polls.
|
|
23
|
+
* In long-poll mode a `getRun` returns every ~25s, so a ticker driven only by
|
|
24
|
+
* `onTick` freezes for the whole wait; this re-renders the LAST snapshot
|
|
25
|
+
* every second with the wall-clock time that has passed since it arrived.
|
|
26
|
+
*/
|
|
27
|
+
export function createLiveRunProgress(ticker, opts = {}, tag) {
|
|
28
|
+
const now = opts.now ?? Date.now;
|
|
29
|
+
const setIntervalFn = opts.setIntervalFn ?? setInterval;
|
|
30
|
+
const clearIntervalFn = opts.clearIntervalFn ?? clearInterval;
|
|
31
|
+
const enabled = opts.enabled ?? ticker.redrawsInPlace;
|
|
32
|
+
let snapshot;
|
|
33
|
+
let handle;
|
|
34
|
+
if (enabled) {
|
|
35
|
+
handle = setIntervalFn(() => {
|
|
36
|
+
if (!snapshot)
|
|
37
|
+
return;
|
|
38
|
+
ticker.update(formatRunProgressLine(snapshot.run, snapshot.elapsedMs + (now() - snapshot.at), tag));
|
|
39
|
+
}, opts.intervalMs ?? 1000);
|
|
40
|
+
// Never let the refresher keep the process alive on its own.
|
|
41
|
+
handle.unref?.();
|
|
42
|
+
}
|
|
43
|
+
return {
|
|
44
|
+
onTick(run, elapsedMs) {
|
|
45
|
+
snapshot = { run, elapsedMs, at: now() };
|
|
46
|
+
ticker.update(formatRunProgressLine(run, elapsedMs, tag));
|
|
47
|
+
},
|
|
48
|
+
stop() {
|
|
49
|
+
if (handle !== undefined) {
|
|
50
|
+
clearIntervalFn(handle);
|
|
51
|
+
handle = undefined;
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
//# sourceMappingURL=run-progress.js.map
|
package/dist/lib/runs.types.d.ts
CHANGED
|
@@ -11,6 +11,17 @@ export interface TriggerRunBody {
|
|
|
11
11
|
source: 'cli';
|
|
12
12
|
/** Optional override for the project's configured target URL. */
|
|
13
13
|
targetUrl?: string;
|
|
14
|
+
/**
|
|
15
|
+
* DEV-747: id of a tunnel client minted through `POST /api/cli/v1/tunnel`.
|
|
16
|
+
*
|
|
17
|
+
* An ID, never a proxy string — the caller does not choose the proxy host.
|
|
18
|
+
* The server loads the binding, checks it belongs to the calling principal
|
|
19
|
+
* and that the tunnel is connected, and only then builds the proxy string
|
|
20
|
+
* from its own configuration. Sent ONLY alongside a loopback `targetUrl`;
|
|
21
|
+
* the server refuses the pairing in every other combination rather than
|
|
22
|
+
* dropping the field.
|
|
23
|
+
*/
|
|
24
|
+
tunnelClientId?: string;
|
|
14
25
|
}
|
|
15
26
|
/**
|
|
16
27
|
* Body sent to `POST /api/cli/v1/tests/{testId}/runs/rerun`.
|
|
@@ -78,6 +89,10 @@ export interface RerunResponse {
|
|
|
78
89
|
* on every other response, including older backends that predate the field.
|
|
79
90
|
*/
|
|
80
91
|
advisories?: RerunAdvisory[];
|
|
92
|
+
/** See `TriggerRunResponse.dashboardUrl` — same present-or-absent contract. */
|
|
93
|
+
dashboardUrl?: string;
|
|
94
|
+
/** See `TriggerRunResponse.executionUrl` — same present-or-absent contract. */
|
|
95
|
+
executionUrl?: string;
|
|
81
96
|
}
|
|
82
97
|
/**
|
|
83
98
|
* Body sent to `POST /api/cli/v1/tests/batch/rerun`.
|
|
@@ -151,6 +166,18 @@ export interface TriggerRunResponse {
|
|
|
151
166
|
codeVersion: string;
|
|
152
167
|
/** Resolved target URL (project default when --target-url absent). */
|
|
153
168
|
targetUrl: string;
|
|
169
|
+
/**
|
|
170
|
+
* Portal deep link for the run's test, built by the server for the store
|
|
171
|
+
* that dispatched it. Present-or-absent (never null): an older backend, a
|
|
172
|
+
* V3 run while the server's org-link flag is off, or one with no resolvable
|
|
173
|
+
* workspace all OMIT it, and the CLI prints nothing rather than guessing.
|
|
174
|
+
*/
|
|
175
|
+
dashboardUrl?: string;
|
|
176
|
+
/**
|
|
177
|
+
* Portal deep link to THIS run's result page — V3-served runs only (a V2
|
|
178
|
+
* run has no execution page). Same present-or-absent contract.
|
|
179
|
+
*/
|
|
180
|
+
executionUrl?: string;
|
|
154
181
|
}
|
|
155
182
|
/**
|
|
156
183
|
* Public run-status values.
|
|
@@ -192,6 +219,11 @@ export interface RunStepDto {
|
|
|
192
219
|
export interface RunResponse {
|
|
193
220
|
runId: string;
|
|
194
221
|
testId: string;
|
|
222
|
+
/**
|
|
223
|
+
* The test's human title, for CI output. `null`/absent on older servers or
|
|
224
|
+
* when it can't be resolved — consumers fall back to `testId`.
|
|
225
|
+
*/
|
|
226
|
+
testTitle?: string | null;
|
|
195
227
|
projectId: string;
|
|
196
228
|
userId: string;
|
|
197
229
|
status: RunStatus;
|
|
@@ -237,6 +269,14 @@ export interface RunResponse {
|
|
|
237
269
|
* `withRunDashboardUrl` in `commands/test.ts`.
|
|
238
270
|
*/
|
|
239
271
|
dashboardUrl?: string | null;
|
|
272
|
+
/**
|
|
273
|
+
* Portal deep link to THIS RUN's result page (`…/projects/{pid}/execution/{eid}`),
|
|
274
|
+
* the run-scoped companion to `dashboardUrl` (which opens the test case). Same
|
|
275
|
+
* server-built / omit-not-null contract as `dashboardUrl`: **V3-served runs
|
|
276
|
+
* only** — a V2 run has no execution page, so the field is absent there and the
|
|
277
|
+
* CLI keeps `dashboardUrl` (the test-case link) for the run cell.
|
|
278
|
+
*/
|
|
279
|
+
executionUrl?: string | null;
|
|
240
280
|
/**
|
|
241
281
|
* Full ordered step list. Only present when the request includes
|
|
242
282
|
* `?includeSteps=true`. Absent (undefined) when the flag was not sent.
|
|
@@ -400,4 +440,14 @@ export interface BatchRunFreshResponse {
|
|
|
400
440
|
skippedIntegration: Array<{
|
|
401
441
|
testId: string;
|
|
402
442
|
}>;
|
|
443
|
+
/**
|
|
444
|
+
* Project-level portal link the batch closes with ("watch it here"). Same
|
|
445
|
+
* absent-vs-present contract as the per-run `dashboardUrl`: ABSENT ⇒ an older
|
|
446
|
+
* backend (or the V2 engine, whose live page is the CLI's own
|
|
447
|
+
* `/dashboard/tests/{projectId}` template) — compute the legacy link
|
|
448
|
+
* client-side; a string ⇒ print it verbatim; `null` ⇒ the server knows no
|
|
449
|
+
* correct page exists (several sibling projects, no owning org) — print
|
|
450
|
+
* nothing rather than a dead link.
|
|
451
|
+
*/
|
|
452
|
+
dashboardUrl?: string | null;
|
|
403
453
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type AgentTarget } from './agent-targets.js';
|
|
1
2
|
import type { OutputMode } from './output.js';
|
|
2
3
|
/**
|
|
3
4
|
* Full command paths (group + leaf) that signal the caller is actively driving
|
|
@@ -41,13 +42,20 @@ export declare function isPlanTemplateInvocation(commandPath: string, planTempla
|
|
|
41
42
|
export interface SkillPresenceDeps {
|
|
42
43
|
existsSync?: (p: string) => boolean;
|
|
43
44
|
readFileSync?: (p: string) => string;
|
|
45
|
+
/**
|
|
46
|
+
* Narrow the check to specific agents. Pass the agents actually calling: a
|
|
47
|
+
* skill installed for some OTHER agent is not one this caller can read, and
|
|
48
|
+
* treating it as installed is what makes the miss silent. Empty or omitted
|
|
49
|
+
* keeps the any-target answer, which is all an unidentified caller supports.
|
|
50
|
+
*/
|
|
51
|
+
requiredTargets?: readonly AgentTarget[];
|
|
44
52
|
}
|
|
45
53
|
/**
|
|
46
|
-
* True if the `testsprite-verify` skill is installed
|
|
47
|
-
*
|
|
48
|
-
* exists. managed-section target (codex / AGENTS.md):
|
|
49
|
-
* carries one complete managed section — a user-authored
|
|
50
|
-
* sentinels, or with a truncated section, does NOT count
|
|
54
|
+
* True if the `testsprite-verify` skill is installed in `dir` — for any
|
|
55
|
+
* supported agent, or only for `deps.requiredTargets` when given. own-file
|
|
56
|
+
* targets: the landing file exists. managed-section target (codex / AGENTS.md):
|
|
57
|
+
* the file exists AND carries one complete managed section — a user-authored
|
|
58
|
+
* AGENTS.md without the sentinels, or with a truncated section, does NOT count.
|
|
51
59
|
*
|
|
52
60
|
* The TARGETS table is the single source of truth for landing paths, so this
|
|
53
61
|
* stays in lockstep with `agent install` without re-listing paths. Best-effort:
|