dsh-fish-soul 0.18.4 → 0.18.5
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
|
@@ -597,6 +597,33 @@ function decodeMessageNode(c, selfSecUid = '', secByUid = null) {
|
|
|
597
597
|
}
|
|
598
598
|
}
|
|
599
599
|
|
|
600
|
+
/**
|
|
601
|
+
* 这条解出来的消息算不算「一条真消息」。
|
|
602
|
+
*
|
|
603
|
+
* 🔴 **全仓唯一的判据** —— 以前这个判据有 3 份副本(本文件的 `countUseful`
|
|
604
|
+
* 和 `pickMessages` 各一份内联、`douyin-dm.mjs` 的 `filterUseful` 一份),
|
|
605
|
+
* 修一处漏两处:#129 给 `filterUseful` 挡了协议控制帧,但这两处内联副本没挡,
|
|
606
|
+
* 于是控制帧(kind=50001、text 空、带 convId/seq/senderId)照样通过
|
|
607
|
+
* `pickMessages` 的「唯一会话」判定 → 它的 convId 被当成这一轮读到的会话,
|
|
608
|
+
* 多个会话拿到同一个 convId(#128 的串会话)。
|
|
609
|
+
* ⇒ 判据只留这一份,`douyin-dm.mjs` 从这里 import。
|
|
610
|
+
*
|
|
611
|
+
* 判据要点(都是踩出来的,别动):
|
|
612
|
+
* · 不能放 `kind`:空壳消息的 kind 也非 0(实测 58),放进来会让
|
|
613
|
+
* 「解出一堆空壳」的结构赢过「解出真消息」的结构。
|
|
614
|
+
* · 协议控制帧必须挡:`kind === 50001` 或带 `raw.command_type` 的帧
|
|
615
|
+
* (登录态同步、会话标记等)也有 convId/seq/senderId,但它不是用户消息,
|
|
616
|
+
* 拿来定会话归属会把别人的消息记到这个会话头上。
|
|
617
|
+
*
|
|
618
|
+
* @param {object} m parseMessages 解出来的消息
|
|
619
|
+
* @returns {boolean}
|
|
620
|
+
*/
|
|
621
|
+
export function isUsefulMessage(m) {
|
|
622
|
+
if (!m) return false
|
|
623
|
+
if (m.kind === 50001 || (m.raw && m.raw.command_type != null)) return false
|
|
624
|
+
return Boolean(m.text || m.tips || m.shareAweme || m.convId || m.seq || m.senderId)
|
|
625
|
+
}
|
|
626
|
+
|
|
600
627
|
/**
|
|
601
628
|
* 把 hook 抓到的一条 protobuf 响应解成消息数组。
|
|
602
629
|
*
|
|
@@ -642,15 +669,9 @@ export function parseMessages(raw, opts = {}) {
|
|
|
642
669
|
|
|
643
670
|
const selfSecUid = String(opts.selfSecUid || '')
|
|
644
671
|
|
|
645
|
-
//
|
|
646
|
-
//
|
|
647
|
-
|
|
648
|
-
// ⚠️ 判据里**不能放 kind**:空壳消息的 kind 也是非 0(实测 58),放进去会让「解出一堆空壳」
|
|
649
|
-
// 的结构赢过「解出真消息」的结构 —— 直接挑错。只有 convId / seq / senderId 才是
|
|
650
|
-
// 「这条真的是一条带身份的消息」的证据。
|
|
651
|
-
const countUseful = (list) => list.filter(
|
|
652
|
-
(m) => m.text || m.tips || m.shareAweme || m.convId || m.seq || m.senderId,
|
|
653
|
-
).length
|
|
672
|
+
// 「解出来了」的判据走全仓唯一那份(`isUsefulMessage`)—— 详见它的注释:
|
|
673
|
+
// 内联副本会漏掉后来加的判据(协议控制帧),#128 的串会话就是这么来的。
|
|
674
|
+
const countUseful = (list) => list.filter(isUsefulMessage).length
|
|
654
675
|
|
|
655
676
|
// ① 旧结构:消息在 `#6.#301.#1[]`。解每个 item 时重新走一遍原始字段,
|
|
656
677
|
// 否则 36 字节的会话 ID 会被 parseTree 误判成子树(见 fieldsToNodes 注释)。
|
|
@@ -861,12 +882,10 @@ export function pickMessages(captured, opts = {}) {
|
|
|
861
882
|
try {
|
|
862
883
|
const raw = Buffer.from(h.b64, 'base64')
|
|
863
884
|
const parsed = parseMessages(raw, opts)
|
|
864
|
-
//
|
|
865
|
-
//
|
|
866
|
-
//
|
|
867
|
-
const useful = parsed.messages.filter(
|
|
868
|
-
(m) => m.text || m.tips || m.shareAweme || m.convId || m.seq || m.senderId,
|
|
869
|
-
)
|
|
885
|
+
// 判据走全仓唯一那份(`isUsefulMessage`):媒体消息(无 text/tips)也算解出来了,
|
|
886
|
+
// 否则「对方只发图片」的响应会被整条跳过 → 推送/轮询都拿不到 convId;
|
|
887
|
+
// 同时又挡掉协议控制帧(它带 convId,会被当成「这一轮读到的会话」)。
|
|
888
|
+
const useful = parsed.messages.filter(isUsefulMessage)
|
|
870
889
|
if (!useful.length) continue
|
|
871
890
|
const ids = new Set(useful.map((m) => String(m.convId ?? '').trim()).filter((x) => x !== ''))
|
|
872
891
|
// 指定了会话:只要它,别的会话直接跳过
|
|
@@ -21,6 +21,7 @@ import {
|
|
|
21
21
|
drain as apiDrain,
|
|
22
22
|
peek as apiPeek,
|
|
23
23
|
pickMessages as apiPickMessages,
|
|
24
|
+
isUsefulMessage,
|
|
24
25
|
parseMessages as apiParseMessages,
|
|
25
26
|
selfInfo as apiSelfInfo,
|
|
26
27
|
triggerFetch as apiTriggerFetch,
|
|
@@ -401,13 +402,13 @@ function shapeResult(rawMessages, limit, via, convId = '') {
|
|
|
401
402
|
*
|
|
402
403
|
* ⚠️ 缓存也要用这个过滤 —— 否则缓存里塞一堆 kind=8 的空壳,
|
|
403
404
|
* `shapeResult` 过滤完就空了,表现为「缓存命中了但 0 条」。
|
|
405
|
+
*
|
|
406
|
+
* 🔴 判据本体在 `douyin-api.mjs` 的 `isUsefulMessage`(全仓唯一一份)。
|
|
407
|
+
* 以前这里是第 3 份副本,于是 #129 只修到这一份、漏了 api 里那两份,
|
|
408
|
+
* 控制帧照样从 `pickMessages` 穿过去(#128 的串会话)。别再复制判据过来。
|
|
404
409
|
*/
|
|
405
410
|
function filterUseful(rawMessages) {
|
|
406
|
-
return (rawMessages || []).filter(
|
|
407
|
-
// ⚠️ 判据里**不能放 kind**:空壳消息的 kind 也是非 0(实测 58),放进来会把
|
|
408
|
-
// 「解出一堆空壳」当成「解出消息」。只有 text/tips/shareAweme 或
|
|
409
|
-
// convId/seq/senderId 才算真的解出了一条带身份的消息。
|
|
410
|
-
m.text || m.tips || m.shareAweme || m.convId || m.seq || m.senderId)
|
|
411
|
+
return (rawMessages || []).filter(isUsefulMessage)
|
|
411
412
|
}
|
|
412
413
|
|
|
413
414
|
/** 内部函数给测试用(不参与对外契约)。 */
|
package/lib/douyin-browse.js
CHANGED
|
@@ -231,7 +231,9 @@ export class DouyinBrowser {
|
|
|
231
231
|
const timeout = () => Math.max(1, Math.min(this.tm.evalTimeoutMs, left()));
|
|
232
232
|
// 预算耗尽后**不能再发起** eval / send / 睡眠:max(1,…) 只防 0,不是通行证。
|
|
233
233
|
// 否则点「下一条」失败后,键盘 / 滚轮分支会各在预算之外再等一次超时,照样霸锁。
|
|
234
|
-
|
|
234
|
+
// 🔴 剩余预算只剩几毫秒时也别发起:timeout() 的 max(1,…) 会把 1ms 当成可用预算,
|
|
235
|
+
// 于是 send 在 left()=1ms 时被放行、1ms 后超时——断言「预算耗尽后不再发起」会红。
|
|
236
|
+
const expired = () => left() <= 10;
|
|
235
237
|
const changed = async () => {
|
|
236
238
|
for (let i = 0; i < 8; i++) {
|
|
237
239
|
if (expired()) return false;
|
package/lib/routes.js
CHANGED
|
@@ -567,6 +567,7 @@ export function registerRoutes(ctx, deps) {
|
|
|
567
567
|
followUpCount: q.followUpCount ?? 3,
|
|
568
568
|
followUpSeconds: q.followUpSeconds ?? 120,
|
|
569
569
|
followUpSmart: q.followUpSmart === true,
|
|
570
|
+
mentionOnly: q.mentionOnly === true,
|
|
570
571
|
// 回显:设置页的数字框要能读回来,否则改完刷新又弹回去(写进去读不出来)
|
|
571
572
|
replyWindowMinutes: clampReplyWindow(q.replyWindowMinutes),
|
|
572
573
|
batchMs: q.batchMs ?? 3000,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-fish-soul",
|
|
3
|
-
"version": "0.18.
|
|
3
|
+
"version": "0.18.5",
|
|
4
4
|
"description": "鱼 · 人格、按人记忆(可纠正、有印象、能导入旧聊天记录)、日程自走与主动开口,直连 SnowLuma 收发 QQ(群里会自己插话),B站 / 抖音小号私信与自己刷视频;按功能选模型并统计用量花费,能听会说 QQ 语音、收藏表情包、学群里的梗,可选上网查;心情影响说话、去 AI 味、每个群的设定、按聊天选模型、每晚写日记、每周记忆存档与可选周记(DSH 插件,单角色 feiyu ,v0.15.37)",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./lib/index.js",
|
|
@@ -64,6 +64,6 @@
|
|
|
64
64
|
}
|
|
65
65
|
},
|
|
66
66
|
"scripts": {
|
|
67
|
-
"test": "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-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/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/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/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/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/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/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/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"
|
|
67
|
+
"test": "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-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/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/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/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/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/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/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/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"
|
|
68
68
|
}
|
|
69
69
|
}
|