fix: 修复机器人测试文本错误, 提升版本号

This commit is contained in:
Wxw-Gu committed 2026-11-19 10:07:55 +08:00
1 parent f64ac4e326
commit 2fb519a373
5 files changed
+86 -8

No files matched your search

+31 -4
View File
@@ -1195,6 +1195,7 @@ document.getElementById('memory-clear-btn').addEventListener('click', async () =
/* ---------- 预览与测试发送 ---------- */
const testOutput = document.getElementById('test-output')
let previewSnapshot = null
function showTestOutput(text) {
testOutput.hidden = false
@@ -1204,15 +1205,26 @@ function showTestOutput(text) {
document.getElementById('preview-reply-btn').addEventListener('click', async () => {
collectConfigFromForm()
await callHost('storage.set', { key: CONFIG_KEY, value: config })
const testGroupId = document.getElementById('test-group-select').value
const testMessageText = document.getElementById('test-message-input').value.trim()
const testPersonaId = editingPersonaId
previewSnapshot = {
groupId: testGroupId,
personaId: testPersonaId,
messageText: testMessageText,
replyText: '',
blocked: false
}
showTestOutput('正在执行安全检查与 AI 思考预览…')
try {
const result = await callBackground('previewReply', {
groupId: document.getElementById('test-group-select').value,
personaId: editingPersonaId,
groupId: testGroupId,
personaId: testPersonaId,
senderName: document.getElementById('test-sender-name').value.trim() || '测试群友',
messageText: document.getElementById('test-message-input').value.trim()
messageText: testMessageText
})
if (result.blocked) {
previewSnapshot.blocked = true
showTestOutput(
[
`【安全防护拦截】已触发敏感探测/提示词保护(${result.securityLabel || result.securityCategory})`,
@@ -1233,6 +1245,7 @@ document.getElementById('preview-reply-btn').addEventListener('click', async ()
`【本轮随机抽样方式】${modeLabel}(原因:${result.deliveryReason})`
].join('\n')
)
previewSnapshot.replyText = result.replyText || ''
setBanner('AI 预览生成完成。', 'ok')
} catch (error) {
showTestOutput(`预览失败:${error.message}`)
@@ -1250,10 +1263,24 @@ async function triggerTestSend(mode) {
await callHost('storage.set', { key: CONFIG_KEY, value: config })
showTestOutput(`正在向 ${groupDisplayName(to)} 执行测试发送(模式:${mode})…`)
try {
const messageText = document.getElementById('test-message-input').value.trim()
const preview = previewSnapshot
const samePreview =
preview &&
!preview.blocked &&
preview.groupId === to &&
preview.personaId === editingPersonaId &&
preview.messageText === messageText
if (preview && preview.blocked && preview.groupId === to) {
throw new Error('当前预览已被安全拦截,未发送')
}
const result = await callBackground('testSend', {
to,
mode,
text: document.getElementById('test-message-input').value.trim()
messageText,
replyText: samePreview ? preview.replyText : '',
personaId: editingPersonaId,
senderName: document.getElementById('test-sender-name').value.trim() || '群友'
})
const desc =
result.channel === 'voice'
+2 -2
View File
@@ -14,8 +14,8 @@
"bytes": 33471
},
"group-chat-bot@1.0.0": {
"sha256": "5c2d7409011184b85980a37955347537cd9530860f81b644ec995971d5af6f66",
"bytes": 24751
"sha256": "122a4da7710cf882975f09440819e9dc1b619e4bd6f94153085a7d6fe8a33885",
"bytes": 24981
},
"keyword-bot@1.0.0": {
"sha256": "3d8e5453e7ae6de7e29c16eb3c9e718a98bae27e9ed2edfd10399fb158e1c87d",
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "tracememo",
"version": "2.6.0",
"version": "2.7.0",
"packageManager": "pnpm@7.33.7",
"description": "TraceMemo(迹忆)是一款本地优先、可追溯的 AI 微信知识与分析工作台。 原名 WechatExplorer,支持聊天记录搜索、知识库、微信群聊总结和 Agent 助手。",
"keywords": [
+1
View File
@@ -60,6 +60,7 @@ function createBuilderConfig({ edition, stageRoot, buildOutput, outputRoot, appV
],
extraResources: [
{ from: path.join(stageRoot, 'resources'), to: 'resources', filter: ['**/*'] },
{ from: path.join(ROOT, 'build/extension-templates'), to: 'extension-templates', filter: ['**/*'] },
{ from: path.join(ROOT, 'build/app-update.yml'), to: 'app-update.yml' },
{
from: path.join(ROOT, 'docs/skill/tracememo-reader'),
+51 -1
View File
@@ -83,7 +83,57 @@ function prepareFfmpegRuntime(targetPlatform = process.platform, targetArch = pr
fs.chmodSync(ffmpegPath, 0o755)
if (process.platform === 'darwin') {
execFileSync('/usr/bin/codesign', ['--force', '--sign', '-', ffmpegPath], { stdio: 'ignore' })
assertMachOIntact(ffmpegPath)
try {
execFileSync('/usr/bin/codesign', ['--force', '--sign', '-', ffmpegPath], {
stdio: ['ignore', 'pipe', 'pipe']
})
} catch (error) {
const detail = error?.stderr?.toString?.().trim() || error.message
throw new Error(
'codesign 失败:' +
detail +
'\n最常见原因:ffmpeg-static 下载被截断,文件不完整。' +
'\n处理:删除 ' +
ffmpegPath +
' 后重跑本命令;网络不稳时先用 curl -C - 把 .gz 补齐再解压。'
)
}
}
}
/**
* 截断的 Mach-O 能被 file 认出来,却签不了名,也跑不起来。
* otool 解析 load command,截断会直接失败——比事后读 codesign 的天书便宜。
*/
function assertMachOIntact(ffmpegPath) {
let listing = ''
try {
listing = execFileSync('/usr/bin/otool', ['-l', ffmpegPath], {
encoding: 'utf8',
maxBuffer: 16 * 1024 * 1024
})
} catch {
throw new Error(
'ffmpeg 二进制无法解析(下载不完整):' + ffmpegPath + '\n处理:删除该文件后重跑本命令。'
)
}
// otool 对超出文件末尾的段会标 "(past end of file)":下载被截断的确凿信号。
if (listing.includes('past end of file')) {
throw new Error(
'ffmpeg 二进制被截断(下载不完整):' +
ffmpegPath +
'\n处理:删除该文件后重跑本命令;网络不稳时先用 curl -C - 把 .gz 补齐再解压。'
)
}
let kind = ''
try {
kind = execFileSync('/usr/bin/file', ['-b', ffmpegPath], { encoding: 'utf8' })
} catch {
kind = ''
}
if (!kind.includes('Mach-O')) {
throw new Error('ffmpeg 不是 Mach-O 可执行文件:' + ffmpegPath)
}
}