import type { WorkflowDefinitionSnapshot } from "../workflows/types.js"; /** * Graph layout for the terminal viewer, ported from the acpx replay viewer's * view-model (expand switch edges, classify back edges via shortest levels, * longest-path layering with terminal tail pull-down, barycenter ordering). * The one addition is virtual pass-through cells so every forward edge spans * exactly one rank, which keeps text routing local to each rank gap. */ export type GraphEdge = { edgeId: string; from: string; to: string; /** Switch case key for labelled branches. */ label?: string; isBackEdge: boolean; }; export type GraphCell = { kind: "node"; nodeId: string; } | { kind: "virtual"; edgeId: string; }; export type GraphSegment = { edgeId: string; /** Rank index the segment starts at; it ends at `rank + 1`. */ rank: number; fromCell: number; toCell: number; /** Label to draw on this segment (only on the first segment of an edge). */ label?: string; }; export type GraphLayout = { ranks: GraphCell[][]; edges: GraphEdge[]; /** Forward-edge segments between adjacent ranks. */ segments: GraphSegment[]; /** Rank index of every real node. */ rankOfNode: Map; }; export declare function expandEdges(snapshot: WorkflowDefinitionSnapshot): GraphEdge[]; /** * Build ranks with virtual pass-through cells so every forward edge connects * adjacent ranks, then order cells within ranks by neighbor barycenter. */ export declare function layoutGraph(snapshot: WorkflowDefinitionSnapshot): GraphLayout;