RAGFlow is an agent-native database: a Retrieval-Augmented Generation (RAG) engine that grew into context infrastructure.
Go agent-harnessagent-native-databaseagentic-aiagentic-retrievalagentic-searchaiai-agentscontext-enginecontext-engineeringcontext-managementharness-engineeringknowledge-compilationragretrieval-augmented-generationretrieval-harnesssearch-harness
import {
IIterationNode,
IIterationStartNode,
} from '@/interfaces/database/agent';
import { cn } from '@/lib/utils';
import { NodeProps, NodeResizeControl, Position } from '@xyflow/react';
import { memo } from 'react';
import { NodeHandleId, Operator } from '../../constant';
import { useCanvasReadonly } from '../../context';
import OperatorIcon from '@/components/operator-icon';
import { CommonHandle, LeftEndHandle } from './handle';
import NodeHeader from './node-header';
import { NodeWrapper } from './node-wrapper';
import { ResizeIcon, controlStyle } from './resize-icon';
import { ToolBar } from './toolbar';
export function InnerIterationNode({
id,
data,
isConnectable = true,
selected,
}: NodeProps<IIterationNode>) {
const readOnly = useCanvasReadonly();
return (
<ToolBar selected={selected} id={id} label={data.label} showRun={false}>
<section
className={cn(
'h-full bg-transparent rounded-b-md group border border-border-button border-t-0',
{
['border-x border-accent-primary']: selected,
},
)}
>
{!readOnly && (
<NodeResizeControl
style={{ ...controlStyle, pointerEvents: 'auto' }}
minWidth={100}
minHeight={50}
>
<ResizeIcon />
</NodeResizeControl>
)}
<LeftEndHandle className="!pointer-events-auto"></LeftEndHandle>
<CommonHandle
id={NodeHandleId.Start}
type="source"
position={Position.Right}
isConnectable={isConnectable}
nodeId={id}
className="!pointer-events-auto"
></CommonHandle>
<NodeHeader
id={id}
name={data.name}
label={data.label}
wrapperClassName={cn(
'pointer-events-auto bg-background-header-bar p-2 rounded-t-[10px] absolute w-full top-[-38px] left-[-0.3px] border-x border-t border-border-button',
{
['border-x border-t border-accent-primary']: selected,
},
)}
></NodeHeader>
</section>
</ToolBar>
);
}
export function InnerIterationStartNode({
isConnectable = true,
id,
selected,
}: NodeProps<IIterationStartNode>) {
return (
<NodeWrapper className="w-20" selected={selected}>
<CommonHandle
type="source"
position={Position.Right}
isConnectable={isConnectable}
isConnectableEnd={false}
id={NodeHandleId.Start}
nodeId={id}
></CommonHandle>
<div>
<OperatorIcon name={Operator.Begin}></OperatorIcon>
</div>
</NodeWrapper>
);
}
export const IterationStartNode = memo(InnerIterationStartNode);
export const IterationNode = memo(InnerIterationNode);