dsh-fish-soul 0.19.25 → 0.19.26

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 CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  让一个 QQ 小号背后有"同一个人":固定人格、按人记记忆、有自己的生活节奏、会主动开口;同一个"她"同时出现在 QQ、B站、抖音。
4
4
 
5
- DSH 插件(单角色 `feiyu`)。版本 **0.19.25**。
5
+ DSH 插件(单角色 `feiyu`)。版本 **0.19.26**。
6
6
 
7
7
  QQ 交流群:**1125962189**
8
8
 
@@ -51,6 +51,8 @@ dsh plugin --profile desktop add dsh-fish-soul
51
51
 
52
52
  `$DSH_HOME` 缺省 `~/.dsh`。
53
53
 
54
+ **数据目录可以搬到别处**:设置页「记忆存档 → 数据目录」填一个完整路径(例如 `D:\fish-soul-data`),保存后**重启插件**生效。记忆库、人格卡、备份、存档、两个浏览器 profile 和各类缓存全部跟着走(配置键 `dataDir`;`fish-soul-config.json` 本身留在 `$DSH_HOME`,不改)。改名/搬家只在下次启动时做:先复制到 `<目标>.incoming` 并逐文件核对字节数,通过后才切换;旧目录改名为 `<原名>.moved-<时间戳>` 留档,确认没问题后自行删除。任何一步失败都会继续用旧目录,不会空库启动 —— 浏览器 profile 动辄几百 MB,搬家时保证目标盘有足够空间,也别让两个进程同时写它。
55
+
54
56
  ### 可选:语音文件(#101)
55
57
 
56
58
  「模型 → 语音」里两项独立开关均默认关闭。保存 QQ 语音时,只处理原本会回复、已识别说话人的好友私聊和明确白名单群;不处理未获允许、暂停或无需回复的消息。优先保存消息提供的原始音频,无法取得原件时退回 `get_record` 转出的音频;文件名标 `original` 或 `converted`,扩展名按音频头判断,无法识别时为 `.bin`。原件为 SILK 或未知格式时,会尝试同时保存配对的转码分析文件(`analysis`),供音频插件使用。`voice-in` 最多保存 30 条,可以在设置里清空;文件未加密,清理不包含备份和复制件。为限制资源,单条消息最多处理前 30 段语音,STT 仍只转写前 2 段。
@@ -22,7 +22,7 @@ import { spawn } from 'node:child_process';
22
22
  import { mkdirSync, readFileSync, rmSync } from 'node:fs';
23
23
  import { join } from 'node:path';
24
24
  import { detectBrowsers, pickBrowser } from './browsers.js';
25
- import { dshHome } from './db.js';
25
+ import { dshHome, fishSoulDir } from './db.js';
26
26
 
27
27
  const CDP_READY_TIMEOUT_MS = 15_000;
28
28
  const VIDEO_READY_TIMEOUT_MS = 25_000;
