fix: platform_silent记忆提取 + 群聊上下文整合 + 多QQ实例支持
- platform_silent模式接入Orchestrator记忆提取:被动观察群聊时提取值得记住的信息到对应命名空间 - post_chat后台思考注入平台观察:对话后思考也能看到群聊摘要 - QQ适配器:OneBot v11 self_id动态捕获、CQ图片URL提取、视觉+OCR并行处理 - Router解耦:ConfigName/PlatformName分离,支持多QQ实例独立连接 - 黑白名单功能:后端API + Ethend代理 + UI面板 - \n\n双换行断句:AI回复按双换行分割为多条消息按间隔发送 - @提及修复:bot自感知UID进行@检测 - 群聊上下文共享:channel-based userID避免记忆碎片化 - 消息日志显示处理后内容而非原始SSE数据 - platform-bridge Dockerfile + docker-compose.yml更新 Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -25,11 +25,23 @@ type LogEntry struct {
|
||||
Error string `json:"error,omitempty"`
|
||||
}
|
||||
|
||||
// LogListener receives log entries as they are written.
|
||||
type LogListener func(LogEntry)
|
||||
|
||||
// Logger writes message logs to per-platform JSONL files.
|
||||
type Logger struct {
|
||||
mu sync.Mutex
|
||||
dir string
|
||||
files map[string]*os.File
|
||||
mu sync.Mutex
|
||||
dir string
|
||||
files map[string]*os.File
|
||||
listeners []LogListener
|
||||
}
|
||||
|
||||
// OnLog registers a listener that is called for every log entry written.
|
||||
// The listener is called synchronously; avoid heavy work in the callback.
|
||||
func (l *Logger) OnLog(fn LogListener) {
|
||||
l.mu.Lock()
|
||||
defer l.mu.Unlock()
|
||||
l.listeners = append(l.listeners, fn)
|
||||
}
|
||||
|
||||
// NewLogger creates a Logger, ensuring the log directory exists.
|
||||
@@ -60,12 +72,23 @@ func (l *Logger) Log(entry LogEntry) error {
|
||||
}
|
||||
|
||||
l.mu.Lock()
|
||||
defer l.mu.Unlock()
|
||||
|
||||
if _, err := f.Write(append(data, '\n')); err != nil {
|
||||
l.mu.Unlock()
|
||||
return fmt.Errorf("write log: %w", err)
|
||||
}
|
||||
return f.Sync()
|
||||
if err := f.Sync(); err != nil {
|
||||
l.mu.Unlock()
|
||||
return err
|
||||
}
|
||||
listeners := make([]LogListener, len(l.listeners))
|
||||
copy(listeners, l.listeners)
|
||||
l.mu.Unlock()
|
||||
|
||||
// Notify listeners outside the lock.
|
||||
for _, fn := range listeners {
|
||||
fn(entry)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// ReadLogs reads the last N log entries for a platform, newest first.
|
||||
|
||||
Reference in New Issue
Block a user