/** * Turn telemetry (TPS, TTFT, duration, tokens, stalls, cost rate) shown after each agent run. * * Adapted from pi-open-tui's telemetry.ts (MIT, Copyright (c) 2026 pi-open-tui contributors; * see THIRD_PARTY_NOTICES). Formatting changed to match chassis. */ import type { Theme } from "@earendil-works/pi-coding-agent"; /** Below this many output tokens the speed is mostly start-up time, so the line leaves it out. */ export declare const MIN_TPS_TOKENS = 20; export interface Telemetry { tps: number | null; ttftMs: number; totalMs: number; inputTokens: number; outputTokens: number; cacheReadTokens: number; stallMs: number; stallCount: number; /** What the run cost, summed over its turns; null when the provider reports no cost (free or unknown). */ costUsd: number | null; } export declare class TelemetryTracker { private turn; private agentStartMs; private turns; private readonly now; constructor(now?: () => number); /** Feed every relevant pi event; returns the run summary on agent_settled. */ handle(event: { type: string; [k: string]: any; }): Telemetry | undefined; private update; private endMessage; private endTurn; private endAgent; } /** * The telemetry line's icons, by name (icons.ts): a speedometer, a sand timer for the wait for the * first token, a clock and an alert. The plain set has none; the words beside them say it. */ export declare const TELEMETRY_ICONS: { readonly speed: "telSpeed"; readonly ttft: "telTtft"; readonly total: "telTotal"; readonly stall: "telStall"; }; /** A dollar amount at the precision it needs: $12.40, $0.29, $0.031, $0.004. */ export declare function fmtCost(usd: number): string; /** * The line shown after a run: * * 󰓅 42.3 tok/s · 󰔟 ttft 1.1s · 󰅐 4.8s · ↑40k (38k cached) ↓1.2k · $0.031 * * The speed is left out for a short reply (under MIN_TPS_TOKENS output tokens), where it would only * measure start-up. The speed, waits and stalls have a dim icon in front and the separators are dim. The token counts * and the cost have none: the arrows and the $ sign speak for themselves. The cost is what the run * really cost, left out when the provider reports none. */ export declare function formatTelemetry(t: Telemetry, theme: Theme): string;