dsh-chat-comprehension 0.2.0 → 0.3.0
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/NOTICE.md +20 -0
- package/README.md +20 -9
- package/client.js +30 -9
- package/lib/engines.mjs +136 -0
- package/lib/index.js +37 -4
- package/lib/qqbot-0.5.3-patches.json +75 -70
- package/lib/qqbot-patch.mjs +12 -7
- package/lib/video.mjs +11 -2
- package/package.json +7 -23
- package/vendor/dsh-agent-md/LICENSE +21 -0
- package/vendor/dsh-agent-md/cordis.patch.yml +8 -0
- package/vendor/dsh-agent-md/lib/index.js +775 -0
- package/vendor/dsh-agent-md/lib/persona.js +634 -0
- package/vendor/dsh-agent-md/lib/qq.js +527 -0
- package/vendor/dsh-agent-md/package.json +50 -0
- package/vendor/dsh-bili-scroll/LICENSE +21 -0
- package/vendor/dsh-bili-scroll/NOTICE.md +18 -0
- package/vendor/dsh-bili-scroll/cordis.patch.yml +20 -0
- package/vendor/dsh-bili-scroll/index.js +3278 -0
- package/vendor/dsh-bili-scroll/lib/asr.py +141 -0
- package/vendor/dsh-bili-scroll/lib/diagnose.mjs +95 -0
- package/vendor/dsh-bili-scroll/lib/dm.mjs +110 -0
- package/vendor/dsh-bili-scroll/lib/favops.py +90 -0
- package/vendor/dsh-bili-scroll/lib/hostdeps.mjs +148 -0
- package/vendor/dsh-bili-scroll/lib/login.mjs +141 -0
- package/vendor/dsh-bili-scroll/lib/mcp.mjs +144 -0
- package/vendor/dsh-bili-scroll/lib/state.mjs +236 -0
- package/vendor/dsh-bili-scroll/lib/uid.mjs +61 -0
- package/vendor/dsh-bili-scroll/lib/uvfetch.mjs +217 -0
- package/vendor/dsh-bili-scroll/lib/verify.mjs +184 -0
- package/vendor/dsh-bili-scroll/package.json +84 -0
- package/vendor/dsh-bili-scroll/profile-template/bili-duty/cordis.patch.yml +116 -0
- package/vendor/dsh-bili-scroll/profile-template/bili-duty/cordis.yml +4 -0
- package/vendor/dsh-bili-scroll/profile-template/bili-duty/package.json +13 -0
- package/vendor/dsh-bili-scroll/prompts/duty.md +296 -0
- package/vendor/dsh-bili-scroll/vendor/bilibili-mcp/LICENSE +21 -0
- package/vendor/dsh-bili-scroll/vendor/bilibili-mcp/README.md +176 -0
- package/vendor/dsh-bili-scroll/vendor/bilibili-mcp/mcp_server.py +2015 -0
- package/vendor/dsh-bili-scroll/vendor/bilibili-mcp/requirements.txt +10 -0
- package/vendor/dsh-meme/.dsh/skills/dsh-meme-maintenance/SKILL.md +50 -0
- package/vendor/dsh-meme/LICENSE +21 -0
- package/vendor/dsh-meme/anim.js +588 -0
- package/vendor/dsh-meme/cordis.patch.yml +13 -0
- package/vendor/dsh-meme/icon.jpg +0 -0
- package/vendor/dsh-meme/index.js +2616 -0
- package/vendor/dsh-meme/locale/en.json +6 -0
- package/vendor/dsh-meme/locale/zh.json +6 -0
- package/vendor/dsh-meme/memes/dafeiyu-001/index.db +0 -0
- package/vendor/dsh-meme/memes/dafeiyu-001/manifest.json +13 -0
- package/vendor/dsh-meme/memes/dafeiyu-001/memes/angry/shengqi.jpg +0 -0
- package/vendor/dsh-meme/memes/dafeiyu-001/memes/baka/xianqi.jpg +0 -0
- package/vendor/dsh-meme/memes/dafeiyu-001/memes/color/huachi.jpg +0 -0
- package/vendor/dsh-meme/memes/dafeiyu-001/memes/confused/jiazai.jpg +0 -0
- package/vendor/dsh-meme/memes/dafeiyu-001/memes/confused/wenhao.jpg +0 -0
- package/vendor/dsh-meme/memes/dafeiyu-001/memes/cpu/jiaban.jpg +0 -0
- package/vendor/dsh-meme/memes/dafeiyu-001/memes/daily/ganfan.jpg +0 -0
- package/vendor/dsh-meme/memes/dafeiyu-001/memes/fool/buyao.jpg +0 -0
- package/vendor/dsh-meme/memes/dafeiyu-001/memes/givemoney/yaoqian.jpg +0 -0
- package/vendor/dsh-meme/memes/dafeiyu-001/memes/happy/deyi.jpg +0 -0
- package/vendor/dsh-meme/memes/dafeiyu-001/memes/happy/ok.jpg +0 -0
- package/vendor/dsh-meme/memes/dafeiyu-001/memes/happy/piaole.jpg +0 -0
- package/vendor/dsh-meme/memes/dafeiyu-001/memes/like/bixin.jpg +0 -0
- package/vendor/dsh-meme/memes/dafeiyu-001/memes/meow/maozhua.jpg +0 -0
- package/vendor/dsh-meme/memes/dafeiyu-001/memes/morning/zaoshanghao.jpg +0 -0
- package/vendor/dsh-meme/memes/dafeiyu-001/memes/sad/qiurao.jpg +0 -0
- package/vendor/dsh-meme/memes/dafeiyu-001/memes/sad/yun.jpg +0 -0
- package/vendor/dsh-meme/memes/dafeiyu-001/memes/see/zhenjing.jpg +0 -0
- package/vendor/dsh-meme/memes/dafeiyu-001/memes/shy/haixiu.jpg +0 -0
- package/vendor/dsh-meme/memes/dafeiyu-001/memes/shy/toukan.jpg +0 -0
- package/vendor/dsh-meme/memes/dafeiyu-001/memes/sigh/wuyu.jpg +0 -0
- package/vendor/dsh-meme/memes/dafeiyu-001/memes/sleep/shuijiao.jpg +0 -0
- package/vendor/dsh-meme/memes/dafeiyu-001/memes/surprised/xia.jpg +0 -0
- package/vendor/dsh-meme/memes/dafeiyu-001/memes/work/tangping.jpg +0 -0
- package/vendor/dsh-meme/memes.js +998 -0
- package/vendor/dsh-meme/package.json +67 -0
- package/vendor/dsh-meme/panel.html +210 -0
- package/vendor/dsh-video-storyboard/LICENSE +21 -0
- package/vendor/dsh-video-storyboard/NOTICE +12 -0
- package/vendor/dsh-video-storyboard/bin/_args.mjs +16 -0
- package/vendor/dsh-video-storyboard/bin/asr-check.mjs +85 -0
- package/vendor/dsh-video-storyboard/bin/scan-stats.mjs +43 -0
- package/vendor/dsh-video-storyboard/bin/scan-video.mjs +38 -0
- package/vendor/dsh-video-storyboard/bin/storyboard.mjs +195 -0
- package/vendor/dsh-video-storyboard/cordis.patch.yml +3 -0
- package/vendor/dsh-video-storyboard/dsh.plugin.json +12 -0
- package/vendor/dsh-video-storyboard/package.json +88 -0
- package/vendor/dsh-video-storyboard/scripts/check-syntax.mjs +56 -0
- package/vendor/dsh-video-storyboard/scripts/install-dev.mjs +104 -0
- package/vendor/dsh-video-storyboard/src/flicker.js +104 -0
- package/vendor/dsh-video-storyboard/src/index.js +82 -0
- package/vendor/dsh-video-storyboard/src/ocr_bridge.py +103 -0
- package/vendor/dsh-video-storyboard/src/storyboard/asr-lifecycle.js +262 -0
- package/vendor/dsh-video-storyboard/src/storyboard/asr.js +488 -0
- package/vendor/dsh-video-storyboard/src/storyboard/audio.js +168 -0
- package/vendor/dsh-video-storyboard/src/storyboard/binaries.js +69 -0
- package/vendor/dsh-video-storyboard/src/storyboard/board.js +121 -0
- package/vendor/dsh-video-storyboard/src/storyboard/browser-time.js +504 -0
- package/vendor/dsh-video-storyboard/src/storyboard/cache.js +143 -0
- package/vendor/dsh-video-storyboard/src/storyboard/cells.js +70 -0
- package/vendor/dsh-video-storyboard/src/storyboard/density.js +545 -0
- package/vendor/dsh-video-storyboard/src/storyboard/direct-url.js +130 -0
- package/vendor/dsh-video-storyboard/src/storyboard/fetch.js +373 -0
- package/vendor/dsh-video-storyboard/src/storyboard/flash.js +180 -0
- package/vendor/dsh-video-storyboard/src/storyboard/format.js +573 -0
- package/vendor/dsh-video-storyboard/src/storyboard/frames.js +212 -0
- package/vendor/dsh-video-storyboard/src/storyboard/index.js +32 -0
- package/vendor/dsh-video-storyboard/src/storyboard/injection.js +76 -0
- package/vendor/dsh-video-storyboard/src/storyboard/layout-order.js +176 -0
- package/vendor/dsh-video-storyboard/src/storyboard/locate.js +113 -0
- package/vendor/dsh-video-storyboard/src/storyboard/media-store.js +106 -0
- package/vendor/dsh-video-storyboard/src/storyboard/memory.js +94 -0
- package/vendor/dsh-video-storyboard/src/storyboard/ocr-subs.js +107 -0
- package/vendor/dsh-video-storyboard/src/storyboard/ocr.js +167 -0
- package/vendor/dsh-video-storyboard/src/storyboard/pipeline.js +853 -0
- package/vendor/dsh-video-storyboard/src/storyboard/plan.js +400 -0
- package/vendor/dsh-video-storyboard/src/storyboard/probe.js +132 -0
- package/vendor/dsh-video-storyboard/src/storyboard/provenance.js +44 -0
- package/vendor/dsh-video-storyboard/src/storyboard/python.js +84 -0
- package/vendor/dsh-video-storyboard/src/storyboard/register.js +32 -0
- package/vendor/dsh-video-storyboard/src/storyboard/scan.js +486 -0
- package/vendor/dsh-video-storyboard/src/storyboard/segments.js +117 -0
- package/vendor/dsh-video-storyboard/src/storyboard/sheet.js +507 -0
- package/vendor/dsh-video-storyboard/src/storyboard/storage.js +93 -0
- package/vendor/dsh-video-storyboard/src/storyboard/subtitles.js +181 -0
- package/vendor/dsh-video-storyboard/src/storyboard/tool-spec.js +544 -0
- package/vendor/dsh-video-storyboard/src/storyboard/transcript-file.js +146 -0
- package/vendor/dsh-video-storyboard/src/storyboard/url.js +69 -0
- package/vendor/dsh-video-storyboard/src/storyboard/ytdlp.js +289 -0
- package/vendor/dsh-video-storyboard/src/tool-spec.js +17 -0
- package/vendor/dsh-video-storyboard/src/tools/locate.js +39 -0
- package/vendor/dsh-video-storyboard/src/tools/probe.js +23 -0
- package/vendor/dsh-video-storyboard/src/tools/shared.js +39 -0
- package/vendor/dsh-video-storyboard/src/tools/storyboard.js +20 -0
- package/vendor/dsh-video-storyboard/src/tools/zoom.js +56 -0
- package/vendor/dsh-world/LICENSE +21 -0
- package/vendor/dsh-world/assets/qq-card.png +0 -0
- package/vendor/dsh-world/cordis.patch.yml +6 -0
- package/vendor/dsh-world/lib/archive.d.ts +6 -0
- package/vendor/dsh-world/lib/archive.js +49 -0
- package/vendor/dsh-world/lib/archiveSelection.d.ts +8 -0
- package/vendor/dsh-world/lib/archiveSelection.js +20 -0
- package/vendor/dsh-world/lib/compaction.d.ts +124 -0
- package/vendor/dsh-world/lib/compaction.js +273 -0
- package/vendor/dsh-world/lib/compactionRegion.d.ts +42 -0
- package/vendor/dsh-world/lib/compactionRegion.js +210 -0
- package/vendor/dsh-world/lib/console/routes.d.ts +57 -0
- package/vendor/dsh-world/lib/console/routes.js +129 -0
- package/vendor/dsh-world/lib/console/snapshot.d.ts +39 -0
- package/vendor/dsh-world/lib/console/snapshot.js +51 -0
- package/vendor/dsh-world/lib/ecosystem/bridge/bridge.d.ts +36 -0
- package/vendor/dsh-world/lib/ecosystem/bridge/bridge.js +140 -0
- package/vendor/dsh-world/lib/ecosystem/bridge/route.d.ts +9 -0
- package/vendor/dsh-world/lib/ecosystem/bridge/route.js +46 -0
- package/vendor/dsh-world/lib/ecosystem/qq/bridge.d.ts +123 -0
- package/vendor/dsh-world/lib/ecosystem/qq/bridge.js +380 -0
- package/vendor/dsh-world/lib/ecosystem/qq/panel.d.ts +75 -0
- package/vendor/dsh-world/lib/ecosystem/qq/panel.js +187 -0
- package/vendor/dsh-world/lib/ecosystem/qq/route.d.ts +32 -0
- package/vendor/dsh-world/lib/ecosystem/qq/route.js +134 -0
- package/vendor/dsh-world/lib/ecosystem/qq/supervisor.d.ts +57 -0
- package/vendor/dsh-world/lib/ecosystem/qq/supervisor.js +188 -0
- package/vendor/dsh-world/lib/ecosystem/shared/context.d.ts +14 -0
- package/vendor/dsh-world/lib/ecosystem/shared/context.js +42 -0
- package/vendor/dsh-world/lib/ecosystem/shared/identity.d.ts +15 -0
- package/vendor/dsh-world/lib/ecosystem/shared/identity.js +36 -0
- package/vendor/dsh-world/lib/ecosystem/shared/outlets.d.ts +43 -0
- package/vendor/dsh-world/lib/ecosystem/shared/outlets.js +70 -0
- package/vendor/dsh-world/lib/ecosystem/shared/sessions.d.ts +16 -0
- package/vendor/dsh-world/lib/ecosystem/shared/sessions.js +52 -0
- package/vendor/dsh-world/lib/ecosystem/wechat/archive.d.ts +24 -0
- package/vendor/dsh-world/lib/ecosystem/wechat/archive.js +62 -0
- package/vendor/dsh-world/lib/ecosystem/wechat/home.d.ts +21 -0
- package/vendor/dsh-world/lib/ecosystem/wechat/home.js +111 -0
- package/vendor/dsh-world/lib/ecosystem/wechat/images.d.ts +5 -0
- package/vendor/dsh-world/lib/ecosystem/wechat/images.js +43 -0
- package/vendor/dsh-world/lib/ecosystem/wechat/index.d.ts +41 -0
- package/vendor/dsh-world/lib/ecosystem/wechat/index.js +166 -0
- package/vendor/dsh-world/lib/ecosystem/wechat/messages.d.ts +24 -0
- package/vendor/dsh-world/lib/ecosystem/wechat/messages.js +35 -0
- package/vendor/dsh-world/lib/ecosystem/wechat/sending.d.ts +30 -0
- package/vendor/dsh-world/lib/ecosystem/wechat/sending.js +216 -0
- package/vendor/dsh-world/lib/ecosystem/wechat/supervisor.d.ts +39 -0
- package/vendor/dsh-world/lib/ecosystem/wechat/supervisor.js +138 -0
- package/vendor/dsh-world/lib/faults.d.ts +10 -0
- package/vendor/dsh-world/lib/faults.js +13 -0
- package/vendor/dsh-world/lib/history.d.ts +16 -0
- package/vendor/dsh-world/lib/history.js +80 -0
- package/vendor/dsh-world/lib/hostContract.d.ts +19 -0
- package/vendor/dsh-world/lib/hostContract.js +1 -0
- package/vendor/dsh-world/lib/http.d.ts +18 -0
- package/vendor/dsh-world/lib/http.js +39 -0
- package/vendor/dsh-world/lib/index.d.ts +108 -0
- package/vendor/dsh-world/lib/index.js +356 -0
- package/vendor/dsh-world/lib/life/activity.d.ts +14 -0
- package/vendor/dsh-world/lib/life/activity.js +58 -0
- package/vendor/dsh-world/lib/life/alarm.d.ts +39 -0
- package/vendor/dsh-world/lib/life/alarm.js +132 -0
- package/vendor/dsh-world/lib/life/alarmTimer.d.ts +22 -0
- package/vendor/dsh-world/lib/life/alarmTimer.js +49 -0
- package/vendor/dsh-world/lib/life/diary.d.ts +4 -0
- package/vendor/dsh-world/lib/life/diary.js +9 -0
- package/vendor/dsh-world/lib/life/earlyStop.d.ts +19 -0
- package/vendor/dsh-world/lib/life/earlyStop.js +25 -0
- package/vendor/dsh-world/lib/life/home.d.ts +34 -0
- package/vendor/dsh-world/lib/life/home.js +91 -0
- package/vendor/dsh-world/lib/life/host.d.ts +22 -0
- package/vendor/dsh-world/lib/life/host.js +24 -0
- package/vendor/dsh-world/lib/life/journal.d.ts +20 -0
- package/vendor/dsh-world/lib/life/journal.js +59 -0
- package/vendor/dsh-world/lib/life/lifeStore.d.ts +16 -0
- package/vendor/dsh-world/lib/life/lifeStore.js +105 -0
- package/vendor/dsh-world/lib/life/messages.d.ts +17 -0
- package/vendor/dsh-world/lib/life/messages.js +53 -0
- package/vendor/dsh-world/lib/life/notify.d.ts +15 -0
- package/vendor/dsh-world/lib/life/notify.js +40 -0
- package/vendor/dsh-world/lib/life/pricing.d.ts +4 -0
- package/vendor/dsh-world/lib/life/pricing.js +30 -0
- package/vendor/dsh-world/lib/life/runtime.d.ts +52 -0
- package/vendor/dsh-world/lib/life/runtime.js +376 -0
- package/vendor/dsh-world/lib/life/toolRegistry.d.ts +22 -0
- package/vendor/dsh-world/lib/life/toolRegistry.js +64 -0
- package/vendor/dsh-world/lib/life/tools.d.ts +24 -0
- package/vendor/dsh-world/lib/life/tools.js +47 -0
- package/vendor/dsh-world/lib/life/types.d.ts +67 -0
- package/vendor/dsh-world/lib/life/types.js +1 -0
- package/vendor/dsh-world/lib/persona.d.ts +10 -0
- package/vendor/dsh-world/lib/persona.js +29 -0
- package/vendor/dsh-world/lib/promptSection.d.ts +30 -0
- package/vendor/dsh-world/lib/promptSection.js +81 -0
- package/vendor/dsh-world/lib/qqScope.d.ts +11 -0
- package/vendor/dsh-world/lib/qqScope.js +39 -0
- package/vendor/dsh-world/lib/runtime.d.ts +23 -0
- package/vendor/dsh-world/lib/runtime.js +206 -0
- package/vendor/dsh-world/lib/self.d.ts +10 -0
- package/vendor/dsh-world/lib/self.js +36 -0
- package/vendor/dsh-world/lib/sourceArchive.d.ts +28 -0
- package/vendor/dsh-world/lib/sourceArchive.js +156 -0
- package/vendor/dsh-world/lib/store.d.ts +30 -0
- package/vendor/dsh-world/lib/store.js +191 -0
- package/vendor/dsh-world/lib/timeContext.d.ts +3 -0
- package/vendor/dsh-world/lib/timeContext.js +13 -0
- package/vendor/dsh-world/lib/types.d.ts +118 -0
- package/vendor/dsh-world/lib/types.js +1 -0
- package/vendor/dsh-world/lib/worldPrompt.d.ts +47 -0
- package/vendor/dsh-world/lib/worldPrompt.js +49 -0
- package/vendor/dsh-world/lib/worldSwitch.d.ts +44 -0
- package/vendor/dsh-world/lib/worldSwitch.js +78 -0
- package/vendor/dsh-world/package-lock.json +1088 -0
- package/vendor/dsh-world/package.json +88 -0
- package/vendor/dsh-world/scripts/enable-tool-free-compaction.ps1 +33 -0
- package/vendor/dsh-world/src/archive.ts +45 -0
- package/vendor/dsh-world/src/archiveSelection.ts +27 -0
- package/vendor/dsh-world/src/compaction.ts +260 -0
- package/vendor/dsh-world/src/compactionRegion.ts +172 -0
- package/vendor/dsh-world/src/console/routes.ts +125 -0
- package/vendor/dsh-world/src/console/snapshot.ts +84 -0
- package/vendor/dsh-world/src/ecosystem/README.md +14 -0
- package/vendor/dsh-world/src/ecosystem/bridge/bridge.ts +121 -0
- package/vendor/dsh-world/src/ecosystem/bridge/route.ts +35 -0
- package/vendor/dsh-world/src/ecosystem/qq/bridge.ts +456 -0
- package/vendor/dsh-world/src/ecosystem/qq/panel.ts +178 -0
- package/vendor/dsh-world/src/ecosystem/qq/route.ts +130 -0
- package/vendor/dsh-world/src/ecosystem/qq/supervisor.ts +262 -0
- package/vendor/dsh-world/src/ecosystem/shared/context.ts +38 -0
- package/vendor/dsh-world/src/ecosystem/shared/identity.ts +42 -0
- package/vendor/dsh-world/src/ecosystem/shared/outlets.ts +75 -0
- package/vendor/dsh-world/src/ecosystem/shared/sessions.ts +47 -0
- package/vendor/dsh-world/src/ecosystem/wechat/archive.ts +66 -0
- package/vendor/dsh-world/src/ecosystem/wechat/home.ts +94 -0
- package/vendor/dsh-world/src/ecosystem/wechat/images.ts +38 -0
- package/vendor/dsh-world/src/ecosystem/wechat/index.ts +101 -0
- package/vendor/dsh-world/src/ecosystem/wechat/messages.ts +43 -0
- package/vendor/dsh-world/src/ecosystem/wechat/sending.ts +177 -0
- package/vendor/dsh-world/src/ecosystem/wechat/supervisor.ts +116 -0
- package/vendor/dsh-world/src/ecosystem/wechat/windows/README.md +117 -0
- package/vendor/dsh-world/src/ecosystem/wechat/windows/adapter.py +572 -0
- package/vendor/dsh-world/src/ecosystem/wechat/windows/binding.py +52 -0
- package/vendor/dsh-world/src/ecosystem/wechat/windows/engine/LICENSE +43 -0
- package/vendor/dsh-world/src/ecosystem/wechat/windows/engine/NOTICE.md +10 -0
- package/vendor/dsh-world/src/ecosystem/wechat/windows/engine/bridge.cpp +229 -0
- package/vendor/dsh-world/src/ecosystem/wechat/windows/engine/build.ps1 +19 -0
- package/vendor/dsh-world/src/ecosystem/wechat/windows/engine/profile.json +28 -0
- package/vendor/dsh-world/src/ecosystem/wechat/windows/groups.py +42 -0
- package/vendor/dsh-world/src/ecosystem/wechat/windows/incoming.py +157 -0
- package/vendor/dsh-world/src/ecosystem/wechat/windows/native.py +168 -0
- package/vendor/dsh-world/src/ecosystem/wechat/windows/outgoing.py +95 -0
- package/vendor/dsh-world/src/ecosystem/wechat/windows/requirements.txt +1 -0
- package/vendor/dsh-world/src/ecosystem/wechat/windows/sender.py +157 -0
- package/vendor/dsh-world/src/ecosystem/wechat/windows/snapshot.py +32 -0
- package/vendor/dsh-world/src/ecosystem/wechat/windows/stickers.py +60 -0
- package/vendor/dsh-world/src/ecosystem/wechat/windows/wechat.ps1 +75 -0
- package/vendor/dsh-world/src/faults.ts +12 -0
- package/vendor/dsh-world/src/history.ts +77 -0
- package/vendor/dsh-world/src/hostContract.ts +9 -0
- package/vendor/dsh-world/src/http.ts +34 -0
- package/vendor/dsh-world/src/index.ts +286 -0
- package/vendor/dsh-world/src/life/activity.ts +48 -0
- package/vendor/dsh-world/src/life/alarm.ts +119 -0
- package/vendor/dsh-world/src/life/alarmTimer.ts +45 -0
- package/vendor/dsh-world/src/life/diary.ts +10 -0
- package/vendor/dsh-world/src/life/earlyStop.ts +27 -0
- package/vendor/dsh-world/src/life/home.ts +85 -0
- package/vendor/dsh-world/src/life/host.ts +50 -0
- package/vendor/dsh-world/src/life/journal.ts +44 -0
- package/vendor/dsh-world/src/life/lifeStore.ts +70 -0
- package/vendor/dsh-world/src/life/messages.ts +44 -0
- package/vendor/dsh-world/src/life/notify.ts +47 -0
- package/vendor/dsh-world/src/life/pricing.ts +37 -0
- package/vendor/dsh-world/src/life/runtime.ts +318 -0
- package/vendor/dsh-world/src/life/toolRegistry.ts +48 -0
- package/vendor/dsh-world/src/life/tools.ts +61 -0
- package/vendor/dsh-world/src/life/types.ts +19 -0
- package/vendor/dsh-world/src/persona.ts +26 -0
- package/vendor/dsh-world/src/promptSection.ts +71 -0
- package/vendor/dsh-world/src/qqScope.ts +51 -0
- package/vendor/dsh-world/src/runtime.ts +172 -0
- package/vendor/dsh-world/src/self.ts +32 -0
- package/vendor/dsh-world/src/sourceArchive.ts +132 -0
- package/vendor/dsh-world/src/store.ts +170 -0
- package/vendor/dsh-world/src/timeContext.ts +13 -0
- package/vendor/dsh-world/src/types.ts +112 -0
- package/vendor/dsh-world/src/worldPrompt.ts +64 -0
- package/vendor/dsh-world/src/worldSwitch.ts +82 -0
- package/vendor/dsh-world/templates/alarm.md +49 -0
- package/vendor/dsh-world/templates/world-prompt.md +7 -0
- package/vendor/dsh-world/tests/archive.test.ts +57 -0
- package/vendor/dsh-world/tests/archiveScope.test.ts +86 -0
- package/vendor/dsh-world/tests/bridge.test.ts +211 -0
- package/vendor/dsh-world/tests/channelSessions.test.ts +79 -0
- package/vendor/dsh-world/tests/clientHooks.test.ts +103 -0
- package/vendor/dsh-world/tests/compaction.test.ts +141 -0
- package/vendor/dsh-world/tests/console.test.ts +202 -0
- package/vendor/dsh-world/tests/consoleClient.test.ts +101 -0
- package/vendor/dsh-world/tests/enableCompaction.test.ts +19 -0
- package/vendor/dsh-world/tests/fixtures.ts +6 -0
- package/vendor/dsh-world/tests/history.test.ts +100 -0
- package/vendor/dsh-world/tests/hostFixture.ts +46 -0
- package/vendor/dsh-world/tests/lifeActivity.test.ts +70 -0
- package/vendor/dsh-world/tests/lifeAlarm.test.ts +87 -0
- package/vendor/dsh-world/tests/lifeDiary.test.ts +33 -0
- package/vendor/dsh-world/tests/lifeMessages.test.ts +61 -0
- package/vendor/dsh-world/tests/lifeNotify.test.ts +46 -0
- package/vendor/dsh-world/tests/lifeParts.test.ts +45 -0
- package/vendor/dsh-world/tests/lifeRuntime.test.ts +660 -0
- package/vendor/dsh-world/tests/lifeStore.test.ts +90 -0
- package/vendor/dsh-world/tests/lifeTools.test.ts +53 -0
- package/vendor/dsh-world/tests/outlets.test.ts +85 -0
- package/vendor/dsh-world/tests/panel.test.ts +85 -0
- package/vendor/dsh-world/tests/plugin.test.ts +614 -0
- package/vendor/dsh-world/tests/pricing.test.ts +21 -0
- package/vendor/dsh-world/tests/qq.test.ts +121 -0
- package/vendor/dsh-world/tests/qqSessionMode.test.ts +97 -0
- package/vendor/dsh-world/tests/qqSupervisor.test.ts +149 -0
- package/vendor/dsh-world/tests/sourceArchive.test.ts +58 -0
- package/vendor/dsh-world/tests/store.test.ts +82 -0
- package/vendor/dsh-world/tests/storeWriter.ts +5 -0
- package/vendor/dsh-world/tests/timeContext.test.ts +15 -0
- package/vendor/dsh-world/tests/wechat.test.ts +254 -0
- package/vendor/dsh-world/tests/wechatImages.test.ts +130 -0
- package/vendor/dsh-world/tests/wechatSending.test.ts +142 -0
- package/vendor/dsh-world/tests/wechatSupervisor.test.ts +91 -0
- package/vendor/dsh-world/tests/worldPrompt.test.ts +201 -0
- package/vendor/dsh-world/tsconfig.build.json +5 -0
- package/vendor/dsh-world/tsconfig.json +8 -0
package/NOTICE.md
CHANGED
|
@@ -9,6 +9,26 @@
|
|
|
9
9
|
| [dsh-bili-scroll](https://github.com/c1overzz/dsh-bili-scroll) | B站 值班、MCP、日报 | Copyright (c) 2026 c1overzz(内含 bilibili-mcp,Copyright (c) 2026 AGI_Ananas) |
|
|
10
10
|
| [dsh-world](https://github.com/chenkezhen480/dsh-world) | 跨会话记忆 | Copyright (c) 2026 ckz |
|
|
11
11
|
| [@tencent-connect/dsh-qqbot](https://github.com/tencent-connect/dsh-qqbot) | QQ 网关 | Copyright (c) 2026 Tencent Connect |
|
|
12
|
+
| [dsh-video-storyboard](https://github.com/SAOS-3624/dsh-video-storyboard) | QQ 分享视频的分镜/台词 | Copyright (c) 2026 SAOS-3624 |
|
|
13
|
+
| [silk-wasm](https://www.npmjs.com/package/silk-wasm) | QQ 原生 SILK 语音(可选依赖) | Copyright (c) 见上游 LICENSE |
|
|
14
|
+
| [DeepSeek Harness](https://github.com/deepseek-ai/deepseek-harness) | 宿主运行时 | Copyright (c) 2026 DeepSeek Harness contributors |
|
|
12
15
|
|
|
13
16
|
本仓库对它们的改动(QQ 专属记忆作用域、关注列表/自定义时间/联网校时、提示词去冲突、统一界面等)
|
|
14
17
|
以同样的 MIT 条款提供。完整的 MIT 正文分别见各上游仓库的 `LICENSE`;`dsh-chat-comprehension` 自身见本目录的 `LICENSE`。
|
|
18
|
+
|
|
19
|
+
**不随 MIT 代码授权的内容**:角色人格/同人图(需自行确认角色与图片授权)、本地 TTS 下载的模型权重、
|
|
20
|
+
`ffmpeg` / `yt-dlp` 等外部工具;它们不打包在本仓库/本 npm 包里。
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
## 内置引擎(0.3.0 起,vendor/)
|
|
24
|
+
|
|
25
|
+
为减少安装步骤,本包内置了以下引擎的宿主核心(host half)与运行资产;各引擎的客户端/设置页不再随包加载:
|
|
26
|
+
|
|
27
|
+
- `dsh-agent-md` 0.2.0 — MIT
|
|
28
|
+
- `dsh-bili-scroll` 2.2.2-local.1 — MIT(基于上游 dsh-bili-scroll,署名见其 LICENSE/NOTICE)
|
|
29
|
+
- `dsh-world` 0.5.6-local.3 — MIT(基于上游 dsh-world)
|
|
30
|
+
- `dsh-meme` 0.1.63 — MIT(基于 selfloom / dsh-meme)
|
|
31
|
+
- `dsh-video-storyboard` 0.5.0 — MIT(基于上游 dsh-video-storyboard)
|
|
32
|
+
|
|
33
|
+
各引擎的 LICENSE 文件保留在 `vendor/<包名>/LICENSE`。QQ 网关 `@tencent-connect/dsh-qqbot` 仍由用户单独安装,
|
|
34
|
+
本包只提供自动补丁,不内置其代码。
|
package/README.md
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
# dsh-chat-comprehension · 陪伴套件
|
|
2
2
|
|
|
3
|
+
基于dsh-bili-scroll dsh-agent-md dsh-memory dsh-vidio-story dsh-meme五个插件融合开发的养鱼/聊天/谈恋爱的功能最丰富的插件
|
|
3
4
|
给 DeepSeek Harness 一个「一个入口」的陪伴层:**局部人格 + QQ 联动 + 专属记忆 + B站 值班**。
|
|
4
5
|
左侧栏只有一个图标「陪伴」;设置弹层里不再出现三个插件各自那一页。
|
|
5
6
|
|
|
6
|
-
> 当前是 **0.
|
|
7
|
+
> 当前是 **0.3.0**:五个引擎的宿主核心全部内置在本包 `vendor/`;**只装这一个包**就有效果,不会再装/依赖别的引擎插件。QQ 网关仍单独安装(本包只自动打 companion 补丁)。
|
|
7
8
|
> 发布到 npm 后,安装只需要一条:`dsh plugin --profile web add dsh-chat-comprehension`。
|
|
8
9
|
|
|
9
10
|
## 页面里有什么
|
|
@@ -16,7 +17,10 @@
|
|
|
16
17
|
| 人格 | **只做局部人格**:按项目目录编辑、按模板新建、打开原文件;全局人格已删除 |
|
|
17
18
|
| 对话与 QQ | 本项目对话列表、新建/打开、把选中的对话接到 QQ、解除绑定、QQ 机器人扫码绑定 |
|
|
18
19
|
| 记忆 | 世界引擎状态、参与记忆的对话数、最近轮数、**记忆镜像**(可直接读) |
|
|
19
|
-
| B站 | 扫码登录、自动时间(峰谷 + 自定义时间点 +
|
|
20
|
+
| B站 | 扫码登录、自动时间(峰谷 + 自定义时间点 + 联网校时)、关注来源与人数、人格/记忆开关、额外要求、每天条数、私信互通/读图、现在跑一轮、日志与报告 |
|
|
21
|
+
| 表情包 | dsh-meme 状态、AI 斗图开关、图库管理入口 |
|
|
22
|
+
| 语音 | 云端 Qwen-TTS / Sambert、本地 Qwen3-TTS / vLLM / OpenAI 兼容 / GPT-SoVITS / CosyVoice / Fish / 自定义 HTTP、试听、发到 QQ |
|
|
23
|
+
| 环境 | 逐项体检(Node/Python/dashscope/uv/venv/ffmpeg/yt-dlp/SILK/QQ 补丁/内置引擎),缺什么、命令是什么都写出来;有「一键修复内置引擎」重新挂载 |
|
|
20
24
|
| 关于 | 版本、许可、上游署名、发布命令 |
|
|
21
25
|
|
|
22
26
|
## 人格与提示词:只留一处会生效
|
|
@@ -47,9 +51,16 @@
|
|
|
47
51
|
dsh plugin --profile web add dsh-chat-comprehension
|
|
48
52
|
```
|
|
49
53
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
54
|
+
本包已经内置五个引擎的宿主核心与资产(`dsh-agent-md`、`dsh-bili-scroll`、`dsh-world`、`dsh-meme`、`dsh-video-storyboard`),**不需要另外安装它们**;
|
|
55
|
+
插件加载时自动挂载。已经单独安装的引擎会优先用你那份(可选),不会重复挂载。
|
|
56
|
+
|
|
57
|
+
仍需单独准备的是:
|
|
58
|
+
|
|
59
|
+
- `@tencent-connect/dsh-qqbot`(QQ 网关;本包只自动打 companion 补丁);
|
|
60
|
+
- 原生工具:ffmpeg / yt-dlp(视频分镜用)、dashscope(Sambert 用)、uv;
|
|
61
|
+
- 你自己的 TTS Key(不启用语音就发文字)。
|
|
62
|
+
|
|
63
|
+
内置引擎的 host 代码在 `vendor/`;各引擎自带的设置页/客户端不再加载,统一由本页面接管。
|
|
53
64
|
|
|
54
65
|
## 开发(本机)
|
|
55
66
|
|
|
@@ -74,20 +85,20 @@ dsh plugin --profile web add dsh-chat-comprehension
|
|
|
74
85
|
`dsh-chat-comprehension` **不会**把 `@tencent-connect/dsh-qqbot` 一起装进来:它在
|
|
75
86
|
`peerDependencies` 里只是可选 peer,`cordis.patch.yml` 也只插入聚合入口这一行。
|
|
76
87
|
|
|
77
|
-
需要 QQ 的能力时,请单独安装 0.5.3:
|
|
88
|
+
需要 QQ 的能力时,请单独安装 0.5.3 / 0.5.4 / 0.5.5:
|
|
78
89
|
|
|
79
90
|
```bash
|
|
80
|
-
dsh plugin --profile web add @tencent-connect/dsh-qqbot@0.5.
|
|
91
|
+
dsh plugin --profile web add @tencent-connect/dsh-qqbot@0.5.5
|
|
81
92
|
```
|
|
82
93
|
|
|
83
94
|
插件加载时会自动扫描 `~/.dsh/profiles/*/node_modules/@tencent-connect/dsh-qqbot`:
|
|
84
95
|
|
|
85
|
-
- 发现 **0.5.3** →
|
|
96
|
+
- 发现 **0.5.3 / 0.5.4 / 0.5.5** → 自动打上补丁(0.5.5 的 `lib/gateway/` 和 0.5.3 的 `dist/gateway/` 都支持)(数据在 `lib/qqbot-0.5.3-patches.json`):
|
|
86
97
|
- v1:`companionQq` 服务、语音回复、关流式;
|
|
87
98
|
- v2:语音按 SILK 发(QQ 原生格式)、QQ 小程序卡片(B站 分享)补上视频链接(在访问控制之后);
|
|
88
99
|
- 每个文件第一次改动前留 `*.companion-orig` 备份,改完做 `node --check`,不过就整份还原;
|
|
89
100
|
- 已经打过的步骤 → 跳过(可以反复跑);
|
|
90
|
-
- 其他版本 → 不硬改,页面「环境」里明确提示只适配 0.5.3;
|
|
101
|
+
- 其他版本 → 不硬改,页面「环境」里明确提示只适配 0.5.3 / 0.5.4 / 0.5.5;
|
|
91
102
|
- QQ 网关重装/升级覆盖了补丁 → 下次启动自动补回来。
|
|
92
103
|
|
|
93
104
|
打完补丁需要**重启一次 DSH** 才会加载到打过补丁的 qqbot 模块。页面「环境」里有
|
package/client.js
CHANGED
|
@@ -688,6 +688,16 @@ window.__ModuleLoader__.load({
|
|
|
688
688
|
await checkDoctor()
|
|
689
689
|
}), [runBusy, checkDoctor, say])
|
|
690
690
|
|
|
691
|
+
const repairEngines = useCallback(() => runBusy('engines-repair', async () => {
|
|
692
|
+
try {
|
|
693
|
+
const r = await post(CC + '/engines/repair', {})
|
|
694
|
+
if (r && r.ok) say('内置引擎已重新挂载', 'ok')
|
|
695
|
+
else say('重新挂载失败:' + String((r && (r.error || r.detail)) || '看插件日志').slice(-400), 'err')
|
|
696
|
+
} catch (error) { say('重新挂载失败:' + errText(error), 'err') }
|
|
697
|
+
await checkDoctor()
|
|
698
|
+
await load()
|
|
699
|
+
}), [runBusy, checkDoctor, load, say])
|
|
700
|
+
|
|
691
701
|
const patchQqbot = useCallback(() => runBusy('doctor-patch', async () => {
|
|
692
702
|
try {
|
|
693
703
|
const r = await post(CC + '/qqbot/patch', {})
|
|
@@ -713,7 +723,7 @@ window.__ModuleLoader__.load({
|
|
|
713
723
|
return () => { clearInterval(timer); document.removeEventListener('visibilitychange', onVisible) }
|
|
714
724
|
}, [load])
|
|
715
725
|
|
|
716
|
-
useEffect(() => { loadTts() }, [loadTts])
|
|
726
|
+
useEffect(() => { loadTts(); loadMeme() }, [loadTts, loadMeme])
|
|
717
727
|
|
|
718
728
|
// 只在这几个页签打开时才拉重数据(表情包索引、环境体检),平时不跑。
|
|
719
729
|
useEffect(() => {
|
|
@@ -1178,6 +1188,16 @@ window.__ModuleLoader__.load({
|
|
|
1178
1188
|
const ttsPresets = tts && Array.isArray(tts.presets) ? tts.presets : []
|
|
1179
1189
|
const memSessions = memInfo && Array.isArray(memInfo.sessions) ? memInfo.sessions.length : 0
|
|
1180
1190
|
const qqServiceOk = Boolean(mem && mem.qqService && mem.qqService.available)
|
|
1191
|
+
const engineMountState = (id) => (mem && Array.isArray(mem.engines) ? mem.engines.find((e) => e && e.id === id) : null)
|
|
1192
|
+
const engineRow = (id, label, loaded, loadedDetail, command) => {
|
|
1193
|
+
const mount = engineMountState(id)
|
|
1194
|
+
// 挂载成功就算“在运行”;页面自己的数据(meme/memeStatus 等)没拉到时,
|
|
1195
|
+
// 只影响详情文案,不能因此把这一行标红。
|
|
1196
|
+
if (mount && mount.mounted) return { id, label, ok: true, detail: loaded ? '已内置(随本插件)' : '已内置(随本插件)· 打开对应页后显示详情', command: '' }
|
|
1197
|
+
if (mount && mount.installed) return { id, label, ok: true, detail: loaded ? '已单独安装' : '已单独安装 · 打开对应页后显示详情', command: '' }
|
|
1198
|
+
if (mount && mount.error) return { id, label, ok: false, detail: '内置挂载失败:' + mount.error, command: '' }
|
|
1199
|
+
return { id, label, ok: loaded, detail: loaded ? loadedDetail : '没加载', command }
|
|
1200
|
+
}
|
|
1181
1201
|
const loading = !loaded
|
|
1182
1202
|
|
|
1183
1203
|
const statusChips = [
|
|
@@ -1645,15 +1665,16 @@ window.__ModuleLoader__.load({
|
|
|
1645
1665
|
h(Btn, { icon: 'save', kind: 'primary', disabled: busy['doctor-install'] || busy['doctor-check'] || busy['doctor-patch'], onClick: installDashscope }, busy['doctor-install'] ? '安装中(最多 3 分钟)…' : '安装 dashscope'),
|
|
1646
1666
|
(doctor.checks || []).some((c) => c.id === 'yt-dlp' && !c.ok) ? h(Btn, { icon: 'save', disabled: busy.ytdlp, onClick: installYtdlp }, busy.ytdlp ? '安装 yt-dlp 中…' : '安装 yt-dlp') : null,
|
|
1647
1667
|
h(Btn, { icon: 'link', disabled: busy['doctor-patch'] || busy['doctor-check'], onClick: patchQqbot }, busy['doctor-patch'] ? '打补丁中…' : '打 QQ 网关补丁'),
|
|
1668
|
+
h(Btn, { icon: 'refresh', disabled: busy['engines-repair'] || busy['doctor-check'], onClick: repairEngines }, busy['engines-repair'] ? '重新挂载中…' : '一键修复内置引擎'),
|
|
1648
1669
|
h('span', { className: 'dc-note' }, '装进上面那个 Python;打补丁只改 QQ 网关,重启后生效。'))),
|
|
1649
|
-
h(Card, { title: '引擎 / 插件', sub: '
|
|
1670
|
+
h(Card, { title: '引擎 / 插件', sub: '引擎已内置;QQ 网关单独装;原生依赖看「环境」' },
|
|
1650
1671
|
h('div', { className: 'dc-list' },
|
|
1651
1672
|
[
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
{ id: 'storyboard', label: 'dsh-video-storyboard · 视频分镜(QQ 分享的 B站 视频)', ok: Boolean(videoInfo && videoInfo.storyboard && videoInfo.storyboard.installed), detail: videoInfo && videoInfo.storyboard && videoInfo.storyboard.installed ? 'v' + videoInfo.storyboard.version : (videoInfo ? '没装' : '打开「B站」页后检测'), command: '
|
|
1673
|
+
engineRow('agent-md', 'dsh-agent-md · 局部人格 / QQ 绑定', Boolean(agent), '已加载', ''),
|
|
1674
|
+
engineRow('bili-scroll', 'dsh-bili-scroll · B站 值班', Boolean(bili), '已加载', ''),
|
|
1675
|
+
engineRow('world', 'dsh-world · QQ 专属记忆', Boolean(world), '已加载', ''),
|
|
1676
|
+
engineRow('meme', 'dsh-meme · 表情包', Boolean(meme), meme ? 'v' + (meme.pluginVersion || '?') : (memeStatus === 'idle' || memeStatus === 'loading' ? '打开「表情包」页后检测' : '没装/没加载'), ''),
|
|
1677
|
+
{ id: 'storyboard', label: 'dsh-video-storyboard · 视频分镜(QQ 分享的 B站 视频)', ok: Boolean(videoInfo && videoInfo.storyboard && videoInfo.storyboard.installed), detail: videoInfo && videoInfo.storyboard && videoInfo.storyboard.installed ? (videoInfo.storyboard.bundled ? '已内置 v' + videoInfo.storyboard.version : '已单独安装 v' + videoInfo.storyboard.version) : (videoInfo ? '没装' : '打开「B站」页后检测'), command: '' },
|
|
1657
1678
|
{ id: 'qq', label: 'QQ 网关(companionQq)', ok: qqServiceOk, detail: mem && mem.qqService ? (mem.qqService.available ? '服务已提供' : '服务没提供') : '没检测到', command: 'dsh plugin --profile web add @tencent-connect/dsh-qqbot@latest' },
|
|
1658
1679
|
{ id: 'qq-patch', label: 'QQ 网关补丁(companionQq / 语音)', ok: Boolean(mem && mem.qqbotPatch && mem.qqbotPatch.patched), detail: mem && mem.qqbotPatch ? (mem.qqbotPatch.patched ? '已打(' + (mem.qqbotPatch.version || '') + ')' : (mem.qqbotPatch.found ? (mem.qqbotPatch.error || '未打') : '没装 QQ 网关')) : '等待检测', command: '' },
|
|
1659
1680
|
].map((c) => h('div', { key: c.id, className: 'dc-item' },
|
|
@@ -1661,8 +1682,8 @@ window.__ModuleLoader__.load({
|
|
|
1661
1682
|
h('div', { className: 'dc-item-main' },
|
|
1662
1683
|
h('div', { className: 'dc-item-title' }, c.label),
|
|
1663
1684
|
h('div', { className: 'dc-item-sub' }, c.detail),
|
|
1664
|
-
c.ok ? null : h('code', { className: 'dc-code' }, c.command))))),
|
|
1665
|
-
h('div', { className: 'dc-note', style: { marginTop: '10px' } }, '
|
|
1685
|
+
c.ok ? null : (c.command ? h('code', { className: 'dc-code' }, c.command) : null))))),
|
|
1686
|
+
h('div', { className: 'dc-note', style: { marginTop: '10px' } }, '人格、B站、记忆、表情包、视频分镜的宿主核心已内置在本包 vendor/ 里;没单独安装时自动挂载,装了则直接用你的。QQ 网关仍单独安装,本包只自动打 companion 补丁。'))) : null,
|
|
1666
1687
|
|
|
1667
1688
|
tab === 'about' ? h('div', { className: 'dc-grid two' },
|
|
1668
1689
|
h(Card, { title: 'dsh-chat-comprehension', sub: '把几套东西收成一个入口' },
|
package/lib/engines.mjs
ADDED
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* engines.mjs —— 把五个引擎的宿主核心内置进本插件。
|
|
3
|
+
*
|
|
4
|
+
* 关键修正(2026-10-31):
|
|
5
|
+
* - 以前用 node_modules/<pkg> 判断“已安装”就跳过;但包在 node_modules 里
|
|
6
|
+
* ≠ 这个包真的被 profile 的 bundles/rows 加载了。结果是:包在、引擎没跑,
|
|
7
|
+
* 本插件还跳过挂载 ⇒ 页面所有引擎都“没加载”。
|
|
8
|
+
* - 现在只认 **当前 profile 的 dsh.profile.bundles** 或 `cordis.patch.yml` 里的
|
|
9
|
+
* 引擎行;都没有才从 vendor/ 挂载。repair 强制重挂,并先 dispose 旧挂载。
|
|
10
|
+
*/
|
|
11
|
+
import { existsSync, readFileSync, readdirSync } from 'node:fs'
|
|
12
|
+
import { homedir } from 'node:os'
|
|
13
|
+
import { join } from 'node:path'
|
|
14
|
+
|
|
15
|
+
export const VENDORED_ENGINES = [
|
|
16
|
+
{ id: 'agent-md', pkg: 'dsh-agent-md', entry: '../vendor/dsh-agent-md/lib/index.js', config: {} },
|
|
17
|
+
{ id: 'bili-scroll', pkg: 'dsh-bili-scroll', entry: '../vendor/dsh-bili-scroll/index.js', config: {} },
|
|
18
|
+
{ id: 'world', pkg: 'dsh-world', entry: '../vendor/dsh-world/lib/index.js', config: {} },
|
|
19
|
+
{ id: 'meme', pkg: 'dsh-meme', entry: '../vendor/dsh-meme/index.js', config: {} },
|
|
20
|
+
{ id: 'video-storyboard', pkg: 'dsh-video-storyboard', entry: '../vendor/dsh-video-storyboard/src/index.js', config: {} },
|
|
21
|
+
]
|
|
22
|
+
|
|
23
|
+
function dshHome() {
|
|
24
|
+
const fromEnv = String(process.env.DSH_HOME || '').trim()
|
|
25
|
+
return fromEnv || join(homedir(), '.dsh')
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function activeProfileDirs() {
|
|
29
|
+
const explicitDir = String(process.env.DSH_PROFILE_DIR || '').trim()
|
|
30
|
+
if (explicitDir) return [explicitDir]
|
|
31
|
+
const explicitName = String(process.env.DSH_PROFILE || '').trim()
|
|
32
|
+
if (explicitName) return [join(dshHome(), 'profiles', explicitName)]
|
|
33
|
+
const profiles = join(dshHome(), 'profiles')
|
|
34
|
+
if (!existsSync(profiles)) return []
|
|
35
|
+
try { return readdirSync(profiles).map((name) => join(profiles, name)) } catch { return [] }
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
function readText(file) {
|
|
39
|
+
try { return readFileSync(file, 'utf8') } catch { return '' }
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/** 这个引擎是否真的被当前 profile 的 bundles 或 patch 行加载。 */
|
|
43
|
+
export function engineInstalled(pkg) {
|
|
44
|
+
for (const dir of activeProfileDirs()) {
|
|
45
|
+
try {
|
|
46
|
+
const pkgJson = JSON.parse(readText(join(dir, 'package.json')) || '{}')
|
|
47
|
+
const bundles = pkgJson?.dsh?.profile?.bundles || []
|
|
48
|
+
if (Array.isArray(bundles) && bundles.includes(pkg)) return true
|
|
49
|
+
} catch { /* 没 package.json 就下一个 */ }
|
|
50
|
+
// 只认 cordis.patch.yml 里真正的行(name: <包名>),不认 HMR 路径/注释里出现的包名。
|
|
51
|
+
// 之前用 includes(pkg) 会把 HMR root 的路径也当成“已安装”,导致明明没装也跳过。
|
|
52
|
+
const patch = readText(join(dir, 'cordis.patch.yml'))
|
|
53
|
+
if (patch) {
|
|
54
|
+
const esc = pkg.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')
|
|
55
|
+
const row = new RegExp('(^|\n)[ \\t]*name:[ \\t]*[\'"]?' + esc + '[\'"]?[ \\t]*(#.*)?$')
|
|
56
|
+
if (row.test(patch)) return true
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
return false
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
const TOOL_NAMES = {
|
|
63
|
+
'bili-scroll': ['bili_status'],
|
|
64
|
+
meme: ['send_meme'],
|
|
65
|
+
'video-storyboard': ['video_storyboard'],
|
|
66
|
+
}
|
|
67
|
+
const ROUTE_PATHS = {
|
|
68
|
+
'agent-md': '/api/agent-md/state',
|
|
69
|
+
world: '/dsh-world/console/snapshot',
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
function selfBaseUrl() {
|
|
73
|
+
const explicit = String(process.env.COMPANION_SELF_URL || '').trim()
|
|
74
|
+
if (explicit) return explicit.replace(/\/+$/, '')
|
|
75
|
+
return 'http://127.0.0.1:' + (process.env.PORT || 3080)
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/** 真正有没有跑起来:优先看 tools 注册,再看引擎自己的 HTTP 路由。 */
|
|
79
|
+
async function engineLoaded(ctx, engine) {
|
|
80
|
+
const tools = ctx.get('tools')
|
|
81
|
+
const names = TOOL_NAMES[engine.id]
|
|
82
|
+
if (names && tools && typeof tools.list === 'function') {
|
|
83
|
+
try {
|
|
84
|
+
const list = tools.list()
|
|
85
|
+
const ids = new Set((Array.isArray(list) ? list : []).map((t) => (typeof t === 'string' ? t : t && t.name)).filter(Boolean))
|
|
86
|
+
if (names.some((n) => ids.has(n))) return true
|
|
87
|
+
} catch { /* 工具列表读不到就退回 HTTP */ }
|
|
88
|
+
}
|
|
89
|
+
const route = ROUTE_PATHS[engine.id]
|
|
90
|
+
if (route) {
|
|
91
|
+
try {
|
|
92
|
+
const r = await fetch(selfBaseUrl() + route, { signal: AbortSignal.timeout(3000) })
|
|
93
|
+
// 401/403 也说明引擎路由在;404 才是没加载
|
|
94
|
+
return r.status !== 404
|
|
95
|
+
} catch { return false }
|
|
96
|
+
}
|
|
97
|
+
return false
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
const mounted = new Map()
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* 挂载未由 profile 加载的引擎。返回每项状态,供页面/体检显示。
|
|
104
|
+
* 必须在 webServer/tools 等服务可用之后调用。
|
|
105
|
+
*/
|
|
106
|
+
export async function mountVendoredEngines(ctx, { force = false } = {}) {
|
|
107
|
+
const results = []
|
|
108
|
+
for (const engine of VENDORED_ENGINES) {
|
|
109
|
+
const loaded = await engineLoaded(ctx, engine)
|
|
110
|
+
if (!force && loaded) {
|
|
111
|
+
results.push({ id: engine.id, pkg: engine.pkg, installed: true, mounted: false, reason: 'already-loaded' })
|
|
112
|
+
continue
|
|
113
|
+
}
|
|
114
|
+
try {
|
|
115
|
+
const mod = await import(new URL(engine.entry, import.meta.url))
|
|
116
|
+
if (typeof ctx.plugin !== 'function') throw new Error('当前宿主没有 ctx.plugin')
|
|
117
|
+
const fiber = ctx.plugin(mod, engine.config)
|
|
118
|
+
mounted.set(engine.id, fiber)
|
|
119
|
+
results.push({ id: engine.id, pkg: engine.pkg, installed: false, mounted: true })
|
|
120
|
+
console.log(`[companion] 已内置挂载引擎 ${engine.pkg}`)
|
|
121
|
+
} catch (error) {
|
|
122
|
+
results.push({ id: engine.id, pkg: engine.pkg, installed: false, mounted: false, error: String((error && error.message) || error) })
|
|
123
|
+
console.warn(`[companion] 内置引擎 ${engine.pkg} 挂载失败:${String((error && error.message) || error)}`)
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
return results
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/** 一键修复:先卸掉上次 vendor 挂载,再强制全部重挂(不动 profile 里已单独加载的引擎)。 */
|
|
130
|
+
export async function repairVendoredEngines(ctx) {
|
|
131
|
+
for (const fiber of mounted.values()) {
|
|
132
|
+
try { fiber?.dispose?.() } catch { /* 旧挂载清理失败不影响重挂 */ }
|
|
133
|
+
}
|
|
134
|
+
mounted.clear()
|
|
135
|
+
return mountVendoredEngines(ctx, { force: false })
|
|
136
|
+
}
|
package/lib/index.js
CHANGED
|
@@ -19,6 +19,7 @@ import { silkAvailable, wavToSilk } from './silk.mjs'
|
|
|
19
19
|
import { cosyVoiceTts, customHttpTts, findFfmpeg, fishSpeechTts, gptSovitsTts, openaiLikeTts, probeService, toWav } from './tts-local.mjs'
|
|
20
20
|
import { createQwen3Local, QWEN3_MODELS, QWEN3_SPEAKERS } from './qwen3-local.mjs'
|
|
21
21
|
import { createVideoHelper } from './video.mjs'
|
|
22
|
+
import { mountVendoredEngines, repairVendoredEngines } from './engines.mjs'
|
|
22
23
|
import { createVoiceStore } from './voices.mjs'
|
|
23
24
|
import { chmodSync, closeSync, existsSync, fstatSync, mkdirSync, openSync, readFileSync, readSync, statSync, unlinkSync, writeFileSync } from 'node:fs'
|
|
24
25
|
import { homedir } from 'node:os'
|
|
@@ -717,7 +718,7 @@ async function doctor(ctx) {
|
|
|
717
718
|
py.source === 'system' ? '没找到 B站 venv,用的是系统 Python;系统 Python 可能拒绝安装,先让 B站 值班建好 venv 更稳' : '语音页选 Sambert 时需要;点下面的一键安装',
|
|
718
719
|
pyOk ? '' : `uv pip install --python ${py.args.length ? '<python 路径>' : quoted} dashscope`)
|
|
719
720
|
|
|
720
|
-
add('uv', 'uv(Python 环境工具)', Boolean(uv), uv ? uv.version : '没找到 uv', '安装 uv 后可以一键装 dashscope', uv ? '' : (process.platform === 'win32' ? 'powershell -c "irm https://astral.sh/uv/install.ps1 | iex"' : 'curl -LsSf https://astral.sh/uv/install.sh | sh'))
|
|
721
|
+
add('uv', 'uv(Python 环境工具)', Boolean(uv), uv ? uv.version : '没找到 uv', '安装 uv 后可以一键装 dashscope', uv ? '' : (process.platform === 'win32' ? 'powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"' : 'curl -LsSf https://astral.sh/uv/install.sh | sh'))
|
|
721
722
|
const venvDir = join(dshHome(), 'bili-duty', '.venv')
|
|
722
723
|
add('venv', 'B站 Python 环境', existsSync(biliVenvPython()), existsSync(biliVenvPython()) ? venvDir : (existsSync(venvDir) ? '目录在,但里面没有 Python' : '还没建'), 'B站 值班/转写/Sambert 共用一个 venv', '')
|
|
723
724
|
|
|
@@ -751,6 +752,12 @@ async function doctor(ctx) {
|
|
|
751
752
|
add('qqbot-patch', 'QQ 网关 companion 补丁', Boolean(qp && qp.found && qp.patched), qpDetail,
|
|
752
753
|
'装好 QQ 网关后插件会自动识别并打;打完需要重启一次 DSH', qp && qp.found ? '' : 'dsh plugin --profile web add @tencent-connect/dsh-qqbot@latest')
|
|
753
754
|
|
|
755
|
+
const mounts = Array.isArray(engineMounts) ? engineMounts : []
|
|
756
|
+
const enginesOk = mounts.length > 0 && mounts.every((e) => e.installed || e.mounted)
|
|
757
|
+
add('engines', '内置引擎(人格/B站/记忆/表情包/分镜)', enginesOk,
|
|
758
|
+
mounts.length ? mounts.map((e) => e.pkg + (e.installed ? '(已单独装)' : e.mounted ? '(内置)' : '(挂载失败)')).join(' / ') : '还没挂载',
|
|
759
|
+
'没单独安装的引擎会从本包 vendor/ 自动挂载;挂载失败看 DSH 日志', '')
|
|
760
|
+
|
|
754
761
|
const ttsScript = join(dirname(fileURLToPath(import.meta.url)), 'tts_sambert.py')
|
|
755
762
|
add('tts-script', 'Sambert 脚本', existsSync(ttsScript), existsSync(ttsScript) ? ttsScript : '缺失', '插件文件不完整,重装插件', '')
|
|
756
763
|
|
|
@@ -806,6 +813,8 @@ function installYtdlpOnce() {
|
|
|
806
813
|
|
|
807
814
|
// 启动时自动识别并给 QQ 网关打补丁;状态给页面/体检用。
|
|
808
815
|
let qqbotPatchState = null
|
|
816
|
+
// 内置引擎挂载状态(已单独安装的引擎会跳过)。
|
|
817
|
+
let engineMounts = []
|
|
809
818
|
// 本地 Qwen3-TTS 小服务、视频分镜辅助(apply 时创建,卸载时清掉)
|
|
810
819
|
let qwen3 = null
|
|
811
820
|
let video = null
|
|
@@ -866,6 +875,7 @@ function snapshot(ctx) {
|
|
|
866
875
|
},
|
|
867
876
|
qqService,
|
|
868
877
|
qqbotPatch: qqbotPatchState,
|
|
878
|
+
engines: engineMounts,
|
|
869
879
|
video: video ? video.view() : null,
|
|
870
880
|
lastCard: (() => {
|
|
871
881
|
const c = readJson(CARD_CAPTURE, null)
|
|
@@ -882,7 +892,7 @@ function snapshot(ctx) {
|
|
|
882
892
|
|
|
883
893
|
/* ───────────────────────────── 路由 ───────────────────────────── */
|
|
884
894
|
|
|
885
|
-
export function apply(ctx) {
|
|
895
|
+
export async function apply(ctx) {
|
|
886
896
|
// 自动识别已安装的 QQ 网关并打 companion 补丁(补丁被重装覆盖后,下次启动会自己补回来)。
|
|
887
897
|
try {
|
|
888
898
|
qqbotPatchState = ensureQqbotPatched()
|
|
@@ -900,7 +910,7 @@ export function apply(ctx) {
|
|
|
900
910
|
console.log('[companion] QQ 网关补丁检测失败:' + qqbotPatchState.error)
|
|
901
911
|
}
|
|
902
912
|
qwen3 = createQwen3Local({ home: dshHome(), runProcess })
|
|
903
|
-
video = createVideoHelper({ home: dshHome(), runProcess })
|
|
913
|
+
video = createVideoHelper({ home: dshHome(), runProcess, bundledStoryboard: join(dirname(fileURLToPath(import.meta.url)), '..', 'vendor', 'dsh-video-storyboard') })
|
|
904
914
|
voices = createVoiceStore({ home: dshHome(), runProcess })
|
|
905
915
|
video.sync()
|
|
906
916
|
ctx.effect(() => () => {
|
|
@@ -977,6 +987,10 @@ export function apply(ctx) {
|
|
|
977
987
|
qqbotPatchState = ensureQqbotPatched()
|
|
978
988
|
return sendJson(res, 200, { ok: Boolean(qqbotPatchState && qqbotPatchState.patched), ...qqbotPatchState })
|
|
979
989
|
}
|
|
990
|
+
if (req.method === 'POST' && path === '/engines/repair') {
|
|
991
|
+
engineMounts = await repairVendoredEngines(ctx)
|
|
992
|
+
return sendJson(res, 200, { ok: engineMounts.every((e) => e.installed || e.mounted), engines: engineMounts })
|
|
993
|
+
}
|
|
980
994
|
if (req.method === 'POST' && path === '/doctor/install') {
|
|
981
995
|
const body = await readBody(req)
|
|
982
996
|
const what = String(body.what || '')
|
|
@@ -1166,7 +1180,16 @@ export function apply(ctx) {
|
|
|
1166
1180
|
} else if (ctx.webServer !== undefined && ctx.webServer !== null) {
|
|
1167
1181
|
ctx.effect(() => ctx.webServer.register(route))
|
|
1168
1182
|
}
|
|
1169
|
-
|
|
1183
|
+
|
|
1184
|
+
// 没单独安装的引擎:从 vendor/ 自动挂载(QQ 网关不在这里)。
|
|
1185
|
+
try {
|
|
1186
|
+
engineMounts = await mountVendoredEngines(ctx)
|
|
1187
|
+
} catch (error) {
|
|
1188
|
+
engineMounts = [{ id: 'mount', pkg: 'engines', installed: false, mounted: false, error: String((error && error.message) || error) }]
|
|
1189
|
+
ctx.logger?.warn?.('内置引擎挂载失败:' + String((error && error.message) || error))
|
|
1190
|
+
}
|
|
1191
|
+
|
|
1192
|
+
ctx.logger?.info?.('dsh-chat-comprehension:聚合入口已挂载(含 TTS / 斗图通道状态 / 内置引擎)')
|
|
1170
1193
|
}
|
|
1171
1194
|
|
|
1172
1195
|
// companion tts reload 1793101841
|
|
@@ -1182,3 +1205,13 @@ export function apply(ctx) {
|
|
|
1182
1205
|
// doctor reload 1793190861
|
|
1183
1206
|
|
|
1184
1207
|
// qqbot patch reload 1793341241
|
|
1208
|
+
|
|
1209
|
+
// engines integration reload 1793407885
|
|
1210
|
+
|
|
1211
|
+
// engines repair reload 1793412506
|
|
1212
|
+
|
|
1213
|
+
// engines path fix 1793412527
|
|
1214
|
+
|
|
1215
|
+
// actual loaded detection 1793412798
|
|
1216
|
+
|
|
1217
|
+
// meme status fix 1793414547
|
|
@@ -1,76 +1,81 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
{
|
|
6
|
-
"file": "gateway/bootstrap.js",
|
|
7
|
-
"v1Markers": [
|
|
8
|
-
"companionQq",
|
|
9
|
-
"stripForTts",
|
|
10
|
-
"botReady"
|
|
11
|
-
],
|
|
12
|
-
"steps": [
|
|
2
|
+
"version": 2,
|
|
3
|
+
"qqbot": "0.5.3",
|
|
4
|
+
"files": [
|
|
13
5
|
{
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
6
|
+
"file": "gateway/bootstrap.js",
|
|
7
|
+
"v1Markers": [
|
|
8
|
+
"companionQq",
|
|
9
|
+
"stripForTts",
|
|
10
|
+
"botReady"
|
|
11
|
+
],
|
|
12
|
+
"steps": [
|
|
13
|
+
{
|
|
14
|
+
"group": "v1",
|
|
15
|
+
"old": "import { QQBot } from '@tencent-connect/qqbot-nodejs';",
|
|
16
|
+
"new": "import { QQBot } from '@tencent-connect/qqbot-nodejs';\nimport { unlinkSync, writeFileSync } from 'node:fs';\nimport { tmpdir } from 'node:os';\nimport { join } from 'node:path';"
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
"group": "v1",
|
|
20
|
+
"old": " logger.info(`QQBot SDK initialized (UA: ${userAgent})`);",
|
|
21
|
+
"new": " logger.info(`QQBot SDK initialized (UA: ${userAgent})`);\n /** companionQq / 语音回复用:SDK 是否 ready。 */\n let botReady = false;\n // 语音回复需要拿到完整文本再合成;关掉流式,避免把半句话先 TTS 出去。\n config.streaming = false;"
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
"group": "v1",
|
|
25
|
+
"old": " bot.on('error', (err) => {\n logger.error(`bot error: ${err instanceof Error ? err.message : String(err)}`);\n });",
|
|
26
|
+
"new": " bot.on('error', (err) => {\n botReady = false;\n logger.error(`bot error: ${err instanceof Error ? err.message : String(err)}`);\n });"
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
"group": "v1",
|
|
30
|
+
"old": " else {\n logger.error(`Bot disconnected permanently (${detail}), giving up`);\n }",
|
|
31
|
+
"new": " else {\n botReady = false;\n logger.error(`Bot disconnected permanently (${detail}), giving up`);\n }"
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
"group": "v1",
|
|
35
|
+
"old": " bot.on('ready', () => {\n console.log(`[im-qqbot] Bot ready! appId=${config.appId}`);\n });",
|
|
36
|
+
"new": " bot.on('ready', () => {\n botReady = true;\n console.log(`[im-qqbot] Bot ready! appId=${config.appId}`);\n });"
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
"group": "v1",
|
|
40
|
+
"old": " const sender = {\n sendMarkdown: (target, content, opts) => sendResolvedMarkdown(bot, resolveReplyTarget(target, replyLimiter, true), content, opts),\n openStream: (target) => bot.openStream({\n target: {\n scope: target.scope,\n targetId: target.targetId,\n msgId: target.msgId,\n },\n }),\n };",
|
|
41
|
+
"new": " const sender = {\n sendMarkdown: (target, content, opts) => sendResolvedMarkdown(bot, resolveReplyTarget(target, replyLimiter, true), content, opts),\n openStream: (target) => bot.openStream({\n target: {\n scope: target.scope,\n targetId: target.targetId,\n msgId: target.msgId,\n },\n }),\n };\n // ── 语音回复:companionTts 在时,assistant 的 Markdown 先合成语音再发,不再发文字 ──\n const stripForTts = (content) => String(content || '')\n .replace(/```[\\s\\S]*?```/g, ' ')\n .replace(/`([^`]*)`/g, '$1')\n .replace(/\\*\\*([^*]+)\\*\\*/g, '$1')\n .replace(/\\[([^\\]]+)\\]\\([^)]+\\)/g, '$1')\n .replace(/https?:\\/\\/\\S+/g, ' ')\n .replace(/([^)]*)/g, ' ')\n .replace(/\\([^)]*\\)/g, ' ')\n .replace(/[“”「」]/g, '')\n .replace(/[#>*_~]/g, ' ')\n .replace(/\\s+/g, ' ')\n .trim();\n const isSystemNotice = (content) => /^[\\s]*(⚠️|❌|✅|🛠️|📎|📷|🧾)/.test(String(content || ''));\n const originalSendMarkdown = sender.sendMarkdown;\n sender.sendMarkdown = async (target, content, opts) => {\n if (!(opts && opts.keyboard) && !isSystemNotice(content)) {\n let tts = null;\n let ttsStatus = null;\n try {\n tts = ctx.get('companionTts');\n if (tts && typeof tts.status === 'function') ttsStatus = tts.status();\n } catch { tts = null; ttsStatus = null; }\n if (tts && typeof tts.synthesize === 'function' && ttsStatus && ttsStatus.enabled) {\n const speakable = stripForTts(content);\n if (speakable !== '') {\n try {\n const result = await tts.synthesize(speakable);\n if (!result || !result.buffer || result.buffer.length === 0) throw new Error('TTS 没有返回音频');\n const file = join(tmpdir(), 'dsh-qqbot-tts-' + Date.now() + '-' + Math.random().toString(16).slice(2) + '.wav');\n writeFileSync(file, result.buffer);\n try {\n await bot.sendVoice(resolveReplyTarget(target, replyLimiter, false), { localPath: file });\n } finally {\n try { unlinkSync(file); } catch { /* ignore */ }\n }\n return;\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error);\n if (error && error.code === 'tts-config') {\n logger.error(`im-qqbot: TTS config error: ${message}`);\n await originalSendMarkdown(target, '⚠️ 语音配置错误:' + message, opts);\n return;\n }\n logger.warn(`im-qqbot: TTS voice failed, fallback to text: ${message}`);\n await originalSendMarkdown(target, content, opts);\n return;\n }\n }\n }\n }\n return originalSendMarkdown(target, content, opts);\n };"
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
"group": "v1",
|
|
45
|
+
"old": " // 交付物投递:present 声明的文件在轮末发送到当前会话(outbound 路由触发)\n const deliverablesDeliverer = new DeliverablesDeliverer(sender, mediaSender, config, logger);",
|
|
46
|
+
"new": " // ── companionQq 服务:dsh-meme 等插件经它把图/语音发到 QQ ──\n const latestReplyTarget = () => {\n let best = null;\n for (const record of manager.sessions.values()) {\n if (!record || !record.replyTarget) continue;\n if (!best || Number(record.lastActivity || 0) > Number(best.lastActivity || 0)) best = record;\n }\n return best ? best.replyTarget : null;\n };\n if (typeof ctx.provide === 'function') {\n try {\n const disposeCompanionQq = ctx.provide('companionQq', {\n isOnline: () => botReady,\n get lastChatTarget() { return latestReplyTarget(); },\n async sendImage(path, caption) {\n if (!botReady) throw new Error('QQ 通道未就绪');\n const target = latestReplyTarget();\n if (!target) throw new Error('还没有 QQ 聊天目标');\n return bot.sendImage(resolveReplyTarget(target, replyLimiter, false), { localPath: String(path) }, caption ? { content: String(caption) } : undefined);\n },\n async sendVoice(path) {\n if (!botReady) throw new Error('QQ 通道未就绪');\n const target = latestReplyTarget();\n if (!target) throw new Error('还没有 QQ 聊天目标');\n return bot.sendVoice(resolveReplyTarget(target, replyLimiter, false), { localPath: String(path) });\n },\n });\n try { ctx.emit('companionQq/available'); } catch { /* no event bus */ }\n ctx.effect(() => () => { try { if (typeof disposeCompanionQq === 'function') disposeCompanionQq(); } catch { /* ignore */ } }, 'im-qqbot.companionQq');\n logger.info('im-qqbot: companionQq 服务已提供(dsh-meme / 语音)');\n } catch (err) {\n logger.warn(`im-qqbot: companionQq 服务注册失败: ${err instanceof Error ? err.message : String(err)}`);\n }\n }\n // 交付物投递:present 声明的文件在轮末发送到当前会话(outbound 路由触发)\n const deliverablesDeliverer = new DeliverablesDeliverer(sender, mediaSender, config, logger);"
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
"group": "v2",
|
|
50
|
+
"old": "const file = join(tmpdir(), 'dsh-qqbot-tts-' + Date.now() + '-' + Math.random().toString(16).slice(2) + '.wav');",
|
|
51
|
+
"new": "const file = join(tmpdir(), 'dsh-qqbot-tts-' + Date.now() + '-' + Math.random().toString(16).slice(2) + '.' + (result.ext === 'silk' || result.ext === 'mp3' ? result.ext : 'wav')); // companion-patch:v2 silk"
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
"group": "v2",
|
|
55
|
+
"old": " setupMiddlewares(bot, config, manager, logger);",
|
|
56
|
+
"new": " setupMiddlewares(bot, config, manager, logger, ctx); // companion-patch:v2 cards"
|
|
57
|
+
}
|
|
58
|
+
]
|
|
17
59
|
},
|
|
18
60
|
{
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
},
|
|
33
|
-
{
|
|
34
|
-
"group": "v1",
|
|
35
|
-
"old": " bot.on('ready', () => {\n console.log(`[im-qqbot] Bot ready! appId=${config.appId}`);\n });",
|
|
36
|
-
"new": " bot.on('ready', () => {\n botReady = true;\n console.log(`[im-qqbot] Bot ready! appId=${config.appId}`);\n });"
|
|
37
|
-
},
|
|
38
|
-
{
|
|
39
|
-
"group": "v1",
|
|
40
|
-
"old": " const sender = {\n sendMarkdown: (target, content, opts) => sendResolvedMarkdown(bot, resolveReplyTarget(target, replyLimiter, true), content, opts),\n openStream: (target) => bot.openStream({\n target: {\n scope: target.scope,\n targetId: target.targetId,\n msgId: target.msgId,\n },\n }),\n };",
|
|
41
|
-
"new": " const sender = {\n sendMarkdown: (target, content, opts) => sendResolvedMarkdown(bot, resolveReplyTarget(target, replyLimiter, true), content, opts),\n openStream: (target) => bot.openStream({\n target: {\n scope: target.scope,\n targetId: target.targetId,\n msgId: target.msgId,\n },\n }),\n };\n // ── 语音回复:companionTts 在时,assistant 的 Markdown 先合成语音再发,不再发文字 ──\n const stripForTts = (content) => String(content || '')\n .replace(/```[\\s\\S]*?```/g, ' ')\n .replace(/`([^`]*)`/g, '$1')\n .replace(/\\*\\*([^*]+)\\*\\*/g, '$1')\n .replace(/\\[([^\\]]+)\\]\\([^)]+\\)/g, '$1')\n .replace(/https?:\\/\\/\\S+/g, ' ')\n .replace(/([^)]*)/g, ' ')\n .replace(/\\([^)]*\\)/g, ' ')\n .replace(/[“”「」]/g, '')\n .replace(/[#>*_~]/g, ' ')\n .replace(/\\s+/g, ' ')\n .trim();\n const isSystemNotice = (content) => /^[\\s]*(⚠️|❌|✅|🛠️|📎|📷|🧾)/.test(String(content || ''));\n const originalSendMarkdown = sender.sendMarkdown;\n sender.sendMarkdown = async (target, content, opts) => {\n if (!(opts && opts.keyboard) && !isSystemNotice(content)) {\n let tts = null;\n let ttsStatus = null;\n try {\n tts = ctx.get('companionTts');\n if (tts && typeof tts.status === 'function') ttsStatus = tts.status();\n } catch { tts = null; ttsStatus = null; }\n if (tts && typeof tts.synthesize === 'function' && ttsStatus && ttsStatus.enabled) {\n const speakable = stripForTts(content);\n if (speakable !== '') {\n try {\n const result = await tts.synthesize(speakable);\n if (!result || !result.buffer || result.buffer.length === 0) throw new Error('TTS 没有返回音频');\n const file = join(tmpdir(), 'dsh-qqbot-tts-' + Date.now() + '-' + Math.random().toString(16).slice(2) + '.wav');\n writeFileSync(file, result.buffer);\n try {\n await bot.sendVoice(resolveReplyTarget(target, replyLimiter, false), { localPath: file });\n } finally {\n try { unlinkSync(file); } catch { /* ignore */ }\n }\n return;\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error);\n if (error && error.code === 'tts-config') {\n logger.error(`im-qqbot: TTS config error: ${message}`);\n await originalSendMarkdown(target, '⚠️ 语音配置错误:' + message, opts);\n return;\n }\n logger.warn(`im-qqbot: TTS voice failed, fallback to text: ${message}`);\n await originalSendMarkdown(target, content, opts);\n return;\n }\n }\n }\n }\n return originalSendMarkdown(target, content, opts);\n };"
|
|
42
|
-
},
|
|
43
|
-
{
|
|
44
|
-
"group": "v1",
|
|
45
|
-
"old": " // 交付物投递:present 声明的文件在轮末发送到当前会话(outbound 路由触发)\n const deliverablesDeliverer = new DeliverablesDeliverer(sender, mediaSender, config, logger);",
|
|
46
|
-
"new": " // ── companionQq 服务:dsh-meme 等插件经它把图/语音发到 QQ ──\n const latestReplyTarget = () => {\n let best = null;\n for (const record of manager.sessions.values()) {\n if (!record || !record.replyTarget) continue;\n if (!best || Number(record.lastActivity || 0) > Number(best.lastActivity || 0)) best = record;\n }\n return best ? best.replyTarget : null;\n };\n if (typeof ctx.provide === 'function') {\n try {\n const disposeCompanionQq = ctx.provide('companionQq', {\n isOnline: () => botReady,\n get lastChatTarget() { return latestReplyTarget(); },\n async sendImage(path, caption) {\n if (!botReady) throw new Error('QQ 通道未就绪');\n const target = latestReplyTarget();\n if (!target) throw new Error('还没有 QQ 聊天目标');\n return bot.sendImage(resolveReplyTarget(target, replyLimiter, false), { localPath: String(path) }, caption ? { content: String(caption) } : undefined);\n },\n async sendVoice(path) {\n if (!botReady) throw new Error('QQ 通道未就绪');\n const target = latestReplyTarget();\n if (!target) throw new Error('还没有 QQ 聊天目标');\n return bot.sendVoice(resolveReplyTarget(target, replyLimiter, false), { localPath: String(path) });\n },\n });\n try { ctx.emit('companionQq/available'); } catch { /* no event bus */ }\n ctx.effect(() => () => { try { if (typeof disposeCompanionQq === 'function') disposeCompanionQq(); } catch { /* ignore */ } }, 'im-qqbot.companionQq');\n logger.info('im-qqbot: companionQq 服务已提供(dsh-meme / 语音)');\n } catch (err) {\n logger.warn(`im-qqbot: companionQq 服务注册失败: ${err instanceof Error ? err.message : String(err)}`);\n }\n }\n // 交付物投递:present 声明的文件在轮末发送到当前会话(outbound 路由触发)\n const deliverablesDeliverer = new DeliverablesDeliverer(sender, mediaSender, config, logger);"
|
|
47
|
-
},
|
|
48
|
-
{
|
|
49
|
-
"group": "v2",
|
|
50
|
-
"old": "const file = join(tmpdir(), 'dsh-qqbot-tts-' + Date.now() + '-' + Math.random().toString(16).slice(2) + '.wav');",
|
|
51
|
-
"new": "const file = join(tmpdir(), 'dsh-qqbot-tts-' + Date.now() + '-' + Math.random().toString(16).slice(2) + '.' + (result.ext === 'silk' || result.ext === 'mp3' ? result.ext : 'wav')); // companion-patch:v2 silk"
|
|
52
|
-
},
|
|
53
|
-
{
|
|
54
|
-
"group": "v2",
|
|
55
|
-
"old": " setupMiddlewares(bot, config, manager, logger);",
|
|
56
|
-
"new": " setupMiddlewares(bot, config, manager, logger, ctx); // companion-patch:v2 cards"
|
|
57
|
-
}
|
|
58
|
-
]
|
|
59
|
-
},
|
|
60
|
-
{
|
|
61
|
-
"file": "gateway/middleware-setup.js",
|
|
62
|
-
"steps": [
|
|
63
|
-
{
|
|
64
|
-
"group": "v2",
|
|
65
|
-
"old": "export function setupMiddlewares(bot, config, manager, logger) {",
|
|
66
|
-
"new": "export function setupMiddlewares(bot, config, manager, logger, ctx) { // companion-patch:v2 cards"
|
|
67
|
-
},
|
|
68
|
-
{
|
|
69
|
-
"group": "v2",
|
|
70
|
-
"old": " // 4. 群历史缓冲",
|
|
71
|
-
"new": " // companion-patch:v2 cards —— QQ 小程序卡片(B站 分享等)补上视频链接。\n // 放在访问控制之后:被拦下的消息不会走到这里,也就不会替陌生人去解短链。\n bot.use(async (mCtx, next) => {\n try {\n const cards = ctx && typeof ctx.get === 'function' ? ctx.get('companionCards') : null;\n const msg = mCtx.message;\n if (cards && typeof cards.expand === 'function' && msg) {\n const extra = await cards.expand(msg);\n if (typeof extra === 'string' && extra.trim() !== '') {\n msg.content = (msg.content ? String(msg.content) + '\\n' : '') + extra;\n }\n }\n }\n catch (err) {\n logger.warn(`im-qqbot: companion card expand failed: ${err instanceof Error ? err.message : String(err)}`);\n }\n await next();\n });\n // 4. 群历史缓冲"
|
|
61
|
+
"file": "gateway/middleware-setup.js",
|
|
62
|
+
"steps": [
|
|
63
|
+
{
|
|
64
|
+
"group": "v2",
|
|
65
|
+
"old": "export function setupMiddlewares(bot, config, manager, logger) {",
|
|
66
|
+
"new": "export function setupMiddlewares(bot, config, manager, logger, ctx) { // companion-patch:v2 cards"
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
"group": "v2",
|
|
70
|
+
"old": " // 4. 群历史缓冲",
|
|
71
|
+
"new": " // companion-patch:v2 cards —— QQ 小程序卡片(B站 分享等)补上视频链接。\n // 放在访问控制之后:被拦下的消息不会走到这里,也就不会替陌生人去解短链。\n bot.use(async (mCtx, next) => {\n try {\n const cards = ctx && typeof ctx.get === 'function' ? ctx.get('companionCards') : null;\n const msg = mCtx.message;\n if (cards && typeof cards.expand === 'function' && msg) {\n const extra = await cards.expand(msg);\n if (typeof extra === 'string' && extra.trim() !== '') {\n msg.content = (msg.content ? String(msg.content) + '\\n' : '') + extra;\n }\n }\n }\n catch (err) {\n logger.warn(`im-qqbot: companion card expand failed: ${err instanceof Error ? err.message : String(err)}`);\n }\n await next();\n });\n // 4. 群历史缓冲"
|
|
72
|
+
}
|
|
73
|
+
]
|
|
72
74
|
}
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
75
|
+
],
|
|
76
|
+
"versions": [
|
|
77
|
+
"0.5.3",
|
|
78
|
+
"0.5.4",
|
|
79
|
+
"0.5.5"
|
|
80
|
+
]
|
|
76
81
|
}
|