dsh-lm-memory 0.19.1 → 0.19.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,1283 @@
1
+ <!doctype html>
2
+ <html lang="zh-CN">
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <meta name="viewport" content="width=device-width,initial-scale=1">
6
+ <title>记忆库 · Lumen 控制台原型</title>
7
+ <style>
8
+ :root{
9
+ --bg:#05070c; --panel:#0a0e16; --panel2:#0d1219;
10
+ --ink:#e8edf4; --dim:#8fa0b5; --faint:#5c6b80;
11
+ --accent:#e8a13a; --accent-strong:#f2b544;
12
+ --line:rgba(255,255,255,.06); --hairline:rgba(255,255,255,.12);
13
+ --green:#3fbf8f; --blue:#6aa5e8; --red:#e0605c; --violet:#c9a7e0;
14
+ --spring:cubic-bezier(.32,.72,0,1);
15
+ --serif:"Songti SC","STSong","Noto Serif SC",serif;
16
+ --sans:"PingFang SC","Noto Sans SC",-apple-system,system-ui,sans-serif;
17
+ --mono:"JetBrains Mono","SF Mono",Menlo,monospace;
18
+ }
19
+ *{box-sizing:border-box;margin:0;padding:0}
20
+ body{
21
+ background:
22
+ radial-gradient(1200px 700px at 82% -12%, rgba(242,181,68,.06), transparent 60%),
23
+ radial-gradient(900px 600px at 6% 108%, rgba(14,32,25,.5), transparent 62%),
24
+ var(--bg);
25
+ color:var(--ink);font-family:var(--sans);font-size:15px;line-height:1.6;
26
+ min-height:100vh;overflow-x:clip;
27
+ }
28
+ body::after{content:"";position:fixed;inset:0;z-index:90;pointer-events:none;opacity:.045;
29
+ background-image:url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='140' height='140'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3'/></filter><rect width='140' height='140' filter='url(%23n)' opacity='.6'/></svg>")}
30
+ .shell{display:grid;grid-template-columns:236px minmax(0,1fr);min-height:100vh}
31
+
32
+ /* ---------- 侧栏 ---------- */
33
+ .side{position:sticky;top:0;height:100vh;display:flex;flex-direction:column;
34
+ border-right:1px solid var(--line);
35
+ background:linear-gradient(180deg,rgba(10,14,22,.9),rgba(6,8,13,.94));padding:24px 0 18px}
36
+ .brand{display:flex;align-items:center;gap:12px;padding:0 24px 30px}
37
+ .brand .dot{width:10px;height:10px;border-radius:50%;background:var(--accent-strong);
38
+ box-shadow:0 0 20px 5px rgba(242,181,68,.5);animation:breathe 8s ease-in-out infinite;flex:none}
39
+ .brand .t{font-family:var(--serif);font-size:16px;letter-spacing:.24em}
40
+ .brand .s{display:block;font-family:var(--mono);font-size:8.5px;letter-spacing:.3em;color:var(--faint);margin-top:2px}
41
+ .group{margin-bottom:6px}
42
+ .group .cap{font-family:var(--mono);font-size:9px;letter-spacing:.3em;color:var(--faint);padding:18px 24px 8px}
43
+ .item{position:relative;display:flex;align-items:center;gap:12px;padding:10px 24px;border-left:2px solid transparent;
44
+ font-size:13.5px;color:var(--dim);cursor:pointer;transition:background .35s var(--spring),color .35s var(--spring),border-color .35s var(--spring)}
45
+ .item svg{width:15px;height:15px;stroke:currentColor;fill:none;stroke-width:1.4;opacity:.75;flex:none}
46
+ .item:hover{background:rgba(255,255,255,.03);color:var(--ink)}
47
+ .item.on{color:var(--ink);background:rgba(242,181,68,.06);border-left-color:var(--accent-strong)}
48
+ .item.on svg{opacity:1;stroke:var(--accent-strong)}
49
+ .item .n{margin-left:auto;font-family:var(--mono);font-size:10px;color:var(--faint);letter-spacing:.04em}
50
+ .item.alert .n{color:var(--red);border:1px solid rgba(224,96,92,.35);background:rgba(224,96,92,.16);border-radius:999px;padding:0 8px}
51
+ .status{margin:auto 14px 0;border:1px solid var(--line);border-radius:12px;background:rgba(255,255,255,.015);padding:14px 16px}
52
+ .status .row{display:flex;justify-content:space-between;align-items:center;gap:8px;font-size:.74rem;color:var(--dim);padding:4px 0}
53
+ .status .row b{font-family:var(--mono);font-size:.68rem;font-weight:400;color:var(--ink);letter-spacing:.02em}
54
+ .status .pt{display:inline-flex;align-items:center;gap:6px;font-family:var(--mono);font-size:10.5px;color:var(--green)}
55
+ .status .pt::before{content:"";width:5px;height:5px;border-radius:50%;background:currentColor;box-shadow:0 0 8px rgba(63,191,143,.7)}
56
+ .status .pt.blue{color:var(--blue)}
57
+ .status .pt.blue::before{box-shadow:0 0 8px rgba(106,165,232,.7)}
58
+ .foot{padding:14px 0 0;text-align:center;font-family:var(--mono);font-size:.62rem;letter-spacing:.2em;color:var(--faint)}
59
+
60
+ /* ---------- 顶栏 ---------- */
61
+ .top{position:sticky;top:0;z-index:40;display:flex;align-items:center;gap:20px;
62
+ padding:20px 32px;border-bottom:1px solid var(--line);
63
+ background:rgba(6,8,13,.88);backdrop-filter:blur(12px)}
64
+ .top h1{font-family:var(--serif);font-weight:400;font-size:1.15rem;letter-spacing:.14em;white-space:nowrap}
65
+ .search{margin-left:auto;display:flex;align-items:center;gap:10px;width:min(360px,42vw);
66
+ border:1px solid var(--line);border-radius:999px;padding:8px 14px;background:rgba(255,255,255,.02);
67
+ transition:border-color .4s var(--spring),box-shadow .4s var(--spring)}
68
+ .search:focus-within{border-color:rgba(242,181,68,.4);box-shadow:0 0 24px rgba(242,181,68,.12)}
69
+ .search input{flex:1;background:none;border:0;outline:0;color:var(--ink);font-size:.82rem;font-family:var(--sans)}
70
+ .search input::placeholder{color:var(--faint)}
71
+ .search kbd{font-family:var(--mono);font-size:.62rem;color:var(--faint);border:1px solid var(--line);border-radius:5px;padding:1px 6px}
72
+ .clock{font-family:var(--mono);font-size:.74rem;letter-spacing:.14em;color:var(--dim);font-variant-numeric:tabular-nums;white-space:nowrap}
73
+ .avatar{width:34px;height:34px;border-radius:50%;background:linear-gradient(135deg,var(--accent-strong),#a86a1c);
74
+ display:flex;align-items:center;justify-content:center;font-size:.8rem;color:#0b0e14;font-weight:600;flex:none}
75
+
76
+ .content{padding:28px 32px 60px}
77
+ .view{display:none}
78
+ .view.on{display:block;animation:viewIn .5s var(--spring)}
79
+ @keyframes viewIn{from{opacity:0;transform:translateY(10px)}to{opacity:1;transform:none}}
80
+
81
+ /* ---------- KPI ---------- */
82
+ .kpis{display:grid;grid-template-columns:repeat(5,1fr);gap:16px;margin-bottom:22px}
83
+ .kpi{background:var(--panel2);border:1px solid var(--line);border-radius:16px;padding:20px 22px;position:relative;overflow:hidden;
84
+ transition:border-color .45s var(--spring),transform .45s var(--spring)}
85
+ .kpi:hover{border-color:rgba(242,181,68,.35);transform:translateY(-2px)}
86
+ .kpi .label{font-family:var(--mono);font-size:.62rem;letter-spacing:.24em;color:var(--dim);display:block;margin-bottom:10px}
87
+ .kpi .num{font-family:var(--mono);font-size:1.7rem;font-weight:400;letter-spacing:.01em;font-variant-numeric:tabular-nums;line-height:1.1}
88
+ .kpi .num i{font-style:normal;color:var(--accent-strong)}
89
+ .kpi .delta{display:inline-flex;align-items:center;gap:5px;margin-top:10px;font-family:var(--mono);font-size:.66rem;color:var(--faint)}
90
+ .kpi .delta.up{color:var(--green)}
91
+ .kpi.alert{border-color:rgba(224,96,92,.3)}
92
+ .kpi.alert .num,.kpi.alert .num i{color:var(--red)}
93
+ .kpi.alert::after{content:"";position:absolute;top:0;left:0;right:0;height:2px;background:linear-gradient(90deg,var(--red),transparent 70%)}
94
+ .kpi.link{cursor:pointer}
95
+
96
+ /* ---------- 卡片 ---------- */
97
+ .charts{display:grid;grid-template-columns:7fr 5fr;gap:16px;margin-bottom:22px}
98
+ .card{background:var(--panel2);border:1px solid var(--line);border-radius:16px;padding:22px 24px;min-width:0;overflow:hidden}
99
+ .card-head{display:flex;align-items:baseline;justify-content:space-between;margin-bottom:18px;gap:12px}
100
+ .card-head h3{font-family:var(--serif);font-weight:400;font-size:1.02rem;letter-spacing:.1em}
101
+ .card-head .meta{font-family:var(--mono);font-size:.64rem;letter-spacing:.16em;color:var(--faint)}
102
+ .chart-box{flex:1;display:flex;align-items:center}
103
+ .chart-box svg{width:100%;display:block}
104
+ .charts .card{display:flex;flex-direction:column}
105
+ .charts .legend{margin-top:auto}
106
+ .legend{display:flex;gap:18px;flex-wrap:wrap;margin-top:16px}
107
+ .legend .li{display:flex;align-items:center;gap:8px;font-size:.76rem;color:var(--dim)}
108
+ .legend .sw{width:9px;height:9px;border-radius:3px;display:inline-block}
109
+ .live{display:inline-flex;align-items:center;gap:7px;font-family:var(--mono);font-size:.66rem;letter-spacing:.2em;color:var(--green)}
110
+ .live::before{content:"";width:6px;height:6px;border-radius:50%;background:var(--green);box-shadow:0 0 8px rgba(63,191,143,.8);animation:pulse 1.8s ease-in-out infinite}
111
+ .js .chart-line{stroke-dasharray:1200;stroke-dashoffset:1200;animation:draw 1.8s var(--spring) .3s forwards}
112
+ @keyframes draw{to{stroke-dashoffset:0}}
113
+ .js .chart-area{opacity:0;animation:fadeA 1s ease .9s forwards}
114
+ @keyframes fadeA{to{opacity:1}}
115
+ .static .chart-line{stroke-dasharray:none;stroke-dashoffset:0;animation:none}
116
+ .static .chart-area{opacity:1;animation:none}
117
+ .donut-wrap{display:flex;align-items:center;gap:26px}
118
+ .dlist{flex:1;min-width:0}
119
+ .drow{display:flex;align-items:center;gap:10px;padding:8px 0;border-bottom:1px solid var(--line);font-size:.8rem}
120
+ .drow:last-child{border-bottom:none}
121
+ .drow .sw{width:9px;height:9px;border-radius:3px;flex:none}
122
+ .drow .dn{color:var(--dim);flex:1;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
123
+ .drow .dn em{font-family:var(--mono);font-size:.66rem;font-style:normal;color:var(--faint);margin-left:7px;letter-spacing:.08em}
124
+ .drow .dv{font-family:var(--mono);font-size:.74rem;color:var(--ink);font-variant-numeric:tabular-nums}
125
+ .drow .dp{font-family:var(--mono);font-size:.68rem;color:var(--faint);width:46px;text-align:right}
126
+
127
+ /* ---------- 表格 ---------- */
128
+ .table-card{background:var(--panel2);border:1px solid var(--line);border-radius:16px;overflow:hidden}
129
+ .table-head{display:flex;align-items:center;justify-content:space-between;padding:20px 24px 16px;gap:16px;flex-wrap:wrap}
130
+ .table-head h3{font-family:var(--serif);font-weight:400;font-size:1.02rem;letter-spacing:.1em}
131
+ .btn-mini{font-family:var(--mono);font-size:.68rem;letter-spacing:.16em;color:var(--accent);
132
+ border:1px solid rgba(232,161,58,.4);background:rgba(232,161,58,.07);border-radius:999px;padding:7px 18px;cursor:pointer;
133
+ transition:background .4s var(--spring),box-shadow .4s var(--spring)}
134
+ .btn-mini:hover{background:rgba(232,161,58,.16);box-shadow:0 0 20px rgba(242,181,68,.18)}
135
+ table{width:100%;border-collapse:collapse;table-layout:fixed}
136
+ .c-status{width:104px}.c-time{width:96px}.c-type{width:132px}.c-src{width:96px}.c-act{width:92px}
137
+ th{font-family:var(--mono);font-size:.62rem;letter-spacing:.22em;color:var(--faint);font-weight:400;text-align:left;
138
+ padding:10px 20px;border-top:1px solid var(--line);border-bottom:1px solid var(--line);background:rgba(255,255,255,.02);white-space:nowrap}
139
+ td{padding:14px 20px;border-bottom:1px solid var(--line);font-size:.83rem;vertical-align:middle}
140
+ tbody tr{cursor:pointer;transition:background .35s var(--spring)}
141
+ tbody tr:hover{background:rgba(242,181,68,.045)}
142
+ tbody tr:hover .mem-text{color:var(--ink)}
143
+ tr.conflict{background:rgba(224,96,92,.05)}
144
+ tr.conflict:hover{background:rgba(224,96,92,.09)}
145
+ .mem-text{color:var(--dim);transition:color .35s var(--spring);display:block;max-width:56ch;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
146
+ .td-time{font-family:var(--mono);font-size:.72rem;color:var(--faint);white-space:nowrap;font-variant-numeric:tabular-nums}
147
+ .td-type{font-family:var(--mono);font-size:.68rem;letter-spacing:.12em;color:var(--dim);white-space:nowrap}
148
+ .td-hit{font-family:var(--mono);font-size:.74rem;font-variant-numeric:tabular-nums;color:var(--ink);white-space:nowrap}
149
+ .hit-bar{display:inline-block;width:52px;height:3px;border-radius:2px;background:rgba(255,255,255,.08);margin-left:10px;vertical-align:middle;position:relative;overflow:hidden}
150
+ .hit-bar i{position:absolute;left:0;top:0;bottom:0;background:var(--accent);border-radius:2px}
151
+ .tag{display:inline-flex;align-items:center;gap:6px;font-family:var(--mono);font-size:.62rem;letter-spacing:.14em;border-radius:999px;padding:3px 11px;white-space:nowrap}
152
+ .tag::before{content:"";width:5px;height:5px;border-radius:50%;background:currentColor}
153
+ .tag.active{color:var(--accent);border:1px solid rgba(232,161,58,.4);background:rgba(242,181,68,.07)}
154
+ .tag.pin{color:var(--blue);border:1px solid rgba(106,165,232,.4);background:rgba(106,165,232,.08)}
155
+ .tag.sleep{color:var(--dim);border:1px solid var(--hairline);background:rgba(255,255,255,.03)}
156
+ .tag.conflict{color:var(--red);border:1px solid rgba(224,96,92,.4);background:rgba(224,96,92,.08)}
157
+ .row-act{font-family:var(--mono);font-size:.66rem;letter-spacing:.14em;color:var(--dim);border:1px solid var(--line);
158
+ border-radius:999px;padding:5px 14px;white-space:nowrap;cursor:pointer;background:none;
159
+ transition:color .35s var(--spring),border-color .35s var(--spring)}
160
+ .row-act:hover{color:var(--accent);border-color:rgba(232,161,58,.45)}
161
+ .row-act.warn{color:var(--red);border-color:rgba(224,96,92,.35)}
162
+ .t-audit .a-op{width:196px}
163
+ .t-audit .a-by{width:106px}
164
+ .td-type{overflow:hidden;text-overflow:ellipsis}
165
+ .srcdot{display:inline-block;width:5px;height:5px;border-radius:50%;margin-right:7px;vertical-align:middle;background:var(--faint)}
166
+ .srcdot.auto{background:var(--red)}
167
+ .srcdot.session{background:var(--blue)}
168
+ .srcdot.summary{background:var(--dim)}
169
+ .srcdot.lifeos{background:var(--ok,#3fbf8f)}
170
+ .srcdot.manual{background:var(--accent)}
171
+ .empty-row td{text-align:center;color:var(--faint);padding:36px;font-size:.84rem}
172
+
173
+ /* ---------- chips ---------- */
174
+ .chips{display:flex;gap:10px;flex-wrap:wrap;margin-bottom:18px}
175
+ .chip{font-family:var(--mono);font-size:.68rem;letter-spacing:.14em;color:var(--dim);border:1px solid var(--line);
176
+ border-radius:999px;padding:6px 16px;cursor:pointer;background:none;transition:all .4s var(--spring)}
177
+ .chip:hover{color:var(--ink);border-color:var(--hairline)}
178
+ .chip.on{color:#0b0e14;background:var(--accent-strong);border-color:var(--accent-strong)}
179
+
180
+ /* ---------- 冲突卡 ---------- */
181
+ .conflict-card{background:var(--panel2);border:1px solid rgba(224,96,92,.3);border-radius:16px;padding:24px 26px;margin-bottom:18px;
182
+ transition:opacity .6s var(--spring),transform .6s var(--spring)}
183
+ .conflict-card.done{opacity:.45}
184
+ .cc-head{display:flex;align-items:center;justify-content:space-between;margin-bottom:18px;gap:12px;flex-wrap:wrap}
185
+ .cc-title{font-size:.9rem}
186
+ .cc-title .meta{font-family:var(--mono);font-size:.66rem;color:var(--faint);letter-spacing:.1em;margin-left:12px}
187
+ .cc-versions{display:grid;grid-template-columns:1fr 1fr;gap:14px}
188
+ .cc-ver{border:1px solid var(--line);border-radius:12px;padding:16px 18px;background:rgba(255,255,255,.02);cursor:pointer;
189
+ transition:border-color .4s var(--spring),background .4s var(--spring)}
190
+ .cc-ver:hover{border-color:rgba(242,181,68,.35);background:rgba(242,181,68,.04)}
191
+ .cc-ver .vh{display:flex;align-items:center;gap:10px;margin-bottom:10px}
192
+ .open-hint{margin-left:auto;font-family:var(--mono);font-size:.6rem;letter-spacing:.12em;color:var(--faint);opacity:0;transition:opacity .35s var(--spring),color .35s var(--spring)}
193
+ .cc-ver:hover .open-hint{opacity:1;color:var(--accent)}
194
+ .cc-ver p{font-size:.79rem;color:var(--dim);line-height:1.7}
195
+ .cc-acts{display:flex;gap:10px;margin-top:18px;flex-wrap:wrap}
196
+
197
+ /* ---------- 模态 ---------- */
198
+ .modal{position:fixed;inset:0;z-index:80;display:none;align-items:center;justify-content:center;padding:40px;background:rgba(3,5,9,.72);backdrop-filter:blur(6px)}
199
+ .modal.on{display:flex;animation:fadeA .3s ease both}
200
+ .sheet{width:min(760px,100%);max-height:82vh;overflow:auto;border:1px solid var(--hairline);border-radius:18px;
201
+ background:linear-gradient(180deg,#0c1119,#080c13);padding:26px 28px 22px;box-shadow:0 40px 120px -40px rgba(0,0,0,.9)}
202
+ .sheet h3{font-family:var(--serif);font-weight:400;font-size:1.2rem;letter-spacing:.12em;margin-bottom:6px}
203
+ .sheet .meta{font-family:var(--mono);font-size:.66rem;letter-spacing:.14em;color:var(--faint);display:flex;gap:14px;flex-wrap:wrap;margin-bottom:16px}
204
+ .sheet .body{font-size:.9rem;line-height:1.85;white-space:pre-wrap;word-break:break-word}
205
+ .sheet .tagline{margin-top:14px;font-family:var(--mono);font-size:.68rem;color:var(--faint);word-break:break-all}
206
+ .sheet .acts{display:flex;gap:10px;flex-wrap:wrap;margin-top:20px;padding-top:16px;border-top:1px solid var(--line)}
207
+ .toast{position:fixed;right:24px;top:20px;z-index:95;transform:translateX(140%);opacity:0;
208
+ transition:transform .5s var(--spring),opacity .4s;border:1px solid rgba(242,181,68,.35);background:rgba(16,20,28,.96);
209
+ font-size:.78rem;padding:10px 16px;border-radius:12px;box-shadow:0 20px 60px -20px rgba(0,0,0,.9);max-width:340px}
210
+ .toast.on{transform:none;opacity:1}
211
+
212
+ ::-webkit-scrollbar{width:9px;height:9px}
213
+ ::-webkit-scrollbar-thumb{background:rgba(255,255,255,.1);border-radius:99px}
214
+ ::-webkit-scrollbar-thumb:hover{background:rgba(242,181,68,.3)}
215
+ ::-webkit-scrollbar-track{background:transparent}
216
+ @keyframes breathe{0%,100%{box-shadow:0 0 18px 4px rgba(242,181,68,.4)}50%{box-shadow:0 0 30px 10px rgba(242,181,68,.6)}}
217
+ @keyframes pulse{0%,100%{opacity:1}50%{opacity:.35}}
218
+ @media (prefers-reduced-motion:reduce){*{animation:none!important;transition:none!important}}
219
+ .static *{animation:none!important;transition:none!important}
220
+
221
+ @media (max-width:1400px){
222
+ td,th{padding-left:14px;padding-right:14px}
223
+ .c-status{width:92px}.c-time{width:88px}.c-type{width:118px}.c-src{width:80px}.c-act{width:72px}
224
+ .mem-text{max-width:38ch}
225
+ }
226
+ @media (max-width:1180px){.kpis{grid-template-columns:repeat(3,1fr)}.charts{grid-template-columns:1fr}}
227
+ @media (max-width:860px){
228
+ .shell{grid-template-columns:1fr}
229
+ .side{position:static;height:auto;flex-direction:row;flex-wrap:wrap;align-items:center;padding:12px 10px;gap:6px;overflow:hidden}
230
+ .item{border-left-width:0;padding:8px 10px;border-radius:8px}
231
+ .brand{padding:0 12px 0 0}
232
+ .group{display:flex;flex-wrap:wrap;gap:6px;padding:0;margin:0;min-width:0}
233
+ .group .cap,.status,.foot{display:none}
234
+ .top{padding:14px 18px;flex-wrap:wrap}
235
+ .search{width:100%;margin-left:0;order:3}
236
+ .content{padding:20px 18px 40px}
237
+ .kpis{grid-template-columns:repeat(2,1fr)}
238
+ .cc-versions{grid-template-columns:1fr}
239
+ .mem-text{max-width:26ch}
240
+ .donut-wrap{flex-direction:column;align-items:flex-start}
241
+ }
242
+ @media (max-width:1100px){
243
+ .c-src{display:none}
244
+ .mem-text{max-width:30ch}
245
+ }
246
+ @media (max-width:820px){
247
+ .c-act,th.c-act{display:none}
248
+ }
249
+ @media (max-width:700px){
250
+ .c-time,th.c-time{display:none}
251
+ }
252
+ </style>
253
+ </head>
254
+ <body>
255
+ <div class="shell">
256
+ <aside class="side">
257
+ <div class="brand"><span class="dot"></span><span><span class="t">记忆库</span><span class="s">LIVING MEMORY</span></span></div>
258
+
259
+ <div class="group">
260
+ <div class="cap">监控</div>
261
+ <div class="item" data-go="overview"><svg viewBox="0 0 16 16"><rect x="2" y="2" width="5" height="5" rx="1"/><rect x="9" y="2" width="5" height="5" rx="1"/><rect x="2" y="9" width="5" height="5" rx="1"/><rect x="9" y="9" width="5" height="5" rx="1"/></svg>总览<span class="n" id="b-total">0</span></div>
262
+ <div class="item" data-go="events"><svg viewBox="0 0 16 16"><path d="M2 12l3-4 3 2 6-7"/></svg>事件流<span class="n" id="b-events">0</span></div>
263
+ <div class="item" data-go="profile"><svg viewBox="0 0 16 16"><circle cx="8" cy="5.5" r="2.6"/><path d="M2.8 14c.6-2.7 2.7-4.2 5.2-4.2s4.6 1.5 5.2 4.2"/></svg>用户画像</div>
264
+ <div class="item" data-go="all"><svg viewBox="0 0 16 16"><path d="M3 4h10M3 8h10M3 12h6"/></svg>全部条目<span class="n" id="b-all">0</span></div>
265
+ <div class="item" data-go="pinned"><svg viewBox="0 0 16 16"><path d="M4 2h8v12l-4-3-4 3z"/></svg>置顶<span class="n" id="b-pin">0</span></div>
266
+ <div class="item" data-go="dormant"><svg viewBox="0 0 16 16"><path d="M13 9.5A5.5 5.5 0 1 1 6.5 3a4.5 4.5 0 0 0 6.5 6.5z"/></svg>休眠队列<span class="n" id="b-dorm">0</span></div>
267
+ </div>
268
+
269
+ <div class="group">
270
+ <div class="cap">维护</div>
271
+ <div class="item alert" data-go="conflicts"><svg viewBox="0 0 16 16"><path d="M8 2v9M8 13.5v.5"/></svg>冲突裁决<span class="n" id="b-conf">0</span></div>
272
+ <div class="item" data-go="graph"><svg viewBox="0 0 16 16"><circle cx="4" cy="5" r="1.6"/><circle cx="12" cy="4" r="1.6"/><circle cx="9" cy="12" r="1.6"/><path d="M5.4 5.6l5.2-1M5.1 6.3l3 4.4M10.8 5.1l-1.2 5.3"/></svg>关联图谱<span class="n" id="b-graph">0</span></div>
273
+ <div class="item" data-go="signals"><svg viewBox="0 0 16 16"><path d="M2 12l3.5-5 3 3L14 4"/></svg>标签来源</div>
274
+ </div>
275
+
276
+ <div class="group">
277
+ <div class="cap">系统</div>
278
+ <div class="item" id="engine-info"><svg viewBox="0 0 16 16"><circle cx="8" cy="8" r="2.2"/><path d="M8 1.6v2M8 12.4v2M1.6 8h2M12.4 8h2M3.5 3.5l1.4 1.4M11.1 11.1l1.4 1.4M12.5 3.5l-1.4 1.4M4.9 11.1l-1.4 1.4"/></svg>引擎信息</div>
279
+ <div class="item" data-go="audit"><svg viewBox="0 0 16 16"><path d="M3 3h10v10H3z"/><path d="M5.5 6h5M5.5 8.5h5M5.5 11h3"/></svg>审计日志<span class="n" id="b-audit">0</span></div>
280
+ <div class="item" id="copy-db"><svg viewBox="0 0 16 16"><path d="M3 5.5h10v8H3z"/><path d="M5.5 5.5V2.5h8v8h-3"/></svg>数据目录</div>
281
+ </div>
282
+
283
+ <div class="status">
284
+ <div class="row"><span>引擎状态</span><span class="pt">运行中</span></div>
285
+ <div class="row"><span>SQLite</span><span class="pt blue">正常</span></div>
286
+ <div class="row"><span>休眠队列</span><b id="s-dorm">0 条</b></div>
287
+ <div class="row"><span>快照时间</span><b id="s-snap">刚刚</b></div>
288
+ </div>
289
+ <div class="foot">LM-MEMORY V<span id="f-ver">0.0.0</span></div>
290
+ </aside>
291
+
292
+ <main>
293
+ <div class="top">
294
+ <h1 id="page-title">总览</h1>
295
+ <label class="search">
296
+ <span style="color:var(--faint)" aria-hidden="true">⌕</span>
297
+ <input id="q" type="search" placeholder="检索记忆:内容或标签" aria-label="检索记忆">
298
+ <kbd>⌘K</kbd>
299
+ </label>
300
+ <span class="clock" id="clock">--:--:--</span>
301
+ <span class="avatar">记</span>
302
+ </div>
303
+
304
+ <div class="content">
305
+ <section class="view on" id="view-overview">
306
+ <div class="kpis">
307
+ <div class="card kpi"><span class="label">活跃记忆</span><div class="num"><i data-count="total">0</i></div><span class="delta up" id="d-recent">近 7 天</span></div>
308
+ <div class="card kpi"><span class="label">置顶</span><div class="num" data-count="pinned">0</div><span class="delta">整条进启动索引</span></div>
309
+ <div class="card kpi"><span class="label">休眠</span><div class="num" data-count="dormant">0</div><span class="delta">长期未召回</span></div>
310
+ <div class="card kpi"><span class="label">会话来源</span><div class="num" data-count="sessions">0</div><span class="delta">可追溯对话数</span></div>
311
+ <div class="card kpi alert link" data-go="conflicts"><span class="label">待裁决冲突</span><div class="num"><i data-count="conflicts">0</i></div><span class="delta">点击前往裁决</span></div>
312
+ </div>
313
+
314
+ <div class="charts">
315
+ <div class="card">
316
+ <div class="card-head"><h3>写入趋势 · 近 14 天</h3><span class="live">LIVE TOTAL <span id="trend-total">0</span></span></div>
317
+ <div class="chart-box"><svg id="trend" viewBox="0 0 720 300" role="img" aria-label="近十四天写入趋势"></svg></div>
318
+ <div class="legend"><div class="li"><span class="sw" style="background:var(--accent-strong)"></span>每日新增记忆</div><div class="li"><span class="sw" style="background:rgba(242,181,68,.16)"></span>面积渐变</div></div>
319
+ </div>
320
+ <div class="card">
321
+ <div class="card-head"><h3>记忆类型分布</h3><span class="meta">BY KIND</span></div>
322
+ <div class="donut-wrap">
323
+ <svg id="donut" width="150" height="150" viewBox="0 0 150 150" role="img" aria-label="记忆类型分布"></svg>
324
+ <div class="dlist" id="donut-list"></div>
325
+ </div>
326
+ </div>
327
+ </div>
328
+
329
+ <div class="table-card">
330
+ <div class="table-head"><h3>最近写入的记忆</h3><button class="btn-mini" data-go="all">查看全部</button></div>
331
+ <table><thead><tr><th class="c-status">状态</th><th class="c-time">写入时间</th><th class="c-type">类型</th><th>内容摘要</th><th class="c-src">版本</th><th class="c-act">操作</th></tr></thead>
332
+ <tbody id="recent-rows"></tbody></table>
333
+ </div>
334
+ </section>
335
+
336
+ <section class="view" id="view-events">
337
+ <div class="kpis">
338
+ <div class="card kpi"><span class="label">近 24 小时事件</span><div class="num" data-count="last24">0</div><span class="delta">变更流总条数</span></div>
339
+ <div class="card kpi"><span class="label">新增记忆</span><div class="num" data-count="writes24">0</div><span class="delta">写入类事件</span></div>
340
+ <div class="card kpi"><span class="label">修正</span><div class="num" data-count="corrections24">0</div><span class="delta">生成新版本</span></div>
341
+ <div class="card kpi alert"><span class="label">失败任务</span><div class="num"><i data-count="failures24">0</i></div><span class="delta">提炼超时或模型报错</span></div>
342
+ <div class="card kpi"><span class="label">最近冲突扫描</span><div class="num"><i id="sweep">0</i></div><span class="delta">组待复核</span></div>
343
+ </div>
344
+ <div class="charts">
345
+ <div class="card">
346
+ <div class="card-head"><h3>事件密度 · 近 24 小时</h3><span class="live">LIVE <span id="events-total">0</span></span></div>
347
+ <div class="chart-box"><svg id="hours" viewBox="0 0 720 300" role="img" aria-label="近二十四小时事件密度"></svg></div>
348
+ <div class="legend"><div class="li"><span class="sw" style="background:var(--accent-strong)"></span>每小时变更条数</div></div>
349
+ </div>
350
+ <div class="card">
351
+ <div class="card-head"><h3>异常</h3><span class="meta" id="fail-meta">来自审计日志</span></div>
352
+ <div id="failure-list" style="display:grid;gap:10px"></div>
353
+ </div>
354
+ </div>
355
+ <div class="table-card">
356
+ <div class="table-head"><h3>最近变更</h3><span class="meta">点击行查看对应记忆</span></div>
357
+ <table><thead><tr><th class="c-status">事件</th><th class="c-time">时间</th><th class="c-type">对象</th><th>摘要</th><th class="c-src">类型</th><th class="c-act">操作</th></tr></thead>
358
+ <tbody id="event-rows"></tbody></table>
359
+ </div>
360
+ </section>
361
+
362
+ <section class="view" id="view-profile">
363
+ <div class="kpis">
364
+ <div class="card kpi"><span class="label">身份线索</span><div class="num" data-count="pId">0</div><span class="delta">事实类条目</span></div>
365
+ <div class="card kpi"><span class="label">偏好</span><div class="num" data-count="pPref">0</div><span class="delta">沟通与审美</span></div>
366
+ <div class="card kpi"><span class="label">待办</span><div class="num" data-count="pTodo">0</div><span class="delta">未完成事项</span></div>
367
+ <div class="card kpi"><span class="label">经验</span><div class="num" data-count="pProc">0</div><span class="delta">可复用做法</span></div>
368
+ <div class="card kpi"><span class="label">会话摘要</span><div class="num" data-count="pEp">0</div><span class="delta">近期对话</span></div>
369
+ </div>
370
+ <div class="charts" style="grid-template-columns:1.35fr 1fr">
371
+ <div class="card">
372
+ <div class="card-head"><h3>画像正文</h3><span style="display:flex;align-items:center;gap:10px"><span class="meta" id="p-time">生成于</span><span id="p-lag"></span></span></div>
373
+ <div id="profile-body" style="display:grid;gap:10px"></div>
374
+ <div class="legend" style="justify-content:space-between">
375
+ <span style="font-family:var(--mono);font-size:.64rem;letter-spacing:.14em;color:var(--faint)">由模型从记忆库归纳,可能滞后于最新写入</span>
376
+ <button class="btn-mini" id="p-refresh">重新生成</button>
377
+ </div>
378
+ </div>
379
+ <div class="card">
380
+ <div class="card-head"><h3>关键词</h3><span class="meta">BY FREQUENCY</span></div>
381
+ <div id="p-keywords" style="display:flex;flex-wrap:wrap;gap:8px"></div>
382
+ <div class="card-head" style="margin-top:22px"><h3>取样</h3><span class="meta">最近写入</span></div>
383
+ <div id="p-samples"></div>
384
+ </div>
385
+ </div>
386
+ </section>
387
+
388
+ <section class="view" id="view-all">
389
+ <div class="chips" id="kind-chips"></div>
390
+ <div class="table-card">
391
+ <div class="table-head"><h3>全部条目</h3><span class="meta" id="all-count"></span></div>
392
+ <table><thead><tr><th class="c-status">状态</th><th class="c-time">写入时间</th><th class="c-type">类型</th><th>内容摘要</th><th class="c-src">版本</th><th class="c-act">操作</th></tr></thead>
393
+ <tbody id="all-rows"></tbody></table>
394
+ <div class="empty-row" id="all-empty" hidden><table><tbody><tr><td>没有符合条件的记忆</td></tr></tbody></table></div>
395
+ </div>
396
+ </section>
397
+
398
+ <section class="view" id="view-pinned">
399
+ <div class="table-card">
400
+ <div class="table-head"><h3>置顶记忆</h3><span class="meta">整条展开进启动索引</span></div>
401
+ <table><thead><tr><th class="c-status">状态</th><th class="c-time">写入时间</th><th class="c-type">类型</th><th>内容摘要</th><th class="c-src">版本</th><th class="c-act">操作</th></tr></thead>
402
+ <tbody id="pin-rows"></tbody></table>
403
+ <div class="empty-row" id="pin-empty" hidden><table><tbody><tr><td>当前没有置顶记忆</td></tr></tbody></table></div>
404
+ </div>
405
+ </section>
406
+
407
+ <section class="view" id="view-dormant">
408
+ <div class="kpis">
409
+ <div class="card kpi"><span class="label">休眠中</span><div class="num" data-count="dormantCount">0</div><span class="delta">默认召回不含</span></div>
410
+ <div class="card kpi"><span class="label">置顶豁免</span><div class="num" data-count="pinnedCount">0</div><span class="delta">置顶永不休眠</span></div>
411
+ <div class="card kpi"><span class="label">可唤醒</span><div class="num">可</div><span class="delta">memory_pin wake</span></div>
412
+ <div class="card kpi"><span class="label">恢复策略</span><div class="num" style="font-size:1.05rem">降可见度</div><span class="delta">不是删除</span></div>
413
+ <div class="card kpi"><span class="label">最近整理</span><div class="num" style="font-size:1.05rem" id="sweep-time">待运行</div><span class="delta">sleep_pass</span></div>
414
+ </div>
415
+ <div class="table-card">
416
+ <div class="table-head"><h3>休眠队列</h3><button class="btn-mini" id="sleep-run">运行休眠整理</button></div>
417
+ <table><thead><tr><th class="c-status">状态</th><th class="c-time">转入时间</th><th class="c-type">类型</th><th>内容摘要</th><th class="c-src">命中</th><th class="c-act">操作</th></tr></thead>
418
+ <tbody id="dormant-rows"></tbody></table>
419
+ <div class="card" style="margin:0;border:0;border-top:1px solid var(--line);border-radius:0;background:none">
420
+ <div style="font-size:.76rem;color:var(--faint);line-height:1.8">
421
+ 规则:置顶永不休眠;召回与反馈会续租;休眠只是降低可见度,条目仍在库里,<span style="font-family:var(--mono)">scope:"dormant"</span> 可查、可唤醒。
422
+ </div>
423
+ </div>
424
+ </div>
425
+ </section>
426
+
427
+ <section class="view" id="view-audit">
428
+ <div class="kpis">
429
+ <div class="card kpi"><span class="label">审计事件</span><div class="num" data-count="auditRows">0</div><span class="delta">最近样本</span></div>
430
+ <div class="card kpi"><span class="label">操作类型</span><div class="num" data-count="auditOps">0</div><span class="delta">去重后</span></div>
431
+ <div class="card kpi alert"><span class="label">失败记录</span><div class="num"><i id="audit-fail">0</i></div><span class="delta">提炼或复核出错</span></div>
432
+ <div class="card kpi"><span class="label">写入类</span><div class="num" id="audit-write">0</div><span class="delta">remember / correct</span></div>
433
+ <div class="card kpi"><span class="label">后台任务</span><div class="num" id="audit-job">0</div><span class="delta">派发 / 领取 / 结算</span></div>
434
+ </div>
435
+ <div class="chips" id="audit-chips"></div>
436
+ <div class="table-card">
437
+ <div class="table-head"><h3>审计日志</h3><span class="meta" id="audit-count"></span></div>
438
+ <table class="t-audit"><thead><tr><th class="c-status">状态</th><th class="c-time">时间</th><th class="a-op">操作</th><th class="a-by">来源</th><th>详情</th></tr></thead>
439
+ <tbody id="audit-rows"></tbody></table>
440
+ </div>
441
+ </section>
442
+
443
+ <section class="view" id="view-conflicts">
444
+ <div style="font-family:var(--mono);font-size:.66rem;letter-spacing:.14em;color:var(--faint);margin-bottom:14px">点任一卡片查看全文与来源回查,看完再决定采纳或保留</div>
445
+ <div id="pairs"></div>
446
+ </section>
447
+
448
+ <section class="view" id="view-graph">
449
+ <div class="card" style="margin-bottom:16px">
450
+ <div class="card-head"><h3>邻域速写</h3><span class="meta">最活跃节点的直接连线</span></div>
451
+ <div class="chart-box"><svg id="neighbourhood" viewBox="0 0 720 360" role="img" aria-label="最活跃记忆的邻域"></svg></div>
452
+ <div class="legend" id="hub-legend"></div>
453
+ </div>
454
+ <div class="charts">
455
+ <div class="card"><div class="card-head"><h3>关系分布</h3><span class="meta">条数</span></div><div id="rel-bars"></div></div>
456
+ <div class="card"><div class="card-head"><h3>连线最多</h3><span class="meta">度 · 上限 32</span></div><div id="degree-bars"></div></div>
457
+ </div>
458
+ </section>
459
+
460
+ <section class="view" id="view-signals">
461
+ <div class="charts">
462
+ <div class="card"><div class="card-head"><h3>标签占比</h3><span class="meta">按出现次数</span></div><div id="tag-bars"></div></div>
463
+ <div class="card">
464
+ <div class="card-head"><h3>来源说明</h3><span class="meta">只读</span></div>
465
+ <div style="display:grid;gap:12px;font-size:.78rem;color:var(--dim);line-height:1.8">
466
+ <div><span class="tag conflict">自动提炼</span> 未经过语义验证,引用前先用来源回查。</div>
467
+ <div><span class="tag pin">会话</span> 带会话编号,可追溯到具体一次对话。</div>
468
+ <div><span class="tag sleep">摘要</span> 会话摘要,用于跨会话复述,不承载细节。</div>
469
+ <div><span class="tag active">正册</span> 来自 LifeOS 串库写入,与正册档案互为指针。</div>
470
+ </div>
471
+ </div>
472
+ </div>
473
+ </section>
474
+ </div>
475
+ </main>
476
+ </div>
477
+
478
+ <div class="modal" id="modal" role="dialog" aria-modal="true" aria-labelledby="m-title">
479
+ <div class="sheet">
480
+ <h3 id="m-title">记忆详情</h3>
481
+ <div class="meta"><span id="m-id"></span><span id="m-kind"></span><span id="m-date"></span><span id="m-ver"></span><span id="m-hit"></span></div>
482
+ <div class="body" id="m-body"></div>
483
+ <div class="tagline" id="m-tags"></div>
484
+ <div id="m-source" style="margin-top:16px;border-top:1px solid var(--line);padding-top:14px"></div>
485
+ <div class="acts">
486
+ <button class="btn-mini" id="m-adopt" hidden>采纳这一版</button>
487
+ <button class="btn-mini" id="m-keep" hidden style="color:var(--dim);border-color:var(--line);background:none">保留另一版</button>
488
+ <button class="btn-mini" data-act="copy">复制内容</button>
489
+ <button class="btn-mini" data-act="pin">置顶</button>
490
+ <button class="btn-mini" data-act="correct">修正</button>
491
+ <button class="btn-mini" data-act="forget" style="color:var(--red);border-color:rgba(224,96,92,.35);background:rgba(224,96,92,.07)">删除</button>
492
+ <button class="btn-mini" data-act="close" style="margin-left:auto">关闭</button>
493
+ </div>
494
+ </div>
495
+ </div>
496
+ <div class="toast" id="toast" role="status"></div>
497
+
498
+ <script>window.onerror = function (m) { document.title = 'ERR ' + m; };</script>
499
+ <script>
500
+ const SNAPSHOT = null;
501
+ const LIVE = SNAPSHOT === null;
502
+ let DATA = SNAPSHOT;
503
+ const $ = s => document.querySelector(s);
504
+ const el = (t, c, x) => { const n = document.createElement(t); if (c) n.className = c; if (x != null) n.textContent = x; return n; };
505
+ const fmt = n => Number(n).toLocaleString('en-US');
506
+ const KIND = { fact: '事实', procedure: '经验', preference: '偏好', episode: '会话', todo: '待办' };
507
+ const KIND_EN = { fact: 'fact', procedure: 'procedure', preference: 'preference', episode: 'episode', todo: 'todo' };
508
+ const SOURCE = { auto: '自动提炼', session: '会话', summary: '摘要', lifeos: '正册', manual: '手工' };
509
+ const STATUS = { active: ['活跃', 'active'], pin: ['置顶', 'pin'], conflict: ['冲突待裁', 'conflict'], sleep: ['休眠', 'sleep'] };
510
+ const esc = s => String(s).replace(/[&<>"]/g, c => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;' }[c]));
511
+ const day = v => new Date(v).toLocaleDateString('sv', { timeZone: 'Asia/Shanghai' });
512
+
513
+ let current = null;
514
+ let kind = 'all';
515
+ let query = '';
516
+
517
+ function toast(text) {
518
+ const t = $('#toast');
519
+ t.textContent = text;
520
+ t.classList.add('on');
521
+ clearTimeout(toast.timer);
522
+ toast.timer = setTimeout(() => t.classList.remove('on'), 2800);
523
+ }
524
+
525
+ function countUp(node, value) {
526
+ if (node.dataset.done === '1') return;
527
+ node.dataset.done = '1';
528
+ if (document.body.classList.contains('static') || matchMedia('(prefers-reduced-motion: reduce)').matches) { node.textContent = fmt(value); return; }
529
+ const t0 = performance.now();
530
+ const step = now => {
531
+ const p = Math.min(1, (now - t0) / 1200);
532
+ node.textContent = fmt(Math.round(value * (1 - Math.pow(1 - p, 3))));
533
+ if (p < 1) requestAnimationFrame(step);
534
+ };
535
+ requestAnimationFrame(step);
536
+ }
537
+
538
+ function match(item) {
539
+ if (kind !== 'all' && item.kind !== kind) return false;
540
+ if (!query) return true;
541
+ return (item.content + ' ' + item.tags).toLowerCase().includes(query);
542
+ }
543
+
544
+ function row(item) {
545
+ const tr = el('tr');
546
+ if (item.status === 'conflict') tr.className = 'conflict';
547
+ const [label, cls] = STATUS[item.status] ?? STATUS.active;
548
+ tr.innerHTML = '<td class="c-status"><span class="tag ' + cls + '">' + label + '</span></td>'
549
+ + '<td class="td-time c-time">' + day(item.date).slice(5) + ' ' + item.time + '</td>'
550
+ + '<td class="td-type c-type"><span class="srcdot ' + item.source + '" title="来源:' + (SOURCE[item.source] ?? item.source) + '"></span>' + (KIND_EN[item.kind] ?? item.kind).toUpperCase() + '</td>'
551
+ + '<td><span class="mem-text">' + esc(item.content) + '</span></td>'
552
+ + '<td class="td-hit c-src">v' + item.version + '<span class="hit-bar"><i style="width:' + Math.min(100, 24 + item.version * 14) + '%"></i></span></td>'
553
+ + '<td class="c-act"><button class="row-act" type="button">审计</button></td>';
554
+ tr.addEventListener('click', () => openDetail(item));
555
+ return tr;
556
+ }
557
+
558
+ function fill(target, list, empty) {
559
+ const body = $(target);
560
+ body.replaceChildren();
561
+ const shown = list.slice(0, 120);
562
+ for (const item of shown) body.appendChild(row(item));
563
+ if (!shown.length) {
564
+ const tr = el('tr', 'empty-row');
565
+ tr.innerHTML = '<td colspan="6">没有符合条件的记忆</td>';
566
+ body.appendChild(tr);
567
+ }
568
+ if (empty) $(empty).hidden = shown.length > 0;
569
+ return shown.length;
570
+ }
571
+
572
+ function renderAll() {
573
+ const list = DATA.items.filter(match).sort((a, b) => b.id - a.id);
574
+ fill('#all-rows', list);
575
+ $('#all-count').textContent = fmt(list.length) + ' / ' + fmt(DATA.total);
576
+ }
577
+ function renderPinned() { fill('#pin-rows', DATA.items.filter(i => i.pinned === 1 && match(i))); }
578
+ function renderRecent() { fill('#recent-rows', [...DATA.items].sort((a, b) => b.id - a.id).slice(0, 7)); }
579
+
580
+ const OPLABEL = { remember: '新增', episode: '会话卡', ingest: '入库', correct: '修正', forget: '删除', conflict_sweep: '冲突扫描', dormant: '休眠' };
581
+ const OPCLASS = { remember: 'active', episode: 'sleep', ingest: 'pin', correct: 'pin', forget: 'conflict', conflict_sweep: 'conflict', dormant: 'sleep' };
582
+
583
+ function renderHours() {
584
+ const svg = $('#hours');
585
+ const W = 720, H = 300, L = 40, R = 16, T = 24, B = 38;
586
+ const s = DATA.monitor.hours;
587
+ const max = Math.max(1, ...s.map(p => p.n));
588
+ const bw = (W - L - R) / s.length;
589
+ let out = '';
590
+ for (let g = 0; g <= 3; g++) {
591
+ const y = T + (g / 3) * (H - T - B);
592
+ out += '<line x1="' + L + '" y1="' + y + '" x2="' + (W - R) + '" y2="' + y + '" stroke="rgba(255,255,255,.045)" stroke-dasharray="2 4"/>';
593
+ out += '<text x="' + (L - 8) + '" y="' + (y + 3) + '" fill="#5c6b80" font-size="9.5" font-family="ui-monospace,monospace" text-anchor="end">' + Math.round(max * (1 - g / 3)) + '</text>';
594
+ }
595
+ s.forEach((p, i) => {
596
+ const h = (p.n / max) * (H - T - B);
597
+ const x = L + i * bw + bw * 0.22;
598
+ out += '<rect x="' + x.toFixed(1) + '" y="' + (H - B - h).toFixed(1) + '" width="' + (bw * 0.56).toFixed(1) + '" height="' + Math.max(0, h).toFixed(1) + '" rx="1.5" fill="' + (p.n ? 'rgba(242,181,68,.72)' : 'rgba(255,255,255,.05)') + '"/>';
599
+ if (i % 3 === 0) out += '<text x="' + (x + bw * 0.28).toFixed(1) + '" y="' + (H - 12) + '" fill="#5c6b80" font-size="9.5" font-family="ui-monospace,monospace" text-anchor="middle">' + p.hour + '</text>';
600
+ });
601
+ svg.innerHTML = out;
602
+ $('#events-total').textContent = fmt(DATA.monitor.last24);
603
+ }
604
+
605
+ function renderEvents() {
606
+ const body = $('#event-rows');
607
+ body.replaceChildren();
608
+ for (const e of DATA.monitor.events) {
609
+ const tr = el('tr');
610
+ tr.innerHTML = '<td class="c-status"><span class="tag ' + (OPCLASS[e.op] ?? 'sleep') + '">' + (OPLABEL[e.op] ?? e.op) + '</span></td>'
611
+ + '<td class="td-time c-time">' + new Date(e.ts).toLocaleTimeString('zh-CN', { hour12: false, timeZone: 'Asia/Shanghai' }) + '</td>'
612
+ + '<td class="td-type c-type">' + (e.id ? '#' + e.id : '无对象') + '</td>'
613
+ + '<td><span class="mem-text">' + esc(e.clip) + '</span></td>'
614
+ + '<td class="td-type c-src">' + (e.kind ? (KIND_EN[e.kind] ?? e.kind).toUpperCase() : '') + '</td>'
615
+ + '<td class="c-act"><button class="row-act" type="button">定位</button></td>';
616
+ tr.addEventListener('click', () => {
617
+ const target = DATA.items.find(i => i.id === e.id);
618
+ if (target) openDetail(target); else toast('这条事件对应的记忆不在当前快照里');
619
+ });
620
+ body.appendChild(tr);
621
+ }
622
+ $('#fail-meta').textContent = '24 小时 ' + DATA.monitor.failures24 + ' 条 · 显示最近 ' + DATA.monitor.failures.length + ' 条';
623
+ const list = $('#failure-list');
624
+ list.replaceChildren();
625
+ if (!DATA.monitor.failures.length) {
626
+ const d = el('div'); d.style.cssText = 'font-size:.78rem;color:var(--faint)'; d.textContent = '最近没有失败记录'; list.appendChild(d);
627
+ }
628
+ for (const f of DATA.monitor.failures) {
629
+ const d = el('div');
630
+ d.style.cssText = 'border:1px solid rgba(224,96,92,.25);background:rgba(224,96,92,.06);border-radius:10px;padding:10px 12px;font-size:.74rem;line-height:1.6;overflow-wrap:anywhere';
631
+ d.innerHTML = '<div style="color:var(--red);font-family:var(--mono);letter-spacing:.08em">' + esc(f.op) + '</div>'
632
+ + '<div style="color:var(--faint);font-family:var(--mono);margin-top:4px">' + new Date(f.ts).toLocaleString('zh-CN', { hour12: false }) + (f.session ? ' · ' + esc(f.session) : '') + (f.attempts ? ' · ' + f.attempts + ' 次' : '') + '</div>';
633
+ list.appendChild(d);
634
+ }
635
+ }
636
+
637
+ function renderTrend() {
638
+ const svg = $('#trend');
639
+ const W = 720, H = 300, L = 44, R = 18, T = 26, B = 40;
640
+ const s = DATA.series;
641
+ const max = Math.max(1, ...s.map(p => p.n));
642
+ const stepX = (W - L - R) / Math.max(1, s.length - 1);
643
+ const px = i => L + i * stepX;
644
+ const py = n => H - B - (n / max) * (H - T - B);
645
+ let line = '', area = '';
646
+ s.forEach((p, i) => { const cmd = (i ? 'L' : 'M') + px(i).toFixed(1) + ' ' + py(p.n).toFixed(1); line += cmd + ' '; area += cmd + ' '; });
647
+ area += 'L' + px(s.length - 1).toFixed(1) + ' ' + (H - B) + ' L' + px(0).toFixed(1) + ' ' + (H - B) + ' Z';
648
+ let grid = '';
649
+ for (let g = 0; g <= 3; g++) {
650
+ const y = T + (g / 3) * (H - T - B);
651
+ const value = Math.round(max * (1 - g / 3));
652
+ grid += '<line x1="' + L + '" y1="' + y.toFixed(1) + '" x2="' + (W - R) + '" y2="' + y.toFixed(1) + '" stroke="rgba(255,255,255,.045)" stroke-dasharray="2 4"/>';
653
+ grid += '<text x="' + (L - 10) + '" y="' + (y + 3).toFixed(1) + '" fill="#5c6b80" font-size="9.5" font-family="ui-monospace,monospace" text-anchor="end">' + value + '</text>';
654
+ }
655
+ const peak = s.reduce((b, p, i) => (p.n > s[b].n ? i : b), 0);
656
+ const labels = s.map((p, i) => (i % 2 === 0 ? '<text x="' + px(i).toFixed(1) + '" y="' + (H - 12) + '" fill="#5c6b80" font-size="9.5" font-family="ui-monospace,monospace" text-anchor="middle">' + p.day + '</text>' : '')).join('');
657
+ const dots = s.map((p, i) => '<circle cx="' + px(i).toFixed(1) + '" cy="' + py(p.n).toFixed(1) + '" r="' + (i === peak ? 3.4 : 2) + '" fill="' + (i === peak ? '#f2b544' : 'rgba(242,181,68,.65)') + '"/>').join('');
658
+ const callout = '<text x="' + px(peak).toFixed(1) + '" y="' + (py(s[peak].n) - 14).toFixed(1) + '" fill="#8fa0b5" font-size="10" font-family="ui-monospace,monospace" text-anchor="middle">' + s[peak].n + ' 条 · ' + s[peak].day + '</text>';
659
+ const guide = '<line x1="' + px(peak).toFixed(1) + '" y1="' + (py(s[peak].n) + 6).toFixed(1) + '" x2="' + px(peak).toFixed(1) + '" y2="' + (H - B) + '" stroke="rgba(242,181,68,.22)" stroke-dasharray="2 4"/>';
660
+ svg.innerHTML = '<defs><linearGradient id="ga" x1="0" y1="0" x2="0" y2="1">'
661
+ + '<stop offset="0" stop-color="rgba(242,181,68,.34)"/><stop offset="1" stop-color="rgba(242,181,68,0)"/></linearGradient></defs>'
662
+ + grid + '<path class="chart-area" d="' + area + '" fill="url(#ga)"/>'
663
+ + '<path class="chart-line" d="' + line + '" fill="none" stroke="#f2b544" stroke-width="1.7" stroke-linejoin="round"/>'
664
+ + guide + dots + labels + callout;
665
+ $('#trend-total').textContent = fmt(DATA.total);
666
+ }
667
+
668
+ function renderDonut() {
669
+ const svg = $('#donut');
670
+ const order = ['preference', 'fact', 'procedure', 'episode', 'todo']
671
+ .sort((a, b) => (DATA.counts[b] ?? 0) - (DATA.counts[a] ?? 0));
672
+ const color = { fact: '#e8a13a', procedure: '#6aa5e8', preference: '#c9a7e0', episode: '#5c6b80', todo: '#3fbf8f' };
673
+ const total = order.reduce((n, k) => n + (DATA.counts[k] ?? 0), 0) || 1;
674
+ const cx = 75, cy = 75, r = 54, w = 13;
675
+ const C = 2 * Math.PI * r;
676
+ let off = 0, out = '<circle cx="75" cy="75" r="' + r + '" fill="none" stroke="rgba(255,255,255,.05)" stroke-width="' + w + '"/>';
677
+ for (const k of order) {
678
+ const n = DATA.counts[k] ?? 0;
679
+ if (!n) continue;
680
+ const len = (n / total) * C;
681
+ out += '<circle cx="75" cy="75" r="' + r + '" fill="none" stroke="' + color[k] + '" stroke-width="' + w + '"'
682
+ + ' stroke-dasharray="' + Math.max(0, len - 2).toFixed(1) + ' ' + (C - len + 2).toFixed(1) + '"'
683
+ + ' stroke-dashoffset="' + (-off).toFixed(1) + '" transform="rotate(-90 75 75)"/>';
684
+ off += len;
685
+ }
686
+ out += '<text x="75" y="72" fill="#e8edf4" font-size="19" font-family="ui-monospace,monospace" text-anchor="middle">5 类</text>';
687
+ out += '<text x="75" y="88" fill="#5c6b80" font-size="8.5" font-family="ui-monospace,monospace" letter-spacing="2" text-anchor="middle">KINDS</text>';
688
+ svg.innerHTML = out;
689
+ const list = $('#donut-list');
690
+ list.replaceChildren();
691
+ for (const k of order) {
692
+ const n = DATA.counts[k] ?? 0;
693
+ const d = el('div', 'drow');
694
+ d.innerHTML = '<span class="sw" style="background:' + color[k] + '"></span>'
695
+ + '<span class="dn">' + (KIND[k] ?? k) + '<em>' + (KIND_EN[k] ?? k) + '</em></span>'
696
+ + '<span class="dv">' + fmt(n) + '</span>'
697
+ + '<span class="dp">' + Math.round((n / total) * 100) + '%</span>';
698
+ list.appendChild(d);
699
+ }
700
+ }
701
+
702
+ function bars(target, rows) {
703
+ const host = $(target);
704
+ host.replaceChildren();
705
+ const max = Math.max(1, ...rows.map(r => r.n));
706
+ for (const r of rows) {
707
+ const d = el('div', 'drow');
708
+ d.innerHTML = '<span class="dn">' + esc(r.label) + '</span>'
709
+ + '<span class="hit-bar" style="width:96px"><i style="width:' + ((r.n / max) * 100).toFixed(1) + '%"></i></span>'
710
+ + '<span class="dv" style="width:52px;text-align:right">' + fmt(r.n) + '</span>';
711
+ host.appendChild(d);
712
+ }
713
+ }
714
+
715
+ function renderDormant() {
716
+ const q = DATA.dormantQueue;
717
+ $('#b-dorm').textContent = fmt(q.total);
718
+ countUp(document.querySelector('[data-count="dormantCount"]'), q.total);
719
+ countUp(document.querySelector('[data-count="pinnedCount"]'), DATA.pinned);
720
+ const last = DATA.audit.rows.find(r => r.op === 'sleep_pass');
721
+ if (last) $('#sweep-time').textContent = new Date(last.ts).toLocaleTimeString('zh-CN', { hour: '2-digit', minute: '2-digit', hour12: false });
722
+ const body = $('#dormant-rows');
723
+ body.replaceChildren();
724
+ for (const item of q.items) {
725
+ const tr = el('tr');
726
+ tr.innerHTML = '<td class="c-status"><span class="tag sleep">休眠</span></td>'
727
+ + '<td class="td-time c-time">' + day(item.date) + '</td>'
728
+ + '<td class="td-type c-type">' + (KIND_EN[item.kind] ?? item.kind).toUpperCase() + '</td>'
729
+ + '<td><span class="mem-text">' + esc(item.content) + '</span></td>'
730
+ + '<td class="td-hit c-src">' + (item.hit ?? 0) + '</td>'
731
+ + '<td class="c-act"><button class="row-act" type="button">唤醒</button></td>';
732
+ body.appendChild(tr);
733
+ }
734
+ if (!q.items.length) {
735
+ const tr = el('tr', 'empty-row');
736
+ tr.innerHTML = '<td colspan="6">当前没有休眠记忆。长期未召回且未置顶的条目才会转入这里,可随时唤醒。</td>';
737
+ body.appendChild(tr);
738
+ }
739
+ }
740
+
741
+ let auditFilter = 'all';
742
+ const FAIL_OP = /failed|error/i;
743
+ function renderAudit() {
744
+ const rows = DATA.audit.rows;
745
+ $('#b-audit').textContent = fmt(rows.length);
746
+ countUp(document.querySelector('[data-count="auditRows"]'), rows.length);
747
+ countUp(document.querySelector('[data-count="auditOps"]'), DATA.audit.ops.length);
748
+ $('#audit-fail').textContent = fmt(rows.filter(r => FAIL_OP.test(r.op)).length);
749
+ $('#audit-write').textContent = fmt(rows.filter(r => /remember|correct|forget|ingest/.test(r.op)).length);
750
+ $('#audit-job').textContent = fmt(rows.filter(r => /job|lease|dispatch|settle/.test(r.op)).length);
751
+ const chips = $('#audit-chips');
752
+ if (!chips.childElementCount) {
753
+ for (const [op, n] of [['all', rows.length]].concat(DATA.audit.ops.slice(0, 9))) {
754
+ const b = el('button', 'chip' + (op === 'all' ? ' on' : ''), op === 'all' ? '全部 ' + fmt(n) : op + ' ' + fmt(n));
755
+ b.dataset.op = op;
756
+ b.style.letterSpacing = '0';
757
+ b.addEventListener('click', () => {
758
+ auditFilter = op;
759
+ chips.querySelectorAll('.chip').forEach(x => x.classList.toggle('on', x.dataset.op === op));
760
+ renderAudit();
761
+ });
762
+ chips.appendChild(b);
763
+ }
764
+ }
765
+ const list = auditFilter === 'all' ? rows : rows.filter(r => r.op === auditFilter);
766
+ $('#audit-count').textContent = fmt(list.length) + ' 条';
767
+ const body = $('#audit-rows');
768
+ body.replaceChildren();
769
+ for (const row of list.slice(0, 120)) {
770
+ const bad = FAIL_OP.test(row.op);
771
+ const tr = el('tr');
772
+ tr.innerHTML = '<td class="c-status"><span class="tag ' + (bad ? 'conflict' : 'active') + '">' + (bad ? '失败' : '正常') + '</span></td>'
773
+ + '<td class="td-time c-time">' + new Date(row.ts).toLocaleString('zh-CN', { hour12: false, month: '2-digit', day: '2-digit', hour: '2-digit', minute: '2-digit' }) + '</td>'
774
+ + '<td class="td-type a-op" style="letter-spacing:.02em;text-transform:none" title="' + esc(row.op) + '">' + esc(row.op) + '</td>'
775
+ + '<td class="td-type a-by" style="letter-spacing:.04em">' + esc(row.by) + '</td>'
776
+ + '<td><span class="mem-text">' + esc(row.detail) + '</span></td>';
777
+ body.appendChild(tr);
778
+ }
779
+ }
780
+
781
+ function renderProfile() {
782
+ const p = DATA.profile;
783
+ $('#p-time').textContent = p.generatedAt ? '生成于 ' + new Date(p.generatedAt).toLocaleString('zh-CN', { hour12: false, month: '2-digit', day: '2-digit', hour: '2-digit', minute: '2-digit' }) : '未生成';
784
+ const lag = $('#p-lag');
785
+ lag.replaceChildren();
786
+ if (p.lag && p.lag.count > 0) {
787
+ const chip = el('span', 'tag', '落后 ' + p.lag.count + ' 条写入');
788
+ chip.style.cssText = 'color:var(--accent);border:1px solid rgba(232,161,58,.4);background:rgba(232,161,58,.08);letter-spacing:.06em';
789
+ chip.title = '画像生成后又有 ' + p.lag.count + ' 条记忆写入,最新一条在 ' + (p.lag.newestAt ? day(p.lag.newestAt) : '未知');
790
+ lag.appendChild(chip);
791
+ }
792
+ countUp(document.querySelector('[data-count="pId"]'), p.counts.identity);
793
+ countUp(document.querySelector('[data-count="pPref"]'), p.counts.preferences);
794
+ countUp(document.querySelector('[data-count="pTodo"]'), p.counts.todos);
795
+ countUp(document.querySelector('[data-count="pProc"]'), p.counts.procedures);
796
+ countUp(document.querySelector('[data-count="pEp"]'), p.counts.episodes);
797
+
798
+ const body = $('#profile-body');
799
+ body.replaceChildren();
800
+ for (const block of p.blocks) {
801
+ if (block.type === 'h') {
802
+ const h = el('div', null, block.text);
803
+ h.style.cssText = 'font-family:var(--serif);font-size:1rem;letter-spacing:.12em;color:var(--accent);margin-top:6px';
804
+ body.appendChild(h);
805
+ } else if (block.type === 'li') {
806
+ const li = el('div');
807
+ li.style.cssText = 'display:flex;gap:9px;font-size:.79rem;color:var(--dim);line-height:1.75';
808
+ li.innerHTML = '<span style="color:var(--faint);font-family:var(--mono)">·</span><span>' + esc(block.text) + '</span>';
809
+ body.appendChild(li);
810
+ } else {
811
+ const d = el('div', null, block.text);
812
+ d.style.cssText = 'font-size:.8rem;color:var(--ink);line-height:1.8';
813
+ body.appendChild(d);
814
+ }
815
+ }
816
+
817
+ const kw = $('#p-keywords');
818
+ kw.replaceChildren();
819
+ for (const word of p.keywords) {
820
+ const chip = el('span', 'tag active', word);
821
+ chip.style.fontSize = '.64rem';
822
+ kw.appendChild(chip);
823
+ }
824
+
825
+ const samples = $('#p-samples');
826
+ samples.replaceChildren();
827
+ for (const [label, list] of [['身份', p.samples.identity], ['偏好', p.samples.preferences], ['待办', p.samples.todos]]) {
828
+ for (const item of list.slice(0, 2)) {
829
+ const row = el('div', 'drow');
830
+ row.style.cursor = 'pointer';
831
+ row.innerHTML = '<span class="tag sleep">' + label + '</span><span class="dn">' + esc(item.content) + '</span><span class="dv">#' + item.id + '</span>';
832
+ row.addEventListener('click', () => {
833
+ const target = DATA.items.find(i => i.id === item.id);
834
+ if (target) openDetail(target); else toast('这条不在当前快照里');
835
+ });
836
+ samples.appendChild(row);
837
+ }
838
+ }
839
+ }
840
+
841
+ function renderConflicts() {
842
+ const host = $('#pairs');
843
+ host.replaceChildren();
844
+ for (const pair of DATA.conflicts.pairs) {
845
+ const card = el('div', 'conflict-card');
846
+ card.dataset.pair = pair.old.id + '/' + pair.new.id;
847
+ const basis = pair.basis === 'ref'
848
+ ? '<span class="tag sleep">新条引用了旧条编号</span>'
849
+ : '<span class="tag sleep">仅语义相近</span>';
850
+ const simLine = pair.sim == null ? '' : '<span style="font-family:var(--mono);letter-spacing:.12em">相似度 ' + pair.sim.toFixed(3) + '</span>'
851
+ + '<span class="hit-bar" style="width:120px"><i style="width:' + Math.round(pair.sim * 100) + '%"></i></span>'
852
+ + (pair.suggestion ? '<span class="tag sleep" style="margin-left:6px">建议 ' + ({ annotate: '批注取代', 'supersede-review': '复核是否取代' }[pair.suggestion] ?? pair.suggestion) + '</span>' : '');
853
+ card.innerHTML = '<div class="cc-head"><div class="cc-title">同一主题的两种说法<span class="meta">候选对 ' + pair.old.id + ' / ' + pair.new.id + '</span></div>'
854
+ + '<span class="tag conflict">冲突待裁</span></div>'
855
+ + '<div style="display:flex;align-items:center;gap:10px;margin-bottom:14px;font-size:.74rem;color:var(--faint);flex-wrap:wrap">'
856
+ + basis + simLine + '</div>'
857
+ + '<div class="cc-versions">'
858
+ + '<div class="cc-ver" data-id="' + pair.old.id + '"><div class="vh"><span class="tag sleep">旧 #' + pair.old.id + '</span><span class="td-time">' + pair.old.updated_at + '</span><span class="open-hint">查看全文</span></div><p>' + esc(pair.old.snippet) + '</p></div>'
859
+ + '<div class="cc-ver" data-id="' + pair.new.id + '"><div class="vh"><span class="tag active">新 #' + pair.new.id + '</span><span class="td-time">' + pair.new.updated_at + '</span><span class="open-hint">查看全文</span></div><p>' + esc(pair.new.snippet) + '</p></div>'
860
+ + '</div>'
861
+ + '<div class="cc-acts"><button class="btn-mini" data-act-adopt>采纳新说法</button>'
862
+ + '<button class="btn-mini" data-act-keep style="color:var(--dim);border-color:var(--line);background:none">保留旧说法</button>'
863
+ + '<button class="btn-mini" data-act-none style="color:var(--faint);border-color:var(--line);background:none">两条都无关</button></div>';
864
+ card.querySelectorAll('.cc-ver').forEach(box => box.addEventListener('click', () => {
865
+ const item = DATA.items.find(i => i.id === Number(box.dataset.id));
866
+ if (!item) return toast('这条记忆不在当前快照里');
867
+ openDetail(item, { pair: card.dataset.pair, side: Number(box.dataset.id) === pair.old.id ? 'old' : 'new' });
868
+ }));
869
+ const acts = LIVE
870
+ ? [['[data-act-adopt]', 'adopt', '已采纳新说法,旧条转为历史(可审计)'],
871
+ ['[data-act-keep]', 'keep', '已记录:两条都保留'],
872
+ ['[data-act-none]', 'unrelated', '已记录:判为无关,不再提示']]
873
+ : [['[data-act-adopt]', 'adopt', '原型模式:采纳新说法,旧条转为历史'],
874
+ ['[data-act-keep]', 'keep', '原型模式:保留旧说法,新条标记待批注'],
875
+ ['[data-act-none]', 'unrelated', '已标记为无关:这对不会再出现在待裁决里']];
876
+ for (const [selector, verdict, text] of acts) {
877
+ card.querySelector(selector).addEventListener('click', async () => {
878
+ if (!LIVE) { card.classList.add('done'); return toast(text); }
879
+ try {
880
+ if (verdict === 'adopt' && !confirm('采纳新说法:旧条 #' + pair.old.id + ' 将转为历史(逻辑删除,可审计)?')) return;
881
+ const r = await api('/api/conflict/resolve', {
882
+ old: pair.old.id, new: pair.new.id, verdict,
883
+ expected_old_version: pair.old.version,
884
+ expected_new_version: pair.new.version,
885
+ });
886
+ toast(r.msg ?? text);
887
+ if (r.ok) { card.classList.add('done'); await reload(); }
888
+ } catch (e) { toast('操作失败:' + e.message); }
889
+ });
890
+ }
891
+ host.appendChild(card);
892
+ }
893
+ if (!DATA.conflicts.pairs.length) {
894
+ const empty = el('div', 'card');
895
+ empty.textContent = '当前没有待复核的冲突';
896
+ host.appendChild(empty);
897
+ }
898
+ }
899
+
900
+ function renderNeighbourhood() {
901
+ const svg = $('#neighbourhood');
902
+ if (!DATA.hub) { svg.innerHTML = ''; return; }
903
+ const H = 360, cx = 250, cy = 205, R = 112;
904
+ const n = DATA.hub.neighbours.length;
905
+ const color = { fact: '#e8a13a', procedure: '#6aa5e8', preference: '#c9a7e0', episode: '#5c6b80', todo: '#3fbf8f' };
906
+ let out = '';
907
+ DATA.hub.neighbours.forEach((nb, i) => {
908
+ const a = (i / n) * Math.PI * 2 - Math.PI / 2;
909
+ const x = cx + Math.cos(a) * R, y = cy + Math.sin(a) * R;
910
+ out += '<line x1="' + cx + '" y1="' + cy + '" x2="' + x.toFixed(1) + '" y2="' + y.toFixed(1) + '" stroke="rgba(255,255,255,.09)"/>';
911
+ out += '<circle cx="' + x.toFixed(1) + '" cy="' + y.toFixed(1) + '" r="' + (nb.rel === 'ref' ? 4.2 : 3) + '" fill="' + (color[nb.kind] ?? '#5c6b80') + '" opacity=".9"/>';
912
+ out += '<text x="' + (x + Math.cos(a) * 14).toFixed(1) + '" y="' + (y + Math.sin(a) * 14 + 3).toFixed(1) + '" fill="#5c6b80" font-size="9" font-family="ui-monospace,monospace" text-anchor="middle">#' + nb.id + '</text>';
913
+ });
914
+ out += '<circle cx="250" cy="205" r="13" fill="#f2b544"/>';
915
+ out += '<text x="18" y="26" fill="#e8edf4" font-size="12" font-family="ui-monospace,monospace">#' + DATA.hub.id + ' · ' + (KIND[DATA.hub.kind] ?? DATA.hub.kind) + '</text>';
916
+ out += '<text x="18" y="46" fill="#8fa0b5" font-size="10.5">' + esc(DATA.hub.head) + '</text>';
917
+ svg.innerHTML = out;
918
+ const legend = $('#hub-legend');
919
+ legend.replaceChildren();
920
+ const counts = {};
921
+ for (const nb of DATA.hub.neighbours) counts[nb.rel] = (counts[nb.rel] ?? 0) + 1;
922
+ for (const [rel, label] of [['co_tag', '共标签'], ['similar', '向量相似'], ['ref', '显式引用']]) {
923
+ if (!counts[rel]) continue;
924
+ const d = el('div', 'li');
925
+ d.innerHTML = '<span class="sw" style="background:var(--accent-strong)"></span>' + label + ' ' + counts[rel];
926
+ legend.appendChild(d);
927
+ }
928
+ }
929
+
930
+ function renderGraph() {
931
+ renderNeighbourhood();
932
+ bars('#rel-bars', [{ label: '共标签', n: DATA.byRel.co_tag ?? 0 }, { label: '向量相似', n: DATA.byRel.similar ?? 0 }, { label: '显式引用', n: DATA.byRel.ref ?? 0 }]);
933
+ bars('#degree-bars', DATA.topNodes.map(n => ({ label: '#' + n.id + ' ' + (KIND[n.kind] ?? ''), n: n.n })));
934
+ }
935
+
936
+ function renderSignals() {
937
+ bars('#tag-bars', DATA.topTags.map(([tag, n]) => ({ label: tag, n })));
938
+ }
939
+
940
+ const ACTIONS = { copy: '已复制记忆内容', pin: '已切换置顶', correct: '已生成新版本', forget: '已删除(逻辑删除,可审计)' };
941
+
942
+ async function api(path, body) {
943
+ const response = await fetch(path, body === undefined ? { cache: 'no-store' }
944
+ : { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(body) });
945
+ const data = await response.json().catch(() => ({}));
946
+ if (!response.ok) throw new Error(data?.error ?? data?.msg ?? 'HTTP ' + response.status);
947
+ return data;
948
+ }
949
+
950
+ function reload() { return loadLive().then(boot).catch(e => toast('刷新失败:' + e.message)); }
951
+
952
+ async function loadLive() {
953
+ const [mem, conf, dorm, graph, prof, events, audit] = await Promise.all([
954
+ api('/api/memories'), api('/api/conflicts'), api('/api/dormant'), api('/api/graph'),
955
+ api('/api/profile'), api('/api/events'), api('/api/audit'),
956
+ ]);
957
+ const items = (mem.items ?? []).map(item => {
958
+ const tags = String(item.tags ?? '');
959
+ const source = tags.includes('auto') ? 'auto' : tags.includes('summary') ? 'summary'
960
+ : tags.includes('lifeos') ? 'lifeos' : tags.includes('session') ? 'session' : 'manual';
961
+ const date = item.date ?? item.updated_at ?? new Date().toISOString();
962
+ return {
963
+ id: item.id, kind: item.kind, content: String(item.content), tags, date,
964
+ time: new Date(date).toLocaleTimeString('zh-CN', { hour12: false, hour: '2-digit', minute: '2-digit' }),
965
+ pinned: item.pinned ? 1 : 0, version: item.version ?? 1, hit: item.hit_count ?? 0,
966
+ status: 'active', source,
967
+ };
968
+ });
969
+ const conflictIds = new Set((conf.pairs ?? []).flatMap(p => [p.old.id, p.new.id]));
970
+ for (const item of items) item.status = conflictIds.has(item.id) ? 'conflict' : item.pinned ? 'pin' : 'active';
971
+ const counts = mem.counts ?? {};
972
+ const pairs = (conf.pairs ?? []).map(p => {
973
+ const newer = items.find(i => i.id === p.new.id)?.content ?? '';
974
+ return {
975
+ old: { id: p.old.id, kind: p.old.kind, updated_at: p.old.updated_at, snippet: p.old.snippet },
976
+ new: { id: p.new.id, kind: p.new.kind, updated_at: p.new.updated_at, snippet: p.new.snippet },
977
+ basis: new RegExp('(?:id\\s*=\\s*|#)' + p.old.id + '(?![0-9])').test(newer) ? 'ref' : 'similar',
978
+ sim: typeof p.sim === 'number' ? p.sim : null,
979
+ suggestion: p.suggestion ?? null,
980
+ };
981
+ });
982
+ const days = [...new Set(items.map(i => day(i.date)))].sort();
983
+ const series = days.slice(-14).map(d => ({ day: d.slice(5), n: items.filter(i => day(i.date) === d).length }));
984
+ const tagCount = {};
985
+ for (const item of items) for (const raw of String(item.tags || '').split(',')) {
986
+ const key = raw.trim().split(':')[0];
987
+ if (key) tagCount[key] = (tagCount[key] ?? 0) + 1;
988
+ }
989
+ const degree = new Map();
990
+ for (const link of graph.links ?? []) {
991
+ degree.set(link.source, (degree.get(link.source) ?? 0) + 1);
992
+ degree.set(link.target, (degree.get(link.target) ?? 0) + 1);
993
+ }
994
+ const byId = new Map(items.map(i => [i.id, i]));
995
+ const topNodes = [...degree.entries()].sort((a, b) => b[1] - a[1]).slice(0, 8)
996
+ .map(([id, n]) => ({ id, n, kind: byId.get(id)?.kind ?? '-', head: String(byId.get(id)?.content ?? '').slice(0, 44) }));
997
+ const hub = topNodes[0]?.id;
998
+ const seen = new Set();
999
+ const neighbours = (graph.links ?? []).filter(l => l.source === hub || l.target === hub)
1000
+ .map(l => { const other = l.source === hub ? l.target : l.source; return { id: other, kind: byId.get(other)?.kind ?? '-', rel: l.rel, weight: l.weight ?? 1 }; })
1001
+ .filter(nb => (seen.has(nb.id) ? false : (seen.add(nb.id), true)))
1002
+ .sort((a, b) => (b.rel === 'ref') - (a.rel === 'ref') || b.weight - a.weight)
1003
+ .slice(0, 24);
1004
+ const sessions = new Set(items.flatMap(i => String(i.tags).split(',').map(t => t.trim()).filter(t => t.startsWith('session:')).map(t => t.slice(8))));
1005
+ const recent7 = items.filter(i => new Date(i.date) >= new Date(Date.now() - 7 * 864e5)).length;
1006
+ const prev7 = items.filter(i => { const t = new Date(i.date); return t >= new Date(Date.now() - 14 * 864e5) && t < new Date(Date.now() - 7 * 864e5); }).length;
1007
+
1008
+ const profileText = String(prof.cached?.summary ?? '');
1009
+ const kwMatch = profileText.match(/关键词[::]\s*(.+)$/m);
1010
+ const blocks = [];
1011
+ for (const para of profileText.split(/\n{2,}/)) {
1012
+ const lines = para.split('\n').map(l => l.trim()).filter(Boolean);
1013
+ if (!lines.length) continue;
1014
+ const head = lines[0].match(/^\*\*(.+?)\*\*$/);
1015
+ if (head) blocks.push({ type: 'h', text: head[1] });
1016
+ else if (!lines.some(l => l.startsWith('- '))) blocks.push({ type: 'p', text: lines.join(' ').replace(/\*\*/g, '') });
1017
+ for (const line of lines) if (line.startsWith('- ')) blocks.push({ type: 'li', text: line.slice(2).replace(/\*\*/g, '') });
1018
+ }
1019
+ if (blocks[0]?.type === 'h' && blocks[0].text === '用户画像') blocks.shift();
1020
+ const genAt = prof.cached?.generated_at ? new Date(prof.cached.generated_at).getTime() : 0;
1021
+ const pick = (list, n) => (Array.isArray(list) ? list.slice(0, n).map(x => ({ id: x.id, content: String(x.content).slice(0, 220) })) : []);
1022
+ const newest = items.length ? items.reduce((a, b) => (new Date(a.date) > new Date(b.date) ? a : b)).date : null;
1023
+
1024
+ DATA = {
1025
+ generated: new Date().toISOString(),
1026
+ version: events.version ?? '',
1027
+ total: mem.total ?? items.length,
1028
+ counts,
1029
+ pinned: items.filter(i => i.pinned).length,
1030
+ dormant: dorm.total ?? 0,
1031
+ dormantQueue: dorm,
1032
+ sessions: sessions.size,
1033
+ series,
1034
+ topTags: Object.entries(tagCount).sort((a, b) => b[1] - a[1]).slice(0, 8),
1035
+ topNodes,
1036
+ hub: hub ? { id: hub, kind: byId.get(hub)?.kind ?? '-', head: String(byId.get(hub)?.content ?? '').slice(0, 54), neighbours } : null,
1037
+ byRel: graph.byRel ?? {},
1038
+ engine: { port: location.port || '7640', db: events.db ?? '', pid: events.pid ?? null },
1039
+ deltas: { last7: recent7, prev7, pct: prev7 ? Math.round(((recent7 - prev7) / prev7) * 100) : 0 },
1040
+ profile: {
1041
+ generatedAt: prof.cached?.generated_at ?? null, blocks,
1042
+ keywords: kwMatch ? kwMatch[1].split(/[、,,]/).map(k => k.trim()).filter(Boolean) : [],
1043
+ counts: { identity: prof.identity?.length ?? 0, preferences: prof.preferences?.length ?? 0, todos: prof.todos?.length ?? 0, procedures: prof.procedures?.length ?? 0, episodes: prof.episodes?.length ?? 0 },
1044
+ samples: { identity: pick(prof.identity, 5), preferences: pick(prof.preferences, 5), todos: pick(prof.todos, 5) },
1045
+ lag: genAt ? { count: items.filter(i => new Date(i.date).getTime() > genAt).length, newestAt: newest, days: Math.floor((Date.now() - genAt) / 864e5) } : { count: 0 },
1046
+ },
1047
+ monitor: {
1048
+ hours: events.hours ?? [], events: events.events ?? [], failures: events.failures ?? [],
1049
+ last24: events.last24 ?? 0, writes24: events.writes24 ?? 0, corrections24: events.corrections24 ?? 0, failures24: events.failures24 ?? 0,
1050
+ },
1051
+ audit: { rows: audit.rows ?? [], ops: audit.ops ?? [] },
1052
+ conflicts: { total: conf.total ?? pairs.length, pairs },
1053
+ items,
1054
+ };
1055
+ }
1056
+
1057
+ let conflictCtx = null;
1058
+ function openDetail(item, ctx) {
1059
+ current = item;
1060
+ conflictCtx = ctx ?? null;
1061
+ $('#m-adopt').hidden = !conflictCtx;
1062
+ $('#m-keep').hidden = !conflictCtx;
1063
+ $('#m-title').textContent = (KIND[item.kind] ?? item.kind) + ' 记忆';
1064
+ $('#m-id').textContent = '#' + item.id;
1065
+ $('#m-kind').textContent = (KIND_EN[item.kind] ?? item.kind).toUpperCase();
1066
+ $('#m-date').textContent = day(item.date) + ' ' + item.time;
1067
+ $('#m-ver').textContent = 'v' + item.version;
1068
+ $('#m-hit').textContent = '命中 ' + item.hit + ' · 来源 ' + (SOURCE[item.source] ?? item.source);
1069
+ $('#m-body').textContent = item.content;
1070
+ $('#m-tags').textContent = item.tags;
1071
+ const box = $('#m-source');
1072
+ box.replaceChildren();
1073
+ if (item.provenance) {
1074
+ const p = item.provenance;
1075
+ const head = el('div');
1076
+ head.style.cssText = 'display:flex;justify-content:space-between;align-items:baseline;gap:12px;margin-bottom:8px';
1077
+ head.innerHTML = '<span style="font-family:var(--mono);font-size:.66rem;letter-spacing:.16em;color:var(--faint)">来源回查 · ' + p.total + ' 条原文'
1078
+ + (item.corroborations ? ' · ' + item.corroborations + ' 条独立佐证' : '') + '</span>'
1079
+ + '<span class="td-time">' + (p.session ? p.session.slice(8, 20) : '') + '</span>';
1080
+ box.appendChild(head);
1081
+ for (const q of p.quotes) {
1082
+ const d = el('div');
1083
+ d.style.cssText = 'border-left:2px solid rgba(242,181,68,.35);padding:2px 0 2px 10px;margin-bottom:8px;font-size:.78rem;color:var(--dim);line-height:1.7';
1084
+ d.textContent = q.text;
1085
+ box.appendChild(d);
1086
+ }
1087
+ const note = el('div');
1088
+ note.style.cssText = 'font-size:.68rem;color:var(--faint)';
1089
+ note.textContent = '原文已脱敏截断,完整内容用 memory_source 回查';
1090
+ box.appendChild(note);
1091
+ } else {
1092
+ const d = el('div');
1093
+ d.style.cssText = 'font-family:var(--mono);font-size:.66rem;letter-spacing:.14em;color:var(--faint)';
1094
+ d.textContent = '来源回查 · 此条没有可回查的原文证据';
1095
+ box.appendChild(d);
1096
+ }
1097
+ $('#modal').classList.add('on');
1098
+ }
1099
+ function closeDetail() { $('#modal').classList.remove('on'); current = null; conflictCtx = null; }
1100
+
1101
+ function resolveConflict(adoptCurrent) {
1102
+ if (!conflictCtx) return;
1103
+ const card = document.querySelector('.conflict-card[data-pair="' + conflictCtx.pair + '"]');
1104
+ if (card) card.classList.add('done');
1105
+ toast(adoptCurrent
1106
+ ? '原型模式:这里会把 #' + (current?.id ?? '?') + ' 采纳为现行说法,另一版转为历史'
1107
+ : '原型模式:这里会保留另一版,本条标记为待批注');
1108
+ closeDetail();
1109
+ }
1110
+
1111
+ const TITLES = { profile: '用户画像', overview: '总览', events: '事件流', all: '全部条目', pinned: '置顶', dormant: '休眠队列', audit: '审计日志', conflicts: '冲突裁决', graph: '关联图谱', signals: '标签来源' };
1112
+ function setView(next) {
1113
+ const valid = TITLES[next] ? next : 'overview';
1114
+ document.querySelectorAll('.view').forEach(v => v.classList.toggle('on', v.id === 'view-' + valid));
1115
+ document.querySelectorAll('.item').forEach(i => i.classList.toggle('on', i.dataset.go === valid));
1116
+ $('#page-title').textContent = TITLES[valid];
1117
+ if (valid === 'all') renderAll();
1118
+ if (valid === 'pinned') renderPinned();
1119
+ if (valid === 'dormant') renderDormant();
1120
+ if (valid === 'audit') renderAudit();
1121
+ if (valid === 'profile') renderProfile();
1122
+ }
1123
+
1124
+ document.querySelectorAll('[data-go]').forEach(n => n.addEventListener('click', () => { location.hash = n.dataset.go; }));
1125
+
1126
+ for (const c of [{ k: 'all', l: '全部' }].concat(['fact', 'procedure', 'preference', 'episode', 'todo'].map(k => ({ k, l: KIND[k] })))) {
1127
+ const b = el('button', 'chip' + (c.k === 'all' ? ' on' : ''), c.l);
1128
+ b.dataset.kind = c.k;
1129
+ b.addEventListener('click', () => {
1130
+ kind = c.k;
1131
+ document.querySelectorAll('.chip').forEach(x => x.classList.toggle('on', x.dataset.kind === kind));
1132
+ renderAll();
1133
+ if (location.hash !== '#all') location.hash = 'all';
1134
+ });
1135
+ $('#kind-chips').appendChild(b);
1136
+ }
1137
+
1138
+ $('#q').addEventListener('input', e => { query = e.target.value.trim().toLowerCase(); renderAll(); renderPinned(); });
1139
+ document.addEventListener('keydown', e => {
1140
+ if ((e.metaKey || e.ctrlKey) && e.key.toLowerCase() === 'k') { e.preventDefault(); $('#q').focus(); $('#q').select(); }
1141
+ if (e.key === 'Escape') closeDetail();
1142
+ });
1143
+ $('#modal').addEventListener('click', e => { if (e.target.id === 'modal') closeDetail(); });
1144
+ document.querySelectorAll('[data-act]').forEach(b => b.addEventListener('click', async () => {
1145
+ const act = b.dataset.act;
1146
+ if (act === 'close') return closeDetail();
1147
+ if (LIVE && current && (act === 'pin' || act === 'forget' || act === 'correct')) {
1148
+ try {
1149
+ if (act === 'pin') {
1150
+ await api('/api/lifecycle', { id: current.id, action: current.pinned ? 'unpin' : 'pin' });
1151
+ toast(current.pinned ? '已取消置顶' : '已置顶');
1152
+ } else if (act === 'forget') {
1153
+ if (!confirm('逻辑删除 #' + current.id + '?删除后默认召回不再返回,可审计。')) return;
1154
+ await api('/api/forget', { id: current.id });
1155
+ toast(ACTIONS.forget);
1156
+ } else {
1157
+ const text = prompt('修正 #' + current.id + ' 的内容(生成新版本):', current.content);
1158
+ if (!text || text === current.content) return;
1159
+ const r = await api('/api/correct', { id: current.id, content: text, expected_version: current.version });
1160
+ if (!r.ok) { toast(r.msg ?? '修正失败'); return; }
1161
+ toast(ACTIONS.correct);
1162
+ }
1163
+ closeDetail();
1164
+ return reload();
1165
+ } catch (e) { toast('操作失败:' + e.message); return; }
1166
+ }
1167
+ if (act === 'copy' && current) {
1168
+ try { await navigator.clipboard.writeText(current.content); toast(ACTIONS.copy); }
1169
+ catch { toast('浏览器拒绝了剪贴板权限'); }
1170
+ return;
1171
+ }
1172
+ toast(ACTIONS[act] ?? '原型模式');
1173
+ }));
1174
+ window.addEventListener('hashchange', () => setView(location.hash.slice(1)));
1175
+
1176
+ $('#m-adopt').addEventListener('click', () => resolveConflict(true));
1177
+ $('#m-keep').addEventListener('click', () => resolveConflict(false));
1178
+ $('#p-refresh').addEventListener('click', async () => {
1179
+ if (!LIVE) return toast('原型模式:这里会调用模型重新归纳画像,不会覆盖缓存');
1180
+ toast('正在重新归纳画像,可能需要几十秒');
1181
+ try { await api('/api/profile/refresh', {}); await reload(); toast('画像已更新'); }
1182
+ catch (e) { toast('归纳失败:' + e.message); }
1183
+ });
1184
+ $('#sleep-run').addEventListener('click', async () => {
1185
+ if (!LIVE) return toast('原型模式:这里会触发一次休眠整理,不写库');
1186
+ try { const r = await api('/api/sleep', {}); await reload(); toast(r.msg ?? '休眠整理完成'); }
1187
+ catch (e) { toast('整理失败:' + e.message); }
1188
+ });
1189
+ $('#engine-info').addEventListener('click', () => {
1190
+ $('#m-title').textContent = '引擎信息';
1191
+ $('#m-id').textContent = 'mcp: lm-memory';
1192
+ $('#m-kind').textContent = 'LOCAL';
1193
+ $('#m-date').textContent = 'v' + DATA.version;
1194
+ $('#m-ver').textContent = '端口 ' + DATA.engine.port;
1195
+ $('#m-hit').textContent = DATA.engine.pid ? 'PID ' + DATA.engine.pid : '';
1196
+ $('#m-body').textContent = ['管理页 http://127.0.0.1:' + DATA.engine.port, '数据库 ' + DATA.engine.db,
1197
+ '模式 旧版全局库(项目记忆未开启)', '快照 ' + new Date(DATA.generated).toLocaleString('zh-CN', { hour12: false })].join('\n');
1198
+ $('#m-tags').textContent = '原型只读,不会启动或停止任何进程';
1199
+ current = null;
1200
+ $('#modal').classList.add('on');
1201
+ });
1202
+ $('#copy-db').addEventListener('click', async () => {
1203
+ try { await navigator.clipboard.writeText(DATA.engine.db); toast('已复制数据库路径'); }
1204
+ catch { toast('浏览器拒绝了剪贴板权限'); }
1205
+ });
1206
+
1207
+ function clock() {
1208
+ const d = new Date();
1209
+ $('#clock').textContent = d.toLocaleDateString('sv') + ' ' + d.toLocaleTimeString('zh-CN', { hour12: false });
1210
+ }
1211
+ function boot() {
1212
+ document.body.classList.add('js');
1213
+ if (new URLSearchParams(location.search).get('static') === '1') { document.body.classList.add('static'); document.body.classList.remove('js'); }
1214
+ $('#b-total').textContent = fmt(DATA.total);
1215
+ $('#b-all').textContent = fmt(DATA.total);
1216
+ $('#b-pin').textContent = fmt(DATA.pinned);
1217
+ $('#b-conf').textContent = fmt(DATA.conflicts.total);
1218
+ $('#b-graph').textContent = fmt(Object.values(DATA.byRel).reduce((a, b) => a + b, 0));
1219
+ $('#f-ver').textContent = DATA.version;
1220
+ $('#s-dorm').textContent = fmt(DATA.dormant) + ' 条';
1221
+ $('#s-snap').textContent = new Date(DATA.generated).toLocaleTimeString('zh-CN', { hour: '2-digit', minute: '2-digit', hour12: false });
1222
+ const delta = $('#d-recent');
1223
+ delta.textContent = fmt(DATA.deltas.last7) + ' 条 · ' + (DATA.deltas.pct >= 0 ? '↑' : '↓') + Math.abs(DATA.deltas.pct) + '% 较前周';
1224
+ delta.className = 'delta ' + (DATA.deltas.pct >= 0 ? 'up' : '');
1225
+ countUp(document.querySelector('[data-count="total"]'), DATA.total);
1226
+ countUp(document.querySelector('[data-count="pinned"]'), DATA.pinned);
1227
+ countUp(document.querySelector('[data-count="dormant"]'), DATA.dormant);
1228
+ countUp(document.querySelector('[data-count="sessions"]'), DATA.sessions);
1229
+ countUp(document.querySelector('[data-count="conflicts"]'), DATA.conflicts.total);
1230
+ $('#b-events').textContent = fmt(DATA.monitor.last24);
1231
+ $('#sweep').textContent = fmt(DATA.conflicts.total);
1232
+ countUp(document.querySelector('[data-count="last24"]'), DATA.monitor.last24);
1233
+ countUp(document.querySelector('[data-count="writes24"]'), DATA.monitor.writes24);
1234
+ countUp(document.querySelector('[data-count="corrections24"]'), DATA.monitor.corrections24);
1235
+ countUp(document.querySelector('[data-count="failures24"]'), DATA.monitor.failures24);
1236
+ renderHours();
1237
+ renderEvents();
1238
+ renderTrend();
1239
+ renderDonut();
1240
+ renderRecent();
1241
+ renderAll();
1242
+ renderPinned();
1243
+ renderProfile();
1244
+ renderConflicts();
1245
+ renderDormant();
1246
+ renderAudit();
1247
+ renderGraph();
1248
+ renderSignals();
1249
+ clock();
1250
+ setInterval(clock, 1000);
1251
+ setView(location.hash.slice(1));
1252
+ const deepId = Number(new URLSearchParams(location.search).get('open'));
1253
+ const deep = DATA.items.find(i => i.id === deepId);
1254
+ if (deep) openDetail(deep);
1255
+ document.body.dataset.ready = '1';
1256
+ if (new URLSearchParams(location.search).get('check') === '1') {
1257
+ const bad = [...document.querySelectorAll('.card,.kpi,.table-card,.sheet')].filter(n => n.scrollWidth > n.clientWidth + 1).map(n => n.className.split(' ')[0]);
1258
+ let click = '';
1259
+ if (location.hash.slice(1) === 'conflicts') {
1260
+ const box = document.querySelector('.cc-ver');
1261
+ if (box) {
1262
+ box.click();
1263
+ const modal = document.getElementById('modal');
1264
+ const body = document.getElementById('m-body').textContent.length > 10;
1265
+ const adopt = document.getElementById('m-adopt');
1266
+ click = (modal.classList.contains('on') && body ? ' click-ok' : ' click-fail') + (!adopt.hidden ? ' adopt-ok' : ' adopt-missing');
1267
+ if (new URLSearchParams(location.search).get('hold') !== '1') modal.classList.remove('on');
1268
+ } else click = ' click-missing';
1269
+ }
1270
+ document.title = (document.documentElement.scrollWidth > document.documentElement.clientWidth ? 'XOVERFLOW ' : 'OK ') + (bad.length ? bad.join(',') : 'clean') + click;
1271
+ }
1272
+ }
1273
+ if (!LIVE) boot();
1274
+ else loadLive().then(boot).catch(error => {
1275
+ document.body.dataset.ready = 'error';
1276
+ const box = document.querySelector('.content');
1277
+ if (box) box.innerHTML = '<div class="card" style="margin-top:40px"><h3 style="font-family:var(--serif);font-weight:400;font-size:1.02rem;letter-spacing:.1em">读取失败</h3>'
1278
+ + '<p style="margin-top:12px;color:var(--dim);font-size:.82rem">' + String(error.message) + '</p>'
1279
+ + '<p style="margin-top:8px;color:var(--faint);font-size:.74rem">确认 viewer 正在运行,然后刷新页面。</p></div>';
1280
+ });
1281
+ </script>
1282
+ </body>
1283
+ </html>