import type { TreeNode } from "../types.js"; import type { Interval } from "./intervals.js"; import type { Round } from "./rounds.js"; export type Turn = { /** 0-based; screens print `index + 1`. */ index: number; /** When the turn began: the `turnStart` that brought the person's * message, or the trace start for work done before any message. */ start: number; /** When the next turn began, or the trace end. */ end: number; /** The last event of the turn's work; the wait for the person runs * from here to `end`. */ workEnd: number; /** The message that started the turn, when a `turnStart` carried one. */ userText: string | undefined; /** The calls that started in the turn. */ rounds: Round[]; }; /** A turn as the tally keeps it: where it began, how far its work reached, * how many LLM calls completed in it, and whether a `turnStart` opened it. */ type TalliedTurn = { start: number; workEnd: number; calls: number; message: string | undefined; fromMessage: boolean; }; /** A trace's turns, built one event at a time in time order. The runs * explorer feeds it while scanning a log; the viewer feeds it from the * forest. Both get the same split. */ export type TurnTally = { turns: TalliedTurn[]; }; export declare function emptyTally(): TurnTally; /** Feed one event. A `turnStart` opens a turn. Any other event extends the * current turn's work, unless it ends the run. Events before the first * `turnStart` are a turn of their own only when an LLM call completed * among them (a seeded prompt, a script that works and then chats); * otherwise they are startup, and the first turn begins at the first * message. */ export declare function tallyEvent(tally: TurnTally, type: string, at: number, message?: unknown): void; /** The run's wall time split into work and waits for the person. A trace * with fewer than two turns works to its end: the moments before its * `agentEnd` are shutdown, not a person being waited for. */ export declare function tallyTimes(tally: TurnTally, extent: Interval): { elapsedMs: number; workingMs: number; waitingMs: number; }; /** The session's turns, split at every `turnStart` event. A trace with no * `turnStart` is one turn. */ export declare function traceTurns(trace: TreeNode, rounds: Round[]): Turn[]; /** How long the turn worked, and how long it then waited for the person * (or, on the last turn, until the run ended). */ export declare function turnTimes(turn: Turn): { workingMs: number; waitingMs: number; }; /** The run's wall time split into work and waits, for the screens that * print a duration: the overview header, the trace picker, the explorer. */ export declare function traceTimes(trace: TreeNode): { elapsedMs: number; workingMs: number; waitingMs: number; }; export {};