import React from 'react' import type { Attachment, ImageAttachment, McpContent, PlanConfig, TaskTodoConfig, Operation, BaseEvent, HandleImageAttachmentClick, } from '../../types' import { AttachmentItem } from './AttachmentItem' import { ImageAttachmentItem } from './ImageAttachmentItem' import { TodoList } from './TodoList' export interface SystemMessageProps { attachment?: Attachment[] imageAttachment?: ImageAttachment[] operation?: Operation mcpContent?: McpContent planConfig?: PlanConfig taskTodoConfig?: TaskTodoConfig base?: BaseEvent showSystemAttachments: boolean showOperation: boolean showMcpContent: boolean showPlanConfig: boolean showTaskTodoList: boolean onAttachmentClick?: (attachment: Attachment) => void onImageAttachmentClick?: HandleImageAttachmentClick } /** * 系统消息组件 - 渲染系统附件、待办列表、MCP内容、计划配置、操作信息 * 对应 next-agent SystemMessage */ function InnerSystemMessage({ attachment, imageAttachment, operation, mcpContent, planConfig, taskTodoConfig, showSystemAttachments, showOperation, showMcpContent, showPlanConfig, showTaskTodoList, onAttachmentClick, onImageAttachmentClick, }: SystemMessageProps) { const hasContent = showTaskTodoList || (imageAttachment?.length ?? 0) > 0 || (showSystemAttachments && (attachment?.length ?? 0) > 0) || (showMcpContent && !!mcpContent) || (showOperation && !!operation) || (showPlanConfig && !!planConfig) if (!hasContent) return null return (
{/* Todo 列表 */} {showTaskTodoList && taskTodoConfig?.list?.length && ( )} {/* 图片附件(系统消息里的) */} {(imageAttachment?.length ?? 0) > 0 && (
{imageAttachment!.map((img, i) => ( ))}
)} {/* 文件附件(系统消息里的) */} {showSystemAttachments && (attachment?.length ?? 0) > 0 && (
{attachment!.map((att, i) => ( ))}
)} {/* MCP 内容 */} {showMcpContent && mcpContent && (
            {JSON.stringify(mcpContent, null, 2)}
          
)} {/* 操作信息 */} {showOperation && operation && (
            {JSON.stringify(operation, null, 2)}
          
)} {/* 计划配置 */} {showPlanConfig && planConfig?.steps && ( ({ id: s.id, title: s.title, status: s.status, }))} /> )}
) } export const SystemMessage = React.memo(InnerSystemMessage) export default SystemMessage