/** * console-chunk — pure renderers for the "what happened since you last looked" block * that rides on every tool response, and for the freshness/ownership lines derived from * the worker's status. * * Why: the agent used to see only two booleans (testRunning, pendingMaintenance) plus a * rolling log it had to pull explicitly, with one server-side cursor shared by everyone. * A maintenance dialog opened in the human's terminal left no trace; a run that finished * an hour ago looked the same as one that finished a second ago; and an old "About to show * maintenance prompt" line read as "stuck". Now the worker journals lifecycle EVENTS into * the same chronological stream as the console, and this module renders the unseen part * of that stream — in order, capped, with an explicit continuation — so nothing is * skipped and nothing old is presented as current. * * No I/O here: everything takes plain data so it can be unit-tested. */ export interface LogEntry { index: number; timestamp?: string; level: string; message: string; event?: HealixEvent; } export interface HealixEvent { seq?: number; type: string; at?: string; driver?: 'api' | 'terminal'; kind?: string; name?: string; scope?: 'explicit' | 'implicit'; result?: string; durationMs?: number; error?: string; waitingOn?: 'agent' | 'terminal'; blocking?: boolean; message?: string; answer?: string; decision?: string; variableName?: string; platform?: string; jsonPath?: string; incidentId?: string; testName?: string; } export interface StatusLike { sessionActive?: boolean; testRunning?: boolean; suite?: string | null; passed?: number; failed?: number; notRun?: number; serverTime?: string; driver?: 'agent' | 'terminal'; currentActivity?: { kind: string; name: string; startedAt: string; driver?: string; scope?: string; } | null; waitingForHuman?: { prompt: string; message?: string | null; since: string; blocking: boolean; variableName?: string; } | null; lastEvent?: { seq: number; type: string; at: string; } | null; pendingMaintenance?: PausedLike | null; } /** The pause fields the agent is told about (source/optional come from wdio-healix-service 0.53+). */ export interface PausedLike { variableName?: string; testName?: string; pausedAt?: string; /** The project line the run is paused on. */ source?: { file?: string; line?: number; code?: string; } | null; /** Why that line tolerates a miss (e.g. marked FailureHandling.OPTIONAL); null when it does not. */ optional?: string | null; } /** "Paused at file:line `code`" — empty when the worker did not say (older workers). */ export declare function pausedLineText(pm: PausedLike): string; /** What to do about the pause: an optional line is skipped; anything else is diagnosed first. */ export declare function pausedNextText(pm: PausedLike): string; export interface ChunkOptions { /** Max rendered lines (default 150). */ maxLines?: number; /** Max rendered bytes (default 10 000). */ maxBytes?: number; /** Drop pure WDIO/Mocha framework noise (default true). Needed for terminal-driven * sessions, whose buffer is unfiltered (the worker only filters under HEALIX_AGENT). */ hideNoise?: boolean; /** Max chars per message (default 500). */ maxMessageChars?: number; } export interface ChunkResult { /** Markdown block, or '' when there is nothing to show. */ text: string; /** Index of the last entry actually rendered — the caller advances its cursor to this + 1. */ lastShownIndex: number | null; shown: number; hidden: number; omitted: number; /** Where to continue when `omitted > 0`. */ resumeFrom: number | null; } /** Same list the worker applies in agent mode (HealixApiServer.interceptConsoleLogs). */ export declare const NOISE: RegExp[]; export declare function fmtAge(fromIso: string | undefined, nowMs: number): string; /** One line per lifecycle event. */ export declare function fmtEvent(ev: HealixEvent): string; /** * Render the unseen console entries, chronologically, capped. The caller must advance its * cursor ONLY to `lastShownIndex + 1` — never past what the agent actually saw. */ export declare function renderConsoleChunk(entries: LogEntry[], opts?: ChunkOptions): ChunkResult; /** "▶ hook "before" running 3m12s (driver: terminal)" / "⏸ Paused …" / "✓ Idle — …". */ export declare function renderActivityLine(status: StatusLike, nowMs: number): string; /** The human-terminal warning, or null when no BLOCKING prompt is open. */ export declare function renderWaitingForHuman(status: StatusLike, nowMs: number): string | null; export interface RunSentinel { kind: 'test' | 'hook' | 'runall'; name: string; } /** Does this event end the wait for the given run? */ export declare function isRunTerminalEvent(ev: HealixEvent | undefined, sentinel: RunSentinel): boolean; /** Types worth subscribing to for a run wait (server-side filter for until=event). */ export declare function runTerminalTypes(sentinel: RunSentinel): string[];