Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Implementation:Infiniflow Ragflow Canvas Util

From Leeroopedia
Knowledge Sources
Domains Frontend, Agent_System, Graph_Algorithms
Last Updated 2026-02-12 06:00 GMT

Overview

Concrete utility functions for graph traversal and output option building in the agent canvas workflow system of the RAGFlow frontend.

Description

The utils/canvas-util.tsx module provides functions for traversing the agent workflow graph to build output options for downstream operators, finding ancestor/descendant nodes, and validating connection paths between nodes. These are the core graph algorithms powering the agent canvas editor.

Usage

Import these utilities in agent canvas components when building operator connection UIs, validating workflow graphs, or computing available input sources for an operator.

Code Reference

Source Location

Signature

export function buildOutputOptions(nodes: Node[], edges: Edge[], currentNodeId: string): OptionType[];
export function getAncestorNodes(nodes: Node[], edges: Edge[], nodeId: string): Node[];
export function getDescendantNodes(nodes: Node[], edges: Edge[], nodeId: string): Node[];

Import

import { buildOutputOptions, getAncestorNodes } from '@/utils/canvas-util';

I/O Contract

Inputs

Name Type Required Description
nodes Node[] Yes All nodes in the workflow graph
edges Edge[] Yes All edges in the workflow graph
currentNodeId string Yes Node to compute options for

Outputs

Name Type Description
buildOutputOptions() OptionType[] Available output options from upstream nodes
getAncestorNodes() Node[] All ancestor nodes via incoming edges

Usage Examples

import { buildOutputOptions } from '@/utils/canvas-util';

const options = buildOutputOptions(nodes, edges, currentNode.id);
// Returns options like [{ label: 'Retrieval Output', value: 'node-1:output' }]

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment