@pipelex/mthds-ui 0.6.2 → 0.6.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-NISDJYQJ.js → chunk-FHRUYFGV.js} +4 -3
- package/dist/chunk-FHRUYFGV.js.map +1 -0
- package/dist/graph/index.js +1 -1
- package/dist/graph/react/graph-core.css +10 -0
- package/dist/graph/react/index.js +10 -7
- package/dist/graph/react/index.js.map +1 -1
- package/dist/index.js +1 -1
- package/dist/standalone/graph-standalone.html +2358 -0
- package/dist/standalone/graph-viewer.css +2224 -0
- package/dist/standalone/graph-viewer.js +99 -0
- package/package.json +3 -2
- package/dist/chunk-NISDJYQJ.js.map +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pipelex/mthds-ui",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.4",
|
|
4
4
|
"description": "Shared graph rendering logic for MTHDS method visualization",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -45,8 +45,9 @@
|
|
|
45
45
|
"dist"
|
|
46
46
|
],
|
|
47
47
|
"scripts": {
|
|
48
|
-
"prepare": "
|
|
48
|
+
"prepare": "npm run build",
|
|
49
49
|
"build": "tsup",
|
|
50
|
+
"postbuild": "node scripts/build-standalone.mjs",
|
|
50
51
|
"build:standalone": "node scripts/build-standalone.mjs",
|
|
51
52
|
"lint": "eslint src/",
|
|
52
53
|
"format": "prettier --write \"src/**/*.{ts,tsx}\"",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/graph/types.ts","../src/graph/graphAnalysis.ts","../src/graph/pipeCardPayload.ts","../src/graph/graphBuilders.ts","../src/graph/graphFolds.ts","../src/graph/elkGraphBuilder.ts","../src/graph/graphLayout.ts","../src/graph/graphControllers.ts","../src/graph/graphConfig.ts"],"sourcesContent":["// ─── Pipe type taxonomy ─────────────────────────────────────────────────────\n// Operators perform work; controllers orchestrate other pipes.\n\nexport type PipeOperatorType =\n | \"PipeLLM\"\n | \"PipeExtract\"\n | \"PipeCompose\"\n | \"PipeImgGen\"\n | \"PipeSearch\"\n | \"PipeFunc\";\n\nexport type PipeControllerType = \"PipeSequence\" | \"PipeParallel\" | \"PipeCondition\" | \"PipeBatch\";\n\nexport type PipeType = PipeOperatorType | PipeControllerType;\n\nexport type PipeStatus = \"succeeded\" | \"failed\" | \"running\" | \"scheduled\" | \"skipped\";\n\n// ─── Node type constants ────────────────────────────────────────────────────\n// Used by graphBuilders and consumed by ReactFlow custom node registration.\n\nexport const NODE_TYPE_PIPE_CARD = \"pipeCard\" as const;\nexport const NODE_TYPE_STUFF = \"default\" as const;\nexport const NODE_TYPE_CONTROLLER = \"controllerGroup\" as const;\n\n// ─── Stuff node ID helpers ──────────────────────────────────────────────────\n// Stuff (data) nodes use a \"stuff_<digest>\" convention throughout the graph.\n\nexport const STUFF_ID_PREFIX = \"stuff_\";\n\nexport function stuffNodeId(digest: string): string {\n return STUFF_ID_PREFIX + digest;\n}\n\nexport function isStuffNodeId(id: string): boolean {\n return id.startsWith(STUFF_ID_PREFIX);\n}\n\nexport function stuffDigestFromId(id: string): string {\n return id.slice(STUFF_ID_PREFIX.length);\n}\n\n// ─── GraphSpec types (from pipelex-agent --view output) ─────────────────────\n\nexport interface GraphSpecNodeIoItem {\n name?: string;\n digest?: string;\n concept?: string;\n content_type?: string;\n preview?: string;\n size?: number;\n data?: unknown;\n data_text?: string;\n data_html?: string;\n extra?: Record<string, unknown>;\n}\n\nexport interface GraphSpecNodeIo {\n inputs?: GraphSpecNodeIoItem[];\n outputs?: GraphSpecNodeIoItem[];\n}\n\nexport type NodeKind =\n | \"pipe_call\"\n | \"controller\"\n | \"operator\"\n | \"input\"\n | \"output\"\n | \"artifact\"\n | \"error\";\n\nexport interface GraphSpecNodeTiming {\n started_at: string;\n ended_at: string;\n duration: number;\n}\n\nexport interface GraphSpecNodeError {\n error_type: string;\n message: string;\n stack?: string;\n}\n\nexport interface GraphSpecNode {\n id: string;\n kind?: NodeKind;\n pipe_code?: string;\n pipe_type: PipeType;\n description?: string;\n status?: PipeStatus;\n timing?: GraphSpecNodeTiming;\n io?: GraphSpecNodeIo;\n error?: GraphSpecNodeError;\n tags?: Record<string, string>;\n metrics?: Record<string, number>;\n execution_data?: Record<string, unknown>;\n}\n\nexport type GraphSpecEdgeKind =\n | \"contains\"\n | \"data\"\n | \"control\"\n | \"selected_outcome\"\n | \"batch_item\"\n | \"batch_aggregate\"\n | \"parallel_combine\";\n\nexport interface GraphSpecEdge {\n id?: string;\n source: string;\n target: string;\n kind: GraphSpecEdgeKind;\n label?: string;\n source_stuff_digest?: string;\n target_stuff_digest?: string;\n meta?: Record<string, unknown>;\n}\n\n// ─── Concept and Pipe registry types ───────────────────────────────────────\n// Serialized from Python Concept and PipeAbstract instances via model_dump().\n\nexport interface ConceptInfo {\n code: string;\n domain_code: string;\n description: string;\n structure_class_name: string;\n refines: string | null;\n json_schema?: Record<string, unknown>;\n}\n\nexport interface StuffSpecInfo {\n concept: ConceptInfo;\n multiplicity: number | boolean | null;\n}\n\n// ─── Template blueprint (shared by LLM prompts, Search, Compose, ImgGen) ───\n\nexport interface TemplateBlueprint {\n template: string;\n templating_style: string | null;\n category: string;\n extra_context: Record<string, unknown> | null;\n}\n\n// ─── Sub-pipe (used by Sequence, Parallel, Batch) ──────────────────────\n\nexport interface SubPipeSpec {\n pipe_code: string;\n output_name: string | null;\n output_multiplicity: string | number | boolean | null;\n batch_params: { input_list_stuff_name: string; input_item_stuff_name: string } | null;\n}\n\n// ─── PipeAbstract base (common to all pipe types) ──────────────────────\n\nexport interface PipeBlueprintBase {\n type: PipeType;\n pipe_category: \"PipeOperator\" | \"PipeController\";\n code: string;\n domain_code: string;\n description: string;\n inputs: Record<string, StuffSpecInfo>;\n output: StuffSpecInfo;\n}\n\n// ─── Operator blueprints ───────────────────────────────────────────────\n\nexport interface PipeLLMBlueprint extends PipeBlueprintBase {\n type: \"PipeLLM\";\n llm_prompt_spec: {\n templating_style: string | null;\n system_prompt_blueprint: TemplateBlueprint | null;\n prompt_blueprint: TemplateBlueprint | null;\n user_image_references: unknown[] | null;\n user_document_references: unknown[] | null;\n system_image_references: unknown[] | null;\n system_document_references: unknown[] | null;\n };\n llm_choices: { for_text: string | null; for_object: string | null } | null;\n structuring_method: string | null;\n output_multiplicity: string | number | null;\n}\n\nexport interface PipeImgGenBlueprint extends PipeBlueprintBase {\n type: \"PipeImgGen\";\n img_gen_prompt_blueprint: {\n prompt_blueprint: TemplateBlueprint | null;\n negative_prompt_blueprint: TemplateBlueprint | null;\n image_references: unknown[] | null;\n };\n img_gen_choice: string | null;\n aspect_ratio: string | null;\n is_raw: boolean | null;\n seed: number | string | null;\n background: string | null;\n output_format: string | null;\n output_multiplicity: number;\n}\n\n/**\n * A single field in a PipeCompose construct blueprint. Mirrors the\n * `ConstructFieldBlueprint` Pydantic model in pipelex. Exactly one of\n * `fixed_value` / `from_path` / `template` / `nested` is populated, matching\n * the `method` discriminator.\n *\n * - `fixed` → `fixed_value` holds a literal (string, number, bool, list)\n * - `from_var` → `from_path` holds a dotted path into working memory,\n * optionally with a `list_to_dict_keyed_by` modifier\n * - `template` → `template` holds a Jinja2 template string (per-field)\n * - `nested` → `nested` holds a recursive construct blueprint for building\n * nested structured content\n */\nexport interface PipeComposeConstructField {\n method: \"from_var\" | \"fixed\" | \"template\" | \"nested\";\n fixed_value?: unknown;\n from_path?: string | null;\n template?: string | null;\n nested?: PipeComposeConstructBlueprint | null;\n list_to_dict_keyed_by?: string | null;\n}\n\n/**\n * A PipeCompose construct blueprint, parsed from `[pipe.X.construct]` in MTHDS.\n * Mirrors the `ConstructBlueprint` Pydantic model in pipelex.\n */\nexport interface PipeComposeConstructBlueprint {\n fields: Record<string, PipeComposeConstructField>;\n}\n\n/**\n * Per-field record of how each field was built at runtime, emitted by\n * `PipeCompose._run_construct_mode` in pipelex via `execution_data.fields`.\n *\n * - `method` → which composition method was used (mirrors `ConstructFieldMethod`)\n * - `rendered` → present only for `template` fields, holds the Jinja2 output\n *\n * Nested fields record only their method; their sub-fields are not surfaced.\n */\nexport interface FieldResolution {\n method: \"from_var\" | \"fixed\" | \"template\" | \"nested\";\n rendered?: string;\n}\n\nexport interface PipeComposeBlueprint extends PipeBlueprintBase {\n type: \"PipeCompose\";\n /** Legacy monolithic template. Null when construct_blueprint is used instead. */\n template: string | null;\n templating_style: string | null;\n category: string;\n extra_context: Record<string, unknown> | null;\n /** Field-level construct form (e.g. `[pipe.X.construct]` in MTHDS). */\n construct_blueprint: PipeComposeConstructBlueprint | null;\n}\n\nexport interface PipeExtractBlueprint extends PipeBlueprintBase {\n type: \"PipeExtract\";\n extract_choice: string | null;\n should_caption_images: boolean;\n max_page_images: number | null;\n should_include_page_views: boolean;\n page_views_dpi: number | null;\n render_js: boolean | null;\n include_raw_html: boolean | null;\n image_stuff_name: string | null;\n document_stuff_name: string;\n}\n\nexport interface PipeSearchBlueprint extends PipeBlueprintBase {\n type: \"PipeSearch\";\n search_choice: string | null;\n prompt_blueprint: TemplateBlueprint;\n include_images_override: boolean | null;\n max_results_override: number | null;\n from_date: string | null;\n to_date: string | null;\n include_domains: string[] | null;\n exclude_domains: string[] | null;\n is_structured_output: boolean;\n}\n\nexport interface PipeFuncBlueprint extends PipeBlueprintBase {\n type: \"PipeFunc\";\n}\n\n// ─── Controller blueprints ─────────────────────────────────────────────\n\nexport interface PipeSequenceBlueprint extends PipeBlueprintBase {\n type: \"PipeSequence\";\n sequential_sub_pipes: SubPipeSpec[];\n}\n\nexport interface PipeParallelBlueprint extends PipeBlueprintBase {\n type: \"PipeParallel\";\n parallel_sub_pipes: SubPipeSpec[];\n add_each_output: boolean;\n combined_output: string | null;\n}\n\nexport interface PipeConditionBlueprint extends PipeBlueprintBase {\n type: \"PipeCondition\";\n expression: string;\n outcome_map: Record<string, string>;\n default_outcome: string;\n add_alias_from_expression_to: string | null;\n}\n\nexport interface PipeBatchBlueprint extends PipeBlueprintBase {\n type: \"PipeBatch\";\n branch_pipe_code: string;\n batch_params: { input_list_stuff_name: string; input_item_stuff_name: string };\n}\n\nexport type PipeBlueprintUnion =\n | PipeLLMBlueprint\n | PipeImgGenBlueprint\n | PipeComposeBlueprint\n | PipeExtractBlueprint\n | PipeSearchBlueprint\n | PipeFuncBlueprint\n | PipeSequenceBlueprint\n | PipeParallelBlueprint\n | PipeConditionBlueprint\n | PipeBatchBlueprint;\n\n// ─── GraphSpec top-level ───────────────────────────────────────────────────\n\nexport interface GraphSpec {\n graph_id?: string;\n created_at?: string;\n pipeline_ref?: { domain?: string; main_pipe?: string; entrypoint?: string };\n nodes: GraphSpecNode[];\n edges: GraphSpecEdge[];\n meta?: Record<string, unknown>;\n pipe_registry?: Record<string, PipeBlueprintUnion>;\n concept_registry?: Record<string, ConceptInfo>;\n}\n\n// ─── Dataflow analysis result ───────────────────────────────────────────────\n\nexport interface DataflowAnalysis {\n readonly stuffRegistry: Readonly<\n Record<string, { name?: string; concept?: string; contentType?: string }>\n >;\n readonly stuffProducers: Readonly<Record<string, string>>;\n readonly stuffConsumers: Readonly<Record<string, readonly string[]>>;\n readonly controllerNodeIds: ReadonlySet<string>;\n readonly childNodeIds: ReadonlySet<string>;\n readonly containmentTree: Readonly<Record<string, readonly string[]>>;\n}\n\n// ─── Graph configuration ────────────────────────────────────────────────────\n\nexport const GRAPH_DIRECTION = {\n TB: \"TB\",\n BT: \"BT\",\n LR: \"LR\",\n RL: \"RL\",\n} as const;\n\nexport type GraphDirection = (typeof GRAPH_DIRECTION)[keyof typeof GRAPH_DIRECTION];\n\nexport const EDGE_TYPE = {\n /** Bezier curve — ReactFlow v12 renamed this type from \"bezier\" to \"default\". */\n DEFAULT: \"default\",\n STEP: \"step\",\n STRAIGHT: \"straight\",\n SMOOTH_STEP: \"smoothstep\",\n} as const;\n\nexport type EdgeType = (typeof EDGE_TYPE)[keyof typeof EDGE_TYPE];\n\nexport const FOLD_MODE = {\n /** Every pipe controller folded into a single pipe card. */\n FOLDED: \"folded\",\n /** Every pipe controller expanded as a group wrapper. */\n EXPANDED: \"expanded\",\n /** Renderer decides — reserved for future heuristics; currently behaves like EXPANDED. */\n AUTO: \"auto\",\n} as const;\n\nexport type FoldMode = (typeof FOLD_MODE)[keyof typeof FOLD_MODE];\n\nexport interface GraphConfig {\n direction?: GraphDirection;\n showControllers?: boolean;\n foldMode?: FoldMode;\n nodesep?: number;\n ranksep?: number;\n edgeType?: EdgeType;\n initialZoom?: number | null;\n panToTop?: boolean;\n paletteColors?: Record<string, string>;\n}\n\n// ─── Label descriptors ──────────────────────────────────────────────────────\n// Plain objects, no React dependency. GraphViewer maps these to React elements.\n\nexport type LabelDescriptor =\n | { kind: \"pipe\"; label: string; isFailed: boolean }\n | { kind: \"stuff\"; label: string; concept: string };\n\n// ─── Fold toggle options ────────────────────────────────────────────────────\n// Passed by UI click handlers so the orchestrator can decide whether the\n// toggle should propagate to \"cousin\" controllers (other instances of the\n// same pipe) or affect only the clicked one.\n\nexport interface FoldToggleOptions {\n /**\n * When `true`, the toggle applies only to the clicked controller — its\n * cousins (other controller nodes sharing the same `pipe_code`) are left\n * untouched. Wired to the alt/option modifier key in the click handlers.\n */\n soloMode?: boolean;\n}\n\n// ─── Pipe card payload ──────────────────────────────────────────────────────\n// Built by graphBuilders, consumed by PipeCardNode in the React layer.\n\nexport interface PipeCardPayload {\n pipeCode: string;\n pipeType: PipeType;\n description?: string;\n status: PipeStatus;\n inputs: { name: string; concept: string }[];\n outputs: { name: string; concept: string }[];\n /** Layout direction — injected by the layout engine */\n direction?: \"LR\" | \"TB\";\n /** When set, the card renders an unfold button that invokes this callback. */\n onExpand?: (options?: FoldToggleOptions) => void;\n}\n\n// ─── Graph node data ────────────────────────────────────────────────────────\n// Extends Record<string, unknown> for ReactFlow's Node<T> generic parameter.\n\nexport type StuffRole = \"input\" | \"output\";\n\nexport interface GraphNodeData extends Record<string, unknown> {\n labelDescriptor?: LabelDescriptor;\n label?: unknown;\n nodeData?: GraphSpecNode;\n isPipe: boolean;\n isStuff: boolean;\n isController?: boolean;\n labelText: string;\n pipeCode?: string;\n pipeType?: PipeType;\n pipeCardData?: PipeCardPayload;\n /** For stuff nodes: \"input\" (no producer), \"output\" (no consumer), or undefined (intermediate). */\n stuffRole?: StuffRole;\n /** For stuff nodes: the digest used to build the node ID. */\n stuffDigest?: string;\n}\n\n// ─── Graph node / edge / data ───────────────────────────────────────────────\n\nexport interface GraphNode {\n id: string;\n type: string;\n data: GraphNodeData;\n position: { x: number; y: number };\n style?: Record<string, string | number>;\n sourcePosition?: \"top\" | \"bottom\" | \"left\" | \"right\";\n targetPosition?: \"top\" | \"bottom\" | \"left\" | \"right\";\n parentId?: string;\n extent?: \"parent\";\n selected?: boolean;\n}\n\nexport interface GraphEdge {\n id: string;\n source: string;\n target: string;\n type: string;\n animated?: boolean;\n label?: string;\n labelStyle?: Record<string, string | number>;\n labelBgStyle?: Record<string, string | number>;\n labelBgPadding?: [number, number];\n labelBgBorderRadius?: number;\n style?: Record<string, string | number>;\n markerEnd?: { type: string; color: string };\n _batchEdge?: boolean;\n _crossGroup?: boolean;\n}\n\nexport interface GraphData {\n nodes: GraphNode[];\n edges: GraphEdge[];\n}\n\n// ─── Layout ─────────────────────────────────────────────────────────────────\n\nexport interface LayoutConfig {\n nodesep?: number;\n ranksep?: number;\n}\n\n// Controller padding constants (shared between layout and controller modules)\nexport const CONTROLLER_PADDING_X = 40;\nexport const CONTROLLER_PADDING_TOP = 48;\nexport const CONTROLLER_PADDING_BOTTOM = 20;\n\n// Default marker type string (avoids ReactFlow dependency in pure modules)\nexport const ARROW_CLOSED_MARKER = \"arrowclosed\";\n\n// ─── Node dimension helpers ─────────────────────────────────────────────────\n// Extract dimensions from style. Used by buildControllerNodes.\n// NOT used by getLayoutedElements, which estimates dimensions before styles exist.\n\nexport function nodeWidth(n: GraphNode): number {\n const raw = n.style?.width;\n if (raw == null) return 200;\n const w = typeof raw === \"number\" ? raw : parseFloat(raw);\n return isNaN(w) || w <= 0 ? 200 : w;\n}\n\nexport function nodeHeight(n: GraphNode): number {\n const raw = n.style?.height;\n if (raw != null) {\n const h = typeof raw === \"number\" ? raw : parseFloat(raw);\n if (!isNaN(h) && h > 0) return h;\n }\n return n.data?.isStuff ? 60 : 70;\n}\n","import type { GraphSpec, DataflowAnalysis, PipeBlueprintUnion, ConceptInfo } from \"./types\";\n\nexport function buildDataflowAnalysis(graphspec: GraphSpec | null): DataflowAnalysis | null {\n if (!graphspec) return null;\n\n const stuffRegistry: Record<string, { name?: string; concept?: string; contentType?: string }> =\n {};\n const stuffProducers: Record<string, string> = {};\n const stuffConsumers: Record<string, string[]> = {};\n const containmentTree: Record<string, string[]> = {};\n const childNodeIds = new Set<string>();\n\n // Build containment tree from edges\n for (const edge of graphspec.edges) {\n if (edge.kind === \"contains\") {\n if (!containmentTree[edge.source]) containmentTree[edge.source] = [];\n containmentTree[edge.source].push(edge.target);\n childNodeIds.add(edge.target);\n }\n }\n\n // Controller IDs are nodes that have children\n const controllerNodeIds = new Set<string>(Object.keys(containmentTree));\n\n // Register stuffs from all nodes; track producers/consumers from operators only\n for (const node of graphspec.nodes) {\n const nodeIo = node.io || {};\n const isController = controllerNodeIds.has(node.id);\n\n // Register outputs\n for (const output of nodeIo.outputs || []) {\n if (output.digest && !stuffRegistry[output.digest]) {\n stuffRegistry[output.digest] = {\n name: output.name,\n concept: output.concept,\n contentType: output.content_type,\n };\n }\n if (output.digest && !isController) {\n stuffProducers[output.digest] = node.id;\n }\n }\n\n // Register inputs\n for (const input of nodeIo.inputs || []) {\n if (input.digest && !stuffRegistry[input.digest]) {\n stuffRegistry[input.digest] = {\n name: input.name,\n concept: input.concept,\n contentType: input.content_type,\n };\n }\n if (input.digest && !isController) {\n if (!stuffConsumers[input.digest]) stuffConsumers[input.digest] = [];\n stuffConsumers[input.digest].push(node.id);\n }\n }\n }\n\n return {\n stuffRegistry,\n stuffProducers,\n stuffConsumers,\n controllerNodeIds,\n childNodeIds,\n containmentTree,\n };\n}\n\n/**\n * Build a map from node id -> controller id for all nodes that belong to a controller.\n * Includes both direct children (operators) and stuff nodes assigned to controllers.\n *\n * Stuff nodes are placed at the lowest controller level where they connect producers\n * to consumers. A stuff node produced inside controller C is promoted to C's parent\n * if none of its consumers are inside C (output flows outward).\n */\nexport function buildChildToControllerMap(\n graphspec: GraphSpec,\n analysis: DataflowAnalysis,\n): Record<string, string> {\n const childToController: Record<string, string> = {};\n\n // Direct children from containment tree\n for (const [ctrlId, children] of Object.entries(analysis.containmentTree)) {\n for (const childId of children) {\n childToController[childId] = ctrlId;\n }\n }\n\n // Stuff nodes produced by operators inside controllers\n for (const [digest, producerId] of Object.entries(analysis.stuffProducers)) {\n const stuffId = \"stuff_\" + digest;\n const ctrlId = childToController[producerId];\n if (ctrlId) {\n childToController[stuffId] = ctrlId;\n }\n }\n\n // Stuff produced by controllers themselves -> assign to parent controller\n for (const node of graphspec.nodes) {\n if (!analysis.controllerNodeIds.has(node.id)) continue;\n const parentCtrlId = childToController[node.id];\n if (!parentCtrlId) continue;\n for (const output of node.io?.outputs || []) {\n if (!output.digest) continue;\n const stuffId = \"stuff_\" + output.digest;\n if (!childToController[stuffId]) {\n childToController[stuffId] = parentCtrlId;\n }\n }\n }\n\n // Batch item stuff (fan-out) -> assign to the PipeBatch controller\n for (const edge of graphspec.edges) {\n if (edge.kind === \"batch_item\" && edge.target_stuff_digest) {\n const stuffId = \"stuff_\" + edge.target_stuff_digest;\n // edge.source is the PipeBatch controller node\n if (analysis.controllerNodeIds.has(edge.source)) {\n childToController[stuffId] = edge.source;\n }\n }\n }\n\n // ─── Promote stuff nodes whose consumers are all outside their controller ──\n // Stuff involved in stuff-to-stuff edges (batch/parallel) should not be promoted\n // when they have no operator consumers — they're intermediate batch/parallel data.\n const stuffInStuffEdges = new Set<string>();\n for (const edge of graphspec.edges) {\n if (\n edge.kind === \"batch_item\" ||\n edge.kind === \"batch_aggregate\" ||\n edge.kind === \"parallel_combine\"\n ) {\n if (edge.source_stuff_digest) stuffInStuffEdges.add(edge.source_stuff_digest);\n if (edge.target_stuff_digest) stuffInStuffEdges.add(edge.target_stuff_digest);\n }\n }\n\n const stuffPrefix = \"stuff_\";\n const stuffEntries = Object.keys(childToController).filter((id) => id.startsWith(stuffPrefix));\n\n for (const stuffId of stuffEntries) {\n const digest = stuffId.slice(stuffPrefix.length);\n let assignedCtrl: string | undefined = childToController[stuffId];\n if (!assignedCtrl) continue;\n\n const consumers = analysis.stuffConsumers[digest] || [];\n\n if (consumers.length === 0) {\n // No operator consumers — promote to root only if this is a pure final output\n // (not involved in batch/parallel stuff-to-stuff edges)\n if (!stuffInStuffEdges.has(digest)) {\n delete childToController[stuffId];\n }\n continue;\n }\n\n // Has consumers — promote until we find a level where at least one consumer is inside\n while (assignedCtrl) {\n const ctrl = assignedCtrl;\n const hasConsumerInside = consumers.some((consumerId) =>\n isDescendantOf(consumerId, ctrl, childToController),\n );\n if (hasConsumerInside) break;\n\n const parentCtrl: string | undefined = childToController[assignedCtrl];\n if (parentCtrl) {\n childToController[stuffId] = parentCtrl;\n assignedCtrl = parentCtrl;\n } else {\n delete childToController[stuffId];\n assignedCtrl = undefined;\n }\n }\n }\n\n return childToController;\n}\n\n/** Check if nodeId is a descendant of ancestorCtrlId in the containment hierarchy. */\nfunction isDescendantOf(\n nodeId: string,\n ancestorCtrlId: string,\n childToController: Record<string, string>,\n): boolean {\n let current = childToController[nodeId];\n while (current) {\n if (current === ancestorCtrlId) return true;\n current = childToController[current];\n }\n return false;\n}\n\n// ─── Registry lookup helpers ───────────────────────────────────────────────\n\nexport function getPipeBlueprint(spec: GraphSpec, pipeRef: string): PipeBlueprintUnion | undefined {\n return spec.pipe_registry?.[pipeRef];\n}\n\nexport function getConceptInfo(spec: GraphSpec, conceptRef: string): ConceptInfo | undefined {\n return spec.concept_registry?.[conceptRef];\n}\n\nexport function resolveConceptRef(spec: GraphSpec, codeOrRef: string): ConceptInfo | undefined {\n if (!spec.concept_registry) return undefined;\n // Direct lookup first (e.g., \"test_domain.Summary\")\n const direct = spec.concept_registry[codeOrRef];\n if (direct) return direct;\n // Search by code (e.g., \"Summary\" matches \"test_domain.Summary\")\n for (const info of Object.values(spec.concept_registry)) {\n if (info.code === codeOrRef) return info;\n }\n return undefined;\n}\n","import type {\n DataflowAnalysis,\n GraphSpec,\n GraphSpecNode,\n PipeCardPayload,\n PipeType,\n} from \"./types\";\n\n/** Fallback description for operators when neither the node nor the registry carries one. */\nfunction defaultDescription(pipeType: PipeType, pipeCode: string | undefined): string {\n const code = pipeCode || \"this step\";\n const verb: Partial<Record<PipeType, string>> = {\n PipeLLM: \"Analyze and generate output using\",\n PipeExtract: \"Extract content from\",\n PipeCompose: \"Compose output using\",\n PipeImgGen: \"Generate image for\",\n PipeSearch: \"Search the web for\",\n PipeFunc: \"Process data in\",\n };\n return `${verb[pipeType] || \"Execute\"} ${code.replace(/_/g, \" \")}`;\n}\n\n/**\n * Build a PipeCardPayload from a GraphSpecNode + GraphSpec + DataflowAnalysis.\n *\n * Operator/controller distinction uses `analysis.controllerNodeIds` (single source of truth)\n * rather than string-matching against `pipe_type`.\n */\nexport function buildPipeCardPayload(\n node: GraphSpecNode,\n graphspec: GraphSpec,\n analysis: DataflowAnalysis,\n): PipeCardPayload {\n const pipeType = node.pipe_type;\n const pipeCode = node.pipe_code || node.id;\n const isController = analysis.controllerNodeIds.has(node.id);\n\n const inputs = (node.io?.inputs ?? []).map((i) => ({\n name: i.name ?? \"\",\n concept: i.concept ?? \"\",\n }));\n const outputs = (node.io?.outputs ?? []).map((o) => ({\n name: o.name ?? \"\",\n concept: o.concept ?? \"\",\n }));\n\n const registryDescription = node.pipe_code\n ? graphspec.pipe_registry?.[node.pipe_code]?.description\n : undefined;\n\n let description: string | undefined;\n if (node.description) {\n description = node.description;\n } else if (registryDescription) {\n description = registryDescription;\n } else if (isController) {\n description = undefined;\n } else {\n description = defaultDescription(pipeType, node.pipe_code);\n }\n\n return {\n pipeCode,\n pipeType,\n description,\n status: node.status ?? \"scheduled\",\n inputs,\n outputs,\n };\n}\n","import type { GraphSpec, DataflowAnalysis, GraphNode, GraphEdge, GraphData } from \"./types\";\nimport { ARROW_CLOSED_MARKER, NODE_TYPE_PIPE_CARD, NODE_TYPE_STUFF, stuffNodeId } from \"./types\";\nimport { buildDataflowAnalysis, buildChildToControllerMap } from \"./graphAnalysis\";\nimport { buildPipeCardPayload } from \"./pipeCardPayload\";\n\nconst STUFF_CHAR_WIDTH_PX = 7;\nconst STUFF_LABEL_PADDING = 48;\nconst MIN_STUFF_WIDTH = 140;\n\n/**\n * Build dataflow graph from GraphSpec. Creates pipe nodes + stuff (data) nodes +\n * producer/consumer edges. Returns label descriptors (not React elements).\n */\nexport function buildDataflowGraph(\n graphspec: GraphSpec,\n analysis: DataflowAnalysis,\n edgeType: string,\n): GraphData {\n const nodes: GraphNode[] = [];\n const edges: GraphEdge[] = [];\n\n // Find participating pipes (those that produce or consume data)\n const participatingPipes = new Set<string>();\n for (const producer of Object.values(analysis.stuffProducers)) {\n participatingPipes.add(producer);\n }\n for (const consumers of Object.values(analysis.stuffConsumers)) {\n for (const consumer of consumers) {\n participatingPipes.add(consumer);\n }\n }\n\n // Create pipe nodes (only those that participate in data flow)\n for (const node of graphspec.nodes) {\n if (!participatingPipes.has(node.id)) continue;\n\n const isFailed = node.status === \"failed\";\n const label = node.pipe_code || node.id.split(\":\").pop() || node.id;\n const pipeCardData = buildPipeCardPayload(node, graphspec, analysis);\n\n nodes.push({\n id: node.id,\n type: NODE_TYPE_PIPE_CARD,\n data: {\n labelDescriptor: { kind: \"pipe\", label, isFailed },\n nodeData: node,\n isPipe: true,\n isStuff: false,\n labelText: label,\n pipeCode: pipeCardData.pipeCode,\n pipeType: node.pipe_type,\n pipeCardData,\n },\n position: { x: 0, y: 0 },\n });\n }\n\n // Create stuff (data) nodes\n for (const [digest, stuffInfo] of Object.entries(analysis.stuffRegistry)) {\n const stuffId = stuffNodeId(digest);\n const label = stuffInfo.name || \"data\";\n const concept = stuffInfo.concept || \"\";\n const textWidth =\n Math.max(label.length, concept.length) * STUFF_CHAR_WIDTH_PX + STUFF_LABEL_PADDING;\n const stuffWidth = Math.max(MIN_STUFF_WIDTH, textWidth);\n\n // Classify: input (no producer), output (no consumer), or intermediate\n const isInput = !analysis.stuffProducers[digest];\n const isOutput = !isInput && !analysis.stuffConsumers[digest]?.length;\n const stuffRole = isInput ? (\"input\" as const) : isOutput ? (\"output\" as const) : undefined;\n\n const borderColor = isInput\n ? \"var(--color-stuff-input-border, #50FA7B)\"\n : isOutput\n ? \"var(--color-stuff-output-border, #a78bfa)\"\n : \"var(--color-stuff-border)\";\n\n nodes.push({\n id: stuffId,\n type: NODE_TYPE_STUFF,\n data: {\n labelDescriptor: { kind: \"stuff\", label, concept },\n isStuff: true,\n isPipe: false,\n labelText: label,\n stuffRole,\n stuffDigest: digest,\n },\n position: { x: 0, y: 0 },\n style: {\n background: \"var(--color-stuff-bg)\",\n border: `2px solid ${borderColor}`,\n borderRadius: \"999px\",\n padding: \"0\",\n width: stuffWidth + \"px\",\n boxShadow: \"var(--shadow-md)\",\n },\n });\n }\n\n // Create edges: producer -> stuff\n let edgeId = 0;\n for (const [digest, producerNodeId] of Object.entries(analysis.stuffProducers)) {\n const stuffId = stuffNodeId(digest);\n edges.push({\n id: \"edge_\" + edgeId++,\n source: producerNodeId,\n target: stuffId,\n type: edgeType,\n animated: false,\n style: { stroke: \"var(--color-edge)\", strokeWidth: 2 },\n markerEnd: {\n type: ARROW_CLOSED_MARKER,\n color: \"var(--color-edge)\",\n },\n });\n }\n\n // Create edges: stuff -> consumer\n for (const [digest, consumers] of Object.entries(analysis.stuffConsumers)) {\n const stuffId = stuffNodeId(digest);\n for (const consumerNodeId of consumers) {\n edges.push({\n id: \"edge_\" + edgeId++,\n source: stuffId,\n target: consumerNodeId,\n type: edgeType,\n animated: false,\n style: { stroke: \"var(--color-edge)\", strokeWidth: 2 },\n markerEnd: {\n type: ARROW_CLOSED_MARKER,\n color: \"var(--color-edge)\",\n },\n });\n }\n }\n\n // Create PARALLEL_COMBINE edges from GraphSpec\n for (const edge of graphspec.edges) {\n if (edge.kind !== \"parallel_combine\") continue;\n if (!edge.source_stuff_digest || !edge.target_stuff_digest) continue;\n if (\n !analysis.stuffRegistry[edge.source_stuff_digest] ||\n !analysis.stuffRegistry[edge.target_stuff_digest]\n )\n continue;\n const sourceId = stuffNodeId(edge.source_stuff_digest);\n const targetId = stuffNodeId(edge.target_stuff_digest);\n\n edges.push({\n id: edge.id || \"edge_\" + edgeId++,\n source: sourceId,\n target: targetId,\n type: \"smoothstep\",\n animated: false,\n style: {\n stroke: \"var(--color-parallel-combine)\",\n strokeWidth: 2,\n strokeDasharray: \"5,5\",\n },\n markerEnd: {\n type: ARROW_CLOSED_MARKER,\n color: \"var(--color-parallel-combine)\",\n },\n });\n }\n\n // Create BATCH_ITEM and BATCH_AGGREGATE edges (data-centric mode: stuff -> stuff)\n for (const edge of graphspec.edges) {\n if (edge.kind !== \"batch_item\" && edge.kind !== \"batch_aggregate\") continue;\n\n if (!edge.source_stuff_digest || !edge.target_stuff_digest) continue;\n if (\n !analysis.stuffRegistry[edge.source_stuff_digest] ||\n !analysis.stuffRegistry[edge.target_stuff_digest]\n )\n continue;\n const sourceId = stuffNodeId(edge.source_stuff_digest);\n const targetId = stuffNodeId(edge.target_stuff_digest);\n const isBatchItem = edge.kind === \"batch_item\";\n\n edges.push({\n id: edge.id || \"edge_\" + edgeId++,\n source: sourceId,\n target: targetId,\n type: edgeType,\n animated: false,\n _batchEdge: true,\n label: edge.label || \"\",\n labelStyle: {\n fontSize: \"10px\",\n fontFamily: \"var(--font-mono)\",\n fill: isBatchItem ? \"var(--color-batch-item)\" : \"var(--color-batch-aggregate)\",\n },\n labelBgStyle: { fill: \"var(--color-bg)\", fillOpacity: 0.9 },\n style: {\n stroke: isBatchItem ? \"var(--color-batch-item)\" : \"var(--color-batch-aggregate)\",\n strokeWidth: 2,\n strokeDasharray: \"5,5\",\n },\n markerEnd: {\n type: ARROW_CLOSED_MARKER,\n color: isBatchItem ? \"var(--color-batch-item)\" : \"var(--color-batch-aggregate)\",\n },\n });\n }\n\n // Mark edges that cross between different sibling controller groups\n const childToCtrl = buildChildToControllerMap(graphspec, analysis);\n // and assign per-class edge types for better routing\n for (const edge of edges) {\n const srcCtrl = childToCtrl[edge.source] || null;\n const tgtCtrl = childToCtrl[edge.target] || null;\n if (srcCtrl && tgtCtrl && srcCtrl !== tgtCtrl) {\n edge._crossGroup = true;\n // Keep bezier for long-distance cross-group edges (natural curves look better)\n // but visually de-emphasize to reduce spaghetti effect\n edge.style = {\n ...edge.style,\n strokeWidth: 1.5,\n opacity: 0.65,\n };\n }\n }\n\n // Batch edges: keep bezier but visually differentiate\n for (const edge of edges) {\n if (edge._batchEdge) {\n edge.style = {\n ...edge.style,\n opacity: 0.7,\n };\n }\n }\n\n return { nodes, edges };\n}\n\n/**\n * Build graph from GraphSpec using dataflow mode.\n * Returns the built graph data and analysis.\n */\nexport function buildGraph(\n graphspec: GraphSpec | null,\n edgeType: string,\n): { graphData: GraphData; analysis: DataflowAnalysis | null } {\n if (graphspec) {\n const analysis = buildDataflowAnalysis(graphspec);\n if (\n analysis &&\n (Object.keys(analysis.stuffProducers).length > 0 ||\n Object.keys(analysis.stuffConsumers).length > 0)\n ) {\n return { graphData: buildDataflowGraph(graphspec, analysis, edgeType), analysis };\n }\n }\n return { graphData: { nodes: [], edges: [] }, analysis: null };\n}\n","import type {\n DataflowAnalysis,\n FoldToggleOptions,\n GraphData,\n GraphEdge,\n GraphNode,\n GraphSpec,\n GraphSpecNode,\n} from \"./types\";\nimport {\n ARROW_CLOSED_MARKER,\n NODE_TYPE_PIPE_CARD,\n isStuffNodeId,\n stuffDigestFromId,\n} from \"./types\";\nimport { buildChildToControllerMap } from \"./graphAnalysis\";\nimport { buildPipeCardPayload } from \"./pipeCardPayload\";\n\n/**\n * Find every controller that shares the same `pipe_code` as `controllerId` —\n * the \"cousins\" of the clicked controller (other instances of the same pipe,\n * possibly living in different branches of the graph).\n *\n * The result always includes `controllerId` itself. If the controller has no\n * `pipe_code` or no cousins exist, returns a singleton set.\n *\n * Used by GraphViewer to mirror fold/expand actions across all instances of a\n * pipe — the default behavior — while alt/option-click bypasses cousin lookup\n * and toggles only the clicked controller.\n */\nexport function findCousinControllers(\n controllerId: string,\n graphspec: GraphSpec,\n controllerNodeIds: ReadonlySet<string>,\n): Set<string> {\n const result = new Set<string>([controllerId]);\n const clicked = graphspec.nodes.find((n) => n.id === controllerId);\n const pipeCode = clicked?.pipe_code;\n if (!pipeCode) return result;\n for (const node of graphspec.nodes) {\n if (node.pipe_code !== pipeCode) continue;\n if (!controllerNodeIds.has(node.id)) continue;\n result.add(node.id);\n }\n return result;\n}\n\n/**\n * Walk the containment chain from `nodeId` upward, returning the ordered list of\n * ancestor controller IDs from immediate parent → root.\n */\nexport function buildContainmentChain(\n nodeId: string,\n childToCtrl: Readonly<Record<string, string>>,\n): string[] {\n const chain: string[] = [];\n let current: string | undefined = childToCtrl[nodeId];\n const seen = new Set<string>();\n while (current && !seen.has(current)) {\n chain.push(current);\n seen.add(current);\n current = childToCtrl[current];\n }\n return chain;\n}\n\n/**\n * Find the **outermost** (closest to root) ancestor of `nodeId` whose ID is in\n * `foldedSet`. Returns `null` if no ancestor is folded.\n */\nexport function outermostFoldedAncestor(\n nodeId: string,\n childToCtrl: Readonly<Record<string, string>>,\n foldedSet: ReadonlySet<string>,\n): string | null {\n const chain = buildContainmentChain(nodeId, childToCtrl);\n let outermost: string | null = null;\n for (const ancestorId of chain) {\n if (foldedSet.has(ancestorId)) outermost = ancestorId;\n }\n return outermost;\n}\n\n/**\n * Effective ID after folding: returns the outermost folded ancestor if one\n * exists; otherwise the node itself.\n */\nfunction effectiveId(\n nodeId: string,\n childToCtrl: Readonly<Record<string, string>>,\n foldedSet: ReadonlySet<string>,\n): string {\n return outermostFoldedAncestor(nodeId, childToCtrl, foldedSet) ?? nodeId;\n}\n\nfunction findSpecNode(graphspec: GraphSpec, id: string): GraphSpecNode | undefined {\n return graphspec.nodes.find((n) => n.id === id);\n}\n\n/**\n * Apply the fold transformation to a dataflow graph.\n *\n * For each controller in `foldedSet` that is not itself inside another folded\n * controller (outermost-wins): emit a single `pipe-card` node carrying the\n * controller's payload, and rewrite/dedup edges so the controller card replaces\n * its hidden descendants.\n *\n * The function is pure — inputs are not mutated; a fresh `{ nodes, edges,\n * analysis }` is returned.\n */\nexport function applyFolds(\n graphData: GraphData,\n analysis: DataflowAnalysis,\n graphspec: GraphSpec,\n foldedSet: ReadonlySet<string>,\n onToggleFold?: (controllerId: string, options?: FoldToggleOptions) => void,\n): { nodes: GraphNode[]; edges: GraphEdge[]; analysis: DataflowAnalysis } {\n if (foldedSet.size === 0) {\n return { nodes: graphData.nodes, edges: graphData.edges, analysis };\n }\n\n const childToCtrl = buildChildToControllerMap(graphspec, analysis);\n\n // ─── Promote declared-output stuffs out of folded controllers ───────────\n // A folded controller's pipe-card represents the controller as a whole, and\n // its declared outputs are external data flowing out of it. If a stuff node\n // currently lives inside a folded controller that declares it as an output,\n // moving the stuff outside lets the folded card connect to it just like\n // before the fold. Without this, the stuff would be hidden alongside the\n // controller's internals, and the output edge would collapse to a self-loop.\n const outputDeclarers: Map<string, Set<string>> = new Map();\n for (const controllerId of foldedSet) {\n const ctrlNode = findSpecNode(graphspec, controllerId);\n const outputs = ctrlNode?.io?.outputs;\n if (!outputs) continue;\n for (const output of outputs) {\n if (!output.digest) continue;\n let set = outputDeclarers.get(output.digest);\n if (!set) {\n set = new Set();\n outputDeclarers.set(output.digest, set);\n }\n set.add(controllerId);\n }\n }\n\n if (outputDeclarers.size > 0) {\n for (const node of graphData.nodes) {\n if (!isStuffNodeId(node.id)) continue;\n const declarers = outputDeclarers.get(stuffDigestFromId(node.id));\n if (!declarers) continue;\n\n // Walk the chain to find the outermost folded ancestor that declares this\n // stuff as one of its outputs. Reparenting to that ancestor's parent\n // (which may itself be folded or root) ensures the stuff escapes the fold.\n let current: string | undefined = childToCtrl[node.id];\n let outermostDeclarer: string | null = null;\n const seen = new Set<string>();\n while (current && !seen.has(current)) {\n seen.add(current);\n if (declarers.has(current)) outermostDeclarer = current;\n current = childToCtrl[current];\n }\n if (!outermostDeclarer) continue;\n\n const newParent = childToCtrl[outermostDeclarer];\n if (newParent) {\n childToCtrl[node.id] = newParent;\n } else {\n delete childToCtrl[node.id];\n }\n }\n }\n\n // ─── Filter visible nodes ───────────────────────────────────────────────\n // Drop any node whose outermost folded ancestor is non-null (it's hidden\n // inside a folded controller).\n const visibleNodes: GraphNode[] = [];\n for (const node of graphData.nodes) {\n if (outermostFoldedAncestor(node.id, childToCtrl, foldedSet)) continue;\n visibleNodes.push(node);\n }\n\n // ─── Emit pipe-card nodes for outermost-folded controllers ──────────────\n for (const folded of foldedSet) {\n // Skip if this folded controller is itself inside another folded ancestor.\n if (outermostFoldedAncestor(folded, childToCtrl, foldedSet)) continue;\n const specNode = findSpecNode(graphspec, folded);\n if (!specNode) continue; // unknown ID — silently ignore\n\n const payload = buildPipeCardPayload(specNode, graphspec, analysis);\n if (onToggleFold) {\n payload.onExpand = (options?: FoldToggleOptions) => onToggleFold(folded, options);\n }\n\n const cardNode: GraphNode = {\n id: folded,\n type: NODE_TYPE_PIPE_CARD,\n data: {\n labelDescriptor: {\n kind: \"pipe\",\n label: payload.pipeCode,\n isFailed: payload.status === \"failed\",\n },\n nodeData: specNode,\n isPipe: false,\n isStuff: false,\n isController: true,\n labelText: payload.pipeCode,\n pipeCode: payload.pipeCode,\n pipeType: specNode.pipe_type,\n pipeCardData: payload,\n },\n position: { x: 0, y: 0 },\n };\n visibleNodes.push(cardNode);\n }\n\n // ─── Build updated analysis ─────────────────────────────────────────────\n // Drop folded controllers and any controller that lives inside a folded\n // outermost ancestor.\n const updatedControllerIds = new Set<string>();\n for (const ctrlId of analysis.controllerNodeIds) {\n if (foldedSet.has(ctrlId)) continue;\n if (outermostFoldedAncestor(ctrlId, childToCtrl, foldedSet)) continue;\n updatedControllerIds.add(ctrlId);\n }\n\n // containmentTree: only keep entries for surviving controllers; filter their\n // children to drop hidden ones (children whose outermost folded ancestor is\n // a different controller). Children that are the folded controllers themselves\n // should remain as children (they now render as pipe-card leaves).\n const updatedContainmentTree: Record<string, string[]> = {};\n for (const ctrlId of updatedControllerIds) {\n const originalChildren = analysis.containmentTree[ctrlId] ?? [];\n const survivors: string[] = [];\n for (const childId of originalChildren) {\n const outer = outermostFoldedAncestor(childId, childToCtrl, foldedSet);\n // If the child has a folded outermost ancestor that is NOT itself, drop.\n // If the child IS the folded outermost (childId is in foldedSet), keep —\n // it will appear as a pipe-card child of this controller.\n if (outer && outer !== childId) continue;\n survivors.push(childId);\n }\n updatedContainmentTree[ctrlId] = survivors;\n }\n\n // childNodeIds: rebuild from the updated containment tree.\n const updatedChildNodeIds = new Set<string>();\n for (const children of Object.values(updatedContainmentTree)) {\n for (const child of children) updatedChildNodeIds.add(child);\n }\n\n // Rewrite stuffProducers/stuffConsumers so any reference to an operator hidden\n // by a fold is replaced with its outermost folded ancestor — mirroring the\n // edge-endpoint rewrite below. Without this, buildChildToControllerMap's\n // promotion loop loses the consumer/producer trail and stuff nodes get\n // ejected to the root level when their parent controller's sibling is folded.\n const updatedStuffProducers: Record<string, string> = {};\n for (const [digest, producerId] of Object.entries(analysis.stuffProducers)) {\n updatedStuffProducers[digest] = effectiveId(producerId, childToCtrl, foldedSet);\n }\n\n const updatedStuffConsumers: Record<string, string[]> = {};\n for (const [digest, consumers] of Object.entries(analysis.stuffConsumers)) {\n const seen = new Set<string>();\n for (const consumerId of consumers) {\n seen.add(effectiveId(consumerId, childToCtrl, foldedSet));\n }\n updatedStuffConsumers[digest] = [...seen];\n }\n\n const updatedAnalysis: DataflowAnalysis = {\n stuffRegistry: analysis.stuffRegistry,\n stuffProducers: updatedStuffProducers,\n stuffConsumers: updatedStuffConsumers,\n controllerNodeIds: updatedControllerIds,\n childNodeIds: updatedChildNodeIds,\n containmentTree: updatedContainmentTree,\n };\n\n // ─── Rewrite edges ──────────────────────────────────────────────────────\n // Each surviving endpoint is replaced by its effective (outermost-folded)\n // ancestor or itself. Drop self-loops. Dedup by (newSrc, newDst, bucket).\n const dedupMap = new Map<string, GraphEdge>();\n for (const edge of graphData.edges) {\n const newSrc = effectiveId(edge.source, childToCtrl, foldedSet);\n const newDst = effectiveId(edge.target, childToCtrl, foldedSet);\n if (newSrc === newDst) continue;\n const bucket = edge._batchEdge ? \"batch\" : \"data\";\n const key = `${newSrc}->${newDst}|${bucket}`;\n if (dedupMap.has(key)) continue;\n // Clone the edge with rewritten endpoints; drop the stale _crossGroup flag\n // (recomputed below against folded containment).\n const cloned: GraphEdge = {\n ...edge,\n source: newSrc,\n target: newDst,\n id: edge.id,\n };\n // Batch edges carry per-item indices like \"[0]\", \"[1]\" in their labels.\n // Once a fold collapses many of these into a single edge (or hides the\n // per-item target), the surviving index is misleading — generalize to \"[N]\".\n if (edge._batchEdge && (newSrc !== edge.source || newDst !== edge.target)) {\n cloned.label = \"[N]\";\n }\n delete cloned._crossGroup;\n dedupMap.set(key, cloned);\n }\n\n // Recompute _crossGroup against the folded containment. Build a fresh\n // childToCtrl from the updated analysis so the classification reflects the\n // post-fold node graph (folded controllers no longer have children).\n const foldedChildToCtrl = buildChildToControllerMap(\n {\n ...graphspec,\n // Mask out the contains edges for folded outermost controllers — they no\n // longer logically contain anything after folding.\n edges: graphspec.edges.filter((e) => {\n if (e.kind !== \"contains\") return true;\n return updatedControllerIds.has(e.source);\n }),\n },\n updatedAnalysis,\n );\n\n const rewrittenEdges: GraphEdge[] = [];\n for (const edge of dedupMap.values()) {\n const srcCtrl = foldedChildToCtrl[edge.source] || null;\n const tgtCtrl = foldedChildToCtrl[edge.target] || null;\n if (srcCtrl && tgtCtrl && srcCtrl !== tgtCtrl) {\n edge._crossGroup = true;\n edge.style = {\n ...edge.style,\n strokeWidth: 1.5,\n opacity: 0.65,\n };\n } else if (edge.style && (edge.style.opacity === 0.65 || edge.style.strokeWidth === 1.5)) {\n // Edge no longer crosses sibling groups — reset the de-emphasized style.\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n const { opacity: _opacity, strokeWidth: _strokeWidth, ...rest } = edge.style;\n edge.style = { ...rest, strokeWidth: 2 };\n if (!edge.markerEnd) {\n edge.markerEnd = { type: ARROW_CLOSED_MARKER, color: \"var(--color-edge)\" };\n }\n }\n rewrittenEdges.push(edge);\n }\n\n return { nodes: visibleNodes, edges: rewrittenEdges, analysis: updatedAnalysis };\n}\n","import type { ElkNode, ElkPort, ElkExtendedEdge, LayoutOptions } from \"elkjs/lib/elk-api\";\nimport type {\n GraphNode,\n GraphEdge,\n GraphSpec,\n DataflowAnalysis,\n LayoutConfig,\n GraphDirection,\n} from \"./types\";\nimport {\n NODE_TYPE_PIPE_CARD,\n CONTROLLER_PADDING_X,\n CONTROLLER_PADDING_TOP,\n CONTROLLER_PADDING_BOTTOM,\n} from \"./types\";\nimport { buildChildToControllerMap } from \"./graphAnalysis\";\n\n// ─── Direction mapping ──────────────────────────────────────────────────────\n\nfunction elkDirection(direction: GraphDirection): string {\n switch (direction) {\n case \"LR\":\n return \"RIGHT\";\n case \"RL\":\n return \"LEFT\";\n case \"BT\":\n return \"UP\";\n default:\n return \"DOWN\"; // TB\n }\n}\n\n// ─── Port helpers ───────────────────────────────────────────────────────────\n\nconst INPUT_PORT_SUFFIX = \"_in\";\nconst OUTPUT_PORT_SUFFIX = \"_out\";\n\nexport function inputPortId(nodeId: string): string {\n return nodeId + INPUT_PORT_SUFFIX;\n}\n\nexport function outputPortId(nodeId: string): string {\n return nodeId + OUTPUT_PORT_SUFFIX;\n}\n\nfunction makePorts(nodeId: string, dims: NodeDimensions, direction: GraphDirection): ElkPort[] {\n // Port sides must match the flow direction so ELK computes edge attachment\n // on the same side that ReactFlow renders handles.\n // LR: input=WEST, output=EAST | RL: input=EAST, output=WEST\n // TB: input=NORTH, output=SOUTH | BT: input=SOUTH, output=NORTH\n const portSides: Record<GraphDirection, { inSide: string; outSide: string }> = {\n LR: { inSide: \"WEST\", outSide: \"EAST\" },\n RL: { inSide: \"EAST\", outSide: \"WEST\" },\n TB: { inSide: \"NORTH\", outSide: \"SOUTH\" },\n BT: { inSide: \"SOUTH\", outSide: \"NORTH\" },\n };\n const { inSide, outSide } = portSides[direction];\n\n const isHorizontal = direction === \"LR\" || direction === \"RL\";\n // Pin ports at the exact center of each side so ELK computes layout\n // with the same edge attachment point that ReactFlow will render.\n const inX = isHorizontal ? (direction === \"LR\" ? 0 : dims.width) : dims.width / 2;\n const inY = isHorizontal ? dims.height / 2 : direction === \"TB\" ? 0 : dims.height;\n const outX = isHorizontal ? (direction === \"LR\" ? dims.width : 0) : dims.width / 2;\n const outY = isHorizontal ? dims.height / 2 : direction === \"TB\" ? dims.height : 0;\n\n return [\n {\n id: inputPortId(nodeId),\n x: inX,\n y: inY,\n width: 1,\n height: 1,\n layoutOptions: { \"elk.port.side\": inSide },\n },\n {\n id: outputPortId(nodeId),\n x: outX,\n y: outY,\n width: 1,\n height: 1,\n layoutOptions: { \"elk.port.side\": outSide },\n },\n ];\n}\n\n// ─── Node dimension estimation ──────────────────────────────────────────────\n// ELK needs dimensions upfront to compute layout.\n\ninterface NodeDimensions {\n width: number;\n height: number;\n}\n\n// ─── Pipe card layout constants (keep in sync with graph-core.css) ──────────\n// If you change these, update the matching rules in graph-core.css.\nconst PIPE_CARD_HEIGHT_CAP = 320;\n\n// Horizontal padding (12 + 12 = 24) + vertical padding (12 + 12 = 24)\nconst PIPE_CARD_PADDING_X = 28; // padding-left + padding-right (14 + 14)\nconst PIPE_CARD_PADDING_Y = 24; // padding-top + padding-bottom (12 + 12)\nconst PIPE_CARD_GAP = 8; // gap between flex children (header / description / io sections)\n\n// Header: badge (~20px) + code line with status dot\nconst PIPE_CARD_HEADER_HEIGHT = 22;\n\n// Description: 11.5px font × 1.4 line-height ≈ 16.1px per line\nconst PIPE_CARD_DESC_LINE_HEIGHT = 16;\nconst PIPE_CARD_DESC_MAX_LINES_LR = 3;\n\n// I/O section heights (label + first row of pills)\nconst PIPE_CARD_IO_SECTION_HEIGHT_LR = 38; // stacked: label on top, pills below\nconst PIPE_CARD_IO_SECTION_HEIGHT_TB = 30; // inline: label on left, pills on right\nconst PIPE_CARD_IO_EXTRA_ROW_HEIGHT = 22; // each additional wrapping row of pills\n\n// Pill dimension caps (keep in sync with .pipe-card--tb .pipe-card-io-pill-name/concept max-width)\nconst PIPE_CARD_PILL_NAME_MAX_WIDTH = 140;\nconst PIPE_CARD_PILL_CONCEPT_MAX_WIDTH = 100;\nconst PIPE_CARD_PILL_CHROME_WIDTH = 17; // pill padding (10) + name/concept gap (3) + inter-pill gap (4)\nconst PIPE_CARD_IO_LABEL_WIDTH_TB = 58; // min-width 52 + gap 6\n\n// Character width estimates for Inter font\nconst CHAR_WIDTH_DESC = 5.5; // 11.5px font\nconst CHAR_WIDTH_PILL_NAME = 5.0; // 10px font (pill-name)\nconst CHAR_WIDTH_PILL_CONCEPT = 4.5; // 9px font (pill-concept)\n\nconst MAX_VISIBLE_INPUTS = 4;\n\n/** Estimate how many lines the description will wrap to, given direction + text length. */\nfunction estimateDescriptionLines(\n description: string,\n isHorizontal: boolean,\n cardWidth: number,\n): number {\n if (!description) return 0;\n if (!isHorizontal) return 1; // TB always clamps to 1 line (CSS handles ellipsis)\n const textWidth = cardWidth - PIPE_CARD_PADDING_X;\n const charsPerLine = Math.max(1, Math.floor(textWidth / CHAR_WIDTH_DESC));\n const neededLines = Math.ceil(description.length / charsPerLine);\n return Math.min(PIPE_CARD_DESC_MAX_LINES_LR, Math.max(1, neededLines));\n}\n\n/** Estimate the rendered width of a single pill in TB mode. */\nfunction estimateTbPillWidth(name: string, concept: string): number {\n const nameWidth = Math.min(\n PIPE_CARD_PILL_NAME_MAX_WIDTH,\n Math.ceil(name.length * CHAR_WIDTH_PILL_NAME),\n );\n const conceptWidth = Math.min(\n PIPE_CARD_PILL_CONCEPT_MAX_WIDTH,\n Math.ceil(concept.length * CHAR_WIDTH_PILL_CONCEPT),\n );\n return nameWidth + conceptWidth + PIPE_CARD_PILL_CHROME_WIDTH;\n}\n\n/** Count how many wrapping rows a set of pills will occupy in TB mode.\n * Uses a simple first-fit bin-packing against the available pill area width.\n */\nfunction countTbPillRows(\n pills: readonly { name: string; concept: string }[],\n cardWidth: number,\n): number {\n if (pills.length === 0) return 0;\n const availableWidth = cardWidth - PIPE_CARD_PADDING_X - PIPE_CARD_IO_LABEL_WIDTH_TB;\n let rows = 1;\n let currentRowWidth = 0;\n for (const pill of pills) {\n const pillWidth = estimateTbPillWidth(pill.name, pill.concept);\n if (currentRowWidth === 0) {\n currentRowWidth = pillWidth;\n continue;\n }\n if (currentRowWidth + pillWidth <= availableWidth) {\n currentRowWidth += pillWidth;\n } else {\n rows += 1;\n currentRowWidth = pillWidth;\n }\n }\n return rows;\n}\n\nexport function estimateNodeDimensions(node: GraphNode, isHorizontal: boolean): NodeDimensions {\n const nodeData = node.data || {};\n const isStuff = nodeData.isStuff;\n const labelText = nodeData.labelText || \"\";\n const isPipeCard = node.type === NODE_TYPE_PIPE_CARD;\n\n const pipeCardMinWidth = isHorizontal ? 180 : 280;\n const pipeCardMaxWidth = isHorizontal ? 240 : 400;\n // Stuff nodes are visually aligned with pipe cards — they must never be wider\n // than the pipe card max for the current direction, otherwise the graph looks\n // lopsided (a 400px stuff node next to a 240px pipe card in LR mode).\n const estimatedWidth = Math.max(180, Math.min(pipeCardMaxWidth, labelText.length * 8 + 60));\n\n let width: number;\n if (isStuff) {\n width = Math.max(180, estimatedWidth);\n } else if (isPipeCard && nodeData.pipeCardData) {\n width = pipeCardMaxWidth;\n } else {\n width = Math.max(isPipeCard ? pipeCardMinWidth : 200, estimatedWidth);\n }\n\n let height: number;\n if (isStuff) {\n height = 60;\n } else if (isPipeCard && nodeData.pipeCardData) {\n const pcd = nodeData.pipeCardData;\n const inputs = pcd.inputs ?? [];\n const outputs = pcd.outputs ?? [];\n const description = pcd.description || nodeData.nodeData?.description || \"\";\n\n // Header\n let total = PIPE_CARD_PADDING_Y + PIPE_CARD_HEADER_HEIGHT;\n\n // Description: actual lines needed\n const descLines = estimateDescriptionLines(description, isHorizontal, width);\n if (descLines > 0) {\n total += PIPE_CARD_GAP + descLines * PIPE_CARD_DESC_LINE_HEIGHT;\n }\n\n // Inputs — cap visible to MAX_VISIBLE_INPUTS (rest collapses behind \"+N more\")\n const visibleInputs = inputs.slice(0, MAX_VISIBLE_INPUTS);\n if (visibleInputs.length > 0) {\n total += PIPE_CARD_GAP;\n if (isHorizontal) {\n // LR: one pill per row, always stacked\n total +=\n PIPE_CARD_IO_SECTION_HEIGHT_LR +\n (visibleInputs.length - 1) * PIPE_CARD_IO_EXTRA_ROW_HEIGHT;\n } else {\n // TB: bin-pack pills horizontally, each extra row adds height\n const rows = countTbPillRows(visibleInputs, width);\n total += PIPE_CARD_IO_SECTION_HEIGHT_TB + (rows - 1) * PIPE_CARD_IO_EXTRA_ROW_HEIGHT;\n }\n }\n\n // Outputs — same logic as inputs\n if (outputs.length > 0) {\n total += PIPE_CARD_GAP;\n if (isHorizontal) {\n total +=\n PIPE_CARD_IO_SECTION_HEIGHT_LR + (outputs.length - 1) * PIPE_CARD_IO_EXTRA_ROW_HEIGHT;\n } else {\n const rows = countTbPillRows(outputs, width);\n total += PIPE_CARD_IO_SECTION_HEIGHT_TB + (rows - 1) * PIPE_CARD_IO_EXTRA_ROW_HEIGHT;\n }\n }\n\n height = Math.min(PIPE_CARD_HEIGHT_CAP, total);\n } else {\n height = isPipeCard ? 120 : 70;\n }\n\n return { width, height };\n}\n\n// ─── Controller nesting depth ───────────────────────────────────────────────\n\nfunction computeDepths(\n controllerNodeIds: ReadonlySet<string>,\n containmentTree: Readonly<Record<string, readonly string[]>>,\n): Record<string, number> {\n const depthCache: Record<string, number> = {};\n const visiting = new Set<string>();\n\n function getDepth(ctrlId: string): number {\n if (depthCache[ctrlId] !== undefined) return depthCache[ctrlId];\n if (visiting.has(ctrlId)) return 0;\n visiting.add(ctrlId);\n const children = containmentTree[ctrlId] || [];\n let maxChildDepth = -1;\n for (const childId of children) {\n if (controllerNodeIds.has(childId)) {\n maxChildDepth = Math.max(maxChildDepth, getDepth(childId));\n }\n }\n visiting.delete(ctrlId);\n depthCache[ctrlId] = maxChildDepth + 1;\n return depthCache[ctrlId];\n }\n\n for (const id of controllerNodeIds) getDepth(id);\n return depthCache;\n}\n\n// ─── Leaf node builder ──────────────────────────────────────────────────────\n\nfunction makeLeafNode(nodeId: string, dims: NodeDimensions, direction: GraphDirection): ElkNode {\n return {\n id: nodeId,\n width: dims.width,\n height: dims.height,\n ports: makePorts(nodeId, dims, direction),\n layoutOptions: {\n \"elk.portConstraints\": \"FIXED_POS\",\n },\n };\n}\n\n// ─── Build ELK graph ────────────────────────────────────────────────────────\n\nexport function buildElkGraph(\n nodes: GraphNode[],\n edges: GraphEdge[],\n graphspec: GraphSpec | null,\n analysis: DataflowAnalysis | null,\n direction: GraphDirection,\n layoutConfig?: LayoutConfig,\n): { elkGraph: ElkNode; dimensionMap: Record<string, NodeDimensions> } {\n const isHorizontal = direction === \"LR\" || direction === \"RL\";\n const nodesep = layoutConfig?.nodesep ?? 80;\n const ranksep = layoutConfig?.ranksep ?? 70;\n const elkDir = elkDirection(direction);\n\n const edgeNodeSpacing = \"30\";\n\n const rootLayoutOptions: LayoutOptions = {\n \"elk.algorithm\": \"layered\",\n \"elk.direction\": elkDir,\n \"elk.hierarchyHandling\": \"INCLUDE_CHILDREN\",\n \"elk.spacing.nodeNode\": String(nodesep),\n \"elk.layered.spacing.nodeNodeBetweenLayers\": String(ranksep),\n \"elk.spacing.edgeNode\": edgeNodeSpacing,\n \"elk.spacing.edgeEdge\": \"20\",\n \"elk.layered.spacing.edgeNodeBetweenLayers\": edgeNodeSpacing,\n \"elk.layered.spacing.edgeEdgeBetweenLayers\": \"15\",\n \"elk.layered.nodePlacement.favorStraightEdges\": \"true\",\n };\n\n // Fast path: no hierarchy info → flat layout\n if (!graphspec || !analysis || analysis.controllerNodeIds.size === 0) {\n const dimensionMap: Record<string, NodeDimensions> = {};\n const elkChildren: ElkNode[] = nodes.map((node) => {\n const dims = estimateNodeDimensions(node, isHorizontal);\n dimensionMap[node.id] = dims;\n return makeLeafNode(node.id, dims, direction);\n });\n\n const elkEdges: ElkExtendedEdge[] = edges.map((edge) => ({\n id: edge.id,\n sources: [outputPortId(edge.source)],\n targets: [inputPortId(edge.target)],\n }));\n\n return {\n elkGraph: {\n id: \"root\",\n layoutOptions: rootLayoutOptions,\n children: elkChildren,\n edges: elkEdges,\n },\n dimensionMap,\n };\n }\n\n // Hierarchical layout: build tree from containment analysis\n const childToCtrl = buildChildToControllerMap(graphspec, analysis);\n const depths = computeDepths(analysis.controllerNodeIds, analysis.containmentTree);\n const dimensionMap: Record<string, NodeDimensions> = {};\n\n // Create a map from node ID to its ELK leaf node\n const nodeById = new Map<string, GraphNode>();\n for (const node of nodes) nodeById.set(node.id, node);\n\n // Build controller compound nodes (bottom-up: leaf controllers first)\n const controllerElkNodes: Record<string, ElkNode> = {};\n const controllerIds = Array.from(analysis.controllerNodeIds);\n controllerIds.sort((a, b) => (depths[a] ?? 0) - (depths[b] ?? 0));\n\n for (const ctrlId of controllerIds) {\n const depth = depths[ctrlId] ?? 0;\n const depthScale = 1 + depth * 0.15;\n const padX = Math.round(CONTROLLER_PADDING_X * depthScale);\n const padTop = Math.round(CONTROLLER_PADDING_TOP * depthScale);\n const padBottom = Math.round(CONTROLLER_PADDING_BOTTOM * depthScale);\n\n const ctrlLayoutOptions: LayoutOptions = {\n \"elk.padding\": `[top=${padTop},left=${padX},bottom=${padBottom},right=${padX}]`,\n \"elk.spacing.nodeNode\": String(nodesep),\n \"elk.layered.spacing.nodeNodeBetweenLayers\": String(ranksep),\n \"elk.spacing.edgeNode\": edgeNodeSpacing,\n \"elk.layered.spacing.edgeNodeBetweenLayers\": edgeNodeSpacing,\n };\n\n const children: ElkNode[] = [];\n const directChildren = analysis.containmentTree[ctrlId] || [];\n\n for (const childId of directChildren) {\n if (analysis.controllerNodeIds.has(childId)) {\n // Child is a controller — use its already-built compound node\n const childElk = controllerElkNodes[childId];\n if (childElk) children.push(childElk);\n } else {\n // Child is an operator — create leaf node with ports\n const graphNode = nodeById.get(childId);\n if (graphNode) {\n const dims = estimateNodeDimensions(graphNode, isHorizontal);\n dimensionMap[childId] = dims;\n children.push(makeLeafNode(childId, dims, direction));\n }\n }\n }\n\n // Add stuff nodes that belong to this controller\n for (const node of nodes) {\n if (node.data.isStuff && childToCtrl[node.id] === ctrlId) {\n if (!children.some((c) => c.id === node.id)) {\n const dims = estimateNodeDimensions(node, isHorizontal);\n dimensionMap[node.id] = dims;\n children.push(makeLeafNode(node.id, dims, direction));\n }\n }\n }\n\n controllerElkNodes[ctrlId] = {\n id: ctrlId,\n layoutOptions: ctrlLayoutOptions,\n children,\n };\n }\n\n // Build root children: top-level controllers + loose nodes\n const rootChildren: ElkNode[] = [];\n\n // Add top-level controllers (those not contained by another controller)\n for (const ctrlId of controllerIds) {\n if (!childToCtrl[ctrlId]) {\n const elkNode = controllerElkNodes[ctrlId];\n if (elkNode) rootChildren.push(elkNode);\n }\n }\n\n // Add loose nodes (not inside any controller and not controllers themselves)\n for (const node of nodes) {\n if (!childToCtrl[node.id] && !analysis.controllerNodeIds.has(node.id)) {\n const dims = estimateNodeDimensions(node, isHorizontal);\n dimensionMap[node.id] = dims;\n rootChildren.push(makeLeafNode(node.id, dims, direction));\n }\n }\n\n // All edges at root level — INCLUDE_CHILDREN handles cross-hierarchy routing\n const nodeIdSet = new Set(nodes.map((n) => n.id));\n const elkEdges: ElkExtendedEdge[] = edges\n .filter((e) => nodeIdSet.has(e.source) && nodeIdSet.has(e.target))\n .map((edge) => ({\n id: edge.id,\n sources: [outputPortId(edge.source)],\n targets: [inputPortId(edge.target)],\n }));\n\n return {\n elkGraph: {\n id: \"root\",\n layoutOptions: rootLayoutOptions,\n children: rootChildren,\n edges: elkEdges,\n },\n dimensionMap,\n };\n}\n\n// ─── Extract absolute positions from ELK output ────────────────────────────\n\nexport interface ElkPositionResult {\n x: number;\n y: number;\n width: number;\n height: number;\n}\n\nexport function extractAbsolutePositions(elkResult: ElkNode): Record<string, ElkPositionResult> {\n const positions: Record<string, ElkPositionResult> = {};\n\n function walk(node: ElkNode, parentX: number, parentY: number) {\n const absX = parentX + (node.x ?? 0);\n const absY = parentY + (node.y ?? 0);\n\n if (node.id !== \"root\") {\n positions[node.id] = {\n x: absX,\n y: absY,\n width: node.width ?? 0,\n height: node.height ?? 0,\n };\n }\n\n for (const child of node.children ?? []) {\n walk(child, absX, absY);\n }\n }\n\n walk(elkResult, 0, 0);\n return positions;\n}\n","import ELK from \"elkjs/lib/elk.bundled.js\";\nimport type {\n GraphNode,\n GraphEdge,\n GraphSpec,\n DataflowAnalysis,\n LayoutConfig,\n GraphDirection,\n} from \"./types\";\nimport { buildElkGraph, extractAbsolutePositions, estimateNodeDimensions } from \"./elkGraphBuilder\";\nimport type { ElkPositionResult } from \"./elkGraphBuilder\";\n\n// Cache ELK instance at module level to avoid repeated WASM initialization\nlet elkInstance: InstanceType<typeof ELK> | null = null;\nfunction getElk(): InstanceType<typeof ELK> {\n if (!elkInstance) elkInstance = new ELK();\n return elkInstance;\n}\n\nexport interface LayoutResult {\n nodes: GraphNode[];\n edges: GraphEdge[];\n /** ELK-computed positions/sizes for controller compound nodes. */\n controllerPositions: Record<string, ElkPositionResult>;\n}\n\nexport async function getLayoutedElements(\n nodes: GraphNode[],\n edges: GraphEdge[],\n direction: GraphDirection,\n layoutConfig?: LayoutConfig,\n graphspec?: GraphSpec | null,\n analysis?: DataflowAnalysis | null,\n): Promise<LayoutResult> {\n if (nodes.length === 0) return { nodes: [], edges, controllerPositions: {} };\n\n const isHorizontal = direction === \"LR\" || direction === \"RL\";\n\n const { elkGraph, dimensionMap } = buildElkGraph(\n nodes,\n edges,\n graphspec ?? null,\n analysis ?? null,\n direction,\n layoutConfig,\n );\n\n const layoutResult = await getElk().layout(elkGraph);\n const positions = extractAbsolutePositions(layoutResult);\n\n // Extract controller positions from ELK output\n const controllerPositions: Record<string, ElkPositionResult> = {};\n if (analysis) {\n for (const ctrlId of analysis.controllerNodeIds) {\n if (positions[ctrlId]) {\n controllerPositions[ctrlId] = positions[ctrlId];\n }\n }\n }\n\n const result = nodes.map((node) => {\n const pos = positions[node.id];\n const dims = dimensionMap[node.id] ?? estimateNodeDimensions(node, isHorizontal);\n\n const width = dims.width;\n const height = dims.height;\n\n // Inject direction into pipeCardData so the card component can adjust orientation\n const pipeCardData = node.data.pipeCardData;\n const cardDirection = isHorizontal ? (\"LR\" as const) : (\"TB\" as const);\n const updatedPipeCardData = pipeCardData\n ? { ...pipeCardData, direction: cardDirection }\n : undefined;\n\n return {\n ...node,\n data: {\n ...node.data,\n _estimatedWidth: width,\n _estimatedHeight: height,\n pipeCardData: updatedPipeCardData,\n },\n // Lock the ReactFlow node wrapper to the exact dimensions ELK used for layout.\n // This ensures ReactFlow's Handle (centered on the DOM element) matches\n // the port position ELK computed (centered on the estimated dimensions).\n style: {\n ...node.style,\n width: width + \"px\",\n height: height + \"px\",\n },\n position: {\n x: pos ? pos.x : 0,\n y: pos ? pos.y : 0,\n },\n sourcePosition: (isHorizontal\n ? direction === \"LR\"\n ? \"right\"\n : \"left\"\n : direction === \"TB\"\n ? \"bottom\"\n : \"top\") as GraphNode[\"sourcePosition\"],\n targetPosition: (isHorizontal\n ? direction === \"LR\"\n ? \"left\"\n : \"right\"\n : direction === \"TB\"\n ? \"top\"\n : \"bottom\") as GraphNode[\"targetPosition\"],\n };\n });\n\n return { nodes: result, edges, controllerPositions };\n}\n","import type {\n GraphSpec,\n DataflowAnalysis,\n FoldToggleOptions,\n GraphNode,\n GraphEdge,\n PipeType,\n} from \"./types\";\nimport {\n CONTROLLER_PADDING_X,\n CONTROLLER_PADDING_TOP,\n CONTROLLER_PADDING_BOTTOM,\n NODE_TYPE_CONTROLLER,\n nodeWidth,\n nodeHeight,\n isStuffNodeId,\n} from \"./types\";\nimport { buildChildToControllerMap } from \"./graphAnalysis\";\n\n/** Max visible children before a parallel/batch controller auto-collapses. */\nexport const MAX_VISIBLE_CONTROLLER_CHILDREN = 5;\n\n/**\n * Collect all descendant node IDs of a controller (recursive).\n */\nfunction getDescendants(\n controllerId: string,\n containmentTree: Readonly<Record<string, readonly string[]>>,\n controllerNodeIds: ReadonlySet<string>,\n): Set<string> {\n const result = new Set<string>();\n const stack = [controllerId];\n while (stack.length > 0) {\n const id = stack.pop()!;\n for (const childId of containmentTree[id] || []) {\n result.add(childId);\n if (controllerNodeIds.has(childId)) stack.push(childId);\n }\n }\n return result;\n}\n\n/** Position and size for a controller, as computed by the layout engine. */\nexport interface ControllerRect {\n x: number;\n y: number;\n width: number;\n height: number;\n}\n\n/**\n * Build controller group nodes that wrap child operators/stuff nodes.\n *\n * When `controllerPositions` is provided (from ELK layout), uses those exact\n * positions/sizes instead of recomputing from child bounding boxes. This ensures\n * controller containers match the layout engine's spacing and edge routing.\n *\n * **Side effect:** mutates `layoutedNodes` entries to set `parentId`, `extent`,\n * and convert positions to parent-relative coordinates.\n */\nexport function buildControllerNodes(\n graphspec: GraphSpec,\n analysis: DataflowAnalysis,\n layoutedNodes: GraphNode[],\n controllerPositions?: Record<string, ControllerRect>,\n): GraphNode[] {\n const nodeById: Record<string, GraphNode> = {};\n for (const n of layoutedNodes) {\n nodeById[n.id] = n;\n }\n\n const controllerInfo: Record<string, GraphSpec[\"nodes\"][number]> = {};\n for (const node of graphspec.nodes) {\n if (analysis.controllerNodeIds.has(node.id)) {\n controllerInfo[node.id] = node;\n }\n }\n\n const depthCache: Record<string, number> = {};\n const depthVisiting = new Set<string>();\n function getDepth(controllerId: string): number {\n if (depthCache[controllerId] !== undefined) return depthCache[controllerId];\n if (depthVisiting.has(controllerId)) {\n throw new Error(\n `Cycle detected in containment tree: controller \"${controllerId}\" is part of a containment cycle`,\n );\n }\n depthVisiting.add(controllerId);\n const children = analysis.containmentTree[controllerId] || [];\n let maxChildDepth = -1;\n for (const childId of children) {\n if (analysis.controllerNodeIds.has(childId)) {\n maxChildDepth = Math.max(maxChildDepth, getDepth(childId));\n }\n }\n depthVisiting.delete(controllerId);\n depthCache[controllerId] = maxChildDepth + 1;\n return depthCache[controllerId];\n }\n\n const childToController = buildChildToControllerMap(graphspec, analysis);\n const controllerStuffChildren: Record<string, string[]> = {};\n for (const [nodeId, ctrlId] of Object.entries(childToController)) {\n if (!isStuffNodeId(nodeId)) continue;\n if (!nodeById[nodeId]) continue;\n if (!controllerStuffChildren[ctrlId]) controllerStuffChildren[ctrlId] = [];\n controllerStuffChildren[ctrlId].push(nodeId);\n }\n\n const controllerIds = Array.from(analysis.controllerNodeIds);\n for (const id of controllerIds) getDepth(id);\n controllerIds.sort((a, b) => depthCache[a] - depthCache[b]);\n\n const controllerNodes: GraphNode[] = [];\n const childToParent: Record<string, string> = {};\n\n for (const controllerId of controllerIds) {\n const directChildren = analysis.containmentTree[controllerId] || [];\n const renderedChildren = directChildren.filter((cid) => nodeById[cid]);\n const stuffChildren = controllerStuffChildren[controllerId] || [];\n const allChildren = [...renderedChildren, ...stuffChildren];\n\n if (allChildren.length === 0) continue;\n\n let groupX: number, groupY: number, groupW: number, groupH: number;\n\n const elkPos = controllerPositions?.[controllerId];\n if (elkPos) {\n // Use ELK's computed position and size — accounts for edge routing and spacing\n groupX = elkPos.x;\n groupY = elkPos.y;\n groupW = elkPos.width;\n groupH = elkPos.height;\n } else {\n // Fallback: compute bounding box from child positions\n let minX = Infinity,\n minY = Infinity,\n maxX = -Infinity,\n maxY = -Infinity;\n for (const childId of allChildren) {\n const child = nodeById[childId];\n const pos = child.position;\n const w = nodeWidth(child);\n const h = nodeHeight(child);\n minX = Math.min(minX, pos.x);\n minY = Math.min(minY, pos.y);\n maxX = Math.max(maxX, pos.x + w);\n maxY = Math.max(maxY, pos.y + h);\n }\n\n const depth = depthCache[controllerId] ?? 0;\n const depthScale = 1 + depth * 0.15;\n const padX = Math.round(CONTROLLER_PADDING_X * depthScale);\n const padTop = Math.round(CONTROLLER_PADDING_TOP * depthScale);\n const padBottom = Math.round(CONTROLLER_PADDING_BOTTOM * depthScale);\n\n groupX = minX - padX;\n groupY = minY - padTop;\n groupW = maxX - minX + 2 * padX;\n groupH = maxY - minY + padTop + padBottom;\n }\n\n const info = controllerInfo[controllerId] || {};\n const pipeCode = info.pipe_code || controllerId.split(\":\").pop() || controllerId;\n const groupNode: GraphNode = {\n id: controllerId,\n type: NODE_TYPE_CONTROLLER,\n data: {\n label: pipeCode,\n pipeType: info.pipe_type,\n isController: true,\n isPipe: false,\n isStuff: false,\n pipeCode: pipeCode,\n labelText: pipeCode,\n },\n position: { x: groupX, y: groupY },\n style: {\n width: groupW + \"px\",\n height: groupH + \"px\",\n padding: \"0\",\n },\n };\n\n controllerNodes.push(groupNode);\n nodeById[controllerId] = groupNode;\n\n for (const childId of allChildren) {\n childToParent[childId] = controllerId;\n }\n }\n\n // Convert child positions to parent-relative and set parentId\n for (const [childId, parentId] of Object.entries(childToParent)) {\n const child = nodeById[childId];\n const parent = nodeById[parentId];\n if (!child || !parent) continue;\n child.position = {\n x: child.position.x - parent.position.x,\n y: child.position.y - parent.position.y,\n };\n child.parentId = parentId;\n child.extent = \"parent\";\n }\n\n return controllerNodes;\n}\n\n/**\n * Apply controller containers to layouted nodes if showControllers is enabled.\n *\n * When `expandedControllers` is provided, PipeParallel/PipeBatch controllers with\n * more than MAX_VISIBLE_CONTROLLER_CHILDREN children are auto-collapsed unless the\n * controller ID is in the expanded set.\n */\nexport function applyControllers(\n layoutedNodes: GraphNode[],\n layoutedEdges: GraphEdge[],\n graphspec: GraphSpec | null,\n analysis: DataflowAnalysis | null,\n showControllers: boolean,\n expandedControllers?: ReadonlySet<string>,\n onToggleCollapse?: (controllerId: string) => void,\n controllerPositions?: Record<string, ControllerRect>,\n onToggleFold?: (controllerId: string, options?: FoldToggleOptions) => void,\n): { nodes: GraphNode[]; edges: GraphEdge[] } {\n if (!showControllers || !analysis || !graphspec) {\n return { nodes: layoutedNodes, edges: layoutedEdges };\n }\n\n // ─── Compute child counts and effective collapse state ─────────────────\n const childCounts: Record<string, number> = {};\n const collapsedSet = new Set<string>();\n\n const controllerTypeMap: Record<string, PipeType> = {};\n for (const node of graphspec.nodes) {\n if (analysis.controllerNodeIds.has(node.id)) {\n controllerTypeMap[node.id] = node.pipe_type;\n }\n }\n\n for (const ctrlId of analysis.controllerNodeIds) {\n const directChildren = analysis.containmentTree[ctrlId] || [];\n childCounts[ctrlId] = directChildren.length;\n const pipeType = controllerTypeMap[ctrlId];\n const isCollapsible = pipeType === \"PipeParallel\" || pipeType === \"PipeBatch\";\n if (\n isCollapsible &&\n directChildren.length > MAX_VISIBLE_CONTROLLER_CHILDREN &&\n !expandedControllers?.has(ctrlId)\n ) {\n collapsedSet.add(ctrlId);\n }\n }\n\n // ─── Filter hidden children for collapsed controllers ──────────────────\n let filteredNodes = layoutedNodes;\n let filteredEdges = layoutedEdges;\n\n if (collapsedSet.size > 0) {\n const hiddenNodes = new Set<string>();\n\n for (const ctrlId of collapsedSet) {\n const directChildren = analysis.containmentTree[ctrlId] || [];\n const toHide = directChildren.slice(MAX_VISIBLE_CONTROLLER_CHILDREN);\n for (const childId of toHide) {\n hiddenNodes.add(childId);\n if (analysis.controllerNodeIds.has(childId)) {\n for (const d of getDescendants(\n childId,\n analysis.containmentTree,\n analysis.controllerNodeIds,\n )) {\n hiddenNodes.add(d);\n }\n }\n }\n }\n\n // Also hide stuff nodes inside collapsed controllers that have no visible\n // pipe connection. We ignore stuff-to-stuff edges (batch_item/batch_aggregate)\n // because those would keep orphaned branch stuff nodes alive.\n const childToCtrl = buildChildToControllerMap(graphspec, analysis);\n for (const node of layoutedNodes) {\n if (!isStuffNodeId(node.id) || hiddenNodes.has(node.id)) continue;\n const ctrlId = childToCtrl[node.id];\n if (!ctrlId || (!collapsedSet.has(ctrlId) && !hiddenNodes.has(ctrlId))) continue;\n const pipeEdges = layoutedEdges.filter((e) => {\n if (e.source !== node.id && e.target !== node.id) return false;\n const other = e.source === node.id ? e.target : e.source;\n return !isStuffNodeId(other); // only pipe connections\n });\n if (\n pipeEdges.length === 0 ||\n pipeEdges.every((e) => {\n const other = e.source === node.id ? e.target : e.source;\n return hiddenNodes.has(other);\n })\n ) {\n hiddenNodes.add(node.id);\n }\n }\n\n filteredNodes = layoutedNodes.filter((n) => !hiddenNodes.has(n.id));\n filteredEdges = layoutedEdges.filter(\n (e) => !hiddenNodes.has(e.source) && !hiddenNodes.has(e.target),\n );\n }\n\n // ─── Build controller group nodes from visible children ────────────────\n const controllerNodes = buildControllerNodes(\n graphspec,\n analysis,\n filteredNodes,\n controllerPositions,\n );\n if (controllerNodes.length === 0) {\n return { nodes: filteredNodes, edges: filteredEdges };\n }\n\n // Inject collapse + fold metadata into controller node data\n for (const cn of controllerNodes) {\n const count = childCounts[cn.id] ?? 0;\n const isCollapsed = collapsedSet.has(cn.id);\n cn.data.childCount = count;\n cn.data.isCollapsed = isCollapsed;\n if (onToggleCollapse) {\n const id = cn.id;\n cn.data.onToggleCollapse = () => onToggleCollapse(id);\n }\n if (onToggleFold) {\n const id = cn.id;\n cn.data.onToggleFold = (options?: FoldToggleOptions) => onToggleFold(id, options);\n }\n }\n\n const allNodes = [...controllerNodes, ...filteredNodes];\n\n // Sort: ReactFlow requires parent group nodes before their children.\n const nodeMap: Record<string, GraphNode> = {};\n for (const n of allNodes) nodeMap[n.id] = n;\n const depthOf: Record<string, number> = {};\n const depthVisiting = new Set<string>();\n function getContainmentDepth(id: string): number {\n if (depthOf[id] !== undefined) return depthOf[id];\n if (depthVisiting.has(id)) {\n throw new Error(\n `Cycle detected in node parent chain: node \"${id}\" references itself as an ancestor`,\n );\n }\n depthVisiting.add(id);\n const n = nodeMap[id];\n depthOf[id] = n && n.parentId ? 1 + getContainmentDepth(n.parentId) : 0;\n depthVisiting.delete(id);\n return depthOf[id];\n }\n for (const n of allNodes) getContainmentDepth(n.id);\n allNodes.sort((a, b) => depthOf[a.id] - depthOf[b.id]);\n\n return { nodes: allNodes, edges: filteredEdges };\n}\n","import type { GraphConfig } from \"./types\";\nimport { EDGE_TYPE, FOLD_MODE } from \"./types\";\n\nexport const DEFAULT_GRAPH_CONFIG: GraphConfig = {\n direction: \"LR\",\n showControllers: false,\n foldMode: FOLD_MODE.EXPANDED,\n nodesep: 50,\n ranksep: 100,\n edgeType: EDGE_TYPE.DEFAULT,\n initialZoom: null,\n panToTop: true,\n paletteColors: {\n // Graph node/edge colors\n \"--color-pipe\": \"#ff6b6b\",\n \"--color-pipe-bg\": \"rgba(224,108,117,0.18)\",\n \"--color-pipe-text\": \"#ffffff\",\n \"--color-stuff\": \"#4ECDC4\",\n \"--color-stuff-bg\": \"rgba(78,205,196,0.12)\",\n \"--color-stuff-border\": \"#9ddcfd\",\n \"--color-stuff-text\": \"#98FB98\",\n \"--color-stuff-text-dim\": \"#9ddcfd\",\n \"--color-edge\": \"#FFFACD\",\n \"--color-batch-item\": \"#bd93f9\",\n \"--color-batch-aggregate\": \"#50fa7b\",\n \"--color-parallel-combine\": \"#d6a4ff\",\n \"--color-success\": \"#50FA7B\",\n \"--color-success-bg\": \"rgba(80,250,123,0.15)\",\n \"--color-error\": \"#FF5555\",\n \"--color-error-bg\": \"rgba(255,85,85,0.15)\",\n \"--color-accent\": \"#8BE9FD\",\n \"--color-warning\": \"#FFB86C\",\n // Base theme vars used by graph-core.css\n \"--color-bg\": \"#0a0a0a\",\n \"--color-bg-dots\": \"rgba(255, 255, 255, 0.35)\",\n \"--color-text-muted\": \"#94a3b8\",\n \"--color-controller-text\": \"#94a3b8\",\n \"--font-sans\": '\"Inter\", -apple-system, BlinkMacSystemFont, \"Segoe UI\", sans-serif',\n \"--font-mono\": '\"JetBrains Mono\", \"Monaco\", \"Menlo\", monospace',\n \"--shadow-lg\": \"0 8px 24px rgba(0, 0, 0, 0.5)\",\n },\n};\n\nexport function getPaletteColors():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