44048b333a
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
52 lines
1.7 KiB
Go
52 lines
1.7 KiB
Go
package subsession
|
|
|
|
import (
|
|
"context"
|
|
"time"
|
|
|
|
"git.yeij.top/AskaEth/Cyrene/ai-core/internal/llm"
|
|
"git.yeij.top/AskaEth/Cyrene/ai-core/internal/model"
|
|
"git.yeij.top/AskaEth/Cyrene/ai-core/internal/persona"
|
|
)
|
|
|
|
// Provider 子会话提供者接口
|
|
// 每种子会话类型实现此接口
|
|
type Provider interface {
|
|
// Type 返回子会话类型标识
|
|
Type() model.SubSessionType
|
|
|
|
// CanHandle 判断是否需要为此消息创建子会话
|
|
CanHandle(ctx context.Context, intent *model.IntentResult, userMessage string) bool
|
|
|
|
// Priority 返回优先级 (数字越小优先级越高)
|
|
Priority() int
|
|
|
|
// CreateContext 创建子会话的 LLM 上下文
|
|
// 不包含对话历史(历史由 Orchestrator 统一管理)
|
|
CreateContext(ctx context.Context, params CreateContextParams) ([]model.LLMMessage, error)
|
|
|
|
// Timeout 返回此子会话的超时时间
|
|
Timeout() time.Duration
|
|
|
|
// Execute 执行子会话逻辑,返回结果
|
|
// 子会话可以调用 LLM、执行工具调用等
|
|
Execute(ctx context.Context, subCtx []model.LLMMessage) (*model.SubSessionResult, error)
|
|
}
|
|
|
|
// CreateContextParams 创建上下文参数
|
|
type CreateContextParams struct {
|
|
UserID string
|
|
SessionID string
|
|
UserMessage string
|
|
PersonaConfig *persona.PersonaConfig
|
|
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)
|
|
ChatWithTools(ctx context.Context, messages []model.LLMMessage, tools []llm.OpenAITool) (*model.LLMResponse, error)
|
|
}
|