This repository has been archived on 2026-08-12. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
Cyrene/backend/platform-bridge/internal/handler/log_handler.go
T
AskaEth 44048b333a 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
2026-06-28 20:22:09 +08:00

57 lines
1.4 KiB
Go

package handler
import (
"net/http"
"strconv"
"git.yeij.top/AskaEth/Cyrene/platform-bridge/internal/config"
"git.yeij.top/AskaEth/Cyrene/platform-bridge/internal/logging"
)
// LogHandler exposes message log retrieval endpoints.
type LogHandler struct {
logger *logging.Logger
store *config.Store
}
func NewLogHandler(logger *logging.Logger, store *config.Store) *LogHandler {
return &LogHandler{logger: logger, store: store}
}
func (h *LogHandler) RegisterRoutes(mux *http.ServeMux) {
mux.HandleFunc("/api/v1/logs/", h.handleLogs)
}
func (h *LogHandler) handleLogs(w http.ResponseWriter, r *http.Request) {
name := r.URL.Path[len("/api/v1/logs/"):]
if name == "" {
writeJSON(w, http.StatusBadRequest, errResp("missing platform name in path"))
return
}
// Use the name directly as the log key. Each config has its own log file
// named by its unique identifier (e.g., "obv11-main.log").
platform := name
limit := 100
if l := r.URL.Query().Get("limit"); l != "" {
if n, err := strconv.Atoi(l); err == nil && n > 0 && n <= 1000 {
limit = n
}
}
entries, err := h.logger.ReadLogs(platform, limit)
if err != nil {
writeJSON(w, http.StatusInternalServerError, errResp(err.Error()))
return
}
if entries == nil {
entries = []logging.LogEntry{}
}
writeJSON(w, http.StatusOK, map[string]interface{}{
"platform": platform,
"total": len(entries),
"logs": entries,
})
}