dsh-fish-soul 0.17.0 → 0.18.1

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.17.0**。
5
+ DSH 插件(单角色 `feiyu`)。版本 **0.18.1**。
6
6
 
7
7
  QQ 交流群:**1125962189**
8
8
 
@@ -559,7 +559,16 @@ export class Browser {
559
559
  })
560
560
  }
561
561
 
562
- /** 在页面里执行 JS,返回结果 */
562
+ /**
563
+ * 在页面里执行 JS,返回结果
564
+ *
565
+ * @param {string} expression
566
+ * @param {object} opts
567
+ * @param {boolean} opts.awaitPromise
568
+ * @param {number} opts.timeoutMs 这次 eval 的上限(默认 60 秒 = send 的默认值)。
569
+ * 页面 renderer 卡死但 CDP 连接还在时,Runtime.evaluate **永不回包** ——
570
+ * 不给短超时时一把浏览器锁能被拖住好几分钟。
571
+ */
563
572
  async eval(expression, opts = {}) {
564
573
  // 🔴 **绝不在这里启动浏览器**。
565
574
  // 以前是 `if (!this.ready) await this.launch()` —— 而后台累积器每 2 秒
@@ -567,12 +576,13 @@ export class Browser {
567
576
  // **窗口每隔 2 秒自己弹一次**。
568
577
  // 要不要开浏览器只有一个地方能决定:桥的 ensureBrowser()。
569
578
  if (!this.ready) throw new Error('浏览器没连上(连接已断),需要重新获取浏览器')
579
+ const timeoutMs = Number(opts.timeoutMs) > 0 ? Number(opts.timeoutMs) : 60000
570
580
  const r = await this.send('Runtime.evaluate', {
571
581
  expression,
572
582
  returnByValue: true,
573
583
  awaitPromise: opts.awaitPromise !== false,
574
584
  userGesture: true,
575
- }, this.sessionId)
585
+ }, this.sessionId, timeoutMs)
576
586
  if (r.exceptionDetails) {
577
587
  throw new Error(`页面 JS 报错:${r.exceptionDetails.exception?.description || r.exceptionDetails.text}`)
578
588
  }
