import { IAgentForm, IToolNode } from '@/interfaces/database/agent'; import { Handle, NodeProps, Position } from '@xyflow/react'; import { get } from 'lodash'; import { MouseEventHandler, memo, useCallback } from 'react'; import { NodeHandleId, Operator } from '../../constant'; import { ToolCard } from '../../form/agent-form/agent-tools'; import { useFindMcpById } from '../../hooks/use-find-mcp-by-id'; import OperatorIcon from '../../operator-icon'; import useGraphStore from '../../store'; import { NodeWrapper } from './node-wrapper'; function InnerToolNode({ id, isConnectable = true, selected, }: NodeProps) { const { edges, getNode } = useGraphStore((state) => state); const upstreamAgentNodeId = edges.find((x) => x.target === id)?.source; const upstreamAgentNode = getNode(upstreamAgentNodeId); const { findMcpById } = useFindMcpById(); const handleClick = useCallback( (operator: string): MouseEventHandler => (e) => { if (operator === Operator.Code) { e.preventDefault(); e.stopPropagation(); } }, [], ); const tools: IAgentForm['tools'] = get( upstreamAgentNode, 'data.form.tools', [], ); const mcpList: IAgentForm['mcp'] = get( upstreamAgentNode, 'data.form.mcp', [], ); return (
    {tools.map((x) => (
    {x.component_name}
    ))} {mcpList.map((x) => ( {findMcpById(x.mcp_id)?.name} ))}
); } export const ToolNode = memo(InnerToolNode);