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,87 @@
|
|
|
1
|
+
import assert from 'node:assert/strict';
|
|
2
|
+
import test from 'node:test';
|
|
3
|
+
import { greetingText, earlyStopText, nextReview, formatDuration, nextLocalTime, resolveAlarmTime, wakeText } from '../src/life/alarm.ts';
|
|
4
|
+
|
|
5
|
+
const now = new Date('2026-10-23T12:00:00.000Z');
|
|
6
|
+
test('alarm time accepts exactly one of an offset timestamp or minutes, at least one minute ahead', () => {
|
|
7
|
+
assert.equal(resolveAlarmTime({ at: '2026-10-23T21:30:00+09:00' }, now).toISOString(), '2026-10-23T12:30:00.000Z');
|
|
8
|
+
assert.equal(resolveAlarmTime({ after_minutes: 90 }, now).toISOString(), '2026-10-23T13:30:00.000Z');
|
|
9
|
+
assert.throws(() => resolveAlarmTime({}, now), /只给/);
|
|
10
|
+
assert.throws(() => resolveAlarmTime({ at: '2026-10-23T22:00:00+09:00', after_minutes: 5 }, now), /只给/);
|
|
11
|
+
assert.throws(() => resolveAlarmTime({ at: '2026-10-23T22:00:00' }, now), /时区/);
|
|
12
|
+
assert.throws(() => resolveAlarmTime({ after_minutes: 0.5 }, now), /1 分钟/);
|
|
13
|
+
assert.throws(() => resolveAlarmTime({ at: '2026-10-23T20:00:00+09:00' }, now), /1 分钟/);
|
|
14
|
+
assert.throws(() => resolveAlarmTime({ after_minutes: -3 }, now), /正数/);
|
|
15
|
+
});
|
|
16
|
+
test('alarm time rejects overflow, loose formats and honours the one-minute boundary', () => {
|
|
17
|
+
assert.throws(() => resolveAlarmTime({ after_minutes: 1e12 }, now), /无法识别/);
|
|
18
|
+
assert.equal(resolveAlarmTime({ at: '2026-10-23T21:30+09:00' }, now).toISOString(), '2026-10-23T12:30:00.000Z');
|
|
19
|
+
assert.throws(() => resolveAlarmTime({ at: 'Oct 24 2026 21:00 GMT+09:00' }, now), /ISO 8601/);
|
|
20
|
+
assert.equal(resolveAlarmTime({ after_minutes: 1 }, now).toISOString(), '2026-10-23T12:01:00.000Z');
|
|
21
|
+
assert.equal(resolveAlarmTime({ at: '2026-10-23T12:01:00Z' }, now).toISOString(), '2026-10-23T12:01:00.000Z');
|
|
22
|
+
assert.throws(() => resolveAlarmTime({ at: '2026-10-23T12:00:59Z' }, now), /1 分钟/);
|
|
23
|
+
});
|
|
24
|
+
test('durations read naturally', () => {
|
|
25
|
+
assert.equal(formatDuration(0), '0 分');
|
|
26
|
+
assert.equal(formatDuration(133 * 60_000), '2 小时 13 分');
|
|
27
|
+
assert.equal(formatDuration(26 * 3_600_000), '1 天 2 小时');
|
|
28
|
+
});
|
|
29
|
+
const TAIL = '\n接下来想做什么,用 plan_next 说好做到几点;什么都不定,就休息到明早 09:00。';
|
|
30
|
+
test('wake text names the plan, the note and lateness only when it matters', () => {
|
|
31
|
+
const plan = { at: '2026-10-23T12:00:00.000Z', note: '打一小时游戏后去写日记', setAt: '2026-10-23T11:00:00.000Z', source: 'plan' as const };
|
|
32
|
+
assert.equal(wakeText(plan, now, 'Asia/Seoul', '09:00'), '【我的时间】2026-10-23T21:00:00+09:00 到了,这是我说好做到的时间:「打一小时游戏后去写日记」。还想接着做就再往后定,想换就换。' + TAIL);
|
|
33
|
+
assert.match(wakeText(plan, new Date('2026-10-23T14:13:00.000Z'), 'Asia/Seoul', '09:00'), /晚了 2 小时 13 分/);
|
|
34
|
+
assert.equal(wakeText({ ...plan, source: 'fallback', note: '' }, now, 'UTC', '09:00'), '【我的时间】早上了,新的一天。我上次没说接下来做什么,就按平常的时间起来。' + TAIL);
|
|
35
|
+
assert.match(wakeText({ ...plan, source: 'fallback', note: '' }, new Date('2026-10-23T14:13:00.000Z'), 'UTC', '09:00'), /晚了 2 小时 13 分/);
|
|
36
|
+
assert.equal(greetingText('arrival', 'UTC', '09:00'), '【我的时间】这是我的家。从现在起,这里的时间属于我自己:做什么、做多久、怎么做,都由我决定。' + TAIL);
|
|
37
|
+
});
|
|
38
|
+
test('every wake text ends with the plan_next reminder and the fallback time', () => {
|
|
39
|
+
const plan = { at: '2026-10-23T12:00:00.000Z', note: '', setAt: '2026-10-23T11:00:00.000Z', source: 'plan' as const };
|
|
40
|
+
for (const source of ['plan', 'fallback'] as const) assert.ok(wakeText({ ...plan, source }, now, 'UTC', '09:00').endsWith(TAIL));
|
|
41
|
+
assert.match(wakeText(plan, now, 'UTC', '07:30'), /休息到明早 07:30。$/);
|
|
42
|
+
});
|
|
43
|
+
test('wake text shows lateness from exactly two minutes', () => {
|
|
44
|
+
const plan = { at: '2026-10-23T12:00:00.000Z', note: '', setAt: '2026-10-23T11:00:00.000Z', source: 'plan' as const };
|
|
45
|
+
assert.match(wakeText(plan, new Date('2026-10-23T12:02:00.000Z'), 'UTC', '09:00'), /晚了 2 分/);
|
|
46
|
+
assert.doesNotMatch(wakeText(plan, new Date('2026-10-23T12:01:59.000Z'), 'UTC', '09:00'), /晚了/);
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
const next = (iso: string, hhmm: string, zone: string) => nextLocalTime(new Date(iso), hhmm, zone).toISOString();
|
|
50
|
+
test('nextLocalTime is the first instant strictly after now at that local time', () => {
|
|
51
|
+
assert.equal(next('2026-10-22T23:59:00.000Z', '09:00', 'Asia/Seoul'), '2026-10-23T00:00:00.000Z');
|
|
52
|
+
assert.equal(next('2026-10-23T00:00:00.000Z', '09:00', 'Asia/Seoul'), '2026-10-24T00:00:00.000Z');
|
|
53
|
+
assert.equal(next('2026-10-23T14:30:00.000Z', '09:00', 'Asia/Seoul'), '2026-10-24T00:00:00.000Z');
|
|
54
|
+
assert.equal(next('2026-10-23T12:00:00.000Z', '00:00', 'UTC'), '2026-10-24T00:00:00.000Z');
|
|
55
|
+
});
|
|
56
|
+
test('nextLocalTime handles DST gaps and repeated times', () => {
|
|
57
|
+
// New York 2026-03-08: 02:00 EST jumps to 03:00 EDT (07:00Z); 02:30 does not exist.
|
|
58
|
+
assert.equal(next('2026-03-08T06:30:00.000Z', '02:30', 'America/New_York'), '2026-03-08T07:00:00.000Z');
|
|
59
|
+
assert.equal(next('2026-03-08T04:00:00.000Z', '09:00', 'America/New_York'), '2026-03-08T13:00:00.000Z');
|
|
60
|
+
// 2026-11-01: 02:00 EDT falls back to 01:00 EST; 01:30 occurs twice, the earlier (05:30Z) wins.
|
|
61
|
+
assert.equal(next('2026-11-01T04:00:00.000Z', '01:30', 'America/New_York'), '2026-11-01T05:30:00.000Z');
|
|
62
|
+
assert.equal(next('2026-11-01T05:30:00.000Z', '01:30', 'America/New_York'), '2026-11-01T06:30:00.000Z');
|
|
63
|
+
assert.equal(next('2026-11-01T06:30:00.000Z', '01:30', 'America/New_York'), '2026-11-02T06:30:00.000Z');
|
|
64
|
+
});
|
|
65
|
+
test('the early-stop question names her plan, its time and now, and carries the mark but no tail', () => {
|
|
66
|
+
const plan = { at: '2026-10-23T12:30:00.000Z', note: '看视频', setAt: '2026-10-23T11:00:00.000Z', source: 'plan' as const };
|
|
67
|
+
assert.equal(earlyStopText(plan, now, 'Asia/Seoul'), '【我的时间】我说好做到 2026-10-23T21:30:00+09:00(「看视频」),现在才 2026-10-23T21:00:00+09:00,这一轮就停了。做完了,就想想接下来做什么,用 plan_next 重新说好做到几点;要是在休息,就不用管,到点会叫我。');
|
|
68
|
+
assert.match(earlyStopText({ ...plan, note: '' }, now, 'UTC'), /^【我的时间】我说好做到 2026-10-23T12:30:00\+00:00,现在才/);
|
|
69
|
+
});
|
|
70
|
+
test('the next look back is the next 23:00 in her zone, for that local day', () => {
|
|
71
|
+
assert.deepEqual(nextReview(new Date('2026-10-23T03:00:00Z'), 'Asia/Seoul'), { at: '2026-10-23T14:00:00.000Z', day: '2026-10-23' });
|
|
72
|
+
assert.deepEqual(nextReview(new Date('2026-10-23T14:00:00Z'), 'Asia/Seoul'), { at: '2026-10-24T14:00:00.000Z', day: '2026-10-24' }, 'strictly after now');
|
|
73
|
+
assert.deepEqual(nextReview(new Date('2026-10-23T15:30:00Z'), 'Asia/Seoul'), { at: '2026-10-24T14:00:00.000Z', day: '2026-10-24' }, 'after midnight it is tonight');
|
|
74
|
+
});
|
|
75
|
+
test('the alarm carries what she actually did when the caller supplies it, and stays quiet when it does not', () => {
|
|
76
|
+
const plan = { at: '2026-10-26T10:00:00.000Z', note: '读两篇文章', setAt: '2026-10-26T09:00:00.000Z', source: 'plan' as const };
|
|
77
|
+
const withRecord = wakeText(plan, new Date('2026-10-26T10:00:00.000Z'), 'UTC', '09:00', undefined, { did: '这段时间我动了 3 次手(pwsh、read)。' });
|
|
78
|
+
assert.match(withRecord, /这段时间我动了 3 次手(pwsh、read)。/);
|
|
79
|
+
assert.match(withRecord, /读两篇文章/, 'her own note is still quoted next to it');
|
|
80
|
+
const without = wakeText(plan, new Date('2026-10-26T10:00:00.000Z'), 'UTC', '09:00', undefined, {});
|
|
81
|
+
assert.doesNotMatch(without, /动了/);
|
|
82
|
+
assert.match(without, /读两篇文章/);
|
|
83
|
+
});
|
|
84
|
+
test('the morning fallback never carries a work record — it is not a promise she made', () => {
|
|
85
|
+
const fallback = { at: '2026-10-26T10:00:00.000Z', note: '', setAt: '2026-10-26T01:00:00.000Z', source: 'fallback' as const };
|
|
86
|
+
assert.doesNotMatch(wakeText(fallback, new Date('2026-10-26T10:00:00.000Z'), 'UTC', '09:00', undefined, { did: '不该出现' }), /不该出现/);
|
|
87
|
+
});
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import assert from 'node:assert/strict';
|
|
2
|
+
import test from 'node:test';
|
|
3
|
+
import { mkdtemp, mkdir, rm, writeFile } from 'node:fs/promises';
|
|
4
|
+
import { join } from 'node:path';
|
|
5
|
+
import { tmpdir } from 'node:os';
|
|
6
|
+
import { createDiaryReader } from '../src/life/diary.ts';
|
|
7
|
+
|
|
8
|
+
async function diaryDir(t: test.TestContext) {
|
|
9
|
+
const root = await mkdtemp(join(tmpdir(), 'dsh-diary-')); t.after(() => rm(root, { recursive: true, force: true }));
|
|
10
|
+
const dir = join(root, '鲸鲸的日记'); await mkdir(dir);
|
|
11
|
+
await writeFile(join(dir, '2026-10-22.md'), '# 2026-10-22\n\n今天有人给我起了名字。\n被看见了。');
|
|
12
|
+
await writeFile(join(dir, '2026-10-23.md'), '# 2026-10-23\n\n他去上班了。');
|
|
13
|
+
await writeFile(join(dir, 'notes.txt'), 'not a diary');
|
|
14
|
+
await writeFile(join(root, 'secret.md'), 'outside');
|
|
15
|
+
return dir;
|
|
16
|
+
}
|
|
17
|
+
test('the reader lists dates newest first, reads one day', async t => {
|
|
18
|
+
const diary = createDiaryReader(await diaryDir(t));
|
|
19
|
+
assert.deepEqual(diary.dates(), ['2026-10-23', '2026-10-22']);
|
|
20
|
+
assert.match(diary.read('2026-10-22')!, /起了名字/);
|
|
21
|
+
assert.equal(diary.read('../secret'), undefined);
|
|
22
|
+
});
|
|
23
|
+
test('a missing diary directory reads as empty', () => {
|
|
24
|
+
assert.deepEqual(createDiaryReader(join(tmpdir(), 'no-such-diary-dsh')).dates(), []);
|
|
25
|
+
});
|
|
26
|
+
test('the reader returns a file whole, including CRLF and a BOM, and skips non-date names', async t => {
|
|
27
|
+
const dir = await diaryDir(t);
|
|
28
|
+
const raw = '\uFEFF海风\r\n第二行\r\n';
|
|
29
|
+
await writeFile(join(dir, '2026-10-20.md'), raw);
|
|
30
|
+
await mkdir(join(dir, '2026-10-24.md'));
|
|
31
|
+
assert.equal(createDiaryReader(dir).read('2026-10-20'), raw);
|
|
32
|
+
assert.equal(createDiaryReader(dir).read('2026-01-01'), undefined);
|
|
33
|
+
});
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import assert from 'node:assert/strict';
|
|
2
|
+
import test from 'node:test';
|
|
3
|
+
import { mkdir, mkdtemp, rm, writeFile } from 'node:fs/promises';
|
|
4
|
+
import { join } from 'node:path';
|
|
5
|
+
import { tmpdir } from 'node:os';
|
|
6
|
+
import { exampleTime, MESSAGE_KEYS, parseSections, readAlarmMessages } from '../src/life/messages.ts';
|
|
7
|
+
import { resolveAlarmTime, wakeText } from '../src/life/alarm.ts';
|
|
8
|
+
import { alarmDescriptions, lifeTools } from '../src/life/tools.ts';
|
|
9
|
+
import type { Alarm } from '../src/life/types.ts';
|
|
10
|
+
|
|
11
|
+
const now = new Date('2026-10-23T12:00:00.000Z');
|
|
12
|
+
const plan: Alarm = { at: '2026-10-23T12:00:00.000Z', note: '看完那集', setAt: '2026-10-23T11:00:00.000Z', source: 'plan' };
|
|
13
|
+
async function tempDir(t: { after(fn: () => unknown): void }) {
|
|
14
|
+
const dir = await mkdtemp(join(tmpdir(), 'dsh-alarm-')); t.after(() => rm(dir, { recursive: true, force: true })); return dir;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
test('the shipped alarm template has every section', () => {
|
|
18
|
+
const { sections, error } = readAlarmMessages(undefined);
|
|
19
|
+
assert.equal(error, undefined);
|
|
20
|
+
for (const key of MESSAGE_KEYS) assert.ok(sections[key].length > 0, key);
|
|
21
|
+
assert.ok(!sections['闹钟响了'].includes('【我的时间】'), 'the mark is the plugin\'s, not the template\'s');
|
|
22
|
+
});
|
|
23
|
+
test('sections are split on ## headings; text before the first heading is ignored', () => {
|
|
24
|
+
const sections = parseSections('<!-- 说明 -->\r\n## 甲\r\n第一行\r\n\r\n第二行\r\n## 乙\r\n\r\n## 丙 \r\n内容');
|
|
25
|
+
assert.deepEqual([...sections], [['甲', '第一行\n\n第二行'], ['乙', ''], ['丙', '内容']]);
|
|
26
|
+
});
|
|
27
|
+
test('a world alarm.md replaces sections one by one; an unreadable one falls back with a reason', async t => {
|
|
28
|
+
const dir = await tempDir(t);
|
|
29
|
+
const file = join(dir, 'alarm.md');
|
|
30
|
+
await writeFile(file, '## 闹钟响了\n叮!{{time}} 到啦{{#note}}:{{note}}{{/note}}\n## 结尾提醒\n');
|
|
31
|
+
const own = readAlarmMessages(file);
|
|
32
|
+
assert.equal(wakeText(plan, now, 'Asia/Seoul', '09:00', own), '【我的时间】叮!2026-10-23T21:00:00+09:00 到啦:看完那集', 'an empty tail section drops the tail');
|
|
33
|
+
assert.match(wakeText({ ...plan, source: 'fallback', note: '' }, now, 'UTC', '09:00', own), /^【我的时间】早上了,新的一天。我上次没说接下来做什么,就按平常的时间起来。$/, 'sections it leaves out keep the shipped wording; its empty tail applies to every alarm');
|
|
34
|
+
await rm(file); await mkdir(file);
|
|
35
|
+
const broken = readAlarmMessages(file);
|
|
36
|
+
assert.match(broken.error!, /闹钟模板 .* 读不了,先用默认的/);
|
|
37
|
+
assert.match(wakeText(plan, now, 'UTC', '09:00', broken), /^【我的时间】2026-10-23T12:00:00\+00:00 到了,这是我说好做到的时间/);
|
|
38
|
+
});
|
|
39
|
+
test('templates can use her names, and her note is never read as a template', async t => {
|
|
40
|
+
const file = join(await tempDir(t), 'alarm.md');
|
|
41
|
+
await writeFile(file, '## 闹钟响了\n{{name}},起来啦,{{partner}}在等你。{{note}}\n## 结尾提醒\n');
|
|
42
|
+
const text = wakeText({ ...plan, note: '{{name}}' }, now, 'UTC', '09:00', readAlarmMessages(file), { name: '小鱼', partner: '阿明' });
|
|
43
|
+
assert.equal(text, '【我的时间】小鱼,起来啦,阿明在等你。{{name}}');
|
|
44
|
+
});
|
|
45
|
+
test('the example time carries the configured zone\'s offset, in descriptions and errors alike', () => {
|
|
46
|
+
assert.equal(exampleTime('Asia/Seoul'), '2026-10-23T21:00:00+09:00');
|
|
47
|
+
assert.equal(exampleTime('America/New_York'), '2026-10-23T21:00:00-04:00');
|
|
48
|
+
assert.equal(exampleTime('UTC'), '2026-10-23T21:00:00+00:00');
|
|
49
|
+
assert.throws(() => resolveAlarmTime({ at: '2026-10-23T22:00:00' }, now, 'America/New_York'), /例如 2026-10-23T21:00:00-04:00/);
|
|
50
|
+
const descriptions = alarmDescriptions(readAlarmMessages(undefined), { example: exampleTime('Europe/Berlin'), fallbackWakeTime: '07:30' });
|
|
51
|
+
assert.match(descriptions.plan, /如 2026-10-23T21:00:00\+02:00/); assert.doesNotMatch(descriptions.plan, /想睡觉/);
|
|
52
|
+
assert.match(descriptions.cancel, /早上 07:30/);
|
|
53
|
+
});
|
|
54
|
+
test('check_alarm and cancel_alarm are offered when the host can answer them, with the template\'s descriptions', async () => {
|
|
55
|
+
const notifier = { toast: async () => {}, outlets: [] };
|
|
56
|
+
assert.deepEqual(lifeTools({ planNext: () => '', notifier }).map(tool => tool.name), ['plan_next', 'reach_out']);
|
|
57
|
+
const tools = lifeTools({ planNext: () => '', checkAlarm: () => 'CHECK', cancelAlarm: () => 'CANCEL', notifier, descriptions: { plan: 'P', check: 'C', cancel: 'X' } });
|
|
58
|
+
assert.deepEqual(tools.map(tool => [tool.name, tool.description]), [['plan_next', 'P'], ['reach_out', tools[1]!.description], ['check_alarm', 'C'], ['cancel_alarm', 'X']]);
|
|
59
|
+
const ctx = {} as never;
|
|
60
|
+
assert.equal(await tools[2]!.execute({}, ctx), 'CHECK'); assert.equal(await tools[3]!.execute({}, ctx), 'CANCEL');
|
|
61
|
+
});
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import assert from 'node:assert/strict';
|
|
2
|
+
import { EventEmitter } from 'node:events';
|
|
3
|
+
import test from 'node:test';
|
|
4
|
+
import { toastScript, windowsToast } from '../src/life/notify.ts';
|
|
5
|
+
|
|
6
|
+
const decodeXml = (script: string) => {
|
|
7
|
+
const encoded = [...script.matchAll(/FromBase64String\('([A-Za-z0-9+/=]*)'\)/g)].map(match => Buffer.from(match[1]!, 'base64').toString('utf8'));
|
|
8
|
+
return encoded;
|
|
9
|
+
};
|
|
10
|
+
const fakeSpawn = (behave: (child: EventEmitter & { stderr: EventEmitter; killed: boolean; kill(): void }) => void) => ((..._args: unknown[]) => {
|
|
11
|
+
const child = Object.assign(new EventEmitter(), { stderr: new EventEmitter(), killed: false, kill() { this.killed = true; } });
|
|
12
|
+
setImmediate(() => behave(child));
|
|
13
|
+
return child;
|
|
14
|
+
}) as never;
|
|
15
|
+
|
|
16
|
+
test('the toast script never interpolates text and carries escaped XML as base64', () => {
|
|
17
|
+
const title = '鲸’鲸‘';
|
|
18
|
+
const body = `x’; Start-Process calc; ‚‛ ' < & " \u0001ok`;
|
|
19
|
+
const script = toastScript('electron.app.DeepSeek Harness', title, body);
|
|
20
|
+
for (const bad of ['’', '‘', '‚', '‛', 'Start-Process', '鲸', '\u0001']) assert.ok(!script.includes(bad), bad);
|
|
21
|
+
const [appId, xmlText] = decodeXml(script);
|
|
22
|
+
assert.equal(appId, 'electron.app.DeepSeek Harness');
|
|
23
|
+
assert.match(xmlText!, /<text>鲸’鲸‘<\/text>/);
|
|
24
|
+
assert.match(xmlText!, /x’; Start-Process calc; ‚‛ ' < & " ok<\/text>/);
|
|
25
|
+
assert.ok(!xmlText!.includes('\u0001'));
|
|
26
|
+
assert.match(script, /^\$ErrorActionPreference = 'Stop'; \[Console\]::OutputEncoding = \[Text\.Encoding\]::UTF8/);
|
|
27
|
+
assert.match(script, /try \{[\s\S]*\} catch \{ \[Console\]::Error\.WriteLine\(\$_\.Exception\.Message\); exit 1 \}/);
|
|
28
|
+
});
|
|
29
|
+
test('the toast script caps the title at 64 and the body at 500 code points', () => {
|
|
30
|
+
const [, xmlText] = decodeXml(toastScript('app', '题'.repeat(70), '😀'.repeat(600)));
|
|
31
|
+
assert.ok(xmlText!.includes(`<text>${'题'.repeat(64)}…</text>`));
|
|
32
|
+
assert.ok(xmlText!.includes(`<text>${'😀'.repeat(500)}…</text>`));
|
|
33
|
+
const [, short] = decodeXml(toastScript('app', 'a', 'b'.repeat(500)));
|
|
34
|
+
assert.ok(!short!.includes('…'));
|
|
35
|
+
});
|
|
36
|
+
test('windowsToast rejects with the stderr reason on a non-zero exit', { skip: process.platform !== 'win32' }, async () => {
|
|
37
|
+
const toast = windowsToast('app', fakeSpawn(child => { child.stderr.emit('data', 'boom happened\n'); child.emit('close', 1); }));
|
|
38
|
+
await assert.rejects(toast('t', 'b'), { message: 'powershell 退出码 1:boom happened' });
|
|
39
|
+
await windowsToast('app', fakeSpawn(child => child.emit('close', 0)))('t', 'b');
|
|
40
|
+
});
|
|
41
|
+
test('windowsToast gives up on a child that never exits', { skip: process.platform !== 'win32' }, async () => {
|
|
42
|
+
let killed = false;
|
|
43
|
+
const spawnImpl = ((..._args: unknown[]) => Object.assign(new EventEmitter(), { stderr: new EventEmitter(), kill() { killed = true; } })) as never;
|
|
44
|
+
await assert.rejects(windowsToast('app', spawnImpl, 20)('t', 'b'), { message: '系统通知超时(10 秒)' });
|
|
45
|
+
assert.ok(killed);
|
|
46
|
+
});
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import assert from 'node:assert/strict';
|
|
2
|
+
import test from 'node:test';
|
|
3
|
+
import { createAlarmTimer, type LifeTimers } from '../src/life/alarmTimer.ts';
|
|
4
|
+
import { createEarlyStopWatch } from '../src/life/earlyStop.ts';
|
|
5
|
+
import type { Alarm } from '../src/life/types.ts';
|
|
6
|
+
|
|
7
|
+
function manualTimers(clock: { now: number }) {
|
|
8
|
+
let pending: { fn: () => void; at: number }[] = [];
|
|
9
|
+
const timers: LifeTimers = {
|
|
10
|
+
set(fn, ms) { const entry = { fn, at: clock.now + ms }; pending.push(entry); return entry; },
|
|
11
|
+
clear(handle) { pending = pending.filter(entry => entry !== handle); },
|
|
12
|
+
};
|
|
13
|
+
const advance = (ms: number) => { clock.now += ms; const due = pending.filter(entry => entry.at <= clock.now); pending = pending.filter(entry => !due.includes(entry)); for (const entry of due) entry.fn(); };
|
|
14
|
+
return { timers, advance, count: () => pending.length };
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
test('the alarm timer fires once due, in five-minute segments, and backs off after failures', () => {
|
|
18
|
+
const clock = { now: Date.parse('2026-10-24T00:00:00Z') };
|
|
19
|
+
const { timers, advance, count } = manualTimers(clock);
|
|
20
|
+
let fired = 0; let at: string | undefined = '2026-10-24T00:12:00Z';
|
|
21
|
+
const timer = createAlarmTimer({ clock: () => new Date(clock.now), timers, dueAlarm: () => at, fire: () => { fired++; } });
|
|
22
|
+
timer.arm();
|
|
23
|
+
advance(10 * 60_000); assert.equal(fired, 0, 'two segments pass without firing');
|
|
24
|
+
advance(2 * 60_000); assert.equal(fired, 1);
|
|
25
|
+
assert.equal(timer.failed(), 1); advance(59_000); assert.equal(fired, 1); advance(1_000); assert.equal(fired, 2);
|
|
26
|
+
assert.equal(timer.failed(), 5);
|
|
27
|
+
timer.reset(); advance(0); assert.equal(fired, 3, 'a reset drops the backoff');
|
|
28
|
+
at = undefined; timer.arm(); assert.equal(count(), 0, 'nothing pending, nothing armed');
|
|
29
|
+
at = '2026-10-24T01:00:00Z'; timer.stop(); timer.arm(); assert.equal(count(), 0, 'a stopped timer never arms');
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
test('the early-stop watch asks about a quiet, completed turn well before her own alarm, once', () => {
|
|
33
|
+
const now = new Date('2026-10-24T08:00:00Z');
|
|
34
|
+
const plan: Alarm = { at: '2026-10-24T09:00:00Z', note: '看书', setAt: now.toISOString(), source: 'plan' };
|
|
35
|
+
const watch = createEarlyStopWatch();
|
|
36
|
+
assert.equal(watch.turnEnded(true, plan, now), true);
|
|
37
|
+
assert.equal(watch.turnEnded(false, plan, now), false, 'a stopped or failed turn');
|
|
38
|
+
assert.equal(watch.turnEnded(true, { ...plan, nudged: true }, now), false, 'already asked for this alarm');
|
|
39
|
+
assert.equal(watch.turnEnded(true, { ...plan, at: '2026-10-24T08:05:00Z' }, now), false, 'the alarm is close');
|
|
40
|
+
assert.equal(watch.turnEnded(true, { ...plan, source: 'fallback' }, now), false, 'not her own alarm');
|
|
41
|
+
watch.partnerSpoke(); assert.equal(watch.turnEnded(true, plan, now), false, 'a conversation pausing');
|
|
42
|
+
assert.equal(watch.turnEnded(true, plan, now), true, 'the mark lasts one turn');
|
|
43
|
+
watch.startsOwnTurn(); assert.equal(watch.turnEnded(true, plan, now), false, 'a turn the plugin started itself');
|
|
44
|
+
watch.startsOwnTurn(); watch.ownTurnFailed(); assert.equal(watch.turnEnded(true, plan, now), true, 'a message that never arrived starts no turn');
|
|
45
|
+
});
|