dsh-fish-soul 0.18.22 → 0.18.24

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.18.22**。
5
+ DSH 插件(单角色 `feiyu`)。版本 **0.18.24**。
6
6
 
7
7
  QQ 交流群:**1125962189**
8
8
 
@@ -205,10 +205,11 @@ export function occurrenceIndexes(prints) {
205
205
  * 别为了省事把 ② 也降级到 ③ —— 那会让「同一天说两次『在』」第二句收不到。
206
206
  *
207
207
  * @param {object} m 入站消息(可能带 `time` / `seq`)
208
- * @param {{print?: string, occ?: number, fallbackTime?: number, dayKey?: string}} ctx
208
+ * @param {{occ?: number, fallbackTime?: number, dayKey?: string}} ctx
209
209
  * @returns {{timeMs: number, messageId: string}}
210
210
  */
211
- export function messageIdFor(m, { print = '', occ = 0, fallbackTime = Date.now(), dayKey = '' } = {}) {
211
+ export function messageIdFor(m, { occ = 0, fallbackTime = Date.now(), dayKey = '' } = {}) {
212
+ const print = messageFingerprint((m?.type || m?.isText || m?.kind === 7) ? { ...m, type: m.type ?? 'text' } : m);
212
213
  const rawTime = Number(m?.time);
213
214
  const hasTime = rawTime > 1e12 || rawTime > 1e9;
214
215
  const timeMs = rawTime > 1e12 ? rawTime : rawTime > 1e9 ? rawTime * 1000 : fallbackTime;
@@ -1352,14 +1353,12 @@ export class DouyinChannel {
1352
1353
  // 以前这里是「没有时间就用内容指纹」—— 同一天发两次同一张表情会撞键(第二次收不到),
1353
1354
  // 而纯 Date.now() 又会让同一条推送重发时新入库一遍。两头的病都躲不掉。
1354
1355
  const dayKey = new Date().toISOString().slice(0, 10);
1355
- const pushOcc = new Map();
1356
- for (const m of fresh) {
1356
+ const occurrences = occurrenceIndexes(fresh.map(messageFingerprint));
1357
+ for (const [i, m] of fresh.entries()) {
1357
1358
  // 指纹用「内容 + 推送内出现次数」:推送帧重放同一批时 occ 一致 ⇒ ID 一致(去重);
1358
1359
  // 同一批里真有两张一模一样的图 ⇒ occ 递增 ⇒ ID 不同(都收得到)。
1359
- const contentKey = `push-${convId}-${sha1(`${m.text ?? ''}|${m.type ?? ''}|${m.media?.src ?? m.media?.data ?? ''}`).slice(0, 16)}`;
1360
- const n = pushOcc.get(contentKey) ?? 0;
1361
- pushOcc.set(contentKey, n + 1);
1362
- const { timeMs, messageId } = messageIdFor(m, { print: contentKey, occ: n, dayKey });
1360
+ const contentKey = messageFingerprint(m);
1361
+ const { timeMs, messageId } = messageIdFor(m, { occ: occurrences[i], dayKey });
1363
1362
  // 轮询路读的时候这条已经在窗口里了 → 已经收过,别重复收
1364
1363
  if (skipBefore > 0 && timeMs <= skipBefore) continue;
1365
1364
  const norm = normalizeDouyinMessage(m, { name, timeMs, messageId, identity, convId });
@@ -1916,10 +1915,10 @@ export class DouyinChannel {
1916
1915
  // ③ 两者都没有(极少) → `<指纹>-<自然日>-<occ>`(保底不重复入库)
1917
1916
  const dayKey = new Date().toISOString().slice(0, 10);
1918
1917
  // 同一指纹在这次读到的列表里是第几次出现:对方连发同一句话时,没 seq 的 ID 也不会撞
1919
- const occ = occurrenceIndexes(prints);
1918
+ const occ = occurrenceIndexes(msgs.map(messageFingerprint));
1920
1919
  for (const [i, m] of fresh.entries()) {
1921
1920
  const { timeMs, messageId } = messageIdFor(m, {
1922
- print: prints[freshIndexes[i]], occ: occ[freshIndexes[i]], fallbackTime, dayKey,
1921
+ occ: occ[freshIndexes[i]], fallbackTime, dayKey,
1923
1922
  });
1924
1923
  const norm = normalizeDouyinMessage(m, { name, timeMs, messageId, group, members, identity, convId });
1925
1924
  if (norm !== null) { norm.idConfidence = m.seq ? 'platform' : 'heuristic'; normalized.push(norm); }
@@ -30,7 +30,7 @@ import {
30
30
  MESSAGE_URL_RE,
31
31
  wsConversationId as apiWsConversationId,
32
32
  } from './douyin-api.mjs'
33
- import { parseSingleConversation, soleConversationId as soleConvId } from '../../../douyin-conversation.js'
33
+ import { parseSingleConversation, soleConversationId as soleConvId, soleSingleConversationId as soleSingleConvId } from '../../../douyin-conversation.js'
34
34
  import { sleep } from './douyin-util.mjs'
35
35
  import { ensurePanel, enterChat, hasInput } from './douyin-panel.mjs'
36
36
  // 🔴 事件游标必须是 `browser.seq` 的单调序号,不是 `browser.events.length`
@@ -194,7 +194,13 @@ export async function readDMViaApi({ browser, uname = '', limit = 30, scrollBack
194
194
  let captured = await apiDrain(browser)
195
195
  let parsed = null
196
196
 
197
- if (hasPb(captured)) {
197
+ // 🔴 #169:首次接触(target='')时,drain 倒出来的可能是**上一轮读别的会话**
198
+ // (比如主人)留下的响应 —— pickMessages(convId='') 只要求「响应内部唯一
199
+ // 会话」,主人那条完全合格 ⇒ 直接当成本轮结果 ⇒ 叔叔的收件箱从第一条起
200
+ // 就被灌进主人的消息、游标钉死到主人 convId。drain 照做(清掉遗留),
201
+ // 但只有 target 明确时才解析;首次接触的证据只能来自 step ④ 进会话
202
+ // 触发的新响应。
203
+ if (target !== '' && hasPb(captured)) {
198
204
  const me = await apiSelfInfo(browser).catch(() => ({ secUid: '' }))
199
205
  parsed = await fillConvIdFromWs(browser, apiPickMessages(captured, { selfSecUid: me.secUid, convId: target }))
200
206
  const useful = filterUseful(parsed.messages)
@@ -311,16 +317,21 @@ export async function readDMViaApi({ browser, uname = '', limit = 30, scrollBack
311
317
  * 做法:从 hook 抓到的响应里,找唯一一个「会话名 == uname」的会话。
312
318
  * 名字来自会话列表 / 消息里的 senderName,两条路任一命中即可。
313
319
  *
314
- * ⚠️ 接口消息**经常不带 senderName**(空字符串),按名字匹配永远失败 ⇒
315
- * 会话 ID 拿不到 ⇒ 发送前的身份校验永远「不敢发」。所以名字对不上时
316
- * 退到「唯一会话 ID」:会话 ID 本身就是会话身份的证据,不需要昵称背书。
317
- * 多个会话混在一起仍然不猜(返回 '')。
320
+ * ⚠️ #169 起删掉「唯一会话 ID」盲兜底:它不看昵称、不限时间窗,把缓冲里
321
+ * 唯一抓到的会话当成任何目标的 convId(主人/叔叔/群共用主人 convId 的根源)。
322
+ * 昵称对不上就返回 '',调用方按「拿不到身份」处理 —— 宁可拒绝,不猜。
323
+ * 发送路径的兜底走 since 限定的 latestConvIdFromCdp / cdpHasConv(见 currentPeer)。
324
+ *
325
+ * 🔴 传了 `since > 0` 时只认**这个时间点之后**触发的响应:发送快路径刚 enterChat
326
+ * 进目标会话,缓冲里还躺着上一轮读别的会话(主人)留下的响应 —— 那些不是
327
+ * 「当前打开的会话」的证据,采信它就会把主人 convId 报成当前会话(发错窗口)。
318
328
  *
319
329
  * @param {object} browser
320
330
  * @param {string} uname 会话名(昵称)
331
+ * @param {number} [since=0] 只认这个事件序号之后的响应;0 = 不限(读路径首次接触)
321
332
  * @returns {Promise<string>} convId,解析不出来 ''
322
333
  */
323
- async function resolveConvId(browser, uname) {
334
+ async function resolveConvId(browser, uname, since = 0) {
324
335
  const want = String(uname ?? '').trim()
325
336
  if (want === '') return ''
326
337
  // 页面 hook 的缓存经常是空的:字节的安全 SDK 把原始 fetch 存进自己的闭包,
@@ -328,33 +339,40 @@ async function resolveConvId(browser, uname) {
328
339
  // 发送前的身份校验只问这个缓存,于是永远「拿不到会话 ID,不敢发」。
329
340
  // CDP 的 Network 域能看到同一份响应,hook 为空时从那里取。
330
341
  let hits = []
331
- const peeked = await apiPeek(browser).catch(() => [])
332
- hits = (peeked || []).filter((x) => x.kind === 'pb' && MESSAGE_URL_RE.test(String(x.url)))
342
+ // 🔴 since > 0 时跳过 hook 缓冲:那个缓冲没有时间序,只能整份倒出来,
343
+ // 倒出来的必然包含 since 之前的遗留响应(#169 串会话来源之一)。
344
+ if (since <= 0) {
345
+ const peeked = await apiPeek(browser).catch(() => [])
346
+ hits = (peeked || []).filter((x) => x.kind === 'pb' && MESSAGE_URL_RE.test(String(x.url)))
347
+ }
333
348
  if (!hits.length) {
334
- const bodies = await captureImBodies(browser, 0).catch(() => [])
349
+ const bodies = await captureImBodies(browser, since).catch(() => [])
335
350
  hits = bodies.map((c) => ({ url: c.url, kind: 'pb', b64: c.body.toString('base64') }))
336
351
  }
337
352
  const me = await apiSelfInfo(browser).catch(() => ({ secUid: '' }))
338
353
  const found = new Set()
339
- // 每份响应里**唯一**的会话 ID。昵称对不上时的兜底证据:会话 ID 本身就是
340
- // 会话身份的证据(`0:1:<我>:<对方>`),不需要昵称来背书。
341
- const sole = new Set()
342
354
  for (const h of hits) {
343
355
  try {
344
356
  const parsed = apiParseMessages(Buffer.from(h.b64, 'base64'), { selfSecUid: me.secUid })
345
357
  const useful = filterUseful(parsed.messages)
346
- const id = soleConvId(useful)
358
+ // 🔴 #169:证据必须是**单聊** —— 群里的同名发送者不能把群错配成单聊 convId。
359
+ const { id } = soleSingleConvId(useful)
347
360
  if (id === '') continue
348
- sole.add(id)
349
- // 会话名:消息里带的 senderName(对方那一侧的)或会话列表的名字
361
+ // 会话名:消息里带的 senderName(对方那一侧的)
350
362
  const names = useful.map((m) => String(m.senderName ?? '').trim()).filter((n) => n !== '')
351
363
  if (names.includes(want)) found.add(id)
352
364
  } catch { /* 解不开就跳过 */ }
353
365
  }
366
+ // 🔴 #169:删掉「唯一会话 ID」盲兜底。它不看昵称、不限时间窗,把缓冲里唯一
367
+ // 抓到的会话(往往是主人那条单聊)当成**任何**目标的 convId —— 主人/叔叔/群
368
+ // 共用主人 convId 的直接根源(真机:读叔叔时缓冲里只有主人的响应)。
369
+ // 昵称对不上就返回 '',调用方按「拿不到身份」处理:
370
+ // · 读路径 failRead(unread 下一轮绕过熔断重试;推送路早已把 convId 写进
371
+ // 游标,多数首次接触带着 expectConvId 进来,不走这条路);
372
+ // · 发送路径还有 since 限定的 latestConvIdFromCdp / cdpHasConv /
373
+ // 「切走再切回」/ 唯一昵称四道证据,不靠这个兜底。
354
374
  if (found.size === 1) return [...found][0]
355
- // 昵称匹配不上(接口消息经常不带 senderName):唯一会话 ID 就是证据。
356
- // 多个会话混在一起仍然不猜 —— 返回 '',调用方不能退回昵称信任。
357
- return sole.size === 1 ? [...sole][0] : ''
375
+ return ''
358
376
  }
359
377
 
360
378
  /** 把接口解出来的消息整理成和 DOM 路径一致的形状 */
@@ -1567,7 +1585,10 @@ export async function currentPeer({ browser, since = 0 }) {
1567
1585
  const r = await browser.eval(CUR_JS)
1568
1586
  if (!r) return { inChat: false, name: '', convId: '' }
1569
1587
  // 名字不是身份:能反查出会话 ID 就带上,反查不到就留空 —— 调用方据此决定敢不敢发。
1570
- let convId = r.name ? await resolveConvId(browser, r.name).catch(() => '') : ''
1588
+ // 🔴 #169:带上 since —— 只看进这个会话之后触发的响应。不带的话,缓冲里
1589
+ // 上一轮读别的会话(主人)的遗留响应会被当成本会话的证据,把主人 convId
1590
+ // 报成「当前打开的会话」,于是发错窗口。
1591
+ let convId = r.name ? await resolveConvId(browser, r.name, since).catch(() => '') : ''
1571
1592
  // resolveConvId 靠消息里的 senderName 匹配,而接口消息经常不带昵称,匹配不上。
1572
1593
  // 刚 enterChat 进来时,CDP 缓冲里最近的消息响应就是当前会话的。取它的 convId 兜底。
1573
1594
  if (convId === '' && r.inChat) {
package/lib/client.js CHANGED
@@ -1083,11 +1083,11 @@ window.__ModuleLoader__.load({
1083
1083
  }, [subtab]);
1084
1084
  // 虚拟时钟走秒(纯展示)
1085
1085
  react.useEffect(() => {
1086
- if (subtab !== "life") return undefined;
1086
+ if (tab !== "daily" || subtab !== "life") return undefined;
1087
1087
  const timer = setInterval(() => setLife((prev) => prev?.clock?.virtualNowMs
1088
1088
  ? { ...prev, clock: { ...prev.clock, virtualNowMs: prev.clock.virtualNowMs + 1000 * (prev.clock.timeScale ?? 1) } } : prev), 1000);
1089
1089
  return () => clearInterval(timer);
1090
- }, [tab]);
1090
+ }, [tab, subtab]);
1091
1091
 
1092
1092
  react.useEffect(() => {
1093
1093
  let active = true;
@@ -50,7 +50,7 @@ window.__ModuleLoader__.load({
50
50
  return Group({ title: "按功能选模型", className: "fs-model-routes", aside: host ? Muted(`DSH 默认:${providerName(host.provider)} · ${host.model}`) : null },
51
51
  providers.length === 0 && !host ? Row({ title: "可用模型" }, State("warning", "DSH 里还没配模型")) : null,
52
52
  data.lastError ? Row({ title: "上次调用" }, State("error", data.lastError)) : null,
53
- ...(data.features ?? []).map((f) => Row({ title: f.label, key: f.id, meta: f.resolved ? (f.selection ? undefined : `现在用 ${f.resolved.model}`) : "没有可用的模型" },
53
+ ...(data.features ?? []).map((f) => Row({ title: f.label, key: f.id, meta: f.resolved ? (f.selection ? undefined : `现在用 ${f.resolved.model}`) : (f.id === "vision" ? "不启用(图直接给会话模型)" : "没有可用的模型") },
54
54
  Select({ value: f.selection ? `${f.selection.provider}${SEP}${f.selection.model}` : "", "aria-label": f.label, onChange: (e) => pick(f.id, e.target.value) }, ...options(f.selection)))));
55
55
  }
56
56
 
@@ -12,6 +12,7 @@ export function biliConfigSchema(z) {
12
12
  proactive: z.boolean().default(false), // 主动给主人发 B站私信
13
13
  pollSeconds: z.number().default(20),
14
14
  batchMs: z.number().default(3000),
15
+ batchMaxWaitMs: z.number().default(8000),
15
16
  replyWindowMinutes: z.number().default(120), // 超过多久的旧消息只记不回(分钟);默认 120,和 QQ 那边一致
16
17
  shareCard: z.boolean().default(false), // 刷到想分享的视频走原生卡片(默认关)
17
18
  browse: z.object({
@@ -67,6 +68,7 @@ export function douyinConfigSchema(z) {
67
68
  groupReply: z.boolean().default(false), // 抖音群里有人 @ 她 / 叫她名字时回(默认关:群里只看不说)
68
69
  callNames: z.array(z.string()).default([]), // 抖音群里叫她的名字(比如她的抖音昵称);QQ 那边的称呼 / 人格卡名字也算
69
70
  batchMs: z.number().default(3000),
71
+ batchMaxWaitMs: z.number().default(8000),
70
72
  replyWindowMinutes: z.number().default(120), // 超过多久的旧消息只记不回(分钟);默认 120,和 QQ 那边一致
71
73
  shareCard: z.boolean().default(false), // 刷到想分享的视频走原生卡片(默认关)
72
74
  browser: z.object({
@@ -79,7 +79,7 @@ export class DouyinAdapter {
79
79
  groups: Array.isArray(d.groups) ? d.groups.map((x) => String(x).trim()).filter(Boolean) : [],
80
80
  groupReply: d.groupReply === true,
81
81
  callNames: Array.isArray(d.callNames) ? d.callNames.map((x) => String(x).trim()).filter(Boolean) : [],
82
- batchMs: num(d.batchMs, 3000),
82
+ batchMs: num(d.batchMs, 3000), batchMaxWaitMs: num(d.batchMaxWaitMs, 8000),
83
83
  replyWindowMinutes: clampReplyWindow(d.replyWindowMinutes)
84
84
  };
85
85
  }
@@ -17,13 +17,13 @@ import { getKv, setKv } from './db.js';
17
17
  import { tokenizeForBm25 } from './segment.js';
18
18
  import { detail } from './channels/vendor/douyin-bridge/douyin-detail.mjs';
19
19
  import { callBridge, commentBridgeReady, installCommentBridge } from './channels/vendor/douyin-bridge/douyin-comment.js';
20
+ import { resolveDouyinShortLink } from './douyin-short-link.js';
20
21
 
21
22
  const FEED_URL = 'https://www.douyin.com/?recommend=1';
22
23
  const VIDEO_RE = /(?:douyin\.com\/(?:video|note)\/|iesdouyin\.com\/share\/(?:video|note)\/|[?&](?:modal_id|aweme_id|vid)=)(\d{15,20})/g;
23
24
  const SHORT_RE = /https?:\/\/v\.douyin\.com\/[0-9A-Za-z_-]+\/?/g;
24
25
  const DESCRIBE_TTL_MS = 3600_000;
25
26
  const DAY_MS = 86_400_000;
26
- const MOBILE_UA = 'Mozilla/5.0 (iPhone; CPU iPhone OS 17_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.0 Mobile/15E148 Safari/604.1';
27
27
 
28
28
  const oneLine = (s, n) => String(s ?? '').replace(/\s+/g, ' ').replace(/【/g, '〔').replace(/】/g, '〕').trim().slice(0, n);
29
29
  const errText = (e) => String(e instanceof Error ? e.message : e);
@@ -644,20 +644,7 @@ export class DouyinBrowser {
644
644
 
645
645
  /** v.douyin.com 短链 → 视频 id(拿不到返回 '')。 */
646
646
  async resolveShort(url) {
647
- let cur = url;
648
- for (let i = 0; i < 3; i++) {
649
- try {
650
- const res = await this.fetch(cur, { redirect: 'manual', headers: { 'User-Agent': MOBILE_UA }, signal: AbortSignal.timeout(5000) });
651
- const loc = res.headers.get('location') ?? '';
652
- const ids = findDouyinRefs(loc).ids;
653
- if (ids.length > 0) return ids[0];
654
- if (!loc) return '';
655
- cur = new URL(loc, cur).href;
656
- } catch {
657
- return '';
658
- }
659
- }
660
- return '';
647
+ return await resolveDouyinShortLink(url, { fetchImpl: this.fetch });
661
648
  }
662
649
 
663
650
  /** 聊天里有人发了抖音视频:打开详情读文案和热评,拼一段简短介绍进消息,让她"看过"再回。 */
@@ -81,6 +81,36 @@ export function soleConversationId(messages) {
81
81
  return ids.size === 1 ? [...ids][0] : '';
82
82
  }
83
83
 
84
+ /**
85
+ * 唯一**单聊**会话 ID(#169)。
86
+ *
87
+ * 和 soleConversationId 的差别:它只认「明确是单聊」的消息(convId 是 0:1: 形状、
88
+ * 且不是群)。群消息(convType=2,或 convId 不是 0:1: 形状)会被算进「非群消息数」,
89
+ * 从而把「面板里只抓到一个群会话」挡在兜底外 —— 否则读群会话会被误判成
90
+ * 「面板里唯一抓到的单聊」(主人那条),把群消息按主人私聊入库(串会话根源)。
91
+ *
92
+ * @param {Array<{convId?: string, convType?: number}>} messages
93
+ * @returns {{ id: string, nonGroupCount: number, groupLike: boolean }}
94
+ * id = 唯一单聊 convId(没有/有多个/有非单聊混入时 '');
95
+ * nonGroupCount = 明确是群的消息条数;groupLike = 这批消息里有没有群。
96
+ */
97
+ export function soleSingleConversationId(messages) {
98
+ const ids = new Set();
99
+ let nonGroupCount = 0;
100
+ let groupLike = false;
101
+ for (const m of messages ?? []) {
102
+ const id = String(m?.convId ?? '').trim();
103
+ // 🔴 先判群,再看 id 空不空:群消息的 convId 经常解不出来(接口对群会话
104
+ // 不一定回填 0:1: 形状),但它带着 convType=2 —— 若先 `id==='' continue`
105
+ // 就把群漏掉了,groupLike 永远置不上,兜底照样错配。
106
+ const isGroup = Number(m?.convType) === 2 || (id !== '' && !isSingleConversation(id));
107
+ if (isGroup) { groupLike = true; nonGroupCount++; continue; }
108
+ if (id === '') continue; // 既不是群、又没 id:信息不足,不当证据也不算群
109
+ ids.add(id);
110
+ }
111
+ return { id: ids.size === 1 && !groupLike ? [...ids][0] : '', nonGroupCount, groupLike };
112
+ }
113
+
84
114
  /**
85
115
  * 会话的稳定身份键:`douyin:<对方uid>`。
86
116
  *
@@ -6,10 +6,24 @@
6
6
  //
7
7
  // ⚠️ 拿不到就返回空串,**不猜**:猜错就是发错视频的卡片,比不发严重。
8
8
 
9
+ import { isIP } from 'node:net';
10
+
9
11
  const MOBILE_UA = 'Mozilla/5.0 (iPhone; CPU iPhone OS 17_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.0 Mobile/15E148 Safari/604.1';
10
12
 
11
- /** 跳转地址里带的作品 ID(`/video/<数字>` 或 `?modal_id=<数字>` 两种都见过)。 */
12
- const ID_IN_URL = /(?:video\/|modal_id=|aweme_id=)(\d{8,20})(?!\d)/;
13
+ /** 跳转地址里带的作品 ID(`/video/<数字>`、`/note/<数字>` 或 `?modal_id=`/`aweme_id=`/`vid=`)。 */
14
+ const ID_IN_URL = /(?:(?:video|note)\/|[?&](?:modal_id|aweme_id|vid)=)(\d{8,20})(?!\d)/;
15
+
16
+ /** 仅放行 https 协议、无凭据、标准 443 端口的抖音官网域,拦截内网/IP 字面量 SSRF 跳转。 */
17
+ function isAllowedDouyinUrl(raw) {
18
+ let u;
19
+ try { u = new URL(raw); } catch { return false; }
20
+ if (u.protocol !== 'https:') return false;
21
+ if (u.username !== '' || u.password !== '') return false;
22
+ if (u.port !== '' && u.port !== '443') return false;
23
+ const host = u.hostname.toLowerCase().replace(/\.$/, '');
24
+ if (host === '' || isIP(host.replace(/^\[|\]$/g, '')) !== 0) return false;
25
+ return host === 'douyin.com' || host.endsWith('.douyin.com') || host === 'iesdouyin.com' || host.endsWith('.iesdouyin.com');
26
+ }
13
27
 
14
28
  /**
15
29
  * 跟随 `v.douyin.com` 短链,拿作品 ID。
@@ -20,7 +34,7 @@ const ID_IN_URL = /(?:video\/|modal_id=|aweme_id=)(\d{8,20})(?!\d)/;
20
34
  */
21
35
  export async function resolveDouyinShortLink(url, { fetchImpl, timeoutMs = 5000 } = {}) {
22
36
  const start = String(url ?? '').trim();
23
- if (start === '') return '';
37
+ if (start === '' || !isAllowedDouyinUrl(start)) return '';
24
38
  // 已经是完整链接:不用发请求
25
39
  const direct = ID_IN_URL.exec(start);
26
40
  if (direct !== null) return direct[1];
@@ -36,9 +50,11 @@ export async function resolveDouyinShortLink(url, { fetchImpl, timeoutMs = 5000
36
50
  });
37
51
  const loc = res?.headers?.get?.('location') ?? '';
38
52
  if (loc === '') return '';
39
- const hit = ID_IN_URL.exec(loc);
53
+ const next = new URL(loc, cur).href;
54
+ if (!isAllowedDouyinUrl(next)) return '';
55
+ const hit = ID_IN_URL.exec(next);
40
56
  if (hit !== null) return hit[1];
41
- cur = new URL(loc, cur).href;
57
+ cur = next;
42
58
  } catch {
43
59
  // 超时 / 断网 / 地址不合法:一律当「拿不到」,不猜
44
60
  return '';
@@ -16,6 +16,7 @@ import { callBridge, commentBridgeReady, installCommentBridge, uploadImage as up
16
16
  import { extname, join, resolve } from 'node:path';
17
17
  import { createHash } from 'node:crypto';
18
18
  import { SocialBase, socialCfg, cleanSocialText } from './social.js';
19
+ import { insertMemory } from './soul-memory.js';
19
20
  import { DouyinPostJobs } from './douyin-post-jobs.js';
20
21
  import { 抠正文图, 兜底表情包 } from './channels/vendor/qq-bridge.js';
21
22
  import { fishSoulDir, getKv, setKv } from './db.js';
@@ -762,9 +763,19 @@ export function douyinSocialDriver(host, timing = {}) {
762
763
  if (el) el.click();
763
764
  return Boolean(el);
764
765
  })()`, { timeoutMs: tm.evalTimeoutMs }).catch(() => false);
765
- await sleep(1500);
766
- const r = await br.send('Runtime.evaluate', { expression: `document.querySelector('input[type="file"][accept*="image"]') || document.querySelector('input[type="file"]')` }, br.sessionId, tm.evalTimeoutMs);
767
- const objectId = r?.result?.objectId;
766
+ // 上传入口是一次性注入的:页面没就绪/加载慢时 sleep(1500) 后还没挂上 DOM,
767
+ // 一次性查不到就报「改版了」是冤案(2026-11-22 真机偶发 NO_UPLOAD,同 URL 隔天成功)。
768
+ // ⇒ waitFor 轮询等它挂上,再退到按「点击上传/上传图文」文案找触发点,仍没有才报 NO_UPLOAD。
769
+ const UPLOAD_INPUT_JS = `(() => {
770
+ const direct = document.querySelector('input[type="file"][accept*="image"]') || document.querySelector('input[type="file"]');
771
+ if (direct) return direct;
772
+ const trigger = [...document.querySelectorAll('div, span, button')].find((x) => x.children.length === 0 && /点击上传|上传图文|上传图片/.test((x.innerText || '').trim()));
773
+ return trigger ? trigger.closest('div')?.querySelector('input[type="file"]') ?? null : null;
774
+ })()`;
775
+ const objectId = await waitFor(async () => {
776
+ const r = await br.send('Runtime.evaluate', { expression: UPLOAD_INPUT_JS }, br.sessionId, tm.evalTimeoutMs).catch(() => null);
777
+ return r?.result?.objectId ?? null;
778
+ }, { tries: 8, gapMs: 1500, budgetMs: tm.waitBudgetMs });
768
779
  if (!objectId) return { ok: false, code: 'NO_UPLOAD', error: '创作者中心页面上没找到上传图片的地方(可能改版了)' };
769
780
  await br.send('DOM.setFileInputFiles', { files: [file], objectId }, br.sessionId);
770
781
  const ready = await waitFor(() => br.eval(`(() => Boolean(document.querySelector('input[placeholder*="标题"]') || document.querySelector('[contenteditable="true"]')))()`, { timeoutMs: tm.evalTimeoutMs }), { tries: 40, budgetMs: tm.waitBudgetMs });
@@ -1250,6 +1261,13 @@ export class DouyinSocial extends SocialBase {
1250
1261
  }
1251
1262
  this.db.exec('COMMIT');
1252
1263
  } catch (error) { this.db.exec('ROLLBACK'); throw error; }
1264
+ // 结果未知的发布,人工核实「已发布」后她也该记得自己发过这条 ——
1265
+ // 否则她被问「你发过什么」时对这条一无所知(2026-11-23 用户反馈)。
1266
+ // 与 social.js post() 成功路径(314 行)同一条 insertMemory。
1267
+ try {
1268
+ const kind = this.postJobs.kindOf(pending.id);
1269
+ insertMemory(this.db, this.worker, { ownerId: 'self', channel: this.platform, channelId: `${this.platform}:post:manual-${pending.id}`, kind: 'event', content: `我在${this.label}发了条${this.postNounOf(kind)}:${pending.text}`, importance: 1, evidence: '自己发的(人工核实)' }, now);
1270
+ } catch { /* 记忆可缺 */ }
1253
1271
  return { ok: true };
1254
1272
  }
1255
1273
 
@@ -321,6 +321,24 @@ export const mediaMethods = {
321
321
  }
322
322
  },
323
323
 
324
+ /**
325
+ * 用识图模型把一张入站图说成一段文字(给会话模型看的「她看到的图」)。
326
+ * 失败回 null(调用方退回原图)。maxTokens 小:只要一段描述,不要它发挥。
327
+ */
328
+ async describeInboundImage(part, quoted) {
329
+ try {
330
+ const out = await this.withTimeout(this.vision(
331
+ (quoted ? '这是别人发的一条消息里被引用的图片。' : '这是聊天里别人发来的一张图。') + '用一两句话客观描述画面里有什么(人物 / 动作 / 物品 / 文字 / 风格,是表情包就说表情包 + 上面写的字)。只输出描述,不要加任何前缀。',
332
+ [{ data: part.data, mediaType: part.mediaType }],
333
+ ), 20_000);
334
+ const text = String(out ?? '').trim();
335
+ if (text === '') return null;
336
+ return `${quoted ? '【被引用的图】' : '【图】'}${text.slice(0, 300)}`;
337
+ } catch {
338
+ return null;
339
+ }
340
+ },
341
+
324
342
  async admitImages(text, items, sessionId = '', { backlog, quotedImages } = {}) {
325
343
  const imgs = [];
326
344
  for (const { m } of items) for (const img of m.images) if (imgs.length < MAX_INBOUND_IMAGES) imgs.push({ img, m });
@@ -331,6 +349,10 @@ export const mediaMethods = {
331
349
  // 被引用的那条消息里的图:也进模型(单独一档,前面加一句说明,模型才知道哪张是被引用的那张)。
332
350
  const quoted = (quotedImages ?? []).slice(0, Math.max(0, MAX_INBOUND_IMAGES - imgs.length));
333
351
  if (imgs.length === 0 && quoted.length === 0) return base;
352
+ // 识图模型只在配置了 models.vision 时启用(没配 = 老行为,图直接给会话模型)。
353
+ const describeImage = this.vision !== null && this.vision !== undefined && String(this.getConfig().models?.vision?.model ?? '') !== ''
354
+ ? (part, quoted) => this.describeInboundImage(part, quoted)
355
+ : null;
334
356
  const attachments = service(this.ctx, 'attachments');
335
357
  if (!attachments || typeof attachments.admitPromptContent !== 'function') {
336
358
  // 宿主没提供 attachments:图片只能丢,但得留痕 —— 否则表现是「她说看不见图」而日志空白
@@ -362,6 +384,14 @@ export const mediaMethods = {
362
384
  const mediaType = mediaTypeOf(bytes);
363
385
  this.stickers?.remember(sessionId, { bytes, mediaType, sticker: img.sticker === true, summary: img.summary, from: m.nickname || m.userId });
364
386
  const part = { type: 'image', data: bytes.toString('base64'), mediaType, name: `qq-${entry.quoteId || m.messageId || 'x'}-${i + 1}.${mediaType.split('/')[1]}` };
387
+ // 配了识图模型:会话模型没视觉也能"看见" —— 先让视觉模型把这张图说成一段文字,喂文字不喂图。
388
+ // 只在主人明确配了 models.vision 时才走;没配 = 原样把图塞给会话模型(行为一字不变)。
389
+ if (describeImage !== null) {
390
+ const described = await describeImage(part, entry.quoted === true);
391
+ if (described !== null) { (entry.quoted === true ? quotedParts : parts).push({ type: 'text', text: described }); continue; }
392
+ // 描述失败(模型没视觉 / 超时 / 图没送进去):退回原图,让会话模型自己试 —— 比把图丢了强。
393
+ this.diag?.add('image-describe-failed', { reason: 'vision_null' }, 'warn');
394
+ }
365
395
  if (entry.quoted === true) quotedParts.push(part); else parts.push(part);
366
396
  }
367
397
  if (quotedParts.length > 0) {
package/lib/gateway.js CHANGED
@@ -222,7 +222,7 @@ export class ChatGateway {
222
222
  * @param {object} deps.soul index.js 提供的人格/记忆回调
223
223
  * @param {(agentCtx: object) => void} [deps.agentSections] 给单个 agent 挂人格卡 / 瞬态块(index.js 传入 registerAgentSections)
224
224
  */
225
- constructor({ ctx, db, clock, getConfig, log, channel, bili = null, browser = null, douyin = null, douyinBrowser = null, canvasConvert = null, soul, voice = null, stickers = null, slang = null, agentSections = null, groupAdmin = null, embedder = null, embeddingCfg = null, diag = null }) {
225
+ constructor({ ctx, db, clock, getConfig, log, channel, bili = null, browser = null, douyin = null, douyinBrowser = null, canvasConvert = null, soul, voice = null, stickers = null, slang = null, agentSections = null, groupAdmin = null, embedder = null, embeddingCfg = null, diag = null, vision = null }) {
226
226
  this.ctx = ctx;
227
227
  this.db = db;
228
228
  this.clock = clock;
@@ -258,6 +258,8 @@ export class ChatGateway {
258
258
  this.embedder = embedder;
259
259
  this.embeddingCfg = embeddingCfg;
260
260
  this.slang = slang;
261
+ // 识图模型(设置页「模型 · 识图」):配了就把用户发的图先描述成文字再喂会话模型 —— 会话模型没视觉也能"看见"。
262
+ this.vision = vision;
261
263
  /** 群管理(入群申请):主人回"/鱼 同意/拒绝"时用它(可能没有) */
262
264
  this.groupAdmin = groupAdmin;
263
265
  /** 给单个 agent 挂人格卡 / 瞬态块:`(agentCtx) => void`(在 setup 里调,只对那个 agent 生效) */
@@ -338,7 +340,7 @@ export class ChatGateway {
338
340
  followUpSeconds: Number.isFinite(Number(q.followUpSeconds)) ? Number(q.followUpSeconds) : 120,
339
341
  followUpSmart: q.followUpSmart === true, // #59 她说"这轮聊完了"就不接着听(默认关)
340
342
  mentionOnly: q.mentionOnly === true, // 群里只回点名:关掉接听和插话(默认关,老行为不变)
341
- batchMs: Number.isFinite(Number(q.batchMs)) ? Number(q.batchMs) : 3000,
343
+ batchMs: Number.isFinite(Number(q.batchMs)) ? Number(q.batchMs) : 3000, batchMaxWaitMs: Number.isFinite(Number(q.batchMaxWaitMs)) ? Number(q.batchMaxWaitMs) : 8000,
342
344
  replyWindowMinutes: clampReplyWindow(q.replyWindowMinutes),
343
345
  callNames: Array.isArray(q.callNames) ? q.callNames.map((x) => String(x).trim()).filter(Boolean) : [],
344
346
  interject: interjectConfig(q.interject)
@@ -430,7 +432,7 @@ export class ChatGateway {
430
432
  allowList: Array.isArray(b.allowList) ? b.allowList.map((x) => String(x).trim()).filter(Boolean) : [],
431
433
  replyMutual: b.replyMutual !== false,
432
434
  proactive: b.proactive === true,
433
- batchMs: num(b.batchMs, 3000),
435
+ batchMs: num(b.batchMs, 3000), batchMaxWaitMs: num(b.batchMaxWaitMs, 8000),
434
436
  replyWindowMinutes: clampReplyWindow(b.replyWindowMinutes)
435
437
  };
436
438
  }
@@ -729,6 +731,25 @@ export class ChatGateway {
729
731
  return [...new Set([...base, ...omTools])];
730
732
  }
731
733
 
734
+ /** 抖音会话要不要让模型「看得见」宿主工具(只影响可见性,授权仍在 guard 里逐轮判)。 */
735
+ douyinHostVisible() {
736
+ // guard 没装上就不能只靠 restrict 一层兜宿主工具,宁可继续只给记忆工具
737
+ return this.voiceGuardReady === true && this.sessionAllowMode() !== 'memory';
738
+ }
739
+
740
+ /** 宿主工具名(不含插件自己的聊天工具、联网工具、OpenMotion 和 run_code)。 */
741
+ hostToolNames(agentCtx) {
742
+ const names = [];
743
+ for (const reg of [this.ctx?.tools, agentCtx?.tools]) {
744
+ try {
745
+ if (typeof reg?.definitions === 'function') names.push(...(reg.definitions() ?? []).map((t) => t?.name));
746
+ else if (typeof reg?.list === 'function') names.push(...(reg.list() ?? []).map((t) => (typeof t === 'string' ? t : t?.name)));
747
+ } catch { /* 读不到就少给几个,不影响授权 */ }
748
+ }
749
+ const mine = new Set([...CHAT_TOOLS, ...WEB_TOOLS, OWN_WEB_TOOL, 'sound_read', 'run_code']);
750
+ return [...new Set(names.filter((n) => typeof n === 'string' && n !== '' && !mine.has(n) && !isOpenMotionTool(n)))];
751
+ }
752
+
732
753
  /** 传话配置:熟人托她给另一个人带句话(默认关,白名单按平台 uid 精确匹配)。 */
733
754
  relayConfig() {
734
755
  const r = this.getConfig().relay ?? {};
@@ -786,6 +807,11 @@ export class ChatGateway {
786
807
  }
787
808
  if (channelId !== undefined && this.sessionOpenFor(channelId)) return; // #37 主人/全部放开:不 restrict,会话用宿主默认工具组合
788
809
  const allow = this.allowedTools(agentCtx, channelId);
810
+ // #169 抖音:档位放开的只是「可见性」,真正放不放由 guard 每轮按身份当场判(见 lib/index.js)。
811
+ // 这里不判身份 —— 身份证据会变,restrict 是一次性的,判错就收不回来。guard 没装就不放宽。
812
+ if (platformOf(channelId) === 'douyin' && this.douyinHostVisible()) {
813
+ for (const name of this.hostToolNames(agentCtx)) if (!allow.includes(name)) allow.push(name);
814
+ }
789
815
  if (typeof agentCtx?.tools?.restrict === 'function' && allow.length > 0) {
790
816
  try {
791
817
  agentCtx.tools.restrict({ allow });
@@ -1050,7 +1076,7 @@ export class ChatGateway {
1050
1076
  if (this.agentsService() === null) throw new Error('宿主没有 agents 服务');
1051
1077
  const row = findChatSession(this.db, platformOf(key), key);
1052
1078
  // 先建新会话成功(insertChatSession 会原子退役旧行),再清旧状态 —— 避免失败时丢原会话和 workspace_path。
1053
- const agent = await this.createSession(owner, row?.workspace_path || undefined, mergeFrom);
1079
+ const agent = await this.createSession(owner, row?.workspace_path || undefined, mergeFrom, { keepTitle: row?.title ?? '' });
1054
1080
  this.resetRecycleBreaker(key);
1055
1081
  if (row !== null) {
1056
1082
  this.bound.delete(row.session_id);
@@ -1080,7 +1106,7 @@ export class ChatGateway {
1080
1106
  return `QQ·${sanitizeName(name, chat.targetId)}${chat.targetId === this.masterQq() ? '(主人)' : ''}`;
1081
1107
  }
1082
1108
 
1083
- async createSession(chat, workspacePath = this.workspacePath(), mergeFrom = '') {
1109
+ async createSession(chat, workspacePath = this.workspacePath(), mergeFrom = '', { keepTitle = '' } = {}) {
1084
1110
  const agents = this.agentsService();
1085
1111
  const ws = await this.ensureWorkspace(workspacePath);
1086
1112
  const sessionId = `fish-soul-${randomUUID()}`;
@@ -1093,7 +1119,10 @@ export class ChatGateway {
1093
1119
  ...(agentOptions !== undefined ? { agentOptions } : {}),
1094
1120
  setup: (agentCtx) => this.setupAgent(agentCtx, chat.channelId)
1095
1121
  });
1096
- const title = await this.chatTitle(chat);
1122
+ // 换新会话(resetSession)沿用旧标题:chatTitle 依赖人物库的当前状态,
1123
+ // 对方改了昵称 / person 行被合并过,重算出来的题头就变了 —— 用户眼里是
1124
+ // 「我只是换了个新会话,题头怎么变了」(2026-11-23 用户反馈)。
1125
+ const title = keepTitle !== '' ? keepTitle : await this.chatTitle(chat);
1097
1126
  this.diag?.add('session-create', { sessionId, channelId: chat.channelId, reason: title });
1098
1127
  try { await ws.attachSession?.(sessionId); } catch (error) {
1099
1128
  this.log('warn', `[fish-soul] 会话挂到工作区失败:${String(error instanceof Error ? error.message : error)}`);
@@ -1536,7 +1565,16 @@ export class ChatGateway {
1536
1565
  });
1537
1566
  };
1538
1567
  if (batch.items.length >= 20 || cfg.batchMs <= 0) { flush(); return; }
1539
- batch.timer = setTimeout(flush, cfg.batchMs);
1568
+ // 🔴 #169:光有静默窗口会被「每条间隔都小于 batchMs」的持续说话无限推迟
1569
+ // (只能靠 20 条硬顶兜底)。加「从第一条进队算起的最长等待 batchMaxWaitMs」:
1570
+ // 到点必发,窗口内继续安静合并。0 = 不限(旧行为)。
1571
+ if (batch.firstAt === undefined) batch.firstAt = Date.now();
1572
+ const maxWaitMs = Number(cfg.batchMaxWaitMs) > 0 ? Number(cfg.batchMaxWaitMs) : 0;
1573
+ const elapsed = Date.now() - batch.firstAt;
1574
+ const delay = maxWaitMs > 0
1575
+ ? Math.max(0, Math.min(cfg.batchMs, maxWaitMs - elapsed))
1576
+ : cfg.batchMs;
1577
+ batch.timer = setTimeout(flush, delay);
1540
1578
  batch.timer.unref?.();
1541
1579
  }
1542
1580
 
package/lib/index.js CHANGED
@@ -1075,6 +1075,8 @@ async function startup(ctx, config, { log, gate }) {
1075
1075
  testHooks.gateway = null;
1076
1076
  gateway = new ChatGateway({
1077
1077
  ctx, db, clock, getConfig, log, channel, bili, browser, douyin, douyinBrowser, canvasConvert, voice, stickers, slang,
1078
+ // 识图模型:复用表情包那套看图调用(超时 / 失败隔离都是现成的),只是功能名换成 vision(设置页「模型 · 识图」)
1079
+ vision: createStickerVision({ call: (prompt, opts = {}) => llmRouter.call(prompt, { ...opts, feature: 'vision' }) }),
1078
1080
  // 按感觉挑表情:复用记忆那套嵌入模型(主人拍板)。没配就跟以前一样按文件名发
1079
1081
  embedder, embeddingCfg,
1080
1082
  groupAdmin, // 群管理(入群申请):主人回"/鱼 同意/拒绝"时用它
@@ -1270,6 +1272,7 @@ async function startup(ctx, config, { log, gate }) {
1270
1272
  const id = exec?.agent?.id;
1271
1273
  const activeChannel = gateway?.turns?.get(String(id))?.channelId;
1272
1274
  const boundChannel = gateway?.chatForSession(String(id))?.channel_id;
1275
+ let douyinMaster = false; // 这一轮抖音身份验明是主人,且档位不是 memory
1273
1276
  if ((activeChannel && platformOf(activeChannel) === 'douyin') || (boundChannel && platformOf(boundChannel) === 'douyin')) {
1274
1277
  // 抖音会话被并进主人 QQ 私聊会话时,身份就是主人,跟 QQ 那边一样放行;
1275
1278
  // 认不出主人(陌生私信)才照旧拦。
@@ -1279,6 +1282,9 @@ async function startup(ctx, config, { log, gate }) {
1279
1282
  const douyinUin = douyinChannel === '' ? '' : String(gateway?.douyinUinOf?.({ channelId: douyinChannel }) ?? '');
1280
1283
  const masterUin = String(currentConfig.masterQqUin ?? '').trim();
1281
1284
  if (douyinUin === '' || masterUin === '' || douyinUin !== masterUin) return '抖音身份尚未验证,暂不开放聊天工具';
1285
+ // 身份这一轮验明了是主人:档位放开时宿主工具放行(run_code 下面照旧拦)。
1286
+ // 判定放在这里而不是建会话时的 restrict —— 身份证据会变,这里每轮都能收回。
1287
+ douyinMaster = gateway.sessionAllowMode() !== 'memory';
1282
1288
  }
1283
1289
  const ours = id !== undefined && id !== null && gateway?.isOurSession(id) === true;
1284
1290
  if (!ours && WEB_TOOLS.includes(exec?.name)) markHostWebSeen();
@@ -1302,6 +1308,7 @@ async function startup(ctx, config, { log, gate }) {
1302
1308
  }
1303
1309
  if (exec.name === 'run_code') return `聊天会话里不能运行代码(放开工具也不放 run_code:它能跑任意程序)`;
1304
1310
  if (sessionOpen(id)) return undefined; // #37 主人/全部放开:宿主工具都放
1311
+ if (douyinMaster && !isOpenMotionTool(exec.name)) return undefined; // #169 抖音这一轮验明是主人
1305
1312
  if (isOpenMotionTool(exec.name)) {
1306
1313
  return isMasterSession(id) ? undefined : 'OpenMotion 视频工具只能在主人的私聊里用';
1307
1314
  }
package/lib/llm.js CHANGED
@@ -21,6 +21,7 @@ export const FEATURES = [
21
21
  ['slang', '学群里的说法'],
22
22
  ['diary', '写日记'],
23
23
  ['mood', '每轮判断心情'],
24
+ ['vision', '识图(看她收到的图)'],
24
25
  ['other', '其他']
25
26
  ];
26
27
  const FEATURE_IDS = new Set(FEATURES.map(([id]) => id));
@@ -162,7 +163,9 @@ export class LlmRouter {
162
163
  // 一个都选不出来(宿主没报提供方 / 默认模型):不指定,交给宿主自己决定(老版本的行为)
163
164
  if (target === null) target = { provider: undefined, model: '(宿主默认)', from: 'none' };
164
165
  // 推理模型会先把额度花在思考上:这个模型返回过空的,以后直接给大额度(只是上限,不用就不花)
165
- const roomy = this.roomy ?? (this.roomy = new Set());
166
+ // 🔴 #181:roomy 以前是纯内存 Set,**重启即清** ⇒ 每次重启第一枪必空转一次。
167
+ // 现在落 kv(读一次缓存住,加入时写回)。
168
+ const roomy = this.roomy ?? (this.roomy = this.loadRoomy());
166
169
  const key = `${target.provider ?? ''}/${target.model}`;
167
170
  const tried = _tried ?? new Set();
168
171
  const budget = roomy.has(key) ? Math.max(maxTokens, ROOMY_TOKENS) : maxTokens;
@@ -237,9 +240,14 @@ export class LlmRouter {
237
240
  return this.fallback(prompt, { signal, maxTokens, feature, thinkFallback, images, needImages, failureInfo, tried: tried.add(key) });
238
241
  }
239
242
  const text = (out.trim() || blockText.trim());
240
- if (text === '' && budget < ROOMY_TOKENS && !signal?.aborted) {
243
+ // 🔴 #181:正文空、结束原因是 max-tokens、而且收到了思考 —— 额度全被思考吃光,
244
+ // 放大到 8000 再试一次**注定也是空**(推理模型的思考动辄 13k token),
245
+ // 那次重试是纯烧钱。跳过它,直接走下面的失败记录 + 换默认模型。
246
+ // ⚠️ 不把这个模型加进 roomy:预算抬到 8000 只会让每次调用烧更多思考费。
247
+ const thinkAteBudget = text === '' && finish === 'max-tokens' && think !== '';
248
+ if (text === '' && budget < ROOMY_TOKENS && !thinkAteBudget && !signal?.aborted) {
241
249
  // 空回复多半是额度全花在思考上了:记住这个模型,放大额度再试一次
242
- roomy.add(key);
250
+ roomy.add(key); this.saveRoomy(roomy);
243
251
  this.record(f, target.model, { inputTokens: usage ? Number(usage.inputTokens) || 0 : estimateTokens(prompt), outputTokens: usage ? Number(usage.outputTokens) || 0 : 0, estimated: !usage, failed: true });
244
252
  return this.call(prompt, { signal, maxTokens, feature, thinkFallback, images, needImages, failureInfo, _target: target, _tried: tried });
245
253
  }
@@ -281,6 +289,25 @@ export class LlmRouter {
281
289
  return (prompt, opts = {}) => this.call(prompt, { ...opts, feature: opts.feature ?? feature });
282
290
  }
283
291
 
292
+ /**
293
+ * 读出「吃过空回复的模型」名单(#181)。落 kv 而不是只放内存:
294
+ * 以前重启即清,每次重启第一枪都要空转一遍才重新学到。
295
+ * 读失败返回空集 —— 退化到旧行为,不影响调用。
296
+ */
297
+ loadRoomy() {
298
+ try { return new Set(getKv(this.db, 'llm.roomy', []) ?? []); } catch { return new Set(); }
299
+ }
300
+
301
+ /**
302
+ * 存回「吃过空回复的模型」名单(#181)。写失败只留痕:
303
+ * 这是省钱优化,不该因为它挂掉调用。
304
+ */
305
+ saveRoomy(set) {
306
+ try { setKv(this.db, 'llm.roomy', [...set]); } catch (error) {
307
+ this.log('warn', `[fish-soul] 记「吃过空回复的模型」失败:${String(error instanceof Error ? error.message : error)}`);
308
+ }
309
+ }
310
+
284
311
  record(feature, model, { inputTokens, outputTokens, estimated, failed }) {
285
312
  try {
286
313
  const key = `usage.${dayKey(Date.now())}`;
package/lib/routes-v07.js CHANGED
@@ -126,7 +126,8 @@ export async function handleV07Route({ method, path, url, req, res, send, readBo
126
126
  for (const [id, label] of FEATURES) {
127
127
  const r = await llmRouter.resolve(id);
128
128
  const pick = cfg.models?.[id];
129
- features.push({ id, label, selection: pick && pick.provider && pick.model ? { provider: pick.provider, model: pick.model } : null, resolved: r, });
129
+ // vision(识图)的语义是「不配 = 不启用」,不是「跟 DSH 默认」:没配时 resolved 给 null,别让面板显示「现在用 xxx」误导人。
130
+ features.push({ id, label, selection: pick && pick.provider && pick.model ? { provider: pick.provider, model: pick.model } : null, resolved: (id === 'vision' && !(pick && pick.model)) ? null : r, });
130
131
  }
131
132
  send(200, {
132
133
  ok: true, providers, features, hostDefault: llmRouter.hostDefault(), prices: cfg.modelPrices ?? {},
package/lib/routes.js CHANGED
@@ -7,7 +7,7 @@
7
7
  * 聊天记录导入在 routes-soul.js;v0.7 的模型 / 用量 / 语音 / 表情包 / 群里的说法 / 首次引导在 routes-v07.js(UI 文档契约 21~31)。
8
8
  */
9
9
  import { readFileSync, existsSync } from 'node:fs';
10
- import { readVecMeta, writeVecMeta, listChatSessions } from './db.js';
10
+ import { readVecMeta, writeVecMeta, listChatSessions, ensureMasterPerson, getProfile, setKv } from './db.js';
11
11
  import { douyinState, handleDouyinRoute } from './routes-douyin.js';
12
12
  import { douyinSessionHealth } from './douyin-http.js';
13
13
  import { describeHealth } from './session-health.js';
@@ -21,6 +21,7 @@ import { pluginVersion } from './update-check.js';
21
21
  import { stickerConfig } from './stickers.js';
22
22
  import { slangConfig } from './slang.js';
23
23
  import { importMemories } from './importer.js';
24
+ import { insertMemory } from './soul-memory.js';
24
25
  import { bulkMemory, filterWhere, MEMORY_DATE } from './memory-bulk.js';
25
26
  import { dedicatedWorkspacePath, interjectConfig, clampReplyWindow } from './gateway.js';
26
27
  import { DEFAULT_DAILY_MAX, DEFAULT_IDLE_REAL_GAP_MIN } from './life.js';
@@ -109,7 +110,7 @@ export function registerRoutes(ctx, deps) {
109
110
  // canApply 恒 false ⇒ 面板上「更新到」按钮**从来没渲染过**。
110
111
  // 放在这里而不是各个调用方,是为了以后新增路由不用再记得传一遍。
111
112
  deps.ctx ??= ctx;
112
- const { db, clock, embedder, worker, life, getConfig, saveConfig, log, gateway, channel, bili, biliClient, browser, biliSocial } = deps;
113
+ const { db, clock, embedder, worker, life, getConfig, saveConfig, log, gateway, channel, bili, biliClient, browser, biliSocial, persona } = deps;
113
114
  const logger = log ?? (() => {});
114
115
  /** 进行中的 B站扫码(密钥只留在服务端) */
115
116
  let qr = null;
@@ -342,7 +343,7 @@ export function registerRoutes(ctx, deps) {
342
343
 
343
344
  // ── 契约 5:自走层状态 ──
344
345
  if (method === 'GET' && path === '/life/state') {
345
- return send(200, { ok: true, ...life.stateSnapshot() });
346
+ return send(200, { ok: true, apiVersion: 1, pluginVersion: pluginVersion(), ...life.stateSnapshot() });
346
347
  }
347
348
 
348
349
  // ── 契约 6:主动投递白名单(严格校验,审查 #01)──
@@ -991,6 +992,77 @@ export function registerRoutes(ctx, deps) {
991
992
  // ── 人格:模板 / 编辑 / 导入角色卡 / 撤销 ──
992
993
  if (await handlePersonaRoute({ method, path, req, send, readBody: readBodyLogged, sameOrigin, deps })) return;
993
994
 
995
+ // ── 桌面宠物 v1 互通:上下文(人格 / 画像 / 主人关系 / 最近记忆)──
996
+ if (method === 'GET' && path === '/life/context') {
997
+ const nowVirtual = clock.now();
998
+ const personaRaw = typeof persona === 'function' ? persona() : (persona ?? {});
999
+ const master = ensureMasterPerson(db, nowVirtual);
1000
+ const profile = getProfile(db, 'user:master');
1001
+ const memories = db.prepare(`
1002
+ SELECT id, content, kind, keywords, importance, emotion, evidence, created_at, updated_at, source_session
1003
+ FROM memory
1004
+ WHERE character_id = 'feiyu' AND owner_id = 'user:master' AND status = 'active' AND valid_to IS NULL
1005
+ ORDER BY created_at DESC LIMIT 8
1006
+ `).all().map((m) => ({
1007
+ id: m.id, content: m.content, kind: m.kind, keywords: m.keywords,
1008
+ importance: m.importance, emotion: m.emotion, evidence: m.evidence ?? '',
1009
+ createdAt: m.created_at, updatedAt: m.updated_at, sourceSession: m.source_session
1010
+ }));
1011
+ return send(200, {
1012
+ ok: true, apiVersion: 1,
1013
+ persona: {
1014
+ name: personaRaw.name ?? 'feiyu',
1015
+ anchor: personaRaw.anchor ?? '',
1016
+ routine: personaRaw.routine ?? '',
1017
+ brief: String(personaRaw.staticText ?? personaRaw.brief ?? '').trim().slice(0, 300)
1018
+ },
1019
+ profile: profile?.text ?? null,
1020
+ memories,
1021
+ master: {
1022
+ ownerId: 'user:master',
1023
+ displayName: master.display_name ?? '主人',
1024
+ relationStage: master.relation_stage ?? 'close',
1025
+ interactionCount: master.interaction_count ?? 0
1026
+ },
1027
+ lastInteractionVirtualAt: life.lastAnyInteractionVirtualMs ?? null,
1028
+ lastInteractionAt: life.lastAnyInteractionVirtualMs ?? null, // 兼容旧桌宠端,同 lastInteractionVirtualAt(虚拟钟,勿与 Date.now() 对表)
1029
+ lastInteractionRealAt: life.lastAnyInteractionRealMs ?? null
1030
+ });
1031
+ }
1032
+
1033
+ // ── 桌面宠物 v1 互通:互动回传(点击 / 拖拽 / 聊天 / 语音 / 唤醒)──
1034
+ if (method === 'POST' && path === '/life/interaction') {
1035
+ if (!sameOrigin(req)) return send(403, { ok: false, reason: 'forbidden' });
1036
+ let body;
1037
+ try { body = JSON.parse(await readBody(req, logger) || '{}'); } catch { return send(400, { ok: false, reason: 'invalid-json' }); }
1038
+ const type = String(body.type ?? '');
1039
+ if (!['click', 'drag', 'chat', 'voice', 'wake'].includes(type)) return send(400, { ok: false, reason: 'bad-request' });
1040
+ const text = String(body.text ?? '').trim().slice(0, 500);
1041
+ const petId = String(body.petId ?? '').slice(0, 80);
1042
+ const nowVirtual = clock.now();
1043
+ ensureMasterPerson(db, nowVirtual);
1044
+ life.noteInteraction('user:master');
1045
+ const isConversational = type === 'chat' || type === 'voice';
1046
+ db.prepare(isConversational
1047
+ ? "UPDATE person SET interaction_count = interaction_count + 1, last_seen_at = ? WHERE canonical_id = 'master'"
1048
+ : "UPDATE person SET last_seen_at = ? WHERE canonical_id = 'master'"
1049
+ ).run(nowVirtual);
1050
+ let memoryId = null;
1051
+ if ((type === 'chat' || type === 'voice') && text !== '') {
1052
+ memoryId = insertMemory(db, worker, {
1053
+ ownerId: 'user:master', channel: 'dsh', channelId: 'desktop-pet',
1054
+ kind: 'episode', content: text,
1055
+ importance: 1, emotion: 0,
1056
+ sourceSession: 'desktop-pet',
1057
+ evidence: type === 'voice' ? '桌面语音输入' : '桌面宠物对话',
1058
+ private: false
1059
+ }, nowVirtual);
1060
+ } else {
1061
+ setKv(db, 'desktop.lastInteraction', { type, petId, at: nowVirtual });
1062
+ }
1063
+ return send(200, { ok: true, apiVersion: 1, interaction: { type, petId, at: nowVirtual, memoryId } });
1064
+ }
1065
+
994
1066
  return send(404, { ok: false, error: 'not found' });
995
1067
  } catch (error) {
996
1068
  logger('error', `[fish-soul] 路由异常:${String(error instanceof Error ? error.message : error)}`);
package/lib/slang.js CHANGED
@@ -202,8 +202,10 @@ export class SlangLearner {
202
202
  let parsed;
203
203
  try { parsed = JSON.parse(text.match(/\{[\s\S]*\}/)?.[0] ?? 'null'); } catch { parsed = null; }
204
204
  if (!parsed || typeof parsed !== 'object') return { ok: false, error: '模型回的不是 JSON' };
205
- const drop = new Set((Array.isArray(parsed.drop) ? parsed.drop : []).map((x) => String(x).trim()));
206
- const terms = d.terms.filter((t) => t.byUser === true || !drop.has(t.term)); // 主人加的不被模型删
205
+ // 🔴 #182:不采信模型给的 drop,只增不减,靠 MAX_TERMS 截断。
206
+ // drop 和「学新词」是同一个模型同一次输出:小模型分不清「不知道」和「已经不用」,
207
+ // 会把还在用的词写进 drop,而误删是单向的、没有通知。
208
+ const terms = d.terms.slice();
207
209
  let added = 0;
208
210
  const self = clean(this.personaName());
209
211
  for (const raw of (Array.isArray(parsed.terms) ? parsed.terms : []).slice(0, 10)) {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "dsh-fish-soul",
3
- "version": "0.18.22",
4
- "description": "鱼 · 人格、按人记忆(可纠正、有印象、能导入旧聊天记录)、日程自走与主动开口,直连 SnowLuma 收发 QQ(群里会自己插话),B站 / 抖音小号私信与自己刷视频;按功能选模型并统计用量花费,能听会说 QQ 语音、收藏表情包、学群里的梗,可选上网查;心情影响说话、去 AI 味、每个群的设定、按聊天选模型、每晚写日记、每周记忆存档与可选周记(DSH 插件,单角色 feiyu ,v0.18.22)",
3
+ "version": "0.18.24",
4
+ "description": "鱼 · 人格、按人记忆(可纠正、有印象、能导入旧聊天记录)、日程自走与主动开口,直连 SnowLuma 收发 QQ(群里会自己插话),B站 / 抖音小号私信与自己刷视频;按功能选模型并统计用量花费,能听会说 QQ 语音、收藏表情包、学群里的梗,可选上网查;心情影响说话、去 AI 味、每个群的设定、按聊天选模型、每晚写日记、每周记忆存档与可选周记(DSH 插件,单角色 feiyu ,v0.18.23)",
5
5
  "type": "module",
6
6
  "main": "./lib/index.js",
7
7
  "files": [
@@ -64,7 +64,7 @@
64
64
  }
65
65
  },
66
66
  "scripts": {
67
- "test": "node test/check-test-chain.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-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-read-fail-retry-poll.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-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/smoke.mjs && node test/browser-launch-early-exit.mjs && node test/douyin-browser.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/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/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/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/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/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/context-source-platform.mjs && node test/memory-source-label.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-visibility.mjs && node test/bili-allowlist.mjs && node test/douyin-master-uid-mismatch.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/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/douyin-video-wire.mjs && node test/video-gen.mjs",
67
+ "test": "node test/check-test-chain.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-read-fail-retry-poll.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/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-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/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/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/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/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/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/context-source-platform.mjs && node test/memory-source-label.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-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/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/douyin-video-wire.mjs && node test/video-gen.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
  }