fix: 死锁修复、管理员权限集中管控、群聊频率控制、表情映射修复
thinker.go: 移除所有 defer t.muUnlock() 持锁跨阻塞调用的模式,消除8处死锁点 - performThink: defer→立即解锁,LLM调用不再持锁 - lightThinkLoop: defer在for循环内→第2次迭代自死锁 - resetSilenceTimer: defer持锁调performThink - UpdatePresence: defer持锁调time.Sleep+performThink - storeThought: defer+panic→锁泄露; 移除extractProactiveMessage嵌套锁 is_admin三层防御: - synthesizer: 系统提示词注入管理员/非管理员身份标签 - iot_provider: 非管理员直接拒绝IoT操作 - plugin-manager: ToolDefinition.AdminOnly自动拦截,集中管控 群聊优化: - group_ambient: 强化审查指令,【不发送】自审查标签 - 群聊间隔4s→3s,最多2条/轮 - 工具失败也推跟进消息,避免沉默 平台桥接: - 日志文件名使用适配器唯一标识符(ConfigName) - QQ表情映射替换为官方116条目数据 - CQ表情保留名称/ID
This commit is contained in:
@@ -972,6 +972,19 @@ func registerPluginTools(registry *plgManager.ToolRegistry, plugin plgSDK.Plugin
|
||||
}
|
||||
|
||||
// wrapTool 包装 ai-core 旧 ToolExecutor 为 sdk.Tool
|
||||
// adminOnlyToolIDs lists tool IDs that require admin permission.
|
||||
// Each tool declares its own AdminOnly flag; the plugin manager enforces it automatically.
|
||||
// To add a new admin-only tool, add its ID here.
|
||||
var adminOnlyToolIDs = map[string]bool{
|
||||
"host_exec": true,
|
||||
"host_file": true,
|
||||
"host_system": true,
|
||||
"os_exec": true,
|
||||
"os_file": true,
|
||||
"os_system": true,
|
||||
"iot_control": true,
|
||||
}
|
||||
|
||||
func wrapTool(executor tools.ToolExecutor, id, displayName, category string) plgSDK.Tool {
|
||||
return &toolAdapter{
|
||||
executor: executor,
|
||||
@@ -981,6 +994,7 @@ func wrapTool(executor tools.ToolExecutor, id, displayName, category string) plg
|
||||
Category: category,
|
||||
Complexity: plgSDK.ComplexitySimple,
|
||||
Parameters: executor.Definition().Parameters,
|
||||
AdminOnly: adminOnlyToolIDs[id],
|
||||
},
|
||||
}
|
||||
}
|
||||
@@ -1084,8 +1098,13 @@ func handleChat(
|
||||
if thinker != nil {
|
||||
thinker.RecordUserMessage(req.SessionID)
|
||||
}
|
||||
// 在消息前加审查指令,让 LLM 自己判断是否插话
|
||||
req.Message = "【群聊环境消息】" + message + "\n\n你不需要回复这条消息,除非你真有特别相关的话要说。如果不想说话,只用 <action> 在心里轻轻想一下即可,不用发消息。"
|
||||
// 在消息前加审查指令,让 LLM 自己判断是否插话。
|
||||
// 关键规则:
|
||||
// 1. 绝大多数群聊消息不需要你回复。只有话题直接涉及你、有人@你、或你真有特别相关的信息时才开口。
|
||||
// 2. 如果有人说"别说话""闭嘴""先别说""别让ta说"之类让你安静的话,必须立刻闭嘴,后续几条消息都不要回复。
|
||||
// 3. 不想说话时不要发消息。不要为了刷存在感而发言。
|
||||
// 4. 每轮最多说 1-2 句话,不要长篇大论。
|
||||
req.Message = "【群聊审查模式】以下是群聊里的一条消息。绝大多数群聊消息你不需要回复。只有以下情况才开口:(1)有人直接@你或叫你名字 (2)话题与你高度相关 (3)你有重要信息补充。如果有人让你闭嘴/别说话,必须严格遵守。每次回复最多1-2句话。如果你被唤醒了但觉得不该说话,在消息开头写 【不发送】——这条消息就不会被发出去,只在你心里想过。\n\n" + message
|
||||
req.Mode = "text"
|
||||
}
|
||||
if req.Mode == "platform_silent" {
|
||||
@@ -1199,6 +1218,7 @@ func handleChat(
|
||||
ChannelID: req.Source.ChannelID,
|
||||
BotUID: req.Source.BotUID,
|
||||
AdapterName: req.Source.AdapterName,
|
||||
IsAdmin: req.IsAdmin,
|
||||
})
|
||||
if err != nil {
|
||||
fallback := getFallbackMessage()
|
||||
|
||||
Reference in New Issue
Block a user