/** * 解析后的消息片段类型 */ export interface ParsedPart { type: 'text' | 'planning' | 'replanning' | 'reasoning' | 'action_log' | 'final_result' | 'process_text'; content: string; } /** * 解析规则配置 */ export interface ParseAgentMessageOptions { /** * 解析模式 * - 'xml': XML 标签模式 ... * - 'comment': 注释标签模式 /*REASONING*\/ * - 'custom': 自定义正则模式 */ mode?: 'xml' | 'comment' | 'custom'; /** * 自定义正则规则 (mode='custom' 时使用) * @example * [ * { regex: /\[REASONING\]([\s\S]*?)\[\/REASONING\]/g, type: 'reasoning' }, * { regex: /\[PLANNING\]([\s\S]*?)\[\/PLANNING\]/g, type: 'planning' } * ] */ customPatterns?: Array<{ regex: RegExp; type: ParsedPart['type']; }>; /** * 最终答案标记 (comment 模式使用) * @default '/*FINAL_ANSWER*\/' */ finalMarker?: string; } /** * 清理 process 文本 * - 移除多余的换行 * - 移除 JSON 代码块标记 */ export declare function cleanProcessText(text: string): string; /** * 解析 Agent 消息 (支持多种格式) * * @param text 原始消息文本 * @param options 解析选项 * @returns 解析后的消息片段数组 * * @example * // XML 模式 (默认) * const parts1 = parseAgentMessage(` * 分析用户需求... * 最终回复内容 * `); * * @example * // 注释模式 (业务项目格式) * const parts2 = parseAgentMessage(` * /*REASONING*\/分析用户需求... * /*FINAL_ANSWER*\/最终回复内容 * `, { mode: 'comment' }); * * @example * // 自定义模式 * const parts3 = parseAgentMessage(text, { * mode: 'custom', * customPatterns: [ * { regex: /\[REASONING\]([\s\S]*?)\[\/REASONING\]/g, type: 'reasoning' } * ] * }); */ export declare function parseAgentMessage(text: string, options?: ParseAgentMessageOptions): ParsedPart[]; /** * 检查是否包含 process 内容 */ export declare function hasProcessContent(parts: ParsedPart[]): boolean; /** * 获取纯文本内容(不包含 process 标签) */ export declare function getPlainText(parts: ParsedPart[]): string;