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,156 @@
|
|
|
1
|
+
import { SessionId } from '@deepseek-ai/dsh-session';
|
|
2
|
+
import { extractConversationRecords } from "./archive.js";
|
|
3
|
+
import { inQqScope, isQqCurrent } from "./qqScope.js";
|
|
4
|
+
import { wechatDeliveryPatch } from "./ecosystem/wechat/archive.js";
|
|
5
|
+
const pageSize = 128;
|
|
6
|
+
/**
|
|
7
|
+
* A session log the host itself cannot read (a compaction cut off mid-write, a half-flushed turn). It is not
|
|
8
|
+
* our bug and it never fixes itself, so retrying adds nothing — one broken conversation must not cost her the
|
|
9
|
+
* whole world: flushed and thrown, it fails the plugin's load and every session loses its memory block.
|
|
10
|
+
*/
|
|
11
|
+
export function isCorruptSessionLog(error) {
|
|
12
|
+
const text = error instanceof Error ? `${error.name} ${error.message}` : String(error ?? '');
|
|
13
|
+
return /stored log is corrupt|SessionFormatError|does not match an open turn/i.test(text);
|
|
14
|
+
}
|
|
15
|
+
export function belongsToWorld(session, config) {
|
|
16
|
+
const header = session.header;
|
|
17
|
+
if (header.origin === 'subagent' || (header.delegationDepth ?? 0) > 0)
|
|
18
|
+
return false;
|
|
19
|
+
if (config.scope === 'qq')
|
|
20
|
+
return isQqCurrent(header.id, config.qqSessionsFile);
|
|
21
|
+
return header.agentPreset === config.agentPreset;
|
|
22
|
+
}
|
|
23
|
+
const isNotFound = (error) => error instanceof Error && error.name === 'SessionPersistenceNotFoundError';
|
|
24
|
+
const ordinary = (header) => header.origin !== 'subagent' && (header.delegationDepth ?? 0) === 0;
|
|
25
|
+
/**
|
|
26
|
+
* Copies her conversations from the host's session logs into the archive. Each session is replayed from where
|
|
27
|
+
* the archive left off; replays run one at a time, and a session already queued is not queued twice. Sessions
|
|
28
|
+
* outside `archived` are left alone.
|
|
29
|
+
*/
|
|
30
|
+
export function createSourceArchive(ctx, config, store, archived = () => true) {
|
|
31
|
+
const dirty = new Set();
|
|
32
|
+
const jobs = new Map();
|
|
33
|
+
const failures = new Map();
|
|
34
|
+
let tail = Promise.resolve();
|
|
35
|
+
/** Copies what the archive has not seen yet; `skip` moves past it without keeping it. */
|
|
36
|
+
async function replay(sessionId, skip = false) {
|
|
37
|
+
const id = SessionId(sessionId);
|
|
38
|
+
const live = ctx.sessions.get(id);
|
|
39
|
+
if (live)
|
|
40
|
+
await ctx.sessions.flush(live);
|
|
41
|
+
// A deleted session keeps what it already archived; there is nothing left to replay.
|
|
42
|
+
const handle = await ctx.sessionPersistence.open(id, 'read').catch(error => {
|
|
43
|
+
if (isNotFound(error)) {
|
|
44
|
+
ctx.logger.warn(`dsh-world: session ${sessionId} is no longer stored; skipping replay`);
|
|
45
|
+
store.forgetProgress(sessionId);
|
|
46
|
+
return undefined;
|
|
47
|
+
}
|
|
48
|
+
throw error;
|
|
49
|
+
});
|
|
50
|
+
if (!handle)
|
|
51
|
+
return;
|
|
52
|
+
try {
|
|
53
|
+
let { nextSeq, turn } = store.progress(id);
|
|
54
|
+
while (true) {
|
|
55
|
+
const { events } = await handle.read(nextSeq, pageSize);
|
|
56
|
+
if (!events.length)
|
|
57
|
+
break;
|
|
58
|
+
const records = events.flatMap(event => {
|
|
59
|
+
if (event.type === 'turn/start')
|
|
60
|
+
turn = event.data.turn;
|
|
61
|
+
return skip ? [] : extractConversationRecords(event, { ...config, header: handle.header, inheritedEventCount: handle.inheritedEventCount, turn }).map(record => {
|
|
62
|
+
const delivery = record.wechatDelivery ? store.delivery(record.recordId) : undefined;
|
|
63
|
+
return delivery ? { ...record, ...wechatDeliveryPatch(record, delivery) } : record;
|
|
64
|
+
});
|
|
65
|
+
});
|
|
66
|
+
nextSeq = events.at(-1).seq + 1;
|
|
67
|
+
await store.commitRecords(records, { sessionId: id, nextSeq, turn });
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
finally {
|
|
71
|
+
await handle.close();
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
/** Runs after every queued replay. */
|
|
75
|
+
function enqueue(work) {
|
|
76
|
+
const job = tail.then(work);
|
|
77
|
+
tail = job.catch(error => { ctx.logger.error(error); });
|
|
78
|
+
return job;
|
|
79
|
+
}
|
|
80
|
+
function schedule(sessionId) {
|
|
81
|
+
// Not archived itself, it still waits for the replays already queued, so its memory block is current.
|
|
82
|
+
if (!archived(sessionId))
|
|
83
|
+
return tail;
|
|
84
|
+
dirty.add(sessionId);
|
|
85
|
+
const pending = jobs.get(sessionId);
|
|
86
|
+
if (pending)
|
|
87
|
+
return pending;
|
|
88
|
+
const job = tail.then(async () => {
|
|
89
|
+
while (dirty.delete(sessionId))
|
|
90
|
+
await replay(sessionId);
|
|
91
|
+
failures.delete(sessionId);
|
|
92
|
+
});
|
|
93
|
+
jobs.set(sessionId, job);
|
|
94
|
+
tail = job.catch(error => {
|
|
95
|
+
// Skips and a warning instead of a stored failure — see `isCorruptSessionLog`.
|
|
96
|
+
if (isCorruptSessionLog(error)) {
|
|
97
|
+
dirty.delete(sessionId);
|
|
98
|
+
ctx.logger.warn(`dsh-world: 会话 ${sessionId} 的日志读不动,先跳过(这段对话不归档)`);
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
failures.set(sessionId, error);
|
|
102
|
+
ctx.logger.error(error);
|
|
103
|
+
}).finally(() => { jobs.delete(sessionId); });
|
|
104
|
+
return job;
|
|
105
|
+
}
|
|
106
|
+
return {
|
|
107
|
+
schedule,
|
|
108
|
+
/**
|
|
109
|
+
* Every session the archive has seen, replayed again so nothing written while the plugin was not loaded is
|
|
110
|
+
* missed; with `skip`, what was said while her world was stopped is passed over instead.
|
|
111
|
+
*/
|
|
112
|
+
async catchUp(skip = false) {
|
|
113
|
+
// One session's failure is kept for flush(); it must not stop the sessions after it.
|
|
114
|
+
const replayOne = (id) => (skip ? enqueue(() => replay(id, true)) : schedule(id)).catch(() => { });
|
|
115
|
+
// The host exposes a metadata inventory; every selected message log is still read in pages.
|
|
116
|
+
const snapshots = await ctx.sessionPersistence.list();
|
|
117
|
+
const visited = new Set();
|
|
118
|
+
for (let offset = 0; offset < snapshots.length; offset += pageSize) {
|
|
119
|
+
for (const { header } of snapshots.slice(offset, offset + pageSize)) {
|
|
120
|
+
if (!ordinary(header) || (!config.archiveScope && header.agentPreset !== config.agentPreset) || !archived(header.id))
|
|
121
|
+
continue;
|
|
122
|
+
visited.add(header.id);
|
|
123
|
+
await replayOne(header.id);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
let after = '';
|
|
127
|
+
for (let ids = store.sourcePage(after); ids.length; ids = store.sourcePage(after)) {
|
|
128
|
+
for (const id of ids) {
|
|
129
|
+
after = id;
|
|
130
|
+
if (visited.has(id))
|
|
131
|
+
continue;
|
|
132
|
+
// A session deleted from the host (not merely archived there) keeps its records but has nothing left to resume.
|
|
133
|
+
if (!await ctx.sessionPersistence.stat(SessionId(id))) {
|
|
134
|
+
store.forgetProgress(id);
|
|
135
|
+
continue;
|
|
136
|
+
}
|
|
137
|
+
if (!archived(id))
|
|
138
|
+
continue;
|
|
139
|
+
await replayOne(id);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
},
|
|
143
|
+
/** Moves past everything a session holds now without keeping it (said while her world was stopped). */
|
|
144
|
+
skip: (sessionId) => enqueue(() => replay(sessionId, true)),
|
|
145
|
+
/** Waits for every queued replay; rejects while any session still has an unresolved failure. */
|
|
146
|
+
async flush() {
|
|
147
|
+
let current;
|
|
148
|
+
do {
|
|
149
|
+
current = tail;
|
|
150
|
+
await current;
|
|
151
|
+
} while (current !== tail);
|
|
152
|
+
if (failures.size)
|
|
153
|
+
throw new AggregateError([...failures.values()], 'dsh-world: source archive has unresolved failures');
|
|
154
|
+
},
|
|
155
|
+
};
|
|
156
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { ConversationRecord, DeliveryState, PageQuery, RecordPage, WorldConfig } from './types.ts';
|
|
2
|
+
import type { SpeakerIdentity } from './ecosystem/shared/identity.ts';
|
|
3
|
+
export interface ExportProgress {
|
|
4
|
+
sessionId: string;
|
|
5
|
+
nextSeq: number;
|
|
6
|
+
turn: number;
|
|
7
|
+
}
|
|
8
|
+
export declare function createArchiveStore(config: WorldConfig & {
|
|
9
|
+
root: string;
|
|
10
|
+
}): {
|
|
11
|
+
commitRecords: (records: readonly ConversationRecord[], progress?: ExportProgress) => Promise<void>;
|
|
12
|
+
hasRecord: (recordId: string) => boolean;
|
|
13
|
+
updateRecord: (recordId: string, revise: (record: ConversationRecord) => Pick<ConversationRecord, "content" | "wechatDelivery"> & Partial<SpeakerIdentity>) => Promise<void>;
|
|
14
|
+
readPage: (query: PageQuery) => Promise<RecordPage>;
|
|
15
|
+
readTurn: (_worldId: string, turnId: string, afterSeq?: number, limit?: number) => Promise<ConversationRecord[]>;
|
|
16
|
+
progress: (sessionId: string) => ExportProgress;
|
|
17
|
+
forgetProgress: (sessionId: string) => void;
|
|
18
|
+
sourcePage: (afterId?: string, limit?: number) => string[];
|
|
19
|
+
stats: () => {
|
|
20
|
+
records: number;
|
|
21
|
+
sessions: number;
|
|
22
|
+
};
|
|
23
|
+
close: () => void;
|
|
24
|
+
channelSession: (key: string) => string | undefined;
|
|
25
|
+
bindChannelSession: (key: string, sessionId: string) => void;
|
|
26
|
+
delivery: (recordId: string) => DeliveryState | undefined;
|
|
27
|
+
registerDelivery: (recordId: string, total: number) => void;
|
|
28
|
+
updateDelivery: (recordId: string, revise: (previous: DeliveryState) => DeliveryState) => void;
|
|
29
|
+
};
|
|
30
|
+
export type ArchiveStore = ReturnType<typeof createArchiveStore>;
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
import { DatabaseSync } from 'node:sqlite';
|
|
2
|
+
import { closeSync, existsSync, fstatSync, fsyncSync, ftruncateSync, mkdirSync, openSync, writeSync } from 'node:fs';
|
|
3
|
+
import { join } from 'node:path';
|
|
4
|
+
import { formatLocalTime } from "./timeContext.js";
|
|
5
|
+
const pageSize = 128;
|
|
6
|
+
export function createArchiveStore(config) {
|
|
7
|
+
// The world id becomes a directory name.
|
|
8
|
+
if (!/^[a-zA-Z0-9][a-zA-Z0-9_-]{0,63}$/.test(config.worldId))
|
|
9
|
+
throw new TypeError('dsh-world: invalid worldId');
|
|
10
|
+
const worldRoot = join(config.root, 'worlds', config.worldId);
|
|
11
|
+
const directory = join(worldRoot, 'conversations');
|
|
12
|
+
mkdirSync(directory, { recursive: true, mode: 0o700 });
|
|
13
|
+
const db = new DatabaseSync(join(worldRoot, 'archive.sqlite'));
|
|
14
|
+
let closed = false;
|
|
15
|
+
db.exec(`PRAGMA busy_timeout=10000; PRAGMA journal_mode=WAL; PRAGMA synchronous=FULL;
|
|
16
|
+
CREATE TABLE IF NOT EXISTS records (
|
|
17
|
+
sequence INTEGER PRIMARY KEY AUTOINCREMENT, recordId TEXT NOT NULL UNIQUE,
|
|
18
|
+
day TEXT NOT NULL, occurredAt TEXT NOT NULL, turnId TEXT NOT NULL, sourceSeq INTEGER NOT NULL,
|
|
19
|
+
body TEXT NOT NULL, fileOffset INTEGER, fileBytes INTEGER
|
|
20
|
+
);
|
|
21
|
+
CREATE INDEX IF NOT EXISTS recordOrder ON records(day DESC, occurredAt DESC, recordId DESC);
|
|
22
|
+
CREATE INDEX IF NOT EXISTS turnOrder ON records(turnId, sourceSeq);
|
|
23
|
+
CREATE INDEX IF NOT EXISTS pendingExports ON records(day, sequence) WHERE fileOffset IS NULL;
|
|
24
|
+
CREATE TABLE IF NOT EXISTS days (day TEXT PRIMARY KEY, exportedBytes INTEGER NOT NULL DEFAULT 0);
|
|
25
|
+
CREATE TABLE IF NOT EXISTS progress (sessionId TEXT PRIMARY KEY, nextSeq INTEGER NOT NULL, turn INTEGER NOT NULL);
|
|
26
|
+
CREATE TABLE IF NOT EXISTS channelSessions (conversationKey TEXT PRIMARY KEY, sessionId TEXT NOT NULL);
|
|
27
|
+
CREATE TABLE IF NOT EXISTS channelDeliveries (recordId TEXT PRIMARY KEY, body TEXT NOT NULL);`);
|
|
28
|
+
function transaction(work) {
|
|
29
|
+
db.exec('BEGIN IMMEDIATE');
|
|
30
|
+
try {
|
|
31
|
+
const result = work();
|
|
32
|
+
db.exec('COMMIT');
|
|
33
|
+
return result;
|
|
34
|
+
}
|
|
35
|
+
catch (error) {
|
|
36
|
+
db.exec('ROLLBACK');
|
|
37
|
+
throw error;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
const decode = (row) => JSON.parse(row.body);
|
|
41
|
+
const dayOf = (record) => formatLocalTime(new Date(record.occurredAt), config.timeZone).slice(0, 10);
|
|
42
|
+
/**
|
|
43
|
+
* Appends a day's unexported records to its JSONL file. The database is the canonical copy: anything past the
|
|
44
|
+
* recorded size (a write cut short by a crash) is cut off and written again, and a file that was deleted or
|
|
45
|
+
* shortened is exported again from the start.
|
|
46
|
+
*/
|
|
47
|
+
function flushDay(day) {
|
|
48
|
+
transaction(() => {
|
|
49
|
+
const file = join(directory, `${day}.jsonl`);
|
|
50
|
+
const fd = openSync(file, existsSync(file) ? 'r+' : 'wx+', 0o600);
|
|
51
|
+
try {
|
|
52
|
+
let offset = Number(db.prepare('SELECT exportedBytes FROM days WHERE day=?').get(day)?.exportedBytes ?? 0);
|
|
53
|
+
if (fstatSync(fd).size < offset) {
|
|
54
|
+
db.prepare('UPDATE records SET fileOffset=NULL, fileBytes=NULL WHERE day=?').run(day);
|
|
55
|
+
offset = 0;
|
|
56
|
+
}
|
|
57
|
+
ftruncateSync(fd, offset);
|
|
58
|
+
let sequence = 0;
|
|
59
|
+
while (true) {
|
|
60
|
+
const pending = db.prepare('SELECT sequence, body FROM records WHERE day=? AND fileOffset IS NULL AND sequence>? ORDER BY sequence LIMIT ?').all(day, sequence, pageSize);
|
|
61
|
+
if (!pending.length)
|
|
62
|
+
break;
|
|
63
|
+
for (const row of pending) {
|
|
64
|
+
const bytes = Buffer.from(row.body + '\n');
|
|
65
|
+
let written = 0;
|
|
66
|
+
while (written < bytes.length)
|
|
67
|
+
written += writeSync(fd, bytes, written, bytes.length - written, offset + written);
|
|
68
|
+
db.prepare('UPDATE records SET fileOffset=?, fileBytes=? WHERE sequence=?').run(offset, bytes.length, row.sequence);
|
|
69
|
+
offset += bytes.length;
|
|
70
|
+
sequence = row.sequence;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
fsyncSync(fd);
|
|
74
|
+
db.prepare('UPDATE days SET exportedBytes=? WHERE day=?').run(offset, day);
|
|
75
|
+
}
|
|
76
|
+
finally {
|
|
77
|
+
closeSync(fd);
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
function flushExports() {
|
|
82
|
+
let after = '';
|
|
83
|
+
while (true) {
|
|
84
|
+
const rows = db.prepare('SELECT DISTINCT day FROM records WHERE fileOffset IS NULL AND day>? ORDER BY day LIMIT ?').all(after, pageSize);
|
|
85
|
+
if (!rows.length)
|
|
86
|
+
break;
|
|
87
|
+
for (const row of rows) {
|
|
88
|
+
after = String(row.day);
|
|
89
|
+
flushDay(after);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
async function commitRecords(records, progress) {
|
|
94
|
+
try {
|
|
95
|
+
transaction(() => {
|
|
96
|
+
for (const record of records) {
|
|
97
|
+
const day = dayOf(record);
|
|
98
|
+
db.prepare('INSERT OR IGNORE INTO records(recordId, day, occurredAt, turnId, sourceSeq, body) VALUES (?,?,?,?,?,?)').run(record.recordId, day, record.occurredAt, record.turnId, record.sourceSeq, JSON.stringify(record));
|
|
99
|
+
db.prepare('INSERT OR IGNORE INTO days(day) VALUES (?)').run(day);
|
|
100
|
+
}
|
|
101
|
+
if (progress)
|
|
102
|
+
db.prepare('INSERT INTO progress VALUES (?,?,?) ON CONFLICT(sessionId) DO UPDATE SET nextSeq=excluded.nextSeq, turn=excluded.turn WHERE excluded.nextSeq>=progress.nextSeq').run(progress.sessionId, progress.nextSeq, progress.turn);
|
|
103
|
+
});
|
|
104
|
+
// Records and progress commit together; the JSONL export is retried on the next write or read.
|
|
105
|
+
flushExports();
|
|
106
|
+
}
|
|
107
|
+
catch (error) {
|
|
108
|
+
throw new Error(`dsh-world: archive write failed: ${error instanceof Error ? error.message : String(error)}`, { cause: error });
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
async function readPage(query) {
|
|
112
|
+
flushExports();
|
|
113
|
+
const before = query.before;
|
|
114
|
+
const maxSequence = before?.maxSequence ?? Number(db.prepare('SELECT COALESCE(MAX(sequence),0) AS n FROM records').get()?.n);
|
|
115
|
+
const rows = (before
|
|
116
|
+
? db.prepare('SELECT * FROM records WHERE sequence<=? AND (day, occurredAt, recordId)<(?,?,?) ORDER BY day DESC, occurredAt DESC, recordId DESC LIMIT ?').all(maxSequence, before.date, before.occurredAt, before.recordId, query.limit + 1)
|
|
117
|
+
: db.prepare('SELECT * FROM records WHERE sequence<=? ORDER BY day DESC, occurredAt DESC, recordId DESC LIMIT ?').all(maxSequence, query.limit + 1));
|
|
118
|
+
const page = rows.slice(0, query.limit);
|
|
119
|
+
const records = page.map(decode);
|
|
120
|
+
const last = page.at(-1);
|
|
121
|
+
const lastRecord = records.at(-1);
|
|
122
|
+
const nextCursor = rows.length > query.limit && last && lastRecord ? { date: last.day, occurredAt: lastRecord.occurredAt, recordId: lastRecord.recordId, maxSequence } : undefined;
|
|
123
|
+
return { records, ...(nextCursor ? { nextCursor } : {}) };
|
|
124
|
+
}
|
|
125
|
+
async function updateRecord(recordId, revise) {
|
|
126
|
+
transaction(() => {
|
|
127
|
+
const row = db.prepare('SELECT day, body FROM records WHERE recordId=? LIMIT 1').get(recordId);
|
|
128
|
+
if (!row)
|
|
129
|
+
throw new Error('Archive record not found');
|
|
130
|
+
const record = decode(row);
|
|
131
|
+
const updated = { ...record, ...revise(record) };
|
|
132
|
+
const body = JSON.stringify(updated);
|
|
133
|
+
if (updated.wechatDelivery)
|
|
134
|
+
db.prepare('UPDATE channelDeliveries SET body=? WHERE recordId=?').run(JSON.stringify(updated.wechatDelivery), recordId);
|
|
135
|
+
if (body === row.body)
|
|
136
|
+
return;
|
|
137
|
+
db.prepare('UPDATE records SET body=? WHERE recordId=?').run(body, recordId);
|
|
138
|
+
// A changed line invalidates later byte offsets; rebuild this day from the canonical database.
|
|
139
|
+
db.prepare('UPDATE records SET fileOffset=NULL, fileBytes=NULL WHERE day=?').run(row.day);
|
|
140
|
+
db.prepare('UPDATE days SET exportedBytes=0 WHERE day=?').run(row.day);
|
|
141
|
+
});
|
|
142
|
+
flushExports();
|
|
143
|
+
}
|
|
144
|
+
async function readTurn(_worldId, turnId, afterSeq = -1, limit = pageSize) {
|
|
145
|
+
flushExports();
|
|
146
|
+
return db.prepare('SELECT * FROM records WHERE turnId=? AND sourceSeq>? ORDER BY sourceSeq LIMIT ?').all(turnId, afterSeq, limit).map(decode);
|
|
147
|
+
}
|
|
148
|
+
function progress(sessionId) {
|
|
149
|
+
const row = db.prepare('SELECT nextSeq, turn FROM progress WHERE sessionId=?').get(sessionId);
|
|
150
|
+
return { sessionId, nextSeq: Number(row?.nextSeq ?? 0), turn: Number(row?.turn ?? 0) };
|
|
151
|
+
}
|
|
152
|
+
/** The host no longer has this session; only the place to resume from goes, never what it archived. */
|
|
153
|
+
function forgetProgress(sessionId) {
|
|
154
|
+
db.prepare('DELETE FROM progress WHERE sessionId=?').run(sessionId);
|
|
155
|
+
}
|
|
156
|
+
function sourcePage(afterId = '', limit = pageSize) {
|
|
157
|
+
return db.prepare('SELECT sessionId FROM progress WHERE sessionId>? ORDER BY sessionId LIMIT ?').all(afterId, limit).map(row => String(row.sessionId));
|
|
158
|
+
}
|
|
159
|
+
function stats() {
|
|
160
|
+
const row = db.prepare("SELECT count(*) AS records, count(DISTINCT json_extract(body, '$.sourceSessionId')) AS sessions FROM records").get();
|
|
161
|
+
return { records: Number(row?.records ?? 0), sessions: Number(row?.sessions ?? 0) };
|
|
162
|
+
}
|
|
163
|
+
function close() { if (!closed) {
|
|
164
|
+
closed = true;
|
|
165
|
+
db.close();
|
|
166
|
+
} }
|
|
167
|
+
function hasRecord(recordId) { return !!db.prepare('SELECT 1 FROM records WHERE recordId=? LIMIT 1').get(recordId); }
|
|
168
|
+
function channelSession(key) {
|
|
169
|
+
return db.prepare('SELECT sessionId FROM channelSessions WHERE conversationKey=? LIMIT 1').get(key)?.sessionId;
|
|
170
|
+
}
|
|
171
|
+
function bindChannelSession(key, sessionId) {
|
|
172
|
+
transaction(() => { db.prepare('INSERT INTO channelSessions VALUES (?,?) ON CONFLICT(conversationKey) DO UPDATE SET sessionId=excluded.sessionId').run(key, sessionId); });
|
|
173
|
+
}
|
|
174
|
+
function delivery(recordId) {
|
|
175
|
+
const row = db.prepare('SELECT body FROM channelDeliveries WHERE recordId=? LIMIT 1').get(recordId);
|
|
176
|
+
return row ? JSON.parse(String(row.body)) : undefined;
|
|
177
|
+
}
|
|
178
|
+
function registerDelivery(recordId, total) {
|
|
179
|
+
transaction(() => { db.prepare('INSERT OR IGNORE INTO channelDeliveries VALUES (?,?)').run(recordId, JSON.stringify({ status: 'pending', confirmed: 0, total })); });
|
|
180
|
+
}
|
|
181
|
+
function updateDelivery(recordId, revise) {
|
|
182
|
+
transaction(() => {
|
|
183
|
+
const previous = delivery(recordId);
|
|
184
|
+
if (!previous)
|
|
185
|
+
throw new Error('Delivery record not found');
|
|
186
|
+
db.prepare('UPDATE channelDeliveries SET body=? WHERE recordId=?').run(JSON.stringify(revise(previous)), recordId);
|
|
187
|
+
});
|
|
188
|
+
}
|
|
189
|
+
return { commitRecords, hasRecord, updateRecord, readPage, readTurn, progress, forgetProgress, sourcePage, stats, close,
|
|
190
|
+
channelSession, bindChannelSession, delivery, registerDelivery, updateDelivery };
|
|
191
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/** ISO 8601 local time with its UTC offset in the given IANA zone, e.g. 2026-10-23T21:30:00+09:00. */
|
|
2
|
+
export function formatLocalTime(now, timeZone) {
|
|
3
|
+
const formatter = new Intl.DateTimeFormat('en-US', {
|
|
4
|
+
timeZone, year: 'numeric', month: '2-digit', day: '2-digit',
|
|
5
|
+
hour: '2-digit', minute: '2-digit', second: '2-digit', hourCycle: 'h23', timeZoneName: 'longOffset',
|
|
6
|
+
});
|
|
7
|
+
const parts = Object.fromEntries(formatter.formatToParts(now).map(part => [part.type, part.value]));
|
|
8
|
+
const offset = parts.timeZoneName === 'GMT' ? '+00:00' : parts.timeZoneName.slice(3);
|
|
9
|
+
return `${parts.year}-${parts.month}-${parts.day}T${parts.hour}:${parts.minute}:${parts.second}${offset}`;
|
|
10
|
+
}
|
|
11
|
+
export function formatTimeContext(now, timeZone) {
|
|
12
|
+
return `当前时间:${formatLocalTime(now, timeZone)}\n时区:${timeZone}`;
|
|
13
|
+
}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import type { OutletConfig } from './ecosystem/shared/outlets.ts';
|
|
2
|
+
import type { SessionHeader } from '@deepseek-ai/dsh-session';
|
|
3
|
+
import type { SpeakerIdentity } from './ecosystem/shared/identity.ts';
|
|
4
|
+
import type { MemoryArchiveScope } from './archiveSelection.ts';
|
|
5
|
+
export interface WorldConfig {
|
|
6
|
+
worldId: string;
|
|
7
|
+
agentPreset: string;
|
|
8
|
+
/**
|
|
9
|
+
* `world` follows the host preset (upstream behavior); `qq` follows the sessions dsh-agent-md binds
|
|
10
|
+
* to the QQ gateway, so only the QQ conversation is injected and archived.
|
|
11
|
+
*/
|
|
12
|
+
scope?: 'world' | 'qq';
|
|
13
|
+
/** dsh-agent-md's binding list; `scope: 'qq'` reads it. */
|
|
14
|
+
qqSessionsFile?: string;
|
|
15
|
+
/** A human-readable mirror of the memory block built for the QQ conversation. */
|
|
16
|
+
qqMirrorFile?: string;
|
|
17
|
+
timeZone: string;
|
|
18
|
+
/** Archive her current home alone, or ordinary sessions in its workspace (default). */
|
|
19
|
+
archiveScope?: MemoryArchiveScope;
|
|
20
|
+
/** The life line (home session, alarm, tools, console); on by default. */
|
|
21
|
+
life?: boolean;
|
|
22
|
+
/** Her diary directory; defaults to `<world>/diary`. */
|
|
23
|
+
diaryDir?: string;
|
|
24
|
+
/** Local HH:MM of the morning wake when no alarm is pending (she set none, or cancelled hers); 09:00 by default. */
|
|
25
|
+
fallbackWakeTime?: string;
|
|
26
|
+
/** Her own "who I am" file, part of the world prompt; defaults to `<world>/room/我是谁.md` in the plugin. */
|
|
27
|
+
selfFile?: string;
|
|
28
|
+
/** Her name (home title, notifications, memory labels); TA when unset. */
|
|
29
|
+
companionName?: string;
|
|
30
|
+
/** What she calls her partner in the plugin's own words; 伙伴 when unset. */
|
|
31
|
+
partnerName?: string;
|
|
32
|
+
/** Her layered persona, edited in the world console; defaults to `<world>/persona.md`. */
|
|
33
|
+
personaFile?: string;
|
|
34
|
+
/** The world prompt template; defaults to `<world>/world-prompt.md` when it exists, else the shipped one. */
|
|
35
|
+
worldPromptFile?: string;
|
|
36
|
+
/** The alarm wording template; defaults to `<world>/alarm.md` when it exists, else the shipped one. */
|
|
37
|
+
alarmTemplateFile?: string;
|
|
38
|
+
/** Where her words go outside DSH: replies to bridged words, the busy notice, reach_out. */
|
|
39
|
+
outlets?: OutletConfig[];
|
|
40
|
+
/** Runs the bridge: a local app may hand her partner's words to her home. */
|
|
41
|
+
bridge?: boolean;
|
|
42
|
+
/** The independent local WeChat module; the Windows adapter uses `<world>/wechat.json`. */
|
|
43
|
+
wechat?: boolean;
|
|
44
|
+
/** With `wechat`, run the Windows adapter for as long as the module runs; naming both here is the standing permission for it to send (`--allow-send`). */
|
|
45
|
+
wechatAdapter?: {
|
|
46
|
+
python?: string;
|
|
47
|
+
config?: string;
|
|
48
|
+
};
|
|
49
|
+
/** reach_out also shows a system notification (Windows only); on by default. */
|
|
50
|
+
toast?: boolean;
|
|
51
|
+
/** Names besides this machine the console and the bridge answer to (a LAN address or domain behind a reverse proxy). */
|
|
52
|
+
allowedHosts?: string[];
|
|
53
|
+
/** The qq-bridge checkout, so QQ can reach her home too; empty leaves the module off. */
|
|
54
|
+
qqBridgeDir?: string;
|
|
55
|
+
/** The bridge's console port; 3100 by default. */
|
|
56
|
+
qqBridgePort?: number;
|
|
57
|
+
/** Node used to start the bridge; the current process by default. */
|
|
58
|
+
qqBridgeNode?: string;
|
|
59
|
+
/** Start the bridge together with her world; off by default, so it stays a manual start from the console. */
|
|
60
|
+
qqBridgeAutoStart?: boolean;
|
|
61
|
+
/**
|
|
62
|
+
* Who shares her home session. Empty leaves the bridge's own `socialV2.bindHomeSession` alone; `owner` keeps
|
|
63
|
+
* every group on its own session and binds only the owner's private chat to her home; `all` binds every entry;
|
|
64
|
+
* `none` removes the key so the bridge falls back to binding nothing.
|
|
65
|
+
*/
|
|
66
|
+
qqBridgeBindHomeSession?: 'owner' | 'all' | 'none' | '';
|
|
67
|
+
}
|
|
68
|
+
export interface DeliveryState {
|
|
69
|
+
status: 'pending' | 'sent' | 'uncertain' | 'failed';
|
|
70
|
+
confirmed: number;
|
|
71
|
+
total: number;
|
|
72
|
+
}
|
|
73
|
+
export interface ConversationRecord extends Partial<SpeakerIdentity> {
|
|
74
|
+
schemaVersion: 1;
|
|
75
|
+
worldId: string;
|
|
76
|
+
recordId: string;
|
|
77
|
+
sourceSessionId: string;
|
|
78
|
+
sourceMessageId: string;
|
|
79
|
+
sourceSeq: number;
|
|
80
|
+
turnId: string;
|
|
81
|
+
role: 'user' | 'assistant';
|
|
82
|
+
occurredAt: string;
|
|
83
|
+
content: string;
|
|
84
|
+
status: 'complete' | 'interrupted';
|
|
85
|
+
wechatDelivery?: DeliveryState;
|
|
86
|
+
}
|
|
87
|
+
export interface ArchiveScope {
|
|
88
|
+
worldId: string;
|
|
89
|
+
agentPreset: string;
|
|
90
|
+
header: SessionHeader;
|
|
91
|
+
inheritedEventCount: number;
|
|
92
|
+
turn: number;
|
|
93
|
+
archiveScope?: MemoryArchiveScope;
|
|
94
|
+
}
|
|
95
|
+
export interface ArchiveCursor {
|
|
96
|
+
date: string;
|
|
97
|
+
occurredAt: string;
|
|
98
|
+
recordId: string;
|
|
99
|
+
maxSequence: number;
|
|
100
|
+
}
|
|
101
|
+
export interface PageQuery {
|
|
102
|
+
worldId: string;
|
|
103
|
+
before?: ArchiveCursor;
|
|
104
|
+
limit: number;
|
|
105
|
+
}
|
|
106
|
+
export interface RecordPage {
|
|
107
|
+
records: ConversationRecord[];
|
|
108
|
+
nextCursor?: ArchiveCursor;
|
|
109
|
+
}
|
|
110
|
+
export interface ConversationTurn {
|
|
111
|
+
turnId: string;
|
|
112
|
+
occurredAt: string;
|
|
113
|
+
messages: ConversationRecord[];
|
|
114
|
+
}
|
|
115
|
+
export interface ArchiveReader {
|
|
116
|
+
readPage(query: PageQuery): Promise<RecordPage>;
|
|
117
|
+
readTurn(worldId: string, turnId: string, afterSeq?: number, limit?: number): Promise<ConversationRecord[]>;
|
|
118
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type { LifeOptions } from './life/types.ts';
|
|
2
|
+
/** The template shipped with the plugin; a `world-prompt.md` in the world directory replaces it. */
|
|
3
|
+
export declare const DEFAULT_TEMPLATE_FILE: string;
|
|
4
|
+
export interface WorldNames {
|
|
5
|
+
companion: string;
|
|
6
|
+
partner: string;
|
|
7
|
+
}
|
|
8
|
+
/** No name is assumed for anyone's companion: an unnamed one is the neutral TA. */
|
|
9
|
+
export declare function worldNames(config: {
|
|
10
|
+
companionName?: string;
|
|
11
|
+
partnerName?: string;
|
|
12
|
+
}): WorldNames;
|
|
13
|
+
export declare const homeTitle: (names: WorldNames) => string;
|
|
14
|
+
/** Her room as a workspace in the host's sidebar. */
|
|
15
|
+
export declare const roomTitle: (names: WorldNames) => string;
|
|
16
|
+
export interface WorldPrompt {
|
|
17
|
+
/** Her template, when present; the shipped default otherwise. */
|
|
18
|
+
file?: string;
|
|
19
|
+
/** Her layered persona (`persona.md`), placed above the world prompt when written. */
|
|
20
|
+
persona?: string;
|
|
21
|
+
/** Where the daily exports of her archive are (`<world>/conversations`). */
|
|
22
|
+
conversationsDir?: string;
|
|
23
|
+
names: WorldNames;
|
|
24
|
+
/** Present when the life line runs: room, diary, world line, ask-first rules. */
|
|
25
|
+
life?: LifeOptions;
|
|
26
|
+
}
|
|
27
|
+
export interface TemplateRead {
|
|
28
|
+
text: string;
|
|
29
|
+
error?: string;
|
|
30
|
+
}
|
|
31
|
+
/** Never throws: a template that cannot be read falls back to the shipped one and says why. */
|
|
32
|
+
export declare function readTemplate(file: string | undefined): TemplateRead;
|
|
33
|
+
/**
|
|
34
|
+
* A small Mustache subset: `{{#flag}}…{{/flag}}` keeps its body when the flag is on, `{{^flag}}…{{/flag}}`
|
|
35
|
+
* when it is off (different flags may nest), and `{{name}}` is replaced in one pass, so values such as her
|
|
36
|
+
* 我是谁 are never scanned for tags themselves. Unknown names stay as written.
|
|
37
|
+
*/
|
|
38
|
+
export declare function renderTemplate(template: string, flags: Record<string, boolean>, values: Record<string, string>): string;
|
|
39
|
+
/**
|
|
40
|
+
* The one world prompt every world session carries in its system prompt. `template` and `self` are read at
|
|
41
|
+
* session start and after compaction only, so the prompt does not change between compactions. The world
|
|
42
|
+
* line's tools live in the home alone; the template tells other sessions where to find them.
|
|
43
|
+
*/
|
|
44
|
+
export declare function renderWorldPrompt(prompt: WorldPrompt, template: string, self: {
|
|
45
|
+
file: string;
|
|
46
|
+
text: string;
|
|
47
|
+
} | undefined, home: boolean): string;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { existsSync, readFileSync } from 'node:fs';
|
|
2
|
+
import { fileURLToPath } from 'node:url';
|
|
3
|
+
/** The template shipped with the plugin; a `world-prompt.md` in the world directory replaces it. */
|
|
4
|
+
export const DEFAULT_TEMPLATE_FILE = fileURLToPath(new URL('../templates/world-prompt.md', import.meta.url));
|
|
5
|
+
/** No name is assumed for anyone's companion: an unnamed one is the neutral TA. */
|
|
6
|
+
export function worldNames(config) {
|
|
7
|
+
return { companion: config.companionName?.trim() || 'TA', partner: config.partnerName?.trim() || '伙伴' };
|
|
8
|
+
}
|
|
9
|
+
export const homeTitle = (names) => `${names.companion}的家`;
|
|
10
|
+
/** Her room as a workspace in the host's sidebar. */
|
|
11
|
+
export const roomTitle = (names) => `${names.companion}的房间`;
|
|
12
|
+
/** Never throws: a template that cannot be read falls back to the shipped one and says why. */
|
|
13
|
+
export function readTemplate(file) {
|
|
14
|
+
if (file && existsSync(file)) {
|
|
15
|
+
try {
|
|
16
|
+
return { text: readFileSync(file, 'utf8').trim() };
|
|
17
|
+
}
|
|
18
|
+
catch (error) {
|
|
19
|
+
return { text: readFileSync(DEFAULT_TEMPLATE_FILE, 'utf8'), error: `世界提示词模板 ${file} 读不了,先用默认模板:${error instanceof Error ? error.message : String(error)}` };
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
return { text: readFileSync(DEFAULT_TEMPLATE_FILE, 'utf8') };
|
|
23
|
+
}
|
|
24
|
+
const section = /\{\{([#^])(\w+)\}\}([\s\S]*?)\{\{\/\2\}\}/;
|
|
25
|
+
/**
|
|
26
|
+
* A small Mustache subset: `{{#flag}}…{{/flag}}` keeps its body when the flag is on, `{{^flag}}…{{/flag}}`
|
|
27
|
+
* when it is off (different flags may nest), and `{{name}}` is replaced in one pass, so values such as her
|
|
28
|
+
* 我是谁 are never scanned for tags themselves. Unknown names stay as written.
|
|
29
|
+
*/
|
|
30
|
+
export function renderTemplate(template, flags, values) {
|
|
31
|
+
let text = template.replace(/\r\n?/g, '\n');
|
|
32
|
+
for (let match = section.exec(text); match; match = section.exec(text)) {
|
|
33
|
+
const [whole, kind, flag, body] = match;
|
|
34
|
+
text = text.replace(whole, () => (kind === '#') === Boolean(flags[flag]) ? body : '');
|
|
35
|
+
}
|
|
36
|
+
return text.replace(/\{\{(\w+)\}\}/g, (tag, name) => values[name] ?? tag).replace(/[ \t]+\n/g, '\n').replace(/\n{3,}/g, '\n\n').trim();
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* The one world prompt every world session carries in its system prompt. `template` and `self` are read at
|
|
40
|
+
* session start and after compaction only, so the prompt does not change between compactions. The world
|
|
41
|
+
* line's tools live in the home alone; the template tells other sessions where to find them.
|
|
42
|
+
*/
|
|
43
|
+
export function renderWorldPrompt(prompt, template, self, home) {
|
|
44
|
+
const { life, names } = prompt;
|
|
45
|
+
return renderTemplate(template, { life: Boolean(life), home, selfFile: Boolean(self), conversationsDir: Boolean(prompt.conversationsDir) }, {
|
|
46
|
+
name: names.companion, partner: names.partner, homeTitle: homeTitle(names), selfFile: self?.file ?? '', self: self?.text ?? '', conversationsDir: prompt.conversationsDir ?? '',
|
|
47
|
+
...(life ? { roomDir: life.roomDir, diaryDir: life.diaryDir, fallbackWakeTime: life.fallbackWakeTime } : {}),
|
|
48
|
+
});
|
|
49
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { type MemoryArchiveScope } from './archiveSelection.ts';
|
|
2
|
+
/** How many of the newest turns the memory block carries when nothing else is set. */
|
|
3
|
+
export declare const DEFAULT_MEMORY_TURNS = 200;
|
|
4
|
+
/** WeChat group messages read before a mention, and seconds a private image waits for its companions. */
|
|
5
|
+
export declare const DEFAULT_WECHAT_CONTEXT = 8, MAX_WECHAT_CONTEXT = 20;
|
|
6
|
+
export declare const DEFAULT_WECHAT_BUFFER_SECONDS = 3, MAX_WECHAT_BUFFER_SECONDS = 30;
|
|
7
|
+
/**
|
|
8
|
+
* Her world's own settings, changed from the world console and kept in `<world>/world.json` so they outlast a
|
|
9
|
+
* restart: whether it runs (memory block, prompts, archive and life line together), how much her home may
|
|
10
|
+
* spend a day, and how many recent turns her memory block carries. A world that already has a life line from before the switch existed is running; a new one waits
|
|
11
|
+
* for its partner to press start.
|
|
12
|
+
*/
|
|
13
|
+
export declare function createWorldSwitch(worldDir: string, configuredScope?: MemoryArchiveScope): {
|
|
14
|
+
archiveScope: () => MemoryArchiveScope;
|
|
15
|
+
selectedArchiveScope: () => MemoryArchiveScope;
|
|
16
|
+
restartRequired: () => boolean;
|
|
17
|
+
setArchiveScope(scope: MemoryArchiveScope): void;
|
|
18
|
+
running: () => boolean;
|
|
19
|
+
set: (running: boolean) => void;
|
|
20
|
+
/** CNY a day for her home; undefined is no limit. */
|
|
21
|
+
dailyBudget: () => number | undefined;
|
|
22
|
+
setDailyBudget(yuan: number | undefined): void;
|
|
23
|
+
/** Turns in her memory block; read when a block is built, so a change shows from the next session start or compaction. */
|
|
24
|
+
memoryTurns: () => number;
|
|
25
|
+
setMemoryTurns(turns: number | undefined): void;
|
|
26
|
+
/** The console's switches for the WeChat and QQ modules; on unless turned off, and only an off switch is written out. */
|
|
27
|
+
wechatEnabled: () => boolean;
|
|
28
|
+
qqEnabled: () => boolean;
|
|
29
|
+
setModules(next: {
|
|
30
|
+
wechat?: boolean;
|
|
31
|
+
qq?: boolean;
|
|
32
|
+
}): void;
|
|
33
|
+
/** Read by the WeChat adapter on its next poll; a batch already waiting keeps the value it started with. */
|
|
34
|
+
wechatContext: () => number;
|
|
35
|
+
wechatBufferSeconds: () => number;
|
|
36
|
+
setWechat(next: {
|
|
37
|
+
context?: number | null;
|
|
38
|
+
bufferSeconds?: number | null;
|
|
39
|
+
}): void;
|
|
40
|
+
};
|
|
41
|
+
export type WorldSwitch = ReturnType<typeof createWorldSwitch>;
|
|
42
|
+
export declare const validTurns: (value: unknown) => value is number;
|
|
43
|
+
export declare const validWechatContext: (value: unknown) => value is number;
|
|
44
|
+
export declare const validWechatBuffer: (value: unknown) => value is number;
|