@@ -175,6 +175,7 @@ export class BiliPlayback {
175
175
  // 起进程这一步可替换,测试才能验「ensureBrowser 真的用了 playbackBrowserArgs」
176
176
  // 而不只是验那个函数返回了什么(本项目栽过好几次「函数对、没接线」)。
177
177
  this.spawn = spawnImpl;
178
+ this.homeOverride = homedirOverride;
178
179
  this.home = homedirOverride !== '' ? homedirOverride : dshHome();
179
180
  this.browserPath = '';
180
181
  this.launching = null;
@@ -205,7 +206,9 @@ export class BiliPlayback {
205
206
  userDataDir() {
206
207
  const configured = String(this.cfg().userDataDir ?? '').trim();
207
208
  if (configured !== '') return configured;
208
- return join(this.home, 'fish-soul', 'bili-playback');
209
+ // `this.home` 是测试注入的假 DSH_HOME;没注入时跟着数据目录走(可能被改到别的盘)
210
+ if (this.homeOverride !== '') return join(this.home, 'fish-soul', 'bili-playback');
211
+ return join(fishSoulDir(), 'bili-playback');
209
212
  }
210
213
 
211
214
  /** 找浏览器(配置指定的优先,否则按 detectBrowsers 的顺序挑第一个)。 */
@@ -472,6 +472,7 @@ window.__ModuleLoader__.load({
472
472
  const [history, setHistory] = react.useState(null);
473
473
  const [historyQuery, setHistoryQuery] = react.useState("");
474
474
  const [showAllFiles, setShowAllFiles] = react.useState(false);
475
+ const [dataDirForm, setDataDirForm] = react.useState(null);
475
476
  const [confirm, confirmNode] = useConfirm();
476
477
  react.useEffect(() => { if (chat && form === null) setForm({ enabled: chat.enabled, channels: chat.channels.join(", "), days: chat.days }); }, [chat, form]);
477
478
  react.useEffect(() => { if (storage && threshold === null) setThreshold({ warnMB: storage.warnMB, freeMB: storage.freeMB, keep: storage.keep ?? 10 }); }, [storage, threshold]);
@@ -479,6 +480,34 @@ window.__ModuleLoader__.load({
479
480
  const size = (x) => `${(Number(x || 0) / 1048576).toFixed(1)} MB`;
480
481
  async function storageConfig(patch) { const r=await api("POST", "/storage/config", patch); if(r?.ok){await load();notify("已保存");}else notify(r?.error??"保存失败"); }
481
482
  async function snapshot() { setBusy(true);const r=await api("POST", "/storage/snapshot", {});setBusy(false);if(r?.ok){notify("存档已校验");await load();}else notify(r?.error??"存档失败"); }
483
+ async function saveDataDir() {
484
+ const next = String(dataDirForm ?? storage.dataDir ?? "").trim();
485
+ const warning = next === "" ? "改回默认目录?重启后会把数据从当前目录搬回默认位置。" : `改到 ${next}?重启插件后会把当前数据(含浏览器登录态,可能几百 MB)复制过去,成功后旧目录改名留档。`;
486
+ if(!(await confirm({ title: "换数据目录", description: warning })))return;
487
+ setBusy(true);const r=await api("POST", "/storage/datadir", {dir:next});setBusy(false);
488
+ if(r?.ok){setDataDirForm(r.dataDir === "" ? storage.defaultDataDir : r.dataDir);notify("已保存,重启插件后生效");await load();}else notify(r?.error??"保存失败");
489
+ }
490
+ /** 用系统的选文件夹对话框挑路径(桌面端才有;浏览器里没有绝对路径可用)。 */
491
+ async function pickDataDir() {
492
+ const picker = globalThis.__DSH_DIRECTORY_PICKER__;
493
+ if (!picker || typeof picker.pick !== "function") { notify("这个界面里没有系统选择框,直接填路径也可以"); return; }
494
+ try {
495
+ const picked = await picker.pick();
496
+ if (typeof picked === "string" && picked.trim() !== "") setDataDirForm(picked);
497
+ } catch (e) { notify(`打开选择框失败:${String(e?.message ?? e)}`); }
498
+ }
499
+ /** 删掉一份留档(搬家留下的旧目录)。 */
500
+ async function removeArchived(dir) {
501
+ if(!(await confirm({ title: "删除旧目录留档", description: `永久删除 ${dir}?这份是搬家前的完整副本,删了就不能退回旧目录了。`, danger: true })))return;
502
+ setBusy(true);const r=await api("POST", "/storage/archived/delete", {dir});setBusy(false);
503
+ if(r?.ok){notify("已删除");await load();}else notify(r?.error??"删除失败");
504
+ }
505
+ /** 一键回到默认目录(等价于把「数据目录」清空)。 */
506
+ async function resetDataDir() {
507
+ if(!(await confirm({ title: "恢复默认数据目录", description: `重启插件后会把数据搬回 ${storage.defaultDataDir},成功后当前目录改名留档。` })))return;
508
+ setBusy(true);const r=await api("POST", "/storage/datadir", {dir:""});setBusy(false);
509
+ if(r?.ok){setDataDirForm(null);notify("已改回默认,重启插件后生效");await load();}else notify(r?.error??"保存失败");
510
+ }
482
511
  async function fileAction(action, file) {
483
512
  const warning = action === "restore" ? "恢复将于重启后替换当前记忆库;当前库会先另存。确定?" : "永久删除这份存档?不会删除在线记忆。";
484
513
  if(!(await confirm({ title: action === "restore" ? "恢复存档" : "删除存档", description: warning, danger: action === "delete" })))return;setBusy(true);const r=await api("POST", `/storage/${action}`, {file});setBusy(false);
@@ -528,6 +557,18 @@ window.__ModuleLoader__.load({
528
557
  h("div", { className: "fs-track", style: { width: "100%", flex: "none" }, role: "progressbar", "aria-valuemin": 0, "aria-valuemax": 100, "aria-valuenow": budgetPct },
529
558
  h("div", { className: "fs-fill", "data-tone": budgetWarn ? "warn" : undefined, style: { width: `${budgetPct}%` } })),
530
559
  h("span", { className: "fs-usage-kpi-sub" }, storage.budget.consecutive >= 3 ? `连续 ${storage.budget.consecutive} 次接近上限` : "按记忆片段字符估算"))),
560
+ Group({title:"数据目录",tip:"记忆库、备份、存档、浏览器 profile、缓存都在这个目录下。改到别的盘后要重启插件才生效,旧目录会在下次启动时搬到新位置并改名留档"},
561
+ Row({title:"当前目录",meta: storage.dataDir === storage.defaultDataDir ? "默认位置" : "已改到别处", stack:true},
562
+ h("div", { className: "fs-inline-ctl" },
563
+ Input({ className: "wide", value: dataDirForm ?? storage.dataDir, placeholder: storage.defaultDataDir, "aria-label": "数据目录", onChange: e => setDataDirForm(e.target.value) }),
564
+ Button({ disabled: busy, onClick: pickDataDir }, "选文件夹"),
565
+ Button({ disabled: busy, onClick: saveDataDir }, "保存"))),
566
+ Row({title:"恢复默认",meta:"等价于把上面的路径清空;重启后数据搬回默认位置"},Button({ variant:"ghost", disabled: busy, onClick: resetDataDir }, "用默认目录")),
567
+ Row({title:"默认位置"}, Muted(storage.defaultDataDir)),
568
+ Row({title:"换目录后"}, Muted("重启插件生效;旧数据会复制到新位置并逐文件核对,成功后旧目录改名留档,失败就继续用旧目录")),
569
+ ...(storage.archived ?? []).map(a => Row({ title: "旧目录留档", meta: a.dir, stack: true },
570
+ Button({ variant: "danger", disabled: busy, onClick: () => removeArchived(a.dir) }, "删除"))),
571
+ ),
531
572
  Group({title:"存储与快照",tip:"压缩快照保留全部记忆及来源,不删除在线数据;本地文件未加密"},
532
573
  Row({title:"每周自动存档",meta:"压缩校验,不删除原文;存档未加密"},h(Switch,{label:"每周自动存档",checked:storage.auto,disabled:busy,onChange:v=>storageConfig({auto:v})})),
533
574
  Row({title:"立即存档",meta:`现有 ${storage.files.length} 份,当前库 ${size(storage.databaseBytes)};每次大小取决于数据`},Button({disabled:busy||storage.running,onClick:snapshot},busy||storage.running?"处理中":"立即存档")),
@@ -4,6 +4,11 @@ import { DEFAULT_DAILY_MAX, DEFAULT_IDLE_REAL_GAP_MIN } from './life.js';
4
4
 
5
5
  export function fishSoulConfigSchema(z) {
6
6
  return z.object({
7
+ // 数据目录(库 / 备份 / 存档 / 浏览器 profile / 缓存)。空 = $DSH_HOME/fish-soul。
8
+ // ⚠️ 这个键在建库**之前**就要读到,所以它不经 schema 生效 —— 真正读它的是
9
+ // db.js 的 configuredDataDir()(直接读配置文件)。在这里登记是为了让它
10
+ // 出现在设置页的读写与校验链里。
11
+ dataDir: z.string().default(''),
7
12
  masterQqUin: z.string().default(''),
8
13
  qq: z.object({
9
14
  enabled: z.boolean().default(false),
@@ -0,0 +1,190 @@
1
+ /**
2
+ * data-dir.js —— 数据目录可以让人自己挑。
3
+ *
4
+ * 为什么要有这个:默认所有东西都在 `$DSH_HOME/fish-soul` 下(真机 529MB,其中两个浏览器
5
+ * profile 占 357MB)。系统盘紧张只能改 DSH_HOME,而那会把宿主其它插件一起挪走。
6
+ *
7
+ * 契约(`test/data-dir.mjs` 钉着):
8
+ * - 没配 → 默认目录,行为与以前逐字节一致;
9
+ * - 配了、目标已有内容 → 直接用(上次搬过 / 用户自己搬过);
10
+ * - 配了、目标空着、旧目录有数据 → 复制到 `<目标>.incoming`,逐文件核对大小,
11
+ * 通过才改名成目标,旧目录改名 `fish-moved-<时间>` 留档;
12
+ * - 任何一步失败 → **回退旧目录继续跑,绝不空库启动**(半份数据比没有更糟)。
13
+ */
14
+ import { cp, mkdir, readdir, rename, rm, stat } from 'node:fs/promises';
15
+ import { existsSync } from 'node:fs';
16
+ import { dirname, isAbsolute, join, resolve, sep } from 'node:path';
17
+ import { dshHome, configuredDataDir, setActiveDataDir, getKv, setKv } from './db.js';
18
+ import { stampLocal } from './time-util.js';
19
+
20
+ /** 目录里有东西吗(跳过点开头的残留文件)。 */
21
+ async function hasContent(dir) {
22
+ try {
23
+ return (await readdir(dir)).some((n) => !n.startsWith('.'));
24
+ } catch { return false; }
25
+ }
26
+
27
+ /** 相对路径 → 字节数(只收普通文件,软链跳过:复制它没意义)。 */
28
+ async function walk(root, prefix = '', out = new Map()) {
29
+ let entries;
30
+ try { entries = await readdir(root, { withFileTypes: true }); } catch { return out; }
31
+ for (const e of entries) {
32
+ const rel = prefix === '' ? e.name : `${prefix}/${e.name}`;
33
+ if (e.isDirectory()) { await walk(join(root, e.name), rel, out); continue; }
34
+ if (!e.isFile()) continue;
35
+ try { out.set(rel, (await stat(join(root, e.name))).size); } catch { /* 读不到就不算,校验会报缺 */ }
36
+ }
37
+ return out;
38
+ }
39
+
40
+ /**
41
+ * 逐文件核对字节数。只看「源里的每个文件目标都有、且一样大」——
42
+ * 多出来的文件不管(.incoming 是新目录,多出来的只可能是并发写入)。
43
+ */
44
+ export async function verifyCopy(from, to) {
45
+ const a = await walk(from);
46
+ const b = await walk(to);
47
+ const missing = [];
48
+ const wrong = [];
49
+ for (const [rel, size] of a) {
50
+ if (!b.has(rel)) missing.push(rel);
51
+ else if (b.get(rel) !== size) wrong.push(`${rel}(${size} ≠ ${b.get(rel)})`);
52
+ }
53
+ if (missing.length > 0 || wrong.length > 0) {
54
+ const sample = [...missing, ...wrong].slice(0, 5).join('、');
55
+ throw new Error(`复制后核对不符(${missing.length} 个缺失 / ${wrong.length} 个大小不同):${sample}`);
56
+ }
57
+ }
58
+
59
+ /**
60
+ * 启动时决定数据放哪,必要时把默认目录搬过去。
61
+ *
62
+ * 必须在 `openDatabase()` 之前调用 —— 库路径就是这里钉下去的。
63
+ * @returns {Promise<{dir: string, moved: boolean, archived: string}>} archived = 旧目录改成的留档路径(没搬为空)
64
+ */
65
+ export async function ensureDataDir({ log = () => {}, copy = cp } = {}) {
66
+ const from = join(dshHome(), 'fish-soul');
67
+ const want = configuredDataDir();
68
+ if (want === null || resolve(want) === resolve(from)) {
69
+ // 没配(或配成默认)时**不缓存**:让 fishSoulDir() 每次现拼 dshHome(),
70
+ // 否则测试里换 DSH_HOME 会全部串到第一个 home 上(smoke 第 20 组就是这么挂的)。
71
+ setActiveDataDir(null);
72
+ return { dir: from, moved: false };
73
+ }
74
+ if (await hasContent(want)) {
75
+ setActiveDataDir(want);
76
+ return { dir: want, moved: false };
77
+ }
78
+ if (!(await hasContent(from))) {
79
+ // 全新安装:直接在新位置起,没有可搬的东西
80
+ await mkdir(want, { recursive: true });
81
+ setActiveDataDir(want);
82
+ return { dir: want, moved: false };
83
+ }
84
+
85
+ log('info', `[fish-soul] 数据目录搬家:${from} → ${want}`);
86
+ const incoming = `${want}.incoming`;
87
+ try {
88
+ // ⚠️ 不能先 mkdir(want):Windows 上 rename 到一个**已存在的目录**会 EPERM,
89
+ // 哪怕它是空的。复制目标用 incoming,成功后 rename 上去 —— 那时 want 必须不存在。
90
+ if (existsSync(want)) await rm(want, { recursive: true, force: true }); // 只可能是空目录(上面判过)
91
+ await rm(incoming, { recursive: true, force: true }); // 上次中断的残留
92
+ await mkdir(dirname(want), { recursive: true }); // 父级要存在,不然 cp 的 recursive 只会建 incoming 自己
93
+ await copy(from, incoming, { recursive: true });
94
+ await verifyCopy(from, incoming);
95
+ await rename(incoming, want);
96
+ } catch (error) {
97
+ // 半份数据不能留下 —— 下次启动会被当成「已经有内容」直接用
98
+ try { await rm(incoming, { recursive: true, force: true }); } catch { /* 删不掉也不影响回退 */ }
99
+ setActiveDataDir(null); // 回退到「跟着 DSH_HOME 走」
100
+ const msg = error instanceof Error ? error.message : String(error);
101
+ log('error', `[fish-soul] 数据目录搬家失败,继续用 ${from}:${msg}`);
102
+ throw error;
103
+ }
104
+
105
+ const archive = `${from}.moved-${stampLocal(Date.now())}`;
106
+ let archived = '';
107
+ try {
108
+ await rename(from, archive);
109
+ archived = archive;
110
+ log('info', `[fish-soul] 旧数据目录已改名留档:${archive}(确认新目录没问题后可在设置页删掉)`);
111
+ } catch (error) {
112
+ // 改名失败不影响使用:数据已经在新位置了,旧目录当成多余的副本
113
+ log('warn', `[fish-soul] 旧数据目录改名失败(不影响使用):${error instanceof Error ? error.message : String(error)}`);
114
+ }
115
+ setActiveDataDir(want);
116
+ // 留档路径同时记进新库(openDatabase 之后才调 importArchives),这样面板能列出来删
117
+ return { dir: want, moved: true, archived };
118
+ }
119
+
120
+ /** 留档目录记在哪(kv)。 */
121
+ const ARCHIVES_KEY = 'dataDir.archived';
122
+
123
+ /**
124
+ * 把留档路径记进库 —— 要在 `openDatabase()` **之后**调(搬家时库还没开)。
125
+ * 顺手把「路径早就不在」的旧记录清掉(用户可能自己删了)。
126
+ */
127
+ export function importArchives(db, dirs = []) {
128
+ if (!db) return;
129
+ const list = listArchived(db);
130
+ const seen = new Set(list.map((x) => resolve(x.dir)));
131
+ for (const dir of dirs) {
132
+ const d = String(dir ?? '').trim();
133
+ if (d === '' || seen.has(resolve(d))) continue;
134
+ // at 用来排「哪份更新」;同一毫秒里加进多份会让顺序不确定 ⇒ 取比现有最大值更大的
135
+ list.push({ dir: d, at: Math.max(Date.now(), ...list.map((x) => Number(x.at ?? 0) + 1)) });
136
+ seen.add(resolve(d));
137
+ }
138
+ try { setKv(db, ARCHIVES_KEY, list); } catch { /* 记不上只影响「面板里能删」,不影响使用 */ }
139
+ }
140
+
141
+ /** 搬过家留下的旧目录(只列**确实还在磁盘上**的;用户自己删掉的不再显示)。 */
142
+ export function listArchived(db) {
143
+ if (!db) return [];
144
+ let rows = [];
145
+ try { rows = getKv(db, ARCHIVES_KEY, []) ?? []; } catch { return []; }
146
+ if (!Array.isArray(rows)) return [];
147
+ return rows
148
+ .filter((x) => x && typeof x.dir === 'string' && existsSync(x.dir))
149
+ .sort((a, b) => Number(b.at ?? 0) - Number(a.at ?? 0));
150
+ }
151
+
152
+ /**
153
+ * 删掉一份留档。只删**记录里登记过**的路径 —— 不接任意路径进来,
154
+ * 免得这个接口变成「删本机任何目录」。
155
+ */
156
+ export async function removeArchived(db, dir) {
157
+ const target = resolve(String(dir ?? ''));
158
+ const hit = listArchived(db).find((x) => resolve(x.dir) === target);
159
+ if (!hit) return { ok: false, error: '没有这份留档(可能已经删掉了)' };
160
+ try {
161
+ await rm(hit.dir, { recursive: true, force: true });
162
+ } catch (error) {
163
+ return { ok: false, error: `删不掉:${error instanceof Error ? error.message : String(error)}` };
164
+ }
165
+ try { setKv(db, ARCHIVES_KEY, listArchived(db).filter((x) => resolve(x.dir) !== target)); }
166
+ catch { /* 记录没清掉也不影响:下次 list 会因为目录不存在而不显示 */ }
167
+ return { ok: true };
168
+ }
169
+
170
+ /**
171
+ * 校验用户填的目录。返回 `''` = 可接受,否则是给人看的错误文案。
172
+ *
173
+ * 纯函数,路由与测试共用 —— 不然改完规则测不到接线。
174
+ */
175
+ export function checkDataDir(value, current) {
176
+ const raw = String(value ?? '').trim();
177
+ if (raw === '') return ''; // 空 = 用默认,永远合法
178
+ if (!isAbsolute(raw)) return '请填完整路径,比如 D:\fish-soul-data';
179
+ const next = resolve(raw);
180
+ const cur = resolve(String(current ?? ''));
181
+ if (next === cur) return ''; // 没变,允许(保存等于什么都没做)
182
+ // 套娃拦截:新目录在当前目录里面(或反过来)会让复制把源也复制进去,无限膨胀。
183
+ // resolve 后的根目录(`D:\`)自带尾分隔符,再拼一个就永远匹配不上。
184
+ if (cur !== '') {
185
+ const c = cur.endsWith(sep) ? cur : cur + sep;
186
+ const n = next.endsWith(sep) ? next : next + sep;
187
+ if (n.startsWith(c) || c.startsWith(n)) return '不能和当前数据目录互相嵌套,换个平级的路径';
188
+ }
189
+ return '';
190
+ }
package/lib/db.js CHANGED
@@ -8,7 +8,7 @@
8
8
  * - person 自动注册走 ON CONFLICT(qq_uin) 原子 Upsert(审查 #05)。
9
9
  */
10
10
  import { DatabaseSync } from 'node:sqlite';
11
- import { mkdirSync } from 'node:fs';
11
+ import { mkdirSync, readFileSync } from 'node:fs';
12
12
  import { homedir } from 'node:os';
13
13
  import { basename, dirname, join, resolve } from 'node:path';
14
14
 
@@ -24,8 +24,35 @@ export function dshHome() {
24
24
  return basename(resolved) === 'fish-soul' ? dirname(resolved) : resolved;
25
25
  }
26
26
 
27
+ /**
28
+ * 用户指定的数据目录(设置页填的,null = 没配、跟着 `$DSH_HOME` 走)。
29
+ *
30
+ * 为什么要缓存而不是每次读配置:`fishSoulDir()` 在 12 个模块的构造期就被调用
31
+ * (浏览器 profile、cookie、人格卡、表情缓存…),逐个改成传参等于改一遍架构。
32
+ * 启动时 `ensureDataDir()` 先把它钉下来,之后所有人读到同一个值。
33
+ * ⚠️ 必须在 `openDatabase()` 之前钉好,否则库开在旧位置、别的文件写在新位置。
34
+ * ⚠️ 缓存的是**用户配置值**,不是最终路径 —— 最终路径每次由 `dshHome()` 现拼,
35
+ * 这样测试里改 `DSH_HOME` 仍然生效(否则 `test/smoke.mjs` 那种逐用例换 home 的写法会串)。
36
+ */
37
+ let userDataDir = null;
38
+
39
+ /** 设置页填的目录(读配置文件本身,不经 schema:这个键要在建库之前就可用)。空 = 用默认。 */
40
+ export function configuredDataDir() {
41
+ try {
42
+ const text = readFileSync(configPath(), 'utf8').replace(/^\uFEFF/, '');
43
+ const value = JSON.parse(text);
44
+ const raw = String(value?.dataDir ?? '').trim();
45
+ return raw === '' ? null : resolve(raw);
46
+ } catch { return null; }
47
+ }
48
+
49
+ /** 钉下用户选的数据目录(`null` = 回到默认)。搬家的最终位置由 data-dir.js 算好再传进来。 */
50
+ export function setActiveDataDir(dir) {
51
+ userDataDir = dir === null ? null : resolve(String(dir));
52
+ }
53
+
27
54
  export function fishSoulDir() {
28
- return join(dshHome(), 'fish-soul');
55
+ return userDataDir ?? join(dshHome(), 'fish-soul');
29
56
  }
30
57
 
31
58
  export function configPath() {
@@ -19,7 +19,7 @@
19
19
  */
20
20
  import { createHash } from 'node:crypto';
21
21
  import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';
22
- import { dshHome } from './db.js';
22
+ import { fishSoulDir } from './db.js';
23
23
  import { join } from 'node:path';
24
24
  import { generateABogus } from './vendor/douyin-bogus.js';
25
25
  import { sessionHealth } from './session-health.js';
@@ -99,7 +99,7 @@ export function aBogusSignature({ query, body = '', userAgent = CHROME_UA, scree
99
99
 
100
100
  /** cookie 文件位置(和插件其它数据放一起,不进仓库;跟着 DSH_HOME 走,测试才能隔离)。 */
101
101
  export function douyinCookiePath() {
102
- return join(dshHome(), 'fish-soul', 'douyin-cookie.json');
102
+ return join(fishSoulDir(), 'douyin-cookie.json');
103
103
  }
104
104
 
105
105
  /**
package/lib/index.js CHANGED
@@ -17,7 +17,7 @@ import {
17
17
  openDatabase, configPath, fishSoulDir, resolveOrCreatePerson, resolveOrCreateBiliPerson,
18
18
  findPersonByQq, findPersonByBili, findPersonByDouyin, readVecMeta, getKv, setKv, ensureMasterPerson
19
19
  } from './db.js';
20
- import { WeeklyCompressor } from './weekly.js';
20
+ import { WeeklyCompressor } from './weekly.js'; import { ensureDataDir, importArchives } from './data-dir.js';
21
21
  import { MemoryArchive } from './storage.js';
22
22
  import { ChatArchive } from './chat-archive.js';
23
23
  import { formatChatSearchRows } from './chat-archive-fts.js';
@@ -231,11 +231,11 @@ async function startup(ctx, config, { log, gate }) {
231
231
  });
232
232
 
233
233
  step(STARTUP_STEPS[0]);
234
- // ── 底座 ──
234
+ let archivedDir = ''; try { archivedDir = (await ensureDataDir({ log })).archived ?? ''; } catch { /* 已回退,原因已记 */ }
235
235
  // 设置页选了「恢复到这份」:打开库之前换上去(当前的库先另存)
236
236
  let restored = null;
237
237
  try { restored = applyPendingRestore({ log }); } catch (error) { log('error', `[fish-soul] 恢复备份失败,继续用原来的库:${String(error instanceof Error ? error.message : error)}`); }
238
- const db = openDatabase();
238
+ const db = openDatabase(); if (archivedDir !== '') importArchives(db, [archivedDir]);
239
239
  if (restored !== null) setKv(db, 'backup.restored', restored);
240
240
  ctx.effect(() => () => { try { db.close(); } catch { /* 已关闭 */ } }, 'dsh-fish-soul: db');
241
241
  // 虚拟钟从上次快照续走(加速验收中途重启不倒退)
@@ -7,6 +7,8 @@
7
7
  * - 聊天记录导入:预览 → 开始 → 进度 → 取消。
8
8
  */
9
9
  import { getProfile, setProfile, getKv } from './db.js';
10
+ import { checkDataDir, removeArchived } from './data-dir.js';
11
+ import { resolve } from 'node:path';
10
12
  import { tokenizeForBm25 } from './segment.js';
11
13
  import { platformOf } from './gateway.js';
12
14
  import { STAGES, PROFILE_FIELDS, stageBase, effectiveAffinity, getMood, mergeProfileFields, digestConfig } from './soul-memory.js';
@@ -233,6 +235,24 @@ export async function handleSoulRoute({ method, path, url, req, res, send, readB
233
235
  for(const k of ['warnMB','freeMB']) if(b[k]!==undefined) { const n=Number(b[k]);if(!Number.isFinite(n)||n<50||n>1048576){send(200,{ok:false,error:'阈值须在 50–1048576 MB'});return true;}patch[k]=Math.floor(n); }
234
236
  saveConfig({storage:patch});send(200,storage?.state() ?? {ok:false,error:'存档未启动'});return true;
235
237
  }
238
+ // 删掉搬家留下的旧目录(只认记录里登记过的那几个,不接受任意路径)
239
+ if(path === '/storage/archived/delete' && post) {
240
+ if (!guard()) return true; const b=await body();
241
+ const r = await removeArchived(db, String(b.dir ?? ''));
242
+ send(200, r.ok ? (storage?.state() ?? { ok: true }) : { ok: false, error: r.error });
243
+ return true;
244
+ }
245
+ // 换数据目录:只写配置,真正的搬家在下次启动时做(运行中的库文件和浏览器 profile 搬不动)
246
+ if(path === '/storage/datadir' && post) {
247
+ if (!guard()) return true; const b=await body();
248
+ const current = storage?.state?.().dataDir ?? '';
249
+ const bad = checkDataDir(b.dir, current);
250
+ if (bad !== '') { send(200,{ok:false,error:bad}); return true; }
251
+ const value = String(b.dir ?? '').trim();
252
+ saveConfig({ dataDir: value === '' ? '' : resolve(value) });
253
+ send(200,{ok:true, dataDir: value === '' ? '' : resolve(value), restart: true});
254
+ return true;
255
+ }
236
256
  if(path === '/storage/snapshot' && post) { if(!guard())return true;send(200,storage?await storage.snapshot({force:true}):{ok:false,error:'存档未启动'});return true; }
237
257
  if(path === '/storage/restore' && post) {if(!guard())return true;const b=await body();send(200,storage&&backup?await storage.stageRestore(String(b.file??''),backup):{ok:false,error:'存档未启动'});return true;}
238
258
  if(path === '/storage/delete' && post) {if(!guard())return true;const b=await body();send(200,storage?.remove(String(b.file??''))??{ok:false,error:'存档未启动'});return true;}
package/lib/storage.js CHANGED
@@ -5,8 +5,9 @@ import { createGzip, createGunzip } from 'node:zlib';
5
5
  import { createHash, randomBytes } from 'node:crypto';
6
6
  import { DatabaseSync } from 'node:sqlite';
7
7
  import { join } from 'node:path';
8
- import { fishSoulDir, getKv, setKv } from './db.js';
8
+ import { dshHome, fishSoulDir, getKv, setKv } from './db.js';
9
9
  import { backupDir } from './backup.js';
10
+ import { listArchived } from './data-dir.js';
10
11
  import { stampLocal } from './time-util.js';
11
12
  const MB=1024*1024, WEEK=7*86400000, DEFAULT_KEEP=10;
12
13
  const ARCHIVE=/^memory-\d{8}-\d{6}-[a-f0-9]{8}\.db\.gz$/;
@@ -36,7 +37,7 @@ export class MemoryArchive {
36
37
  SUM(CASE WHEN kind<>'weekly' AND (importance>=3 OR created_at<=?) THEN 1 ELSE 0 END) longTerm
37
38
  FROM memory WHERE character_id='feiyu' AND status='active' AND valid_to IS NULL`).get(now-7*86400000,now-7*86400000);
38
39
  const tiers={weekly:Number(t.weekly||0),recent:Number(t.recent||0),longTerm:Number(t.longTerm||0)};
39
- return {ok:true,...cfg,databaseBytes,archivesBytes,backupsBytes,chatBytes,freeBytes,usedBytes:used,warning:used>=cfg.warnMB*MB || (freeBytes!==null&&freeBytes<cfg.freeMB*MB),files,last:getKv(this.db,'archive.last',null),error:this.lastError,running:this.running,tiers,budget:{...this.budget}};
40
+ return {ok:true,...cfg,dataDir:fishSoulDir(),defaultDataDir:join(dshHome(),'fish-soul'),archived:listArchived(this.db),databaseBytes,archivesBytes,backupsBytes,chatBytes,freeBytes,usedBytes:used,warning:used>=cfg.warnMB*MB || (freeBytes!==null&&freeBytes<cfg.freeMB*MB),files,last:getKv(this.db,'archive.last',null),error:this.lastError,running:this.running,tiers,budget:{...this.budget}};
40
41
  }
41
42
  noteBudget(used,budget,truncated) { if(!(budget>0))return;const ratio=Math.max(0,used/budget);this.budget.samples++;this.budget.lastRatio=Math.round(ratio*100)/100;this.budget.consecutive=truncated||ratio>=0.9?this.budget.consecutive+1:0; }
42
43
  async snapshot({force=false, minAgeMs=5*60_000}={}) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-fish-soul",
3
- "version": "0.19.25",
3
+ "version": "0.19.26",
4
4
  "description": "鱼 · 人格、按人记忆(可纠正、有印象、能导入旧聊天记录)、日程自走与主动开口,直连 SnowLuma 收发 QQ(群里会自己插话),B站 / 抖音小号私信与自己刷视频;按功能选模型并统计用量花费,能听会说 QQ 语音、收藏表情包、学群里的梗,可选上网查;心情影响说话、去 AI 味、每个群的设定、按聊天选模型、每晚写日记、每周记忆存档与可选周记(DSH 插件,单角色 feiyu)",
5
5
  "type": "module",
6
6
  "main": "./lib/index.js",
@@ -64,7 +64,7 @@
64
64
  }
65
65
  },
66
66
  "scripts": {
67
- "test": "node test/check-test-chain.mjs && node test/config-shape-contract.mjs && node test/affected-suites-clean.mjs && node test/new-export-gate-rule.mjs && node test/check-commit-author.mjs && node test/check-docs-version-refs.mjs && node test/affected-suites-test.mjs && node test/check-commit-author-rule.mjs && node test/check-commit-author-wire.mjs && node test/check-docs-version-refs-rule.mjs && node test/check-docs-version-refs-wire.mjs && node test/check-release-version.mjs && node test/wire-helper.mjs && node test/marker-audit.mjs && node test/douyin-send.mjs && node test/douyin-mechanism.mjs && node test/douyin-route.mjs && node test/douyin-adapter.mjs && node test/douyin-contract.mjs && node test/memory-bulk-move.mjs && node test/safe-download.mjs && node test/douyin-exact-id.mjs && node test/douyin-pb-init.mjs && node test/douyin-conversation.mjs && node test/douyin-inbox.mjs && node test/douyin-quarantine.mjs && node test/douyin-send-target.mjs && node test/douyin-send-exclusive.mjs && node test/douyin-gap-dedupe.mjs && node test/douyin-message-id-dedupe.mjs && node test/douyin-push-poll-dedupe.mjs && node test/douyin-share-card-dedupe.mjs && node test/douyin-share-card-dom.mjs && node test/douyin-inline-share.mjs && node test/douyin-short-link.mjs && node test/douyin-inline-ledger.mjs && node test/douyin-group-chat.mjs && node test/douyin-group-read.mjs && node test/douyin-group-reply.mjs && node test/session-overflow-recycle.mjs && node test/douyin-read-fail-retry.mjs && node test/douyin-read-cache.mjs && node test/douyin-dm-media-conv.mjs && node test/douyin-meta-lines.mjs && node test/douyin-read-fail-retry-poll.mjs && node test/douyin-live-fails.mjs && node test/douyin-inbox-contract.mjs && node test/person-attribution.mjs && node test/memory-owner-reassign.mjs && node test/douyin-poll-and-timer-safety.mjs && node test/p2-limits.mjs && node test/resource-safety.mjs && node test/leftover-edge-cases.mjs && node test/douyin-master-person-merge.mjs && node test/douyin-master-uid.mjs && node test/douyin-identity-e2e.mjs && node test/douyin-note-upload-poll.mjs && node test/douyin-post-jobs.mjs && node test/douyin-video-post.mjs && node test/douyin-video-trigger.mjs && node test/douyin-video-driver.mjs && node test/retrieval-filtered-vectors.mjs && node test/security-boundaries.mjs && node test/douyin-cdp-cursor.mjs && node test/douyin-nav-timeout.mjs && node test/persona-isolation.mjs && node test/prompts.mjs && node test/prompts-route.mjs && node test/diary-topics-217.mjs && node test/smoke.mjs && node test/life-context-interaction.mjs && node test/life-clock-refresh.mjs && node test/browser-launch-early-exit.mjs && node test/douyin-browser.mjs && node test/douyin-crash-restore.mjs && node test/douyin-page-alive.mjs && node test/douyin-eval-timeout.mjs && node test/douyin-bridge-timeout.mjs && node test/douyin-goto-budget.mjs && node test/douyin-music.mjs && node test/douyin-ax-button.mjs && node test/startup-gate.mjs && node test/outbox.mjs && node test/import-coverage.mjs && node test/update-check.mjs && node test/issue-fixes.mjs && node test/import-resume.mjs && node test/maibot-extras.mjs && node test/slang-global.mjs && node test/worldinfo.mjs && node test/memory-bulk.mjs && node test/memory-tiers.mjs && node test/retrieval-tier-weights.mjs && node test/retrieval-tier-weights-route.mjs && node test/memory-weekly.mjs && node test/issue-98-self-archive.mjs && node test/issue-99-memory-order.mjs && node test/issue-115-memory-date.mjs && node test/issue-119-memory-page.mjs && node test/issue-125-memory-filter.mjs && node test/issue-78-diagnostic.mjs && node test/memory-storage.mjs && node test/memory-storage-restore.mjs && node test/backup-restore.mjs && node test/douyin-group.mjs && node test/review-fixes.mjs && node test/at-reads-video.mjs && node test/search-source.mjs && node test/followups.mjs && node test/detail-config.mjs && node test/qq-send-any-image.mjs && node test/qq-read-attachment.mjs && node test/qq-batch-window.mjs && node test/llm-roomy-budget.mjs && node test/llm-failure-backoff.mjs && node test/llm-budget-and-social-backoff.mjs && node test/comment-video.mjs && node test/frames.mjs && node test/face-name.mjs && node test/comment-reply.mjs && node test/chat-comment.mjs && node test/at-target.mjs && node test/quota-caps.mjs && node test/client-lint.mjs && node test/client-panels.mjs && node test/dsh-desktop.mjs && node test/dsh-desktop-as-master.mjs && node test/desktop-as-master-switch.mjs && node test/group-mention-only.mjs && node test/qq-private-allowlist.mjs && node test/issue-59-interject.mjs && node test/issue-59-diagnose.mjs && node test/diag-douyin-running.mjs && node test/sticker-backfill.mjs && node test/issue-118-sticker-diagnostics.mjs && node test/sticker-manage.mjs && node test/bili-emotes.mjs && node test/qq-outbound-sanitize.mjs && node test/repeat-guard-cross-turn.mjs && node test/voice-paragraph-split.mjs && node test/voice-paragraph-split-wire.mjs && node test/person-delete.mjs && node test/qq-group-admin.mjs && node test/douyin-recovery.mjs && node test/session-preset.mjs && node test/qq-connect-error.mjs && node test/douyin-comment-bridge.mjs && node test/douyin-comment-write-unknown.mjs && node test/douyin-reply-verify-status.mjs && node test/bili-comment-emoji.mjs && node test/douyin-state-echo.mjs && node test/issue-75-proactive.mjs && node test/issue-76-capability.mjs && node test/douyin-http-browse.mjs && node test/douyin-verify-backoff.mjs && node test/douyin-digg-bridge.mjs && node test/memory-evidence-transcript.mjs && node test/chat-archive-default.mjs && node test/issue-113-desktop-archive.mjs && node test/dream-transcript-wire.mjs && node test/douyin-frames-collect.mjs && node test/master-qq-uin-rebind.mjs && node test/douyin-session-health.mjs && node test/douyin-delivered.mjs && node test/douyin-card-share.mjs && node test/douyin-push-drop.mjs && node test/douyin-stranger-dm.mjs && node test/douyin-uid-binding.mjs && node test/image-webp-fallback.mjs && node test/douyin-emoji-fallback.mjs && node test/douyin-panel-width-threshold.mjs && node test/douyin-emoji-panel-close.mjs && node test/relay-other-platform.mjs && node test/relay-to-friend.mjs && node test/relay-sender-id.mjs && node test/dsh-home-guard.mjs && node test/relay-config-route.mjs && node test/share-fallback.mjs && node test/share-quota-refund.mjs && node test/issue-101-voice-files.mjs && node test/voice-volcengine.mjs && node test/voice-minimax-dashscope.mjs && node test/bili-switch-persist.mjs && node test/cross-channel-context.mjs && node test/reply-target.mjs && node test/shared-session.mjs && node test/outbound-quote-and-images.mjs && node test/sticker-bracket-fallback.mjs && node test/dream-transcript-scope.mjs && node test/memory-date-context.mjs && node test/memory-time-dedupe.mjs && node test/context-source-platform.mjs && node test/memory-source-label.mjs && node test/issue-239-maxtokens-wire.mjs && node test/issue-239-maxtokens.mjs && node test/pending-delivery.mjs && node test/recall-window-78.mjs && node test/memory-recall-recent-78.mjs && node test/client-syntax.mjs && node test/diag-log.mjs && node test/check-rings.mjs && node test/release-workflow.mjs && node test/sticker-import-gif.mjs && node test/sticker-real-gif.mjs && node test/sticker-upload-binary.mjs && node test/sticker-vision-tags.mjs && node test/sticker-manual-tags.mjs && node test/sticker-auto-name.mjs && node test/self-update.mjs && node test/group-list.mjs && node test/douyin-inbox-noise.mjs && node test/douyin-inbox-diag.mjs && node test/douyin-inbox-stuck.mjs && node test/reply-window.mjs && node test/douyin-sticker-heuristic.mjs && node test/douyin-image-boundary.mjs && node test/media-image-boundary.mjs && node test/douyin-comment-identity-cid.mjs && node test/qq-mention-only-echo.mjs && node test/bili-panel-pagination.mjs && node test/bili-comment-link.mjs && node test/bili-comment-visibility.mjs && node test/bili-allowlist.mjs && node test/douyin-master-uid-mismatch.mjs && node test/vision-model.mjs && node test/image-inbound-fail.mjs && node test/group-backlog-images.mjs && node test/group-master-tag.mjs && node test/check-route-guard.mjs && node test/check-client-imports.mjs && node test/chat-archive-fts.mjs && node test/chat-search-tool.mjs && node test/memory-invalidate-kind.mjs && node test/dream-merge-duplicates.mjs && node test/mood-guard.mjs && node test/time-awareness.mjs && node test/tts-strip-emoji.mjs && node test/session-reset-route.mjs && node test/check-secrets.mjs && node test/check-secrets-nickname.mjs && node test/check-docs-freshness.mjs && node test/check-package-json-format.mjs && node test/wire-limits.mjs && node test/check-chromium-suites.mjs && node test/check-no-stash-scripts.mjs && node test/douyin-video-wire.mjs && node test/douyin-self-uid.mjs && node test/douyin-group-cursor.mjs && node test/douyin-dom-text.mjs && node test/video-gen.mjs && node test/scheduled-tasks.mjs && node test/scheduled-tasks-ui.mjs && node test/douyin-wave12-fixes.mjs && node test/prefetch-vec-await.mjs && node test/wave2-token-optimizations.mjs && node test/wave3-memory-retrieval.mjs && node test/rc5-token-inflation.mjs && node test/pending-surfaced-closure.mjs && node test/memory-digest-retry-239.mjs && node test/issue-244-paragraph-split.mjs && node test/issue-244-cleanout-e2e.mjs && node test/issue-269-qq-split-budget.mjs && node test/voice-mention-guard.mjs && node test/issue-247-media-url.mjs && node test/check-fork-pr-gate.mjs && node test/check-pr-hygiene.mjs && node test/check-import-cycles.mjs && node test/check-file-size-budget.mjs && node test/check-file-size-budget-rule.mjs && node test/check-silent-catch.mjs && node test/check-silent-catch-rule.mjs && node test/douyin-cookie-refresh.mjs && node test/douyin-back-to-list.mjs && node test/douyin-fastpath.mjs && node test/douyin-post-id-backfill.mjs && node test/douyin-canary-panel.mjs && node test/douyin-note-text.mjs && node test/bili-playback.mjs && node test/prompts-diary.mjs && node test/interject-interest.mjs && node test/transcript-master-only.mjs && node test/usage-visualization.mjs",
67
+ "test": "node test/check-test-chain.mjs && node test/config-shape-contract.mjs && node test/affected-suites-clean.mjs && node test/new-export-gate-rule.mjs && node test/check-commit-author.mjs && node test/check-docs-version-refs.mjs && node test/affected-suites-test.mjs && node test/check-commit-author-rule.mjs && node test/check-commit-author-wire.mjs && node test/check-docs-version-refs-rule.mjs && node test/check-docs-version-refs-wire.mjs && node test/check-release-version.mjs && node test/wire-helper.mjs && node test/marker-audit.mjs && node test/douyin-send.mjs && node test/douyin-mechanism.mjs && node test/douyin-route.mjs && node test/douyin-adapter.mjs && node test/douyin-contract.mjs && node test/memory-bulk-move.mjs && node test/safe-download.mjs && node test/douyin-exact-id.mjs && node test/douyin-pb-init.mjs && node test/douyin-conversation.mjs && node test/douyin-inbox.mjs && node test/douyin-quarantine.mjs && node test/douyin-send-target.mjs && node test/douyin-send-exclusive.mjs && node test/douyin-gap-dedupe.mjs && node test/douyin-message-id-dedupe.mjs && node test/douyin-push-poll-dedupe.mjs && node test/douyin-share-card-dedupe.mjs && node test/douyin-share-card-dom.mjs && node test/douyin-inline-share.mjs && node test/douyin-short-link.mjs && node test/douyin-inline-ledger.mjs && node test/douyin-group-chat.mjs && node test/douyin-group-read.mjs && node test/douyin-group-reply.mjs && node test/session-overflow-recycle.mjs && node test/douyin-read-fail-retry.mjs && node test/douyin-read-cache.mjs && node test/douyin-dm-media-conv.mjs && node test/douyin-meta-lines.mjs && node test/douyin-read-fail-retry-poll.mjs && node test/douyin-live-fails.mjs && node test/douyin-inbox-contract.mjs && node test/person-attribution.mjs && node test/memory-owner-reassign.mjs && node test/douyin-poll-and-timer-safety.mjs && node test/p2-limits.mjs && node test/resource-safety.mjs && node test/leftover-edge-cases.mjs && node test/douyin-master-person-merge.mjs && node test/douyin-master-uid.mjs && node test/douyin-identity-e2e.mjs && node test/douyin-note-upload-poll.mjs && node test/douyin-post-jobs.mjs && node test/douyin-video-post.mjs && node test/douyin-video-trigger.mjs && node test/douyin-video-driver.mjs && node test/retrieval-filtered-vectors.mjs && node test/security-boundaries.mjs && node test/douyin-cdp-cursor.mjs && node test/douyin-nav-timeout.mjs && node test/persona-isolation.mjs && node test/prompts.mjs && node test/prompts-route.mjs && node test/diary-topics-217.mjs && node test/smoke.mjs && node test/life-context-interaction.mjs && node test/life-clock-refresh.mjs && node test/browser-launch-early-exit.mjs && node test/douyin-browser.mjs && node test/douyin-crash-restore.mjs && node test/douyin-page-alive.mjs && node test/douyin-eval-timeout.mjs && node test/douyin-bridge-timeout.mjs && node test/douyin-goto-budget.mjs && node test/douyin-music.mjs && node test/douyin-ax-button.mjs && node test/startup-gate.mjs && node test/outbox.mjs && node test/import-coverage.mjs && node test/update-check.mjs && node test/issue-fixes.mjs && node test/import-resume.mjs && node test/maibot-extras.mjs && node test/slang-global.mjs && node test/worldinfo.mjs && node test/memory-bulk.mjs && node test/memory-tiers.mjs && node test/retrieval-tier-weights.mjs && node test/retrieval-tier-weights-route.mjs && node test/memory-weekly.mjs && node test/issue-98-self-archive.mjs && node test/issue-99-memory-order.mjs && node test/issue-115-memory-date.mjs && node test/issue-119-memory-page.mjs && node test/issue-125-memory-filter.mjs && node test/issue-78-diagnostic.mjs && node test/memory-storage.mjs && node test/memory-storage-restore.mjs && node test/backup-restore.mjs && node test/douyin-group.mjs && node test/review-fixes.mjs && node test/at-reads-video.mjs && node test/search-source.mjs && node test/followups.mjs && node test/detail-config.mjs && node test/qq-send-any-image.mjs && node test/qq-read-attachment.mjs && node test/qq-batch-window.mjs && node test/llm-roomy-budget.mjs && node test/llm-failure-backoff.mjs && node test/llm-budget-and-social-backoff.mjs && node test/comment-video.mjs && node test/frames.mjs && node test/face-name.mjs && node test/comment-reply.mjs && node test/chat-comment.mjs && node test/at-target.mjs && node test/quota-caps.mjs && node test/client-lint.mjs && node test/client-panels.mjs && node test/dsh-desktop.mjs && node test/dsh-desktop-as-master.mjs && node test/desktop-as-master-switch.mjs && node test/group-mention-only.mjs && node test/qq-private-allowlist.mjs && node test/issue-59-interject.mjs && node test/issue-59-diagnose.mjs && node test/diag-douyin-running.mjs && node test/sticker-backfill.mjs && node test/issue-118-sticker-diagnostics.mjs && node test/sticker-manage.mjs && node test/bili-emotes.mjs && node test/qq-outbound-sanitize.mjs && node test/repeat-guard-cross-turn.mjs && node test/voice-paragraph-split.mjs && node test/voice-paragraph-split-wire.mjs && node test/person-delete.mjs && node test/qq-group-admin.mjs && node test/douyin-recovery.mjs && node test/session-preset.mjs && node test/qq-connect-error.mjs && node test/douyin-comment-bridge.mjs && node test/douyin-comment-write-unknown.mjs && node test/douyin-reply-verify-status.mjs && node test/bili-comment-emoji.mjs && node test/douyin-state-echo.mjs && node test/issue-75-proactive.mjs && node test/issue-76-capability.mjs && node test/douyin-http-browse.mjs && node test/douyin-verify-backoff.mjs && node test/douyin-digg-bridge.mjs && node test/memory-evidence-transcript.mjs && node test/chat-archive-default.mjs && node test/issue-113-desktop-archive.mjs && node test/dream-transcript-wire.mjs && node test/douyin-frames-collect.mjs && node test/master-qq-uin-rebind.mjs && node test/douyin-session-health.mjs && node test/douyin-delivered.mjs && node test/douyin-card-share.mjs && node test/douyin-push-drop.mjs && node test/douyin-stranger-dm.mjs && node test/douyin-uid-binding.mjs && node test/image-webp-fallback.mjs && node test/douyin-emoji-fallback.mjs && node test/douyin-panel-width-threshold.mjs && node test/douyin-emoji-panel-close.mjs && node test/relay-other-platform.mjs && node test/relay-to-friend.mjs && node test/relay-sender-id.mjs && node test/data-dir.mjs && node test/data-dir-panel.mjs && node test/dsh-home-guard.mjs && node test/relay-config-route.mjs && node test/share-fallback.mjs && node test/share-quota-refund.mjs && node test/issue-101-voice-files.mjs && node test/voice-volcengine.mjs && node test/voice-minimax-dashscope.mjs && node test/bili-switch-persist.mjs && node test/cross-channel-context.mjs && node test/reply-target.mjs && node test/shared-session.mjs && node test/outbound-quote-and-images.mjs && node test/sticker-bracket-fallback.mjs && node test/dream-transcript-scope.mjs && node test/memory-date-context.mjs && node test/memory-time-dedupe.mjs && node test/context-source-platform.mjs && node test/memory-source-label.mjs && node test/issue-239-maxtokens-wire.mjs && node test/issue-239-maxtokens.mjs && node test/pending-delivery.mjs && node test/recall-window-78.mjs && node test/memory-recall-recent-78.mjs && node test/client-syntax.mjs && node test/diag-log.mjs && node test/check-rings.mjs && node test/release-workflow.mjs && node test/sticker-import-gif.mjs && node test/sticker-real-gif.mjs && node test/sticker-upload-binary.mjs && node test/sticker-vision-tags.mjs && node test/sticker-manual-tags.mjs && node test/sticker-auto-name.mjs && node test/self-update.mjs && node test/group-list.mjs && node test/douyin-inbox-noise.mjs && node test/douyin-inbox-diag.mjs && node test/douyin-inbox-stuck.mjs && node test/reply-window.mjs && node test/douyin-sticker-heuristic.mjs && node test/douyin-image-boundary.mjs && node test/media-image-boundary.mjs && node test/douyin-comment-identity-cid.mjs && node test/qq-mention-only-echo.mjs && node test/bili-panel-pagination.mjs && node test/bili-comment-link.mjs && node test/bili-comment-visibility.mjs && node test/bili-allowlist.mjs && node test/douyin-master-uid-mismatch.mjs && node test/vision-model.mjs && node test/image-inbound-fail.mjs && node test/group-backlog-images.mjs && node test/group-master-tag.mjs && node test/check-route-guard.mjs && node test/check-client-imports.mjs && node test/chat-archive-fts.mjs && node test/chat-search-tool.mjs && node test/memory-invalidate-kind.mjs && node test/dream-merge-duplicates.mjs && node test/mood-guard.mjs && node test/time-awareness.mjs && node test/tts-strip-emoji.mjs && node test/session-reset-route.mjs && node test/check-secrets.mjs && node test/check-secrets-nickname.mjs && node test/check-docs-freshness.mjs && node test/check-package-json-format.mjs && node test/wire-limits.mjs && node test/check-chromium-suites.mjs && node test/check-no-stash-scripts.mjs && node test/douyin-video-wire.mjs && node test/douyin-self-uid.mjs && node test/douyin-group-cursor.mjs && node test/douyin-dom-text.mjs && node test/video-gen.mjs && node test/scheduled-tasks.mjs && node test/scheduled-tasks-ui.mjs && node test/douyin-wave12-fixes.mjs && node test/prefetch-vec-await.mjs && node test/wave2-token-optimizations.mjs && node test/wave3-memory-retrieval.mjs && node test/rc5-token-inflation.mjs && node test/pending-surfaced-closure.mjs && node test/memory-digest-retry-239.mjs && node test/issue-244-paragraph-split.mjs && node test/issue-244-cleanout-e2e.mjs && node test/issue-269-qq-split-budget.mjs && node test/voice-mention-guard.mjs && node test/issue-247-media-url.mjs && node test/check-fork-pr-gate.mjs && node test/check-pr-hygiene.mjs && node test/check-import-cycles.mjs && node test/check-file-size-budget.mjs && node test/check-file-size-budget-rule.mjs && node test/check-silent-catch.mjs && node test/check-silent-catch-rule.mjs && node test/douyin-cookie-refresh.mjs && node test/douyin-back-to-list.mjs && node test/douyin-fastpath.mjs && node test/douyin-post-id-backfill.mjs && node test/douyin-canary-panel.mjs && node test/douyin-note-text.mjs && node test/bili-playback.mjs && node test/prompts-diary.mjs && node test/interject-interest.mjs && node test/transcript-master-only.mjs && node test/usage-visualization.mjs",
68
68
  "test:douyin": "node test/parallel.mjs 4 --only douyin",
69
69
  "test:fast": "node test/parallel.mjs 4 --skip \"douyin|browser\"",
70
70
  "typecheck": "npx --yes -p typescript tsc -p tsconfig.check.json"