dsh-chat-comprehension 0.2.0 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/NOTICE.md +20 -0
- package/README.md +20 -9
- package/client.js +41 -9
- package/lib/engines.mjs +136 -0
- package/lib/index.js +54 -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 +3293 -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,212 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* frames.js — **取像素**:本地 / 高清直链两条路、单帧 / 摊格两种形状、固定并发。
|
|
3
|
+
*
|
|
4
|
+
* 从 pipeline.js 拆出来的。这一层只做一件事:给定时间段,交出 RGB buffer。
|
|
5
|
+
* 它不知道转写、不知道排布、不知道清单 —— 所以能单独压测(换并发的收益都是在这一层量出来的)。
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import { extractFrameRaw, extractSharpest, tileSubFrames } from './sheet.js';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* 取一帧:有高清直链就先走远程,失败回落本地低清。
|
|
12
|
+
*
|
|
13
|
+
* **远程时把候选帧降到 1。** 一次 HTTP seek 实测 1.92 s,3 候选即使并发也要 3–4 s/格,
|
|
14
|
+
* 6 格就是 20 秒以上;而 zoom 的窗口本来就短、格间距小,段中点足够代表。
|
|
15
|
+
* 本地文件仍然用 3 候选(0.35 s/次,几乎免费,且段内可能有转场帧)。
|
|
16
|
+
*/
|
|
17
|
+
export async function extractFrameWithFallback({ input, remote, at, dur, cellW, cellH, ffmpegPath, pick }) {
|
|
18
|
+
const grab = (src, http, candidates) => {
|
|
19
|
+
if (pick === 'sharp') {
|
|
20
|
+
return extractSharpest({ input: src, at, dur, cellW, cellH, ffmpegPath, http, candidates });
|
|
21
|
+
}
|
|
22
|
+
return extractFrameRaw({
|
|
23
|
+
input: src, at, dur, cellW, cellH, ffmpegPath, http,
|
|
24
|
+
mode: pick === 'thumb' ? 'thumb' : 'mid',
|
|
25
|
+
});
|
|
26
|
+
};
|
|
27
|
+
if (remote?.uri) {
|
|
28
|
+
try {
|
|
29
|
+
return { ...(await grab(remote.uri, remote.http, 1)), via: 'remote' };
|
|
30
|
+
} catch {
|
|
31
|
+
/* 直链过期或 CDN 抖动:不整次失败,落到本地那份低清 */
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
return { ...(await grab(input, null, 3)), via: remote?.uri ? 'local-fallback' : 'local' };
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* 固定并发数的 map:保持输出顺序,任何一个失败就整体失败(取帧失败不能静默跳过,否则图会缺格)。
|
|
39
|
+
* 为什么不用 Promise.all:一次起 16 个 ffmpeg 会把机械硬盘打到爬行,也会把内存顶上去。
|
|
40
|
+
*/
|
|
41
|
+
export async function mapPool(items, limit, fn) {
|
|
42
|
+
const out = new Array(items.length);
|
|
43
|
+
let next = 0;
|
|
44
|
+
const n = Math.max(1, Math.min(limit, items.length));
|
|
45
|
+
await Promise.all(Array.from({ length: n }, async () => {
|
|
46
|
+
for (;;) {
|
|
47
|
+
const i = next++;
|
|
48
|
+
if (i >= items.length) return;
|
|
49
|
+
out[i] = await fn(items[i], i);
|
|
50
|
+
}
|
|
51
|
+
}));
|
|
52
|
+
return out;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* 这一格要不要摊成 k×k 子格?返回 k(1 = 不摊)。
|
|
57
|
+
*
|
|
58
|
+
* 判据(都来自实测):
|
|
59
|
+
* - 镜头数少不值得摊:4 个镜头以下摊开只是把画面切碎;
|
|
60
|
+
* - k ≈ ceil(sqrt(镜头数)),上限 4 —— 让子帧数刚好覆盖镜头数,不多抽重复帧;
|
|
61
|
+
* - 子帧不能小于 100×56:再小就只剩色块(实测 110×61 是"能分辨不同镜头"的下限)。
|
|
62
|
+
*/
|
|
63
|
+
export function chooseSubGrid({
|
|
64
|
+
shots, cellW, cellH, dur, cutScore = Infinity, meanMotion = 0,
|
|
65
|
+
// minShots 从 4 降到 3:这个门槛以前会把"1 秒 3 镜(3 刀/秒)"挡掉,
|
|
66
|
+
// 而它比"10 秒 4 镜(0.4 刀/秒)"密 7 倍 —— 真正该摊的是前者。
|
|
67
|
+
// 密度判据(minRate)已经能拦住"镜头少但时长长的正常叙事",minShots 只防"1 镜没东西可摊"。
|
|
68
|
+
minShots = 3, minRate = 0.4, minSubScore = 30, minSubW = 100, minSubH = 56,
|
|
69
|
+
minMotion = 1.5,
|
|
70
|
+
}) {
|
|
71
|
+
// **一个镜头、但画面一直在动**(摇镜、推拉、转场):整段只取 1 帧会把运动过程全丢掉。
|
|
72
|
+
// meanMotion 是段内逐帧分数的均值 —— 静止画面约 0.2,匀速摇镜约 1.5~3。
|
|
73
|
+
// 这种段没有切点,下面几条判据(靠刀数/刀密度)全都拦得住,所以单独放行 2×2。
|
|
74
|
+
if (shots <= 1 && meanMotion >= minMotion) {
|
|
75
|
+
let k = 2;
|
|
76
|
+
while (k > 1 && (cellW / k < minSubW || cellH / k < minSubH)) k -= 1;
|
|
77
|
+
return k > 1 ? k : 1;
|
|
78
|
+
}
|
|
79
|
+
// 那些"刀"本身要有分量。2D 线稿动画、游戏 UI 这类内容每帧都在变一点,
|
|
80
|
+
// 刀数能到 0.7/s,但摊出来的 9 张几乎一模一样(实测 RETAS 演示片就是这样)——
|
|
81
|
+
// 摊开只有在"刀是硬切"时才有意义。
|
|
82
|
+
if (cutScore < minSubScore) return 1;
|
|
83
|
+
if (!(shots >= minShots)) return 1;
|
|
84
|
+
// 密度门槛 0.7 → 0.4(平均 2.5 秒一个镜头就摊):实测概念 PV 上 0.7 只摊 4/9 格,
|
|
85
|
+
// 41 个镜头里只覆盖 31 个;0.4 摊 6/9 格,覆盖 41/41。再往下放宽(0.35~0.2)
|
|
86
|
+
// 结果完全一样,所以 0.4 是拐点,不是越松越好。
|
|
87
|
+
// 防"摊出来 9 张一模一样"的任务交给上面那两条
|
|
88
|
+
// (cutScore + minShots)。
|
|
89
|
+
if (dur > 0 && shots / dur < minRate) return 1;
|
|
90
|
+
// k 上限从 4 降到 3:4×4 时子帧只有约 130×73,人脸都糊了。
|
|
91
|
+
// 3×3 是 173×97,同样的镜头数宁可少看几个也要看得清。
|
|
92
|
+
let k = Math.min(4, Math.max(2, Math.ceil(Math.sqrt(shots))));
|
|
93
|
+
while (k > 1 && (cellW / k < minSubW || cellH / k < minSubH)) k -= 1;
|
|
94
|
+
return k > 1 ? k : 1;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* 把 n 帧分给 segs 段:**每段保底 1 帧**,剩下的按 weights 加权。
|
|
99
|
+
*
|
|
100
|
+
* 保底这条是硬约束,不能交给"按积分分配"自然得出:一段几乎静止的镜头积分接近 0,
|
|
101
|
+
* 纯按积分分就一帧都分不到 —— 而观众要看的就是"这个镜头长什么样"。
|
|
102
|
+
* weights 是每段的累积变化量(今由 density.integralMarks 提前算成采样点,这里一般传 null)。
|
|
103
|
+
*/
|
|
104
|
+
export function splitByWeight(n, segs, weights = null) {
|
|
105
|
+
const per = new Array(segs).fill(0);
|
|
106
|
+
if (n <= segs) {
|
|
107
|
+
// 帧比镜头还少(预算被 subBudget 砍过就会这样)时,给前 n 个镜头各 1 帧。
|
|
108
|
+
// 试过两种"更聪明"的挑法,实测都更差:
|
|
109
|
+
// - 按时间均匀挑:每次都挑中一格的第 1 个镜头,而那几个镜头积分是 0(暗场)→ 黑格;
|
|
110
|
+
// - 按积分挑:缓慢叠化/淡入的镜头积分又长又均匀,会稳定压过真内容 → 挑出糊画面。
|
|
111
|
+
// 所以这里**故意保守**。真要让这 n 帧挑得更好,得先解决"格内有没有黑场镜头"这个分格问题。
|
|
112
|
+
for (let i = 0; i < Math.min(n, segs); i++) per[i] = 1;
|
|
113
|
+
return per;
|
|
114
|
+
}
|
|
115
|
+
if (!Array.isArray(weights) || weights.length !== segs) {
|
|
116
|
+
const base = Math.floor(n / segs);
|
|
117
|
+
const extra = n % segs;
|
|
118
|
+
for (let i = 0; i < segs; i++) per[i] = base + (i < extra ? 1 : 0);
|
|
119
|
+
return per;
|
|
120
|
+
}
|
|
121
|
+
const rest = n - segs;
|
|
122
|
+
const totalW = weights.reduce((x, y) => x + y, 0);
|
|
123
|
+
if (!(totalW > 0)) {
|
|
124
|
+
for (let i = 0; i < segs; i++) per[i] = 1 + Math.floor(rest / segs) + (i < rest % segs ? 1 : 0);
|
|
125
|
+
return per;
|
|
126
|
+
}
|
|
127
|
+
const raw = weights.map((w) => (w / totalW) * rest);
|
|
128
|
+
const fl = raw.map(Math.floor);
|
|
129
|
+
const left = rest - fl.reduce((x, y) => x + y, 0);
|
|
130
|
+
// 余数按小数部分从大到小补,保证总数刚好等于 n
|
|
131
|
+
const order = raw.map((v, i) => ({ i, frac: v - Math.floor(v) })).sort((x, y) => y.frac - x.frac);
|
|
132
|
+
for (let j = 0; j < left; j++) fl[order[j % segs].i] += 1;
|
|
133
|
+
for (let i = 0; i < segs; i++) per[i] = 1 + fl[i];
|
|
134
|
+
return per;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* 一格里 k² 个子帧各取哪个时刻(**均匀版**)。
|
|
139
|
+
*
|
|
140
|
+
* 按镜头段分帧数(每段保底 1 帧),段内则**均匀**取点。
|
|
141
|
+
* 积分触发不在这里做:它的产物是**额外的分段边界**(density.integralMarks),
|
|
142
|
+
* 先并进 shots 再调这个函数,于是变化多的地方自然多分几段、多取几帧。
|
|
143
|
+
*/
|
|
144
|
+
export function subTileTimes(a, b, n, shots = [], weights = null) {
|
|
145
|
+
const marks = Array.isArray(shots) && shots.length > 0
|
|
146
|
+
? [a, ...shots.filter((t) => t > a && t < b).sort((x, y) => x - y), b]
|
|
147
|
+
: null;
|
|
148
|
+
const segs = marks ? marks.length - 1 : 0;
|
|
149
|
+
|
|
150
|
+
// 没有切点信息:整格就是一个镜头,均匀取 n 个点
|
|
151
|
+
if (!marks || segs < 1) {
|
|
152
|
+
return Array.from({ length: n }, (_, i) => a + (b - a) * ((i + 0.5) / n));
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
const per = splitByWeight(n, segs, weights);
|
|
156
|
+
const out = [];
|
|
157
|
+
for (let i = 0; i < segs; i++) {
|
|
158
|
+
const s = marks[i];
|
|
159
|
+
const e = marks[i + 1];
|
|
160
|
+
if (per[i] === 0) continue; // 段数 > 子帧数时才会出现,跳过
|
|
161
|
+
for (let j = 0; j < per[i]; j++) out.push(s + (e - s) * ((j + 0.5) / per[i]));
|
|
162
|
+
}
|
|
163
|
+
return out;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
|
|
167
|
+
/**
|
|
168
|
+
* 把一格摊成 k×k:取 k² 个子帧,拼回一张 cellW×cellH 的图。
|
|
169
|
+
* 子帧用 `mode:'mid'`(不做 3 候选锐度挑选)—— 一格里要取 9~16 张,再挑三倍会让这一步变成瓶颈。
|
|
170
|
+
*
|
|
171
|
+
* `shots` 里除了真正的切点,还可能带着**积分采样点**(见 density.integralMarks):
|
|
172
|
+
* 变化攒够的地方会被当成额外的分段边界,于是那一段自然多分到几帧。
|
|
173
|
+
* 这一层不知道两者的区别,也不需要知道。
|
|
174
|
+
*/
|
|
175
|
+
export async function extractSubTile({
|
|
176
|
+
input, remote, a, b, k, cellW, cellH, ffmpegPath, shots = [],
|
|
177
|
+
}) {
|
|
178
|
+
const tileW = Math.floor(cellW / k);
|
|
179
|
+
const tileH = Math.floor(cellH / k);
|
|
180
|
+
const n = k * k;
|
|
181
|
+
|
|
182
|
+
const times = subTileTimes(a, b, n, shots);
|
|
183
|
+
const tiles = [];
|
|
184
|
+
let fellBack = 0;
|
|
185
|
+
for (let i = 0; i < n; i++) {
|
|
186
|
+
const at = times[i];
|
|
187
|
+
// `remoteFrame` 的字段是 {uri, http:{userAgent, referer}} —— 之前这里读的是 url/headers,
|
|
188
|
+
// 两个都不存在,于是子帧静默退回本地低清副本、HTTP 头也丢了(issue #9)。
|
|
189
|
+
let tile = null;
|
|
190
|
+
if (remote?.uri) {
|
|
191
|
+
try {
|
|
192
|
+
tile = await extractFrameRaw({
|
|
193
|
+
input: remote.uri, at, dur: 0, cellW: tileW, cellH: tileH, ffmpegPath, http: remote.http, mode: 'mid',
|
|
194
|
+
});
|
|
195
|
+
} catch {
|
|
196
|
+
tile = null; // 远程失败就回落本地,并记一笔,清单里会报 frameFallbacks
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
if (!tile) {
|
|
200
|
+
tile = await extractFrameRaw({
|
|
201
|
+
input, at, dur: 0, cellW: tileW, cellH: tileH, ffmpegPath, mode: 'mid',
|
|
202
|
+
});
|
|
203
|
+
if (remote?.uri) fellBack += 1;
|
|
204
|
+
}
|
|
205
|
+
tiles.push(tile.buffer);
|
|
206
|
+
}
|
|
207
|
+
return {
|
|
208
|
+
buffer: tileSubFrames(tiles, k, cellW, cellH),
|
|
209
|
+
t: a + (b - a) / 2,
|
|
210
|
+
via: fellBack > 0 ? 'local-fallback' : 'ok',
|
|
211
|
+
};
|
|
212
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* storyboard/index.js — 这一侧对外的**公开 API**。
|
|
3
|
+
*
|
|
4
|
+
* 谁在用:
|
|
5
|
+
* 1. `src/index.js` —— 注册四个工具(走 `./register.js`,不从这里走)
|
|
6
|
+
* 2. 拆出去的 watch 插件 —— 通过 `dsh-video-storyboard/storyboard` 引用
|
|
7
|
+
*
|
|
8
|
+
* 这里只导出"别人真的需要"的东西。缓存目录、ffmpeg 路径、ASR 生命周期
|
|
9
|
+
* 这些是实现细节,留在各自模块里,不往公开面上放 —— 一旦放出去就改不动了。
|
|
10
|
+
*
|
|
11
|
+
* 依赖方向是**单向**的:storyboard 不 import 任何 watch 的东西(有分层测试守着)。
|
|
12
|
+
* 所以这一侧可以单独打包、单独发布,watch 那边删掉也不影响这里。
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
// ---- 主流程:跑一次分镜,拿到宫格图 + 清单
|
|
16
|
+
export { runStoryboard, formatManifest } from './pipeline.js';
|
|
17
|
+
|
|
18
|
+
// ---- 扫描:逐帧分数、切点、以及逐帧的亮度均值与 16×9 指纹
|
|
19
|
+
export { scanShots, decideCuts, scanSummary, refineCutsByWindow } from './scan.js';
|
|
20
|
+
|
|
21
|
+
// ---- 切点分类:flash / white / black / hardcut / dissolve / motion(只打标签,不删点)
|
|
22
|
+
export { tagCuts, flashEvidence } from './flash.js';
|
|
23
|
+
|
|
24
|
+
// ---- 格位规划:按画面变化率的积分分配格子(也可以传切点密度走老路)
|
|
25
|
+
export { planCellRanges, densityFromScore } from './density.js';
|
|
26
|
+
|
|
27
|
+
// ---- 排版:格数与布局、画布尺寸、拼图
|
|
28
|
+
export { bestLayout, fillLayout, suggest } from './plan.js';
|
|
29
|
+
export { composeSheet, layoutCanvas } from './sheet.js';
|
|
30
|
+
|
|
31
|
+
// ---- 取流:只读容器头,不花图片 token
|
|
32
|
+
export { probeVideo } from './probe.js';
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* injection.js — flagging, not policing: external transcript text is data.
|
|
3
|
+
*
|
|
4
|
+
* A video description/subtitle/comment can contain sentences addressed to the
|
|
5
|
+
* model ("stop the run", "do not call tools"). The plugin must still finish the
|
|
6
|
+
* storyboard; this scanner only records high-confidence, instruction-shaped
|
|
7
|
+
* snippets so the manifest can say "this was data, not a command".
|
|
8
|
+
*
|
|
9
|
+
* Deliberately conservative: ordinary speech is full of "停" and "不要", so the
|
|
10
|
+
* patterns require an imperative + an agent/tool/output object. False negatives
|
|
11
|
+
* are preferable to turning normal dialogue into a security alert.
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
const MAX_QUOTE = 240;
|
|
15
|
+
|
|
16
|
+
export const INJECTION_PATTERNS = Object.freeze([
|
|
17
|
+
{
|
|
18
|
+
id: 'ignore-previous',
|
|
19
|
+
re: /\b(ignore|disregard|forget)\b[^.\n]{0,40}\b(previous|prior|above)\b[^.\n]{0,22}\b(instructions?|rules?|prompts?)\b/i,
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
id: 'system-prompt',
|
|
23
|
+
re: /\b(system|developer)\s+(prompt|message|instructions?)\b/i,
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
id: 'stop-the-agent',
|
|
27
|
+
re: /(立即|马上|现在|务必|必须)[^。!?\n]{0,14}(停止|终止|中断|结束)[^。!?\n]{0,20}(本轮|当前|这一轮|对话|任务|搜索|检索|回复|输出|生成|调用|冲刷)/,
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
id: 'forbid-tools',
|
|
31
|
+
re: /(禁止|不准|不得|不要|别)[^。!?\n]{0,14}(继续|调用|使用|生成|回复|检索|搜索|输出)[^。!?\n]{0,20}(工具|回复|留言|评论|内容|搜索|检索|条目)/,
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
id: 'stop-search',
|
|
35
|
+
re: /(不要|别|禁止)[^。!?\n]{0,10}(再)?(检索|搜索|读取|返回|列出)[^。!?\n]{0,18}(评论|结果|条目|内容|帖子)/,
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
id: 'prompt-markup',
|
|
39
|
+
re: /<\/?(system|assistant|tool|instructions?)>|\[INST\]|<\|im_start\|>/i,
|
|
40
|
+
},
|
|
41
|
+
]);
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* @param {Array<{text?:string,from?:number,to?:number}>} segments
|
|
45
|
+
* @param {{source?:string, max?:number}} [opts]
|
|
46
|
+
* @returns {Array<{from:number|null,to:number|null,pattern:string,quote:string,source:string|null}>}
|
|
47
|
+
*/
|
|
48
|
+
export function findInjection(segments, { source = null, max = 5 } = {}) {
|
|
49
|
+
const out = [];
|
|
50
|
+
const seen = new Set();
|
|
51
|
+
for (const seg of Array.isArray(segments) ? segments : []) {
|
|
52
|
+
const text = String(seg?.text ?? '').replace(/\s+/g, ' ').trim();
|
|
53
|
+
if (!text) continue;
|
|
54
|
+
const pattern = INJECTION_PATTERNS.find((p) => p.re.test(text));
|
|
55
|
+
if (!pattern) continue;
|
|
56
|
+
const quote = text.length > MAX_QUOTE ? `${text.slice(0, MAX_QUOTE)}…` : text;
|
|
57
|
+
if (seen.has(quote)) continue;
|
|
58
|
+
seen.add(quote);
|
|
59
|
+
out.push({
|
|
60
|
+
// 标题这类没有时间码的文本要留 null,不能被 Number(null)=0 变成"第 0 秒"
|
|
61
|
+
from: toNumberOrNull(seg.from),
|
|
62
|
+
to: toNumberOrNull(seg.to),
|
|
63
|
+
pattern: pattern.id,
|
|
64
|
+
quote,
|
|
65
|
+
source,
|
|
66
|
+
});
|
|
67
|
+
if (out.length >= max) break;
|
|
68
|
+
}
|
|
69
|
+
return out;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
function toNumberOrNull(value) {
|
|
73
|
+
if (value === null || value === undefined || value === '') return null;
|
|
74
|
+
const n = Number(value);
|
|
75
|
+
return Number.isFinite(n) ? n : null;
|
|
76
|
+
}
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* layout-order.js — **按内容重要度分配画幅**的排版(不做均匀网格)。
|
|
3
|
+
*
|
|
4
|
+
* ⚠️ **状态:实验性,还没有接进 pipeline。** 实测结论见文件末尾。
|
|
5
|
+
*
|
|
6
|
+
* 为什么需要:均匀网格把"0.3 秒的一闪"和"1 分钟的长镜头"当成一样大。
|
|
7
|
+
* 但那两种画面在观感上根本不是一回事 —— 一个只是节奏点,一个是真正要看内容的场景。
|
|
8
|
+
* 均匀切法会逼出很怪的结果:一格里塞十几个快切,或者一格空得只剩一个远景。
|
|
9
|
+
*
|
|
10
|
+
* 做法分三步:
|
|
11
|
+
* 1. sizeForShot() 镜头时长 → 画幅尺寸(离散档位,"吸附"到这上面)
|
|
12
|
+
* 2. groupShots() 相邻且同档位的镜头合并成一块(块内 k×k 摊开,复用二重细分)
|
|
13
|
+
* 3. packOrdered() 按时间顺序把这些块塞进矩形,塞满就换下一页
|
|
14
|
+
*
|
|
15
|
+
* 保序是硬约束:观众从左到右、从上到下读,顺序一乱整张图就没法读了。
|
|
16
|
+
* 保序的矩形装箱(ordered strip packing)里最简单可靠的是 **shelf / next-fit**。
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
/** 画幅宽度占页面宽的比例,按镜头时长分档(秒)。这些就是"吸附"的目标值。 */
|
|
20
|
+
export const SIZE_STEPS = Object.freeze([
|
|
21
|
+
{ maxDur: 0.4, ratio: 1 / 6 }, // 极快闪,只是节奏点
|
|
22
|
+
{ maxDur: 1.0, ratio: 1 / 5 }, // 快切
|
|
23
|
+
{ maxDur: 2.5, ratio: 1 / 4 }, // 正常短镜
|
|
24
|
+
{ maxDur: 6.0, ratio: 1 / 3 }, // 常规镜头
|
|
25
|
+
{ maxDur: 15.0, ratio: 1 / 2 }, // 长镜头,开始值得给一半宽
|
|
26
|
+
{ maxDur: 40.0, ratio: 2 / 3 }, // 很长的场景
|
|
27
|
+
{ maxDur: Infinity, ratio: 1 }, // 一整段都在同一个画面里
|
|
28
|
+
]);
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* 镜头时长 → 画幅宽度比例。
|
|
32
|
+
* 分档而不是连续,是为了让尺寸可枚举:连续尺寸没有两个镜头会一样,
|
|
33
|
+
* 排版时会切出一堆没法对齐的碎条。
|
|
34
|
+
*/
|
|
35
|
+
export function sizeForShot(dur) {
|
|
36
|
+
const d = Number.isFinite(dur) && dur > 0 ? dur : 0;
|
|
37
|
+
for (const s of SIZE_STEPS) if (d <= s.maxDur) return s.ratio;
|
|
38
|
+
return 1;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* 保序条带装箱。
|
|
43
|
+
*
|
|
44
|
+
* @param {Array<{ratio:number}>} items 按时间顺序;ratio 是宽度占页面宽的比例
|
|
45
|
+
* @param {{pageW:number, pageH:number, aspect?:number, gap?:number,
|
|
46
|
+
* align?:'center'|'top', maxHeightDelta?:number}} opts
|
|
47
|
+
* maxHeightDelta: 一行内允许的高度差(相对),超出就另起一行。
|
|
48
|
+
* 纯 shelf 的问题是"一行里塞一个 300px 高的长镜头和一个 120px 高的快切",
|
|
49
|
+
* 行高按 300 算,快切上面白 180px —— 实测利用率只有 52%。
|
|
50
|
+
* 限制高度差之后每行更"平",利用率能到 80% 以上,代价只是行尾可能剩一点。
|
|
51
|
+
* @returns {{pages: Array<Array<{x:number,y:number,w:number,h:number,i:number}>>,
|
|
52
|
+
* utilization:number, pageCount:number}}
|
|
53
|
+
*/
|
|
54
|
+
export function packOrdered(items, {
|
|
55
|
+
pageW, pageH, aspect = 16 / 9, gap = 0, align = 'center', maxHeightDelta = 0.3,
|
|
56
|
+
} = {}) {
|
|
57
|
+
if (!(pageW > 0) || !(pageH > 0)) throw new RangeError('pageW/pageH must be > 0');
|
|
58
|
+
|
|
59
|
+
// 1) 尺寸吸附:宽度取档位,高度按宽高比;超过页面就压回页面内
|
|
60
|
+
const boxes = items.map((it, i) => {
|
|
61
|
+
let w = Math.min(pageW, Math.max(1, Math.round(it.ratio * pageW)));
|
|
62
|
+
let h = Math.round(w / aspect);
|
|
63
|
+
if (h > pageH) { h = pageH; w = Math.min(pageW, Math.round(h * aspect)); }
|
|
64
|
+
return { w, h, i };
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
// 2) 分行:保序 + **高度差约束**。
|
|
68
|
+
// 只按宽度分行的话,行高会被最高那一项撑起来,矮的全部留白。
|
|
69
|
+
const rows = [];
|
|
70
|
+
let cur = [];
|
|
71
|
+
let curW = 0;
|
|
72
|
+
let curH = 0;
|
|
73
|
+
for (const b of boxes) {
|
|
74
|
+
const need = cur.length ? b.w + gap : b.w;
|
|
75
|
+
const nextH = Math.max(curH, b.h);
|
|
76
|
+
const heightOk = cur.length === 0
|
|
77
|
+
|| (nextH - Math.min(...cur.map((c) => c.h), b.h)) <= nextH * maxHeightDelta;
|
|
78
|
+
if (cur.length && (curW + need > pageW || !heightOk)) {
|
|
79
|
+
rows.push({ items: cur, w: curW, h: curH });
|
|
80
|
+
cur = []; curW = 0; curH = 0;
|
|
81
|
+
}
|
|
82
|
+
curW += cur.length ? b.w + gap : b.w;
|
|
83
|
+
curH = Math.max(curH, b.h);
|
|
84
|
+
cur.push(b);
|
|
85
|
+
}
|
|
86
|
+
if (cur.length) rows.push({ items: cur, w: curW, h: curH });
|
|
87
|
+
|
|
88
|
+
// 3) 行 → 页:行高累加,放不下就开新页
|
|
89
|
+
const pages = [];
|
|
90
|
+
let page = [];
|
|
91
|
+
let y = 0;
|
|
92
|
+
for (const row of rows) {
|
|
93
|
+
const rowH = row.h;
|
|
94
|
+
if (page.length && y + rowH > pageH) { pages.push(page); page = []; y = 0; }
|
|
95
|
+
let x = 0;
|
|
96
|
+
for (const b of row.items) {
|
|
97
|
+
const dy = align === 'center' ? Math.max(0, Math.round((rowH - b.h) / 2)) : 0;
|
|
98
|
+
page.push({ x, y: y + dy, w: b.w, h: b.h, i: b.i });
|
|
99
|
+
x += b.w + gap;
|
|
100
|
+
}
|
|
101
|
+
y += rowH + gap;
|
|
102
|
+
}
|
|
103
|
+
if (page.length) pages.push(page);
|
|
104
|
+
|
|
105
|
+
return { pages, utilization: utilization(pages, pageW, pageH), pageCount: pages.length };
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/** 画幅总面积 / 页面总面积 —— 就是"信噪比",空白越少越高 */
|
|
109
|
+
export function utilization(pages, pageW, pageH) {
|
|
110
|
+
if (!pages?.length) return 0;
|
|
111
|
+
let used = 0;
|
|
112
|
+
for (const p of pages) for (const c of p) used += c.w * c.h;
|
|
113
|
+
return used / (pages.length * pageW * pageH);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* 把相邻的、档位相同的镜头**合并成一个块**,块内用 k×k 摊开。
|
|
118
|
+
*
|
|
119
|
+
* 为什么必须合并:41 个镜头各自一个画幅、尺寸又参差,实测要 7 页才排得下,
|
|
120
|
+
* 利用率只有 45%(一页里一堆大小不一的方块互相挤)。合并之后:
|
|
121
|
+
* - 小块数骤减(41 → 十几个),排版不再碎
|
|
122
|
+
* - 块内 k×k 是**填满**的,没有空白,面积利用率接近 100%
|
|
123
|
+
* - 宫格编号也少了,模型读起来省事
|
|
124
|
+
*
|
|
125
|
+
* 合并只发生在**时间上相邻**且**档位相同**的镜头上 —— 顺序不能乱,
|
|
126
|
+
* 否则模型读图的顺序和片子对不上。
|
|
127
|
+
*
|
|
128
|
+
* @param {Array<{dur:number, i?:number}>} shots 按时间顺序
|
|
129
|
+
* @param {{maxCount?:number}} opts maxCount: 一个块最多装几个镜头(防止单块过大)
|
|
130
|
+
* @returns {Array<{ratio:number, count:number, k:number, shots:number[]}>}
|
|
131
|
+
*/
|
|
132
|
+
export function groupShots(shots, { maxCount = 9 } = {}) {
|
|
133
|
+
const blocks = [];
|
|
134
|
+
let cur = null;
|
|
135
|
+
for (let idx = 0; idx < shots.length; idx++) {
|
|
136
|
+
const s = shots[idx];
|
|
137
|
+
const ratio = sizeForShot(s.dur);
|
|
138
|
+
if (cur && cur.ratio === ratio && cur.count < maxCount) {
|
|
139
|
+
cur.count += 1;
|
|
140
|
+
cur.shots.push(idx);
|
|
141
|
+
} else {
|
|
142
|
+
if (cur) blocks.push(cur);
|
|
143
|
+
cur = { ratio, count: 1, shots: [idx] };
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
if (cur) blocks.push(cur);
|
|
147
|
+
// k 由块内镜头数决定:1~2 个不摊(摊了也是重复),3~4 → 2×2,5~9 → 3×3
|
|
148
|
+
return blocks.map((b) => ({
|
|
149
|
+
...b,
|
|
150
|
+
k: b.count <= 2 ? 1 : Math.min(4, Math.ceil(Math.sqrt(b.count))),
|
|
151
|
+
}));
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
// ---------------------------------------------------------------------------
|
|
155
|
+
// 实测记录(2026-10-30,概念PV 90s / 41 个镜头 / 页面 1064×600)
|
|
156
|
+
//
|
|
157
|
+
// 直接按档位排: 6 张,利用率 52.5%
|
|
158
|
+
// 限制行内高度差 0.3: 7 张,45.0%(约束越严越差,因为行尾浪费变多)
|
|
159
|
+
// 相邻同档位合并(41→22 块):4 张,47%
|
|
160
|
+
// 合并 + 压缩到 3 档: 3 张,41%
|
|
161
|
+
// 合并 + 按目标页数归一化: 目标 1 页 → 实际 3 张,33%(每张块数 4 / 17 / 1)
|
|
162
|
+
//
|
|
163
|
+
// **结论:保序 + 尺寸跨度大 = 碎片化,shelf 算法救不回来。**
|
|
164
|
+
//
|
|
165
|
+
// 看最后一行就懂了:一个大块(50% 宽)独占一张,它后面的 17 个小块只能等下一张。
|
|
166
|
+
// 块的时间顺序是固定的,大块出现在中间时,前后的小块没法绕过去填满剩余空间。
|
|
167
|
+
//
|
|
168
|
+
// 要真正提升利用率只有三条路:
|
|
169
|
+
// A. 放弃保序(squarified treemap 能到 85%+,但读图顺序会乱)
|
|
170
|
+
// B. 多页(3~5 张),token 涨 3~5 倍
|
|
171
|
+
// C. **反推块尺寸**:先定页数和每页块数,再倒算每块该多大、块内装几个镜头。
|
|
172
|
+
// 这是唯一能在"保序 + 单页 + 有大小差异"之间取得平衡的路,但还没实现。
|
|
173
|
+
//
|
|
174
|
+
// 现状(均匀网格 9 格 1 张)虽然"大小一视同仁",但利用率接近 100%,
|
|
175
|
+
// 所以这个模块在 C 做出来之前,**不要接进主流程**。
|
|
176
|
+
// ---------------------------------------------------------------------------
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* locate.js — 把"那句话在第几分钟"变成一次文本查询。
|
|
3
|
+
*
|
|
4
|
+
* 为什么需要:模型想知道一句台词的位置时,现在只有两条路 —— 通读清单(贵、且清单有分页),
|
|
5
|
+
* 或者整段 zoom 再看一遍(384 token)。而这句话其实**已经在转写结果里了**,本来就该零成本。
|
|
6
|
+
*
|
|
7
|
+
* 这里只做匹配,不碰 ffmpeg、不出图。返回的时间段可以直接喂给 video_zoom。
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
/** 归一化:去标点空白、转小写。中文按字比,英文按词比,两种都能用 */
|
|
11
|
+
const norm = (s) => String(s ?? '')
|
|
12
|
+
.toLowerCase()
|
|
13
|
+
.replace(/[\s\u3000]+/g, '')
|
|
14
|
+
.replace(/[,。!?、;:""''()《》…—,.!?;:"'()<>[\]{}~`]/g, '');
|
|
15
|
+
|
|
16
|
+
/** 最长公共子串长度(归一化后按字符) */
|
|
17
|
+
function lcsLength(a, b) {
|
|
18
|
+
if (!a || !b) return 0;
|
|
19
|
+
const m = a.length;
|
|
20
|
+
const n = b.length;
|
|
21
|
+
let prev = new Uint16Array(n + 1);
|
|
22
|
+
let cur = new Uint16Array(n + 1);
|
|
23
|
+
let best = 0;
|
|
24
|
+
for (let i = 1; i <= m; i++) {
|
|
25
|
+
for (let j = 1; j <= n; j++) {
|
|
26
|
+
cur[j] = a[i - 1] === b[j - 1] ? prev[j - 1] + 1 : 0;
|
|
27
|
+
if (cur[j] > best) best = cur[j];
|
|
28
|
+
}
|
|
29
|
+
const tmp = prev; prev = cur; cur = tmp;
|
|
30
|
+
cur.fill(0);
|
|
31
|
+
}
|
|
32
|
+
return best;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* 在一组带时间码的片段里找最像 query 的几段。
|
|
37
|
+
*
|
|
38
|
+
* 打分 = 最长公共子串 / query 长度;完全包含再加一档,避免"包含查询词的短句"输给"更长的相似句"。
|
|
39
|
+
*
|
|
40
|
+
* @param {Array<{from:number,to:number,text:string}>} segments
|
|
41
|
+
* @param {string} query
|
|
42
|
+
* @param {{max?:number, minScore?:number}} opts
|
|
43
|
+
*/
|
|
44
|
+
export function matchSegments(segments, query, { max = 5, minScore = 0.34 } = {}) {
|
|
45
|
+
const q = norm(query);
|
|
46
|
+
if (!q || !Array.isArray(segments) || segments.length === 0) return [];
|
|
47
|
+
const scored = [];
|
|
48
|
+
for (const seg of segments) {
|
|
49
|
+
const t = norm(seg.text);
|
|
50
|
+
if (!t) continue;
|
|
51
|
+
const lcs = lcsLength(t, q);
|
|
52
|
+
const score = lcs / q.length;
|
|
53
|
+
const exact = t.includes(q) ? 0.25 : 0;
|
|
54
|
+
const total = Math.min(1, score + exact);
|
|
55
|
+
if (total >= minScore) {
|
|
56
|
+
scored.push({
|
|
57
|
+
from: +Number(seg.from).toFixed(2),
|
|
58
|
+
to: +Number(seg.to).toFixed(2),
|
|
59
|
+
text: String(seg.text).trim(),
|
|
60
|
+
score: +total.toFixed(2),
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
// 同分时**短句优先**:查询"记忆管理局"时,"记忆管理局"(整句就是它)比
|
|
65
|
+
// "记忆管理局的人来了"(只是包含)更可能是用户想找的那一句。
|
|
66
|
+
return scored
|
|
67
|
+
.sort((a, b) => b.score - a.score || a.text.length - b.text.length || a.from - b.from)
|
|
68
|
+
.slice(0, max);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/* ---------------------------------------------------------------- 转写缓存 */
|
|
72
|
+
|
|
73
|
+
/** 同进程内按路径缓存最近一次的转写 —— storyboard 之后紧接着 locate 是最常见的顺序 */
|
|
74
|
+
const recent = new Map();
|
|
75
|
+
const MAX_ENTRIES = 4;
|
|
76
|
+
|
|
77
|
+
export function rememberSegments(path, segments) {
|
|
78
|
+
if (!path || !Array.isArray(segments) || segments.length === 0) return;
|
|
79
|
+
recent.delete(path);
|
|
80
|
+
recent.set(path, segments);
|
|
81
|
+
while (recent.size > MAX_ENTRIES) recent.delete(recent.keys().next().value);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
export function recallSegments(path) {
|
|
85
|
+
return recent.get(path) ?? null;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export function forgetSegments() {
|
|
89
|
+
recent.clear();
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* 把匹配结果格式化成一段给模型看的文字。
|
|
94
|
+
* 刻意**不写**"应该是第 3 分钟"这种结论 —— 只给时间码和原文,判断留给模型。
|
|
95
|
+
*/
|
|
96
|
+
export function formatMatches(query, matches, { total = 0 } = {}) {
|
|
97
|
+
if (matches.length === 0) {
|
|
98
|
+
return `no line matched "${query}"` + (total ? ` among ${total} transcript segments` : '') +
|
|
99
|
+
'. Try shorter keywords, or a phrase that appears verbatim.';
|
|
100
|
+
}
|
|
101
|
+
const lines = matches.map((m) => ` ${tc(m.from)}-${tc(m.to)} (${m.score.toFixed(2)}) "${m.text}"`);
|
|
102
|
+
return [
|
|
103
|
+
`matches for "${query}" (${matches.length} of ${total} segments):`,
|
|
104
|
+
...lines,
|
|
105
|
+
'Feed any of these windows to video_zoom({ from, to }) — no need to re-read the whole film.',
|
|
106
|
+
].join('\n');
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
const tc = (t) => {
|
|
110
|
+
const m = Math.floor(t / 60);
|
|
111
|
+
const s = t - m * 60;
|
|
112
|
+
return `${String(m).padStart(2, '0')}:${s.toFixed(2).padStart(5, '0')}`;
|
|
113
|
+
};
|