// The frame scan's shapes (release 30, lane P): a stream sampled into frames, // each kept frame read by a vision model through a PROFILE (poker first), the // readings and the transcript's spoken numbers turned into series, events and // segments by pure code. Pure: types and small helpers only. /** One sampled frame in the cache. `t` is the SOURCE second (the grid time). */ export type FrameRef = { t: number; // The JPEG's basename in the cache dir. file: string; // dHash of the frame's grey thumbnail (hex). hash: string; }; /** A cue, as `transcript.cues.json` holds it. */ export type Cue = { start: number; end: number; text: string }; /** A number the streamer SAID, read out of the cues by pure code. */ export type SpokenReading = { t: number; field: string; value: number; // The cue's words (trimmed), so a reader can see why. text: string; // Scaled by a rule (a stack said without "thousand" beside an average said with it). approx?: boolean; }; /** A series point: [t, value], or [t, value, "spoken"] when a spoken number filled it. */ export type SeriesPoint = [number, number] | [number, number, "spoken"]; export type DerivedEvent = { t: number; kind: string; detail: string; // Where it came from: the model's reading of a frame, the series, the // client's log as a frame showed it, or the transcript. source: "frame" | "series" | "log" | "spoken"; tournament?: string; // Release 31 (lane P3): the named rule that made the event, what it read // (the evidence: numbers and the line as shown), and whether a second // reading backs it ("confirmed") or it rests on one ("unconfirmed"). A // flagged reading still makes no event at all. rule?: string; evidence?: Record; confidence?: "confirmed" | "unconfirmed"; }; export type DerivedSegment = { from: number; to: number; phase: string; tournament?: string }; /** A frame reading and a spoken number that disagree (never silently trusted). */ export type DerivedFlag = { t: number; field: string; spoken: number; frame: number; frameT: number; tournament?: string }; export type DerivedTournament = { key: string; name?: string; from: number; to: number; series: Record; // The last values seen: buy-in, prize, field size. facts: Record; }; export type Derived = { tournaments: DerivedTournament[]; events: DerivedEvent[]; segments: DerivedSegment[]; flags: DerivedFlag[]; // Readings the smoothing set aside as misreads, by field. misreads: { t: number; field: string; value: number }[]; }; /** A profile: what a frame is read for, and how readings become a timeline. */ export type FrameProfile = { id: string; // Bumped whenever the prompt or the schema changes. promptVersion: number; // The width frames are scaled to before a model reads them. width: number; // dHash bits two frames may differ by and still be one picture. dupMaxBits: number; // A duplicate run is read again every this many frames (a number on a // static screen can change too small for the hash to see). rereadEvery: number; // Frames per ask on the API and on a local model. framesPerAsk: { api: number; local: number }; system(hints: { hero?: string }): string; user(frames: { t: number }[]): string; // The answer's schema for an ask of `n` frames: `{ frames: [reading…] }`. schema(n: number): object; // A model's reading cleaned to the profile's shape; null when it is not one. coerce(raw: unknown): R | null; spoken(cues: Cue[]): SpokenReading[]; derive(readings: (R & { t: number })[], spoken: SpokenReading[], o: { everySeconds: number; durationSeconds?: number; hero?: string }): Derived; }; export const FRAME_SCAN_FORMAT = "archilyzer-frame-scan"; /** "1:02:03" / "4:05". */ export function clock(t: number): string { const s = Math.max(0, Math.round(t)); const h = Math.floor(s / 3600); const m = Math.floor((s % 3600) / 60); const sec = s % 60; return h > 0 ? `${h}:${String(m).padStart(2, "0")}:${String(sec).padStart(2, "0")}` : `${m}:${String(sec).padStart(2, "0")}`; } /** 12400 → "12,400"; 1.5 → "1.5". */ export function fmtNum(v: number): string { return Number.isInteger(v) ? v.toLocaleString("en-US") : String(Math.round(v * 10) / 10); }