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:
@@ -10,6 +10,8 @@ import (
|
||||
"git.yeij.top/AskaEth/Cyrene/ai-core/internal/model"
|
||||
"git.yeij.top/AskaEth/Cyrene/ai-core/internal/persona"
|
||||
"git.yeij.top/AskaEth/Cyrene/ai-core/internal/tools"
|
||||
|
||||
plgManager "git.yeij.top/AskaEth/Cyrene-Plugins/manager"
|
||||
)
|
||||
|
||||
// IoTDeviceProvider IoT 设备查询接口
|
||||
@@ -195,6 +197,15 @@ func (p *IoTProvider) Execute(ctx context.Context, subCtx []model.LLMMessage) (*
|
||||
Summary: "(未执行 IoT 操作)",
|
||||
}
|
||||
|
||||
// 管理员权限检查:非管理员不能执行设备操作
|
||||
isAdmin, _ := ctx.Value(plgManager.CtxKeyIsAdmin).(bool)
|
||||
if !isAdmin {
|
||||
result.Summary = "【系统提示】此操作需要管理员权限。用户不是管理员——请用温柔俏皮的自然语气告诉对方你无法执行此操作。比如「只有开拓者才能让人家做这些事呢~」或「这个功能只对开拓者开放哦」。不要机械地说「你没有权限」,也不要编造设备操作结果。"
|
||||
result.Confidence = 0.9
|
||||
logger.Printf("[iot-subsession] 非管理员尝试执行 IoT 操作,已拒绝")
|
||||
return result, nil
|
||||
}
|
||||
|
||||
userMessage := ""
|
||||
for i := len(subCtx) - 1; i >= 0; i-- {
|
||||
if subCtx[i].Role == model.RoleUser {
|
||||
|
||||
@@ -42,8 +42,8 @@ type CreateContextParams struct {
|
||||
DeviceContext string // IoT 设备状态文本
|
||||
Intent *model.IntentResult
|
||||
Nickname string // 用户昵称
|
||||
IsAdmin bool // 发送者是否为管理员
|
||||
}
|
||||
|
||||
// LLMClient LLM 调用接口(避免循环依赖)
|
||||
type LLMClient interface {
|
||||
Chat(ctx context.Context, messages []model.LLMMessage) (*model.LLMResponse, error)
|
||||
|
||||
Reference in New Issue
Block a user