feat: 工作流记忆与内置工具、知你客服脚本、Agent管理技能展示与能力配置、文档与Windows启动脚本;忽略 redis_temp 二进制目录
Made-with: Cursor
This commit is contained in:
@@ -386,11 +386,44 @@ const scrollToBottom = () => {
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 知你等工作流约定「自然语言 + 末尾单行 JSON(intent/reply/user_profile)」。
|
||||
* 聊天区若原样展示会重复;展示前去掉末尾 JSON 行(可连续多行);若整段只有 JSON 则用 reply 作为正文。
|
||||
*/
|
||||
const stripOneTrailingWorkflowJsonLine = (raw: string): string => {
|
||||
if (!raw || typeof raw !== 'string') return ''
|
||||
const t = raw.trimEnd()
|
||||
const lastNl = t.lastIndexOf('\n')
|
||||
const lastLine = (lastNl >= 0 ? t.slice(lastNl + 1) : t).trim()
|
||||
if (!lastLine.startsWith('{')) return raw
|
||||
try {
|
||||
const j = JSON.parse(lastLine) as Record<string, unknown>
|
||||
if (!j || typeof j !== 'object') return raw
|
||||
const reply = j.reply
|
||||
if (typeof reply !== 'string') return raw
|
||||
const head = lastNl >= 0 ? t.slice(0, lastNl).trimEnd() : ''
|
||||
if (head) return head
|
||||
return reply
|
||||
} catch {
|
||||
return raw
|
||||
}
|
||||
}
|
||||
|
||||
const stripTrailingWorkflowJsonLine = (raw: string): string => {
|
||||
let cur = raw
|
||||
for (let i = 0; i < 6; i++) {
|
||||
const next = stripOneTrailingWorkflowJsonLine(cur)
|
||||
if (next === cur) break
|
||||
cur = next
|
||||
}
|
||||
return cur
|
||||
}
|
||||
|
||||
// 格式化消息(支持简单的Markdown)
|
||||
const formatMessage = (content: string) => {
|
||||
if (!content) return ''
|
||||
// 简单的换行处理
|
||||
return content.replace(/\n/g, '<br>')
|
||||
const display = stripTrailingWorkflowJsonLine(content)
|
||||
return display.replace(/\n/g, '<br>')
|
||||
}
|
||||
|
||||
// 格式化时间
|
||||
|
||||
Reference in New Issue
Block a user