agent-loft 0.2.88 → 0.2.89
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/README.md +7 -5
- package/package.json +1 -1
- package/src/agents/claude/session.ts +1 -1
- package/src/channels/web/api.ts +158 -6
- package/src/core/backup.ts +228 -0
- package/src/core/chat-history.ts +224 -56
- package/src/core/db.ts +72 -1
- package/src/core/fts.ts +53 -0
- package/src/core/hub.ts +20 -5
- package/src/core/memory-curator.ts +418 -76
- package/src/core/memory-dates.ts +16 -0
- package/src/core/memory-mcp.ts +1 -1
- package/src/core/memory-summaries.ts +225 -0
- package/src/core/memory.ts +698 -73
- package/src/core/personal.ts +33 -2
- package/src/core/tasks.ts +8 -7
- package/src/main.ts +27 -1
- package/src/mcp/memory-server.ts +237 -21
- package/web/css/settings.css +27 -0
- package/web/settings/memory.js +291 -13
- package/web/views/sidebar.js +1 -1
- package/web/views/todos.js +3 -3
package/web/settings/memory.js
CHANGED
|
@@ -8,6 +8,240 @@ import { field, saveButton } from "./common.js";
|
|
|
8
8
|
|
|
9
9
|
// ---------- 记忆(每个人自己的) ----------
|
|
10
10
|
|
|
11
|
+
/** 列表一次先显示这么多条 */
|
|
12
|
+
const PAGE = 50;
|
|
13
|
+
|
|
14
|
+
/** 筛选词和显示了多少条:改了东西页面会刷新,刷新后还是原样 */
|
|
15
|
+
const listState = { filter: "", shown: PAGE };
|
|
16
|
+
|
|
17
|
+
function dayText(ts) {
|
|
18
|
+
const d = new Date(ts);
|
|
19
|
+
return `${d.getFullYear()}-${String(d.getMonth() + 1).padStart(2, "0")}-${String(d.getDate()).padStart(2, "0")}`;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/** 展开着的区块:改了东西页面会刷新,刷新后还开着 */
|
|
23
|
+
const openSections = new Set();
|
|
24
|
+
|
|
25
|
+
/** 一个点开才读的区块 */
|
|
26
|
+
function lazySection(key, title, load) {
|
|
27
|
+
const body = h("div", { class: "memory-more-body" });
|
|
28
|
+
const details = h("details", { open: openSections.has(key) }, h("summary", { class: "memory-more" }, title), body);
|
|
29
|
+
let loaded = false;
|
|
30
|
+
details.ontoggle = () => {
|
|
31
|
+
if (details.open) openSections.add(key);
|
|
32
|
+
else openSections.delete(key);
|
|
33
|
+
if (!details.open || loaded) return;
|
|
34
|
+
loaded = true;
|
|
35
|
+
void load(body);
|
|
36
|
+
};
|
|
37
|
+
return h("div", { class: "section" }, details);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/** 归档和回收站:点开才读 */
|
|
41
|
+
function otherItemsSection(title, view, count, hint, reload, run) {
|
|
42
|
+
return lazySection(view, `${title}(${count})`, async (body) => {
|
|
43
|
+
fill(body, h("span", { class: "spinner" }));
|
|
44
|
+
let items;
|
|
45
|
+
try {
|
|
46
|
+
items = (await api(`/api/account/memory/items?view=${view}`)).items;
|
|
47
|
+
} catch (err) {
|
|
48
|
+
fill(body, h("div", { class: "error-text" }, err.message));
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
const row = (it) => {
|
|
52
|
+
const restore = h("button", { class: "btn small" }, "恢复");
|
|
53
|
+
const buttons = [restore];
|
|
54
|
+
if (view === "archive") {
|
|
55
|
+
restore.onclick = run(restore, () => api(`/api/account/memory/items/${it.id}`, { method: "PATCH", body: { tier: "active" } }));
|
|
56
|
+
const del = h("button", { class: "btn small danger" }, "删除");
|
|
57
|
+
del.onclick = run(del, () => api(`/api/account/memory/items/${it.id}`, { method: "DELETE" }));
|
|
58
|
+
buttons.push(del);
|
|
59
|
+
} else {
|
|
60
|
+
restore.onclick = run(restore, () => api(`/api/account/memory/items/${it.id}/restore`, { method: "POST" }));
|
|
61
|
+
const purge = h("button", { class: "btn small danger" }, "彻底删除");
|
|
62
|
+
purge.onclick = run(purge, async () => {
|
|
63
|
+
const sure = await confirmDialog({ title: "彻底删除这条?", message: "连同它的改动记录一起删掉,不能恢复。", confirmText: "彻底删除", danger: true });
|
|
64
|
+
if (!sure) return false;
|
|
65
|
+
await api(`/api/account/memory/items/${it.id}?purge=1`, { method: "DELETE" });
|
|
66
|
+
});
|
|
67
|
+
buttons.push(purge);
|
|
68
|
+
}
|
|
69
|
+
const when = view === "trash" ? `删于 ${relTime(it.deletedAt)}` : relTime(it.updatedAt);
|
|
70
|
+
return h("div", { class: "list-item memory-item" }, h("div", { class: "grow" }, h("div", { class: "t", style: { whiteSpace: "pre-wrap" } }, it.text), h("div", { class: "s" }, when)), ...buttons);
|
|
71
|
+
};
|
|
72
|
+
fill(body, h("div", { class: "muted" }, hint), items.length ? items.slice(0, 200).map(row) : h("div", { class: "muted" }, "这里没有东西。"));
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
const ACTORS = { user: "你", agent: "agent", auto: "自动整理", system: "系统" };
|
|
77
|
+
|
|
78
|
+
function describeChange(e) {
|
|
79
|
+
const text = e.newText ?? e.oldText ?? "";
|
|
80
|
+
if (e.action === "about") return "改了「关于我」";
|
|
81
|
+
if (e.action === "add") return `记下:${text}`;
|
|
82
|
+
if (e.action === "update") return `改成:${text}(原来是:${e.oldText ?? ""})`;
|
|
83
|
+
if (e.action === "delete") return `删掉:${text}`;
|
|
84
|
+
if (e.action === "restore") return `恢复:${text}`;
|
|
85
|
+
const tiers = { core: "长期", active: "活跃", archive: "归档" };
|
|
86
|
+
return `把一条从「${tiers[e.oldTier] ?? e.oldTier}」挪到「${tiers[e.newTier] ?? e.newTier}」${e.note ? `(${e.note})` : ""}`;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/** 改动记录:谁在什么时候改了什么,可以撤销 */
|
|
90
|
+
function logSection(reload) {
|
|
91
|
+
return lazySection("log", "改动记录", async (body) => {
|
|
92
|
+
const list = h("div");
|
|
93
|
+
let before;
|
|
94
|
+
const more = h("button", { class: "btn small" }, "再看更早的");
|
|
95
|
+
const row = (e) => {
|
|
96
|
+
const undo = h("button", { class: "btn small" }, "撤销");
|
|
97
|
+
undo.onclick = async () => {
|
|
98
|
+
undo.disabled = true;
|
|
99
|
+
try {
|
|
100
|
+
await api(`/api/account/memory/log/${e.id}/undo`, { method: "POST" });
|
|
101
|
+
toast("已撤销");
|
|
102
|
+
await reload();
|
|
103
|
+
} catch (err) {
|
|
104
|
+
toast(err.message);
|
|
105
|
+
undo.disabled = false;
|
|
106
|
+
}
|
|
107
|
+
};
|
|
108
|
+
return h(
|
|
109
|
+
"div",
|
|
110
|
+
{ class: "list-item memory-item" },
|
|
111
|
+
h("div", { class: "grow" }, h("div", { class: "t", style: { whiteSpace: "pre-wrap" } }, describeChange(e)), h("div", { class: "s" }, `${ACTORS[e.actor] ?? e.actor} · ${relTime(e.at)}${e.undoneAt ? " · 已撤销" : ""}`)),
|
|
112
|
+
e.undoneAt ? null : undo,
|
|
113
|
+
);
|
|
114
|
+
};
|
|
115
|
+
const page = async () => {
|
|
116
|
+
try {
|
|
117
|
+
const { log } = await api(`/api/account/memory/log${before ? `?before=${before}` : ""}`);
|
|
118
|
+
if (!before && log.length === 0) list.append(h("div", { class: "muted" }, "还没有改动。"));
|
|
119
|
+
for (const e of log) list.append(row(e));
|
|
120
|
+
before = log.at(-1)?.id;
|
|
121
|
+
more.hidden = log.length < 30;
|
|
122
|
+
} catch (err) {
|
|
123
|
+
toast(err.message);
|
|
124
|
+
}
|
|
125
|
+
};
|
|
126
|
+
more.onclick = page;
|
|
127
|
+
fill(body, h("div", { class: "muted" }, "记忆的每一次改动都在这里,自动整理改错了可以撤销。"), list, more);
|
|
128
|
+
await page();
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
/** 摘要:月度的和每段对话的 */
|
|
133
|
+
function summariesSection(mem) {
|
|
134
|
+
const total = (mem.summaries?.conv ?? 0) + (mem.summaries?.month ?? 0);
|
|
135
|
+
return lazySection("summaries", `摘要(${total})`, async (body) => {
|
|
136
|
+
const list = h("div");
|
|
137
|
+
let offset = 0;
|
|
138
|
+
const more = h("button", { class: "btn small" }, "再看更早的");
|
|
139
|
+
const row = (s) => {
|
|
140
|
+
const del = h("button", { class: "btn small danger" }, "删除");
|
|
141
|
+
const item = h(
|
|
142
|
+
"div",
|
|
143
|
+
{ class: "list-item memory-item" },
|
|
144
|
+
h(
|
|
145
|
+
"div",
|
|
146
|
+
{ class: "grow" },
|
|
147
|
+
h("div", { class: "t" }, `${s.kind === "month" ? `${s.scope} 月度:` : ""}${s.title}`),
|
|
148
|
+
h("div", { style: { whiteSpace: "pre-wrap" } }, s.text),
|
|
149
|
+
h("div", { class: "s" }, `${dayText(s.toTs)}${s.project ? ` · ${s.project}` : ""}`),
|
|
150
|
+
),
|
|
151
|
+
del,
|
|
152
|
+
);
|
|
153
|
+
del.onclick = async () => {
|
|
154
|
+
del.disabled = true;
|
|
155
|
+
try {
|
|
156
|
+
await api(`/api/account/memory/summaries/${s.id}`, { method: "DELETE" });
|
|
157
|
+
item.remove();
|
|
158
|
+
} catch (err) {
|
|
159
|
+
toast(err.message);
|
|
160
|
+
del.disabled = false;
|
|
161
|
+
}
|
|
162
|
+
};
|
|
163
|
+
return item;
|
|
164
|
+
};
|
|
165
|
+
const page = async () => {
|
|
166
|
+
try {
|
|
167
|
+
const { summaries } = await api(`/api/account/memory/summaries?offset=${offset}`);
|
|
168
|
+
if (offset === 0 && summaries.length === 0) list.append(h("div", { class: "muted" }, "还没有。整理记忆时会顺带给每段对话写摘要,一个月过去之后合成月度摘要。"));
|
|
169
|
+
for (const s of summaries) list.append(row(s));
|
|
170
|
+
offset += 30;
|
|
171
|
+
more.hidden = summaries.length < 30;
|
|
172
|
+
} catch (err) {
|
|
173
|
+
toast(err.message);
|
|
174
|
+
}
|
|
175
|
+
};
|
|
176
|
+
more.onclick = page;
|
|
177
|
+
fill(body, h("div", { class: "muted" }, "agent 回答「那段时间做了什么」「那件事的经过」时会看这些。整理范围内的对话才有。"), list, more);
|
|
178
|
+
await page();
|
|
179
|
+
});
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
/** 导出、导入、备份、搜索统计 */
|
|
183
|
+
function dataSection(mem, reload) {
|
|
184
|
+
const file = h("input", { type: "file", accept: "application/json,.json", style: { display: "none" } });
|
|
185
|
+
const importBtn = h("button", { class: "btn small" }, "导入记忆");
|
|
186
|
+
importBtn.onclick = () => file.click();
|
|
187
|
+
file.onchange = async () => {
|
|
188
|
+
const f = file.files?.[0];
|
|
189
|
+
file.value = "";
|
|
190
|
+
if (!f) return;
|
|
191
|
+
importBtn.disabled = true;
|
|
192
|
+
try {
|
|
193
|
+
const r = await api("/api/account/memory/import", { method: "POST", body: JSON.parse(await f.text()) });
|
|
194
|
+
toast(`导入了 ${r.added} 条记忆${r.summaries ? `、${r.summaries} 份摘要` : ""}${r.skipped ? `,${r.skipped} 条已有的跳过` : ""}`);
|
|
195
|
+
await reload();
|
|
196
|
+
} catch (err) {
|
|
197
|
+
toast(err instanceof SyntaxError ? "这个文件不是合法的 JSON" : err.message);
|
|
198
|
+
} finally {
|
|
199
|
+
importBtn.disabled = false;
|
|
200
|
+
}
|
|
201
|
+
};
|
|
202
|
+
const stats = mem.searchStats;
|
|
203
|
+
const b = mem.backup;
|
|
204
|
+
let backupRow = null;
|
|
205
|
+
if (b) {
|
|
206
|
+
const btn = h("button", { class: "btn small" }, "现在备份");
|
|
207
|
+
btn.onclick = async () => {
|
|
208
|
+
btn.disabled = true;
|
|
209
|
+
btn.textContent = "备份中…";
|
|
210
|
+
try {
|
|
211
|
+
await api("/api/account/memory/backup", { method: "POST" });
|
|
212
|
+
toast("已备份");
|
|
213
|
+
await reload();
|
|
214
|
+
} catch (err) {
|
|
215
|
+
toast(err.message);
|
|
216
|
+
btn.disabled = false;
|
|
217
|
+
btn.textContent = "现在备份";
|
|
218
|
+
}
|
|
219
|
+
};
|
|
220
|
+
const size = b.last ? `,${(b.last.size / 1048576).toFixed(1)} MB` : "";
|
|
221
|
+
backupRow = [
|
|
222
|
+
h("div", { class: "row", style: { alignItems: "center", gap: "10px" } }, btn, h("span", { class: "muted" }, b.last ? `上次备份:${relTime(b.last.at)}${size},共 ${b.count} 份` : "还没有备份")),
|
|
223
|
+
h("div", { class: "muted" }, `整个数据库每天自动备份一份到 ${b.dir}(留最近 7 天、4 周、12 个月)。这个目录和数据在同一块盘上,防不了硬盘损坏;可以设环境变量 AGENT_LOFT_BACKUP_DIR 放到别的盘。`),
|
|
224
|
+
b.error ? h("div", { class: "error-text" }, `上次备份失败(${relTime(b.error.at)}):${b.error.message}`) : null,
|
|
225
|
+
];
|
|
226
|
+
}
|
|
227
|
+
return h(
|
|
228
|
+
"div",
|
|
229
|
+
{ class: "section" },
|
|
230
|
+
h("h4", {}, "导出和备份"),
|
|
231
|
+
h(
|
|
232
|
+
"div",
|
|
233
|
+
{ class: "row" },
|
|
234
|
+
h("a", { class: "btn small memory-link", href: "/api/account/memory/export", download: "" }, "导出记忆"),
|
|
235
|
+
h("a", { class: "btn small memory-link", href: "/api/account/history/export", download: "" }, "导出聊天记录"),
|
|
236
|
+
importBtn,
|
|
237
|
+
file,
|
|
238
|
+
),
|
|
239
|
+
h("div", { class: "muted" }, "记忆导出成 JSON(条目、摘要和改动记录),可以导入到别的账号或服务器,内容一样的会跳过。聊天记录导出成一行一句的 JSONL。"),
|
|
240
|
+
backupRow,
|
|
241
|
+
stats?.searches ? h("div", { class: "muted" }, `近 30 天 agent 搜了 ${stats.searches} 次聊天记录,${stats.empty} 次没搜到。`) : null,
|
|
242
|
+
);
|
|
243
|
+
}
|
|
244
|
+
|
|
11
245
|
export async function memoryTab(panel, refresh = false) {
|
|
12
246
|
const box = h("div", { class: "section" }, h("h4", {}, "记忆"), h("span", { class: "spinner" }));
|
|
13
247
|
// 更新时保留旧内容,避免加载占位让页面变短、滚动位置被浏览器压回顶部。
|
|
@@ -62,7 +296,7 @@ export async function memoryTab(panel, refresh = false) {
|
|
|
62
296
|
clearHistory.onclick = run(clearHistory, async () => {
|
|
63
297
|
const sure = await confirmDialog({
|
|
64
298
|
title: "清空聊天记录索引?",
|
|
65
|
-
message: "侧栏的「搜索」和 agent
|
|
299
|
+
message: "侧栏的「搜索」和 agent 都将搜不到以前聊天的内容(按标题还能搜到;对话本身不删,侧栏里照样能打开)。从聊天写出来的对话摘要和月度摘要也一起清掉。之后的聊天还会继续记进来。",
|
|
66
300
|
confirmText: "清空",
|
|
67
301
|
danger: true,
|
|
68
302
|
});
|
|
@@ -88,30 +322,66 @@ export async function memoryTab(panel, refresh = false) {
|
|
|
88
322
|
if (e.key === "Enter" && !e.isComposing) addBtn.click();
|
|
89
323
|
};
|
|
90
324
|
|
|
91
|
-
const items = [...mem.items].sort((a, b) => b.updatedAt - a.updatedAt);
|
|
325
|
+
const items = [...mem.items].sort((a, b) => Math.max(b.updatedAt, b.lastUsedAt ?? 0) - Math.max(a.updatedAt, a.lastUsedAt ?? 0));
|
|
326
|
+
const patchItem = (it, body) => api(`/api/account/memory/items/${it.id}`, { method: "PATCH", body });
|
|
327
|
+
const itemMeta = (it) => {
|
|
328
|
+
const from = { user: "你加的", asked: "你让记的", agent: "agent 在聊天里记的", auto: "聊完后自动整理的" }[it.source] ?? "agent 记的";
|
|
329
|
+
return [
|
|
330
|
+
it.tier === "core" ? (it.locked ? "已置顶" : "长期") : "",
|
|
331
|
+
from,
|
|
332
|
+
relTime(it.updatedAt),
|
|
333
|
+
it.observedAt ? `事情发生在 ${dayText(it.observedAt)}` : "",
|
|
334
|
+
it.validUntil ? `到 ${dayText(it.validUntil)} 过期` : "",
|
|
335
|
+
]
|
|
336
|
+
.filter(Boolean)
|
|
337
|
+
.join(" · ");
|
|
338
|
+
};
|
|
92
339
|
const itemRow = (it) => {
|
|
93
|
-
const
|
|
94
|
-
const body = h("div", { class: "grow" }, h("div", { class: "t", style: { whiteSpace: "pre-wrap" } }, it.text), h("div", { class: "s" }, `${from} · ${relTime(it.updatedAt)}`));
|
|
340
|
+
const body = h("div", { class: "grow" }, h("div", { class: "t", style: { whiteSpace: "pre-wrap" } }, it.text), h("div", { class: "s" }, itemMeta(it)));
|
|
95
341
|
const edit = h("button", { class: "btn small" }, "编辑");
|
|
342
|
+
const pin = h("button", { class: "btn small", title: "置顶的一直放在系统提示里,自动整理也不会动它" }, it.tier === "core" ? "取消置顶" : "置顶");
|
|
343
|
+
const archive = h("button", { class: "btn small", title: "归档:不再放进系统提示,agent 需要时还能搜到" }, "归档");
|
|
96
344
|
const del = h("button", { class: "btn small danger" }, "删除");
|
|
97
345
|
edit.onclick = () => {
|
|
98
|
-
edit.hidden = del.hidden = true;
|
|
346
|
+
edit.hidden = del.hidden = pin.hidden = archive.hidden = true;
|
|
99
347
|
const input = h("textarea", { class: "input", rows: 2, maxlength: mem.limits.item });
|
|
100
348
|
input.value = it.text;
|
|
101
349
|
const ok = h("button", { class: "btn small primary" }, "保存");
|
|
102
|
-
ok.onclick = run(ok, () =>
|
|
350
|
+
ok.onclick = run(ok, () => patchItem(it, { text: input.value }));
|
|
103
351
|
fill(body, input, h("div", { class: "row" }, ok, h("button", { class: "btn small", onclick: reload }, "取消")));
|
|
104
352
|
input.focus();
|
|
105
353
|
};
|
|
354
|
+
pin.onclick = run(pin, () => patchItem(it, { tier: it.tier === "core" ? "active" : "core" }));
|
|
355
|
+
archive.onclick = run(archive, () => patchItem(it, { tier: "archive" }));
|
|
106
356
|
del.onclick = run(del, () => api(`/api/account/memory/items/${it.id}`, { method: "DELETE" }));
|
|
107
|
-
return h("div", { class: "list-item" }, body, edit, del);
|
|
357
|
+
return h("div", { class: "list-item memory-item" }, body, edit, pin, archive, del);
|
|
358
|
+
};
|
|
359
|
+
|
|
360
|
+
// 条目多了要能找:输入就筛,一次先显示前 PAGE 条
|
|
361
|
+
const listBox = h("div");
|
|
362
|
+
const filter = h("input", { class: "input", style: { flex: "1", minWidth: "0" }, placeholder: "筛选记住的事" });
|
|
363
|
+
filter.value = listState.filter;
|
|
364
|
+
const renderList = () => {
|
|
365
|
+
const q = filter.value.trim().toLowerCase();
|
|
366
|
+
const hit = q ? items.filter((it) => it.text.toLowerCase().includes(q)) : items;
|
|
367
|
+
fill(
|
|
368
|
+
listBox,
|
|
369
|
+
hit.length ? hit.slice(0, listState.shown).map(itemRow) : h("div", { class: "muted" }, q ? "没有匹配的。" : "还没有。聊天时说「记住……」,或者在上面手动加。"),
|
|
370
|
+
hit.length > listState.shown ? h("button", { class: "btn small", onclick: () => ((listState.shown += PAGE), renderList()) }, `再显示一些(还有 ${hit.length - listState.shown} 条)`) : null,
|
|
371
|
+
);
|
|
372
|
+
};
|
|
373
|
+
filter.oninput = () => {
|
|
374
|
+
listState.filter = filter.value;
|
|
375
|
+
listState.shown = PAGE;
|
|
376
|
+
renderList();
|
|
108
377
|
};
|
|
378
|
+
renderList();
|
|
109
379
|
|
|
110
380
|
const clearBtn = h("button", { class: "btn danger" }, "清空全部记忆");
|
|
111
381
|
clearBtn.onclick = run(clearBtn, async () => {
|
|
112
382
|
const sure = await confirmDialog({
|
|
113
383
|
title: "清空全部记忆?",
|
|
114
|
-
message: "
|
|
384
|
+
message: "「关于我」、所有记住的事(包括归档和回收站)、改动记录和摘要都会彻底删除,不能恢复。想留一份的话先导出。",
|
|
115
385
|
confirmText: "清空",
|
|
116
386
|
danger: true,
|
|
117
387
|
});
|
|
@@ -158,9 +428,16 @@ export async function memoryTab(panel, refresh = false) {
|
|
|
158
428
|
"div",
|
|
159
429
|
{ class: "section" },
|
|
160
430
|
h("h4", {}, `记住的事(${items.length})`),
|
|
431
|
+
h("div", { class: "muted" }, "「长期」和置顶的一直放在系统提示里;其余的按最近动过的时间放,放不下的 agent 需要时能搜到。满了会把最久没动过的挪到归档,不会删掉。你加的、你让记的、置顶的,自动整理都不会动。"),
|
|
161
432
|
h("div", { class: "row" }, newItem, addBtn),
|
|
162
|
-
items.length
|
|
433
|
+
items.length > 8 ? h("div", { class: "row" }, filter) : null,
|
|
434
|
+
listBox,
|
|
163
435
|
),
|
|
436
|
+
otherItemsSection("归档", "archive", mem.counts?.archive ?? 0, "过时了的事。不放进系统提示,agent 问到以前的情况时能搜到。", reload, run),
|
|
437
|
+
otherItemsSection("回收站", "trash", mem.counts?.trash ?? 0, "删掉的放在这里 30 天,之后彻底删除。", reload, run),
|
|
438
|
+
logSection(reload),
|
|
439
|
+
summariesSection(mem),
|
|
440
|
+
dataSection(mem, reload),
|
|
164
441
|
h(
|
|
165
442
|
"div",
|
|
166
443
|
{ class: "section" },
|
|
@@ -272,7 +549,7 @@ function curateSection(mem, reload) {
|
|
|
272
549
|
r.error
|
|
273
550
|
? `整理失败:${r.error}`
|
|
274
551
|
: r.conversations
|
|
275
|
-
? `整理了 ${r.conversations} 段对话:新增 ${r.added.length}、更新 ${r.updated.length}
|
|
552
|
+
? `整理了 ${r.conversations} 段对话:新增 ${r.added.length}、更新 ${r.updated.length}、移走 ${r.removed}`
|
|
276
553
|
: "没有需要整理的对话(正在回复的那段先不整理)",
|
|
277
554
|
);
|
|
278
555
|
reload();
|
|
@@ -283,10 +560,11 @@ function curateSection(mem, reload) {
|
|
|
283
560
|
}
|
|
284
561
|
};
|
|
285
562
|
const last = mem.lastCuration;
|
|
563
|
+
const retryText = mem.curateRetry ? `失败的对话都留着,${new Date(mem.curateRetry.nextAt).toLocaleTimeString("zh-CN", { hour: "2-digit", minute: "2-digit" })} 之后自动再试。` : "失败的对话都留着,下次再试。";
|
|
286
564
|
const lastText = last
|
|
287
565
|
? last.error
|
|
288
|
-
? `上次整理(${relTime(last.at)}
|
|
289
|
-
: `上次整理:${relTime(last.at)},${last.conversations} 段对话${last.by ? `,用 ${last.by}` : ""},新增 ${last.added.length}、更新 ${last.updated.length}
|
|
566
|
+
? `上次整理(${relTime(last.at)})${last.conversations ? `成功 ${last.conversations} 段,其余` : ""}没成功:${last.error}。${retryText}`
|
|
567
|
+
: `上次整理:${relTime(last.at)},${last.conversations} 段对话${last.by ? `,用 ${last.by}` : ""},新增 ${last.added.length}、更新 ${last.updated.length}、移走 ${last.removed}${last.summaries ? `、写了 ${last.summaries} 份摘要` : ""}`
|
|
290
568
|
: "还没整理过";
|
|
291
569
|
|
|
292
570
|
fill(
|
|
@@ -307,7 +585,7 @@ function curateSection(mem, reload) {
|
|
|
307
585
|
c.when === "off" ? null : field("用哪个 agent", agent),
|
|
308
586
|
c.when === "off" ? null : model,
|
|
309
587
|
h("div", { class: "row", style: { alignItems: "center", gap: "10px" } }, nowBtn, h("span", { class: "muted" }, `${mem.pending ? `有 ${mem.pending} 段对话等着整理。` : ""}${lastText}`)),
|
|
310
|
-
h("div", { class: "muted" }, "
|
|
588
|
+
h("div", { class: "muted" }, "整理时会对照现有记忆补充、更新、归档过时的条目,顺带给每段对话写摘要。你加的、你让记的、置顶的它不会动;改错了可以在下面的「改动记录」里撤销。"),
|
|
311
589
|
);
|
|
312
590
|
};
|
|
313
591
|
render();
|
package/web/views/sidebar.js
CHANGED
|
@@ -575,7 +575,7 @@ export function renderSidebar() {
|
|
|
575
575
|
h("span", { class: "title" }, convTitle(c)),
|
|
576
576
|
fold ? caret(fold.folded, fold.toggle) : null,
|
|
577
577
|
convExpertMark(c),
|
|
578
|
-
c.taskId ? h("span", { class: "brand-icon task-mark", title: "定时任务的对话", html: ICON.clock }) : null,
|
|
578
|
+
c.taskId || c.hasTasks ? h("span", { class: "brand-icon task-mark", title: "定时任务的对话", html: ICON.clock }) : null,
|
|
579
579
|
status(fold?.folded ? fold.keys : [c.key]),
|
|
580
580
|
);
|
|
581
581
|
|
package/web/views/todos.js
CHANGED
|
@@ -25,8 +25,8 @@ export function renderTodos() {
|
|
|
25
25
|
const show = !!list && !dismissed && (done < list.length || S.busy);
|
|
26
26
|
ui.todoBar.hidden = !show;
|
|
27
27
|
if (!show) return fill(ui.todoBar);
|
|
28
|
-
const doing = list.
|
|
29
|
-
const title = doing ? doing.activeForm || doing.content : done === list.length ? "全部完成" : "任务清单";
|
|
28
|
+
const doing = list.filter((t) => t.status === "in_progress");
|
|
29
|
+
const title = doing.length > 1 ? `${doing.length} 项进行中` : doing.length ? doing[0].activeForm || doing[0].content : done === list.length ? "全部完成" : "任务清单";
|
|
30
30
|
fill(
|
|
31
31
|
ui.todoBar,
|
|
32
32
|
h(
|
|
@@ -43,7 +43,7 @@ export function renderTodos() {
|
|
|
43
43
|
renderTodos();
|
|
44
44
|
},
|
|
45
45
|
},
|
|
46
|
-
h("span", { class: `todo-title${doing && S.busy ? " shimmer" : ""}
|
|
46
|
+
h("span", { class: `todo-title${doing.length && S.busy ? " shimmer" : ""}`, title: doing.map((t) => t.activeForm || t.content).join(";") }, title),
|
|
47
47
|
h("span", { class: "todo-count" }, `${done}/${list.length}`),
|
|
48
48
|
h("span", { class: `chev${open ? " open" : ""}` }, "›"),
|
|
49
49
|
),
|