/** * Service layer for `peaks log tail` and `peaks log ls` subcommands. * * commander layer in `src/cli/commands/log-commands.ts` wraps. * Separated from `logger.ts` so the surface is small + testable * without spinning up a Commander program. * * Both helpers default to the on-disk log dir (`resolveLogDir()`) * but accept an `dirOverride` so tests can pin the home to a * tempdir without monkey-patching `os.homedir()`. */ import { type LogEntry } from './logger.js'; /** * Return all `peaks-loop-*.log` files in the log dir, sorted by * date descending (newest first). Returns `[]` when the dir is * missing or unreadable. Non-matching entries (e.g. a stray * README) are filtered out. */ export declare function listLogFiles(opts?: { dirOverride?: string; }): string[]; export type TailLogOptions = { /** Number of trailing lines to return. Defaults to 50. */ lines?: number; /** Override the clock for deterministic tests. */ now?: () => Date; /** Override the log dir (used by tests). */ dirOverride?: string; /** Override the date (PRD AC2: PEAKS_LOG_DATE_OVERRIDE). */ dateOverride?: string; /** * only entries whose `batchId` field matches are returned (and * the trailing-window accounting respects the post-filter total * so a busy day does not push old matching entries out of view). */ batchId?: string; }; export type TailLogResult = { /** Absolute path to the file that was tailed, or null when no file exists. */ file: string | null; /** The trailing entries (already trimmed to `lines`). */ entries: LogEntry[]; /** The total number of entries in the file (for header messaging). */ total: number; /** When `batchId` filter is applied, the number of matches in the file. */ batchMatches?: number; }; /** * Read today's log file and return the last `lines` entries. When * no file exists for the given date, returns `{ file: null, entries: [], total: 0 }`. */ export declare function tailLog(opts?: TailLogOptions): TailLogResult;