import type { ExtensionAPI, ExtensionContext } from "@earendil-works/pi-coding-agent"; import type { WorkflowClient } from "../client/client.js"; import { type WorkflowSessionMessage, type WorkflowSessionView } from "../client/view.js"; import { type WorkflowMessageContent, type WorkflowTurnStopReason } from "../state/workflow-messages.js"; type SettledTurn = { stopReason: WorkflowTurnStopReason; responseSessionEntryId: string | null; }; type BeforeTurnEnd = (message: WorkflowSessionMessage, end: SettledTurn) => Promise; type DeliveryCallbacks = { beforeTurnEnd?: BeforeTurnEnd; terminalDelivered?: (message: WorkflowSessionMessage) => Promise; }; /** Adds every server-owned workflow message to one Pi session through one public API path. */ export declare class WorkflowMessageCoordinator { private readonly queued; private readonly closedTurnMessages; private readonly finalizedTerminals; private synchronizing; private lastBranchEpoch; private view; private turn; private content; /** * A lost subscription keeps the last snapshot for display, but it removes * authority: no turn may start, answer, or claim an epoch from that snapshot * until a fresh one arrives. */ private fenced; /** * Read and verify the current message content. Large content arrives as a * bounded, digest-checked reference, so this must finish before delivery. */ prepareContent(client: WorkflowClient): Promise; /** Verified content of the current message, when it is prepared and current. */ verifiedContent(message: WorkflowSessionMessage): WorkflowMessageContent | undefined; private contentFor; updateView(view: WorkflowSessionView): void; branchChanged(): void; startTurn(): void; endTurn(stopReason: WorkflowTurnStopReason, responseSessionEntryId: string | null): void; activeTurnMessage(): WorkflowSessionMessage | undefined; toolCallBlockReason(toolName: string, input: unknown): string | undefined; synchronize(pi: ExtensionAPI, client: WorkflowClient, ctx: Pick, callbacks?: DeliveryCallbacks): Promise; /** * Remove authority from the last view. The extension calls this when its * subscription fails, so a snapshot the server no longer confirms cannot start * a Pi turn or answer a request. A fresh snapshot clears the fence. */ fence(): void; clear(): void; abortCancelledTurn(ctx: Pick): void; private turnCandidate; private flushTurn; private reportBranch; private hasUnconfirmedBranchEntry; } export declare function branchWorkflowEntries(entries: readonly unknown[]): Map; export declare function responseEntryId(entries: readonly unknown[]): string | null; export {};