@memtensor/memos-local-openclaw-plugin 0.1.2 → 0.1.4
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.
- package/.env.example +13 -5
- package/README.md +180 -68
- package/dist/capture/index.d.ts +5 -7
- package/dist/capture/index.d.ts.map +1 -1
- package/dist/capture/index.js +72 -43
- package/dist/capture/index.js.map +1 -1
- package/dist/ingest/providers/anthropic.d.ts +2 -0
- package/dist/ingest/providers/anthropic.d.ts.map +1 -1
- package/dist/ingest/providers/anthropic.js +110 -1
- package/dist/ingest/providers/anthropic.js.map +1 -1
- package/dist/ingest/providers/bedrock.d.ts +2 -5
- package/dist/ingest/providers/bedrock.d.ts.map +1 -1
- package/dist/ingest/providers/bedrock.js +110 -6
- package/dist/ingest/providers/bedrock.js.map +1 -1
- package/dist/ingest/providers/gemini.d.ts +2 -0
- package/dist/ingest/providers/gemini.d.ts.map +1 -1
- package/dist/ingest/providers/gemini.js +106 -1
- package/dist/ingest/providers/gemini.js.map +1 -1
- package/dist/ingest/providers/index.d.ts +9 -0
- package/dist/ingest/providers/index.d.ts.map +1 -1
- package/dist/ingest/providers/index.js +66 -4
- package/dist/ingest/providers/index.js.map +1 -1
- package/dist/ingest/providers/openai.d.ts +2 -0
- package/dist/ingest/providers/openai.d.ts.map +1 -1
- package/dist/ingest/providers/openai.js +112 -1
- package/dist/ingest/providers/openai.js.map +1 -1
- package/dist/ingest/task-processor.d.ts +63 -0
- package/dist/ingest/task-processor.d.ts.map +1 -0
- package/dist/ingest/task-processor.js +339 -0
- package/dist/ingest/task-processor.js.map +1 -0
- package/dist/ingest/worker.d.ts +1 -1
- package/dist/ingest/worker.d.ts.map +1 -1
- package/dist/ingest/worker.js +18 -13
- package/dist/ingest/worker.js.map +1 -1
- package/dist/recall/engine.d.ts +1 -0
- package/dist/recall/engine.d.ts.map +1 -1
- package/dist/recall/engine.js +21 -11
- package/dist/recall/engine.js.map +1 -1
- package/dist/recall/mmr.d.ts.map +1 -1
- package/dist/recall/mmr.js +3 -1
- package/dist/recall/mmr.js.map +1 -1
- package/dist/storage/sqlite.d.ts +67 -1
- package/dist/storage/sqlite.d.ts.map +1 -1
- package/dist/storage/sqlite.js +251 -5
- package/dist/storage/sqlite.js.map +1 -1
- package/dist/types.d.ts +15 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -1
- package/dist/viewer/html.d.ts +1 -1
- package/dist/viewer/html.d.ts.map +1 -1
- package/dist/viewer/html.js +955 -115
- package/dist/viewer/html.js.map +1 -1
- package/dist/viewer/server.d.ts +3 -0
- package/dist/viewer/server.d.ts.map +1 -1
- package/dist/viewer/server.js +59 -1
- package/dist/viewer/server.js.map +1 -1
- package/index.ts +221 -45
- package/openclaw.plugin.json +20 -45
- package/package.json +3 -4
- package/skill/SKILL.md +59 -0
- package/src/capture/index.ts +85 -45
- package/src/ingest/providers/anthropic.ts +128 -1
- package/src/ingest/providers/bedrock.ts +130 -6
- package/src/ingest/providers/gemini.ts +128 -1
- package/src/ingest/providers/index.ts +74 -8
- package/src/ingest/providers/openai.ts +130 -1
- package/src/ingest/task-processor.ts +380 -0
- package/src/ingest/worker.ts +21 -15
- package/src/recall/engine.ts +22 -12
- package/src/recall/mmr.ts +3 -1
- package/src/storage/sqlite.ts +298 -5
- package/src/types.ts +19 -0
- package/src/viewer/html.ts +955 -115
- package/src/viewer/server.ts +63 -1
- package/SKILL.md +0 -43
- package/www/index.html +0 -606
package/dist/viewer/html.js
CHANGED
|
@@ -26,7 +26,33 @@ exports.viewerHTML = `<!DOCTYPE html>
|
|
|
26
26
|
--shadow-lg:0 20px 40px rgba(0,0,0,.35);
|
|
27
27
|
--radius:12px;--radius-lg:14px;--radius-xl:18px;
|
|
28
28
|
}
|
|
29
|
-
|
|
29
|
+
[data-theme="light"]{
|
|
30
|
+
--bg:#f1f5f9;--bg-card:#fff;--bg-card-hover:#f8fafc;
|
|
31
|
+
--border:rgba(0,0,0,.08);--border-glow:rgba(0,187,238,.4);
|
|
32
|
+
--text:#0f172a;--text-sec:#475569;--text-muted:#64748b;
|
|
33
|
+
--pri:#0891b2;--pri-glow:rgba(8,145,178,.12);--pri-dark:#0e7490;
|
|
34
|
+
--pri-grad:linear-gradient(135deg,#0891b2,#0e7490);
|
|
35
|
+
--accent:#dc2626;--accent-glow:rgba(220,38,38,.1);
|
|
36
|
+
--green:#059669;--green-bg:rgba(5,150,105,.1);
|
|
37
|
+
--amber:#d97706;--amber-bg:rgba(217,119,6,.1);
|
|
38
|
+
--violet:#7c3aed;--rose:#e11d48;--rose-bg:rgba(225,29,72,.1);
|
|
39
|
+
--shadow-sm:0 1px 2px rgba(0,0,0,.06);--shadow:0 4px 12px rgba(0,0,0,.08);
|
|
40
|
+
--shadow-lg:0 20px 40px rgba(0,0,0,.12);
|
|
41
|
+
}
|
|
42
|
+
[data-theme="light"] .auth-screen{background:linear-gradient(135deg,#e0f2fe 0%,#f0f9ff 50%,#e0e7ff 100%)}
|
|
43
|
+
[data-theme="light"] .auth-card{box-shadow:0 25px 50px -12px rgba(0,0,0,.12)}
|
|
44
|
+
[data-theme="light"] .topbar{background:rgba(255,255,255,.95);border-bottom-color:var(--border)}
|
|
45
|
+
[data-theme="light"] .session-item .count,[data-theme="light"] .kind-tag,[data-theme="light"] .session-tag{background:rgba(0,0,0,.06)}
|
|
46
|
+
[data-theme="light"] .card-content pre{background:rgba(0,0,0,.05);border-color:var(--border)}
|
|
47
|
+
[data-theme="light"] .vscore-badge{background:rgba(59,130,246,.1);color:#3b82f6}
|
|
48
|
+
[data-theme="light"] ::-webkit-scrollbar-thumb{background:rgba(0,0,0,.2)}
|
|
49
|
+
[data-theme="light"] .analytics-card{background:linear-gradient(145deg,#fff 0%,#f8fafc 100%);border-color:rgba(0,0,0,.08)}
|
|
50
|
+
[data-theme="light"] .analytics-section{background:#fff;border-color:rgba(0,0,0,.08)}
|
|
51
|
+
[data-theme="light"] .breakdown-item{background:rgba(0,0,0,.04)}
|
|
52
|
+
[data-theme="light"] .metrics-toolbar .range-btn{background:#fff;border-color:rgba(0,0,0,.1)}
|
|
53
|
+
[data-theme="light"] .metrics-toolbar .range-btn.active{background:rgba(0,0,0,.06);color:var(--text);border-color:rgba(0,0,0,.15)}
|
|
54
|
+
[data-theme="light"] .metrics-toolbar .range-btn:hover{border-color:var(--pri);color:var(--pri)}
|
|
55
|
+
body{font-family:'Inter',-apple-system,BlinkMacSystemFont,sans-serif;background:var(--bg);color:var(--text);line-height:1.6;transition:background .2s,color .2s}
|
|
30
56
|
button{cursor:pointer;font-family:inherit;font-size:inherit}
|
|
31
57
|
input,textarea,select{font-family:inherit;font-size:inherit}
|
|
32
58
|
|
|
@@ -38,12 +64,12 @@ input,textarea,select{font-family:inherit;font-size:inherit}
|
|
|
38
64
|
.auth-card p{color:hsl(0 0% 45.1%);margin-bottom:24px;font-size:14px}
|
|
39
65
|
.auth-card input{width:100%;padding:12px 16px;border:1px solid hsl(0 0% 89.8%);border-radius:8px;font-size:14px;transition:all .2s;margin-bottom:10px;outline:none;background:#fff;color:hsl(0 0% 3.9%)}
|
|
40
66
|
.auth-card input::placeholder{color:hsl(0 0% 45.1%)}
|
|
41
|
-
.auth-card input:focus{border-color
|
|
42
|
-
.auth-card .btn-auth{width:100%;padding:12px;border:none;border-radius:8px;background
|
|
43
|
-
.auth-card .btn-auth:hover{background
|
|
67
|
+
.auth-card input:focus{border-color:#3b82f6;box-shadow:0 0 0 3px rgba(59,130,246,.15)}
|
|
68
|
+
.auth-card .btn-auth{width:100%;padding:12px;border:none;border-radius:8px;background:#3b82f6;color:#fff;font-weight:600;font-size:14px;transition:all .2s}
|
|
69
|
+
.auth-card .btn-auth:hover{background:#2563eb;transform:translateY(-1px);box-shadow:0 8px 25px rgba(59,130,246,.3)}
|
|
44
70
|
.auth-card .error-msg{color:hsl(0 84.2% 60.2%);font-size:13px;margin-top:8px;min-height:20px}
|
|
45
71
|
.auth-card .btn-text{color:hsl(0 0% 45.1%)}
|
|
46
|
-
.auth-card .btn-text:hover{color
|
|
72
|
+
.auth-card .btn-text:hover{color:#3b82f6}
|
|
47
73
|
|
|
48
74
|
.reset-guide{text-align:left;margin-bottom:20px}
|
|
49
75
|
.reset-step{display:flex;gap:14px;margin-bottom:16px}
|
|
@@ -59,10 +85,12 @@ input,textarea,select{font-family:inherit;font-size:inherit}
|
|
|
59
85
|
|
|
60
86
|
/* ─── App Layout (dark dashboard, same as www) ─── */
|
|
61
87
|
.app{display:none;flex-direction:column;min-height:100vh}
|
|
62
|
-
.topbar{background:rgba(5,5,16,.
|
|
63
|
-
.topbar .brand{display:flex;align-items:center;gap:
|
|
64
|
-
.topbar .brand .icon{width:
|
|
65
|
-
.topbar .
|
|
88
|
+
.topbar{background:rgba(5,5,16,.92);border-bottom:1px solid var(--border);padding:0 28px;height:56px;display:flex;align-items:center;position:sticky;top:0;z-index:100;backdrop-filter:blur(16px)}
|
|
89
|
+
.topbar .brand{display:flex;align-items:center;gap:10px;font-weight:700;font-size:15px;color:var(--text);letter-spacing:-.02em;flex-shrink:0}
|
|
90
|
+
.topbar .brand .icon{width:32px;height:32px;display:flex;align-items:center;justify-content:center;font-size:22px;background:none;border-radius:0}
|
|
91
|
+
.topbar .brand .sub{font-weight:400;color:var(--text-muted);font-size:11px}
|
|
92
|
+
.topbar-center{flex:1;display:flex;justify-content:center}
|
|
93
|
+
.topbar .actions{display:flex;align-items:center;gap:6px;flex-shrink:0}
|
|
66
94
|
|
|
67
95
|
.main-content{display:flex;flex:1;max-width:1400px;margin:0 auto;width:100%;padding:28px 32px;gap:28px}
|
|
68
96
|
|
|
@@ -90,11 +118,11 @@ input,textarea,select{font-family:inherit;font-size:inherit}
|
|
|
90
118
|
|
|
91
119
|
/* ─── Feed ─── */
|
|
92
120
|
.feed{flex:1;min-width:0}
|
|
93
|
-
.search-bar{display:flex;gap:
|
|
94
|
-
.search-bar input{flex:1;padding:
|
|
121
|
+
.search-bar{display:flex;gap:10px;margin-bottom:16px;position:relative;align-items:center}
|
|
122
|
+
.search-bar input{flex:1;padding:10px 16px 10px 40px;border:1px solid var(--border);border-radius:10px;font-size:14px;outline:none;background:var(--bg-card);color:var(--text);transition:all .2s}
|
|
95
123
|
.search-bar input::placeholder{color:var(--text-muted)}
|
|
96
124
|
.search-bar input:focus{border-color:var(--pri);box-shadow:0 0 0 3px var(--pri-glow)}
|
|
97
|
-
.search-bar .search-icon{position:absolute;left:
|
|
125
|
+
.search-bar .search-icon{position:absolute;left:14px;top:50%;transform:translateY(-50%);color:var(--text-muted);font-size:14px;pointer-events:none}
|
|
98
126
|
.search-meta{font-size:12px;color:var(--text-sec);margin-bottom:14px;padding:0 2px}
|
|
99
127
|
|
|
100
128
|
.filter-bar{display:flex;gap:8px;margin-bottom:16px;flex-wrap:wrap}
|
|
@@ -119,19 +147,25 @@ input,textarea,select{font-family:inherit;font-size:inherit}
|
|
|
119
147
|
.card-content.show{max-height:600px;overflow-y:auto}
|
|
120
148
|
.card-content pre{white-space:pre-wrap;word-break:break-all;background:rgba(0,0,0,.25);padding:14px;border-radius:10px;font-size:12px;font-family:ui-monospace,monospace;margin-top:10px;border:1px solid var(--border);color:var(--text-sec)}
|
|
121
149
|
.card-actions{display:flex;align-items:center;gap:8px;margin-top:14px}
|
|
122
|
-
.vscore-badge{display:inline-flex;align-items:center;background:
|
|
150
|
+
.vscore-badge{display:inline-flex;align-items:center;background:rgba(59,130,246,.15);color:#60a5fa;font-size:10px;font-weight:700;padding:4px 10px;border-radius:8px;margin-left:auto}
|
|
123
151
|
|
|
124
152
|
/* ─── Buttons ─── */
|
|
125
|
-
.btn{padding:
|
|
153
|
+
.btn{padding:7px 14px;border-radius:8px;border:1px solid var(--border);background:var(--bg-card);color:var(--text);font-size:13px;font-weight:500;transition:all .18s ease;display:inline-flex;align-items:center;gap:5px;white-space:nowrap}
|
|
126
154
|
.btn:hover{border-color:var(--pri);color:var(--pri)}
|
|
127
|
-
.btn-primary{background:var(--
|
|
128
|
-
.btn-primary:hover{background
|
|
129
|
-
.btn-
|
|
130
|
-
.btn-
|
|
131
|
-
.btn-
|
|
132
|
-
.btn-
|
|
133
|
-
.btn-
|
|
155
|
+
.btn-primary{background:rgba(255,255,255,.08);color:var(--text);border:1px solid var(--border);font-weight:600}
|
|
156
|
+
.btn-primary:hover{background:rgba(255,255,255,.14);transform:translateY(-1px);border-color:var(--pri);color:var(--pri)}
|
|
157
|
+
.btn-ghost{border-color:transparent;background:transparent;color:var(--text-sec)}
|
|
158
|
+
.btn-ghost:hover{background:rgba(255,255,255,.06);color:var(--text)}
|
|
159
|
+
.btn-danger{color:var(--accent);border-color:rgba(230,57,70,.25)}
|
|
160
|
+
.btn-danger:hover{background:rgba(230,57,70,.1);color:var(--accent)}
|
|
161
|
+
.btn-sm{padding:5px 12px;font-size:12px}
|
|
162
|
+
.btn-icon{padding:5px 7px;font-size:15px;border-radius:8px}
|
|
163
|
+
.btn-text{border:none;background:none;color:var(--text-muted);font-size:12px;padding:4px 8px}
|
|
134
164
|
.btn-text:hover{color:var(--pri)}
|
|
165
|
+
[data-theme="light"] .btn-primary{background:rgba(0,0,0,.05);color:var(--text);border-color:rgba(0,0,0,.12)}
|
|
166
|
+
[data-theme="light"] .btn-primary:hover{background:rgba(0,0,0,.08);border-color:var(--pri);color:var(--pri)}
|
|
167
|
+
[data-theme="light"] .btn-ghost{color:var(--text-sec)}
|
|
168
|
+
[data-theme="light"] .btn-ghost:hover{background:rgba(0,0,0,.04);color:var(--text)}
|
|
135
169
|
|
|
136
170
|
/* ─── Modal ─── */
|
|
137
171
|
.modal-overlay{display:none;position:fixed;inset:0;background:rgba(0,0,0,.6);z-index:500;align-items:center;justify-content:center;backdrop-filter:blur(8px)}
|
|
@@ -181,72 +215,219 @@ input,textarea,select{font-family:inherit;font-size:inherit}
|
|
|
181
215
|
.pagination .pg-btn.disabled{opacity:.4;pointer-events:none}
|
|
182
216
|
.pagination .pg-info{font-size:12px;color:var(--text-sec);padding:0 12px}
|
|
183
217
|
|
|
184
|
-
|
|
218
|
+
/* ─── Tasks 视图 ─── */
|
|
219
|
+
.tasks-view{display:none;flex:1;min-width:0;flex-direction:column;gap:16px}
|
|
220
|
+
.tasks-view.show{display:flex}
|
|
221
|
+
.tasks-header{display:flex;flex-direction:column;gap:14px}
|
|
222
|
+
.tasks-stats{display:flex;gap:16px}
|
|
223
|
+
.tasks-stat{display:flex;align-items:center;gap:8px;background:var(--bg-card);border:1px solid var(--border);border-radius:var(--radius);padding:12px 18px;flex:1;transition:all .2s}
|
|
224
|
+
.tasks-stat:hover{border-color:var(--border-glow)}
|
|
225
|
+
.tasks-stat-value{font-size:22px;font-weight:700;color:var(--text)}
|
|
226
|
+
.tasks-stat-label{font-size:12px;color:var(--text-sec);font-weight:500}
|
|
227
|
+
.tasks-filters{display:flex;align-items:center;gap:6px;flex-wrap:wrap}
|
|
228
|
+
.tasks-list{display:flex;flex-direction:column;gap:10px}
|
|
229
|
+
.task-card{background:var(--bg-card);border:1px solid var(--border);border-radius:var(--radius-lg);padding:18px 20px;cursor:pointer;transition:all .25s;position:relative;overflow:hidden}
|
|
230
|
+
.task-card:hover{border-color:var(--border-glow);background:var(--bg-card-hover);transform:translateY(-1px);box-shadow:var(--shadow)}
|
|
231
|
+
.task-card::before{content:'';position:absolute;top:0;left:0;bottom:0;width:3px;border-radius:3px 0 0 3px}
|
|
232
|
+
.task-card.status-active::before{background:var(--green)}
|
|
233
|
+
.task-card.status-completed::before{background:var(--pri)}
|
|
234
|
+
.task-card.status-skipped::before{background:var(--text-muted)}
|
|
235
|
+
.task-card.status-skipped{opacity:.6}
|
|
236
|
+
.task-card-top{display:flex;align-items:flex-start;justify-content:space-between;gap:12px;margin-bottom:8px}
|
|
237
|
+
.task-card-title{font-size:14px;font-weight:600;color:var(--text);line-height:1.4;flex:1;word-break:break-word}
|
|
238
|
+
.task-card-title:empty::after{content:'Untitled Task';color:var(--text-muted);font-style:italic}
|
|
239
|
+
.task-status-badge{font-size:10px;font-weight:700;text-transform:uppercase;letter-spacing:.06em;padding:3px 10px;border-radius:20px;flex-shrink:0}
|
|
240
|
+
.task-status-badge.active{color:var(--green);background:var(--green-bg)}
|
|
241
|
+
.task-status-badge.completed{color:var(--pri);background:var(--pri-glow)}
|
|
242
|
+
.task-status-badge.skipped{color:var(--text-muted);background:rgba(128,128,128,.15)}
|
|
243
|
+
.task-card-summary{font-size:13px;color:var(--text-sec);line-height:1.5;margin-bottom:10px;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden}
|
|
244
|
+
.task-card-summary:empty{display:none}
|
|
245
|
+
.task-card-bottom{display:flex;align-items:center;gap:14px;font-size:11px;color:var(--text-muted)}
|
|
246
|
+
.task-card-bottom .tag{display:flex;align-items:center;gap:4px}
|
|
247
|
+
.task-card-bottom .tag .icon{font-size:12px}
|
|
248
|
+
|
|
249
|
+
/* ─── Task Detail Overlay ─── */
|
|
250
|
+
.task-detail-overlay{display:none;position:fixed;inset:0;background:rgba(0,0,0,.6);z-index:200;align-items:center;justify-content:center;padding:24px;backdrop-filter:blur(4px)}
|
|
251
|
+
.task-detail-overlay.show{display:flex}
|
|
252
|
+
.task-detail-panel{background:var(--bg);border:1px solid var(--border);border-radius:var(--radius-xl);width:100%;max-width:780px;max-height:85vh;overflow-y:auto;box-shadow:var(--shadow-lg);padding:28px 32px}
|
|
253
|
+
.task-detail-header{display:flex;align-items:flex-start;justify-content:space-between;gap:16px;margin-bottom:16px}
|
|
254
|
+
.task-detail-header h2{font-size:18px;font-weight:700;color:var(--text);line-height:1.4;flex:1}
|
|
255
|
+
.task-detail-meta{display:flex;flex-wrap:wrap;gap:12px;margin-bottom:20px;font-size:12px;color:var(--text-sec)}
|
|
256
|
+
.task-detail-meta .meta-item{display:flex;align-items:center;gap:5px;background:var(--bg-card);border:1px solid var(--border);border-radius:8px;padding:5px 12px}
|
|
257
|
+
.task-detail-summary{background:var(--bg-card);border:1px solid var(--border);border-radius:var(--radius);padding:20px;margin-bottom:20px;font-size:13px;line-height:1.7;color:var(--text);word-break:break-word}
|
|
258
|
+
.task-detail-summary:empty::after{content:'Summary not yet generated (task still active)';color:var(--text-muted);font-style:italic}
|
|
259
|
+
.task-detail-summary .summary-section-title{font-size:14px;font-weight:700;color:var(--text);margin:14px 0 6px 0;padding-bottom:4px;border-bottom:1px solid var(--border)}
|
|
260
|
+
.task-detail-summary .summary-section-title:first-child{margin-top:0}
|
|
261
|
+
.task-detail-summary ul{margin:4px 0 8px 0;padding-left:20px}
|
|
262
|
+
.task-detail-summary li{margin:3px 0;color:var(--text-sec);line-height:1.6}
|
|
263
|
+
.task-detail-chunks-title{font-size:12px;font-weight:700;color:var(--text-muted);text-transform:uppercase;letter-spacing:.06em;margin-bottom:12px}
|
|
264
|
+
.task-detail-chunks{display:flex;flex-direction:column;gap:14px;padding:8px 0}
|
|
265
|
+
.task-chunk-item{display:flex;flex-direction:column;max-width:82%;font-size:13px;line-height:1.6}
|
|
266
|
+
.task-chunk-item.role-user{align-self:flex-end;align-items:flex-end}
|
|
267
|
+
.task-chunk-item.role-assistant,.task-chunk-item.role-tool{align-self:flex-start;align-items:flex-start}
|
|
268
|
+
.task-chunk-role{font-size:10px;font-weight:600;text-transform:uppercase;letter-spacing:.05em;margin-bottom:3px;padding:0 4px}
|
|
269
|
+
.task-chunk-role.user{color:var(--pri)}
|
|
270
|
+
.task-chunk-role.assistant{color:var(--green)}
|
|
271
|
+
.task-chunk-role.tool{color:var(--amber)}
|
|
272
|
+
.task-chunk-bubble{padding:12px 16px;border-radius:16px;white-space:pre-wrap;word-break:break-word;max-height:200px;overflow:hidden;position:relative;transition:all .2s}
|
|
273
|
+
.task-chunk-bubble.expanded{max-height:none}
|
|
274
|
+
.role-user .task-chunk-bubble{background:var(--pri);color:#000;border-bottom-right-radius:4px}
|
|
275
|
+
.role-assistant .task-chunk-bubble{background:var(--bg-card);border:1px solid var(--border);color:var(--text-sec);border-bottom-left-radius:4px}
|
|
276
|
+
.role-tool .task-chunk-bubble{background:rgba(245,158,11,.08);border:1px solid rgba(245,158,11,.2);color:var(--text-sec);border-bottom-left-radius:4px;font-family:'SF Mono',Monaco,Consolas,monospace;font-size:12px}
|
|
277
|
+
.task-chunk-bubble:hover{filter:brightness(1.05)}
|
|
278
|
+
.task-chunk-time{font-size:10px;color:var(--text-muted);margin-top:3px;padding:0 4px}
|
|
279
|
+
[data-theme="light"] .role-user .task-chunk-bubble{background:var(--pri);color:#fff}
|
|
280
|
+
[data-theme="light"] .role-assistant .task-chunk-bubble{background:#f0f0f0;border:none;color:#333}
|
|
281
|
+
[data-theme="light"] .task-detail-panel{background:#fff}
|
|
282
|
+
[data-theme="light"] .task-card{background:#fff}
|
|
283
|
+
[data-theme="light"] .tasks-stat{background:#fff}
|
|
284
|
+
|
|
285
|
+
/* ─── Analytics / 统计 ─── */
|
|
286
|
+
.nav-tabs{display:flex;align-items:center;gap:2px;background:rgba(255,255,255,.06);border-radius:10px;padding:3px}
|
|
287
|
+
.nav-tabs .tab{padding:6px 20px;border-radius:8px;font-size:13px;font-weight:600;color:var(--text-sec);background:transparent;border:1px solid transparent;cursor:pointer;transition:all .2s;white-space:nowrap}
|
|
288
|
+
.nav-tabs .tab:hover{color:var(--text)}
|
|
289
|
+
.nav-tabs .tab.active{color:var(--text);background:rgba(255,255,255,.1);border-color:var(--border);box-shadow:0 1px 4px rgba(0,0,0,.15)}
|
|
290
|
+
[data-theme="light"] .nav-tabs{background:rgba(0,0,0,.05)}
|
|
291
|
+
[data-theme="light"] .nav-tabs .tab.active{background:#fff;border-color:rgba(0,0,0,.1);box-shadow:0 1px 3px rgba(0,0,0,.08);color:var(--text)}
|
|
292
|
+
.analytics-view{display:none;flex:1;min-width:0;flex-direction:column;gap:20px}
|
|
293
|
+
.analytics-view.show{display:flex}
|
|
294
|
+
.feed-wrap{flex:1;min-width:0;display:flex;flex-direction:column}
|
|
295
|
+
.feed-wrap.hide{display:none}
|
|
296
|
+
.analytics-cards{display:grid;grid-template-columns:repeat(5,1fr);gap:14px}
|
|
297
|
+
.analytics-card{background:linear-gradient(145deg,var(--bg-card) 0%,rgba(255,255,255,.02) 100%);border:1px solid var(--border);border-radius:var(--radius-lg);padding:20px 18px;position:relative;overflow:hidden;transition:all .25s}
|
|
298
|
+
.analytics-card:hover{border-color:var(--border-glow);transform:translateY(-2px);box-shadow:0 8px 20px rgba(0,0,0,.15)}
|
|
299
|
+
.analytics-card::before{content:'';position:absolute;top:0;left:0;right:0;height:3px;background:linear-gradient(90deg,#3b82f6,#60a5fa);opacity:.85}
|
|
300
|
+
.analytics-card.green::before{background:linear-gradient(90deg,var(--green),#34d399)}
|
|
301
|
+
.analytics-card.amber::before{background:linear-gradient(90deg,var(--amber),#fbbf24)}
|
|
302
|
+
.analytics-card.violet::before{background:linear-gradient(90deg,var(--violet),#a78bfa)}
|
|
303
|
+
.analytics-card .ac-value{font-size:26px;font-weight:800;letter-spacing:-.03em;color:var(--text);line-height:1.1}
|
|
304
|
+
.analytics-card .ac-label{font-size:11px;color:var(--text-muted);margin-top:5px;font-weight:500;text-transform:uppercase;letter-spacing:.04em}
|
|
305
|
+
.analytics-section{background:var(--bg-card);border:1px solid var(--border);border-radius:var(--radius-lg);padding:22px 24px}
|
|
306
|
+
.analytics-section h3{font-size:12px;font-weight:700;color:var(--text-muted);text-transform:uppercase;letter-spacing:.06em;margin-bottom:16px;display:flex;align-items:center;gap:8px}
|
|
307
|
+
.analytics-section h3 .icon{font-size:14px;opacity:.7}
|
|
308
|
+
.chart-bars{display:flex;align-items:flex-end;gap:4px;padding:8px 0;overflow-x:auto}
|
|
309
|
+
.chart-bar-wrap{flex:1;min-width:18px;max-width:60px;display:flex;flex-direction:column;align-items:center;gap:4px;position:relative}
|
|
310
|
+
.chart-bar-col{width:100%;height:160px;display:flex;flex-direction:column;justify-content:flex-end;align-items:stretch}
|
|
311
|
+
.chart-bar-wrap:hover .chart-bar{filter:brightness(1.25)}
|
|
312
|
+
.chart-bar-wrap:hover .chart-bar-label{color:var(--pri)}
|
|
313
|
+
.chart-bar-wrap:hover .chart-tip{opacity:1;transform:translateX(-50%) translateY(0)}
|
|
314
|
+
.chart-tip{position:absolute;top:-6px;left:50%;transform:translateX(-50%) translateY(4px);background:var(--bg);border:1px solid var(--border);color:var(--text);padding:2px 8px;border-radius:6px;font-size:10px;font-weight:700;white-space:nowrap;z-index:5;pointer-events:none;box-shadow:var(--shadow);opacity:0;transition:all .15s ease}
|
|
315
|
+
.chart-bar{width:100%;border-radius:4px 4px 0 0;background:linear-gradient(180deg,#60a5fa,#3b82f6);transition:all .3s ease}
|
|
316
|
+
.chart-bar.violet{background:linear-gradient(180deg,var(--violet),#7c3aed)}
|
|
317
|
+
.chart-bar.green{background:linear-gradient(180deg,var(--green),#059669)}
|
|
318
|
+
.chart-bar.zero{background:var(--border);opacity:.4;border-radius:2px}
|
|
319
|
+
.chart-bar-label{font-size:9px;color:var(--text-muted);white-space:nowrap;overflow:hidden;text-overflow:ellipsis;max-width:100%;text-align:center;transition:color .15s}
|
|
320
|
+
.chart-legend{display:flex;gap:16px;margin-top:12px;flex-wrap:wrap;font-size:12px;color:var(--text-sec)}
|
|
321
|
+
.chart-legend span{display:inline-flex;align-items:center;gap:6px}
|
|
322
|
+
.chart-legend .dot{width:8px;height:8px;border-radius:50%}
|
|
323
|
+
.chart-legend .dot.pri{background:var(--pri)}
|
|
324
|
+
.chart-legend .dot.violet{background:var(--violet)}
|
|
325
|
+
.chart-legend .dot.green{background:var(--green)}
|
|
326
|
+
.breakdown-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(200px,1fr));gap:20px}
|
|
327
|
+
.breakdown-item{display:flex;flex-direction:column;gap:6px;padding:12px 14px;background:rgba(0,0,0,.12);border-radius:10px;border:1px solid var(--border);transition:border-color .15s}
|
|
328
|
+
.breakdown-item:hover{border-color:var(--border-glow)}
|
|
329
|
+
.breakdown-item .bd-top{display:flex;align-items:center;justify-content:space-between}
|
|
330
|
+
.breakdown-item .label{font-size:13px;color:var(--text-sec);font-weight:500;text-transform:capitalize}
|
|
331
|
+
.breakdown-item .value{font-size:14px;font-weight:700;color:var(--text)}
|
|
332
|
+
.breakdown-bar-wrap{height:4px;background:rgba(0,0,0,.15);border-radius:2px;overflow:hidden}
|
|
333
|
+
.breakdown-bar{height:100%;border-radius:2px;background:linear-gradient(90deg,#3b82f6,#60a5fa);transition:width .5s ease}
|
|
334
|
+
.metrics-toolbar{display:flex;align-items:center;gap:12px;margin-bottom:16px;flex-wrap:wrap}
|
|
335
|
+
.metrics-toolbar .range-btn{padding:6px 14px;border-radius:8px;border:1px solid var(--border);background:var(--bg-card);color:var(--text-sec);font-size:12px;font-weight:600;cursor:pointer;transition:all .15s}
|
|
336
|
+
.metrics-toolbar .range-btn:hover{border-color:var(--pri);color:var(--pri)}
|
|
337
|
+
.metrics-toolbar .range-btn.active{background:rgba(255,255,255,.1);color:var(--text);border-color:var(--border)}
|
|
338
|
+
|
|
339
|
+
.theme-toggle{position:relative;width:28px;height:28px;padding:0;display:flex;align-items:center;justify-content:center;font-size:14px;border:none;background:transparent}
|
|
340
|
+
.theme-toggle .theme-icon-light{display:none}
|
|
341
|
+
.theme-toggle .theme-icon-dark{display:inline}
|
|
342
|
+
[data-theme="light"] .theme-toggle .theme-icon-light{display:inline}
|
|
343
|
+
[data-theme="light"] .theme-toggle .theme-icon-dark{display:none}
|
|
344
|
+
|
|
345
|
+
.auth-top-actions{position:absolute;top:16px;right:16px;z-index:10;display:flex;align-items:center;gap:2px;background:rgba(255,255,255,.18);backdrop-filter:blur(10px);border-radius:20px;padding:3px}
|
|
346
|
+
.auth-theme-toggle{width:30px;height:30px;border:none;border-radius:50%;background:transparent;color:rgba(255,255,255,.7);cursor:pointer;display:flex;align-items:center;justify-content:center;font-size:13px;transition:all .2s}
|
|
347
|
+
.auth-theme-toggle:hover{background:rgba(255,255,255,.2);color:#fff}
|
|
348
|
+
.auth-theme-toggle .theme-icon-light{display:none}
|
|
349
|
+
.auth-theme-toggle .theme-icon-dark{display:inline}
|
|
350
|
+
[data-theme="light"] .auth-theme-toggle{color:rgba(0,0,0,.45)}
|
|
351
|
+
[data-theme="light"] .auth-theme-toggle:hover{background:rgba(0,0,0,.08);color:#0f172a}
|
|
352
|
+
[data-theme="light"] .auth-top-actions{background:rgba(0,0,0,.06)}
|
|
353
|
+
[data-theme="light"] .auth-theme-toggle .theme-icon-light{display:inline}
|
|
354
|
+
[data-theme="light"] .auth-theme-toggle .theme-icon-dark{display:none}
|
|
355
|
+
|
|
356
|
+
@media(max-width:1100px){.analytics-cards{grid-template-columns:repeat(3,1fr)}}
|
|
357
|
+
@media(max-width:900px){.main-content{flex-direction:column;padding:20px}.sidebar{width:100%}.sidebar .stats-grid{grid-template-columns:repeat(4,1fr)}.analytics-cards{grid-template-columns:repeat(2,1fr)}.topbar{padding:0 16px;gap:8px}.topbar .brand span{display:none}.topbar-center{justify-content:flex-start}}
|
|
185
358
|
</style>
|
|
186
359
|
</head>
|
|
187
360
|
<body>
|
|
188
361
|
|
|
189
362
|
<!-- ─── Auth: Setup Password ─── -->
|
|
190
363
|
<div id="setupScreen" class="auth-screen" style="display:none">
|
|
364
|
+
<div class="auth-top-actions">
|
|
365
|
+
<button class="auth-theme-toggle" onclick="toggleViewerTheme()" title="Toggle light/dark" aria-label="Toggle theme"><span class="theme-icon-dark">\u{1F319}</span><span class="theme-icon-light">\u2600</span></button>
|
|
366
|
+
<button class="auth-theme-toggle" onclick="toggleLang()" aria-label="Switch language"><span data-i18n="lang.switch">EN</span></button>
|
|
367
|
+
</div>
|
|
191
368
|
<div class="auth-card">
|
|
192
369
|
<div class="logo">\u{1F99E}</div>
|
|
193
|
-
<h1>OpenClaw Memory</h1>
|
|
194
|
-
<p style="font-size:12px;color:var(--text-sec);margin-bottom:6px">Powered by MemOS</p>
|
|
195
|
-
<p>Set a password to protect your memories</p>
|
|
196
|
-
<input type="password" id="setupPw" placeholder="Enter a password (4+ characters)" autofocus>
|
|
197
|
-
<input type="password" id="setupPw2" placeholder="Confirm password">
|
|
198
|
-
<button class="btn-auth" onclick="doSetup()">Set Password & Enter</button>
|
|
370
|
+
<h1 data-i18n="title">OpenClaw Memory</h1>
|
|
371
|
+
<p style="font-size:12px;color:var(--text-sec);margin-bottom:6px" data-i18n="subtitle">Powered by MemOS</p>
|
|
372
|
+
<p data-i18n="setup.desc">Set a password to protect your memories</p>
|
|
373
|
+
<input type="password" id="setupPw" data-i18n-ph="setup.pw" placeholder="Enter a password (4+ characters)" autofocus>
|
|
374
|
+
<input type="password" id="setupPw2" data-i18n-ph="setup.pw2" placeholder="Confirm password">
|
|
375
|
+
<button class="btn-auth" onclick="doSetup()" data-i18n="setup.btn">Set Password & Enter</button>
|
|
199
376
|
<div class="error-msg" id="setupErr"></div>
|
|
200
377
|
</div>
|
|
201
378
|
</div>
|
|
202
379
|
|
|
203
380
|
<!-- ─── Auth: Login ─── -->
|
|
204
381
|
<div id="loginScreen" class="auth-screen" style="display:none">
|
|
382
|
+
<div class="auth-top-actions">
|
|
383
|
+
<button class="auth-theme-toggle" onclick="toggleViewerTheme()" title="Toggle light/dark" aria-label="Toggle theme"><span class="theme-icon-dark">\u{1F319}</span><span class="theme-icon-light">\u2600</span></button>
|
|
384
|
+
<button class="auth-theme-toggle" onclick="toggleLang()" aria-label="Switch language"><span data-i18n="lang.switch">EN</span></button>
|
|
385
|
+
</div>
|
|
205
386
|
<div class="auth-card">
|
|
206
387
|
<div class="logo">\u{1F99E}</div>
|
|
207
|
-
<h1>OpenClaw Memory</h1>
|
|
208
|
-
<p style="font-size:12px;color:var(--text-sec);margin-bottom:6px">Powered by MemOS</p>
|
|
209
|
-
<p>Enter your password to access memories</p>
|
|
388
|
+
<h1 data-i18n="title">OpenClaw Memory</h1>
|
|
389
|
+
<p style="font-size:12px;color:var(--text-sec);margin-bottom:6px" data-i18n="subtitle">Powered by MemOS</p>
|
|
390
|
+
<p data-i18n="login.desc">Enter your password to access memories</p>
|
|
210
391
|
<div id="loginForm">
|
|
211
|
-
<input type="password" id="loginPw" placeholder="Password" autofocus>
|
|
212
|
-
<button class="btn-auth" onclick="doLogin()">Unlock</button>
|
|
392
|
+
<input type="password" id="loginPw" data-i18n-ph="login.pw" placeholder="Password" autofocus>
|
|
393
|
+
<button class="btn-auth" onclick="doLogin()" data-i18n="login.btn">Unlock</button>
|
|
213
394
|
<div class="error-msg" id="loginErr"></div>
|
|
214
|
-
<button class="btn-text" style="margin-top:12px;font-size:13px;color:var(--text-sec)" onclick="showResetForm()">Forgot password?</button>
|
|
395
|
+
<button class="btn-text" style="margin-top:12px;font-size:13px;color:var(--text-sec)" onclick="showResetForm()" data-i18n="login.forgot">Forgot password?</button>
|
|
215
396
|
</div>
|
|
216
397
|
<div id="resetForm" style="display:none">
|
|
217
398
|
<div class="reset-guide">
|
|
218
399
|
<div class="reset-step">
|
|
219
400
|
<div class="step-num">1</div>
|
|
220
401
|
<div class="step-body">
|
|
221
|
-
<div class="step-title">Open Terminal</div>
|
|
222
|
-
<div class="step-desc">Run the following command to get your reset token (use the pattern below so you get the line that contains the token):</div>
|
|
402
|
+
<div class="step-title" data-i18n="reset.step1.title">Open Terminal</div>
|
|
403
|
+
<div class="step-desc" data-i18n="reset.step1.desc">Run the following command to get your reset token (use the pattern below so you get the line that contains the token):</div>
|
|
223
404
|
<div class="cmd-box" onclick="copyCmd(this)">
|
|
224
405
|
<code>grep "password reset token:" /tmp/openclaw/openclaw-*.log ~/.openclaw/logs/gateway.log 2>/dev/null | tail -1</code>
|
|
225
|
-
<span class="copy-hint">Click to copy</span>
|
|
406
|
+
<span class="copy-hint" data-i18n="copy.hint">Click to copy</span>
|
|
226
407
|
</div>
|
|
227
408
|
</div>
|
|
228
409
|
</div>
|
|
229
410
|
<div class="reset-step">
|
|
230
411
|
<div class="step-num">2</div>
|
|
231
412
|
<div class="step-body">
|
|
232
|
-
<div class="step-title">Find the token</div>
|
|
233
|
-
<div class="step-desc">In the output, find <span style="font-family:monospace;font-size:12px;color:var(--pri)">password reset token: <strong>a1b2c3d4e5f6...</strong></span> (plain line or inside JSON). Copy the 32-character hex string after the colon.</div>
|
|
413
|
+
<div class="step-title" data-i18n="reset.step2.title">Find the token</div>
|
|
414
|
+
<div class="step-desc" id="resetStep2Desc">In the output, find <span style="font-family:monospace;font-size:12px;color:var(--pri)">password reset token: <strong>a1b2c3d4e5f6...</strong></span> (plain line or inside JSON). Copy the 32-character hex string after the colon.</div>
|
|
234
415
|
</div>
|
|
235
416
|
</div>
|
|
236
417
|
<div class="reset-step">
|
|
237
418
|
<div class="step-num">3</div>
|
|
238
419
|
<div class="step-body">
|
|
239
|
-
<div class="step-title">Paste & reset</div>
|
|
240
|
-
<div class="step-desc">Paste the token below and set your new password.</div>
|
|
420
|
+
<div class="step-title" data-i18n="reset.step3.title">Paste & reset</div>
|
|
421
|
+
<div class="step-desc" data-i18n="reset.step3.desc">Paste the token below and set your new password.</div>
|
|
241
422
|
</div>
|
|
242
423
|
</div>
|
|
243
424
|
</div>
|
|
244
|
-
<input type="text" id="resetToken" placeholder="Paste reset token here" style="margin-bottom:8px;font-family:monospace">
|
|
245
|
-
<input type="password" id="resetNewPw" placeholder="New password (4+ characters)">
|
|
246
|
-
<input type="password" id="resetNewPw2" placeholder="Confirm new password">
|
|
247
|
-
<button class="btn-auth" onclick="doReset()">Reset Password</button>
|
|
425
|
+
<input type="text" id="resetToken" data-i18n-ph="reset.token" placeholder="Paste reset token here" style="margin-bottom:8px;font-family:monospace">
|
|
426
|
+
<input type="password" id="resetNewPw" data-i18n-ph="reset.newpw" placeholder="New password (4+ characters)">
|
|
427
|
+
<input type="password" id="resetNewPw2" data-i18n-ph="reset.newpw2" placeholder="Confirm new password">
|
|
428
|
+
<button class="btn-auth" onclick="doReset()" data-i18n="reset.btn">Reset Password</button>
|
|
248
429
|
<div class="error-msg" id="resetErr"></div>
|
|
249
|
-
<button class="btn-text" style="margin-top:12px;font-size:13px;color:var(--text-sec)" onclick="showLoginForm()">\u2190 Back to login</button>
|
|
430
|
+
<button class="btn-text" style="margin-top:12px;font-size:13px;color:var(--text-sec)" onclick="showLoginForm()" data-i18n="reset.back">\u2190 Back to login</button>
|
|
250
431
|
</div>
|
|
251
432
|
</div>
|
|
252
433
|
</div>
|
|
@@ -256,77 +437,153 @@ input,textarea,select{font-family:inherit;font-size:inherit}
|
|
|
256
437
|
<div class="topbar">
|
|
257
438
|
<div class="brand">
|
|
258
439
|
<div class="icon">\u{1F99E}</div>
|
|
259
|
-
<span
|
|
440
|
+
<span data-i18n="title">OpenClaw Memory</span>
|
|
441
|
+
</div>
|
|
442
|
+
<div class="topbar-center">
|
|
443
|
+
<nav class="nav-tabs">
|
|
444
|
+
<button class="tab active" data-view="memories" onclick="switchView('memories')" data-i18n="tab.memories">\u{1F4DA} Memories</button>
|
|
445
|
+
<button class="tab" data-view="tasks" onclick="switchView('tasks')" data-i18n="tab.tasks">\u{1F4CB} Tasks</button>
|
|
446
|
+
<button class="tab" data-view="analytics" onclick="switchView('analytics')" data-i18n="tab.analytics">\u{1F4CA} Analytics</button>
|
|
447
|
+
</nav>
|
|
260
448
|
</div>
|
|
261
449
|
<div class="actions">
|
|
262
|
-
<button class="btn btn-
|
|
263
|
-
<button class="btn" onclick="
|
|
264
|
-
<button class="btn btn-
|
|
265
|
-
<button class="btn btn-
|
|
450
|
+
<button class="btn btn-icon" onclick="toggleLang()" aria-label="Switch language" style="font-size:12px;font-weight:700;padding:4px 8px"><span data-i18n="lang.switch">EN</span></button>
|
|
451
|
+
<button class="btn btn-icon theme-toggle" onclick="toggleViewerTheme()" title="Toggle light/dark" aria-label="Toggle theme"><span class="theme-icon-dark">\u{1F319}</span><span class="theme-icon-light">\u2600</span></button>
|
|
452
|
+
<button class="btn btn-ghost btn-sm" onclick="loadAll()" data-i18n="refresh">\u21BB Refresh</button>
|
|
453
|
+
<button class="btn btn-ghost btn-sm" onclick="doLogout()" data-i18n="logout">Logout</button>
|
|
266
454
|
</div>
|
|
267
455
|
</div>
|
|
268
456
|
|
|
269
457
|
<div class="main-content">
|
|
270
458
|
<div class="sidebar" id="sidebar">
|
|
271
459
|
<div class="stats-grid" id="statsGrid">
|
|
272
|
-
<div class="stat-card pri"><div class="stat-value" id="statTotal">-</div><div class="stat-label">Memories</div></div>
|
|
273
|
-
<div class="stat-card green"><div class="stat-value" id="statSessions">-</div><div class="stat-label">Sessions</div></div>
|
|
274
|
-
<div class="stat-card amber"><div class="stat-value" id="statEmbeddings">-</div><div class="stat-label">Embeddings</div></div>
|
|
275
|
-
<div class="stat-card rose"><div class="stat-value" id="statTimeSpan">-</div><div class="stat-label">Days</div></div>
|
|
460
|
+
<div class="stat-card pri"><div class="stat-value" id="statTotal">-</div><div class="stat-label" data-i18n="stat.memories">Memories</div></div>
|
|
461
|
+
<div class="stat-card green"><div class="stat-value" id="statSessions">-</div><div class="stat-label" data-i18n="stat.sessions">Sessions</div></div>
|
|
462
|
+
<div class="stat-card amber"><div class="stat-value" id="statEmbeddings">-</div><div class="stat-label" data-i18n="stat.embeddings">Embeddings</div></div>
|
|
463
|
+
<div class="stat-card rose"><div class="stat-value" id="statTimeSpan">-</div><div class="stat-label" data-i18n="stat.days">Days</div></div>
|
|
276
464
|
</div>
|
|
277
465
|
<div id="embeddingStatus"></div>
|
|
278
|
-
<div class="section-title">Sessions</div>
|
|
466
|
+
<div class="section-title" data-i18n="sidebar.sessions">Sessions</div>
|
|
279
467
|
<div class="session-list" id="sessionList"></div>
|
|
468
|
+
<button class="btn btn-sm btn-ghost" style="width:100%;margin-top:20px;justify-content:center;color:var(--text-muted);font-size:11px" onclick="clearAll()" data-i18n="sidebar.clear">\u{1F5D1} Clear All Data</button>
|
|
280
469
|
</div>
|
|
281
470
|
|
|
471
|
+
<div class="feed-wrap" id="feedWrap">
|
|
282
472
|
<div class="feed">
|
|
283
473
|
<div class="search-bar">
|
|
284
474
|
<span class="search-icon">\u{1F50D}</span>
|
|
285
|
-
<input type="text" id="searchInput" placeholder="Search memories (supports semantic search)..." oninput="debounceSearch()">
|
|
475
|
+
<input type="text" id="searchInput" data-i18n-ph="search.placeholder" placeholder="Search memories (supports semantic search)..." oninput="debounceSearch()">
|
|
286
476
|
</div>
|
|
287
477
|
<div class="search-meta" id="searchMeta"></div>
|
|
288
478
|
<div class="filter-bar" id="filterBar">
|
|
289
|
-
<button class="filter-chip active" data-role="" onclick="setRoleFilter(this,'')">All</button>
|
|
479
|
+
<button class="filter-chip active" data-role="" onclick="setRoleFilter(this,'')" data-i18n="filter.all">All</button>
|
|
290
480
|
<button class="filter-chip" data-role="user" onclick="setRoleFilter(this,'user')">User</button>
|
|
291
481
|
<button class="filter-chip" data-role="assistant" onclick="setRoleFilter(this,'assistant')">Assistant</button>
|
|
292
482
|
<button class="filter-chip" data-role="system" onclick="setRoleFilter(this,'system')">System</button>
|
|
293
483
|
<span class="filter-sep"></span>
|
|
294
484
|
<select id="filterKind" class="filter-select" onchange="applyFilters()">
|
|
295
|
-
<option value="">All kinds</option>
|
|
296
|
-
<option value="paragraph">Paragraph</option>
|
|
297
|
-
<option value="code_block">Code</option>
|
|
298
|
-
<option value="dialog">Dialog</option>
|
|
299
|
-
<option value="list">List</option>
|
|
300
|
-
<option value="error_stack">Error</option>
|
|
301
|
-
<option value="command">Command</option>
|
|
485
|
+
<option value="" data-i18n="filter.allkinds">All kinds</option>
|
|
486
|
+
<option value="paragraph" data-i18n="filter.paragraph">Paragraph</option>
|
|
487
|
+
<option value="code_block" data-i18n="filter.code">Code</option>
|
|
488
|
+
<option value="dialog" data-i18n="filter.dialog">Dialog</option>
|
|
489
|
+
<option value="list" data-i18n="filter.list">List</option>
|
|
490
|
+
<option value="error_stack" data-i18n="filter.error">Error</option>
|
|
491
|
+
<option value="command" data-i18n="filter.command">Command</option>
|
|
302
492
|
</select>
|
|
303
493
|
<select id="filterSort" class="filter-select" onchange="applyFilters()">
|
|
304
|
-
<option value="newest">Newest first</option>
|
|
305
|
-
<option value="oldest">Oldest first</option>
|
|
494
|
+
<option value="newest" data-i18n="filter.newest">Newest first</option>
|
|
495
|
+
<option value="oldest" data-i18n="filter.oldest">Oldest first</option>
|
|
306
496
|
</select>
|
|
307
497
|
</div>
|
|
308
498
|
<div class="date-filter">
|
|
309
|
-
<label>From</label><input type="datetime-local" id="dateFrom" step="1" onchange="applyFilters()">
|
|
310
|
-
<label>To</label><input type="datetime-local" id="dateTo" step="1" onchange="applyFilters()">
|
|
311
|
-
<button class="btn btn-sm btn-text" onclick="clearDateFilter()">Clear</button>
|
|
499
|
+
<label data-i18n="filter.from">From</label><input type="datetime-local" id="dateFrom" step="1" onchange="applyFilters()">
|
|
500
|
+
<label data-i18n="filter.to">To</label><input type="datetime-local" id="dateTo" step="1" onchange="applyFilters()">
|
|
501
|
+
<button class="btn btn-sm btn-text" onclick="clearDateFilter()" data-i18n="filter.clear">Clear</button>
|
|
312
502
|
</div>
|
|
313
503
|
<div class="memory-list" id="memoryList"><div class="spinner"></div></div>
|
|
314
504
|
<div class="pagination" id="pagination"></div>
|
|
315
505
|
</div>
|
|
506
|
+
</div>
|
|
507
|
+
<div class="tasks-view" id="tasksView">
|
|
508
|
+
<div class="tasks-header">
|
|
509
|
+
<div class="tasks-stats">
|
|
510
|
+
<div class="tasks-stat"><span class="tasks-stat-value" id="tasksTotalCount">-</span><span class="tasks-stat-label" data-i18n="tasks.total">Total Tasks</span></div>
|
|
511
|
+
<div class="tasks-stat"><span class="tasks-stat-value" id="tasksActiveCount">-</span><span class="tasks-stat-label" data-i18n="tasks.active">Active</span></div>
|
|
512
|
+
<div class="tasks-stat"><span class="tasks-stat-value" id="tasksCompletedCount">-</span><span class="tasks-stat-label" data-i18n="tasks.completed">Completed</span></div>
|
|
513
|
+
<div class="tasks-stat"><span class="tasks-stat-value" id="tasksSkippedCount">-</span><span class="tasks-stat-label" data-i18n="tasks.status.skipped">Skipped</span></div>
|
|
514
|
+
</div>
|
|
515
|
+
<div class="tasks-filters">
|
|
516
|
+
<button class="filter-chip active" data-task-status="" onclick="setTaskStatusFilter(this,'')" data-i18n="filter.all">All</button>
|
|
517
|
+
<button class="filter-chip" data-task-status="active" onclick="setTaskStatusFilter(this,'active')" data-i18n="tasks.status.active">Active</button>
|
|
518
|
+
<button class="filter-chip" data-task-status="completed" onclick="setTaskStatusFilter(this,'completed')" data-i18n="tasks.status.completed">Completed</button>
|
|
519
|
+
<button class="filter-chip" data-task-status="skipped" onclick="setTaskStatusFilter(this,'skipped')" data-i18n="tasks.status.skipped">Skipped</button>
|
|
520
|
+
<button class="btn btn-sm btn-ghost" onclick="loadTasks()" style="margin-left:auto" data-i18n="refresh">\u21BB Refresh</button>
|
|
521
|
+
</div>
|
|
522
|
+
</div>
|
|
523
|
+
<div class="tasks-list" id="tasksList"><div class="spinner"></div></div>
|
|
524
|
+
<div class="pagination" id="tasksPagination"></div>
|
|
525
|
+
<div class="task-detail-overlay" id="taskDetailOverlay" onclick="closeTaskDetail(event)">
|
|
526
|
+
<div class="task-detail-panel" onclick="event.stopPropagation()">
|
|
527
|
+
<div class="task-detail-header">
|
|
528
|
+
<h2 id="taskDetailTitle"></h2>
|
|
529
|
+
<button class="btn btn-icon" onclick="closeTaskDetail()" title="Close">\u2715</button>
|
|
530
|
+
</div>
|
|
531
|
+
<div class="task-detail-meta" id="taskDetailMeta"></div>
|
|
532
|
+
<div class="task-detail-summary" id="taskDetailSummary"></div>
|
|
533
|
+
<div class="task-detail-chunks-title" data-i18n="tasks.chunks">Related Memories</div>
|
|
534
|
+
<div class="task-detail-chunks" id="taskDetailChunks"></div>
|
|
535
|
+
</div>
|
|
536
|
+
</div>
|
|
537
|
+
</div>
|
|
538
|
+
<div class="analytics-view" id="analyticsView">
|
|
539
|
+
<div class="metrics-toolbar">
|
|
540
|
+
<span style="font-size:12px;color:var(--text-sec);font-weight:600" data-i18n="range">Range</span>
|
|
541
|
+
<button class="range-btn" data-days="7" onclick="setMetricsDays(7)">7 <span data-i18n="range.days">days</span></button>
|
|
542
|
+
<button class="range-btn active" data-days="30" onclick="setMetricsDays(30)">30 <span data-i18n="range.days">days</span></button>
|
|
543
|
+
<button class="range-btn" data-days="90" onclick="setMetricsDays(90)">90 <span data-i18n="range.days">days</span></button>
|
|
544
|
+
<button class="btn btn-sm" onclick="loadMetrics()" style="margin-left:auto" data-i18n="refresh">\u21BB Refresh</button>
|
|
545
|
+
</div>
|
|
546
|
+
<div class="analytics-cards" id="analyticsCards">
|
|
547
|
+
<div class="analytics-card"><div class="ac-value" id="mTotal">-</div><div class="ac-label" data-i18n="analytics.total">Total Memories</div></div>
|
|
548
|
+
<div class="analytics-card green"><div class="ac-value" id="mTodayWrites">-</div><div class="ac-label" data-i18n="analytics.writes">Writes Today</div></div>
|
|
549
|
+
<div class="analytics-card violet"><div class="ac-value" id="mTodayCalls">-</div><div class="ac-label" data-i18n="analytics.calls">Viewer Calls Today</div></div>
|
|
550
|
+
<div class="analytics-card"><div class="ac-value" id="mSessions">-</div><div class="ac-label" data-i18n="analytics.sessions">Sessions</div></div>
|
|
551
|
+
<div class="analytics-card amber"><div class="ac-value" id="mEmbeddings">-</div><div class="ac-label" data-i18n="analytics.embeddings">Embeddings</div></div>
|
|
552
|
+
</div>
|
|
553
|
+
<div class="analytics-section">
|
|
554
|
+
<h3><span class="icon">\u{1F4CA}</span> <span data-i18n="chart.writes">Memory Writes per Day</span></h3>
|
|
555
|
+
<div class="chart-bars" id="chartWrites"></div>
|
|
556
|
+
</div>
|
|
557
|
+
<div class="analytics-section">
|
|
558
|
+
<h3><span class="icon">\u{1F50D}</span> <span data-i18n="chart.calls">Viewer API Calls per Day (List / Search)</span></h3>
|
|
559
|
+
<div class="chart-bars" id="chartCalls"></div>
|
|
560
|
+
<div class="chart-legend"><span><span class="dot pri"></span> <span data-i18n="chart.list">List</span></span><span><span class="dot violet"></span> <span data-i18n="chart.search">Search</span></span></div>
|
|
561
|
+
</div>
|
|
562
|
+
<div class="breakdown-grid" style="display:grid;grid-template-columns:1fr 1fr;gap:24px">
|
|
563
|
+
<div class="analytics-section">
|
|
564
|
+
<h3><span class="icon">\u{1F464}</span> <span data-i18n="breakdown.role">By Role</span></h3>
|
|
565
|
+
<div id="breakdownRole"></div>
|
|
566
|
+
</div>
|
|
567
|
+
<div class="analytics-section">
|
|
568
|
+
<h3><span class="icon">\u{1F4DD}</span> <span data-i18n="breakdown.kind">By Kind</span></h3>
|
|
569
|
+
<div id="breakdownKind"></div>
|
|
570
|
+
</div>
|
|
571
|
+
</div>
|
|
572
|
+
</div>
|
|
316
573
|
</div>
|
|
317
574
|
</div>
|
|
318
575
|
|
|
319
576
|
<!-- ─── Memory Modal ─── -->
|
|
320
577
|
<div class="modal-overlay" id="modalOverlay">
|
|
321
578
|
<div class="modal">
|
|
322
|
-
<h2 id="modalTitle">New Memory</h2>
|
|
323
|
-
<div class="form-group"><label>Role</label><select id="mRole"><option value="user">User</option><option value="assistant">Assistant</option><option value="system">System</option></select></div>
|
|
324
|
-
<div class="form-group"><label>Content</label><textarea id="mContent" rows="4" placeholder="Memory content..."></textarea></div>
|
|
325
|
-
<div class="form-group"><label>Summary</label><input type="text" id="mSummary" placeholder="Brief summary (optional)"></div>
|
|
326
|
-
<div class="form-group"><label>Kind</label><select id="mKind"><option value="paragraph">Paragraph</option><option value="code">Code</option><option value="dialog">Dialog</option></select></div>
|
|
579
|
+
<h2 id="modalTitle" data-i18n="modal.new">New Memory</h2>
|
|
580
|
+
<div class="form-group"><label data-i18n="modal.role">Role</label><select id="mRole"><option value="user">User</option><option value="assistant">Assistant</option><option value="system">System</option></select></div>
|
|
581
|
+
<div class="form-group"><label data-i18n="modal.content">Content</label><textarea id="mContent" rows="4" data-i18n-ph="modal.content.ph" placeholder="Memory content..."></textarea></div>
|
|
582
|
+
<div class="form-group"><label data-i18n="modal.summary">Summary</label><input type="text" id="mSummary" data-i18n-ph="modal.summary.ph" placeholder="Brief summary (optional)"></div>
|
|
583
|
+
<div class="form-group"><label data-i18n="modal.kind">Kind</label><select id="mKind"><option value="paragraph" data-i18n="filter.paragraph">Paragraph</option><option value="code" data-i18n="filter.code">Code</option><option value="dialog" data-i18n="filter.dialog">Dialog</option></select></div>
|
|
327
584
|
<div class="modal-actions">
|
|
328
|
-
<button class="btn" onclick="closeModal()">Cancel</button>
|
|
329
|
-
<button class="btn btn-primary" id="modalSubmit" onclick="submitModal()">Create</button>
|
|
585
|
+
<button class="btn btn-ghost" onclick="closeModal()" data-i18n="modal.cancel">Cancel</button>
|
|
586
|
+
<button class="btn btn-primary" id="modalSubmit" onclick="submitModal()" data-i18n="modal.create">Create</button>
|
|
330
587
|
</div>
|
|
331
588
|
</div>
|
|
332
589
|
</div>
|
|
@@ -335,7 +592,276 @@ input,textarea,select{font-family:inherit;font-size:inherit}
|
|
|
335
592
|
<div class="toast-container" id="toasts"></div>
|
|
336
593
|
|
|
337
594
|
<script>
|
|
338
|
-
let activeSession=null,activeRole='',editingId=null,searchTimer=null,memoryCache={},currentPage=1,totalPages=1,totalCount=0,PAGE_SIZE=30;
|
|
595
|
+
let activeSession=null,activeRole='',editingId=null,searchTimer=null,memoryCache={},currentPage=1,totalPages=1,totalCount=0,PAGE_SIZE=30,metricsDays=30;
|
|
596
|
+
|
|
597
|
+
/* ─── i18n ─── */
|
|
598
|
+
const I18N={
|
|
599
|
+
en:{
|
|
600
|
+
'title':'OpenClaw Memory',
|
|
601
|
+
'subtitle':'Powered by MemOS',
|
|
602
|
+
'setup.desc':'Set a password to protect your memories',
|
|
603
|
+
'setup.pw':'Enter a password (4+ characters)',
|
|
604
|
+
'setup.pw2':'Confirm password',
|
|
605
|
+
'setup.btn':'Set Password & Enter',
|
|
606
|
+
'setup.err.short':'Password must be at least 4 characters',
|
|
607
|
+
'setup.err.mismatch':'Passwords do not match',
|
|
608
|
+
'setup.err.fail':'Setup failed',
|
|
609
|
+
'login.desc':'Enter your password to access memories',
|
|
610
|
+
'login.pw':'Password',
|
|
611
|
+
'login.btn':'Unlock',
|
|
612
|
+
'login.err':'Incorrect password',
|
|
613
|
+
'login.forgot':'Forgot password?',
|
|
614
|
+
'reset.step1.title':'Open Terminal',
|
|
615
|
+
'reset.step1.desc':'Run the following command to get your reset token (use the pattern below so you get the line that contains the token):',
|
|
616
|
+
'reset.step2.title':'Find the token',
|
|
617
|
+
'reset.step2.desc.pre':'In the output, find ',
|
|
618
|
+
'reset.step2.desc.post':' (plain line or inside JSON). Copy the 32-character hex string after the colon.',
|
|
619
|
+
'reset.step3.title':'Paste & reset',
|
|
620
|
+
'reset.step3.desc':'Paste the token below and set your new password.',
|
|
621
|
+
'reset.token':'Paste reset token here',
|
|
622
|
+
'reset.newpw':'New password (4+ characters)',
|
|
623
|
+
'reset.newpw2':'Confirm new password',
|
|
624
|
+
'reset.btn':'Reset Password',
|
|
625
|
+
'reset.err.token':'Please enter the reset token',
|
|
626
|
+
'reset.err.short':'Password must be at least 4 characters',
|
|
627
|
+
'reset.err.mismatch':'Passwords do not match',
|
|
628
|
+
'reset.err.fail':'Reset failed',
|
|
629
|
+
'reset.back':'\\u2190 Back to login',
|
|
630
|
+
'copy.hint':'Click to copy',
|
|
631
|
+
'copy.done':'Copied!',
|
|
632
|
+
'tab.memories':'\\u{1F4DA} Memories',
|
|
633
|
+
'tab.tasks':'\\u{1F4CB} Tasks',
|
|
634
|
+
'tab.analytics':'\\u{1F4CA} Analytics',
|
|
635
|
+
'tasks.total':'Total Tasks',
|
|
636
|
+
'tasks.active':'Active',
|
|
637
|
+
'tasks.completed':'Completed',
|
|
638
|
+
'tasks.status.active':'Active',
|
|
639
|
+
'tasks.status.completed':'Completed',
|
|
640
|
+
'tasks.status.skipped':'Skipped',
|
|
641
|
+
'tasks.empty':'No tasks yet. Tasks are automatically created as you converse.',
|
|
642
|
+
'tasks.loading':'Loading...',
|
|
643
|
+
'tasks.untitled':'Untitled Task',
|
|
644
|
+
'tasks.chunks':'Related Memories',
|
|
645
|
+
'tasks.nochunks':'No memories in this task yet.',
|
|
646
|
+
'tasks.skipped.default':'This conversation was too brief to generate a summary. It will not appear in search results.',
|
|
647
|
+
'refresh':'\\u21BB Refresh',
|
|
648
|
+
'logout':'Logout',
|
|
649
|
+
'stat.memories':'Memories',
|
|
650
|
+
'stat.sessions':'Sessions',
|
|
651
|
+
'stat.embeddings':'Embeddings',
|
|
652
|
+
'stat.days':'Days',
|
|
653
|
+
'sidebar.sessions':'Sessions',
|
|
654
|
+
'sidebar.allsessions':'All Sessions',
|
|
655
|
+
'sidebar.clear':'\\u{1F5D1} Clear All Data',
|
|
656
|
+
'search.placeholder':'Search memories (supports semantic search)...',
|
|
657
|
+
'search.meta.total':' memories total',
|
|
658
|
+
'search.meta.semantic':' semantic',
|
|
659
|
+
'search.meta.text':' text',
|
|
660
|
+
'search.meta.results':' results',
|
|
661
|
+
'filter.all':'All',
|
|
662
|
+
'filter.allkinds':'All kinds',
|
|
663
|
+
'filter.paragraph':'Paragraph',
|
|
664
|
+
'filter.code':'Code',
|
|
665
|
+
'filter.dialog':'Dialog',
|
|
666
|
+
'filter.list':'List',
|
|
667
|
+
'filter.error':'Error',
|
|
668
|
+
'filter.command':'Command',
|
|
669
|
+
'filter.newest':'Newest first',
|
|
670
|
+
'filter.oldest':'Oldest first',
|
|
671
|
+
'filter.from':'From',
|
|
672
|
+
'filter.to':'To',
|
|
673
|
+
'filter.clear':'Clear',
|
|
674
|
+
'empty.text':'No memories found',
|
|
675
|
+
'card.expand':'Expand',
|
|
676
|
+
'card.edit':'Edit',
|
|
677
|
+
'card.delete':'Delete',
|
|
678
|
+
'pagination.total':' total',
|
|
679
|
+
'range':'Range',
|
|
680
|
+
'range.days':'days',
|
|
681
|
+
'analytics.total':'Total Memories',
|
|
682
|
+
'analytics.writes':'Writes Today',
|
|
683
|
+
'analytics.calls':'Viewer Calls Today',
|
|
684
|
+
'analytics.sessions':'Sessions',
|
|
685
|
+
'analytics.embeddings':'Embeddings',
|
|
686
|
+
'chart.writes':'Memory Writes per Day',
|
|
687
|
+
'chart.calls':'Viewer API Calls per Day (List / Search)',
|
|
688
|
+
'chart.nodata':'No data in this range',
|
|
689
|
+
'chart.nocalls':'No viewer calls in this range',
|
|
690
|
+
'chart.list':'List',
|
|
691
|
+
'chart.search':'Search',
|
|
692
|
+
'breakdown.role':'By Role',
|
|
693
|
+
'breakdown.kind':'By Kind',
|
|
694
|
+
'modal.new':'New Memory',
|
|
695
|
+
'modal.edit':'Edit Memory',
|
|
696
|
+
'modal.role':'Role',
|
|
697
|
+
'modal.content':'Content',
|
|
698
|
+
'modal.content.ph':'Memory content...',
|
|
699
|
+
'modal.summary':'Summary',
|
|
700
|
+
'modal.summary.ph':'Brief summary (optional)',
|
|
701
|
+
'modal.kind':'Kind',
|
|
702
|
+
'modal.cancel':'Cancel',
|
|
703
|
+
'modal.create':'Create',
|
|
704
|
+
'modal.save':'Save',
|
|
705
|
+
'modal.err.empty':'Please enter content',
|
|
706
|
+
'toast.created':'Memory created',
|
|
707
|
+
'toast.updated':'Memory updated',
|
|
708
|
+
'toast.deleted':'Memory deleted',
|
|
709
|
+
'toast.opfail':'Operation failed',
|
|
710
|
+
'toast.delfail':'Delete failed',
|
|
711
|
+
'toast.cleared':'All memories cleared',
|
|
712
|
+
'toast.clearfail':'Clear failed',
|
|
713
|
+
'toast.notfound':'Memory not found in cache',
|
|
714
|
+
'confirm.delete':'Delete this memory?',
|
|
715
|
+
'confirm.clearall':'Delete ALL memories? This cannot be undone.',
|
|
716
|
+
'confirm.clearall2':'Are you absolutely sure?',
|
|
717
|
+
'embed.on':'Embedding: ',
|
|
718
|
+
'embed.off':'No embedding model',
|
|
719
|
+
'lang.switch':'中'
|
|
720
|
+
},
|
|
721
|
+
zh:{
|
|
722
|
+
'title':'OpenClaw 记忆',
|
|
723
|
+
'subtitle':'由 MemOS 驱动',
|
|
724
|
+
'setup.desc':'设置密码以保护你的记忆数据',
|
|
725
|
+
'setup.pw':'输入密码(至少4位)',
|
|
726
|
+
'setup.pw2':'确认密码',
|
|
727
|
+
'setup.btn':'设置密码并进入',
|
|
728
|
+
'setup.err.short':'密码至少需要4个字符',
|
|
729
|
+
'setup.err.mismatch':'两次密码不一致',
|
|
730
|
+
'setup.err.fail':'设置失败',
|
|
731
|
+
'login.desc':'输入密码以访问记忆',
|
|
732
|
+
'login.pw':'密码',
|
|
733
|
+
'login.btn':'解锁',
|
|
734
|
+
'login.err':'密码错误',
|
|
735
|
+
'login.forgot':'忘记密码?',
|
|
736
|
+
'reset.step1.title':'打开终端',
|
|
737
|
+
'reset.step1.desc':'运行以下命令获取重置令牌:',
|
|
738
|
+
'reset.step2.title':'找到令牌',
|
|
739
|
+
'reset.step2.desc.pre':'在输出中找到 ',
|
|
740
|
+
'reset.step2.desc.post':'(纯文本行或 JSON 内)。复制冒号后的32位十六进制字符串。',
|
|
741
|
+
'reset.step3.title':'粘贴并重置',
|
|
742
|
+
'reset.step3.desc':'将令牌粘贴到下方并设置新密码。',
|
|
743
|
+
'reset.token':'在此粘贴重置令牌',
|
|
744
|
+
'reset.newpw':'新密码(至少4位)',
|
|
745
|
+
'reset.newpw2':'确认新密码',
|
|
746
|
+
'reset.btn':'重置密码',
|
|
747
|
+
'reset.err.token':'请输入重置令牌',
|
|
748
|
+
'reset.err.short':'密码至少需要4个字符',
|
|
749
|
+
'reset.err.mismatch':'两次密码不一致',
|
|
750
|
+
'reset.err.fail':'重置失败',
|
|
751
|
+
'reset.back':'\\u2190 返回登录',
|
|
752
|
+
'copy.hint':'点击复制',
|
|
753
|
+
'copy.done':'已复制!',
|
|
754
|
+
'tab.memories':'\\u{1F4DA} 记忆',
|
|
755
|
+
'tab.tasks':'\\u{1F4CB} 任务',
|
|
756
|
+
'tab.analytics':'\\u{1F4CA} 分析',
|
|
757
|
+
'tasks.total':'任务总数',
|
|
758
|
+
'tasks.active':'进行中',
|
|
759
|
+
'tasks.completed':'已完成',
|
|
760
|
+
'tasks.status.active':'进行中',
|
|
761
|
+
'tasks.status.completed':'已完成',
|
|
762
|
+
'tasks.status.skipped':'已跳过',
|
|
763
|
+
'tasks.empty':'暂无任务。任务会随着对话自动创建。',
|
|
764
|
+
'tasks.loading':'加载中...',
|
|
765
|
+
'tasks.untitled':'未命名任务',
|
|
766
|
+
'tasks.chunks':'关联记忆',
|
|
767
|
+
'tasks.nochunks':'此任务暂无关联记忆。',
|
|
768
|
+
'tasks.skipped.default':'对话内容过少,未生成摘要。该任务不会出现在检索结果中。',
|
|
769
|
+
'refresh':'\\u21BB 刷新',
|
|
770
|
+
'logout':'退出',
|
|
771
|
+
'stat.memories':'记忆',
|
|
772
|
+
'stat.sessions':'会话',
|
|
773
|
+
'stat.embeddings':'嵌入',
|
|
774
|
+
'stat.days':'天数',
|
|
775
|
+
'sidebar.sessions':'会话列表',
|
|
776
|
+
'sidebar.allsessions':'全部会话',
|
|
777
|
+
'sidebar.clear':'\\u{1F5D1} 清除所有数据',
|
|
778
|
+
'search.placeholder':'搜索记忆(支持语义搜索)...',
|
|
779
|
+
'search.meta.total':' 条记忆',
|
|
780
|
+
'search.meta.semantic':' 语义',
|
|
781
|
+
'search.meta.text':' 文本',
|
|
782
|
+
'search.meta.results':' 条结果',
|
|
783
|
+
'filter.all':'全部',
|
|
784
|
+
'filter.allkinds':'所有类型',
|
|
785
|
+
'filter.paragraph':'段落',
|
|
786
|
+
'filter.code':'代码',
|
|
787
|
+
'filter.dialog':'对话',
|
|
788
|
+
'filter.list':'列表',
|
|
789
|
+
'filter.error':'错误',
|
|
790
|
+
'filter.command':'命令',
|
|
791
|
+
'filter.newest':'最新优先',
|
|
792
|
+
'filter.oldest':'最早优先',
|
|
793
|
+
'filter.from':'起始',
|
|
794
|
+
'filter.to':'截止',
|
|
795
|
+
'filter.clear':'清除',
|
|
796
|
+
'empty.text':'暂无记忆',
|
|
797
|
+
'card.expand':'展开',
|
|
798
|
+
'card.edit':'编辑',
|
|
799
|
+
'card.delete':'删除',
|
|
800
|
+
'pagination.total':' 条',
|
|
801
|
+
'range':'范围',
|
|
802
|
+
'range.days':'天',
|
|
803
|
+
'analytics.total':'总记忆数',
|
|
804
|
+
'analytics.writes':'今日写入',
|
|
805
|
+
'analytics.calls':'今日查看器调用',
|
|
806
|
+
'analytics.sessions':'会话数',
|
|
807
|
+
'analytics.embeddings':'嵌入数',
|
|
808
|
+
'chart.writes':'每日记忆写入',
|
|
809
|
+
'chart.calls':'每日查看器 API 调用(列表 / 搜索)',
|
|
810
|
+
'chart.nodata':'此范围内暂无数据',
|
|
811
|
+
'chart.nocalls':'此范围内暂无查看器调用',
|
|
812
|
+
'chart.list':'列表',
|
|
813
|
+
'chart.search':'搜索',
|
|
814
|
+
'breakdown.role':'按角色',
|
|
815
|
+
'breakdown.kind':'按类型',
|
|
816
|
+
'modal.new':'新建记忆',
|
|
817
|
+
'modal.edit':'编辑记忆',
|
|
818
|
+
'modal.role':'角色',
|
|
819
|
+
'modal.content':'内容',
|
|
820
|
+
'modal.content.ph':'记忆内容...',
|
|
821
|
+
'modal.summary':'摘要',
|
|
822
|
+
'modal.summary.ph':'简要摘要(可选)',
|
|
823
|
+
'modal.kind':'类型',
|
|
824
|
+
'modal.cancel':'取消',
|
|
825
|
+
'modal.create':'创建',
|
|
826
|
+
'modal.save':'保存',
|
|
827
|
+
'modal.err.empty':'请输入内容',
|
|
828
|
+
'toast.created':'记忆已创建',
|
|
829
|
+
'toast.updated':'记忆已更新',
|
|
830
|
+
'toast.deleted':'记忆已删除',
|
|
831
|
+
'toast.opfail':'操作失败',
|
|
832
|
+
'toast.delfail':'删除失败',
|
|
833
|
+
'toast.cleared':'所有记忆已清除',
|
|
834
|
+
'toast.clearfail':'清除失败',
|
|
835
|
+
'toast.notfound':'缓存中未找到此记忆',
|
|
836
|
+
'confirm.delete':'确定要删除这条记忆吗?',
|
|
837
|
+
'confirm.clearall':'确定要删除所有记忆?此操作不可撤销。',
|
|
838
|
+
'confirm.clearall2':'你真的确定吗?',
|
|
839
|
+
'embed.on':'嵌入模型:',
|
|
840
|
+
'embed.off':'无嵌入模型',
|
|
841
|
+
'lang.switch':'EN'
|
|
842
|
+
}
|
|
843
|
+
};
|
|
844
|
+
const LANG_KEY='memos-viewer-lang';
|
|
845
|
+
let curLang=localStorage.getItem(LANG_KEY)||(navigator.language.startsWith('zh')?'zh':'en');
|
|
846
|
+
function t(key){return (I18N[curLang]||I18N.en)[key]||key;}
|
|
847
|
+
function setLang(lang){curLang=lang;localStorage.setItem(LANG_KEY,lang);applyI18n();}
|
|
848
|
+
function toggleLang(){setLang(curLang==='zh'?'en':'zh');}
|
|
849
|
+
|
|
850
|
+
function applyI18n(){
|
|
851
|
+
document.querySelectorAll('[data-i18n]').forEach(el=>{
|
|
852
|
+
const key=el.getAttribute('data-i18n');
|
|
853
|
+
if(key) el.textContent=t(key);
|
|
854
|
+
});
|
|
855
|
+
document.querySelectorAll('[data-i18n-ph]').forEach(el=>{
|
|
856
|
+
const key=el.getAttribute('data-i18n-ph');
|
|
857
|
+
if(key) el.placeholder=t(key);
|
|
858
|
+
});
|
|
859
|
+
const step2=document.getElementById('resetStep2Desc');
|
|
860
|
+
if(step2) step2.innerHTML=t('reset.step2.desc.pre')+'<span style="font-family:monospace;font-size:12px;color:var(--pri)">password reset token: <strong>a1b2c3d4e5f6...</strong></span>'+t('reset.step2.desc.post');
|
|
861
|
+
document.title=t('title')+' - MemOS';
|
|
862
|
+
if(typeof loadStats==='function' && document.getElementById('app').style.display==='flex'){loadStats();}
|
|
863
|
+
if(document.querySelector('.analytics-view.show') && typeof loadMetrics==='function'){loadMetrics();}
|
|
864
|
+
}
|
|
339
865
|
|
|
340
866
|
/* ─── Auth flow ─── */
|
|
341
867
|
async function checkAuth(){
|
|
@@ -357,12 +883,12 @@ async function doSetup(){
|
|
|
357
883
|
const pw=document.getElementById('setupPw').value;
|
|
358
884
|
const pw2=document.getElementById('setupPw2').value;
|
|
359
885
|
const err=document.getElementById('setupErr');
|
|
360
|
-
if(pw.length<4){err.textContent='
|
|
361
|
-
if(pw!==pw2){err.textContent='
|
|
886
|
+
if(pw.length<4){err.textContent=t('setup.err.short');return}
|
|
887
|
+
if(pw!==pw2){err.textContent=t('setup.err.mismatch');return}
|
|
362
888
|
const r=await fetch('/api/auth/setup',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({password:pw})});
|
|
363
889
|
const d=await r.json();
|
|
364
890
|
if(d.ok){document.getElementById('setupScreen').style.display='none';enterApp();}
|
|
365
|
-
else{err.textContent=d.error||'
|
|
891
|
+
else{err.textContent=d.error||t('setup.err.fail')}
|
|
366
892
|
}
|
|
367
893
|
|
|
368
894
|
async function doLogin(){
|
|
@@ -371,7 +897,7 @@ async function doLogin(){
|
|
|
371
897
|
const r=await fetch('/api/auth/login',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({password:pw})});
|
|
372
898
|
const d=await r.json();
|
|
373
899
|
if(d.ok){document.getElementById('loginScreen').style.display='none';enterApp();}
|
|
374
|
-
else{err.textContent='
|
|
900
|
+
else{err.textContent=t('login.err');document.getElementById('loginPw').value='';document.getElementById('loginPw').focus();}
|
|
375
901
|
}
|
|
376
902
|
|
|
377
903
|
async function doLogout(){
|
|
@@ -395,8 +921,8 @@ function copyCmd(el){
|
|
|
395
921
|
const code=el.querySelector('code').textContent;
|
|
396
922
|
navigator.clipboard.writeText(code).then(()=>{
|
|
397
923
|
el.classList.add('copied');
|
|
398
|
-
el.querySelector('.copy-hint').textContent='
|
|
399
|
-
setTimeout(()=>{el.classList.remove('copied');el.querySelector('.copy-hint').textContent='
|
|
924
|
+
el.querySelector('.copy-hint').textContent=t('copy.done');
|
|
925
|
+
setTimeout(()=>{el.classList.remove('copied');el.querySelector('.copy-hint').textContent=t('copy.hint')},2000);
|
|
400
926
|
});
|
|
401
927
|
}
|
|
402
928
|
|
|
@@ -405,13 +931,13 @@ async function doReset(){
|
|
|
405
931
|
const pw=document.getElementById('resetNewPw').value;
|
|
406
932
|
const pw2=document.getElementById('resetNewPw2').value;
|
|
407
933
|
const err=document.getElementById('resetErr');
|
|
408
|
-
if(!token){err.textContent='
|
|
409
|
-
if(pw.length<4){err.textContent='
|
|
410
|
-
if(pw!==pw2){err.textContent='
|
|
934
|
+
if(!token){err.textContent=t('reset.err.token');return}
|
|
935
|
+
if(pw.length<4){err.textContent=t('reset.err.short');return}
|
|
936
|
+
if(pw!==pw2){err.textContent=t('reset.err.mismatch');return}
|
|
411
937
|
const r=await fetch('/api/auth/reset',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({token,newPassword:pw})});
|
|
412
938
|
const d=await r.json();
|
|
413
939
|
if(d.ok){document.getElementById('loginScreen').style.display='none';enterApp();}
|
|
414
|
-
else{err.textContent=d.error||'
|
|
940
|
+
else{err.textContent=d.error||t('reset.err.fail')}
|
|
415
941
|
}
|
|
416
942
|
|
|
417
943
|
function enterApp(){
|
|
@@ -419,6 +945,281 @@ function enterApp(){
|
|
|
419
945
|
loadAll();
|
|
420
946
|
}
|
|
421
947
|
|
|
948
|
+
function switchView(view){
|
|
949
|
+
document.querySelectorAll('.nav-tabs .tab').forEach(t=>t.classList.toggle('active',t.dataset.view===view));
|
|
950
|
+
const feedWrap=document.getElementById('feedWrap');
|
|
951
|
+
const analyticsView=document.getElementById('analyticsView');
|
|
952
|
+
const tasksView=document.getElementById('tasksView');
|
|
953
|
+
feedWrap.classList.add('hide');
|
|
954
|
+
analyticsView.classList.remove('show');
|
|
955
|
+
tasksView.classList.remove('show');
|
|
956
|
+
if(view==='analytics'){
|
|
957
|
+
analyticsView.classList.add('show');
|
|
958
|
+
loadMetrics();
|
|
959
|
+
} else if(view==='tasks'){
|
|
960
|
+
tasksView.classList.add('show');
|
|
961
|
+
loadTasks();
|
|
962
|
+
} else {
|
|
963
|
+
feedWrap.classList.remove('hide');
|
|
964
|
+
}
|
|
965
|
+
}
|
|
966
|
+
|
|
967
|
+
function setMetricsDays(d){
|
|
968
|
+
metricsDays=d;
|
|
969
|
+
document.querySelectorAll('.metrics-toolbar .range-btn').forEach(btn=>btn.classList.toggle('active',Number(btn.dataset.days)===d));
|
|
970
|
+
loadMetrics();
|
|
971
|
+
}
|
|
972
|
+
|
|
973
|
+
async function loadMetrics(){
|
|
974
|
+
const r=await fetch('/api/metrics?days='+metricsDays);
|
|
975
|
+
const d=await r.json();
|
|
976
|
+
document.getElementById('mTotal').textContent=formatNum(d.totals.memories);
|
|
977
|
+
document.getElementById('mTodayWrites').textContent=formatNum(d.totals.todayWrites);
|
|
978
|
+
document.getElementById('mTodayCalls').textContent=formatNum(d.totals.todayViewerCalls);
|
|
979
|
+
document.getElementById('mSessions').textContent=formatNum(d.totals.sessions);
|
|
980
|
+
document.getElementById('mEmbeddings').textContent=formatNum(d.totals.embeddings);
|
|
981
|
+
renderChartWrites(d.writesPerDay);
|
|
982
|
+
renderChartCalls(d.viewerCallsPerDay);
|
|
983
|
+
renderBreakdown(d.roleBreakdown,'breakdownRole');
|
|
984
|
+
renderBreakdown(d.kindBreakdown,'breakdownKind');
|
|
985
|
+
}
|
|
986
|
+
|
|
987
|
+
function formatNum(n){return n>=1e6?(n/1e6).toFixed(1)+'M':n>=1e3?(n/1e3).toFixed(1)+'k':String(n);}
|
|
988
|
+
|
|
989
|
+
/* ─── Tasks View Logic ─── */
|
|
990
|
+
let tasksStatusFilter='';
|
|
991
|
+
let tasksPage=0;
|
|
992
|
+
const TASKS_PER_PAGE=20;
|
|
993
|
+
|
|
994
|
+
function setTaskStatusFilter(btn,status){
|
|
995
|
+
document.querySelectorAll('.tasks-filters .filter-chip').forEach(c=>c.classList.remove('active'));
|
|
996
|
+
btn.classList.add('active');
|
|
997
|
+
tasksStatusFilter=status;
|
|
998
|
+
tasksPage=0;
|
|
999
|
+
loadTasks();
|
|
1000
|
+
}
|
|
1001
|
+
|
|
1002
|
+
async function loadTasks(){
|
|
1003
|
+
const list=document.getElementById('tasksList');
|
|
1004
|
+
list.innerHTML='<div class="spinner"></div>';
|
|
1005
|
+
try{
|
|
1006
|
+
const params=new URLSearchParams({limit:String(TASKS_PER_PAGE),offset:String(tasksPage*TASKS_PER_PAGE)});
|
|
1007
|
+
if(tasksStatusFilter) params.set('status',tasksStatusFilter);
|
|
1008
|
+
const r=await fetch('/api/tasks?'+params);
|
|
1009
|
+
const data=await r.json();
|
|
1010
|
+
|
|
1011
|
+
// stats
|
|
1012
|
+
const allR=await fetch('/api/tasks?limit=1&offset=0');
|
|
1013
|
+
const allD=await allR.json();
|
|
1014
|
+
document.getElementById('tasksTotalCount').textContent=formatNum(allD.total);
|
|
1015
|
+
|
|
1016
|
+
const activeR=await fetch('/api/tasks?status=active&limit=1&offset=0');
|
|
1017
|
+
const activeD=await activeR.json();
|
|
1018
|
+
document.getElementById('tasksActiveCount').textContent=formatNum(activeD.total);
|
|
1019
|
+
|
|
1020
|
+
const compR=await fetch('/api/tasks?status=completed&limit=1&offset=0');
|
|
1021
|
+
const compD=await compR.json();
|
|
1022
|
+
document.getElementById('tasksCompletedCount').textContent=formatNum(compD.total);
|
|
1023
|
+
|
|
1024
|
+
const skipR=await fetch('/api/tasks?status=skipped&limit=1&offset=0');
|
|
1025
|
+
const skipD=await skipR.json();
|
|
1026
|
+
document.getElementById('tasksSkippedCount').textContent=formatNum(skipD.total);
|
|
1027
|
+
|
|
1028
|
+
if(!data.tasks||data.tasks.length===0){
|
|
1029
|
+
list.innerHTML='<div style="text-align:center;padding:48px;color:var(--text-muted);font-size:14px" data-i18n="tasks.empty">'+t('tasks.empty')+'</div>';
|
|
1030
|
+
document.getElementById('tasksPagination').innerHTML='';
|
|
1031
|
+
return;
|
|
1032
|
+
}
|
|
1033
|
+
|
|
1034
|
+
list.innerHTML=data.tasks.map(task=>{
|
|
1035
|
+
const timeStr=formatTime(task.startedAt);
|
|
1036
|
+
const endStr=task.endedAt?formatTime(task.endedAt):'';
|
|
1037
|
+
const durationStr=task.endedAt?formatDuration(task.endedAt-task.startedAt):'';
|
|
1038
|
+
return '<div class="task-card status-'+task.status+'" onclick="openTaskDetail(\\''+task.id+'\\')">'+
|
|
1039
|
+
'<div class="task-card-top">'+
|
|
1040
|
+
'<div class="task-card-title">'+esc(task.title)+'</div>'+
|
|
1041
|
+
'<span class="task-status-badge '+task.status+'">'+task.status+'</span>'+
|
|
1042
|
+
'</div>'+
|
|
1043
|
+
(task.summary?'<div class="task-card-summary">'+esc(task.summary)+'</div>':'')+
|
|
1044
|
+
'<div class="task-card-bottom">'+
|
|
1045
|
+
'<span class="tag"><span class="icon">\\u{1F4C5}</span> '+timeStr+'</span>'+
|
|
1046
|
+
(durationStr?'<span class="tag"><span class="icon">\\u23F1</span> '+durationStr+'</span>':'')+
|
|
1047
|
+
'<span class="tag"><span class="icon">\\u{1F4DD}</span> '+task.chunkCount+' '+(task.chunkCount===1?'chunk':'chunks')+'</span>'+
|
|
1048
|
+
'<span class="tag"><span class="icon">\\u{1F4C2}</span> '+task.sessionKey.slice(0,12)+'</span>'+
|
|
1049
|
+
'</div>'+
|
|
1050
|
+
'</div>';
|
|
1051
|
+
}).join('');
|
|
1052
|
+
|
|
1053
|
+
renderTasksPagination(data.total);
|
|
1054
|
+
}catch(e){
|
|
1055
|
+
list.innerHTML='<div style="text-align:center;padding:24px;color:var(--rose)">Failed to load tasks</div>';
|
|
1056
|
+
}
|
|
1057
|
+
}
|
|
1058
|
+
|
|
1059
|
+
function renderTasksPagination(total){
|
|
1060
|
+
const el=document.getElementById('tasksPagination');
|
|
1061
|
+
const pages=Math.ceil(total/TASKS_PER_PAGE);
|
|
1062
|
+
if(pages<=1){el.innerHTML='';return;}
|
|
1063
|
+
let html='<button class="pg-btn'+(tasksPage===0?' disabled':'')+'" onclick="tasksPage=Math.max(0,tasksPage-1);loadTasks()">\\u2190</button>';
|
|
1064
|
+
const start=Math.max(0,tasksPage-2),end=Math.min(pages,tasksPage+3);
|
|
1065
|
+
for(let i=start;i<end;i++){
|
|
1066
|
+
html+='<button class="pg-btn'+(i===tasksPage?' active':'')+'" onclick="tasksPage='+i+';loadTasks()">'+(i+1)+'</button>';
|
|
1067
|
+
}
|
|
1068
|
+
html+='<button class="pg-btn'+(tasksPage>=pages-1?' disabled':'')+'" onclick="tasksPage=Math.min('+(pages-1)+',tasksPage+1);loadTasks()">\\u2192</button>';
|
|
1069
|
+
html+='<span class="pg-info">'+total+' '+t('pagination.total')+'</span>';
|
|
1070
|
+
el.innerHTML=html;
|
|
1071
|
+
}
|
|
1072
|
+
|
|
1073
|
+
async function openTaskDetail(taskId){
|
|
1074
|
+
const overlay=document.getElementById('taskDetailOverlay');
|
|
1075
|
+
overlay.classList.add('show');
|
|
1076
|
+
document.getElementById('taskDetailTitle').textContent=t('tasks.loading');
|
|
1077
|
+
document.getElementById('taskDetailMeta').innerHTML='';
|
|
1078
|
+
document.getElementById('taskDetailSummary').textContent='';
|
|
1079
|
+
document.getElementById('taskDetailChunks').innerHTML='<div class="spinner"></div>';
|
|
1080
|
+
|
|
1081
|
+
try{
|
|
1082
|
+
const r=await fetch('/api/task/'+taskId);
|
|
1083
|
+
const task=await r.json();
|
|
1084
|
+
|
|
1085
|
+
document.getElementById('taskDetailTitle').textContent=task.title||t('tasks.untitled');
|
|
1086
|
+
|
|
1087
|
+
const meta=[
|
|
1088
|
+
'<span class="meta-item"><span class="task-status-badge '+task.status+'">'+task.status+'</span></span>',
|
|
1089
|
+
'<span class="meta-item">\\u{1F4C5} '+formatTime(task.startedAt)+'</span>',
|
|
1090
|
+
];
|
|
1091
|
+
if(task.endedAt) meta.push('<span class="meta-item">\\u2192 '+formatTime(task.endedAt)+'</span>');
|
|
1092
|
+
meta.push('<span class="meta-item">\\u{1F4C2} '+task.sessionKey+'</span>');
|
|
1093
|
+
meta.push('<span class="meta-item">\\u{1F4DD} '+task.chunks.length+' chunks</span>');
|
|
1094
|
+
document.getElementById('taskDetailMeta').innerHTML=meta.join('');
|
|
1095
|
+
|
|
1096
|
+
var summaryEl=document.getElementById('taskDetailSummary');
|
|
1097
|
+
if(task.status==='skipped'){
|
|
1098
|
+
summaryEl.innerHTML='<div style="color:var(--text-muted);font-style:italic;display:flex;align-items:flex-start;gap:8px"><span style="font-size:18px">\\u26A0\\uFE0F</span><span>'+esc(task.summary||t('tasks.skipped.default'))+'</span></div>';
|
|
1099
|
+
}else{
|
|
1100
|
+
summaryEl.innerHTML=renderSummaryHtml(task.summary);
|
|
1101
|
+
}
|
|
1102
|
+
|
|
1103
|
+
if(task.chunks.length===0){
|
|
1104
|
+
document.getElementById('taskDetailChunks').innerHTML='<div style="color:var(--text-muted);padding:12px;font-size:13px">'+t('tasks.nochunks')+'</div>';
|
|
1105
|
+
}else{
|
|
1106
|
+
document.getElementById('taskDetailChunks').innerHTML=task.chunks.map(c=>{
|
|
1107
|
+
var roleLabel=c.role==='user'?'You':c.role==='assistant'?'Assistant':c.role.toUpperCase();
|
|
1108
|
+
return '<div class="task-chunk-item role-'+c.role+'">'+
|
|
1109
|
+
'<div class="task-chunk-role '+c.role+'">'+roleLabel+'</div>'+
|
|
1110
|
+
'<div class="task-chunk-bubble" onclick="this.classList.toggle(\\\'expanded\\\')">'+esc(c.content)+'</div>'+
|
|
1111
|
+
'<div class="task-chunk-time">'+formatTime(c.createdAt)+'</div>'+
|
|
1112
|
+
'</div>';
|
|
1113
|
+
}).join('');
|
|
1114
|
+
}
|
|
1115
|
+
}catch(e){
|
|
1116
|
+
document.getElementById('taskDetailTitle').textContent='Error';
|
|
1117
|
+
document.getElementById('taskDetailChunks').innerHTML='<div style="color:var(--rose)">Failed to load task details</div>';
|
|
1118
|
+
}
|
|
1119
|
+
}
|
|
1120
|
+
|
|
1121
|
+
function closeTaskDetail(event){
|
|
1122
|
+
if(event && event.target!==document.getElementById('taskDetailOverlay')) return;
|
|
1123
|
+
document.getElementById('taskDetailOverlay').classList.remove('show');
|
|
1124
|
+
}
|
|
1125
|
+
|
|
1126
|
+
function formatDuration(ms){
|
|
1127
|
+
const s=Math.floor(ms/1000);
|
|
1128
|
+
if(s<60) return s+'s';
|
|
1129
|
+
const m=Math.floor(s/60);
|
|
1130
|
+
if(m<60) return m+'min';
|
|
1131
|
+
const h=Math.floor(m/60);
|
|
1132
|
+
if(h<24) return h+'h '+((m%60)>0?(m%60)+'min':'');
|
|
1133
|
+
const d=Math.floor(h/24);
|
|
1134
|
+
return d+'d '+((h%24)>0?(h%24)+'h':'');
|
|
1135
|
+
}
|
|
1136
|
+
|
|
1137
|
+
function formatTime(ts){
|
|
1138
|
+
if(!ts) return '-';
|
|
1139
|
+
return new Date(ts).toLocaleString('zh-CN',{month:'2-digit',day:'2-digit',hour:'2-digit',minute:'2-digit'});
|
|
1140
|
+
}
|
|
1141
|
+
|
|
1142
|
+
function fillDays(rows,days){
|
|
1143
|
+
const map=new Map((rows||[]).map(r=>[r.date,{...r}]));
|
|
1144
|
+
const out=[];const now=new Date();
|
|
1145
|
+
for(let i=days-1;i>=0;i--){
|
|
1146
|
+
const d=new Date(now);d.setDate(d.getDate()-i);
|
|
1147
|
+
const dateStr=d.toISOString().slice(0,10);
|
|
1148
|
+
const row=map.get(dateStr)||{};
|
|
1149
|
+
out.push({date:dateStr,count:row.count??0,list:row.list??0,search:row.search??0,total:(row.list??0)+(row.search??0)});
|
|
1150
|
+
}
|
|
1151
|
+
if(days>21){
|
|
1152
|
+
const weeks=[];let i=0;
|
|
1153
|
+
while(i<out.length){
|
|
1154
|
+
const chunk=out.slice(i,i+7);
|
|
1155
|
+
const first=chunk[0].date,last=chunk[chunk.length-1].date;
|
|
1156
|
+
const c=chunk.reduce((s,r)=>s+r.count,0);
|
|
1157
|
+
const l=chunk.reduce((s,r)=>s+r.list,0);
|
|
1158
|
+
const se=chunk.reduce((s,r)=>s+r.search,0);
|
|
1159
|
+
const label=first.slice(5,10)+'~'+last.slice(8,10);
|
|
1160
|
+
weeks.push({date:label,count:c,list:l,search:se,total:l+se});
|
|
1161
|
+
i+=7;
|
|
1162
|
+
}
|
|
1163
|
+
return weeks;
|
|
1164
|
+
}
|
|
1165
|
+
return out;
|
|
1166
|
+
}
|
|
1167
|
+
|
|
1168
|
+
function renderBars(el,data,valueKey,H){
|
|
1169
|
+
const vals=data.map(d=>d[valueKey]??0);
|
|
1170
|
+
if(vals.every(v=>v===0)){el.innerHTML='<div style="color:var(--text-muted);font-size:13px;padding:20px;text-align:center">'+t('chart.nodata')+'</div>';return;}
|
|
1171
|
+
const max=Math.max(1,...vals);
|
|
1172
|
+
el.innerHTML=data.map(r=>{
|
|
1173
|
+
const v=r[valueKey]??0;
|
|
1174
|
+
const label=r.date.includes('~')?r.date:(r.date.length>5?r.date.slice(5):r.date);
|
|
1175
|
+
if(v===0){
|
|
1176
|
+
return '<div class="chart-bar-wrap"><div class="chart-tip">0</div><div class="chart-bar-col"><div class="chart-bar zero" style="height:2px"></div></div><div class="chart-bar-label">'+label+'</div></div>';
|
|
1177
|
+
}
|
|
1178
|
+
const h=Math.max(8,Math.round((v/max)*H));
|
|
1179
|
+
return '<div class="chart-bar-wrap"><div class="chart-tip">'+v+'</div><div class="chart-bar-col"><div class="chart-bar" style="height:'+h+'px"></div></div><div class="chart-bar-label">'+label+'</div></div>';
|
|
1180
|
+
}).join('');
|
|
1181
|
+
}
|
|
1182
|
+
|
|
1183
|
+
function renderChartWrites(rows){
|
|
1184
|
+
const el=document.getElementById('chartWrites');
|
|
1185
|
+
const filled=fillDays(rows?.map(r=>({date:r.date,count:r.count})),metricsDays);
|
|
1186
|
+
renderBars(el,filled,'count',160);
|
|
1187
|
+
}
|
|
1188
|
+
|
|
1189
|
+
function renderChartCalls(rows){
|
|
1190
|
+
const el=document.getElementById('chartCalls');
|
|
1191
|
+
const filled=fillDays(rows?.map(r=>({date:r.date,list:r.list,search:r.search})),metricsDays);
|
|
1192
|
+
const vals=filled.map(f=>f.total);
|
|
1193
|
+
if(vals.every(v=>v===0)){el.innerHTML='<div style="color:var(--text-muted);font-size:13px;padding:20px;text-align:center">'+t('chart.nocalls')+'</div>';return;}
|
|
1194
|
+
const max=Math.max(1,...vals);
|
|
1195
|
+
const H=160;
|
|
1196
|
+
el.innerHTML=filled.map(r=>{
|
|
1197
|
+
const label=r.date.includes('~')?r.date:(r.date.length>5?r.date.slice(5):r.date);
|
|
1198
|
+
if(r.total===0){
|
|
1199
|
+
return '<div class="chart-bar-wrap"><div class="chart-tip">0</div><div class="chart-bar-col"><div class="chart-bar zero" style="height:2px"></div></div><div class="chart-bar-label">'+label+'</div></div>';
|
|
1200
|
+
}
|
|
1201
|
+
const totalH=Math.max(8,Math.round((r.total/max)*H));
|
|
1202
|
+
const listH=r.list?Math.max(3,Math.round((r.list/r.total)*totalH)):0;
|
|
1203
|
+
const searchH=r.search?totalH-listH:0;
|
|
1204
|
+
const tip='List: '+r.list+', Search: '+r.search;
|
|
1205
|
+
let bars='';
|
|
1206
|
+
if(searchH>0) bars+='<div class="chart-bar violet" style="height:'+searchH+'px"></div>';
|
|
1207
|
+
if(listH>0) bars+='<div class="chart-bar" style="height:'+listH+'px"></div>';
|
|
1208
|
+
return '<div class="chart-bar-wrap"><div class="chart-tip">'+tip+'</div><div class="chart-bar-col"><div style="display:flex;flex-direction:column;gap:1px">'+bars+'</div></div><div class="chart-bar-label">'+label+'</div></div>';
|
|
1209
|
+
}).join('');
|
|
1210
|
+
}
|
|
1211
|
+
|
|
1212
|
+
function renderBreakdown(obj,containerId){
|
|
1213
|
+
const el=document.getElementById(containerId);
|
|
1214
|
+
if(!el)return;
|
|
1215
|
+
const entries=Object.entries(obj||{}).sort((a,b)=>b[1]-a[1]);
|
|
1216
|
+
const total=entries.reduce((s,[,v])=>s+v,0)||1;
|
|
1217
|
+
el.innerHTML=entries.map(([label,value])=>{
|
|
1218
|
+
const pct=Math.round((value/total)*100);
|
|
1219
|
+
return '<div class="breakdown-item"><div class="bd-top"><span class="label">'+esc(label)+'</span><span class="value">'+value+' <span style="font-size:11px;font-weight:500;color:var(--text-muted)">('+pct+'%)</span></span></div><div class="breakdown-bar-wrap"><div class="breakdown-bar" style="width:'+pct+'%"></div></div></div>';
|
|
1220
|
+
}).join('');
|
|
1221
|
+
}
|
|
1222
|
+
|
|
422
1223
|
/* ─── Data loading ─── */
|
|
423
1224
|
async function loadAll(){
|
|
424
1225
|
await Promise.all([loadStats(),loadMemories()]);
|
|
@@ -435,13 +1236,13 @@ async function loadStats(){
|
|
|
435
1236
|
|
|
436
1237
|
const provEl=document.getElementById('embeddingStatus');
|
|
437
1238
|
if(d.embeddingProvider && d.embeddingProvider!=='none'){
|
|
438
|
-
provEl.innerHTML='<div class="provider-badge"><span>\\u2713</span>
|
|
1239
|
+
provEl.innerHTML='<div class="provider-badge"><span>\\u2713</span> '+t('embed.on')+d.embeddingProvider+'</div>';
|
|
439
1240
|
} else {
|
|
440
|
-
provEl.innerHTML='<div class="provider-badge offline"><span>\\u26A0</span>
|
|
1241
|
+
provEl.innerHTML='<div class="provider-badge offline"><span>\\u26A0</span> '+t('embed.off')+'</div>';
|
|
441
1242
|
}
|
|
442
1243
|
|
|
443
1244
|
const sl=document.getElementById('sessionList');
|
|
444
|
-
sl.innerHTML='<div class="session-item'+(activeSession===null?' active':'')+'" onclick="filterSession(null)"><span>
|
|
1245
|
+
sl.innerHTML='<div class="session-item'+(activeSession===null?' active':'')+'" onclick="filterSession(null)"><span>'+t('sidebar.allsessions')+'</span><span class="count">'+d.totalMemories+'</span></div>';
|
|
445
1246
|
(d.sessions||[]).forEach(s=>{
|
|
446
1247
|
const isActive=activeSession===s.session_key;
|
|
447
1248
|
const name=s.session_key.length>20?s.session_key.slice(0,8)+'...'+s.session_key.slice(-8):s.session_key;
|
|
@@ -475,7 +1276,7 @@ async function loadMemories(page){
|
|
|
475
1276
|
const d=await r.json();
|
|
476
1277
|
totalPages=d.totalPages||1;
|
|
477
1278
|
totalCount=d.total||0;
|
|
478
|
-
document.getElementById('searchMeta').textContent=totalCount+'
|
|
1279
|
+
document.getElementById('searchMeta').textContent=totalCount+t('search.meta.total');
|
|
479
1280
|
renderMemories(d.memories||[]);
|
|
480
1281
|
renderPagination();
|
|
481
1282
|
}
|
|
@@ -489,9 +1290,9 @@ async function doSearch(q){
|
|
|
489
1290
|
const r=await fetch('/api/search?'+p.toString());
|
|
490
1291
|
const d=await r.json();
|
|
491
1292
|
const meta=[];
|
|
492
|
-
if(d.vectorCount>0) meta.push(d.vectorCount+'
|
|
493
|
-
if(d.ftsCount>0) meta.push(d.ftsCount+'
|
|
494
|
-
meta.push(d.total+'
|
|
1293
|
+
if(d.vectorCount>0) meta.push(d.vectorCount+t('search.meta.semantic'));
|
|
1294
|
+
if(d.ftsCount>0) meta.push(d.ftsCount+t('search.meta.text'));
|
|
1295
|
+
meta.push(d.total+t('search.meta.results'));
|
|
495
1296
|
document.getElementById('searchMeta').textContent=meta.join(' \\u00B7 ');
|
|
496
1297
|
renderMemories(d.results||[]);
|
|
497
1298
|
document.getElementById('pagination').innerHTML='';
|
|
@@ -535,7 +1336,7 @@ function clearDateFilter(){
|
|
|
535
1336
|
function renderMemories(items){
|
|
536
1337
|
const list=document.getElementById('memoryList');
|
|
537
1338
|
if(!items.length){
|
|
538
|
-
list.innerHTML='<div class="empty"><div class="icon">\\u{1F4ED}</div><p>
|
|
1339
|
+
list.innerHTML='<div class="empty"><div class="icon">\\u{1F4ED}</div><p>'+t('empty.text')+'</p></div>';
|
|
539
1340
|
return;
|
|
540
1341
|
}
|
|
541
1342
|
items.forEach(m=>{memoryCache[m.id]=m});
|
|
@@ -554,9 +1355,9 @@ function renderMemories(items){
|
|
|
554
1355
|
'<div class="card-summary">'+summary+'</div>'+
|
|
555
1356
|
'<div class="card-content" id="content-'+id+'"><pre>'+content+'</pre></div>'+
|
|
556
1357
|
'<div class="card-actions">'+
|
|
557
|
-
'<button class="btn btn-sm btn-
|
|
558
|
-
'<button class="btn btn-sm" onclick="openEditModal(\\''+id+'\\')">
|
|
559
|
-
'<button class="btn btn-sm btn-
|
|
1358
|
+
'<button class="btn btn-sm btn-ghost" onclick="toggleContent(\\''+id+'\\')">'+t('card.expand')+'</button>'+
|
|
1359
|
+
'<button class="btn btn-sm btn-ghost" onclick="openEditModal(\\''+id+'\\')">'+t('card.edit')+'</button>'+
|
|
1360
|
+
'<button class="btn btn-sm btn-ghost" style="color:var(--accent)" onclick="deleteMemory(\\''+id+'\\')">'+t('card.delete')+'</button>'+
|
|
560
1361
|
vscore+
|
|
561
1362
|
'</div></div>';
|
|
562
1363
|
}).join('');
|
|
@@ -579,7 +1380,7 @@ function renderPagination(){
|
|
|
579
1380
|
prev=p;
|
|
580
1381
|
}
|
|
581
1382
|
h+='<button class="pg-btn'+(currentPage>=totalPages?' disabled':'')+'" onclick="goPage('+(currentPage+1)+')">\u203A</button>';
|
|
582
|
-
h+='<span class="pg-info">'+totalCount+'
|
|
1383
|
+
h+='<span class="pg-info">'+totalCount+t('pagination.total')+'</span>';
|
|
583
1384
|
el.innerHTML=h;
|
|
584
1385
|
}
|
|
585
1386
|
|
|
@@ -600,11 +1401,43 @@ function esc(s){
|
|
|
600
1401
|
return s.replace(/&/g,'&').replace(/</g,'<').replace(/>/g,'>').replace(/"/g,'"');
|
|
601
1402
|
}
|
|
602
1403
|
|
|
1404
|
+
function renderSummaryHtml(raw){
|
|
1405
|
+
if(!raw)return'';
|
|
1406
|
+
var lines=raw.split('\\n');
|
|
1407
|
+
var html=[];
|
|
1408
|
+
var inList=false;
|
|
1409
|
+
var sectionRe=new RegExp('^(\u{1F3AF}|\u{1F4CB}|\u2705|\u{1F4A1})\\\\s+(.+)$');
|
|
1410
|
+
var listRe=new RegExp('^- (.+)$');
|
|
1411
|
+
for(var i=0;i<lines.length;i++){
|
|
1412
|
+
var line=lines[i];
|
|
1413
|
+
var hm=line.match(sectionRe);
|
|
1414
|
+
if(hm){
|
|
1415
|
+
if(inList){html.push('</ul>');inList=false;}
|
|
1416
|
+
html.push('<div class="summary-section-title">'+esc(line)+'</div>');
|
|
1417
|
+
continue;
|
|
1418
|
+
}
|
|
1419
|
+
var lm=line.match(listRe);
|
|
1420
|
+
if(lm){
|
|
1421
|
+
if(!inList){html.push('<ul>');inList=true;}
|
|
1422
|
+
html.push('<li>'+esc(lm[1])+'</li>');
|
|
1423
|
+
continue;
|
|
1424
|
+
}
|
|
1425
|
+
if(line.trim()===''){
|
|
1426
|
+
if(inList){html.push('</ul>');inList=false;}
|
|
1427
|
+
continue;
|
|
1428
|
+
}
|
|
1429
|
+
if(inList){html.push('</ul>');inList=false;}
|
|
1430
|
+
html.push('<p style="margin:4px 0">'+esc(line)+'</p>');
|
|
1431
|
+
}
|
|
1432
|
+
if(inList)html.push('</ul>');
|
|
1433
|
+
return html.join('');
|
|
1434
|
+
}
|
|
1435
|
+
|
|
603
1436
|
/* ─── CRUD ─── */
|
|
604
1437
|
function openCreateModal(){
|
|
605
1438
|
editingId=null;
|
|
606
|
-
document.getElementById('modalTitle').textContent='
|
|
607
|
-
document.getElementById('modalSubmit').textContent='
|
|
1439
|
+
document.getElementById('modalTitle').textContent=t('modal.new');
|
|
1440
|
+
document.getElementById('modalSubmit').textContent=t('modal.create');
|
|
608
1441
|
document.getElementById('mRole').value='user';
|
|
609
1442
|
document.getElementById('mContent').value='';
|
|
610
1443
|
document.getElementById('mSummary').value='';
|
|
@@ -614,10 +1447,10 @@ function openCreateModal(){
|
|
|
614
1447
|
|
|
615
1448
|
function openEditModal(id){
|
|
616
1449
|
const m=memoryCache[id];
|
|
617
|
-
if(!m){toast('
|
|
1450
|
+
if(!m){toast(t('toast.notfound'),'error');return}
|
|
618
1451
|
editingId=id;
|
|
619
|
-
document.getElementById('modalTitle').textContent='
|
|
620
|
-
document.getElementById('modalSubmit').textContent='
|
|
1452
|
+
document.getElementById('modalTitle').textContent=t('modal.edit');
|
|
1453
|
+
document.getElementById('modalSubmit').textContent=t('modal.save');
|
|
621
1454
|
document.getElementById('mRole').value=m.role||'user';
|
|
622
1455
|
document.getElementById('mContent').value=m.content||'';
|
|
623
1456
|
document.getElementById('mSummary').value=m.summary||'';
|
|
@@ -636,7 +1469,7 @@ async function submitModal(){
|
|
|
636
1469
|
summary:document.getElementById('mSummary').value,
|
|
637
1470
|
kind:document.getElementById('mKind').value,
|
|
638
1471
|
};
|
|
639
|
-
if(!data.content.trim()){toast('
|
|
1472
|
+
if(!data.content.trim()){toast(t('modal.err.empty'),'error');return}
|
|
640
1473
|
let r;
|
|
641
1474
|
if(editingId){
|
|
642
1475
|
r=await fetch('/api/memory/'+editingId,{method:'PUT',headers:{'Content-Type':'application/json'},body:JSON.stringify(data)});
|
|
@@ -644,25 +1477,25 @@ async function submitModal(){
|
|
|
644
1477
|
r=await fetch('/api/memory',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify(data)});
|
|
645
1478
|
}
|
|
646
1479
|
const d=await r.json();
|
|
647
|
-
if(d.ok){toast(editingId?'
|
|
648
|
-
else{toast(d.error||'
|
|
1480
|
+
if(d.ok){toast(editingId?t('toast.updated'):t('toast.created'),'success');closeModal();loadAll();}
|
|
1481
|
+
else{toast(d.error||t('toast.opfail'),'error')}
|
|
649
1482
|
}
|
|
650
1483
|
|
|
651
1484
|
async function deleteMemory(id){
|
|
652
|
-
if(!confirm('
|
|
1485
|
+
if(!confirm(t('confirm.delete')))return;
|
|
653
1486
|
const r=await fetch('/api/memory/'+id,{method:'DELETE'});
|
|
654
1487
|
const d=await r.json();
|
|
655
|
-
if(d.ok){toast('
|
|
656
|
-
else{toast('
|
|
1488
|
+
if(d.ok){toast(t('toast.deleted'),'success');loadAll();}
|
|
1489
|
+
else{toast(t('toast.delfail'),'error')}
|
|
657
1490
|
}
|
|
658
1491
|
|
|
659
1492
|
async function clearAll(){
|
|
660
|
-
if(!confirm('
|
|
661
|
-
if(!confirm('
|
|
1493
|
+
if(!confirm(t('confirm.clearall')))return;
|
|
1494
|
+
if(!confirm(t('confirm.clearall2')))return;
|
|
662
1495
|
const r=await fetch('/api/memories',{method:'DELETE'});
|
|
663
1496
|
const d=await r.json();
|
|
664
|
-
if(d.ok){toast('
|
|
665
|
-
else{toast('
|
|
1497
|
+
if(d.ok){toast(t('toast.cleared'),'success');loadAll();}
|
|
1498
|
+
else{toast(t('toast.clearfail'),'error')}
|
|
666
1499
|
}
|
|
667
1500
|
|
|
668
1501
|
/* ─── Toast ─── */
|
|
@@ -676,9 +1509,16 @@ function toast(msg,type='info'){
|
|
|
676
1509
|
setTimeout(()=>t.remove(),3500);
|
|
677
1510
|
}
|
|
678
1511
|
|
|
1512
|
+
/* ─── Theme ─── */
|
|
1513
|
+
const VIEWER_THEME_KEY='memos-viewer-theme';
|
|
1514
|
+
function initViewerTheme(){const s=localStorage.getItem(VIEWER_THEME_KEY);const theme=(s==='light'||s==='dark')?s:'dark';document.documentElement.setAttribute('data-theme',theme);}
|
|
1515
|
+
function toggleViewerTheme(){const el=document.documentElement;const cur=el.getAttribute('data-theme')||'dark';const next=cur==='dark'?'light':'dark';el.setAttribute('data-theme',next);localStorage.setItem(VIEWER_THEME_KEY,next);}
|
|
1516
|
+
initViewerTheme();
|
|
1517
|
+
|
|
679
1518
|
/* ─── Init ─── */
|
|
680
1519
|
document.getElementById('modalOverlay').addEventListener('click',e=>{if(e.target.id==='modalOverlay')closeModal()});
|
|
681
1520
|
document.getElementById('searchInput').addEventListener('keydown',e=>{if(e.key==='Escape'){e.target.value='';loadMemories()}});
|
|
1521
|
+
applyI18n();
|
|
682
1522
|
checkAuth();
|
|
683
1523
|
</script>
|
|
684
1524
|
</body>
|