/** * Parser for Claude CLI stream-json thread logs (newline-delimited JSON). * * The agent's stdout is captured as one JSON event per line. This turns that * raw event stream into readable, condensed "turns" for display over Telegram. * A turn is one assistant message (its text + any tool calls) together with the * tool results that immediately follow it. * * Assistant text is shown in full; tool inputs and tool results are previewed * (collapsed to a single line and capped) because they are machine output, not * the agent's reasoning, and would otherwise drown the useful signal. * * Each entry is prefixed with the wall-clock time of the event it came from, so * the reader can tell when a step ran and how long the next one waited. */ export interface LogTurn { /** Rendered lines for this turn, in display order. */ lines: string[]; } export declare const DEFAULT_PREVIEW_CHARS = 300; /** * Parse a raw stream-json log into chronological turns. Malformed lines and * noise events (system, rate_limit_event) are skipped. */ export declare function parseClaudeStreamLog(raw: string, previewChars?: number): LogTurn[]; /** * Extract the agent's most recent assistant TEXT from a raw stream-json log. * * Walks the stream-json events and returns the concatenated text blocks of the * last `assistant` message that carried any non-empty text. tool_use-only * assistant messages are ignored (they carry no operator-visible prose). * * Returns an empty string when the log has no assistant text at all โ€” the * caller (auto-forward) treats that as "nothing to forward". */ export declare function extractLastAssistantText(raw: string): string; /** * Render turns to a single string. With tailFirst (default) the most recent * turn appears first, so a reader paging from the top sees latest activity. */ export declare function renderThreadLog(turns: LogTurn[], tailFirst?: boolean): string; /** Default character window per page โ€” matches Telegram's ~4096-char message cap. */ export declare const DEFAULT_LOG_PAGE_CHARS = 4000; export interface LogPage { /** The character window for this page. */ text: string; /** Start index of this page within the rendered log. */ offset: number; /** Start index of the next page (feeds a "next chunk" button). */ nextOffset: number; /** Whether more text remains after this page. */ hasMore: boolean; /** Total length of the rendered log. */ totalLength: number; } /** * Extract a single character window from a rendered log for paginated display. * * The digest uses astral emoji markers (๐Ÿค–๐Ÿ”งโœ…โ€ฆ), so a naive .slice() could cut * between the two UTF-16 code units of a surrogate pair and emit a lone * surrogate that renders as ๏ฟฝ. When the window would end mid-pair we snap the * end back one unit; that code unit becomes the start of the next page. */ export declare function sliceLogWindow(rendered: string, offsetRaw: number, limitRaw: number): LogPage; //# sourceMappingURL=log-parser.d.ts.map