import { T as ToolHost } from '../tool-host-BqJRPr_T.js'; import { B as Bridge } from '../types-D_TzdBsK.js'; import '../types-ITRQFAir.js'; type FlowNode = { id: string; type?: string; position: { x: number; y: number; }; data: { kind?: string; label?: string; description?: string; status?: string; statusText?: string; config?: Record; [k: string]: unknown; }; }; type FlowEdge = { id: string; source: string; target: string; sourceHandle?: string; targetHandle?: string; label?: string; [k: string]: unknown; }; type NodeRunStatus = "idle" | "queued" | "running" | "done" | "error"; type ExecutorRegistry = Record; type RunResult = { ok: boolean; outputs: Record; error?: string; }; /** * Adapter the host provides — same shape as the editor's local state plus * an optional `run`/`cancel` pair so agents can trigger executions. */ type FlowBridgeAdapter = { getNodes: () => FlowNode[]; setNodes: (next: FlowNode[] | ((prev: FlowNode[]) => FlowNode[])) => void; getEdges: () => FlowEdge[]; setEdges: (next: FlowEdge[] | ((prev: FlowEdge[]) => FlowEdge[])) => void; /** Optional: invoke runFlow with the host's executor registry. */ run?: (executors?: ExecutorRegistry) => Promise; /** Optional: cancel the in-flight run. */ cancel?: () => void; /** Optional: set per-node status text without going through the runner * (useful for agents narrating). */ setNodeStatus?: (id: string, status: NodeRunStatus, text?: string) => void; /** * Human confirm gate for staged actions (trust-but-verify). When * `pendingMode` is on, the bridge calls this before a destructive action; * return false to decline. Wire it to a human control. */ confirm?: (request: FlowConfirmRequest) => Promise | boolean; }; /** What a staged (pendingMode) flow action asks a human to approve. */ type FlowConfirmRequest = { action: "delete_node"; nodeId: string; label?: string; } | { action: "run"; }; type FlowBridgeOptions = { adapter: FlowBridgeAdapter; /** Identity tagged onto agent-authored nodes. */ agent?: { id: string; name?: string; color?: string; }; /** * Enforce port-type compatibility on `flow_connect`, using fancy-flow's * `createConnectionValidator` — the SAME rule `` applies, so an * agent can't build an edge the canvas would refuse. `true` (default) uses the * default rule (untyped ports permissive); pass `ConnectionValidatorOptions` * to tune it, or `false` to disable. No-ops if fancy-flow (>= 0.18.0) isn't * importable — the bridge falls back to the existence-only check. */ validateConnections?: boolean | Record; /** * Validate a node's config against its kind's `configSchema` on * `flow_add_node` / `flow_update_node`. `"reject"` (default) refuses an * invalid write; `"warn"` applies it but reports the issues; `"off"` skips. * No-ops for the legacy 6-pack (no schema) and when fancy-flow isn't importable. */ validateConfig?: "reject" | "warn" | "off"; /** * Stage destructive/human-visible actions (`flow_delete_node`, `flow_run`) for * human confirmation via `adapter.confirm` instead of applying immediately. * **Default: OFF** — flow authoring is high-frequency, unlike a form submit. * When on without an `adapter.confirm`, the action proceeds (nothing to gate). */ pendingMode?: boolean; }; /** * registerFlowBridge — wires an MCP tool set against a fancy-flow editor's * controlled state. Mirrors the whiteboard bridge in shape: read tools, * mutation tools (add / update / delete nodes + edges), and optional * run/cancel if the host provides those callbacks. */ declare function registerFlowBridge(host: ToolHost, options: FlowBridgeOptions): Bridge; export { type FlowBridgeAdapter, type FlowBridgeOptions, type FlowConfirmRequest, registerFlowBridge };