/** * Live workflow widget: a tree of the runs happening right now, drawn below the * editor, and a durable receipt in the transcript once each one reaches a * terminal state. * * The split is deliberate. The widget answers "what is happening" and holds * nothing that has reached a final state — resumable interruptions remain visible. * The transcript entry answers "what did that cost and who did it", and keeps the * answer for the life of the session rather than for a minute. * * Run state arrives as workflow events; the numbers behind it (tokens, cost, * per-agent accounting) live only in the run's state.json, so an event is a * signal to re-read rather than the data itself. A slower rescan timer checks for * changed state files without reparsing unchanged runs. */ import type { ExtensionAPI, Theme } from "@earendil-works/pi-coding-agent"; export type BackgroundWidgetAPI = Pick & { events?: { on?: (name: string, handler: (event: unknown) => void) => () => void; emit?: ExtensionAPI["events"]["emit"]; }; registerEntryRenderer?: ExtensionAPI["registerEntryRenderer"]; registerShortcut?: ExtensionAPI["registerShortcut"]; }; /** * Overrides the switch above, for the tests that cover navigation. * * The behaviour is finished and tested; only its exposure is withheld. Letting * the tests turn it on keeps that coverage alive rather than letting it rot * while the feature waits. */ export declare const __navigationForTests: { enabled: boolean; }; interface ReceiptAgent { id?: string; parentId?: string; name: string; state: string; model?: string; role?: string; requestedModel?: string; tools?: readonly string[]; /** Accepted for rendering older receipt entries; new receipts persist granted tools. */ toolCalls?: number; input: number; output: number; cacheRead: number; costUsd: number; durationMs: number; attempts: number; } interface Receipt { runId: string; workflow: string; state: string; costUsd: number; tokens: number; durationMs: number; phases: readonly string[]; phaseBoundaries: readonly number[]; agents: readonly ReceiptAgent[]; error?: string; } export declare function formatCost(cost: number | undefined): string; /** The receipt as transcript lines: the widget's tree, one level deeper. */ export declare function renderReceipt(data: Receipt, expanded: boolean, theme: Theme): string[]; export interface BackgroundWidgetController { suspend(): void; resume(): void; } export default function widget(pi: BackgroundWidgetAPI, enabled?: boolean): BackgroundWidgetController; export {};