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,90 @@
|
|
|
1
|
+
import assert from 'node:assert/strict';
|
|
2
|
+
import test from 'node:test';
|
|
3
|
+
import { mkdtemp, readFile, rm, writeFile } from 'node:fs/promises';
|
|
4
|
+
import { join } from 'node:path';
|
|
5
|
+
import { tmpdir } from 'node:os';
|
|
6
|
+
import { createLifeStore, durableWrite } from '../src/life/lifeStore.ts';
|
|
7
|
+
import { createWorldSwitch } from '../src/worldSwitch.ts';
|
|
8
|
+
import { readdirSync, renameSync } from 'node:fs';
|
|
9
|
+
|
|
10
|
+
async function dir(t: test.TestContext) { const root = await mkdtemp(join(tmpdir(), 'dsh-life-')); t.after(() => rm(root, { recursive: true, force: true })); return root; }
|
|
11
|
+
|
|
12
|
+
test('life state round-trips atomically and starts empty', async t => {
|
|
13
|
+
const root = await dir(t); const store = createLifeStore(root, 'Asia/Seoul');
|
|
14
|
+
assert.deepEqual(store.read(), { version: 1 });
|
|
15
|
+
const alarm = { at: '2026-10-23T12:00:00.000Z', note: '写日记', setAt: '2026-10-23T11:00:00.000Z', source: 'plan' as const };
|
|
16
|
+
store.write({ version: 1, homeSessionId: 'home', alarm });
|
|
17
|
+
assert.deepEqual(createLifeStore(root, 'Asia/Seoul').read(), { version: 1, homeSessionId: 'home', alarm });
|
|
18
|
+
});
|
|
19
|
+
test('a life.json that is not JSON is reported and left untouched', async t => {
|
|
20
|
+
const root = await dir(t); await writeFile(join(root, 'life.json'), '{broken');
|
|
21
|
+
assert.throws(() => createLifeStore(root, 'UTC').read(), /not valid JSON/);
|
|
22
|
+
assert.equal(await readFile(join(root, 'life.json'), 'utf8'), '{broken');
|
|
23
|
+
});
|
|
24
|
+
test('activity is split by local day and a failed write marks the next record as a gap', async t => {
|
|
25
|
+
const root = await dir(t); const store = createLifeStore(root, 'Asia/Seoul');
|
|
26
|
+
const base = { sessionId: 'home', callId: 'c', tool: 'pwsh', summary: 'x', outside: true };
|
|
27
|
+
assert.ok(store.appendActivity({ ...base, time: '2026-10-22T15:30:00.000Z' }));
|
|
28
|
+
assert.deepEqual(store.activityDays(), ['2026-10-23']);
|
|
29
|
+
assert.equal(store.activity('2026-10-23').length, 1);
|
|
30
|
+
assert.deepEqual(store.activity('../life'), []);
|
|
31
|
+
await rm(join(root, 'activity'), { recursive: true }); await writeFile(join(root, 'activity'), 'not a directory');
|
|
32
|
+
assert.equal(store.appendActivity({ ...base, time: '2026-10-23T01:00:00.000Z' }), false);
|
|
33
|
+
await rm(join(root, 'activity'));
|
|
34
|
+
assert.ok(store.appendActivity({ ...base, time: '2026-10-23T02:00:00.000Z' }));
|
|
35
|
+
assert.equal(store.activity('2026-10-23')[0].gapBefore, true);
|
|
36
|
+
});
|
|
37
|
+
test('wake and compaction logs append and skip a half-written tail', async t => {
|
|
38
|
+
const root = await dir(t); const store = createLifeStore(root, 'UTC');
|
|
39
|
+
store.appendWake({ scheduledAt: 'a', deliveredAt: 'b', source: 'first', lateMs: 0 });
|
|
40
|
+
await writeFile(join(root, 'life', 'wakes.jsonl'), (await readFile(join(root, 'life', 'wakes.jsonl'), 'utf8')) + '{"half');
|
|
41
|
+
assert.equal(store.wakes().length, 1);
|
|
42
|
+
store.appendCompaction({ time: 't', sessionId: 's', ok: true, shadowedTokens: 10 });
|
|
43
|
+
assert.deepEqual(store.compactions(), [{ time: 't', sessionId: 's', ok: true, shadowedTokens: 10 }]);
|
|
44
|
+
});
|
|
45
|
+
test('a half-written tail does not swallow the next record', async t => {
|
|
46
|
+
const root = await dir(t); const store = createLifeStore(root, 'UTC'); const file = join(root, 'life', 'wakes.jsonl');
|
|
47
|
+
store.appendWake({ scheduledAt: 'a', deliveredAt: 'b', source: 'first', lateMs: 0 });
|
|
48
|
+
await writeFile(file, (await readFile(file, 'utf8')) + '{"half');
|
|
49
|
+
store.appendWake({ scheduledAt: 'c', deliveredAt: 'd', source: 'plan', lateMs: 1 });
|
|
50
|
+
assert.deepEqual(store.wakes().map(wake => wake.scheduledAt), ['a', 'c']);
|
|
51
|
+
});
|
|
52
|
+
test('activity heals a deleted directory and non-object lines are skipped', async t => {
|
|
53
|
+
const root = await dir(t); const store = createLifeStore(root, 'UTC');
|
|
54
|
+
const base = { sessionId: 'home', callId: 'c', tool: 'pwsh', summary: 'x', outside: false };
|
|
55
|
+
await rm(join(root, 'activity'), { recursive: true });
|
|
56
|
+
assert.ok(store.appendActivity({ ...base, time: '2026-10-23T01:00:00.000Z' }));
|
|
57
|
+
await writeFile(join(root, 'activity', '2026-10-23.jsonl'), (await readFile(join(root, 'activity', '2026-10-23.jsonl'), 'utf8')) + '42\nnull\n');
|
|
58
|
+
assert.equal(store.activity('2026-10-23').length, 1);
|
|
59
|
+
});
|
|
60
|
+
function fail(code: string) { return Object.assign(new Error(code), { code }); }
|
|
61
|
+
test('durableWrite retries a transient rename lock and then succeeds', async t => {
|
|
62
|
+
const root = await dir(t); const file = join(root, 'life.json'); let calls = 0;
|
|
63
|
+
durableWrite(file, 'new', (from, to) => { if (++calls <= 2) throw fail('EPERM'); renameSync(from, to); });
|
|
64
|
+
assert.equal(calls, 3);
|
|
65
|
+
assert.equal(await readFile(file, 'utf8'), 'new');
|
|
66
|
+
assert.deepEqual(readdirSync(root).filter(name => name.endsWith('.tmp')), []);
|
|
67
|
+
});
|
|
68
|
+
test('durableWrite gives up on a permanent lock and cleans the temp file', async t => {
|
|
69
|
+
const root = await dir(t); const file = join(root, 'life.json'); let calls = 0;
|
|
70
|
+
assert.throws(() => durableWrite(file, 'new', () => { calls++; throw fail('EPERM'); }), { code: 'EPERM' });
|
|
71
|
+
assert.equal(calls, 10);
|
|
72
|
+
assert.deepEqual(readdirSync(root).filter(name => name.endsWith('.tmp')), []);
|
|
73
|
+
});
|
|
74
|
+
test('durableWrite rethrows a non-retryable error immediately', async t => {
|
|
75
|
+
const root = await dir(t); const file = join(root, 'life.json'); let calls = 0;
|
|
76
|
+
assert.throws(() => durableWrite(file, 'new', () => { calls++; throw fail('ENOSPC'); }), { code: 'ENOSPC' });
|
|
77
|
+
assert.equal(calls, 1);
|
|
78
|
+
assert.deepEqual(readdirSync(root).filter(name => name.endsWith('.tmp')), []);
|
|
79
|
+
});
|
|
80
|
+
test('a new world waits for start; a world with a life line from before the switch is running; the switch outlasts a restart', async t => {
|
|
81
|
+
const fresh = await dir(t);
|
|
82
|
+
assert.equal(createWorldSwitch(fresh).running(), false);
|
|
83
|
+
const old = await dir(t); await writeFile(join(old, 'life.json'), JSON.stringify({ version: 1, homeSessionId: 'home' }));
|
|
84
|
+
const power = createWorldSwitch(old);
|
|
85
|
+
assert.equal(power.running(), true);
|
|
86
|
+
power.set(false);
|
|
87
|
+
assert.equal(createWorldSwitch(old).running(), false, 'stopped stays stopped, life.json or not');
|
|
88
|
+
createWorldSwitch(fresh).set(true);
|
|
89
|
+
assert.equal(createWorldSwitch(fresh).running(), true);
|
|
90
|
+
});
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import assert from 'node:assert/strict';
|
|
2
|
+
import test from 'node:test';
|
|
3
|
+
import { lifeTools } from '../src/life/tools.ts';
|
|
4
|
+
import type { Outlet, Push, PushKind } from '../src/ecosystem/shared/outlets.ts';
|
|
5
|
+
|
|
6
|
+
const ctx = {} as never;
|
|
7
|
+
const none = { outlets: [] };
|
|
8
|
+
const outlet = (name: string, send: (push: Push) => Promise<void>, kinds: PushKind[] = ['reply', 'busy', 'reach']): Outlet => ({ name, kinds, send });
|
|
9
|
+
const fail = (reason: string) => async () => { throw new Error(reason); };
|
|
10
|
+
|
|
11
|
+
test('plan_next forwards exactly the given selector and note', async () => {
|
|
12
|
+
const seen: unknown[] = [];
|
|
13
|
+
const [planNext] = lifeTools({ planNext: (input, note) => { seen.push({ input, note }); return 'ok'; }, notifier: none });
|
|
14
|
+
assert.equal(planNext.name, 'plan_next');
|
|
15
|
+
assert.equal(await planNext.execute({ after_minutes: 30, note: '去写日记' }, ctx), 'ok');
|
|
16
|
+
assert.equal(await planNext.execute({ at: '2026-10-24T08:00:00+09:00', note: '早安' }, ctx), 'ok');
|
|
17
|
+
assert.deepEqual(seen, [{ input: { after_minutes: 30 }, note: '去写日记' }, { input: { at: '2026-10-24T08:00:00+09:00' }, note: '早安' }]);
|
|
18
|
+
});
|
|
19
|
+
test('a throwing planNext makes plan_next reject', async () => {
|
|
20
|
+
const [planNext] = lifeTools({ planNext: () => { throw new Error('太近了'); }, notifier: none });
|
|
21
|
+
await assert.rejects(planNext.execute({ after_minutes: 0, note: 'x' }, ctx), /太近了/);
|
|
22
|
+
});
|
|
23
|
+
test('reach_out goes to the system notification and every outlet that takes reach, and reports each one', async () => {
|
|
24
|
+
const seen: unknown[] = [];
|
|
25
|
+
const [, reachOut] = lifeTools({
|
|
26
|
+
planNext: () => '', names: { companion: '鲸鲸', partner: '阿明' }, origin: () => 'http://127.0.0.1:5173',
|
|
27
|
+
notifier: {
|
|
28
|
+
toast: async (title, body) => { seen.push({ title, body }); },
|
|
29
|
+
outlets: [outlet('桌面应用', async push => { seen.push(push); }), outlet('只要回复', async push => { seen.push(push); }, ['reply']), outlet('坏的', fail('HTTP 404'), ['reach'])],
|
|
30
|
+
},
|
|
31
|
+
});
|
|
32
|
+
assert.equal(reachOut.name, 'reach_out');
|
|
33
|
+
assert.match(reachOut.description, /想找阿明时用/); assert.match(reachOut.description, /(系统通知 \+ 桌面应用 \+ 坏的)/);
|
|
34
|
+
assert.equal(await reachOut.execute({ text: '**在吗** ', image: '可爱' }, ctx), '系统通知已发出;桌面应用已送到;坏的没送到:HTTP 404。');
|
|
35
|
+
assert.deepEqual(seen, [
|
|
36
|
+
{ title: '鲸鲸', body: '**在吗** ' },
|
|
37
|
+
{ text: '在吗', kind: 'reach', name: '鲸鲸', images: ['http://127.0.0.1:5173/m/a.png'], image: '可爱' },
|
|
38
|
+
]);
|
|
39
|
+
});
|
|
40
|
+
test('reach_out fails only when every channel fails, so the model sees an error', async () => {
|
|
41
|
+
const [, partly] = lifeTools({ planNext: () => '', notifier: { toast: fail('超时'), outlets: [outlet('桌面应用', async () => {})] } });
|
|
42
|
+
assert.equal(await partly.execute({ text: '在吗' }, ctx), '系统通知没送到:超时;桌面应用已送到。');
|
|
43
|
+
const [, allFail] = lifeTools({ planNext: () => '', notifier: { toast: fail('超时'), outlets: [outlet('桌面应用', fail('running.json 读不到'))] } });
|
|
44
|
+
await assert.rejects(allFail.execute({ text: '在吗' }, ctx), { message: '系统通知没送到:超时;桌面应用没送到:running.json 读不到。' });
|
|
45
|
+
});
|
|
46
|
+
test('without any channel, reach_out says so instead of pretending', async () => {
|
|
47
|
+
const [, reachOut] = lifeTools({ planNext: () => '', notifier: none });
|
|
48
|
+
assert.match(reachOut.description, /现在还没有配置任何通道/);
|
|
49
|
+
await assert.rejects(reachOut.execute({ text: '在吗' }, ctx), /还没有配置任何通道,话留在家里了/);
|
|
50
|
+
const [, toastOnly] = lifeTools({ planNext: () => '', notifier: { toast: async () => {}, outlets: [] } });
|
|
51
|
+
assert.match(toastOnly.description, /(系统通知)/);
|
|
52
|
+
assert.equal(await toastOnly.execute({ text: '在吗' }, ctx), '系统通知已发出。');
|
|
53
|
+
});
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import assert from 'node:assert/strict';
|
|
2
|
+
import test from 'node:test';
|
|
3
|
+
import { mkdtemp, rm, writeFile } from 'node:fs/promises';
|
|
4
|
+
import { tmpdir } from 'node:os';
|
|
5
|
+
import { join } from 'node:path';
|
|
6
|
+
import { busyText, createOutlet, outletUrl, plainMessage, pushOf, readBaseUrl } from '../src/ecosystem/shared/outlets.ts';
|
|
7
|
+
|
|
8
|
+
const BOM = String.fromCharCode(0xfeff);
|
|
9
|
+
async function tempDir(t: test.TestContext) {
|
|
10
|
+
const dir = await mkdtemp(join(tmpdir(), 'dsh-world-outlet-'));
|
|
11
|
+
t.after(() => rm(dir, { recursive: true, force: true }));
|
|
12
|
+
return dir;
|
|
13
|
+
}
|
|
14
|
+
function fakeFetch(reply: () => Promise<Response> = () => Promise.resolve(Response.json({ ok: true }))) {
|
|
15
|
+
const calls: { url: string; body: any; signal: unknown; method?: string }[] = [];
|
|
16
|
+
const fetchImpl = ((url: string, init: RequestInit) => { calls.push({ url, body: JSON.parse(String(init.body)), signal: init.signal, method: init.method }); return reply(); }) as typeof fetch;
|
|
17
|
+
return { calls, fetchImpl };
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
test('stickers come out of her markdown as images and the text is reduced to plain lines', () => {
|
|
21
|
+
assert.deepEqual(plainMessage('\n## 好呀\n**今天**去 __公园__,带上 `伞`。\n\n'), {
|
|
22
|
+
text: '好呀\n今天去 公园,带上 伞。', images: ['http://127.0.0.1:5173/dsh-deepseek-meme/assets/a?size=150', 'http://h/b.png'],
|
|
23
|
+
});
|
|
24
|
+
assert.deepEqual(plainMessage('只有字\n第二行'), { text: '只有字\n第二行', images: [] });
|
|
25
|
+
});
|
|
26
|
+
test('a reply that is only stickers keeps their alt text, since an outlet may drop a push without text', () => {
|
|
27
|
+
assert.deepEqual(plainMessage(' '), { text: '哼 得意', images: ['http://h/a.png', 'http://h/b.png'] });
|
|
28
|
+
assert.deepEqual(plainMessage(''), { text: '(表情包)', images: ['http://h/a.png'] });
|
|
29
|
+
assert.equal(plainMessage('').text, '');
|
|
30
|
+
});
|
|
31
|
+
test('a sticker URL without an origin is resolved against the DSH origin; other schemes are dropped', () => {
|
|
32
|
+
assert.deepEqual(plainMessage(' 嗨 ) ', 'http://127.0.0.1:5173'), {
|
|
33
|
+
text: '嗨', images: ['http://127.0.0.1:5173/dsh-deepseek-meme/assets/a?size=150', 'http://h/c.png'],
|
|
34
|
+
});
|
|
35
|
+
assert.deepEqual(plainMessage(' 嗨').images, [], 'no origin, no relative image');
|
|
36
|
+
});
|
|
37
|
+
test('a base URL is read from a JSON file, with or without a BOM', async t => {
|
|
38
|
+
const dir = await tempDir(t); const file = join(dir, 'running.json');
|
|
39
|
+
await writeFile(file, BOM + JSON.stringify({ baseUrl: 'http://127.0.0.1:7340/', pid: 1 }));
|
|
40
|
+
assert.equal(readBaseUrl(file), 'http://127.0.0.1:7340');
|
|
41
|
+
await writeFile(file, JSON.stringify({ pid: 1 }));
|
|
42
|
+
assert.throws(() => readBaseUrl(file), /baseUrl/);
|
|
43
|
+
assert.throws(() => readBaseUrl(join(dir, 'missing.json')), /missing\.json 读不到/);
|
|
44
|
+
});
|
|
45
|
+
test('a urlFile outlet re-reads its file before every push, so a new port is picked up', async t => {
|
|
46
|
+
const dir = await tempDir(t); const file = join(dir, 'running.json');
|
|
47
|
+
const { calls, fetchImpl } = fakeFetch();
|
|
48
|
+
const outlet = createOutlet({ name: '桌面应用', urlFile: file, path: '/hook?x=1' }, () => 'http://dsh', fetchImpl);
|
|
49
|
+
assert.deepEqual(outlet.kinds, ['reply', 'busy', 'reach'], 'all kinds when none are listed');
|
|
50
|
+
await writeFile(file, BOM + JSON.stringify({ baseUrl: 'http://127.0.0.1:7001' }));
|
|
51
|
+
await outlet.send({ text: '在呢', kind: 'reply', name: 'TA', images: ['http://h/a.png'] });
|
|
52
|
+
await writeFile(file, JSON.stringify({ baseUrl: 'http://127.0.0.1:7002' }));
|
|
53
|
+
await outlet.send({ text: busyText('TA'), kind: 'busy', name: 'TA' });
|
|
54
|
+
assert.deepEqual(calls.map(call => [call.method, call.url, call.body]), [
|
|
55
|
+
['POST', 'http://127.0.0.1:7001/hook?x=1', { text: '在呢', kind: 'reply', name: 'TA', images: ['http://h/a.png'] }],
|
|
56
|
+
['POST', 'http://127.0.0.1:7002/hook?x=1', { text: 'TA在忙,忙完会在家里回你', kind: 'busy', name: 'TA' }],
|
|
57
|
+
]);
|
|
58
|
+
assert.ok(calls[0]!.signal instanceof AbortSignal);
|
|
59
|
+
});
|
|
60
|
+
test('a url outlet fills in the DSH origin, takes only the kinds it lists, and a push carries her name and the expression', async () => {
|
|
61
|
+
const { calls, fetchImpl } = fakeFetch();
|
|
62
|
+
const outlet = createOutlet({ name: '气泡', url: '{origin}/pet/broadcast?pet=main', kinds: ['reach'] }, () => 'http://127.0.0.1:5173', fetchImpl);
|
|
63
|
+
assert.deepEqual(outlet.kinds, ['reach']);
|
|
64
|
+
await outlet.send(pushOf('**想你了** ', 'reach', '小鱼', 'http://127.0.0.1:5173', '可爱'));
|
|
65
|
+
assert.deepEqual(calls.map(call => [call.url, call.body]), [['http://127.0.0.1:5173/pet/broadcast?pet=main', { text: '想你了', kind: 'reach', name: '小鱼', images: ['http://127.0.0.1:5173/m/a.png'], image: '可爱' }]]);
|
|
66
|
+
assert.throws(() => outletUrl({ name: '空的' }, () => 'http://dsh'), /推送目标「空的」没有 url 也没有 urlFile/);
|
|
67
|
+
});
|
|
68
|
+
test('a push fails when the app is not running, refuses, or cannot be reached', async t => {
|
|
69
|
+
const dir = await tempDir(t); const file = join(dir, 'running.json');
|
|
70
|
+
let reply = () => Promise.resolve(Response.json({ ok: true }));
|
|
71
|
+
const { fetchImpl, calls } = fakeFetch(() => reply());
|
|
72
|
+
const outlet = createOutlet({ name: 'app', urlFile: file }, () => 'http://dsh', fetchImpl);
|
|
73
|
+
const push = () => outlet.send({ text: 'hi', kind: 'reach', name: 'TA' });
|
|
74
|
+
await assert.rejects(push(), /running\.json 读不到/);
|
|
75
|
+
assert.equal(calls.length, 0);
|
|
76
|
+
await writeFile(file, JSON.stringify({ baseUrl: 'http://127.0.0.1:7001' }));
|
|
77
|
+
reply = () => Promise.resolve(new Response('nope', { status: 500 }));
|
|
78
|
+
await assert.rejects(push(), { message: 'HTTP 500' });
|
|
79
|
+
reply = () => Promise.resolve(Response.json({ ok: false, message: 'busy' }));
|
|
80
|
+
await assert.rejects(push(), { message: 'busy' });
|
|
81
|
+
reply = () => Promise.reject(new Error('connect ECONNREFUSED'));
|
|
82
|
+
await assert.rejects(push(), { message: 'connect ECONNREFUSED' });
|
|
83
|
+
reply = () => Promise.resolve(new Response('', { status: 200 }));
|
|
84
|
+
await push();
|
|
85
|
+
});
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { test } from 'node:test';
|
|
2
|
+
import assert from 'node:assert/strict';
|
|
3
|
+
import { chmodSync, existsSync, mkdirSync, mkdtempSync, readFileSync, statSync, writeFileSync } from 'node:fs';
|
|
4
|
+
import { tmpdir } from 'node:os';
|
|
5
|
+
import { join } from 'node:path';
|
|
6
|
+
import { bridgeConsoleUrl, createConsoleDoors, createPanelSecrets, findSnowlumaConsole, loginSnowluma, readSnowlumaHome, PANEL_FILE } from '../src/ecosystem/qq/panel.ts';
|
|
7
|
+
|
|
8
|
+
function tempHome(runtime?: unknown): string {
|
|
9
|
+
const home = mkdtempSync(join(tmpdir(), 'snowluma-home-'));
|
|
10
|
+
mkdirSync(join(home, 'config'), { recursive: true });
|
|
11
|
+
if (runtime !== undefined) writeFileSync(join(home, 'config', 'runtime.json'), JSON.stringify(runtime));
|
|
12
|
+
return home;
|
|
13
|
+
}
|
|
14
|
+
const reply = (status: number, body: unknown): typeof fetch =>
|
|
15
|
+
(async () => new Response(JSON.stringify(body), { status, headers: { 'content-type': 'application/json' } })) as unknown as typeof fetch;
|
|
16
|
+
|
|
17
|
+
test('SnowLuma 的控制台地址从它自己的 runtime.json 里读,不是写死的端口', () => {
|
|
18
|
+
const home = tempHome({ webuiPort: 5099, webuiHost: '127.0.0.1', webuiTls: { enabled: false } });
|
|
19
|
+
assert.deepEqual(findSnowlumaConsole(home)?.base, 'http://127.0.0.1:5099');
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
test('绑在所有网卡上的控制台仍然从本机按名字访问;没有配置就说没有', () => {
|
|
23
|
+
assert.equal(findSnowlumaConsole(tempHome({ webuiPort: 6100, webuiHost: '0.0.0.0' }))?.base, 'http://127.0.0.1:6100');
|
|
24
|
+
assert.equal(findSnowlumaConsole(tempHome())?.base, undefined);
|
|
25
|
+
assert.equal(findSnowlumaConsole(''), undefined);
|
|
26
|
+
const empty = mkdtempSync(join(tmpdir(), 'no-snowluma-'));
|
|
27
|
+
assert.equal(findSnowlumaConsole(empty), undefined);
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
test('面板密码记在她世界目录旁边,只有本机用户能读;空密码不算记过', () => {
|
|
31
|
+
const dir = mkdtempSync(join(tmpdir(), 'world-panel-'));
|
|
32
|
+
const secrets = createPanelSecrets(dir);
|
|
33
|
+
assert.equal(secrets.read(), undefined);
|
|
34
|
+
secrets.remember('', 'hunter2');
|
|
35
|
+
assert.deepEqual(secrets.read(), { username: 'admin', password: 'hunter2' });
|
|
36
|
+
const file = join(dir, PANEL_FILE);
|
|
37
|
+
assert.ok(existsSync(file));
|
|
38
|
+
if (process.platform !== 'win32') assert.equal(statSync(file).mode & 0o777, 0o600);
|
|
39
|
+
secrets.forget();
|
|
40
|
+
assert.equal(secrets.read(), undefined);
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
test('面板密码换来的会话令牌直接写进 URL,页面拿到就是登录态', async () => {
|
|
44
|
+
const day = await loginSnowluma('http://127.0.0.1:5099/', 'admin', 'hunter2', reply(200, { success: true, token: 'abc123' }));
|
|
45
|
+
assert.deepEqual(day, { url: 'http://127.0.0.1:5099/?token=abc123' });
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
test('密码错、被限流、连不上,三种都说得清', async () => {
|
|
49
|
+
assert.deepEqual(await loginSnowluma('http://x', 'admin', 'bad', reply(401, { success: false, message: '密码错误' })), { error: '密码错误' });
|
|
50
|
+
const limited = await loginSnowluma('http://x', 'admin', 'bad', reply(429, { success: false })) as { error: string };
|
|
51
|
+
assert.match(limited.error, /登录尝试太多/);
|
|
52
|
+
const dead = await loginSnowluma('http://x', 'admin', 'bad', (async () => { throw new Error('ECONNREFUSED'); }) as unknown as typeof fetch) as { error: string };
|
|
53
|
+
assert.match(dead.error, /连不上 SnowLuma 控制台/);
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
test('qq-bridge 的控制台令牌是文件,读得到就能开,读不到就说还没启动过', () => {
|
|
57
|
+
const bridge = mkdtempSync(join(tmpdir(), 'bridge-'));
|
|
58
|
+
assert.match((bridgeConsoleUrl(bridge, 3100) as { error: string }).error, /没有控制台令牌/);
|
|
59
|
+
mkdirSync(join(bridge, 'state'), { recursive: true });
|
|
60
|
+
writeFileSync(join(bridge, 'state', 'console-token'), 'tok-123\n');
|
|
61
|
+
assert.deepEqual(bridgeConsoleUrl(bridge, 3100), { url: 'http://127.0.0.1:3100/?token=tok-123' });
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
test('桥的配置里本来就写着 SnowLuma 在哪,不用再问一遍', () => {
|
|
65
|
+
const bridge = mkdtempSync(join(tmpdir(), 'bridge-cfg-'));
|
|
66
|
+
assert.equal(readSnowlumaHome(bridge), '');
|
|
67
|
+
writeFileSync(join(bridge, 'config.json'), JSON.stringify({ snowluma: { homeDir: 'D:\\SnowLuma' } }));
|
|
68
|
+
assert.equal(readSnowlumaHome(bridge), 'D:\\SnowLuma');
|
|
69
|
+
// 老位置的写法也认。
|
|
70
|
+
writeFileSync(join(bridge, 'config.json'), JSON.stringify({ dsh: { snowluma: { homeDir: 'E:\\SnowLuma' } } }));
|
|
71
|
+
assert.equal(readSnowlumaHome(bridge), 'E:\\SnowLuma');
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
test('两扇门:SnowLuma 没密码时先要密码,记住之后才开门;密码错了不留下', async () => {
|
|
75
|
+
const world = mkdtempSync(join(tmpdir(), 'world-doors-'));
|
|
76
|
+
const bridge = mkdtempSync(join(tmpdir(), 'bridge-doors-'));
|
|
77
|
+
mkdirSync(join(bridge, 'state'), { recursive: true });
|
|
78
|
+
writeFileSync(join(bridge, 'state', 'console-token'), 'tok-9');
|
|
79
|
+
const home = tempHome({ webuiPort: 5099, webuiHost: '127.0.0.1' });
|
|
80
|
+
const doors = createConsoleDoors({ worldDir: world, bridgeDir: bridge, port: 3100, snowlumaHome: home });
|
|
81
|
+
assert.deepEqual(doors.qq(), { url: 'http://127.0.0.1:3100/?token=tok-9' });
|
|
82
|
+
assert.equal((await doors.snowluma() as { needs?: string }).needs, 'password');
|
|
83
|
+
const secrets = createPanelSecrets(world);
|
|
84
|
+
assert.equal(secrets.read(), undefined);
|
|
85
|
+
});
|