/** * Per-failure artifact bundles. * * When a page fails, the crawler dumps a self-contained directory containing * the screenshot, HTML, error list, run metadata, and the trace up to and * including the failing page. A `repro.sh` script replays the trace so the * failure can be reproduced locally without re-running the full crawl. * * The bundle is designed to be attachable to a CI artefact, GitHub issue, * or chat message: a reviewer with the directory and a checkout of the * project should be able to step through the same sequence of actions. * * Pure helpers (`failureBundleKey`, `shouldSaveArtifacts`, `buildReproScript`) * are unit-testable without a browser. */ import { type TraceEntry } from "./trace.js"; import type { FailureArtifactsOptions, PageResult } from "./types.js"; /** * True when this page result should trigger a failure bundle. We bundle on * any of: navigation error, timeout, crashed page, an HTTP 4xx/5xx status, * or any collected PageError (console / exception / network / invariant). * * The HTTP-status check matters because the crawler hooks this *before* * the recovery branch flips a 404/5xx response from `status: "success"` * to `status: "recovered"`. Without the statusCode check a plain 404 page * with no JS errors would fall through and never get bundled. */ export declare function shouldSaveArtifacts(result: PageResult): boolean; /** * Stable, sortable directory name for a failure. The numeric prefix keeps * the directory listing in chronological order; the URL prefix gives a * human-readable hint; the FNV-1a suffix disambiguates routes that * sanitize to the same prefix (e.g. `/a/b` and `/a_b`). */ export declare function failureBundleKey(url: string, sequence: number): string; /** * Render a self-contained shell script that replays the bundled trace. * Kept intentionally minimal — power users will tweak it (different seed, * `--strict`, network throttling) but the default form gets you the same * navigation + actions back. */ export declare function buildReproScript(opts: { baseUrl: string; tracePath: string; }): string; /** Metadata written to `info.json`. Stable, machine-readable. */ export interface FailureBundleInfo { url: string; status: PageResult["status"]; statusCode?: number; loadTime: number; hasErrors: boolean; errorCount: number; warningCount: number; discoveryMethod?: PageResult["discoveryMethod"]; sourceUrl?: string; sourceElement?: string; recovery?: PageResult["recovery"]; baseUrl: string; seed: number; sequence: number; /** ISO timestamp when this bundle was created. */ createdAt: string; /** Whether each artefact was written. */ artifacts: { screenshot: boolean; html: boolean; trace: boolean; }; } export interface WriteFailureBundleArgs { options: FailureArtifactsOptions; baseUrl: string; seed: number; sequence: number; result: PageResult; /** PNG bytes of the page at failure time. */ screenshot?: Buffer; /** Page HTML at failure time. */ html?: string; /** Trace entries up to and including the failing page. */ trace?: readonly TraceEntry[]; /** Override `Date.now` for deterministic tests. */ now?: () => Date; } /** Write a failure bundle to disk. Returns the bundle directory path. */ export declare function writeFailureBundle(args: WriteFailureBundleArgs): string; //# sourceMappingURL=failure-artifacts.d.ts.map