import { type HelperTimeoutState } from './browser/launch'; /** The query parameter that boots a world for baking. `=1` and nothing else. */ export declare const BAKE_PARAM = "helixBake"; /** The artifact the bake writes, next to the visual contract it is pointed at from. */ export declare const BAKE_ARTIFACT_FILE = "helix.visuals.bake.json"; /** K sun keys for a CYCLING sun, the driver's own default. Below 2 the planner cannot place both horizon keys. */ export declare const DEFAULT_BAKE_KEYS = 9; /** Boot budget FLOOR. SwiftShader boots a world minutes slower than a real GPU, so this is seconds-times-hundreds. */ export declare const DEFAULT_BAKE_BOOT_TIMEOUT_S = 300; /** How much boot budget a megabyte of bundle buys itself — SwiftShader decodes, uploads and compiles it all. */ export declare const BOOT_SECONDS_PER_MIB = 20; export type BakePhase = 'idle' | 'warm-up' | 'relocate' | 'audit' | 'key' | 'practicals' | 'geometry' | 'done' | 'failed'; export type BakeProgress = { phase: BakePhase; done: number; total: number; }; export type BakeKeyTiming = { hours: number; elevationDeg: number; azimuthDeg: number; ms: number; bakeMs: number; }; export type BakeAuditSummary = { probes: number; flagged: number; counts: Record; blockedEdges: number; leakingEdges: number; ms: number; }; export type BakeRepairSummary = { damaged: number; substituted: number; leftDark: number; donorPool: number; occludedCandidates: number; maxDonorGridDistance: number; /** THE TRIPWIRE: a donated probe whose donor it cannot see is a cross-zone light teleport. MUST read 0. */ donorsOccluded: number; ms: number; }; /** Whether the probe volume fits the space the world is played in — a PLACEMENT verdict, not a bake defect. */ export type BakeVolumeFitSummary = { layers: number; /** Probe layers carrying at least `litShare` of the strongest layer's energy. */ litLayers: number; litShare: number; /** Total DC irradiance per Y layer, bottom first. */ layerEnergy: number[]; /** False = most of the box baked darkness or open sky. */ fits: boolean; }; export type BakeSummary = { keys: number; probes: number; totalMs: number; warmUpMs: number; perKey: BakeKeyTiming[]; practicalsMs: number; geometryMs: number; auditKey: number; audit: BakeAuditSummary; repair: BakeRepairSummary; /** OPTIONAL against the ENGINE, not against the contract: a world bundles its own @helix/visual, so a build * made before the volume-fit verdict existed reports no `volumeFit` at all and simply gets no warning. */ volumeFit?: BakeVolumeFitSummary; /** True when the world's sun does not move (`timeOfDay.cycleSeconds: 0`), which is what makes ONE key correct. * OPTIONAL like volumeFit: a world bundling an older @helix/visual reports none, and the label is dropped. */ staticSun?: boolean; /** Radiance passes each key was captured with — the authored `probes.bounces`, 1 being the direct pass alone. * OPTIONAL like volumeFit. */ bounces?: number; /** 3D-texture slices this field's atlas asks for. Probes enter it linearly, so a budget that clears the 2048 * desktop limit can still fail to allocate on a phone, where GLES3 only guarantees 256. OPTIONAL like volumeFit. */ atlasDepth?: number; /** The relocation pre-pass, before the first key: probes moved out through the nearest backface, probes still * over the gate after the clamp (the de-ghost's candidates), and its wall time. OPTIONAL like volumeFit. */ relocated?: number; stillBuried?: number; /** Relocation pushes REFUSED because the destination left the volume box. OPTIONAL like volumeFit. */ rejectedOutsideBox?: number; relocationMs?: number; repairs: number; /** Probes DEACTIVATED: buried with no visible donor, so their SH ships zeroed and their validity flag tells the * sampler to weight them at nothing. OPTIONAL like volumeFit. */ inactive?: number; volume: { probes: [number, number, number]; size: [number, number, number]; center: [number, number, number]; }; /** False when the tier ran without DDGI visibility — the artifact then ships SH only. */ geometry: boolean; fieldBytes: number; geometryBytes: number; /** The baked per-probe occlusion volume (visual >= 0.1.1). OPTIONAL like volumeFit: a world bundling an older * @helix/visual reports none. */ occlusionVoxels?: number; /** Voxels sealed inside geometry that the validity dilation filled from a face neighbour. OPTIONAL like volumeFit. */ occlusionDilated?: number; occlusionBytes?: number; occlusionMs?: number; }; /** Where the bake serves from and which roots take the artifact + the pointer. */ export type BakeTargets = { /** The built bundle the browser loads. */ servedDir: string; /** The world roots written to: the source `public/` (when it exists) and the built bundle root. */ roots: string[]; }; export type BakeWrite = { path: string; kind: 'artifact' | 'contract' | 'removed'; bytes: number; /** True when the file did not exist and this run created it. */ created: boolean; }; export type BakeLightingOptions = { directory: string; /** An EXPLICIT key count. Omitted, the engine plans them off the world's own sun. */ keys?: number | undefined; /** Boot budget in ms — the wait for `window.__helixBake`, NOT a cap on the bake itself. */ timeoutMs?: number | undefined; /** Bake through a system browser on the real GPU instead of the bundled SwiftShader build. */ gpu?: boolean | undefined; /** Write the PACKED field (HXB1: float16, coarse level first, content-addressed, a phone tier) and a version 2 * pointer instead of the JSON store. Plays only on a visual runtime that reads version 2 — see PACKED_NOTE. */ packed?: boolean | undefined; onProgress?: ((message: string) => void) | undefined; }; export type BakeLightingResult = { summary: BakeSummary; written: BakeWrite[]; /** Present on a `--packed` run: the byte numbers worth printing. */ packedReport?: PackedReport | undefined; servedDir: string; /** THE RECEIPT: which GL renderer actually baked this — the only proof `--gpu` reached hardware. */ renderer: string | null; }; export type PackedReport = { bakeId: string; fieldBytes: number; firstPlayableBytes: number; geometryBytes: number; lowBytes: number; lowIsField: boolean; lowProbes: number; jsonBytes: number; }; /** What a `--packed` bake needs from the runtime that will play it — printed with the result. */ export declare const PACKED_NOTE: string; /** * Which bundle is served and which roots are written. Mirrors the convention `helix validate` reads the visual * contract under: the built bundle serves it from the ROOT, a source tree keeps it in `public/` — so both copies * are patched, leaving the just-baked build publishable and the next build carrying the same pointer. */ export declare function resolveBakeTargets(directory: string): BakeTargets; /** Every byte the browser may have to fetch, decode and upload before the handle appears. */ export declare function measureBundleBytes(dir: string): number; /** * The boot budget, in seconds, for a bundle of this size. A fixed deadline is wrong in both directions — * SwiftShader spends minutes on a heavy world's first frame, and a 45 MiB one blew a 300 s budget outright — so * the wait scales with what the browser has to chew through, never dropping below the floor. */ export declare function bootTimeoutForBundle(bundleBytes: number): number; /** * The contract patch: `mode: "baked"` plus the artifact pointer, every other key carried verbatim and in place. * `null` text creates the minimal v1 document — a world may declare no visual contract at all until it is baked. * `keys` records how many sun keys the field actually holds; omitted, the pointer keeps its older two-field shape. */ export declare function patchVisualsConfigText(text: string | null, artifact?: string, keys?: number): string; /** * The PACKED contract patch: `mode: "baked"` plus the version 2 pointer, every other key carried verbatim and in place. * `geometry` and `low` are omitted when the bake shipped none; `low` names the field file itself when that file is already * inside the phone budget. */ export declare function patchVisualsConfigPackedText(text: string | null, pointer: { artifact: string; bakeId: string; geometry?: string | undefined; low?: string | undefined; keys?: number | undefined; }): string; /** * THE GATE. A donated probe whose donor it cannot see is light teleported across a wall, so the artifact is * refused rather than written: the run is sound only while this reads 0. Null when the field is clean. */ export declare function bakeGateFailure(summary: BakeSummary): string | null; export declare function formatDuration(ms: number): string; export declare function formatBakeProgress(progress: BakeProgress, elapsedMs: number): string; /** The compact end-of-run report: what was baked, what it cost, what the audit found, and what landed on disk. */ export declare function formatBakeSummary(summary: BakeSummary, written: readonly BakeWrite[]): string[]; /** The delivery numbers of a `--packed` run, against the JSON store the same bake would have written. */ export declare function formatPackedReport(report: PackedReport): string[]; /** Page errors FIRST — a VisualInvariantError name is the diagnosis, and the reason below it is the consequence. */ export declare function composeBakeFailure(reason: string, errors: readonly string[]): string; export declare function composeBakeTimeoutDiagnosis(state: HelperTimeoutState, errors: string[]): string; /** * Serve, boot, bake, gate, write. The bake itself is MINUTES of blocking GPU work inside one `page.evaluate`, * which Playwright does not time out; `--timeout` bounds only the wait for the handle. */ export declare function bakeLighting(opts: BakeLightingOptions): Promise;