@testsprite/testsprite-cli 0.15.0 → 0.17.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 +53 -141
- package/dist/commands/agent.d.ts +12 -4
- package/dist/commands/agent.js +55 -65
- package/dist/commands/auth.d.ts +6 -10
- package/dist/commands/auth.js +44 -56
- package/dist/commands/ci.d.ts +23 -100
- package/dist/commands/ci.js +297 -489
- package/dist/commands/completion.js +2 -1
- package/dist/commands/conversation.d.ts +27 -0
- package/dist/commands/conversation.js +702 -0
- package/dist/commands/doctor.d.ts +5 -1
- package/dist/commands/doctor.js +130 -34
- package/dist/commands/init.d.ts +4 -45
- package/dist/commands/init.js +116 -68
- package/dist/commands/project-env.d.ts +62 -2
- package/dist/commands/project-env.js +426 -53
- package/dist/commands/project-sign-in.d.ts +0 -48
- package/dist/commands/project-sign-in.js +1 -224
- package/dist/commands/project.d.ts +15 -186
- package/dist/commands/project.js +93 -921
- package/dist/commands/result.d.ts +10 -0
- package/dist/commands/result.js +215 -0
- package/dist/commands/schedule.d.ts +0 -29
- package/dist/commands/schedule.js +47 -97
- package/dist/commands/test.d.ts +315 -1824
- package/dist/commands/test.js +1962 -13733
- package/dist/commands/testlist.d.ts +128 -5
- package/dist/commands/testlist.js +269 -329
- package/dist/commands/tunnel.d.ts +2 -2
- package/dist/commands/tunnel.js +43 -41
- package/dist/commands/usage.d.ts +12 -45
- package/dist/commands/usage.js +51 -131
- package/dist/index.js +189 -108
- package/dist/lib/agent-detect.js +9 -5
- package/dist/lib/agent-targets.d.ts +21 -2
- package/dist/lib/agent-targets.js +88 -11
- package/dist/lib/args.d.ts +13 -0
- package/dist/lib/args.js +49 -0
- package/dist/lib/basic-auth.d.ts +3 -0
- package/dist/lib/basic-auth.js +15 -0
- package/dist/lib/billing-refusal.js +4 -3
- package/dist/lib/ci-linkage.d.ts +4 -82
- package/dist/lib/ci-linkage.js +4 -157
- package/dist/lib/ci-run.js +1 -1
- package/dist/lib/client-factory.d.ts +10 -2
- package/dist/lib/client-factory.js +38 -26
- package/dist/lib/commit-signal.d.ts +65 -0
- package/dist/lib/commit-signal.js +305 -0
- package/dist/lib/concurrency-limiter.d.ts +6 -0
- package/dist/lib/concurrency-limiter.js +29 -0
- package/dist/lib/config.js +10 -5
- package/dist/lib/conflict-reason.d.ts +31 -4
- package/dist/lib/conflict-reason.js +38 -4
- package/dist/lib/conversation/answers.d.ts +9 -0
- package/dist/lib/conversation/answers.js +49 -0
- package/dist/lib/conversation/api.d.ts +71 -0
- package/dist/lib/conversation/api.js +150 -0
- package/dist/lib/conversation/change.d.ts +31 -0
- package/dist/lib/conversation/change.js +124 -0
- package/dist/lib/conversation/context.d.ts +19 -0
- package/dist/lib/conversation/context.js +70 -0
- package/dist/lib/conversation/environment.d.ts +15 -0
- package/dist/lib/conversation/environment.js +33 -0
- package/dist/lib/conversation/follow.d.ts +24 -0
- package/dist/lib/conversation/follow.js +42 -0
- package/dist/lib/conversation/render.d.ts +33 -0
- package/dist/lib/conversation/render.js +315 -0
- package/dist/lib/conversation/title.d.ts +2 -0
- package/dist/lib/conversation/title.js +18 -0
- package/dist/lib/conversation/types.d.ts +156 -0
- package/dist/lib/conversation/types.js +6 -0
- package/dist/lib/credentials.js +67 -11
- package/dist/lib/cron.d.ts +1 -1
- package/dist/lib/cron.js +2 -2
- package/dist/lib/dispatch-stop.d.ts +20 -0
- package/dist/lib/dispatch-stop.js +30 -0
- package/dist/lib/download.d.ts +71 -0
- package/dist/lib/download.js +274 -0
- package/dist/lib/dry-run/fetch.d.ts +10 -0
- package/dist/lib/dry-run/fetch.js +20 -0
- package/dist/lib/dry-run/samples.d.ts +6 -34
- package/dist/lib/dry-run/samples.js +389 -751
- package/dist/lib/environment-tunnel.d.ts +16 -26
- package/dist/lib/environment-tunnel.js +161 -157
- package/dist/lib/errors.d.ts +20 -4
- package/dist/lib/errors.js +36 -16
- package/dist/lib/facade.d.ts +7 -29
- package/dist/lib/facade.js +7 -36
- package/dist/lib/failing-fe-resolver.d.ts +13 -58
- package/dist/lib/failing-fe-resolver.js +47 -132
- package/dist/lib/first-suite-hint.d.ts +16 -22
- package/dist/lib/first-suite-hint.js +38 -47
- package/dist/lib/gh-output.d.ts +76 -21
- package/dist/lib/gh-output.js +171 -90
- package/dist/lib/git-utils.d.ts +56 -0
- package/dist/lib/git-utils.js +212 -0
- package/dist/lib/github-context.d.ts +2 -0
- package/dist/lib/github-context.js +40 -8
- package/dist/lib/history-retention.d.ts +6 -2
- package/dist/lib/history-retention.js +10 -7
- package/dist/lib/http.d.ts +58 -134
- package/dist/lib/http.js +352 -271
- package/dist/lib/interrupt.d.ts +14 -8
- package/dist/lib/interrupt.js +28 -10
- package/dist/lib/junit-report.d.ts +60 -4
- package/dist/lib/junit-report.js +209 -32
- package/dist/lib/local-target.d.ts +3 -3
- package/dist/lib/local-target.js +3 -3
- package/dist/lib/output.d.ts +0 -29
- package/dist/lib/output.js +10 -33
- package/dist/lib/pagination.d.ts +2 -5
- package/dist/lib/pagination.js +2 -5
- package/dist/lib/presigned-url.d.ts +22 -0
- package/dist/lib/presigned-url.js +90 -0
- package/dist/lib/prompt.js +36 -2
- package/dist/lib/proxy.js +2 -1
- package/dist/lib/redact.d.ts +2 -2
- package/dist/lib/redact.js +3 -4
- package/dist/lib/removed-commands.d.ts +18 -0
- package/dist/lib/removed-commands.js +154 -0
- package/dist/lib/render-error.d.ts +31 -6
- package/dist/lib/render-error.js +88 -25
- package/dist/lib/response-schemas.d.ts +38 -30
- package/dist/lib/response-schemas.js +210 -207
- package/dist/lib/result/api.d.ts +24 -0
- package/dist/lib/result/api.js +28 -0
- package/dist/lib/result/evidence.d.ts +71 -0
- package/dist/lib/result/evidence.js +420 -0
- package/dist/lib/result/render.d.ts +20 -0
- package/dist/lib/result/render.js +194 -0
- package/dist/lib/result/types.d.ts +122 -0
- package/dist/lib/result/types.js +19 -0
- package/dist/lib/run-output.d.ts +275 -0
- package/dist/lib/run-output.js +227 -0
- package/dist/lib/run-render.d.ts +101 -0
- package/dist/lib/run-render.js +183 -0
- package/dist/lib/run-wait.d.ts +192 -0
- package/dist/lib/run-wait.js +452 -0
- package/dist/lib/runs.types.d.ts +134 -367
- package/dist/lib/runs.types.js +0 -14
- package/dist/lib/secret-file.d.ts +1 -1
- package/dist/lib/secret-file.js +11 -2
- package/dist/lib/skill-nudge.d.ts +7 -27
- package/dist/lib/skill-nudge.js +9 -37
- package/dist/lib/target-path.d.ts +15 -0
- package/dist/lib/target-path.js +35 -0
- package/dist/lib/target-url-advisory.d.ts +19 -0
- package/dist/lib/target-url-advisory.js +31 -0
- package/dist/lib/target-url-preflight.d.ts +9 -0
- package/dist/lib/target-url-preflight.js +214 -106
- package/dist/lib/target-url.d.ts +1 -1
- package/dist/lib/target-url.js +6 -16
- package/dist/lib/telemetry.d.ts +32 -12
- package/dist/lib/telemetry.js +39 -8
- package/dist/lib/terminal-text.d.ts +41 -0
- package/dist/lib/terminal-text.js +127 -0
- package/dist/lib/testlist.types.d.ts +16 -8
- package/dist/lib/testlist.types.js +1 -1
- package/dist/lib/text-equality.d.ts +2 -0
- package/dist/lib/text-equality.js +5 -0
- package/dist/lib/text-file.d.ts +16 -0
- package/dist/lib/text-file.js +41 -0
- package/dist/lib/text-table.d.ts +46 -0
- package/dist/lib/text-table.js +72 -4
- package/dist/lib/ticker.d.ts +9 -2
- package/dist/lib/ticker.js +16 -3
- package/dist/lib/transport-failure.d.ts +22 -0
- package/dist/lib/transport-failure.js +126 -0
- package/dist/lib/tunnel-session.d.ts +7 -1
- package/dist/lib/tunnel-session.js +22 -9
- package/dist/lib/update-check.js +3 -2
- package/dist/lib/url-template.d.ts +43 -0
- package/dist/lib/url-template.js +151 -0
- package/dist/lib/validate.d.ts +0 -64
- package/dist/lib/validate.js +2 -131
- package/dist/lib/version-notice.js +4 -3
- package/dist/lib/wait-exit.d.ts +37 -2
- package/dist/lib/wait-exit.js +88 -30
- package/dist/lib/workspace-status.js +10 -2
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +3 -4
- package/skills/testsprite-ci.skill.md +48 -18
- package/skills/testsprite-onboard.skill.md +66 -151
- package/skills/testsprite-verify.codex.md +54 -56
- package/skills/testsprite-verify.skill.md +194 -358
- package/dist/lib/browser.d.ts +0 -6
- package/dist/lib/browser.js +0 -54
- package/dist/lib/bundle.d.ts +0 -234
- package/dist/lib/bundle.js +0 -781
- package/dist/lib/deprecate.d.ts +0 -10
- package/dist/lib/deprecate.js +0 -13
- package/dist/lib/flaky.d.ts +0 -91
- package/dist/lib/flaky.js +0 -71
- package/dist/lib/plan-poll.d.ts +0 -171
- package/dist/lib/plan-poll.js +0 -441
- package/dist/lib/plans.types.d.ts +0 -130
- package/dist/lib/plans.types.js +0 -31
- package/dist/lib/poll.d.ts +0 -100
- package/dist/lib/poll.js +0 -290
- package/dist/lib/rate-throttle.d.ts +0 -49
- package/dist/lib/rate-throttle.js +0 -75
- package/dist/lib/run-progress.d.ts +0 -41
- package/dist/lib/run-progress.js +0 -56
- package/dist/lib/v3-advisory.d.ts +0 -55
- package/dist/lib/v3-advisory.js +0 -74
- package/schemas/plan.schema.json +0 -61
package/dist/lib/browser.d.ts
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
export interface OpenInBrowserDeps {
|
|
2
|
-
platform?: NodeJS.Platform;
|
|
3
|
-
/** Process spawner taking an argv array. Defaults to a detached spawn. */
|
|
4
|
-
exec?: (command: string, args: readonly string[]) => void;
|
|
5
|
-
}
|
|
6
|
-
export declare function openInBrowser(url: string, deps?: OpenInBrowserDeps): void;
|
package/dist/lib/browser.js
DELETED
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Cross-platform "open this URL in the default browser" helper for
|
|
3
|
-
* `test open` (issue #121). Spawns the platform opener with an argv array
|
|
4
|
-
* (never a shell string) so a URL can never be shell-injected, and refuses
|
|
5
|
-
* anything that is not http(s) before any process is spawned.
|
|
6
|
-
*
|
|
7
|
-
* Platform openers:
|
|
8
|
-
* darwin open <url>
|
|
9
|
-
* win32 rundll32 url.dll,FileProtocolHandler <url> (avoids `cmd /c start`,
|
|
10
|
-
* whose re-parsing would mangle `&` and other metachars in the URL)
|
|
11
|
-
* other xdg-open <url>
|
|
12
|
-
*
|
|
13
|
-
* The child is detached and unref'd so the CLI exits immediately; failures
|
|
14
|
-
* are the caller's to surface (it already printed the URL as the fallback).
|
|
15
|
-
*/
|
|
16
|
-
import { spawn } from 'node:child_process';
|
|
17
|
-
import { localValidationError } from './errors.js';
|
|
18
|
-
export function openInBrowser(url, deps = {}) {
|
|
19
|
-
let parsed;
|
|
20
|
-
try {
|
|
21
|
-
parsed = new URL(url);
|
|
22
|
-
}
|
|
23
|
-
catch {
|
|
24
|
-
throw localValidationError('url', 'must be a valid http(s) URL', undefined, 'field');
|
|
25
|
-
}
|
|
26
|
-
if (parsed.protocol !== 'https:' && parsed.protocol !== 'http:') {
|
|
27
|
-
// User-input error, not an internal failure: classify as VALIDATION_ERROR
|
|
28
|
-
// so it maps to exit 5 (like every other bad-argument path), not exit 1.
|
|
29
|
-
throw localValidationError('url', `must be an http(s) URL (got ${parsed.protocol})`, undefined, 'field');
|
|
30
|
-
}
|
|
31
|
-
const platform = deps.platform ?? process.platform;
|
|
32
|
-
const exec = deps.exec ??
|
|
33
|
-
((command, args) => {
|
|
34
|
-
const child = spawn(command, [...args], { detached: true, stdio: 'ignore' });
|
|
35
|
-
// spawn() reports a missing binary (ENOENT) ASYNCHRONOUSLY on the child,
|
|
36
|
-
// so the caller's try/catch cannot see it — and an unhandled 'error'
|
|
37
|
-
// event would crash the whole CLI. The URL is already on stdout, so
|
|
38
|
-
// degrade to the same manual-open hint the sync failure path prints.
|
|
39
|
-
child.on('error', () => {
|
|
40
|
-
process.stderr.write('could not launch a browser; open the URL above manually (or use --no-browser)\n');
|
|
41
|
-
});
|
|
42
|
-
child.unref();
|
|
43
|
-
});
|
|
44
|
-
if (platform === 'darwin') {
|
|
45
|
-
exec('open', [url]);
|
|
46
|
-
return;
|
|
47
|
-
}
|
|
48
|
-
if (platform === 'win32') {
|
|
49
|
-
exec('rundll32', ['url.dll,FileProtocolHandler', url]);
|
|
50
|
-
return;
|
|
51
|
-
}
|
|
52
|
-
exec('xdg-open', [url]);
|
|
53
|
-
}
|
|
54
|
-
//# sourceMappingURL=browser.js.map
|
package/dist/lib/bundle.d.ts
DELETED
|
@@ -1,234 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* §6.7 FailureContext bundle writer.
|
|
3
|
-
*
|
|
4
|
-
* Given a `FailureContext` JSON envelope (returned by
|
|
5
|
-
* `GET /api/cli/v1/tests/{id}/failure`), `writeBundle` dereferences
|
|
6
|
-
* every presigned URL into local bytes and writes the §7 disk layout
|
|
7
|
-
* under `<dir>`. The contract is "agent-safe" — every guarantee in
|
|
8
|
-
* the FailureContext spec §3 + §7 is enforced here:
|
|
9
|
-
*
|
|
10
|
-
* 1. **Atomic** — every artifact in the bundle came from one
|
|
11
|
-
* `snapshotId`. We refuse a forged response where
|
|
12
|
-
* `bundle.snapshotId !== result.snapshotId` or steps disagree on
|
|
13
|
-
* `runIdIfAvailable` (`assertContextIntegrity`).
|
|
14
|
-
* 2. **Atomic on disk** — we write to `<dir>/.tmp/...` first and
|
|
15
|
-
* `rename()` each file into place. `meta.json` is renamed last so
|
|
16
|
-
* the presence of `<dir>/meta.json` ⇔ "bundle is complete and
|
|
17
|
-
* self-consistent".
|
|
18
|
-
* 3. **`.partial` on failure** — any download or fs failure leaves
|
|
19
|
-
* a `<dir>/.partial` marker (with `requestId`, error summary,
|
|
20
|
-
* snapshotId) and exits non-zero. Agents check `.partial` before
|
|
21
|
-
* consuming.
|
|
22
|
-
* 4. **Bounded budget** — the writer streams URL → file (no full-
|
|
23
|
-
* buffer), so a 200MB video doesn't sit in V8's heap.
|
|
24
|
-
*
|
|
25
|
-
* What this module deliberately does NOT do:
|
|
26
|
-
*
|
|
27
|
-
* - Re-derive `snapshotId`. The CLI trusts whatever the facade
|
|
28
|
-
* returned. A snapshotId mismatch is a backend bug and we surface
|
|
29
|
-
* it as a typed validation error rather than try to "heal" it.
|
|
30
|
-
* - Generate `summary` strings. Those are server-side per §6.1 of
|
|
31
|
-
* the spec; the CLI emits whatever the facade produced.
|
|
32
|
-
* - Resume after a partial bundle. M2 always re-fetches from scratch
|
|
33
|
-
* when the agent re-runs. M3 may add resume.
|
|
34
|
-
*/
|
|
35
|
-
import type { CliFailureContext } from '../commands/test.js';
|
|
36
|
-
import { type ShutdownHandle } from './interrupt.js';
|
|
37
|
-
import type { FetchImpl } from './http.js';
|
|
38
|
-
/** Schema version stamped into `meta.json`. Bumps with the contract. */
|
|
39
|
-
export declare const BUNDLE_SCHEMA_VERSION: "cli-v1";
|
|
40
|
-
/** Max fetch attempts for each presigned URL (initial + retries). */
|
|
41
|
-
export declare const STREAM_URL_MAX_RETRIES = 3;
|
|
42
|
-
/** Delay between retries for transient transport failures (ms). */
|
|
43
|
-
export declare const STREAM_URL_RETRY_DELAY_MS = 1000;
|
|
44
|
-
/** Default radius around the failed step when `--failed-only` is set. */
|
|
45
|
-
export declare const FAILED_ONLY_RADIUS = 1;
|
|
46
|
-
/**
|
|
47
|
-
* Sentinel reasons emitted on the `details.reason` field when the
|
|
48
|
-
* integrity check throws. Exported so callers can branch on a typed
|
|
49
|
-
* literal rather than parsing the message text.
|
|
50
|
-
*/
|
|
51
|
-
export type BundleIntegrityReason = 'snapshot_id_mismatch' | 'run_id_mismatch' | 'code_version_mismatch' | 'evidence_missing_failed_step' | 'run_id_missing' | 'test_id_mismatch';
|
|
52
|
-
/**
|
|
53
|
-
* Options for {@link assertContextIntegrity}.
|
|
54
|
-
*/
|
|
55
|
-
export interface AssertContextIntegrityOptions {
|
|
56
|
-
/**
|
|
57
|
-
* When `true`, the run-scoped path requires `ctx.meta.runId` (i.e.,
|
|
58
|
-
* `ctx.result.runIdIfAvailable`) to be present. M2 callers pass
|
|
59
|
-
* `{}` (or omit entirely) to preserve the opt-in behavior.
|
|
60
|
-
*/
|
|
61
|
-
requireRunId?: boolean;
|
|
62
|
-
}
|
|
63
|
-
/**
|
|
64
|
-
* Identity card written as `<dir>/meta.json`. Agents read this first —
|
|
65
|
-
* if any other file's `snapshotId` disagrees, the bundle is corrupt
|
|
66
|
-
* and they must refuse to act.
|
|
67
|
-
*
|
|
68
|
-
* `runIdIfAvailable` and `codeVersion` are surfaced from `result`
|
|
69
|
-
* (already shared across every step in a valid bundle, so the meta
|
|
70
|
-
* carries the bundle-wide value rather than the per-step one).
|
|
71
|
-
*/
|
|
72
|
-
export interface BundleMeta {
|
|
73
|
-
schemaVersion: typeof BUNDLE_SCHEMA_VERSION;
|
|
74
|
-
snapshotId: string;
|
|
75
|
-
testId: string;
|
|
76
|
-
projectId: string;
|
|
77
|
-
codeVersion: string | null;
|
|
78
|
-
runIdIfAvailable: string | null;
|
|
79
|
-
targetUrl: string | null;
|
|
80
|
-
failedStepIndex: number | null;
|
|
81
|
-
failureKind: string | null;
|
|
82
|
-
/** When the backend captured the snapshot. Mirrors `result.finishedAt`. */
|
|
83
|
-
capturedAt: string | null;
|
|
84
|
-
/** When the CLI fetched the bundle (this run's clock). */
|
|
85
|
-
fetchedAt: string;
|
|
86
|
-
}
|
|
87
|
-
export interface WriteBundleOptions {
|
|
88
|
-
/** Absolute or relative target directory. */
|
|
89
|
-
dir: string;
|
|
90
|
-
/** Apply the §7.4 `--failed-only` filter (failed step ± 1) before downloading. */
|
|
91
|
-
failedOnly: boolean;
|
|
92
|
-
/** Custom fetch impl for tests. Defaults to global `fetch`. */
|
|
93
|
-
fetchImpl?: FetchImpl;
|
|
94
|
-
shutdownSignal?: AbortSignal;
|
|
95
|
-
shutdown?: Pick<ShutdownHandle, 'runCriticalOperation'>;
|
|
96
|
-
/** Server requestId to embed in `.partial` on failure. */
|
|
97
|
-
requestId?: string;
|
|
98
|
-
}
|
|
99
|
-
export interface WriteBundleResult {
|
|
100
|
-
meta: BundleMeta;
|
|
101
|
-
/** Absolute path of the bundle directory. */
|
|
102
|
-
dir: string;
|
|
103
|
-
/** Files actually written, relative to `dir`. */
|
|
104
|
-
files: string[];
|
|
105
|
-
}
|
|
106
|
-
/**
|
|
107
|
-
* Compose the FailureContext spec §3 invariants into a single
|
|
108
|
-
* trip wire. Throwing here is the agent-safety gate — we trust the
|
|
109
|
-
* facade for the data, not for self-consistency.
|
|
110
|
-
*
|
|
111
|
-
* - Bundle-level `snapshotId` MUST equal `result.snapshotId`.
|
|
112
|
-
* - All steps in the bundle MUST share `runIdIfAvailable` (or all
|
|
113
|
-
* be `null`). Mixed values means a stitched read leaked through.
|
|
114
|
-
*
|
|
115
|
-
* The error envelope is `VALIDATION_ERROR` rather than `INTERNAL`
|
|
116
|
-
* because the operator-facing remediation is "retry once" (the
|
|
117
|
-
* snapshot may genuinely have been mid-mutation; a fresh fetch will
|
|
118
|
-
* succeed). `requestId` is the original request id so support can
|
|
119
|
-
* trace the bad envelope back.
|
|
120
|
-
*/
|
|
121
|
-
export declare function assertContextIntegrity(ctx: CliFailureContext, requestId: string, opts?: AssertContextIntegrityOptions): void;
|
|
122
|
-
/**
|
|
123
|
-
* Apply the `--failed-only` filter — drop neighbor steps and their
|
|
124
|
-
* evidence, keep the failed step. Idempotent: returns `ctx` unchanged
|
|
125
|
-
* when `failedStepIndex` is null (no step-level diagnosis to filter)
|
|
126
|
-
* or when the existing window already matches.
|
|
127
|
-
*/
|
|
128
|
-
export declare function applyFailedOnly(ctx: CliFailureContext): CliFailureContext;
|
|
129
|
-
/**
|
|
130
|
-
* Resolve the user-supplied `--out` path into an absolute directory.
|
|
131
|
-
* Empty strings are rejected with `VALIDATION_ERROR` for consistency
|
|
132
|
-
* with `test code get --out`. We do NOT pre-create the directory or
|
|
133
|
-
* its `.tmp` child — `writeBundle` mkdir's after the integrity check
|
|
134
|
-
* passes so a forged response never modifies the operator's filesystem.
|
|
135
|
-
*/
|
|
136
|
-
export declare function resolveBundleDir(rawPath: string): string;
|
|
137
|
-
/**
|
|
138
|
-
* Pick a code-file extension for `<dir>/code.<ext>` based on the §6.3
|
|
139
|
-
* `language` + `framework`. The extension matches the test code's
|
|
140
|
-
* language, not the user-app code under test.
|
|
141
|
-
*/
|
|
142
|
-
export declare function pickCodeExtension(language: string, framework: string): string;
|
|
143
|
-
/**
|
|
144
|
-
* Pick the on-disk extension for `<dir>/video.<ext>` from the actual
|
|
145
|
-
* `result.videoUrl`, instead of hardcoding `mp4` (the
|
|
146
|
-
* recording is sometimes a `.webm` container; saving it under a `video.mp4`
|
|
147
|
-
* name misleads strict-extension consumers). Falls back to `mp4` when the
|
|
148
|
-
* URL is malformed or its extension isn't a recognized container, so a
|
|
149
|
-
* response-controlled field can never smuggle an arbitrary suffix onto disk.
|
|
150
|
-
*/
|
|
151
|
-
export declare function pickVideoExtension(url: string): string;
|
|
152
|
-
/**
|
|
153
|
-
* Step filename per §7.2 — 1-based index, zero-padded to two digits
|
|
154
|
-
* for indices ≤ 99, three digits for ≥ 100. `${stepIndex}-snapshot.html`
|
|
155
|
-
* etc. Never truncates: an agent constructing the path with
|
|
156
|
-
* `padStart(2, '0')` works for the common case, and step ≥ 100 widens
|
|
157
|
-
* naturally without breaking existing fixtures.
|
|
158
|
-
*/
|
|
159
|
-
export declare function stepFilenamePrefix(stepIndex: number): string;
|
|
160
|
-
/**
|
|
161
|
-
* Refuse a composed artifact path that escapes `baseDir`. Step filenames are
|
|
162
|
-
* built from response-controlled fields, so this is the final containment
|
|
163
|
-
* check before any write. Returns the validated absolute path.
|
|
164
|
-
*/
|
|
165
|
-
export declare function assertNoEscape(baseDir: string, segment: string): string;
|
|
166
|
-
/**
|
|
167
|
-
* Build the §7.1 meta.json given a context. Pure function, no I/O —
|
|
168
|
-
* lets specs assert the meta shape without touching disk.
|
|
169
|
-
*/
|
|
170
|
-
export declare function buildMeta(ctx: CliFailureContext, fetchedAt?: Date): BundleMeta;
|
|
171
|
-
/**
|
|
172
|
-
* Top-level bundle writer. The order matters:
|
|
173
|
-
*
|
|
174
|
-
* 1. `assertContextIntegrity` — fail closed on a forged envelope.
|
|
175
|
-
* 2. `applyFailedOnly` — narrow before download (saves bytes).
|
|
176
|
-
* 3. `mkdir <dir>/.tmp/` — fresh; clean any stale temp.
|
|
177
|
-
* 4. `writeFile result.json / failure.json / code.<ext>` — local data.
|
|
178
|
-
* 5. `fetch + stream` for `video.<ext>` (when set; extension matches the
|
|
179
|
-
* actual recording container) and per-step snapshot/screenshot/
|
|
180
|
-
* evidence-json files.
|
|
181
|
-
* 6. `writeFile meta.json` LAST — its presence means "bundle complete".
|
|
182
|
-
* 7. `rename .tmp/<file> -> <file>` for every file. Last rename
|
|
183
|
-
* makes meta.json visible.
|
|
184
|
-
*
|
|
185
|
-
* On any failure between (3) and (6), write a `<dir>/.partial` marker
|
|
186
|
-
* and re-throw so `index.ts` produces a typed exit code (UNAVAILABLE
|
|
187
|
-
* → 10 by default; the original ApiError is preserved when applicable).
|
|
188
|
-
*/
|
|
189
|
-
export declare function writeBundle(ctx: CliFailureContext, options: WriteBundleOptions): Promise<WriteBundleResult>;
|
|
190
|
-
/**
|
|
191
|
-
* Whether a top-level directory entry belongs to the bundle format —
|
|
192
|
-
* i.e. something a prior `writeBundle` could have produced and this
|
|
193
|
-
* commit is therefore allowed to clean up. `code.<ext>` and `video.<ext>`
|
|
194
|
-
* are matched by pattern (not the current run's extension) so a stale
|
|
195
|
-
* `code.py` or `video.webm` is still swept when the new bundle writes
|
|
196
|
-
* `code.ts` / `video.mp4` (or no video at all). Everything else in the
|
|
197
|
-
* directory is the user's and must never be deleted (`--out` can point at
|
|
198
|
-
* a pre-existing, populated directory).
|
|
199
|
-
*/
|
|
200
|
-
export declare function isBundleOwnedEntry(entry: string): boolean;
|
|
201
|
-
/**
|
|
202
|
-
* Atomically install the complete bundle staged in `tmpDir` into `dir`.
|
|
203
|
-
*
|
|
204
|
-
* Compatible with the #162 data-loss guard: only `isBundleOwnedEntry`
|
|
205
|
-
* names are moved aside or replaced — foreign files in `--out` survive.
|
|
206
|
-
*
|
|
207
|
-
* Re-commit safety: bundle-owned entries are renamed to a sibling
|
|
208
|
-
* aside directory before the new artifacts land. The prior `meta.json`
|
|
209
|
-
* is moved aside first (§3/§7.3 — no meta ⇒ refuse to consume) so a
|
|
210
|
-
* concurrent reader never sees meta pointing at steps already gone.
|
|
211
|
-
* The new `meta.json` is installed last. On failure, aside entries are
|
|
212
|
-
* restored so a failed re-commit never leaves the directory unusable.
|
|
213
|
-
*/
|
|
214
|
-
export declare function commitBundle(tmpDir: string, dir: string, files: ReadonlyArray<string>): Promise<void>;
|
|
215
|
-
/**
|
|
216
|
-
* Stream a presigned URL into a file with bounded retry on transport
|
|
217
|
-
* failures. 4xx (presigned URL expired or unauthorized) is NOT
|
|
218
|
-
* retried — the URL won't recover on its own; an upstream re-fetch
|
|
219
|
-
* is the only fix. Maps to `UNAVAILABLE` so `index.ts` exits 10.
|
|
220
|
-
*
|
|
221
|
-
* Streaming uses `pipeline` to honor backpressure: a slow disk pauses
|
|
222
|
-
* the upstream reader rather than buffering chunks in V8 heap. This
|
|
223
|
-
* matters for video files (multi-MB) and for very large HTML
|
|
224
|
-
* snapshots.
|
|
225
|
-
*
|
|
226
|
-
* Transport failures (network reset, DNS blip, mid-stream EOF) are
|
|
227
|
-
* retried up to STREAM_URL_MAX_RETRIES times with a fixed delay.
|
|
228
|
-
* Presigned URLs are valid for 15 minutes, so retries are safe.
|
|
229
|
-
*/
|
|
230
|
-
export declare function streamUrlToFile(url: string, filePath: string, fetchImpl: FetchImpl, deps?: {
|
|
231
|
-
sleep?: (ms: number) => Promise<void>;
|
|
232
|
-
shutdownSignal?: AbortSignal;
|
|
233
|
-
shutdown?: Pick<ShutdownHandle, 'runCriticalOperation'>;
|
|
234
|
-
}): Promise<void>;
|