import { Download, Eraser, FileText, Plus } from 'lucide-react'
import { useStore, useActiveConversation } from '../../store/useStore'
import { Btn, Field, Section, inputCls, download, stamp } from '../ui'
import ModelPicker from './ModelPicker'
function toMarkdown(conv, agents) {
const lines = [`# ${conv.title}`, '', `> 匯出於 ${new Date().toLocaleString()} · 模型 ${conv.model}`, '']
for (const m of conv.messages) {
if (m.role === 'user') lines.push('## 🧑 使用者', '', m.content, '')
else if (m.role === 'assistant') {
const a = agents.find((x) => x.id === m.agentId)
if (m.content) lines.push(`## ${a?.icon || '🤖'} ${a?.name || 'Assistant'}`, '', m.content, '')
for (const c of m.tool_calls || []) lines.push(`> 🔧 呼叫 \`${c.function?.name}\` ${c.function?.arguments || ''}`, '')
} else if (m.role === 'tool') {
lines.push(`🔧 ${m.name} 結果
`, '', '```', String(m.content), '```', '
目前沒有開啟的對話。
對話途中可以隨時換模型或 Agent,下一輪就會生效。
啟用工具:{agent.tools?.length ? agent.tools.join('、') : '無'}(到「Agent」頁可修改)
)}