import type { ExtensionAPI } from "./pi.js"; import type { PlanItem } from "./wire.js"; /** The kept state of one subagent, merged across its lifecycle events. */ export interface AgentState { id: string; type?: string; description?: string; /** raw pi-subagents lifecycle status. */ status?: string; startedAt?: number; durationMs?: number; result?: string; error?: string; } /** Lifecycle rank: pending(0) < in_progress(1) < terminal(2). pi can emit out of order. */ export declare function statusRank(status: string | undefined): number; /** Merge an incoming lifecycle event into the kept state: preserve type/description/result, * never downgrade status, keep the specific terminal reason over a generic `failed`. * (Port of pi-acp's mergeSubagent.) */ export declare function mergeAgentState(prev: AgentState | undefined, incoming: AgentState): AgentState; /** An AgentState → a `kind:"agent"` plan item for the model's Agents group. */ export declare function toAgentItem(a: AgentState): PlanItem; export interface AgentSource { /** Current fleet as agent plan items. */ items(): PlanItem[]; /** Raw kept state (active + finished), for callers that need more than plan items. */ fleet(): AgentState[]; } /** * Subscribe the subagent lifecycle and maintain the merged fleet (a live Map of AgentState). * `onChange` fires on every update so the caller can repaint. */ export declare function installAgentSource(pi: ExtensionAPI, onChange: () => void): AgentSource;