@@ -584,8 +594,13 @@ export class Browser {
584
594
  *
585
595
  * 🔴 Page.navigate 会**静默失败**(不报错,但页面停在 about:blank)。
586
596
  * ⇒ 必须验证 location.href,不对就重试。
597
+ *
598
+ * @param {object} opts
599
+ * @param {number} opts.timeoutMs **整个导航**的上限(毫秒);不给 = 不设限(老行为)。
600
+ * 页面卡死时验证用的 location.href 读不回(Runtime.evaluate 永不回包)。
601
+ * 这个上限**包住整段导航**:重试间隔、导航后等待、成功后的 settle 都算在里面。
587
602
  */
588
- async goto(url, { settleMs = 9000, retries = 2 } = {}) {
603
+ async goto(url, { settleMs = 9000, retries = 2, timeoutMs = 0 } = {}) {
589
604
  // 🔴 同 eval():不在这里启动浏览器(见上面的说明)
590
605
  if (!this.ready) throw new Error('浏览器没连上(连接已断),需要重新获取浏览器')
591
606
  this.events = []
@@ -593,23 +608,65 @@ export class Browser {
593
608
  this.seq = 0
594
609
  this.messageResponses.clear()
595
610
 
611
+ // 🔴 整个导航的上限(给了才生效)。页面 renderer 卡死但 CDP 连接还在时,
612
+ // 验证用的 location.href 读不回(Runtime.evaluate 永不回包),
613
+ // 没有上限就是 60 秒 × 重试次数。
614
+ const bounded = Number(timeoutMs) > 0
615
+ const end = bounded ? Date.now() + Number(timeoutMs) : 0
616
+ /** 这次还能花多少毫秒;不设限时返回 Infinity(各步都按老行为走) */
617
+ const left = () => (bounded ? end - Date.now() : Infinity)
618
+
619
+ /**
620
+ * 睡一段,但不许睡过预算:睡 min(原值, 剩余)。
621
+ *
622
+ * 🔴 以前这几处是**裸 sleep** —— 导航请求本身有上限,等待却不管:
623
+ * 导航请求超时后还要再睡 800ms × 重试次数,导航成功后还要再睡 settle
624
+ * (settleMs 7000 时是 4500ms)才返回。
625
+ * openWork 把这个上限当整操作 deadline 的一部分 ⇒ 整操作能超过 30 秒
626
+ * (2026-11-15 独立审查打回的阻断项)。
627
+ *
628
+ * 不设限时(left() = Infinity)时就是原来的 sleep(ms),老行为完全不变。
629
+ *
630
+ * 🔴 true = **醒来时**仍在预算内。只看入睡前的 remain 会漏判:
631
+ * 定时器可能迟到(事件循环被占 / 系统休眠 / 后台标签页被节流),
632
+ * 入睡时预算够 ≠ 醒来时预算还在 ⇒ 睡完必须重新核对 left()。
633
+ *
634
+ * @returns {boolean} true = 睡够了且醒来时仍在预算内;false = 没睡够 / 醒来时已超预算
635
+ */
636
+ const sleepWithin = async (ms) => {
637
+ const remain = left()
638
+ if (remain <= 0) return false
639
+ if (remain >= ms) {
640
+ await sleep(ms)
641
+ return left() > 0 // 睡醒后重新核对:定时器可能迟到
642
+ }
643
+ await sleep(remain)
644
+ return false
645
+ }
646
+
596
647
  let lastHref = ''
597
648
  for (let attempt = 0; attempt <= retries; attempt++) {
649
+ if (bounded && left() <= 0) throw new Error(`导航超时(${timeoutMs}ms):${url}`)
650
+ // 这次导航能花多少:整操作预算的剩余时间(没给预算时 = 15 秒,老行为不变)
651
+ const navTimeout = Math.min(15000, left())
598
652
  try {
599
653
  // 导航卡死时不能无限等:CDP 的 Page.navigate 要等对话框被处理才会回包,
600
654
  // 对话框一旦没人点,这里会挂满 send() 默认的 60 秒才报错,重试也跟着等。
601
655
  // 导航单独给 15 秒上限(超时由 send 自己清 pending 和计时器,不会空挂),
602
656
  // 超时当这次失败,走下面的重试 / 报错。
603
- await this.send('Page.navigate', { url }, this.sessionId, 15000)
657
+ await this.send('Page.navigate', { url }, this.sessionId, navTimeout)
604
658
  } catch (e) {
605
659
  const timedOut = /超时/.test(e.message)
606
- if (attempt >= retries) throw new Error(timedOut ? '导航请求超时(15 秒):页面可能被原生确认框挡住' : `导航请求失败:${e.message}`)
607
- await sleep(800)
660
+ if (attempt >= retries) throw new Error(timedOut ? `导航请求超时(${Math.round(navTimeout)}ms):页面可能被原生确认框挡住` : `导航请求失败:${e.message}`)
661
+ await sleepWithin(800)
608
662
  continue
609
663
  }
610
664
 
611
- await sleep(Math.min(2500, Math.max(800, settleMs / 3)))
612
- lastHref = await this.eval('location.href').catch(() => '')
665
+ // 🔴 导航后的首次等待也要看结果:睡醒时已过 deadline ⇒ 别再往下走
666
+ // (再 eval 只会白等,页面多半也是半成品)。
667
+ const waited = await sleepWithin(Math.min(2500, Math.max(800, settleMs / 3)))
668
+ if (bounded && !(waited && left() > 0)) throw new Error(`导航超时(${timeoutMs}ms):导航后等待超预算,${url}`)
669
+ lastHref = await this.eval('location.href', bounded ? { timeoutMs: Math.max(1, left()) } : {}).catch(() => '')
613
670
 
614
671
  const ok = lastHref
615
672
  && lastHref !== 'about:blank'
@@ -617,12 +674,15 @@ export class Browser {
617
674
  && lastHref !== 'chrome://newtab/'
618
675
 
619
676
  if (ok) {
620
- await sleep(Math.max(0, settleMs - 2500))
677
+ // 🔴 成功返回前查 deadline:settle 没睡完 / 睡醒时已过 deadline,
678
+ // 都不能当作成功(页面可能还没渲染完,调用方会拿着半成品继续)。
679
+ const settled = await sleepWithin(Math.max(0, settleMs - 2500))
680
+ if (bounded && !(settled && left() > 0)) throw new Error(`导航超时(${timeoutMs}ms):settle 没睡完,${url}`)
621
681
  return { url: lastHref, attempt }
622
682
  }
623
683
  if (attempt < retries) {
624
684
  this.log(`导航没生效(还在 ${lastHref || 'about:blank'}),重试…`)
625
- await sleep(1000)
685
+ await sleepWithin(1000)
626
686
  }
627
687
  }
628
688
 
@@ -27,7 +27,21 @@
27
27
  // `commentBridgeReady()` 比的是版本号,号没变就认为「已装好」,于是线上一直跑旧代码。
28
28
  // 2026-11-08 就踩过:改了 collect 的端点,验证时抓到的请求还是旧端点。
29
29
  // v2:收藏改走 aweme/collect(原来猜的 commit/collect 是 404 Janus)
30
- export const COMMENT_BRIDGE_VERSION = 3;
30
+ // v5:postComment 的本地校验(缺作品 id / 正文图片都空)改成 NOT_ATTEMPTED —— 请求根本没发出去
31
+ export const COMMENT_BRIDGE_VERSION = 5;
32
+
33
+ /**
34
+ * 写操作状态(页面桥和 Node 侧共用同一套值)。
35
+ *
36
+ * NOT_ATTEMPTED —— 写操作**根本没发出去**(桥没装上 / 图没传上去):
37
+ * 调用方可以退回 DOM 点击重来。
38
+ * ATTEMPTED_UNKNOWN —— 写操作**可能已经发出去了**(超时 / 断连 / 抖音没回评论 id):
39
+ * 调用方绝不能再发一次(再发就是重复评论)。
40
+ *
41
+ * ⚠️ 靠状态字段判断,不要拿错误文本匹配 —— 文本会变,状态不会。
42
+ */
43
+ export const WRITE_NOT_ATTEMPTED = 'NOT_ATTEMPTED';
44
+ export const WRITE_ATTEMPTED_UNKNOWN = 'ATTEMPTED_UNKNOWN';
31
45
 
32
46
  /**
33
47
  * 页面内脚本。挂在 `window.__fishComment` 上。
@@ -43,6 +57,9 @@ export const COMMENT_BRIDGE_SOURCE = String.raw`
43
57
 
44
58
  const ok = (o) => Object.assign({ ok: true }, o);
45
59
  const bad = (e, extra) => Object.assign({ ok: false, error: String((e && e.message) || e) }, extra || {});
60
+ // 写操作状态(和 Node 侧同名)
61
+ const WRITE_NOT_ATTEMPTED = '${WRITE_NOT_ATTEMPTED}';
62
+ const WRITE_ATTEMPTED_UNKNOWN = '${WRITE_ATTEMPTED_UNKNOWN}';
46
63
 
47
64
  /** 页面加载时刻 —— celltime 两个字段都从它算起(实测抖音自己也是这么算的)。 */
48
65
  const PAGE_LOAD_TIME = Date.now();
@@ -277,13 +294,17 @@ export const COMMENT_BRIDGE_SOURCE = String.raw`
277
294
  * @param {Array} [o.images] [{uri,width,height,format}]
278
295
  */
279
296
  async postComment(o) {
297
+ // ⚠️ 分两段:
298
+ // · 本地校验没过 → 请求**根本没发出去**(NOT_ATTEMPTED),调用方可以退回 DOM;
299
+ // · 请求已经发出去了 → 后面的一切(超时 / 断连 / 抖音没回评论 id)都算
300
+ // 「可能已经发出去了」(ATTEMPTED_UNKNOWN),调用方绝不能再发一次。
280
301
  try {
281
302
  const opt = o || {};
282
303
  const awemeId = String(opt.awemeId || '');
283
- if (!awemeId) return { ok: false, error: '没给作品 id' };
304
+ if (!awemeId) return { ok: false, writeState: WRITE_NOT_ATTEMPTED, error: '没给作品 id' };
284
305
  const images = Array.isArray(opt.images) ? opt.images : [];
285
306
  const text = String(opt.text || '');
286
- if (!text && !images.length) return { ok: false, error: '正文和图片都是空的' };
307
+ if (!text && !images.length) return { ok: false, writeState: WRITE_NOT_ATTEMPTED, error: '正文和图片都是空的' };
287
308
 
288
309
  const now = Date.now();
289
310
  const sendCelltime = String(Math.floor((now - PAGE_LOAD_TIME) / 1000) * 1000);
@@ -317,12 +338,13 @@ export const COMMENT_BRIDGE_SOURCE = String.raw`
317
338
  const uifid = cookie('UIFID') || cookie('UIFID_TEMP');
318
339
  if (uifid) extra.uifid = uifid;
319
340
  const r = await api('/aweme/v1/web/comment/publish/', extra, b.toString());
320
- if (!r.ok) return r;
341
+ // 请求已经发出去了(可能服务端已经落库),后面的结果一律「不明」
342
+ if (!r.ok) return Object.assign({ writeState: WRITE_ATTEMPTED_UNKNOWN }, r);
321
343
  const cid = r.data && r.data.comment && r.data.comment.cid;
322
- if (!cid) return { ok: false, error: '抖音没回评论 id', raw: r.data };
344
+ if (!cid) return { ok: false, writeState: WRITE_ATTEMPTED_UNKNOWN, error: '抖音没回评论 id', raw: r.data };
323
345
  // cid 是 19 位整数,JS Number 只能精确到 16 位 —— JSON 里若是数字必须 toFixed(0) 保精度
324
346
  return ok({ cid: typeof cid === 'number' ? cid.toFixed(0) : String(cid) });
325
- } catch (e) { return bad(e); }
347
+ } catch (e) { return { ok: false, writeState: WRITE_ATTEMPTED_UNKNOWN, error: String((e && e.message) || e) }; }
326
348
  },
327
349
 
328
350
  /**
@@ -420,30 +442,30 @@ export const COMMENT_BRIDGE_SOURCE = String.raw`
420
442
  * 在当前页面装上桥(不依赖 preload —— 当前页立刻能用)。
421
443
  * 返回 { ok, error? }。
422
444
  */
423
- export async function installCommentBridge(browser) {
445
+ export async function installCommentBridge(browser, { timeoutMs } = {}) {
424
446
  try {
425
447
  browser.addPreloadScript(COMMENT_BRIDGE_SOURCE);
426
448
  } catch { /* 老版本 Browser 没这方法 */ }
427
449
  try {
428
- await browser.send('Page.addScriptToEvaluateOnNewDocument', { source: COMMENT_BRIDGE_SOURCE }, browser.sessionId);
450
+ await browser.send('Page.addScriptToEvaluateOnNewDocument', { source: COMMENT_BRIDGE_SOURCE }, browser.sessionId, timeoutMs);
429
451
  } catch { /* 装了 preload 就够 */ }
430
452
  try {
431
- await browser.eval(COMMENT_BRIDGE_SOURCE);
453
+ await browser.eval(COMMENT_BRIDGE_SOURCE, { timeoutMs });
432
454
  } catch (error) {
433
455
  return { ok: false, error: String(error instanceof Error ? error.message : error) };
434
456
  }
435
457
  // ⚠️ eval 没抛异常 ≠ 桥真的装上了:页面如果不是真抖音(比如测试用的本地假站),
436
458
  // eval 会静静地什么都没做。所以装完回头验一次版本号。
437
- if (!(await commentBridgeReady(browser))) {
459
+ if (!(await commentBridgeReady(browser, { timeoutMs }))) {
438
460
  return { ok: false, error: '装完验不到桥(页面里没有 window.__fishComment)' };
439
461
  }
440
462
  return { ok: true };
441
463
  }
442
464
 
443
465
  /** 桥是否在位。 */
444
- export async function commentBridgeReady(browser) {
466
+ export async function commentBridgeReady(browser, { timeoutMs } = {}) {
445
467
  try {
446
- const v = await browser.eval('window.__fishComment ? window.__fishComment.version : 0');
468
+ const v = await browser.eval('window.__fishComment ? window.__fishComment.version : 0', { timeoutMs });
447
469
  return Number(v) === COMMENT_BRIDGE_VERSION;
448
470
  } catch {
449
471
  return false;
@@ -455,21 +477,36 @@ export async function commentBridgeReady(browser) {
455
477
  * @param {import('./browser.mjs').Browser} browser
456
478
  * @param {string} method 桥上的方法名
457
479
  * @param {object} args 参数
458
- * @returns {Promise<{ok: boolean, error?: string}>}
480
+ * @param {object} [opts]
481
+ * @param {boolean} [opts.write] 这是写操作吗?写操作的结果不明(超时 / 断连 / 页面没回结果)
482
+ * 一律标成 ATTEMPTED_UNKNOWN —— 调用方绝不能再发一次。
483
+ * @param {number} [opts.timeoutMs] 这次桥调用的上限(毫秒)。不给 = eval 的默认 60 秒。
484
+ * 页面卡死时 Runtime.evaluate 永不回包,不给上限就是 60 秒。
485
+ * @returns {Promise<{ok: boolean, error?: string, writeState?: string}>}
459
486
  */
460
- export async function callBridge(browser, method, args = {}) {
487
+ export async function callBridge(browser, method, args = {}, opts = {}) {
488
+ const write = opts.write === true;
461
489
  const expr = `window.__fishComment && window.__fishComment.${method}
462
490
  ? window.__fishComment.${method}(${JSON.stringify(args)})
463
- : Promise.resolve({ ok: false, error: '桥没装上(window.__fishComment 不存在)' })`;
491
+ : Promise.resolve({ ok: false, writeState: '${WRITE_NOT_ATTEMPTED}', error: '桥没装上(window.__fishComment 不存在)' })`;
464
492
  let r;
465
493
  try {
466
- r = await browser.eval(expr);
494
+ r = await browser.eval(expr, { timeoutMs: opts.timeoutMs });
467
495
  } catch (error) {
468
496
  // CDP 断了 / 页面崩了 —— 抛给调用方没意义,统一转成 ok:false
469
- return { ok: false, error: '桥调用失败:' + String(error instanceof Error ? error.message : error) };
497
+ const out = { ok: false, error: '桥调用失败:' + String(error instanceof Error ? error.message : error) };
498
+ // 写操作:CDP 断了不代表没发出去(请求可能已经发出去了,只是结果没回来)
499
+ if (write) out.writeState = WRITE_ATTEMPTED_UNKNOWN;
500
+ return out;
501
+ }
502
+ if (r && typeof r === 'object' && typeof r.ok === 'boolean') {
503
+ // 写操作:页面侧没给状态就按「可能已经发出去了」处理(宁可这次没回,也别重复发)
504
+ if (write && r.ok === false && !r.writeState) return Object.assign({}, r, { writeState: WRITE_ATTEMPTED_UNKNOWN });
505
+ return r;
470
506
  }
471
- if (r && typeof r === 'object' && typeof r.ok === 'boolean') return r;
472
- return { ok: false, error: '桥调用没返回结果:' + String(JSON.stringify(r) ?? r).slice(0, 200) };
507
+ const out = { ok: false, error: '桥调用没返回结果:' + String(JSON.stringify(r) ?? r).slice(0, 200) };
508
+ if (write) out.writeState = WRITE_ATTEMPTED_UNKNOWN;
509
+ return out;
473
510
  }
474
511
 
475
512
  /**
package/lib/client.js CHANGED
@@ -504,7 +504,7 @@ window.__ModuleLoader__.load({
504
504
  const [busy, setBusy] = react.useState(false);
505
505
  const [form, setForm, patch] = useForm(data, () => ({
506
506
  enabled: qq.enabled === true, wsUrl: qq.wsUrl ?? "ws://127.0.0.1:3001", accessToken: "", masterQqUin: data.masterQqUin ?? "",
507
- groupAllowList: (qq.groupAllowList ?? []).join(", "), allGroups: qq.allGroups === true, mentionOnly: qq.mentionOnly === true, followUpCount: qq.followUpCount ?? 3, followUpSeconds: qq.followUpSeconds ?? 120, batchMs: qq.batchMs ?? 3000, replyWindowMinutes: qq.replyWindowMinutes ?? 120,
507
+ groupAllowList: (qq.groupAllowList ?? []).join(", "), allGroups: qq.allGroups === true, privateAllowList: (qq.privateAllowList ?? []).join(", "), allFriends: qq.allFriends === true, mentionOnly: qq.mentionOnly === true, followUpCount: qq.followUpCount ?? 3, followUpSeconds: qq.followUpSeconds ?? 120, batchMs: qq.batchMs ?? 3000, replyWindowMinutes: qq.replyWindowMinutes ?? 120,
508
508
  callNames: (qq.callNames ?? []).join(", "), ij: { ...(qq.interject ?? {}), chance: Math.round((qq.interject?.chance ?? 0.05) * 100), keywords: (qq.interject?.keywords ?? []).join(", ") },
509
509
  stickersPerDay: qq.stickers?.perDay ?? 10,
510
510
  ga: { enabled: qq.groupAdmin?.enabled === true, groupId: qq.groupAdmin?.groupId ?? "", announce: qq.groupAdmin?.announce !== false, autoApprove: qq.groupAdmin?.autoApprove !== false }
@@ -516,7 +516,7 @@ window.__ModuleLoader__.load({
516
516
  setForm(next);
517
517
  const res = await api("POST", "/channels/qq-config", {
518
518
  enabled: next.enabled, wsUrl: next.wsUrl, ...(next.accessToken !== "" ? { accessToken: next.accessToken } : {}),
519
- masterQqUin: next.masterQqUin, groupAllowList: split(next.groupAllowList), allGroups: next.allGroups === true, mentionOnly: next.mentionOnly === true,
519
+ masterQqUin: next.masterQqUin, groupAllowList: split(next.groupAllowList), allGroups: next.allGroups === true, privateAllowList: split(next.privateAllowList), allFriends: next.allFriends === true, mentionOnly: next.mentionOnly === true,
520
520
  followUpCount: Number(next.followUpCount), followUpSeconds: Number(next.followUpSeconds), batchMs: Number(next.batchMs), replyWindowMinutes: Number(next.replyWindowMinutes), callNames: split(next.callNames),
521
521
  interject: { enabled: next.ij.enabled === true, chance: Number(next.ij.chance) / 100, cooldownMinutes: Number(next.ij.cooldownMinutes), maxPerHour: Number(next.ij.maxPerHour), keywords: split(next.ij.keywords) },
522
522
  groupAdmin: { enabled: next.ga.enabled === true, groupId: next.ga.groupId, announce: next.ga.announce === true, autoApprove: next.ga.autoApprove === true }
@@ -549,6 +549,8 @@ window.__ModuleLoader__.load({
549
549
  form.enabled ? Row({ title: "主人 QQ" }, field("masterQqUin", { inputMode: "numeric" })) : null,
550
550
  form.enabled ? Row({ title: "所有群" }, h(Switch, { label: "所有群", checked: form.allGroups, onChange: (v) => save({ allGroups: v }) }), Muted(form.allGroups ? "任何群里 @ 都回" : "只回下面列的群")) : null,
551
551
  form.enabled && !form.allGroups ? Row({ title: "只在这些群" }, field("groupAllowList", { placeholder: "群号,逗号分隔;空 = 谁都不回" })) : null,
552
+ form.enabled ? Row({ title: "所有好友", desc: "关掉后只回下面名单里的人,主人始终回。升级前好友私聊都会回,想保持那样就打开" }, h(Switch, { label: "所有好友", checked: form.allFriends === true, onChange: (v) => save({ allFriends: v }) }), Muted(form.allFriends ? "任何好友的私聊都回" : "只回名单里的人")) : null,
553
+ form.enabled && !form.allFriends ? Row({ title: "只回这些人" }, field("privateAllowList", { placeholder: "QQ 号,逗号分隔;空 = 只回主人" })) : null,
552
554
  form.enabled ? Row({ title: "群里只回点名", desc: "打开后:只在她被 @ 或叫名字时开口,关掉「接着听」和「自己想插一句」。几个机器人待在同一个群、互相接话刷屏时打开它" },
553
555
  h(Switch, { label: "群里只回点名", checked: form.mentionOnly === true, onChange: (v) => save({ mentionOnly: v }) })) : null,
554
556
  form.enabled && !form.mentionOnly ? Row({ title: "点名后接着听" },
@@ -487,15 +487,18 @@ window.__ModuleLoader__.load({
487
487
  const [source, setSource] = react.useState("");
488
488
  const [bulk, setBulk] = react.useState(false);
489
489
  const [sel, setSel] = react.useState(() => new Set());
490
+ const [page, setPage] = react.useState(0);
491
+ const [dateValue, setDateValue] = react.useState("");
490
492
  const [confirm, confirmNode] = useConfirm();
491
- const qs = new URLSearchParams({ ...(owner !== "all" ? { ownerId: owner } : {}), ...(qApplied ? { q: qApplied } : {}), ...(source ? { source } : {}), ...(bulk ? { limit: "500" } : {}) }).toString();
493
+ const pageSize = bulk ? 100 : 100;
494
+ const qs = new URLSearchParams({ ...(owner !== "all" ? { ownerId: owner } : {}), ...(qApplied ? { q: qApplied } : {}), ...(source ? { source } : {}), limit: String(pageSize), offset: String(page * pageSize) }).toString();
492
495
  const [data, load] = usePoll(api, `/inspector/overview${qs ? `?${qs}` : ""}`, 0);
493
496
  async function dropPending(id) {
494
497
  const r = await api("POST", "/inspector/forget", { targetType: "pending", id });
495
498
  if (r?.ok) { notify("已删掉这条待办"); load(); } else notify(r?.error ?? "删除失败");
496
499
  }
497
500
  const [adding, setAdding] = react.useState("");
498
- react.useEffect(() => { setSel(new Set()); }, [owner, qApplied, source, bulk]);
501
+ react.useEffect(() => { setSel(new Set()); setPage(0); }, [owner, qApplied, source, bulk]);
499
502
  if (!data) return null;
500
503
  const persons = data.persons ?? [];
501
504
  const memories = data.memories ?? [];
@@ -525,6 +528,9 @@ window.__ModuleLoader__.load({
525
528
  Button({ variant: "ghost", disabled: n === 0, onClick: () => runBulk("visibility", "private", "标成私密") }, "标私密"),
526
529
  Button({ variant: "ghost", disabled: n === 0, onClick: () => runBulk("visibility", "normal", "取消私密") }, "取消私密"),
527
530
  ...[1, 3, 5].map((v) => Button({ key: v, variant: "ghost", disabled: n === 0, onClick: () => runBulk("importance", v, `重要度改成 ${v}`) }, `重要度 ${v}`)),
531
+ Input({ type: "date", value: dateValue, "aria-label": "批量事件日期", onChange: (e) => setDateValue(e.target.value) }),
532
+ Button({ variant: "ghost", disabled: n === 0 || dateValue === "", onClick: () => runBulk("sortDate", dateValue, "事件日期已改") }, "设日期"),
533
+ Button({ variant: "ghost", disabled: n === 0, onClick: () => runBulk("sortDate", null, "事件日期已清空") }, "清日期"),
528
534
  h("span", { className: "fs-fill-gap" }),
529
535
  Button({ variant: "ghost", disabled: !narrowed, title: narrowed ? "删掉符合当前筛选(人 / 来源 / 包含的字)的全部记忆,不只是这页显示的" : "先选一个人、来源或输入要包含的字", onClick: () => runBulk("forget", null, "按筛选删除", true) },
530
536
  `删掉符合筛选的全部${data.matchedTotal != null ? ` ${data.matchedTotal} 条` : ""}`)));
@@ -557,7 +563,11 @@ window.__ModuleLoader__.load({
557
563
  Input({ value: adding, className: "wide", placeholder: "手动记一条(比如:她不吃香菜)", onChange: (e) => setAdding(e.target.value), onKeyDown: (e) => { if (e.key === "Enter" && adding.trim()) add(); } }),
558
564
  Button({ disabled: adding.trim() === "", onClick: add }, "记下")) : null,
559
565
  h("div", { className: "fs-list" }, memories.length === 0 ? Empty("还没有记忆")
560
- : memories.map((m) => h(MemoryItem, { key: m.id, m, ui, api, notify, refresh: load, curGen: data.currentGenerationId ?? 1, selectable: bulk, selected: sel.has(m.id), onSelect })))),
566
+ : memories.map((m) => h(MemoryItem, { key: m.id, m, ui, api, notify, refresh: load, curGen: data.currentGenerationId ?? 1, selectable: bulk, selected: sel.has(m.id), onSelect }))),
567
+ data.matchedTotal > pageSize ? h("div", { className: "fs-row" },
568
+ Button({ variant: "ghost", disabled: page === 0, onClick: () => setPage(page - 1) }, "上一页"),
569
+ Muted(`第 ${page + 1} / ${Math.ceil(data.matchedTotal / pageSize)} 页`),
570
+ Button({ variant: "ghost", disabled: (page + 1) * pageSize >= data.matchedTotal, onClick: () => setPage(page + 1) }, "下一页")) : null),
561
571
  pendings.length === 0 ? null : Group({ title: "待办", aside: Tag(String(pendings.length), "outline") },
562
572
  h("div", { className: "fs-list" }, pendings.map((p) => Item({
563
573
  key: p.id, lead: Muted(props.fmtDueAt(p.dueAt), { className: "fs-unit num" }), text: p.reason,
@@ -11,6 +11,8 @@ export function fishSoulConfigSchema(z) {
11
11
  accessToken: z.string().default(''),
12
12
  groupAllowList: z.array(z.string()).default([]), // 白名单:空 = 谁都不放行(默认拒绝);群要在这里列出才会被回应
13
13
  allGroups: z.boolean().default(false), // 显式放开:true = 所有群(仍然只听点名)
14
+ privateAllowList: z.array(z.string()).default([]), // 私聊白名单:空 = 谁都不放行(默认拒绝,主人永远放行);要放开所有好友见 allFriends
15
+ allFriends: z.boolean().default(false), // 显式放开:true = 所有好友的私聊都回(等价于旧的默认行为)
14
16
  followUpCount: z.number().default(3),
15
17
  followUpSeconds: z.number().default(120),
16
18
  followUpSmart: z.boolean().default(false), // #59 她自己说"这轮聊完了"就不接着听(默认关)
package/lib/diag-log.js CHANGED
@@ -42,6 +42,7 @@ const LABELS = {
42
42
  'context-size': '这一轮上下文长度',
43
43
  'image-skip': '图片没送进模型',
44
44
  'sticker-skip': '表情没收藏成功',
45
+ 'sticker-tag-failed': '表情补标签未全部成功',
45
46
  'turn-no-recall': '这一轮没组装记忆',
46
47
  'config-invalid': '配置文件读不懂',
47
48
  // 抖音私信的两类提示:设置页那块已经删了(主人嫌吵),落到这里来查。