import { useMemo, useState, } from 'react' import { RiArrowRightSLine, RiListView, } from '@remixicon/react' import cn from '@/utils/classnames' import Button from '@/app/components/base/button' import type { AgentLogItemWithChildren } from '@/types/workflow' import NodeStatusIcon from '@/app/components/workflow/nodes/_base/components/node-status-icon' import CodeEditor from '@/app/components/workflow/nodes/_base/components/editor/code-editor' import { CodeLanguage } from '@/app/components/workflow/nodes/code/types' import BlockIcon from '@/app/components/workflow/block-icon' import { BlockEnum } from '@/app/components/workflow/types' import useGetIcon from '@/app/components/plugins/install-plugin/base/use-get-icon' type AgentLogItemProps = { item: AgentLogItemWithChildren onShowAgentOrToolLog: (detail: AgentLogItemWithChildren) => void } const AgentLogItem = ({ item, onShowAgentOrToolLog, }: AgentLogItemProps) => { const { label, status, children, data, metadata, } = item const [expanded, setExpanded] = useState(false) const { getIconUrl } = useGetIcon() const toolIcon = useMemo(() => { const icon = metadata?.icon if (icon) { if (icon.includes('http')) return icon return getIconUrl(icon) } return '' }, [getIconUrl, metadata?.icon]) const mergeStatus = useMemo(() => { if (status === 'start') return 'running' return status }, [status]) return (
setExpanded(!expanded)} > { expanded ? : }
{label}
{ metadata?.elapsed_time && (
{metadata?.elapsed_time?.toFixed(3)}s
) }
{ expanded && (
{ !!children?.length && ( ) } { data && ( {'data'.toLocaleUpperCase()}
} language={CodeLanguage.json} value={data} isJSONStringifyBeauty /> ) }
) } ) } export default AgentLogItem