import { EventEmitter } from 'node:events'; import type { NormalizedEvent } from '../normalize/event-types.js'; /** * Pure stateful translator. One instance per Claude session. Holds: * - `seenMsgIds`: msg.id dedup set (one Claude API message may produce multiple jsonl entries) * - `currentTurnUsages`: per-message usage accumulator, summed at turn boundary * - `turnCount`: number of distinct messages so far in the current turn * * Reset implicitly happens when a `system/turn_duration` event is consumed. * * @see DR-0012 §3.4 — cost reconstructed from per-message usage; per-message dedup avoids double-counting. */ export declare class JsonlEventNormalizer { private seenMsgIds; private currentTurnUsages; private turnCount; consume(raw: any): NormalizedEvent[]; private handleAssistant; private handleUser; private handleTurnDuration; /** Reset all state (typically called when starting a fresh session, not between turns). */ reset(): void; } export interface JsonlTailOptions { /** Read pre-existing content when start() is called. Default false (skip to end-of-file). */ fromStart?: boolean; /** @deprecated No longer used. start() is non-blocking and never rejects on a missing file — * the tail polls until the file appears. Kept for backward-compatible construction. */ waitForFileMs?: number; /** Poll interval for file size changes, in ms. Default 200. fs.watch is not used because it's * unreliable on some filesystems; polling is universal and the throughput here is low. */ pollIntervalMs?: number; } type JsonlTailEvents = { /** Raw parsed JSON object from one jsonl line. Emitted for EVERY line including unparseable ones (with type='_parse_error'). */ event: (raw: any) => void; /** Emitted when a `system/turn_duration` event is observed. Convenience signal for turn boundary. */ 'turn-end': (raw: { durationMs?: number; messageCount?: number; }) => void; error: (err: Error) => void; }; /** * Tails a Claude session jsonl file by polling its size and reading appended bytes. Buffers across * partial-line writes. Stops on `stop()`. * * @see DR-0012 §3.2 — feeds JsonlEventNormalizer in the TUI adapter. */ export declare class JsonlTail extends EventEmitter { private readonly filePath; private offset; private buffer; private pollTimer; private stopped; private readonly waitForFileMs; private readonly pollIntervalMs; private readonly fromStart; constructor(filePath: string, opts?: JsonlTailOptions); on(event: K, listener: JsonlTailEvents[K]): this; start(): Promise; stop(): Promise; private schedulePoll; private readNewBytes; private drainBuffer; private dispatchLine; } export {};