import type { ExtensionContext } from "@earendil-works/pi-coding-agent"; import type { AgentContextWindowStats } from "./agent.js"; import type { AgentHistoryEntry } from "./agent-history.js"; import { type ConductorRunStatus } from "./conductor-types.js"; import type { WorkflowErrorCode } from "./errors.js"; import type { WorkflowMeta } from "./workflow.js"; export type WorkflowAgentStatus = "queued" | "running" | "done" | "error" | "skipped"; export interface WorkflowAgentSnapshot { id: number; label: string; phase?: string; prompt: string; status: WorkflowAgentStatus; resultPreview?: string; error?: string; errorCode?: WorkflowErrorCode; recoverable?: boolean; history?: AgentHistoryEntry[]; /** Tokens used by this agent. */ tokens?: number; /** Context-window occupancy stats for this agent, when known. */ contextWindow?: AgentContextWindowStats; /** The model this agent ran on (provider/id), when known. */ model?: string; /** ISO timestamp when this agent originally started. Preserved across resume replay. */ startedAt?: string; /** ISO timestamp when this agent originally ended. Preserved across resume replay. */ endedAt?: string; } export interface WorkflowSnapshot { name: string; description?: string; phases: string[]; currentPhase?: string; logs: string[]; agents: WorkflowAgentSnapshot[]; agentCount: number; runningCount: number; doneCount: number; errorCount: number; durationMs?: number; result?: unknown; tokenUsage?: { input: number; output: number; total: number; cost?: number; cacheRead?: number; cacheWrite?: number; }; runId?: string; } export interface WorkflowDisplay { update(snapshot: WorkflowSnapshot): void; complete(snapshot: WorkflowSnapshot): void; clear(): void; } export interface WorkflowDisplayOptions { key?: string; placement?: "aboveEditor" | "belowEditor"; maxAgents?: number; showStatus?: boolean; showResultPreviews?: boolean; } export declare function createWorkflowSnapshot(meta: WorkflowMeta): WorkflowSnapshot; export declare function recomputeWorkflowSnapshot(snapshot: WorkflowSnapshot): WorkflowSnapshot; export declare function createWidgetWorkflowDisplay(ctx: Pick, options?: WorkflowDisplayOptions): WorkflowDisplay; export declare function createToolUpdateWorkflowDisplay(onUpdate: ((result: { content: Array<{ type: "text"; text: string; }>; details: unknown; }) => void) | undefined, ctx?: Pick, options?: WorkflowDisplayOptions & { streamToolUpdates?: boolean; }): WorkflowDisplay; /** Minimal theme surface so rendering works without a real Theme (tool output, tests). */ export interface ThemeLike { fg(color: string, text: string): string; bold(text: string): string; } export declare function renderWorkflowLines(snapshot: WorkflowSnapshot, options?: WorkflowDisplayOptions, theme?: ThemeLike): string[]; export declare function renderWorkflowText(snapshot: WorkflowSnapshot, completed?: boolean): string; export declare function statusIcon(status: WorkflowAgentStatus): string; export declare function shorten(value: string, max: number): string; export declare function firstLine(value: string | undefined | null): string; /** Inline error suffix for an errored agent row — shared by both the detailed * task panel and the live workflow widget so the two renderers cannot diverge. * Renders the first non-empty error line (surrogate-safe), and returns "" when * there is no error or the error is blank/whitespace-only (no dangling ` — `). */ export declare function agentErrorText(agent: { status: string; error?: string; }, theme: ThemeLike, max?: number): string; export declare function preview(value: unknown, max?: number): string; /** * Format a conductor-level semantic status for display. * Used by the task panel and /workflows status output to show the semantic * overlay (e.g. "workflow-complete-pane-open") alongside the engine status. */ export declare function formatConductorStatus(status: ConductorRunStatus): string;