import { type LiveSession, type LogDeps } from "../../cli/logsSession/target.js"; import { type TraceSummary } from "../../logsViewer/traceSummaries.js"; import type { TreeNode } from "../../logsViewer/types.js"; import { type TraceSelectionFlags } from "../../runDirectory/traceSelection.js"; import type { Trace } from "../../runDirectory/traces.js"; /** `outline` and `search` read the most recent trace when no flag picks. */ export declare const MOST_RECENT_ONLY = 1; export type QueryResult = { text: string; json: unknown; exitCode: number; }; /** One trace of an opened log: its root and its summary. The root is built * from the trace's own events, as `session show` builds it, so every * address a command prints is one `show` resolves. */ export type OpenedTrace = { traceId: string; root: TreeNode; summary: TraceSummary; }; /** The log a query reads, found by `chooseLog`. The first line of every * command's text names `logPath`. */ export type OpenedLog = { logPath: string; /** `logPath` relative to the current directory when it is inside it, * so `runs/today/statelog.jsonl` and `log.jsonl` read apart. */ shown: string; traces: OpenedTrace[]; }; export type QueryDeps = LogDeps & { /** The open viewers, probed as the session commands probe them, so a * query reads the log the one open viewer has. A query never talks to * the viewer itself. */ probe(): Promise; readLog(logPath: string): Trace[]; now(): number; }; export declare function openQueryLog(log: string | undefined, deps: QueryDeps): Promise; /** What a command works on once its log is open and its traces picked. */ export type PickedTraces = { log: OpenedLog; picked: OpenedTrace[]; older: number; }; /** * Open the log, pick the traces, and hand them to `body`; a refusal from * either step is the command's answer. `keep` narrows the traces before * picking (`traces --errors`), so `--last` counts only the kept ones. Every * command's selection goes through here. */ export declare function withPickedTraces(options: TraceSelectionFlags & { log?: string; }, pick: { defaultLast: number; keep?: (trace: OpenedTrace) => boolean; }, deps: QueryDeps, body: (picked: PickedTraces) => QueryResult): Promise; /** The line every command prints first: the log it read, then the rest. */ export declare function logLine(log: OpenedLog, rest: string): string; export declare function refusal(reason: string): QueryResult; /** `1 trace`, `3 traces`; `plural` for a phrase that does not take an s. */ export declare function countOf(count: number, singular: string, plural?: string): string; /** A trace's summary as JSON: times as ISO strings, absent facts as null. */ export declare function traceRecord(summary: TraceSummary): Record;