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
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* transcript-file.js — 读取一份**已有的**转写,跳过 ASR。
|
|
3
|
+
*
|
|
4
|
+
* 为什么需要它:B 站视频大多带 CC / AI 字幕,`yt-dlp --write-subs` 或字幕接口能直接
|
|
5
|
+
* 拿到带时间码的文本。为了这份已经存在的东西去跑一遍 ASR,是纯粹浪费——一条 10 分钟
|
|
6
|
+
* 的口播要 60–120 秒,还多一次模型调用。
|
|
7
|
+
*
|
|
8
|
+
* 顺带解决另一类问题:很多宿主的 ASR 走 chat/completions 方言,接不上
|
|
9
|
+
* `/audio/transcriptions`。有字幕文件时,这条路根本不需要通。
|
|
10
|
+
*
|
|
11
|
+
* 支持三种形态,自动识别:
|
|
12
|
+
* 1. SRT `00:00:01,000 --> 00:00:03,500`
|
|
13
|
+
* 2. 通用 JSON 数组 `[{start,end,text}]` 或 `[{from,to,text}]`
|
|
14
|
+
* 3. B 站字幕 JSON `{"body":[{"from":0.0,"to":2.5,"content":"..."}]}`
|
|
15
|
+
*
|
|
16
|
+
* 统一输出 `[{from, to, text}]` —— 和 asr.js 的 segments 同构,下游 alignCells 不用改。
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
import { readFile } from 'node:fs/promises';
|
|
20
|
+
|
|
21
|
+
/** `00:01:02,500` / `00:01:02.500` / `1:02,5` → 秒 */
|
|
22
|
+
export function parseTimecode(raw) {
|
|
23
|
+
const s = String(raw).trim().replace(',', '.');
|
|
24
|
+
const parts = s.split(':');
|
|
25
|
+
if (parts.length === 3) {
|
|
26
|
+
const [h, m, sec] = parts;
|
|
27
|
+
return Number(h) * 3600 + Number(m) * 60 + Number(sec);
|
|
28
|
+
}
|
|
29
|
+
if (parts.length === 2) {
|
|
30
|
+
const [m, sec] = parts;
|
|
31
|
+
return Number(m) * 60 + Number(sec);
|
|
32
|
+
}
|
|
33
|
+
const n = Number(parts[0]);
|
|
34
|
+
return Number.isFinite(n) ? n : NaN;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/** 去掉字幕里常见的标记:`<i>` `<font color=...>` `{\an8}` 和 ` ` */
|
|
38
|
+
export function stripMarkup(text) {
|
|
39
|
+
return String(text)
|
|
40
|
+
.replace(/<[^>]{1,80}>/g, '')
|
|
41
|
+
.replace(/\{\\[^}]{1,40}\}/g, '')
|
|
42
|
+
.replace(/ /gi, ' ')
|
|
43
|
+
.replace(/&/gi, '&')
|
|
44
|
+
.replace(/</gi, '<')
|
|
45
|
+
.replace(/>/gi, '>')
|
|
46
|
+
.replace(/[ \t]+/g, ' ')
|
|
47
|
+
.trim();
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* 解析 SRT。容忍:BOM、CRLF、缺序号、时间码用 `.` 而不是 `,`、正文多行。
|
|
52
|
+
* @returns {{from:number,to:number,text:string}[]}
|
|
53
|
+
*/
|
|
54
|
+
export function parseSrt(source) {
|
|
55
|
+
const text = String(source).replace(/^\uFEFF/, '').replace(/\r\n?/g, '\n');
|
|
56
|
+
const segments = [];
|
|
57
|
+
// 以空行分块,比逐行状态机更耐受"最后一块没有尾随空行"的畸形文件
|
|
58
|
+
for (const block of text.split(/\n{2,}/)) {
|
|
59
|
+
const lines = block.split('\n').filter((line) => line.trim() !== '');
|
|
60
|
+
if (lines.length === 0) continue;
|
|
61
|
+
const arrowAt = lines.findIndex((line) => line.includes('-->'));
|
|
62
|
+
if (arrowAt === -1) continue;
|
|
63
|
+
const [left, right] = lines[arrowAt].split('-->');
|
|
64
|
+
const from = parseTimecode(left);
|
|
65
|
+
// 右侧可能带坐标后缀:`00:00:03,500 X1:100 X2:200 Y1:...`
|
|
66
|
+
const to = parseTimecode(String(right).trim().split(/\s+/)[0]);
|
|
67
|
+
if (!Number.isFinite(from) || !Number.isFinite(to)) continue;
|
|
68
|
+
const body = stripMarkup(lines.slice(arrowAt + 1).join(' '));
|
|
69
|
+
if (!body) continue;
|
|
70
|
+
segments.push({ from, to: Math.max(to, from), text: body });
|
|
71
|
+
}
|
|
72
|
+
return segments;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
const pick = (obj, keys) => {
|
|
76
|
+
for (const key of keys) {
|
|
77
|
+
if (obj[key] !== undefined && obj[key] !== null) return obj[key];
|
|
78
|
+
}
|
|
79
|
+
return undefined;
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* 解析 JSON 形态。不假设固定 schema —— 三种常见布局都认:
|
|
84
|
+
* 数组 + {start,end,text} / {from,to,text} / {from,to,content}
|
|
85
|
+
* {body:[...]}(B 站) {segments:[...]}(OpenAI verbose_json / whisper)
|
|
86
|
+
*/
|
|
87
|
+
export function parseJsonTranscript(payload) {
|
|
88
|
+
let list = null;
|
|
89
|
+
if (Array.isArray(payload)) {
|
|
90
|
+
list = payload;
|
|
91
|
+
} else if (payload && typeof payload === 'object') {
|
|
92
|
+
for (const key of ['body', 'segments', 'subtitles', 'items', 'data']) {
|
|
93
|
+
if (Array.isArray(payload[key])) { list = payload[key]; break; }
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
if (!list) throw new Error('unrecognised transcript JSON: expected an array, or an object with body/segments/subtitles/items/data');
|
|
97
|
+
|
|
98
|
+
const segments = [];
|
|
99
|
+
for (const item of list) {
|
|
100
|
+
if (!item || typeof item !== 'object') continue;
|
|
101
|
+
const start = Number(pick(item, ['start', 'from', 'startTime', 'start_time', 'st']));
|
|
102
|
+
const end = Number(pick(item, ['end', 'to', 'endTime', 'end_time', 'et']));
|
|
103
|
+
const raw = pick(item, ['text', 'content', 'line', 'transcript', 'caption']);
|
|
104
|
+
if (!Number.isFinite(start) || !Number.isFinite(end) || raw === undefined) continue;
|
|
105
|
+
const body = stripMarkup(raw);
|
|
106
|
+
if (!body) continue;
|
|
107
|
+
segments.push({ from: start, to: Math.max(end, start), text: body });
|
|
108
|
+
}
|
|
109
|
+
return segments;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/** 猜格式:先看内容,再看扩展名。JSON 解析失败就退回 SRT,让错误信息更具体。 */
|
|
113
|
+
export function parseTranscript(source, filename = '') {
|
|
114
|
+
const text = String(source).replace(/^\uFEFF/, '');
|
|
115
|
+
const head = text.trimStart().slice(0, 1);
|
|
116
|
+
const looksJson = head === '[' || head === '{';
|
|
117
|
+
const ext = String(filename).toLowerCase().split('.').pop();
|
|
118
|
+
|
|
119
|
+
if (looksJson || ext === 'json') {
|
|
120
|
+
let payload;
|
|
121
|
+
try {
|
|
122
|
+
payload = JSON.parse(text);
|
|
123
|
+
} catch (error) {
|
|
124
|
+
throw new Error(`transcript JSON is not valid JSON: ${error.message}`);
|
|
125
|
+
}
|
|
126
|
+
return { segments: parseJsonTranscript(payload), format: 'json' };
|
|
127
|
+
}
|
|
128
|
+
const segments = parseSrt(text);
|
|
129
|
+
if (segments.length === 0) {
|
|
130
|
+
throw new Error('could not find any timed text: no "--> " blocks (SRT) and no JSON array');
|
|
131
|
+
}
|
|
132
|
+
return { segments, format: 'srt' };
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* 读文件并解析。时间轴统一成**相对整段视频**的秒数;窗口偏移由 pipeline 负责减。
|
|
137
|
+
* @param {string} path
|
|
138
|
+
* @returns {Promise<{segments:{from:number,to:number,text:string}[], format:string}>}
|
|
139
|
+
*/
|
|
140
|
+
export async function loadTranscriptFile(path) {
|
|
141
|
+
const text = await readFile(path, 'utf8');
|
|
142
|
+
const { segments, format } = parseTranscript(text, path);
|
|
143
|
+
// 按起点排序:手工编辑过的 SRT 时常出现顺序错乱,alignCells 假设递增
|
|
144
|
+
segments.sort((a, b) => a.from - b.from || a.to - b.to);
|
|
145
|
+
return { segments, format };
|
|
146
|
+
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* url.js — 链接的判别、白名单与归一化。**零依赖叶子**,谁都能用。
|
|
3
|
+
*
|
|
4
|
+
* 从 fetch.js 拆出来的:`direct-url.js` 和 `fetch.js` 都要用,放在任何一边都会成环。
|
|
5
|
+
* 三个函数看起来琐碎,但每一条规则都有事故背景(见各自的注释),所以它们值得单独一个文件
|
|
6
|
+
* —— 改这里的规则等于改"什么算同一条视频",不该埋在取流代码中间。
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
/** 是不是 http(s) 链接。其它一切(含 file://、裸路径)都按本地文件处理。 */
|
|
10
|
+
export function isHttpUrl(value) {
|
|
11
|
+
if (typeof value !== 'string') return false;
|
|
12
|
+
if (!/^https?:\/\//i.test(value.trim())) return false;
|
|
13
|
+
try {
|
|
14
|
+
const parsed = new URL(value.trim());
|
|
15
|
+
return parsed.protocol === 'http:' || parsed.protocol === 'https:';
|
|
16
|
+
} catch {
|
|
17
|
+
return false;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const PRIVATE_HOST = [
|
|
22
|
+
/^localhost$/i,
|
|
23
|
+
/^127\./,
|
|
24
|
+
/^0\./,
|
|
25
|
+
/^10\./,
|
|
26
|
+
/^192\.168\./,
|
|
27
|
+
/^172\.(1[6-9]|2\d|3[01])\./,
|
|
28
|
+
/^169\.254\./,
|
|
29
|
+
/^\[?::1\]?$/,
|
|
30
|
+
/^\[?f[cd][0-9a-f]{2}:/i,
|
|
31
|
+
];
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* 允许的链接:只放 http(s),且**拒绝内网地址**。
|
|
35
|
+
* 理由不是洁癖 —— yt-dlp 会把链接交给 ffmpeg,一个 169.254.169.254 就能把云元数据读出来。
|
|
36
|
+
*/
|
|
37
|
+
export function assertFetchableUrl(raw) {
|
|
38
|
+
const value = String(raw).trim();
|
|
39
|
+
if (!isHttpUrl(value)) {
|
|
40
|
+
throw new Error('only http(s) links are fetched; for a local file pass the path directly');
|
|
41
|
+
}
|
|
42
|
+
const { hostname } = new URL(value);
|
|
43
|
+
if (PRIVATE_HOST.some((re) => re.test(hostname))) {
|
|
44
|
+
throw new Error(`refusing to fetch a private/loopback host: ${hostname}`);
|
|
45
|
+
}
|
|
46
|
+
return value;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* 归一化链接,用来做缓存键。
|
|
51
|
+
* 去掉站外跟踪参数(B 站会带一长串 spm_id_from),但**保留 `p`**(分P),否则不同 P 会撞同一个键。
|
|
52
|
+
*/
|
|
53
|
+
export function normalizeUrl(raw) {
|
|
54
|
+
try {
|
|
55
|
+
const url = new URL(String(raw).trim());
|
|
56
|
+
url.hash = '';
|
|
57
|
+
const drop = [];
|
|
58
|
+
for (const key of url.searchParams.keys()) {
|
|
59
|
+
if (/^(spm_id_from|vd_source|share_source|share_medium|share_plat|share_tag|timestamp|unique_k|from_source|from_spmid|bbid|ts)$/i.test(key)) {
|
|
60
|
+
drop.push(key);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
for (const key of drop) url.searchParams.delete(key);
|
|
64
|
+
url.hostname = url.hostname.toLowerCase();
|
|
65
|
+
return url.toString();
|
|
66
|
+
} catch {
|
|
67
|
+
return String(raw).trim();
|
|
68
|
+
}
|
|
69
|
+
}
|
|
@@ -0,0 +1,289 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ytdlp.js — 「怎么调 yt-dlp」:找到它、跑它、读它的配置、翻译它的报错。
|
|
3
|
+
*
|
|
4
|
+
* 从 fetch.js 拆出来的。这一层只跟 yt-dlp 这个外部程序的**方言**打交道:
|
|
5
|
+
* `-J` 的 JSON 长什么样、`-f` 选择器怎么写、失败时的 stderr 该怎么翻译成中文提示、
|
|
6
|
+
* cookies 从哪儿来。它不知道"扫描清晰度""直链""分镜"这些东西。
|
|
7
|
+
*
|
|
8
|
+
* 好处是可替换:将来换成别的下载器,只需要另写一份同样五个函数,fetch.js 不用动。
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import { spawn } from 'node:child_process';
|
|
12
|
+
import { readFile } from 'node:fs/promises';
|
|
13
|
+
import { homedir } from 'node:os';
|
|
14
|
+
import { fileExists } from './media-store.js';
|
|
15
|
+
import { delimiter, join } from 'node:path';
|
|
16
|
+
|
|
17
|
+
export const COOKIES_ENV = 'DSH_VIDEO_COOKIES';
|
|
18
|
+
|
|
19
|
+
/** 与 DSH 默认一致的浏览器 UA —— B 站 CDN 对空 UA 直接 403 */
|
|
20
|
+
export const DEFAULT_UA =
|
|
21
|
+
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36';
|
|
22
|
+
|
|
23
|
+
const INSTALL_HINT = [
|
|
24
|
+
'yt-dlp not found. Install one of:',
|
|
25
|
+
' pip install --user -U yt-dlp (Windows/macOS/Linux)',
|
|
26
|
+
' winget install yt-dlp (Windows)',
|
|
27
|
+
' brew install yt-dlp (macOS)',
|
|
28
|
+
'Then either put it on PATH or set DSH_YTDLP_PATH to the executable.',
|
|
29
|
+
].join('\n');
|
|
30
|
+
|
|
31
|
+
/* ------------------------------------------------------------------ yt-dlp 发现 */
|
|
32
|
+
|
|
33
|
+
/** PATH 上找可执行文件(手写一份,避免依赖 which 包) */
|
|
34
|
+
async function findOnPath(name, env = process.env) {
|
|
35
|
+
const dirs = (env.PATH || env.Path || '').split(delimiter).filter(Boolean);
|
|
36
|
+
const exts = process.platform === 'win32'
|
|
37
|
+
? (env.PATHEXT || '.EXE;.CMD;.BAT').split(';').filter(Boolean)
|
|
38
|
+
: [''];
|
|
39
|
+
for (const dir of dirs) {
|
|
40
|
+
for (const ext of exts) {
|
|
41
|
+
const candidate = join(dir, name + ext);
|
|
42
|
+
if (await fileExists(candidate)) return candidate;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
return null;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/** pip 在 Windows 上把脚本放在 %APPDATA%\Python\Python3xx\Scripts,通常不在 PATH 上 */
|
|
49
|
+
async function findPipScript(env = process.env) {
|
|
50
|
+
const roots = [];
|
|
51
|
+
if (process.platform === 'win32' && env.APPDATA) {
|
|
52
|
+
roots.push(join(env.APPDATA, 'Python'));
|
|
53
|
+
}
|
|
54
|
+
roots.push(join(homedir(), '.local', 'bin'));
|
|
55
|
+
if (process.platform === 'darwin') {
|
|
56
|
+
roots.push('/opt/homebrew/bin', '/usr/local/bin');
|
|
57
|
+
}
|
|
58
|
+
for (const root of roots) {
|
|
59
|
+
const direct = join(root, process.platform === 'win32' ? 'yt-dlp.exe' : 'yt-dlp');
|
|
60
|
+
if (await fileExists(direct)) return direct;
|
|
61
|
+
// %APPDATA%\Python\Python313\Scripts\yt-dlp.exe
|
|
62
|
+
let children = [];
|
|
63
|
+
try {
|
|
64
|
+
children = await readdir(root);
|
|
65
|
+
} catch {
|
|
66
|
+
continue;
|
|
67
|
+
}
|
|
68
|
+
for (const child of children) {
|
|
69
|
+
const candidate = join(root, child, 'Scripts', process.platform === 'win32' ? 'yt-dlp.exe' : 'yt-dlp');
|
|
70
|
+
if (await fileExists(candidate)) return candidate;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
return null;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* 找一个能跑的 yt-dlp,并**真的执行一次 `--version`** —— 存在但跑不起来(残缺安装、
|
|
78
|
+
* 架构不对)比不存在更坑,所以不能只看文件在不在。
|
|
79
|
+
* @returns {Promise<{bin:string, prefix:string[], version:string}>}
|
|
80
|
+
*/
|
|
81
|
+
export async function discoverYtdlp({ env = process.env, run = runProcess } = {}) {
|
|
82
|
+
const explicit = env.DSH_YTDLP_PATH;
|
|
83
|
+
const candidates = [];
|
|
84
|
+
if (explicit) candidates.push(explicit);
|
|
85
|
+
candidates.push(await findOnPath('yt-dlp', env));
|
|
86
|
+
candidates.push(await findPipScript(env));
|
|
87
|
+
|
|
88
|
+
const tried = [];
|
|
89
|
+
for (const candidate of candidates.filter(Boolean)) {
|
|
90
|
+
tried.push(candidate);
|
|
91
|
+
try {
|
|
92
|
+
const { stdout } = await run({ bin: candidate, prefix: [] }, ['--version'], { timeoutMs: 20_000 });
|
|
93
|
+
const version = stdout.trim().split('\n')[0].trim();
|
|
94
|
+
if (version) return { bin: candidate, prefix: [], version };
|
|
95
|
+
} catch {
|
|
96
|
+
/* 试下一个 */
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
const error = new Error(INSTALL_HINT);
|
|
100
|
+
error.code = 'YTDLP_MISSING';
|
|
101
|
+
error.tried = tried;
|
|
102
|
+
throw error;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/* ------------------------------------------------------------------ 子进程 */
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* 跑一个子进程。**argv 数组,永不经过 shell** —— 链接里带 `&&` 也不会被执行。
|
|
109
|
+
* @returns {Promise<{stdout:string, stderr:string, code:number}>}
|
|
110
|
+
*/
|
|
111
|
+
export function runProcess({ bin, prefix = [] }, args, { timeoutMs = 120_000, signal } = {}) {
|
|
112
|
+
return new Promise((resolve, reject) => {
|
|
113
|
+
let child;
|
|
114
|
+
try {
|
|
115
|
+
child = spawn(bin, [...prefix, ...args], { stdio: ['ignore', 'pipe', 'pipe'], signal });
|
|
116
|
+
} catch (error) {
|
|
117
|
+
reject(new Error(`failed to spawn ${bin}: ${error.message}`));
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
let stdout = '';
|
|
121
|
+
let stderr = '';
|
|
122
|
+
let settled = false;
|
|
123
|
+
const timer = setTimeout(() => {
|
|
124
|
+
if (settled) return;
|
|
125
|
+
settled = true;
|
|
126
|
+
child.kill('SIGKILL');
|
|
127
|
+
reject(new Error(`yt-dlp timed out after ${Math.round(timeoutMs / 1000)}s`));
|
|
128
|
+
}, timeoutMs);
|
|
129
|
+
|
|
130
|
+
child.stdout.on('data', (chunk) => { stdout += chunk.toString(); });
|
|
131
|
+
child.stderr.on('data', (chunk) => { stderr += chunk.toString(); });
|
|
132
|
+
child.on('error', (error) => {
|
|
133
|
+
if (settled) return;
|
|
134
|
+
settled = true;
|
|
135
|
+
clearTimeout(timer);
|
|
136
|
+
reject(new Error(`failed to run ${bin}: ${error.message}`));
|
|
137
|
+
});
|
|
138
|
+
child.on('close', (code) => {
|
|
139
|
+
if (settled) return;
|
|
140
|
+
settled = true;
|
|
141
|
+
clearTimeout(timer);
|
|
142
|
+
resolve({ stdout, stderr, code: code ?? 0 });
|
|
143
|
+
});
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
/* ------------------------------------------------------------------ 配置 */
|
|
148
|
+
|
|
149
|
+
export const CONFIG_FILE = 'video.json';
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* 读 `~/.dsh/video.json`。
|
|
153
|
+
*
|
|
154
|
+
* 为什么必须有这个:**DSH 桌面版读不到用户 `setx` 设的环境变量**(ASR 那边已经踩过一次,
|
|
155
|
+
* 所以 asr.json 存在)。只靠 env 的话,用户在终端里配好了、插件里依然是"没有 cookie"。
|
|
156
|
+
* 配置文件是唯一可靠的通道。
|
|
157
|
+
*/
|
|
158
|
+
export async function loadVideoConfig({ env = process.env } = {}) {
|
|
159
|
+
const home = env.DSH_HOME || join(homedir(), '.dsh');
|
|
160
|
+
try {
|
|
161
|
+
const raw = JSON.parse(await readFile(join(home, CONFIG_FILE), 'utf8'));
|
|
162
|
+
return raw && typeof raw === 'object' ? raw : {};
|
|
163
|
+
} catch {
|
|
164
|
+
return {};
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
/* ------------------------------------------------------------------ 认证 */
|
|
169
|
+
|
|
170
|
+
/**
|
|
171
|
+
* 认证来源:显式参数 > 环境变量 > `~/.dsh/video.json`。
|
|
172
|
+
*
|
|
173
|
+
* **没有 cookie 不再阻断。** 早期版本直接抛错,结果在真实使用里被证明是错的:
|
|
174
|
+
* 同一条视频匿名可能已经有 1080P(实测 `BV1BK411Q7ys` 就是这样),硬拦只会让模型
|
|
175
|
+
* 花好几轮去排查一个不存在的问题。现在改成"先探再判断"——
|
|
176
|
+
* 匿名能拿到目标档就照常走,拿不到才在结果里标 `degraded` 并给一条警告。
|
|
177
|
+
*
|
|
178
|
+
* @returns {{kind:'cookies'|'anonymous', cookiesPath:string|null, warning:string|null}}
|
|
179
|
+
*/
|
|
180
|
+
export async function resolveAuth({ cookies, allowAnonymous = false, env = process.env, config = null } = {}) {
|
|
181
|
+
const cfg = config ?? await loadVideoConfig({ env });
|
|
182
|
+
const path = cookies || env[COOKIES_ENV] || cfg.cookies;
|
|
183
|
+
if (path) {
|
|
184
|
+
if (!(await fileExists(path))) {
|
|
185
|
+
throw new Error(
|
|
186
|
+
`cookies file not found: ${path}\n` +
|
|
187
|
+
`fix ${COOKIES_ENV} or the "cookies" field in ~/.dsh/${CONFIG_FILE}`,
|
|
188
|
+
);
|
|
189
|
+
}
|
|
190
|
+
return { kind: 'cookies', cookiesPath: path, warning: null };
|
|
191
|
+
}
|
|
192
|
+
return {
|
|
193
|
+
kind: 'anonymous',
|
|
194
|
+
cookiesPath: null,
|
|
195
|
+
// allowAnonymous 现在的含义是"我知道是匿名,别提醒我",而不是"允许匿名"
|
|
196
|
+
warning: allowAnonymous
|
|
197
|
+
? null
|
|
198
|
+
: 'anonymous: resolution is not guaranteed (no cookies in DSH_VIDEO_COOKIES or ~/.dsh/video.json)',
|
|
199
|
+
};
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
/** 把 yt-dlp 的 stderr 翻译成人能看懂的结论,不把原始日志倒给用户 */
|
|
203
|
+
export function explainYtdlpError(stderr, code = 1) {
|
|
204
|
+
const text = String(stderr || '');
|
|
205
|
+
if (/Failed to decrypt|DPAPI|App-Bound/i.test(text)) {
|
|
206
|
+
return 'cookie decryption failed: Chromium 127+ uses App-Bound Encryption (v20), ' +
|
|
207
|
+
'which yt-dlp cannot read. Export cookies.txt with a browser extension instead of using --cookies-from-browser.';
|
|
208
|
+
}
|
|
209
|
+
if (/Sign in to confirm|login required|需要登录|Please log in/i.test(text)) {
|
|
210
|
+
return 'this video needs a signed-in session. Export cookies.txt and set DSH_VIDEO_COOKIES ' +
|
|
211
|
+
'(or "cookies" in ~/.dsh/video.json) — SESSDATA may also have expired. See docs/SETUP.md.';
|
|
212
|
+
}
|
|
213
|
+
if (/HTTP Error 567/i.test(text)) {
|
|
214
|
+
return 'Bilibili refused this request (HTTP 567) — that is their risk control, not a plugin bug. ' +
|
|
215
|
+
'It usually means the video needs a signed-in session (1080P+, 会员/付费, or a fresh rate-limit). ' +
|
|
216
|
+
'Fix: export cookies.txt (README "needs a signed-in video" / docs/SETUP.md §3) and point ' +
|
|
217
|
+
'DSH_VIDEO_COOKIES at it, or download the file yourself and pass a local path. ' +
|
|
218
|
+
'Anonymous 360P usually still works on ordinary videos.';
|
|
219
|
+
}
|
|
220
|
+
if (/HTTP Error 412/i.test(text)) {
|
|
221
|
+
return 'HTTP 412: the site rate-limited this request. Wait a moment and retry.';
|
|
222
|
+
}
|
|
223
|
+
if (/Requested format is not available|No video formats found/i.test(text)) {
|
|
224
|
+
return 'no usable format matched the selector: Bilibili serves DASH tracks, ' +
|
|
225
|
+
'use "bv*[height<=N]+ba" rather than "b[height<=N]".';
|
|
226
|
+
}
|
|
227
|
+
if (/Unsupported URL/i.test(text)) {
|
|
228
|
+
return 'this site is not supported by the installed yt-dlp build.';
|
|
229
|
+
}
|
|
230
|
+
const tail = text.trim().split('\n').slice(-3).join(' | ');
|
|
231
|
+
return `yt-dlp exited ${code}${tail ? `: ${tail}` : ''}`;
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
/* ------------------------------------------------------------------ 解析 */
|
|
235
|
+
|
|
236
|
+
const HEIGHT_KEYS = ['height'];
|
|
237
|
+
|
|
238
|
+
/**
|
|
239
|
+
* 一次 `-J` 拿到全部需要的元信息。
|
|
240
|
+
* 为什么不用 `-F`:`-F` 是人读的表格,要正则去啃;`-J` 是结构化 JSON,而且和 `-g`
|
|
241
|
+
* 一样快(实测 2.4s vs 2.6s),顺带把 title/duration 也带回来。
|
|
242
|
+
*/
|
|
243
|
+
export function summariseInfo(info) {
|
|
244
|
+
const formats = Array.isArray(info?.formats) ? info.formats : [];
|
|
245
|
+
const video = formats.filter((f) => f && f.vcodec && f.vcodec !== 'none');
|
|
246
|
+
const heights = [...new Set(video.map((f) => Number(f[HEIGHT_KEYS[0]])).filter((h) => Number.isFinite(h) && h > 0))]
|
|
247
|
+
.sort((a, b) => a - b);
|
|
248
|
+
// 站点自己说了"登录才给"的字段(B 站实测会返回 need_login_subtitle / is_upower_*)。
|
|
249
|
+
// 这些不是"没有",是"不登录不给" —— 必须区分开,否则清单会把"要登录"说成"这视频没有"。
|
|
250
|
+
const loginGates = [];
|
|
251
|
+
if (info?.need_login_subtitle === true) loginGates.push('subtitle');
|
|
252
|
+
if (info?.is_upower_exclusive === true || info?.is_upower_play === true) loginGates.push('paywalled');
|
|
253
|
+
return {
|
|
254
|
+
title: typeof info?.title === 'string' ? info.title : null,
|
|
255
|
+
duration: Number.isFinite(Number(info?.duration)) ? Number(info.duration) : null,
|
|
256
|
+
heights,
|
|
257
|
+
maxHeight: heights.length > 0 ? heights.at(-1) : null,
|
|
258
|
+
formats,
|
|
259
|
+
loginGates,
|
|
260
|
+
};
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
/**
|
|
264
|
+
* `-J` 对播放列表会返回 `{_type:'playlist', entries:[...]}`,取第一个条目。
|
|
265
|
+
* 多 P 视频显式带 `p` 参数时 yt-dlp 自己就给单个条目,所以这里只是兜底。
|
|
266
|
+
*/
|
|
267
|
+
export function unwrapSingle(info, url) {
|
|
268
|
+
if (!info || info._type !== 'playlist') return info;
|
|
269
|
+
const entries = Array.isArray(info.entries) ? info.entries.filter(Boolean) : [];
|
|
270
|
+
if (entries.length === 0) throw new Error(`no playable entry found at ${url}`);
|
|
271
|
+
return entries[0];
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
/** 选出"能覆盖到 h 的最省参数"的格式串。B 站是 DASH,所以必须是 bv*+ba。 */
|
|
275
|
+
export function formatSelector(height, { withAudio = true } = {}) {
|
|
276
|
+
const cap = Number.isFinite(height) && height > 0 ? `[height<=${Math.round(height)}]` : '';
|
|
277
|
+
// **优先渐进式单文件**(B 站的 `b`):一个文件、不用合流,比 `bv*+ba` 快得多,也省一次落盘。
|
|
278
|
+
// 渐进式最高一般只到 720p,但扫描只用 360p,够;拿不到再退回 DASH。
|
|
279
|
+
// B 站有些版本会把 video-only 的 mp4 也塞进 `b`,所以要求它必须带音轨;
|
|
280
|
+
// 拿不到就落到 `bv*+ba`(需要 ffmpeg 合流,fetchMedia 会把 DSH 的 ffmpeg 位置传给 yt-dlp)。
|
|
281
|
+
// 末尾的 /b 是给真正没有音轨的素材留的:bv*+ba 选不到音频时会失败,
|
|
282
|
+
// 不能因为"要求音轨"连一个无声视频都下不下来。
|
|
283
|
+
if (!cap) return withAudio ? 'bv*+ba/b[acodec!=none]/b' : 'bv*/b';
|
|
284
|
+
return withAudio
|
|
285
|
+
? `b${cap}[acodec!=none]/bv*${cap}+ba/b${cap}[acodec!=none]/bv*+ba/b`
|
|
286
|
+
: `b${cap}/bv*${cap}/bv*/b`;
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* tool-spec.js — **公开入口**:把四个视频识别工具的契约再导出成一份。
|
|
3
|
+
*
|
|
4
|
+
* 真正的定义在 `storyboard/tool-spec.js`(video_storyboard / zoom / probe / locate)。
|
|
5
|
+
*
|
|
6
|
+
* 为什么保留这个文件:`dsh-video-storyboard/tool-spec` 是 package.json 里的公开子路径,
|
|
7
|
+
* 外部(CLI、测试、可能的第三方)一直从这里拿 spec。**搬家不能断入口**。
|
|
8
|
+
*
|
|
9
|
+
* 陪看的契约(`watch_together`)**不在这里** —— 它属于 `dsh-watch-together` 那个包,
|
|
10
|
+
* 从 `dsh-watch-together/tool-spec` 取。
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
export {
|
|
14
|
+
LOCATE_TOOL_NAME, PROBE_TOOL_NAME, TOOL_NAME, ZOOM_TOOL_NAME,
|
|
15
|
+
locateToolSpec, probeToolSpec, storyboardToolSpec, validateToolArgs, validateZoomArgs,
|
|
16
|
+
zoomToolSpec,
|
|
17
|
+
} from './storyboard/tool-spec.js';
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* tools/locate.js — `video_locate` 的 execute。
|
|
3
|
+
*
|
|
4
|
+
* 纯文本:不读帧、不出图。没有现成转写时补跑一次 textOnly 的管线(复用 storyboard
|
|
5
|
+
* 的全套配置),跑完它会自己把转写塞进 locate 的缓存里,下次直接命中。
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import { formatMatches, matchSegments, recallSegments } from '../storyboard/locate.js';
|
|
9
|
+
import { resolveInput } from '../storyboard/fetch.js';
|
|
10
|
+
import { runStoryboard } from '../storyboard/pipeline.js';
|
|
11
|
+
|
|
12
|
+
export async function execute(ctx, args) {
|
|
13
|
+
if (!args?.input) throw new Error('input is required');
|
|
14
|
+
if (!args?.query) throw new Error('query is required');
|
|
15
|
+
const max = Math.min(20, Math.max(1, Number(args.max) || 5));
|
|
16
|
+
const resolved = await resolveInput(args.input, {
|
|
17
|
+
cookies: args.cookies, allowAnonymous: args.allowAnonymous === true,
|
|
18
|
+
});
|
|
19
|
+
let segments = recallSegments(resolved.path);
|
|
20
|
+
if (!segments) {
|
|
21
|
+
await runStoryboard({
|
|
22
|
+
input: resolved.path, from: args.from, to: args.to, cells: 1,
|
|
23
|
+
transcriptFile: args.transcriptFile, textOnly: true, encode: false,
|
|
24
|
+
});
|
|
25
|
+
segments = recallSegments(resolved.path);
|
|
26
|
+
}
|
|
27
|
+
if (!segments || segments.length === 0) {
|
|
28
|
+
return {
|
|
29
|
+
text: 'no transcript available for this file: run video_storyboard first, ' +
|
|
30
|
+
'or pass transcriptFile. Without a transcript there is nothing to match on.',
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
const lo = Number.isFinite(args.from) ? args.from : 0;
|
|
34
|
+
const hi = Number.isFinite(args.to) ? args.to : Infinity;
|
|
35
|
+
const inWindow = segments.filter((x) => x.to >= lo && x.from <= hi);
|
|
36
|
+
const matches = matchSegments(inWindow, args.query, { max });
|
|
37
|
+
return { text: formatMatches(args.query, matches, { total: inWindow.length }) };
|
|
38
|
+
}
|
|
39
|
+
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* tools/probe.js — `video_probe` 的 execute。
|
|
3
|
+
*
|
|
4
|
+
* 只读容器头,**不下载**:probe 的全部价值就是"便宜"。链接走 probeUrl(只解析),
|
|
5
|
+
* 本地走 probeVideo(几毫秒)。下载 7 MB 再读头,这个工具就没有意义了。
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import { probeVideo } from '../storyboard/probe.js';
|
|
9
|
+
import { formatProbe, formatRemoteProbe } from '../storyboard/format.js';
|
|
10
|
+
import { probeUrl } from '../storyboard/fetch.js';
|
|
11
|
+
import { isHttpUrl } from '../storyboard/url.js';
|
|
12
|
+
|
|
13
|
+
export async function execute(ctx, args) {
|
|
14
|
+
if (!args?.input) throw new Error('input is required');
|
|
15
|
+
const fetchOptions = { cookies: args.cookies, allowAnonymous: args.allowAnonymous === true };
|
|
16
|
+
if (isHttpUrl(args.input)) {
|
|
17
|
+
const remote = await probeUrl(args.input, fetchOptions);
|
|
18
|
+
return { text: formatRemoteProbe(remote) };
|
|
19
|
+
}
|
|
20
|
+
const info = { ...(await probeVideo(args.input)), path: args.input };
|
|
21
|
+
return { text: await formatProbe(info) };
|
|
22
|
+
}
|
|
23
|
+
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* tools/shared.js — 分镜类工具(storyboard / zoom)共用的宿主胶水。
|
|
3
|
+
*
|
|
4
|
+
* 这里只做"把库层的结果变成宿主认得的返回值":提交附件、渲染清单。
|
|
5
|
+
* **不要在这里读 args** —— 每个工具的 schema 各自独立,共用的读法会让
|
|
6
|
+
* `test/schema-audit.test.mjs` 分不清某个参数到底属于哪个工具。
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import { runStoryboard } from '../storyboard/pipeline.js';
|
|
10
|
+
import { formatForDetail } from '../storyboard/format.js';
|
|
11
|
+
|
|
12
|
+
/** 把每张分镜图提交成附件。两个入口各写过一遍这段循环,收成一处 —— mediaType / 命名改一次就够。 */
|
|
13
|
+
export async function attachSheetImages(ctx, result) {
|
|
14
|
+
const images = [];
|
|
15
|
+
for (const sheet of result.sheets) {
|
|
16
|
+
images.push(await ctx.attachments.saveImage({
|
|
17
|
+
data: sheet.png,
|
|
18
|
+
mediaType: 'image/png',
|
|
19
|
+
name: `storyboard-${sheet.sheet}.png`,
|
|
20
|
+
}));
|
|
21
|
+
}
|
|
22
|
+
return images;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* 跑一次管线,把每张图提交成附件,返回规范值 { images, text }。
|
|
27
|
+
*
|
|
28
|
+
* 预算:单次工具结果有上限,超出会被宿主折进磁盘(模型常常不会去读)。
|
|
29
|
+
* 24k 字符 ≈ 一张 16 格图的完整清单还有余量;超了就在 cell 边界截断并给出续读方式。
|
|
30
|
+
*/
|
|
31
|
+
export async function runAndAttach(ctx, options, problems, cellRange) {
|
|
32
|
+
if (problems.length > 0) throw new Error(`invalid arguments: ${problems.join('; ')}`);
|
|
33
|
+
const result = await runStoryboard(options);
|
|
34
|
+
return {
|
|
35
|
+
images: await attachSheetImages(ctx, result),
|
|
36
|
+
text: formatForDetail(result, { detail: options.detail, cellRange }),
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* tools/storyboard.js — `video_storyboard` 的 execute。
|
|
3
|
+
*
|
|
4
|
+
* 参数 → runStoryboard 选项全在 board.js 的 `boardOptions(args, {kind:'board'})` 里,
|
|
5
|
+
* 这里只补一个"清单分页"的 cellRange。
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import { boardOptions } from '../storyboard/board.js';
|
|
9
|
+
import { validateToolArgs } from '../storyboard/tool-spec.js';
|
|
10
|
+
import { runAndAttach } from './shared.js';
|
|
11
|
+
|
|
12
|
+
export function execute(ctx, args) {
|
|
13
|
+
return runAndAttach(
|
|
14
|
+
ctx,
|
|
15
|
+
boardOptions(args, { kind: 'board' }),
|
|
16
|
+
validateToolArgs(args),
|
|
17
|
+
args.cellRange ?? null,
|
|
18
|
+
);
|
|
19
|
+
}
|
|
20
|
+
|