import { type Json, type PreviewGlb } from '../visualQa/vehiclePreview'; export declare const WHEEL_SLOT_TYPES: ReadonlySet; /** How the part's placement is judged. */ export type AddOnKind = /** A wheel / tyre set: one copy per corner, centred on each hub. */ 'wheel' /** `authoringFrame: "socket"` — centred on its mount socket. */ | 'socket' /** `authoringFrame: "host"` — vertices already in the host model's coordinates; must land where authored, inside the car, not at its origin. */ | 'host' /** No geometry is drawn (a tune-only slot, or no GLB): the judgement is that its ops changed the composed tuning. */ | 'tune' /** A part with a GLB that declares no frame (the runtime cannot place it): reported, judged as failed. */ | 'unframed'; export interface PreviewAddOn { /** The directory it was read from. */ dir: string; title: string; /** A stable synthetic item id (the preview mints nothing; this only names the fitted row). */ itemId: string; slotType: string; fits: Json; ops: Json[]; kind: AddOnKind; glb?: PreviewGlb; frame?: Json; /** The authored mesh bounds (the GLB's own vertex AABB, before any placement). */ authoredBox?: { min: number[]; max: number[]; }; } export declare class PreviewAddOnError extends Error { } /** Classify an add-on from its slot type, whether it ships geometry, and its declared mesh frame. Pure. */ export declare function classifyAddOn(slotType: string, hasGlb: boolean, frame: Json | undefined): AddOnKind; /** Read one add-on directory (`addon.json` + optional `model.glb`) into what the preview needs. Throws PreviewAddOnError. */ export declare function loadPreviewAddOn(dirArg: string): PreviewAddOn; export declare function loadPreviewAddOns(dirs: readonly string[]): PreviewAddOn[]; /** The visual ops the runtime draws (what the backend keeps in `visibleAddOns[].visualOps`): hide, material patches, presentation mounts. */ export declare function visualOpsOf(ops: readonly unknown[]): unknown[]; export interface RuntimeSlot { id: string; rowId?: string; type: string; fill?: 'all' | 'each'; siblings?: string[]; parentSlotId?: string; depth?: number; socket?: { prefer?: string[]; accepts?: string[]; }; } /** * The slot an add-on takes: the first open slot of its type on the host's board, in id order, skipping ones an earlier add-on of * this fit already took. A fill-all slot (wheels) is addressed by its primary sibling, the way the backend freezes it. */ export declare function pickSlot(slots: readonly RuntimeSlot[], slotType: string, taken: ReadonlySet): { slotId: string; slot: RuntimeSlot; } | { problem: string; }; export interface FittedRow { itemId: string; title: string; slotType: string; kind: AddOnKind; slotId: string; fill: 'all' | 'each' | null; mountSocket: string[]; modelUrl: string | null; finesse: string[]; } export interface ComposeInput { /** The proxy session's own `composition` (its frozen runtime recipe and appearance rows), as the backend sent it. */ original: Json; /** The identity of the package the runtime will be handed (the candidate's checksum, or the published car's own). */ identity: { format: unknown; revision: unknown; checksumSha256: string; }; addOns: readonly PreviewAddOn[]; /** Where each add-on's GLB is served (null for a tune-only add-on). */ modelUrlOf(addOn: PreviewAddOn): string | null; /** The candidate car is not published: its id is not on any add-on's `fits.only.items`, so the proxy's id is added to it. */ relaxOnlyItems: boolean; } export interface ComposeResult { composition: Json; fitted: FittedRow[]; compositionDigest: string; recipeDigest: string; } /** Canonical JSON (sorted keys, no whitespace): the bytes both the backend and the engine digest. */ export declare function canonicalJsonString(value: unknown): string; /** Re-derive a recipe's digest (sha256 of its canonical body) — the check the engine runs before it folds. */ export declare function recipeDigestOf(recipe: Json): string; /** * Build the session `composition` that fits `addOns` onto the host the proxy's session describes. Throws PreviewAddOnError. * Mirrors `buildVehicleRuntimeRecipe` + the trial response (helix-backend-api: add-ons/runtime-recipe.ts, * instant-worlds/services/instant-world-item-trial.service.ts) without calling them. */ export declare function composeFittedBuild(input: ComposeInput): ComposeResult; /** The content URL an add-on's GLB is served at (on the proxy's own CDN origin, like the candidate car's GLB). */ export declare function addOnModelUrl(cdnOrigin: string, addOn: PreviewAddOn): string | null; export type V3 = [number, number, number]; /** One attached copy of an add-on, as the page probe reads it (all positions in the car's body frame, metres). */ export interface AttachProbe { name: string; itemId: string; /** The host node the engine mounted it on (`socket:` anchor's name), if any. */ socketNode: string | null; socketPos: V3 | null; /** Centre of the drawn vertices' AABB, and the AABB itself. */ centre: V3 | null; min: V3 | null; max: V3 | null; triangles: number; meshes: number; } export interface AddOnProbe { attach: AttachProbe[]; /** Physics wheel hubs (the wheel node of each contact), body frame. */ hubs: Array<{ id: string; pos: V3; }>; /** Centre of the host's own `rim_*` nodes, body frame (what a socket-frame wheel is authored to replace). */ rimNodes: Array<{ name: string; pos: V3; }>; /** The car's own drawn bounds with every add-on excluded, body frame. */ carBounds: { min: V3; max: V3; } | null; /** Named host nodes the judgement needs (a host-framed part's bind root), body frame: origin and the node's 4x4 (column-major); null when absent. */ nodes?: Record; } export interface AddOnVerdict { id: string; pass: boolean; severity: 'block' | 'warn'; detail: string; measured?: Record; } /** Metres: a host-frame part's drawn centre must be at least this far from the vehicle's origins (the "drawn at the car's origin" bug). */ export declare const NOT_AT_ORIGIN_M = 0.15; /** Metres: a wheel's drawn centre must be this close to its hub on the two axes it does not turn about. */ export declare const WHEEL_HUB_TOLERANCE_M = 0.01; /** Metres a host-frame part may sit outside the stock car's bounds (a wing overhangs the body) before it is called outside. */ export declare const CAR_BOUNDS_MARGIN_M = 0.6; export interface JudgeOptions { toleranceCm?: number; tuning?: TuningJudgement | null; } export interface TuningJudgement { /** One row per `tune` op: where it points, what it should do, the stock value and the live value. */ ops: Array<{ opIndex: number; op: string; path: string; value: unknown; stock: number | null; live: number | null; expected: number | null; applied: boolean; why: string; }>; /** Leaves of the live tuning that differ from the stock car (path -> [stock, live]) — the evidence the fold changed anything. */ changed: Array<{ path: string; stock: unknown; live: unknown; }>; } /** The expected value of one tune op on a stock value. `mul` multiplies, `add` adds, `set` replaces; anything else is unknown. */ export declare function applyTuneOp(op: string, stock: number, value: number): number | null; /** * Judge the tune ops of an add-on against stock and live tuning leaves (flat dotted paths, arrays indexed). Pure. * Handles a scalar (`limiterRpm add 400`), a `contacts.*` path (every contact), an array (`gearbox.ratios mul 1.1`, every * element) and a curve (`torqueCurve add { points }` / `mul`: the live curve evaluated at the stock curve's rpm). When the * car runs the v2 driveline, the change must show there too. */ export declare function judgeTuneOps(addOn: PreviewAddOn, stock: Record, live: Record): TuningJudgement; /** * Judge one add-on's drawn geometry against its anchor. `attach` is the probe's rows for THIS add-on (matched by item id). * Every verdict id is `preview.addon..`, n the add-on's position in the command line. */ export declare function judgeAddOn(index: number, addOn: PreviewAddOn, probe: AddOnProbe, opts?: JudgeOptions): AddOnVerdict[];