// 新消息使用结构化 attachment_refs;这里只解析旧客户端与存量消息的正文标记。 const USER_ATTACHMENT_RE = /^\[(用户上传的参考图|用户上传的文件)\]\s+(.+?)\s*$/; export function parseUserAttachments(content) { const attachments = []; const bodyLines = []; for (const line of String(content || "").split("\n")) { const match = line.match(USER_ATTACHMENT_RE); if (!match) { bodyLines.push(line); continue; } attachments.push({ path: match[2], kind: match[1] === "用户上传的参考图" ? "image" : "file", }); } return { content: bodyLines.join("\n").trim(), attachments }; }