import type { DashboardSnapshot } from './render.js'; /** * ccx's state, for something other than a terminal to read. * * The dashboard's snapshot is already a render-agnostic view of everything ccx * knows, so this is that same snapshot in a shape a program can depend on * rather than a shape a terminal can paint. Built the same way the live screen is, * which is the point: a second surface deciding these things for itself would * drift from the first, and it would drift on exactly the thing that matters, * which account can be used right now. Each call is still a snapshot of its * own moment; what is shared is the rules, not the reading. * * The derived status travels WITH the numbers on purpose. A consumer that * re-derived "is this account usable" from the raw windows would be * reimplementing a rule that has already been got wrong once in this codebase: * the table said `ready` beside a window reading 100% while rotation refused * to touch that account. Ship the answer, not just the inputs. */ /** Bump when a field changes meaning or leaves. Additions do not need it. */ export declare const STATE_SCHEMA_VERSION = 1; export interface StateAccount { name: string; email?: string; plan?: string; loggedIn: boolean; enabled: boolean; active: boolean; priority: number; /** Epoch ms ccx recorded this account as capped until, if it did. */ cappedUntil?: number; usage?: DashboardSnapshot['accounts'][number]['usage']; status: { /** ready | blocked | disabled | logged-out */ state: string; /** What is being named: a model, `5h`, `week`, `capped`. Null when ready. */ label: string | null; /** Epoch ms it can be used again, when that is known. */ until: number | null; /** Everything blocking it, not only the one named. */ blockedBy: Array<{ label: string; until?: number | null; }>; }; } export interface StatePayload { schemaVersion: number; /** Which ccx produced this, so a reader can tell old data from new. */ ccxVersion?: string; /** When it was taken. Every `until` is an absolute epoch ms against this. */ now: number; /** The account ccx would use, and the model it prefers. */ active: string | null; preferredModel: string | null; /** Where rotation goes next, in words. Null when nothing pins a model. */ nextUp: string | null; accounts: StateAccount[]; /** Recent activity, newest last, already formatted for reading. */ events: string[]; } /** Turn the dashboard's snapshot into the published shape. */ export declare function toStatePayload(snapshot: DashboardSnapshot): StatePayload;