import type { ChainProgress } from "./types"; // Stan progress lines for a single chain look like: // "Iteration: 800 / 2000 [ 40%] (Warmup)" export const parseProgress = (msg: string): ChainProgress | undefined => { if (!msg.startsWith("Iteration:")) return undefined; const cleaned = msg.replace(/\[|\]/g, ""); const parts = cleaned.split(/\s+/); const iteration = parseInt(parts[1]); const totalIterations = parseInt(parts[3]); const warmup = parts[5] === "(Warmup)"; if (isNaN(iteration) || isNaN(totalIterations)) return undefined; return { iteration, totalIterations, warmup }; };