/** * Deterministic workflow graph extraction (no LLM). Runs `@sapiom/agent-core`'s * `check()` pipeline (in an isolated child process — see * core/canvas-manifest-check.ts for why) against a workflow project on disk * — the same bundle+manifest+graph-validation path `sapiom agents check` * uses — and reshapes the resulting manifest into the small node/edge model * `canvas-svg.ts` renders. Never throws: extraction failure (missing * node_modules, a type error, an invalid graph) is returned as a typed * `ExtractionFailure` so the caller can render an honest degraded panel * instead of crashing or silently falling back to an LLM. */ import type { AgentManifest } from "@sapiom/agent"; import { type DetectedLaunch, type DetectedCapability } from "@sapiom/mcp/map"; export type CanvasNodeKind = "entry" | "step" | "pause" | "terminal-success" | "terminal-warn" | "launched-workflow"; export type CanvasEdgeKind = "sequential" | "branching" | "cross" | "launch"; export interface CanvasNode { id: string; kind: CanvasNodeKind; label: string; sublabel?: string; /** Human-authored step description from the manifest (Option A); "" when none. */ description?: string; /** The step's declared input contract (JSON Schema) from the manifest. */ inputSchema?: Record | null; /** Author-declared Sapiom capabilities the step calls. */ capabilities?: readonly string[]; /** The step's declared dispatch timeout (ms); null when unset. */ timeoutMs?: number | null; } export interface CanvasEdge { from: string; to: string; kind: CanvasEdgeKind; label?: string; } /** One workflow's extracted, render-ready graph. */ export interface CanvasGraph { /** The manifest's own name — used both as a display title fallback and as * the match key for cross-workflow interconnection detection. */ manifestName: string; /** Human-authored workflow description from the manifest (Option A); "" when none. */ description?: string; entry: string; nodes: CanvasNode[]; edges: CanvasEdge[]; /** Non-fatal graph smells from `assertValidGraph` (unreachable steps, no * path to a terminal) — surfaced as a badge, not an error. */ warnings: string[]; } export interface ExtractionSuccess { ok: true; graph: CanvasGraph; } export interface ExtractionFailure { ok: false; /** Human-readable, terminal-safe reason — shown verbatim in the degraded panel. */ reason: string; /** Stable agent-core failure code when extraction reached check(). */ code?: string; } export type ExtractionResult = ExtractionSuccess | ExtractionFailure; /** * The precedence table above, over nothing but a step's declared transition * kinds — so a caller that has transitions from somewhere OTHER than a local * `AgentManifest` classifies identically. * * Exported because the Studio's template preview projects the SAME graph from * core's relayed `DefinitionTransitionDto[]` (see `core/template-catalog.ts`). * That preview claims parity with the canvas, so it must not re-derive this: * a second copy of the rule is a second answer to "what kind of node is this", * and the two surfaces disagreeing is the exact class of bug the template work * set out to remove. Collapsing the four kinds into a single `terminal` boolean * (as the first cut of that preview did) renders a fail-only sink as a green * success exit and a `continue`-plus-`terminate` gate as a terminal. */ export declare function classifyStepKind(input: { name: string; entry: string; transitions: ReadonlyArray<{ kind: string; signal?: string | null; }>; }): { kind: CanvasNodeKind; sublabel: string; }; /** Reshapes a validated `AgentManifest` into the render-ready graph model. */ export declare function graphFromManifest(manifest: AgentManifest, warnings: string[]): CanvasGraph; /** * Merges heuristically detected cross-workflow launches into the workflow's * own graph: one dashed `launched-workflow` node per distinct slug, with a * `launch`-kind edge from the step the call was attributed to (falling back * to the entry step — the launch definitely happens somewhere downstream of * it). Self-launches (a workflow re-launching itself) are skipped: the graph * already shows those steps. Pure — returns a new graph. */ export declare function mergeLaunchesIntoGraph(graph: CanvasGraph, launches: readonly DetectedLaunch[]): CanvasGraph; /** Fills each step node's `capabilities` from statically-detected * `ctx.sapiom.*` calls, unless the manifest already declared them (authored * capabilities win). Pure — returns a new graph. */ export declare function mergeCapabilitiesIntoGraph(graph: CanvasGraph, detected: readonly DetectedCapability[]): CanvasGraph; /** * Extracts a workflow's step graph from its project directory, with detected * cross-workflow launches merged in as dashed nodes. Never throws: any * failure (no node_modules, a bundle/type error, an invalid graph, a * check-process crash or timeout) comes back as `{ ok: false, reason }` for * the caller to render as a degraded panel — this is the only place * extraction failure is allowed to happen silently instead of crashing the * render. */ export declare function extractWorkflowGraph(sourceDir: string): Promise; //# sourceMappingURL=canvas-graph.d.ts.map