perf(agent): smooth SSE streaming updates

This commit is contained in:
jxxghp
2026-08-07 12:42:57 +08:00
parent 4814f53c4e
commit 0eb81b4ecb
10 changed files with 408 additions and 55 deletions
+21
View File
@@ -0,0 +1,21 @@
import MarkdownIt from 'markdown-it'
import mdLinkAttributes from 'markdown-it-link-attributes'
const agentMarkdown = new MarkdownIt({
html: false,
breaks: true,
linkify: true,
typographer: true,
})
agentMarkdown.use(mdLinkAttributes, {
attrs: {
target: '_blank',
rel: 'noopener noreferrer',
},
})
// Agent 内容来自模型和工具输出,禁用原始 HTML 后统一转换为可展示 Markdown。
export function renderAgentMarkdown(content: string) {
return content ? agentMarkdown.render(content) : ''
}