feat: 全链路优化 — 死锁修复、MD3主题、上下文持久化、群聊自然化、打字状态、知识库

**死锁根因修复**
- periodicThinkLoop:1015 orphaned lock → 删除(字段已原子化)
- RecordUserMessage 隔离为 recordMu
- atomic.Int64 替换 lastUserMessage/lastThinkTime 等

**MD3 / Android 17 主题**
- 毛玻璃卡片 (backdrop-filter)
- MD3 色彩令牌 (pink primary #f472b6)
- icons.js 独立矢量图标库 + 运行时 emoji 替换
- 无边框卡片、圆角按钮、阴影层次

**上下文持久化**
- AddMessage → saveToDB 异步写 PostgreSQL
- LoadFromDB 恢复 (admin-session-main + 懒加载)
- LLMMessage.Timestamp 字段

**群聊与适配器**
- group_ambient 模式: 非@消息让 LLM 自己判断是否插话
- 戳一戳动作消息总是回复
- NapCat 打字状态 (set_input_status, 最小3秒显示)
- HTTP API 配置 (http_url/http_token)

**知识库 & 防编造**
- knowledge.CanHandle 对 chat 意图也触发
- 关键词预筛选避免无关 embedding 调用
- persona + synthesizer 三重诚实规则
- 工具结果持久化到会话历史

**平台桥接器**
- detached:true Go进程独立存活
- ethend 重启自动接管已运行服务
- stop() 接管模式 taskkill/F/ PID
- Windows netstat 替代 fuser 获取 PID
- 重复适配器种子逻辑修复
- 失败转发日志 Direction: error

**崩溃诊断**
- crashlog 包 (Recover + WrapHTTP + LLMCall)
- /api/v1/debug/goroutines 端点
- thinker 操作日志 + 30s stats
- 日志写入 logs/ 目录持久化

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2026-06-28 11:29:29 +08:00
parent 0d6970a2d3
commit fd44b15d81
23 changed files with 1447 additions and 254 deletions
+25 -15
View File
@@ -5,32 +5,37 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Cyrene ethend</title>
<style>
/* ========== CSS Variables (深色主题) ========== */
/* ========== Android 17 / Material You Design Tokens ========== */
:root {
--bg: #0f1117; --bg2: #1a1d27; --bg3: #252833; --bg4: #2d3140;
--border: #2d3140; --border2: #383d4a;
--text: #c9d1d9; --text2: #8b949e; --text3: #5d6470;
--accent: #f472b6; --accent2: #ec4899; --accent-bg: rgba(244,114,182,.12);
--green: #22c55e; --green-bg: rgba(34,197,94,.12);
--red: #ef4444; --red-bg: rgba(239,68,68,.12);
--yellow: #eab308; --yellow-bg: rgba(234,179,8,.12);
--blue: #3b82f6; --blue-bg: rgba(59,130,246,.12);
--orange: #f97316; --orange-bg: rgba(249,115,22,.12);
--bg: #111118; --bg2: #1b1b26; --bg3: #262434; --bg4: #312f40;
--border: #312f40; --border2: #3e3b4d;
--text: #e3e2e8; --text2: #c4c3cd; --text3: #8e8d97;
--accent: #f472b6; --accent2: #ff80c4; --accent-bg: rgba(244,114,182,.16);
--blue: #8ab4f8; --blue-bg: rgba(138,180,248,.14);
--green: #34d399; --green-bg: rgba(52,211,153,.14);
--red: #f87171; --red-bg: rgba(248,113,113,.14);
--yellow: #fbbf24; --yellow-bg: rgba(251,191,36,.14);
--orange: #fb923c; --orange-bg: rgba(251,146,60,.14);
--sidebar-w: 220px; --sidebar-collapsed: 52px;
--radius: 10px; --radius-sm: 6px;
--transition: 0.2s ease;
--radius: 12px; --radius-sm: 8px;
--transition: 0.25s cubic-bezier(0.4,0,0.2,1);
--glass-bg: rgba(27,27,38,0.72);
--glass-blur: blur(16px);
--elevation-1: 0 1px 2px rgba(0,0,0,.3), 0 1px 3px rgba(0,0,0,.15);
--elevation-2: 0 2px 4px rgba(0,0,0,.3), 0 4px 8px rgba(0,0,0,.15);
}
*,*::before,*::after{box-sizing:border-box;margin:0;padding:0}
body {
font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
font-family: 'Google Sans', 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
background: var(--bg); color: var(--text); font-size: 13px; line-height: 1.5;
display: flex; height: 100vh; overflow: hidden;
-webkit-font-smoothing: antialiased;
}
/* ========== 侧边栏 ========== */
#sidebar {
width: var(--sidebar-w); min-width: var(--sidebar-collapsed);
background: var(--bg2); border-right: 1px solid var(--border);
background: var(--bg2); box-shadow: 2px 0 12px rgba(0,0,0,.2);
display: flex; flex-direction: column; transition: width var(--transition);
overflow: hidden; z-index: 10;
}
@@ -127,8 +132,10 @@ body {
/* ========== 通用组件 ========== */
.card {
background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius);
background: var(--glass-bg); border: none; border-radius: var(--radius);
padding: 16px; margin-bottom: 16px;
backdrop-filter: var(--glass-blur); -webkit-backdrop-filter: var(--glass-blur);
box-shadow: var(--elevation-1);
}
.card-header {
display: flex; align-items: center; justify-content: space-between;
@@ -4234,6 +4241,8 @@ var PLATFORM_FIELDS = { obv11: [
]},
{ key: 'remote_url', label: 'NapCat OneBot WS 地址', placeholder: '如: ws://127.0.0.1:10311', showIf: { key: 'mode', value: 'client' } },
{ key: 'access_token', label: 'Access Token (可选)', placeholder: '留空则不验证' },
{ key: 'http_url', label: 'NapCat HTTP API 地址 (可选)', placeholder: '如: http://127.0.0.1:6099, 留空则从WS地址推导', showIf: { key: 'mode', value: 'client' } },
{ key: 'http_token', label: 'HTTP API Token (可选)', placeholder: '留空则使用 Access Token', showIf: { key: 'mode', value: 'client' } },
{ key: 'bot_port', label: '本地监听端口', placeholder: '8096', showIf: { key: 'mode', value: 'server' } },
{ key: 'send_interval_ms', label: '消息发送间隔 (毫秒, 防封控)', placeholder: '2000' },
{ key: 'admin_uids', label: '管理员账号ID (多个用逗号分隔)', placeholder: '如: 123456789,987654321' }
@@ -5959,6 +5968,7 @@ function formatTokens(n) {
}
</script>
<script src="icons.js"></script>
<script src="iot-panel.js"></script>
<script>
// ========== 初始化 ==========