dsh-chat-comprehension 0.2.0 → 0.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (364) hide show
  1. package/NOTICE.md +20 -0
  2. package/README.md +20 -9
  3. package/client.js +41 -9
  4. package/lib/engines.mjs +136 -0
  5. package/lib/index.js +54 -4
  6. package/lib/qqbot-0.5.3-patches.json +75 -70
  7. package/lib/qqbot-patch.mjs +12 -7
  8. package/lib/video.mjs +11 -2
  9. package/package.json +7 -23
  10. package/vendor/dsh-agent-md/LICENSE +21 -0
  11. package/vendor/dsh-agent-md/cordis.patch.yml +8 -0
  12. package/vendor/dsh-agent-md/lib/index.js +775 -0
  13. package/vendor/dsh-agent-md/lib/persona.js +634 -0
  14. package/vendor/dsh-agent-md/lib/qq.js +527 -0
  15. package/vendor/dsh-agent-md/package.json +50 -0
  16. package/vendor/dsh-bili-scroll/LICENSE +21 -0
  17. package/vendor/dsh-bili-scroll/NOTICE.md +18 -0
  18. package/vendor/dsh-bili-scroll/cordis.patch.yml +20 -0
  19. package/vendor/dsh-bili-scroll/index.js +3293 -0
  20. package/vendor/dsh-bili-scroll/lib/asr.py +141 -0
  21. package/vendor/dsh-bili-scroll/lib/diagnose.mjs +95 -0
  22. package/vendor/dsh-bili-scroll/lib/dm.mjs +110 -0
  23. package/vendor/dsh-bili-scroll/lib/favops.py +90 -0
  24. package/vendor/dsh-bili-scroll/lib/hostdeps.mjs +148 -0
  25. package/vendor/dsh-bili-scroll/lib/login.mjs +141 -0
  26. package/vendor/dsh-bili-scroll/lib/mcp.mjs +144 -0
  27. package/vendor/dsh-bili-scroll/lib/state.mjs +236 -0
  28. package/vendor/dsh-bili-scroll/lib/uid.mjs +61 -0
  29. package/vendor/dsh-bili-scroll/lib/uvfetch.mjs +217 -0
  30. package/vendor/dsh-bili-scroll/lib/verify.mjs +184 -0
  31. package/vendor/dsh-bili-scroll/package.json +84 -0
  32. package/vendor/dsh-bili-scroll/profile-template/bili-duty/cordis.patch.yml +116 -0
  33. package/vendor/dsh-bili-scroll/profile-template/bili-duty/cordis.yml +4 -0
  34. package/vendor/dsh-bili-scroll/profile-template/bili-duty/package.json +13 -0
  35. package/vendor/dsh-bili-scroll/prompts/duty.md +296 -0
  36. package/vendor/dsh-bili-scroll/vendor/bilibili-mcp/LICENSE +21 -0
  37. package/vendor/dsh-bili-scroll/vendor/bilibili-mcp/README.md +176 -0
  38. package/vendor/dsh-bili-scroll/vendor/bilibili-mcp/mcp_server.py +2015 -0
  39. package/vendor/dsh-bili-scroll/vendor/bilibili-mcp/requirements.txt +10 -0
  40. package/vendor/dsh-meme/.dsh/skills/dsh-meme-maintenance/SKILL.md +50 -0
  41. package/vendor/dsh-meme/LICENSE +21 -0
  42. package/vendor/dsh-meme/anim.js +588 -0
  43. package/vendor/dsh-meme/cordis.patch.yml +13 -0
  44. package/vendor/dsh-meme/icon.jpg +0 -0
  45. package/vendor/dsh-meme/index.js +2616 -0
  46. package/vendor/dsh-meme/locale/en.json +6 -0
  47. package/vendor/dsh-meme/locale/zh.json +6 -0
  48. package/vendor/dsh-meme/memes/dafeiyu-001/index.db +0 -0
  49. package/vendor/dsh-meme/memes/dafeiyu-001/manifest.json +13 -0
  50. package/vendor/dsh-meme/memes/dafeiyu-001/memes/angry/shengqi.jpg +0 -0
  51. package/vendor/dsh-meme/memes/dafeiyu-001/memes/baka/xianqi.jpg +0 -0
  52. package/vendor/dsh-meme/memes/dafeiyu-001/memes/color/huachi.jpg +0 -0
  53. package/vendor/dsh-meme/memes/dafeiyu-001/memes/confused/jiazai.jpg +0 -0
  54. package/vendor/dsh-meme/memes/dafeiyu-001/memes/confused/wenhao.jpg +0 -0
  55. package/vendor/dsh-meme/memes/dafeiyu-001/memes/cpu/jiaban.jpg +0 -0
  56. package/vendor/dsh-meme/memes/dafeiyu-001/memes/daily/ganfan.jpg +0 -0
  57. package/vendor/dsh-meme/memes/dafeiyu-001/memes/fool/buyao.jpg +0 -0
  58. package/vendor/dsh-meme/memes/dafeiyu-001/memes/givemoney/yaoqian.jpg +0 -0
  59. package/vendor/dsh-meme/memes/dafeiyu-001/memes/happy/deyi.jpg +0 -0
  60. package/vendor/dsh-meme/memes/dafeiyu-001/memes/happy/ok.jpg +0 -0
  61. package/vendor/dsh-meme/memes/dafeiyu-001/memes/happy/piaole.jpg +0 -0
  62. package/vendor/dsh-meme/memes/dafeiyu-001/memes/like/bixin.jpg +0 -0
  63. package/vendor/dsh-meme/memes/dafeiyu-001/memes/meow/maozhua.jpg +0 -0
  64. package/vendor/dsh-meme/memes/dafeiyu-001/memes/morning/zaoshanghao.jpg +0 -0
  65. package/vendor/dsh-meme/memes/dafeiyu-001/memes/sad/qiurao.jpg +0 -0
  66. package/vendor/dsh-meme/memes/dafeiyu-001/memes/sad/yun.jpg +0 -0
  67. package/vendor/dsh-meme/memes/dafeiyu-001/memes/see/zhenjing.jpg +0 -0
  68. package/vendor/dsh-meme/memes/dafeiyu-001/memes/shy/haixiu.jpg +0 -0
  69. package/vendor/dsh-meme/memes/dafeiyu-001/memes/shy/toukan.jpg +0 -0
  70. package/vendor/dsh-meme/memes/dafeiyu-001/memes/sigh/wuyu.jpg +0 -0
  71. package/vendor/dsh-meme/memes/dafeiyu-001/memes/sleep/shuijiao.jpg +0 -0
  72. package/vendor/dsh-meme/memes/dafeiyu-001/memes/surprised/xia.jpg +0 -0
  73. package/vendor/dsh-meme/memes/dafeiyu-001/memes/work/tangping.jpg +0 -0
  74. package/vendor/dsh-meme/memes.js +998 -0
  75. package/vendor/dsh-meme/package.json +67 -0
  76. package/vendor/dsh-meme/panel.html +210 -0
  77. package/vendor/dsh-video-storyboard/LICENSE +21 -0
  78. package/vendor/dsh-video-storyboard/NOTICE +12 -0
  79. package/vendor/dsh-video-storyboard/bin/_args.mjs +16 -0
  80. package/vendor/dsh-video-storyboard/bin/asr-check.mjs +85 -0
  81. package/vendor/dsh-video-storyboard/bin/scan-stats.mjs +43 -0
  82. package/vendor/dsh-video-storyboard/bin/scan-video.mjs +38 -0
  83. package/vendor/dsh-video-storyboard/bin/storyboard.mjs +195 -0
  84. package/vendor/dsh-video-storyboard/cordis.patch.yml +3 -0
  85. package/vendor/dsh-video-storyboard/dsh.plugin.json +12 -0
  86. package/vendor/dsh-video-storyboard/package.json +88 -0
  87. package/vendor/dsh-video-storyboard/scripts/check-syntax.mjs +56 -0
  88. package/vendor/dsh-video-storyboard/scripts/install-dev.mjs +104 -0
  89. package/vendor/dsh-video-storyboard/src/flicker.js +104 -0
  90. package/vendor/dsh-video-storyboard/src/index.js +82 -0
  91. package/vendor/dsh-video-storyboard/src/ocr_bridge.py +103 -0
  92. package/vendor/dsh-video-storyboard/src/storyboard/asr-lifecycle.js +262 -0
  93. package/vendor/dsh-video-storyboard/src/storyboard/asr.js +488 -0
  94. package/vendor/dsh-video-storyboard/src/storyboard/audio.js +168 -0
  95. package/vendor/dsh-video-storyboard/src/storyboard/binaries.js +69 -0
  96. package/vendor/dsh-video-storyboard/src/storyboard/board.js +121 -0
  97. package/vendor/dsh-video-storyboard/src/storyboard/browser-time.js +504 -0
  98. package/vendor/dsh-video-storyboard/src/storyboard/cache.js +143 -0
  99. package/vendor/dsh-video-storyboard/src/storyboard/cells.js +70 -0
  100. package/vendor/dsh-video-storyboard/src/storyboard/density.js +545 -0
  101. package/vendor/dsh-video-storyboard/src/storyboard/direct-url.js +130 -0
  102. package/vendor/dsh-video-storyboard/src/storyboard/fetch.js +373 -0
  103. package/vendor/dsh-video-storyboard/src/storyboard/flash.js +180 -0
  104. package/vendor/dsh-video-storyboard/src/storyboard/format.js +573 -0
  105. package/vendor/dsh-video-storyboard/src/storyboard/frames.js +212 -0
  106. package/vendor/dsh-video-storyboard/src/storyboard/index.js +32 -0
  107. package/vendor/dsh-video-storyboard/src/storyboard/injection.js +76 -0
  108. package/vendor/dsh-video-storyboard/src/storyboard/layout-order.js +176 -0
  109. package/vendor/dsh-video-storyboard/src/storyboard/locate.js +113 -0
  110. package/vendor/dsh-video-storyboard/src/storyboard/media-store.js +106 -0
  111. package/vendor/dsh-video-storyboard/src/storyboard/memory.js +94 -0
  112. package/vendor/dsh-video-storyboard/src/storyboard/ocr-subs.js +107 -0
  113. package/vendor/dsh-video-storyboard/src/storyboard/ocr.js +167 -0
  114. package/vendor/dsh-video-storyboard/src/storyboard/pipeline.js +853 -0
  115. package/vendor/dsh-video-storyboard/src/storyboard/plan.js +400 -0
  116. package/vendor/dsh-video-storyboard/src/storyboard/probe.js +132 -0
  117. package/vendor/dsh-video-storyboard/src/storyboard/provenance.js +44 -0
  118. package/vendor/dsh-video-storyboard/src/storyboard/python.js +84 -0
  119. package/vendor/dsh-video-storyboard/src/storyboard/register.js +32 -0
  120. package/vendor/dsh-video-storyboard/src/storyboard/scan.js +486 -0
  121. package/vendor/dsh-video-storyboard/src/storyboard/segments.js +117 -0
  122. package/vendor/dsh-video-storyboard/src/storyboard/sheet.js +507 -0
  123. package/vendor/dsh-video-storyboard/src/storyboard/storage.js +93 -0
  124. package/vendor/dsh-video-storyboard/src/storyboard/subtitles.js +181 -0
  125. package/vendor/dsh-video-storyboard/src/storyboard/tool-spec.js +544 -0
  126. package/vendor/dsh-video-storyboard/src/storyboard/transcript-file.js +146 -0
  127. package/vendor/dsh-video-storyboard/src/storyboard/url.js +69 -0
  128. package/vendor/dsh-video-storyboard/src/storyboard/ytdlp.js +289 -0
  129. package/vendor/dsh-video-storyboard/src/tool-spec.js +17 -0
  130. package/vendor/dsh-video-storyboard/src/tools/locate.js +39 -0
  131. package/vendor/dsh-video-storyboard/src/tools/probe.js +23 -0
  132. package/vendor/dsh-video-storyboard/src/tools/shared.js +39 -0
  133. package/vendor/dsh-video-storyboard/src/tools/storyboard.js +20 -0
  134. package/vendor/dsh-video-storyboard/src/tools/zoom.js +56 -0
  135. package/vendor/dsh-world/LICENSE +21 -0
  136. package/vendor/dsh-world/assets/qq-card.png +0 -0
  137. package/vendor/dsh-world/cordis.patch.yml +6 -0
  138. package/vendor/dsh-world/lib/archive.d.ts +6 -0
  139. package/vendor/dsh-world/lib/archive.js +49 -0
  140. package/vendor/dsh-world/lib/archiveSelection.d.ts +8 -0
  141. package/vendor/dsh-world/lib/archiveSelection.js +20 -0
  142. package/vendor/dsh-world/lib/compaction.d.ts +124 -0
  143. package/vendor/dsh-world/lib/compaction.js +273 -0
  144. package/vendor/dsh-world/lib/compactionRegion.d.ts +42 -0
  145. package/vendor/dsh-world/lib/compactionRegion.js +210 -0
  146. package/vendor/dsh-world/lib/console/routes.d.ts +57 -0
  147. package/vendor/dsh-world/lib/console/routes.js +129 -0
  148. package/vendor/dsh-world/lib/console/snapshot.d.ts +39 -0
  149. package/vendor/dsh-world/lib/console/snapshot.js +51 -0
  150. package/vendor/dsh-world/lib/ecosystem/bridge/bridge.d.ts +36 -0
  151. package/vendor/dsh-world/lib/ecosystem/bridge/bridge.js +140 -0
  152. package/vendor/dsh-world/lib/ecosystem/bridge/route.d.ts +9 -0
  153. package/vendor/dsh-world/lib/ecosystem/bridge/route.js +46 -0
  154. package/vendor/dsh-world/lib/ecosystem/qq/bridge.d.ts +123 -0
  155. package/vendor/dsh-world/lib/ecosystem/qq/bridge.js +380 -0
  156. package/vendor/dsh-world/lib/ecosystem/qq/panel.d.ts +75 -0
  157. package/vendor/dsh-world/lib/ecosystem/qq/panel.js +187 -0
  158. package/vendor/dsh-world/lib/ecosystem/qq/route.d.ts +32 -0
  159. package/vendor/dsh-world/lib/ecosystem/qq/route.js +134 -0
  160. package/vendor/dsh-world/lib/ecosystem/qq/supervisor.d.ts +57 -0
  161. package/vendor/dsh-world/lib/ecosystem/qq/supervisor.js +188 -0
  162. package/vendor/dsh-world/lib/ecosystem/shared/context.d.ts +14 -0
  163. package/vendor/dsh-world/lib/ecosystem/shared/context.js +42 -0
  164. package/vendor/dsh-world/lib/ecosystem/shared/identity.d.ts +15 -0
  165. package/vendor/dsh-world/lib/ecosystem/shared/identity.js +36 -0
  166. package/vendor/dsh-world/lib/ecosystem/shared/outlets.d.ts +43 -0
  167. package/vendor/dsh-world/lib/ecosystem/shared/outlets.js +70 -0
  168. package/vendor/dsh-world/lib/ecosystem/shared/sessions.d.ts +16 -0
  169. package/vendor/dsh-world/lib/ecosystem/shared/sessions.js +52 -0
  170. package/vendor/dsh-world/lib/ecosystem/wechat/archive.d.ts +24 -0
  171. package/vendor/dsh-world/lib/ecosystem/wechat/archive.js +62 -0
  172. package/vendor/dsh-world/lib/ecosystem/wechat/home.d.ts +21 -0
  173. package/vendor/dsh-world/lib/ecosystem/wechat/home.js +111 -0
  174. package/vendor/dsh-world/lib/ecosystem/wechat/images.d.ts +5 -0
  175. package/vendor/dsh-world/lib/ecosystem/wechat/images.js +43 -0
  176. package/vendor/dsh-world/lib/ecosystem/wechat/index.d.ts +41 -0
  177. package/vendor/dsh-world/lib/ecosystem/wechat/index.js +166 -0
  178. package/vendor/dsh-world/lib/ecosystem/wechat/messages.d.ts +24 -0
  179. package/vendor/dsh-world/lib/ecosystem/wechat/messages.js +35 -0
  180. package/vendor/dsh-world/lib/ecosystem/wechat/sending.d.ts +30 -0
  181. package/vendor/dsh-world/lib/ecosystem/wechat/sending.js +216 -0
  182. package/vendor/dsh-world/lib/ecosystem/wechat/supervisor.d.ts +39 -0
  183. package/vendor/dsh-world/lib/ecosystem/wechat/supervisor.js +138 -0
  184. package/vendor/dsh-world/lib/faults.d.ts +10 -0
  185. package/vendor/dsh-world/lib/faults.js +13 -0
  186. package/vendor/dsh-world/lib/history.d.ts +16 -0
  187. package/vendor/dsh-world/lib/history.js +80 -0
  188. package/vendor/dsh-world/lib/hostContract.d.ts +19 -0
  189. package/vendor/dsh-world/lib/hostContract.js +1 -0
  190. package/vendor/dsh-world/lib/http.d.ts +18 -0
  191. package/vendor/dsh-world/lib/http.js +39 -0
  192. package/vendor/dsh-world/lib/index.d.ts +108 -0
  193. package/vendor/dsh-world/lib/index.js +356 -0
  194. package/vendor/dsh-world/lib/life/activity.d.ts +14 -0
  195. package/vendor/dsh-world/lib/life/activity.js +58 -0
  196. package/vendor/dsh-world/lib/life/alarm.d.ts +39 -0
  197. package/vendor/dsh-world/lib/life/alarm.js +132 -0
  198. package/vendor/dsh-world/lib/life/alarmTimer.d.ts +22 -0
  199. package/vendor/dsh-world/lib/life/alarmTimer.js +49 -0
  200. package/vendor/dsh-world/lib/life/diary.d.ts +4 -0
  201. package/vendor/dsh-world/lib/life/diary.js +9 -0
  202. package/vendor/dsh-world/lib/life/earlyStop.d.ts +19 -0
  203. package/vendor/dsh-world/lib/life/earlyStop.js +25 -0
  204. package/vendor/dsh-world/lib/life/home.d.ts +34 -0
  205. package/vendor/dsh-world/lib/life/home.js +91 -0
  206. package/vendor/dsh-world/lib/life/host.d.ts +22 -0
  207. package/vendor/dsh-world/lib/life/host.js +24 -0
  208. package/vendor/dsh-world/lib/life/journal.d.ts +20 -0
  209. package/vendor/dsh-world/lib/life/journal.js +59 -0
  210. package/vendor/dsh-world/lib/life/lifeStore.d.ts +16 -0
  211. package/vendor/dsh-world/lib/life/lifeStore.js +105 -0
  212. package/vendor/dsh-world/lib/life/messages.d.ts +17 -0
  213. package/vendor/dsh-world/lib/life/messages.js +53 -0
  214. package/vendor/dsh-world/lib/life/notify.d.ts +15 -0
  215. package/vendor/dsh-world/lib/life/notify.js +40 -0
  216. package/vendor/dsh-world/lib/life/pricing.d.ts +4 -0
  217. package/vendor/dsh-world/lib/life/pricing.js +30 -0
  218. package/vendor/dsh-world/lib/life/runtime.d.ts +52 -0
  219. package/vendor/dsh-world/lib/life/runtime.js +376 -0
  220. package/vendor/dsh-world/lib/life/toolRegistry.d.ts +22 -0
  221. package/vendor/dsh-world/lib/life/toolRegistry.js +64 -0
  222. package/vendor/dsh-world/lib/life/tools.d.ts +24 -0
  223. package/vendor/dsh-world/lib/life/tools.js +47 -0
  224. package/vendor/dsh-world/lib/life/types.d.ts +67 -0
  225. package/vendor/dsh-world/lib/life/types.js +1 -0
  226. package/vendor/dsh-world/lib/persona.d.ts +10 -0
  227. package/vendor/dsh-world/lib/persona.js +29 -0
  228. package/vendor/dsh-world/lib/promptSection.d.ts +30 -0
  229. package/vendor/dsh-world/lib/promptSection.js +81 -0
  230. package/vendor/dsh-world/lib/qqScope.d.ts +11 -0
  231. package/vendor/dsh-world/lib/qqScope.js +39 -0
  232. package/vendor/dsh-world/lib/runtime.d.ts +23 -0
  233. package/vendor/dsh-world/lib/runtime.js +206 -0
  234. package/vendor/dsh-world/lib/self.d.ts +10 -0
  235. package/vendor/dsh-world/lib/self.js +36 -0
  236. package/vendor/dsh-world/lib/sourceArchive.d.ts +28 -0
  237. package/vendor/dsh-world/lib/sourceArchive.js +156 -0
  238. package/vendor/dsh-world/lib/store.d.ts +30 -0
  239. package/vendor/dsh-world/lib/store.js +191 -0
  240. package/vendor/dsh-world/lib/timeContext.d.ts +3 -0
  241. package/vendor/dsh-world/lib/timeContext.js +13 -0
  242. package/vendor/dsh-world/lib/types.d.ts +118 -0
  243. package/vendor/dsh-world/lib/types.js +1 -0
  244. package/vendor/dsh-world/lib/worldPrompt.d.ts +47 -0
  245. package/vendor/dsh-world/lib/worldPrompt.js +49 -0
  246. package/vendor/dsh-world/lib/worldSwitch.d.ts +44 -0
  247. package/vendor/dsh-world/lib/worldSwitch.js +78 -0
  248. package/vendor/dsh-world/package-lock.json +1088 -0
  249. package/vendor/dsh-world/package.json +88 -0
  250. package/vendor/dsh-world/scripts/enable-tool-free-compaction.ps1 +33 -0
  251. package/vendor/dsh-world/src/archive.ts +45 -0
  252. package/vendor/dsh-world/src/archiveSelection.ts +27 -0
  253. package/vendor/dsh-world/src/compaction.ts +260 -0
  254. package/vendor/dsh-world/src/compactionRegion.ts +172 -0
  255. package/vendor/dsh-world/src/console/routes.ts +125 -0
  256. package/vendor/dsh-world/src/console/snapshot.ts +84 -0
  257. package/vendor/dsh-world/src/ecosystem/README.md +14 -0
  258. package/vendor/dsh-world/src/ecosystem/bridge/bridge.ts +121 -0
  259. package/vendor/dsh-world/src/ecosystem/bridge/route.ts +35 -0
  260. package/vendor/dsh-world/src/ecosystem/qq/bridge.ts +456 -0
  261. package/vendor/dsh-world/src/ecosystem/qq/panel.ts +178 -0
  262. package/vendor/dsh-world/src/ecosystem/qq/route.ts +130 -0
  263. package/vendor/dsh-world/src/ecosystem/qq/supervisor.ts +262 -0
  264. package/vendor/dsh-world/src/ecosystem/shared/context.ts +38 -0
  265. package/vendor/dsh-world/src/ecosystem/shared/identity.ts +42 -0
  266. package/vendor/dsh-world/src/ecosystem/shared/outlets.ts +75 -0
  267. package/vendor/dsh-world/src/ecosystem/shared/sessions.ts +47 -0
  268. package/vendor/dsh-world/src/ecosystem/wechat/archive.ts +66 -0
  269. package/vendor/dsh-world/src/ecosystem/wechat/home.ts +94 -0
  270. package/vendor/dsh-world/src/ecosystem/wechat/images.ts +38 -0
  271. package/vendor/dsh-world/src/ecosystem/wechat/index.ts +101 -0
  272. package/vendor/dsh-world/src/ecosystem/wechat/messages.ts +43 -0
  273. package/vendor/dsh-world/src/ecosystem/wechat/sending.ts +177 -0
  274. package/vendor/dsh-world/src/ecosystem/wechat/supervisor.ts +116 -0
  275. package/vendor/dsh-world/src/ecosystem/wechat/windows/README.md +117 -0
  276. package/vendor/dsh-world/src/ecosystem/wechat/windows/adapter.py +572 -0
  277. package/vendor/dsh-world/src/ecosystem/wechat/windows/binding.py +52 -0
  278. package/vendor/dsh-world/src/ecosystem/wechat/windows/engine/LICENSE +43 -0
  279. package/vendor/dsh-world/src/ecosystem/wechat/windows/engine/NOTICE.md +10 -0
  280. package/vendor/dsh-world/src/ecosystem/wechat/windows/engine/bridge.cpp +229 -0
  281. package/vendor/dsh-world/src/ecosystem/wechat/windows/engine/build.ps1 +19 -0
  282. package/vendor/dsh-world/src/ecosystem/wechat/windows/engine/profile.json +28 -0
  283. package/vendor/dsh-world/src/ecosystem/wechat/windows/groups.py +42 -0
  284. package/vendor/dsh-world/src/ecosystem/wechat/windows/incoming.py +157 -0
  285. package/vendor/dsh-world/src/ecosystem/wechat/windows/native.py +168 -0
  286. package/vendor/dsh-world/src/ecosystem/wechat/windows/outgoing.py +95 -0
  287. package/vendor/dsh-world/src/ecosystem/wechat/windows/requirements.txt +1 -0
  288. package/vendor/dsh-world/src/ecosystem/wechat/windows/sender.py +157 -0
  289. package/vendor/dsh-world/src/ecosystem/wechat/windows/snapshot.py +32 -0
  290. package/vendor/dsh-world/src/ecosystem/wechat/windows/stickers.py +60 -0
  291. package/vendor/dsh-world/src/ecosystem/wechat/windows/wechat.ps1 +75 -0
  292. package/vendor/dsh-world/src/faults.ts +12 -0
  293. package/vendor/dsh-world/src/history.ts +77 -0
  294. package/vendor/dsh-world/src/hostContract.ts +9 -0
  295. package/vendor/dsh-world/src/http.ts +34 -0
  296. package/vendor/dsh-world/src/index.ts +286 -0
  297. package/vendor/dsh-world/src/life/activity.ts +48 -0
  298. package/vendor/dsh-world/src/life/alarm.ts +119 -0
  299. package/vendor/dsh-world/src/life/alarmTimer.ts +45 -0
  300. package/vendor/dsh-world/src/life/diary.ts +10 -0
  301. package/vendor/dsh-world/src/life/earlyStop.ts +27 -0
  302. package/vendor/dsh-world/src/life/home.ts +85 -0
  303. package/vendor/dsh-world/src/life/host.ts +50 -0
  304. package/vendor/dsh-world/src/life/journal.ts +44 -0
  305. package/vendor/dsh-world/src/life/lifeStore.ts +70 -0
  306. package/vendor/dsh-world/src/life/messages.ts +44 -0
  307. package/vendor/dsh-world/src/life/notify.ts +47 -0
  308. package/vendor/dsh-world/src/life/pricing.ts +37 -0
  309. package/vendor/dsh-world/src/life/runtime.ts +318 -0
  310. package/vendor/dsh-world/src/life/toolRegistry.ts +48 -0
  311. package/vendor/dsh-world/src/life/tools.ts +61 -0
  312. package/vendor/dsh-world/src/life/types.ts +19 -0
  313. package/vendor/dsh-world/src/persona.ts +26 -0
  314. package/vendor/dsh-world/src/promptSection.ts +71 -0
  315. package/vendor/dsh-world/src/qqScope.ts +51 -0
  316. package/vendor/dsh-world/src/runtime.ts +172 -0
  317. package/vendor/dsh-world/src/self.ts +32 -0
  318. package/vendor/dsh-world/src/sourceArchive.ts +132 -0
  319. package/vendor/dsh-world/src/store.ts +170 -0
  320. package/vendor/dsh-world/src/timeContext.ts +13 -0
  321. package/vendor/dsh-world/src/types.ts +112 -0
  322. package/vendor/dsh-world/src/worldPrompt.ts +64 -0
  323. package/vendor/dsh-world/src/worldSwitch.ts +82 -0
  324. package/vendor/dsh-world/templates/alarm.md +49 -0
  325. package/vendor/dsh-world/templates/world-prompt.md +7 -0
  326. package/vendor/dsh-world/tests/archive.test.ts +57 -0
  327. package/vendor/dsh-world/tests/archiveScope.test.ts +86 -0
  328. package/vendor/dsh-world/tests/bridge.test.ts +211 -0
  329. package/vendor/dsh-world/tests/channelSessions.test.ts +79 -0
  330. package/vendor/dsh-world/tests/clientHooks.test.ts +103 -0
  331. package/vendor/dsh-world/tests/compaction.test.ts +141 -0
  332. package/vendor/dsh-world/tests/console.test.ts +202 -0
  333. package/vendor/dsh-world/tests/consoleClient.test.ts +101 -0
  334. package/vendor/dsh-world/tests/enableCompaction.test.ts +19 -0
  335. package/vendor/dsh-world/tests/fixtures.ts +6 -0
  336. package/vendor/dsh-world/tests/history.test.ts +100 -0
  337. package/vendor/dsh-world/tests/hostFixture.ts +46 -0
  338. package/vendor/dsh-world/tests/lifeActivity.test.ts +70 -0
  339. package/vendor/dsh-world/tests/lifeAlarm.test.ts +87 -0
  340. package/vendor/dsh-world/tests/lifeDiary.test.ts +33 -0
  341. package/vendor/dsh-world/tests/lifeMessages.test.ts +61 -0
  342. package/vendor/dsh-world/tests/lifeNotify.test.ts +46 -0
  343. package/vendor/dsh-world/tests/lifeParts.test.ts +45 -0
  344. package/vendor/dsh-world/tests/lifeRuntime.test.ts +660 -0
  345. package/vendor/dsh-world/tests/lifeStore.test.ts +90 -0
  346. package/vendor/dsh-world/tests/lifeTools.test.ts +53 -0
  347. package/vendor/dsh-world/tests/outlets.test.ts +85 -0
  348. package/vendor/dsh-world/tests/panel.test.ts +85 -0
  349. package/vendor/dsh-world/tests/plugin.test.ts +614 -0
  350. package/vendor/dsh-world/tests/pricing.test.ts +21 -0
  351. package/vendor/dsh-world/tests/qq.test.ts +121 -0
  352. package/vendor/dsh-world/tests/qqSessionMode.test.ts +97 -0
  353. package/vendor/dsh-world/tests/qqSupervisor.test.ts +149 -0
  354. package/vendor/dsh-world/tests/sourceArchive.test.ts +58 -0
  355. package/vendor/dsh-world/tests/store.test.ts +82 -0
  356. package/vendor/dsh-world/tests/storeWriter.ts +5 -0
  357. package/vendor/dsh-world/tests/timeContext.test.ts +15 -0
  358. package/vendor/dsh-world/tests/wechat.test.ts +254 -0
  359. package/vendor/dsh-world/tests/wechatImages.test.ts +130 -0
  360. package/vendor/dsh-world/tests/wechatSending.test.ts +142 -0
  361. package/vendor/dsh-world/tests/wechatSupervisor.test.ts +91 -0
  362. package/vendor/dsh-world/tests/worldPrompt.test.ts +201 -0
  363. package/vendor/dsh-world/tsconfig.build.json +5 -0
  364. package/vendor/dsh-world/tsconfig.json +8 -0
@@ -0,0 +1,527 @@
1
+ /**
2
+ * dsh-agent-md —— QQ 网关联动(宿主侧,纯 node: 内置模块)。
3
+ *
4
+ * 要解决的问题:
5
+ * DSH 的同一个会话同一时刻只允许**一个进程**持有写租约(session.lock),
6
+ * 所以「把网页里的某个对话接到 QQ」只有在 QQ 网关与本进程**同进程**时才成立:
7
+ * QQ 消息 → `agents.get(sessionId)` 命中同一个 live agent → 对话里出现用户消息;
8
+ * 网页里跑出来的回复 → `session/event` → 网关按 sessionId 找到记录 → 发回 QQ。
9
+ *
10
+ * 网关(@tencent-connect/dsh-qqbot)把「QQ peer → sessionId」的映射存在
11
+ * `~/.dsh-qqbot/model-prefs.json` 的 `sessionIds` 里,并且**只在构造时读一次**。
12
+ * 所以本模块的做法是:
13
+ * 1. 停掉 im-qqbot 这一行(释放它的会话记录、断掉 websocket);
14
+ * 2. 写 prefs(`qqbot:<appId>:<scope>:<peer>` → 目标 sessionId);
15
+ * 3. 重新起这一行,新的 SessionManager 从磁盘读回映射;
16
+ * 4. 下一条 QQ 消息就会直接落进目标对话。
17
+ *
18
+ * 绑定前的原始值记在 `<DSH_HOME>/agents/qq-bindings.json`,解绑时原样还回去。
19
+ *
20
+ * 本文件只 import node: 内置模块与同目录 ./persona.js(本地 link: 安装时 Node
21
+ * 以真实路径解析,裸包名会解析失败)。
22
+ */
23
+
24
+ import { mkdirSync, readFileSync, renameSync, writeFileSync } from 'node:fs'
25
+ import { homedir } from 'node:os'
26
+ import { dirname, join } from 'node:path'
27
+
28
+ import { agentsRoot } from './persona.js'
29
+
30
+ /** QQ 网关插件在 profile 里的条目 id(bundle 补丁里写死的)。 */
31
+ export const QQ_ENTRY_ID = 'im-qqbot'
32
+ /** QQ 网关插件包名。 */
33
+ export const QQ_PLUGIN = '@tencent-connect/dsh-qqbot'
34
+ /** prefs 里 sessionKey 的前缀。 */
35
+ const KEY_PREFIX = 'qqbot:'
36
+
37
+ /**
38
+ * QQ 网关自己的数据目录。
39
+ *
40
+ * 网关插件用 `homedir()/.dsh-qqbot`(与 DSH_HOME 无关),这里必须一致;
41
+ * `DSH_QQBOT_HOME` 是给测试用的覆盖点(生产环境不会设置它)。
42
+ */
43
+ export function qqBotHome() {
44
+ const fromEnv = typeof process.env.DSH_QQBOT_HOME === 'string' ? process.env.DSH_QQBOT_HOME.trim() : ''
45
+ return fromEnv !== '' ? fromEnv : join(homedir(), '.dsh-qqbot')
46
+ }
47
+
48
+ /** 网关的 per-peer 偏好文件。 */
49
+ export function qqPrefsPath() {
50
+ return join(qqBotHome(), 'model-prefs.json')
51
+ }
52
+
53
+ /** 本插件自己的绑定记录(用来解绑时还原)。 */
54
+ export function bindingsPath() {
55
+ return join(agentsRoot(), 'qq-bindings.json')
56
+ }
57
+
58
+ /**
59
+ * QQ 专属记忆的「会话清单」:dsh-world 的 QQ 作用域只认这里列出的会话。
60
+ *
61
+ * 每次绑定都把「这一次的目标会话」和「绑定前的旧会话」一起记下来 —— 于是新的 QQ 对话能读到
62
+ * 上一次 QQ 对话里说过的话;没被绑定过的对话既不读也不写这份记忆。
63
+ */
64
+ export function qqMemoryPath() {
65
+ return join(agentsRoot(), 'qq-memory.json')
66
+ }
67
+
68
+ /** 读会话清单(坏文件回退空表)。 */
69
+ export function readQqMemorySessions() {
70
+ const raw = readJson(qqMemoryPath())
71
+ if (raw === null || typeof raw !== 'object' || !Array.isArray(raw.sessions)) return []
72
+ return raw.sessions.filter((id) => typeof id === 'string' && id !== '')
73
+ }
74
+
75
+ /**
76
+ * 当前真正「住着」QQ 的那个对话。
77
+ *
78
+ * `sessions` 是**归档来源**(当前 + 历史上用过的 QQ 对话),`current` 只放当前绑定的那一个:
79
+ * 记忆块只注入 current,旧对话只供阅读,不会被写入新的记忆块。
80
+ */
81
+ export function readQqMemoryCurrent() {
82
+ const raw = readJson(qqMemoryPath())
83
+ if (raw === null || typeof raw !== 'object' || typeof raw.current !== 'string') return ''
84
+ return raw.current
85
+ }
86
+
87
+ /**
88
+ * 把若干会话记进 QQ 专属记忆清单(去重、只留最近 30 个)。
89
+ * @returns {string[]} 写入后的完整清单
90
+ */
91
+ export function recordQqMemorySessions(ids, current) {
92
+ const next = []
93
+ for (const id of Array.isArray(ids) ? ids : []) {
94
+ if (typeof id !== 'string') continue
95
+ const trimmed = id.trim()
96
+ if (trimmed === '' || next.includes(trimmed)) continue
97
+ next.push(trimmed)
98
+ }
99
+ for (const id of readQqMemorySessions()) {
100
+ if (!next.includes(id)) next.push(id)
101
+ }
102
+ const kept = next.slice(0, 30)
103
+ const active = typeof current === 'string' ? current.trim() : readQqMemoryCurrent()
104
+ try {
105
+ writeJson(qqMemoryPath(), { version: 1, current: active, sessions: kept, updatedAt: new Date().toISOString() })
106
+ } catch {
107
+ // 记忆清单写不进去不能拦住绑定本身
108
+ }
109
+ return kept
110
+ }
111
+
112
+ /** 解绑时把「当前对话」清掉:历史会话仍留在 sessions 里供以后阅读。 */
113
+ export function setQqMemoryCurrent(current) {
114
+ const active = typeof current === 'string' ? current.trim() : ''
115
+ try {
116
+ writeJson(qqMemoryPath(), {
117
+ version: 1,
118
+ current: active,
119
+ sessions: readQqMemorySessions(),
120
+ updatedAt: new Date().toISOString(),
121
+ })
122
+ } catch {
123
+ // 同上
124
+ }
125
+ return active
126
+ }
127
+
128
+ function readJson(file) {
129
+ try {
130
+ return JSON.parse(readFileSync(file, 'utf8'))
131
+ } catch {
132
+ return null
133
+ }
134
+ }
135
+
136
+ /** 原子写:先写 .tmp 再 rename,避免网关读到半截 JSON。 */
137
+ function writeJson(file, value) {
138
+ mkdirSync(dirname(file), { recursive: true })
139
+ const tmp = `${file}.tmp-${process.pid}`
140
+ writeFileSync(tmp, `${JSON.stringify(value, null, 2)}\n`, 'utf8')
141
+ renameSync(tmp, file)
142
+ }
143
+
144
+ /**
145
+ * 读网关的 prefs(坏文件/缺文件都回退空表:网关的偏好坏了不能拖垮设置页)。
146
+ * @returns {{overrides: object, sessionIds: object, presets: object}}
147
+ */
148
+ export function readQqPrefs() {
149
+ const raw = readJson(qqPrefsPath())
150
+ const out = { overrides: {}, sessionIds: {}, presets: {} }
151
+ if (raw === null || typeof raw !== 'object') return out
152
+ for (const key of ['overrides', 'sessionIds', 'presets']) {
153
+ const table = raw[key]
154
+ if (table !== null && typeof table === 'object' && !Array.isArray(table)) out[key] = table
155
+ }
156
+ return out
157
+ }
158
+
159
+ /** 写回 prefs(只保留网关认识的三个表)。 */
160
+ export function writeQqPrefs(prefs) {
161
+ writeJson(qqPrefsPath(), {
162
+ overrides: prefs.overrides || {},
163
+ sessionIds: prefs.sessionIds || {},
164
+ presets: prefs.presets || {},
165
+ })
166
+ }
167
+
168
+ /**
169
+ * 解析 sessionKey:`qqbot:<appId>:<scope>:<peerId>`。
170
+ * @returns {{key: string, appId: string, scope: string, peerId: string} | null}
171
+ */
172
+ export function parsePeerKey(key) {
173
+ if (typeof key !== 'string' || !key.startsWith(KEY_PREFIX)) return null
174
+ const parts = key.split(':')
175
+ if (parts.length < 4) return null
176
+ const appId = parts[1]
177
+ const scope = parts[2]
178
+ const peerId = parts.slice(3).join(':')
179
+ if (appId === '' || peerId === '') return null
180
+ if (scope !== 'c2c' && scope !== 'group') return null
181
+ return { key, appId, scope, peerId }
182
+ }
183
+
184
+ /** 拼 sessionKey(与网关 SessionManager.sessionKey 完全一致)。 */
185
+ export function peerKeyFor(appId, scope, peerId) {
186
+ return `${KEY_PREFIX}${appId}:${scope}:${peerId}`
187
+ }
188
+
189
+ /**
190
+ * 列出网关已经记下的 QQ 账号(= prefs.sessionIds 的 key)。
191
+ *
192
+ * ⚠️ 网关只在「显式换过会话」时才把 key 落盘(`/new`、切模型、fork);
193
+ * 只是聊过天不会写。所以空列表是正常状态,界面要给一句「先在 QQ 里发 /new」的提示。
194
+ */
195
+ export function listQqPeers(prefs) {
196
+ const table = (prefs || readQqPrefs()).sessionIds
197
+ const peers = []
198
+ for (const [key, sessionId] of Object.entries(table)) {
199
+ const info = parsePeerKey(key)
200
+ if (info === null) continue
201
+ peers.push({ ...info, sessionId: typeof sessionId === 'string' ? sessionId : '' })
202
+ }
203
+ peers.sort((a, b) => (a.scope === b.scope ? a.peerId.localeCompare(b.peerId) : a.scope === 'c2c' ? -1 : 1))
204
+ return peers
205
+ }
206
+
207
+ /** 读绑定记录(坏文件回退空表)。 */
208
+ export function readBindings() {
209
+ const raw = readJson(bindingsPath())
210
+ if (raw !== null && typeof raw === 'object' && Array.isArray(raw.bindings)) {
211
+ return raw.bindings.filter((b) => b !== null && typeof b === 'object' && typeof b.peerKey === 'string' && b.peerKey !== '')
212
+ }
213
+ return []
214
+ }
215
+
216
+ /** 写绑定记录。 */
217
+ export function writeBindings(bindings) {
218
+ writeJson(bindingsPath(), { version: 1, bindings: Array.isArray(bindings) ? bindings : [] })
219
+ }
220
+
221
+ /** 找某个 peer 的绑定记录。 */
222
+ export function findBinding(peerKey) {
223
+ return readBindings().find((b) => b.peerKey === peerKey) || null
224
+ }
225
+
226
+ /**
227
+ * 写入一条绑定:prefs 里的 sessionId 指向目标对话,同时在本地记下原值。
228
+ *
229
+ * 幂等:同一个 peer 再绑一个对话只更新目标,`originalSessionId` 保留第一次绑定前的值。
230
+ * @returns {{record: object, previousSessionId: string|null, sessionIds: object}}
231
+ */
232
+ export function applyBinding(options) {
233
+ const peerKey = String(options.peerKey || '')
234
+ const sessionId = String(options.sessionId || '')
235
+ const info = parsePeerKey(peerKey)
236
+ if (info === null) throw new Error(`非法的 QQ peer key:${peerKey}`)
237
+ if (sessionId === '') throw new Error('缺少 sessionId')
238
+
239
+ const prefs = readQqPrefs()
240
+ const bindings = readBindings()
241
+ const hasKey = Object.prototype.hasOwnProperty.call(prefs.sessionIds, peerKey)
242
+ const previousSessionId = hasKey && typeof prefs.sessionIds[peerKey] === 'string' ? prefs.sessionIds[peerKey] : null
243
+
244
+ let record = bindings.find((b) => b.peerKey === peerKey)
245
+ if (record === undefined) {
246
+ record = {
247
+ peerKey,
248
+ appId: info.appId,
249
+ scope: info.scope,
250
+ peerId: info.peerId,
251
+ originalSessionId: previousSessionId,
252
+ sessionId,
253
+ cwd: typeof options.cwd === 'string' ? options.cwd : '',
254
+ boundAt: new Date().toISOString(),
255
+ }
256
+ bindings.push(record)
257
+ } else {
258
+ record.sessionId = sessionId
259
+ record.appId = info.appId
260
+ record.scope = info.scope
261
+ record.peerId = info.peerId
262
+ if (typeof options.cwd === 'string' && options.cwd !== '') record.cwd = options.cwd
263
+ record.boundAt = new Date().toISOString()
264
+ }
265
+
266
+ prefs.sessionIds[peerKey] = sessionId
267
+ writeQqPrefs(prefs)
268
+ writeBindings(bindings)
269
+ return { record, previousSessionId, sessionIds: prefs.sessionIds }
270
+ }
271
+
272
+ /**
273
+ * 解除绑定:把 prefs 里的 sessionId 还原成绑定前的值(原本没有就删掉)。
274
+ * @returns {{record: object|null, restoredSessionId: string|null}}
275
+ */
276
+ export function removeBinding(peerKey) {
277
+ const prefs = readQqPrefs()
278
+ const bindings = readBindings()
279
+ const index = bindings.findIndex((b) => b.peerKey === peerKey)
280
+ const record = index >= 0 ? bindings[index] : null
281
+ if (index >= 0) bindings.splice(index, 1)
282
+
283
+ const restored = record !== null && typeof record.originalSessionId === 'string' ? record.originalSessionId : null
284
+ if (restored === null || restored === '') delete prefs.sessionIds[peerKey]
285
+ else prefs.sessionIds[peerKey] = restored
286
+
287
+ writeQqPrefs(prefs)
288
+ writeBindings(bindings)
289
+ return { record, restoredSessionId: restored }
290
+ }
291
+
292
+ // ---- 宿主插件(loader / 网关条目)------------------------------------------
293
+
294
+ /** 取一个可选服务:写进 inject 会让 headless 宿主整个插件挂在等待状态。 */
295
+ function serviceOf(ctx, name) {
296
+ if (ctx === null || ctx === undefined) return undefined
297
+ try {
298
+ if (typeof ctx.get === 'function') {
299
+ const service = ctx.get(name)
300
+ if (service !== undefined && service !== null) return service
301
+ }
302
+ const direct = ctx[name]
303
+ return direct === undefined ? undefined : direct
304
+ } catch {
305
+ return undefined
306
+ }
307
+ }
308
+
309
+ /**
310
+ * 在 loader 条目树里找 QQ 网关。
311
+ *
312
+ * 条目 id 可能是 `im-qqbot`,也可能被 include 包成 `include:im-qqbot`,
313
+ * 所以按**包名**扫,比猜 id 稳。
314
+ * @returns {{entry: object|null, loader: object|undefined}}
315
+ */
316
+ export function findQqEntry(ctx) {
317
+ const loader = serviceOf(ctx, 'loader')
318
+ if (loader === undefined || loader === null || typeof loader.entries !== 'function') {
319
+ return { entry: null, loader }
320
+ }
321
+ try {
322
+ for (const entry of loader.entries()) {
323
+ const name = entry !== null && entry !== undefined && entry.options !== undefined && entry.options !== null
324
+ ? entry.options.name
325
+ : undefined
326
+ if (name === QQ_PLUGIN || (typeof name === 'string' && name.startsWith(`${QQ_PLUGIN}/`))) {
327
+ return { entry, loader }
328
+ }
329
+ }
330
+ } catch {
331
+ return { entry: null, loader }
332
+ }
333
+ return { entry: null, loader }
334
+ }
335
+
336
+ /**
337
+ * 网关条目的生命周期阶段(Cordis FiberState:0 PENDING / 1 LOADING / 2 ACTIVE /
338
+ * 3 FAILED / 4 DISPOSED / 5 UNLOADING)。
339
+ *
340
+ * 单行重载是异步的:`entry.init()` 返回时 apply 可能还在跑,所以界面需要区分
341
+ * 「启动中」和「没在跑」——否则刚绑完会短暂显示成红的。
342
+ */
343
+ export function gatewayPhase(entry) {
344
+ if (entry === null || entry === undefined) return 'missing'
345
+ if (entry.disabled === true) return 'disabled'
346
+ const fiber = entry.fiber
347
+ if (fiber === null || fiber === undefined) return 'stopped'
348
+ if (fiber.state === 2) return 'active'
349
+ if (fiber.state === 0 || fiber.state === 1) return 'loading'
350
+ if (fiber.state === 3) return 'failed'
351
+ return 'stopped'
352
+ }
353
+
354
+ /** 网关条目是否真的在运行。 */
355
+ function entryRunning(entry) {
356
+ return gatewayPhase(entry) === 'active'
357
+ }
358
+
359
+ /** 网关条目当前配置(只取界面要用的几项)。 */
360
+ function entryConfig(entry) {
361
+ if (entry === null || entry === undefined) return {}
362
+ const options = entry.options
363
+ const config = options !== null && options !== undefined ? options.config : undefined
364
+ return config !== null && typeof config === 'object' ? config : {}
365
+ }
366
+
367
+ /**
368
+ * 设置页 / 接口用的 QQ 状态。
369
+ *
370
+ * `installed` = 本进程的 Loader 里有 QQ 网关这一行;`running` = 该行已激活。
371
+ * 两者都为 false 时界面直接说「这台 DSH 没加载 QQ 网关」,而不是让用户猜。
372
+ */
373
+ export function qqStatus(ctx) {
374
+ const { entry, loader } = findQqEntry(ctx)
375
+ const prefs = readQqPrefs()
376
+ const bindings = readBindings()
377
+ const config = entryConfig(entry)
378
+ const peers = listQqPeers(prefs)
379
+ // 绑定过但 prefs 里没有 key 的(手写记录/被网关覆盖):也列出来,别让绑定凭空消失
380
+ for (const binding of bindings) {
381
+ if (peers.some((p) => p.key === binding.peerKey)) continue
382
+ const info = parsePeerKey(binding.peerKey)
383
+ if (info === null) continue
384
+ peers.push({ ...info, sessionId: typeof binding.sessionId === 'string' ? binding.sessionId : '' })
385
+ }
386
+ for (const peer of peers) {
387
+ const binding = bindings.find((b) => b.peerKey === peer.key)
388
+ peer.binding = binding !== undefined ? binding : null
389
+ peer.boundSessionId = binding !== undefined && typeof binding.sessionId === 'string' ? binding.sessionId : null
390
+ }
391
+ return {
392
+ installed: entry !== null && entry !== undefined,
393
+ running: entryRunning(entry),
394
+ phase: gatewayPhase(entry),
395
+ canReload: loader !== undefined && loader !== null && typeof loader.entries === 'function',
396
+ entryId: entry !== null && entry !== undefined && entry.options !== undefined && entry.options !== null ? String(entry.options.id ?? '') : '',
397
+ appId: typeof config.appId === 'string' && config.appId !== '' ? config.appId : (peers.length > 0 ? peers[0].appId : ''),
398
+ gatewayCwd: typeof config.cwd === 'string' ? config.cwd : '',
399
+ prefsPath: qqPrefsPath(),
400
+ memory: {
401
+ sessionsPath: qqMemoryPath(),
402
+ current: readQqMemoryCurrent(),
403
+ sessions: readQqMemorySessions(),
404
+ mirrorPath: join(agentsRoot(), 'qq-memory.md'),
405
+ },
406
+ bindings,
407
+ peers,
408
+ }
409
+ }
410
+
411
+ /**
412
+ * 停掉网关的那一个 fiber。
413
+ *
414
+ * ⚠️ 这里**不能**直接 `fiber.dispose()`:Loader 的 `internal/plugin` 监听器会把
415
+ * 「不是经由 registry 删除的卸载」当成意外掉线,顺手把 `options.disabled` 写成
416
+ * true 并持久化——下一次就再也起不来了(2026-10-26 实测踩过)。必须像 HMR 那样
417
+ * 先 `registry.delete(plugin)`:Loader 看到注册表里已经没有了,才会跳过那条路径。
418
+ */
419
+ async function stopGatewayEntry(entry) {
420
+ if (entry === null || entry === undefined) return { stopped: false, ticket: null }
421
+ const fiber = entry.fiber
422
+ if (fiber === null || fiber === undefined) return { stopped: false, ticket: null }
423
+ const runtime = fiber.runtime
424
+ const plugin = runtime !== null && runtime !== undefined ? runtime.callback : undefined
425
+ const parent = fiber.parent
426
+ const registry = parent !== null && parent !== undefined ? parent.registry : undefined
427
+ if (plugin === undefined || registry === undefined || typeof registry.delete !== 'function') {
428
+ // 老版本 Cordis:没有注册表可删。退回直接 dispose(可能留下 disabled,由用户重启恢复)
429
+ try {
430
+ if (typeof fiber.dispose === 'function') await fiber.dispose()
431
+ return { stopped: true, ticket: null }
432
+ } catch {
433
+ return { stopped: false, ticket: null }
434
+ }
435
+ }
436
+ const ticket = { plugin, config: fiber.config, parent, entry }
437
+ try {
438
+ registry.delete(plugin)
439
+ if (typeof fiber.await === 'function') await fiber.await().catch(() => {})
440
+ return { stopped: true, ticket }
441
+ } catch {
442
+ // 停不下来也继续:绑定写进去,重启后生效
443
+ return { stopped: false, ticket }
444
+ }
445
+ }
446
+
447
+ /**
448
+ * 把网关重新起起来。
449
+ *
450
+ * 正常路径:`entry.init()` 会重新 import(走模块缓存)并用 loader 的 ctx 重新
451
+ * `registry.plugin(...)`;新 fiber 的 `entry` 由 Loader 的 `internal/plugin` 监听器
452
+ * 自己补上,所以不需要手工接线(HMR 里那几行是给「换模块」场景用的)。
453
+ */
454
+ async function startGatewayEntry(ctx, entry) {
455
+ if (entry === null || entry === undefined) {
456
+ return { ok: false, code: 'not-installed', message: '这个 DSH 进程没有加载 QQ 网关插件(@tencent-connect/dsh-qqbot)。' }
457
+ }
458
+ if (entry.disabled === true) {
459
+ return { ok: false, code: 'disabled', message: 'QQ 网关这一行在 profile 里被禁用了。' }
460
+ }
461
+ if (typeof entry.init !== 'function') {
462
+ return { ok: false, code: 'no-init', message: '当前 Loader 版本不支持单行重载,重启 DSH 后生效。' }
463
+ }
464
+ try {
465
+ await entry.init()
466
+ // 等 apply 收敛(最多 3 秒):这样接口返回的 qq.running 就是真实状态,
467
+ // 而不是「刚 init、还没激活」的瞬时值。
468
+ const fiber = entry.fiber
469
+ if (fiber !== null && fiber !== undefined && typeof fiber.await === 'function') {
470
+ let timer
471
+ await Promise.race([
472
+ Promise.resolve().then(() => fiber.await()).catch(() => {}),
473
+ new Promise((resolve) => {
474
+ timer = setTimeout(resolve, 3000)
475
+ if (typeof timer.unref === 'function') timer.unref()
476
+ }),
477
+ ])
478
+ if (timer !== undefined) clearTimeout(timer)
479
+ }
480
+ return { ok: true, code: 'ok', message: 'QQ 网关已按新绑定重载。' }
481
+ } catch (error) {
482
+ const message = String((error && error.message) || error)
483
+ return { ok: false, code: 'reload-failed', message: `重载 QQ 网关失败:${message}(绑定已写入,重启 DSH 后生效)` }
484
+ }
485
+ }
486
+
487
+ /**
488
+ * 重启网关这一行(先安全卸载,再重新 init)。
489
+ *
490
+ * 只有这样才能让新的 SessionManager 从磁盘读回我们刚写的映射。
491
+ * 失败不抛:调用方把「已写入绑定,但需要重启 DSH」如实告诉用户。
492
+ * @returns {Promise<{ok: boolean, code: string, message: string}>}
493
+ */
494
+ export async function restartQqGateway(ctx) {
495
+ const { entry } = findQqEntry(ctx)
496
+ await stopGatewayEntry(entry)
497
+ return startGatewayEntry(ctx, entry)
498
+ }
499
+
500
+ /**
501
+ * 先停网关、再写 prefs、最后重新起网关。
502
+ *
503
+ * 顺序很关键:PrefsStore 在内存里持有整张 sessionIds 表,任何一次 `write()`
504
+ * (切模型、/new 等)都会用内存值覆盖磁盘。先把网关停掉,就不会出现
505
+ * 「刚写进去的绑定被旧实例覆盖」的竞态。
506
+ */
507
+ export async function bindQqPeer(ctx, options) {
508
+ const { entry } = findQqEntry(ctx)
509
+ await stopGatewayEntry(entry)
510
+ const applied = applyBinding(options)
511
+ // 记忆清单:当前目标 + 绑定前的旧会话(上一次 QQ 用的对话),只写这里列出的会话。
512
+ recordQqMemorySessions([options.sessionId, applied.previousSessionId].filter((id) => typeof id === 'string' && id !== ''), options.sessionId)
513
+ const reload = await startGatewayEntry(ctx, entry)
514
+ return { ...applied, reload }
515
+ }
516
+
517
+ /** 解绑:同样先停网关、还原 prefs、再起网关。 */
518
+ export async function unbindQqPeer(ctx, peerKey) {
519
+ const { entry } = findQqEntry(ctx)
520
+ await stopGatewayEntry(entry)
521
+ const removed = removeBinding(peerKey)
522
+ // 解绑后没有「当前 QQ 对话」了:历史仍保留,但不再往任何会话里注入记忆。
523
+ setQqMemoryCurrent('')
524
+ const reload = await startGatewayEntry(ctx, entry)
525
+ return { ...removed, reload }
526
+ }
527
+
@@ -0,0 +1,50 @@
1
+ {
2
+ "name": "dsh-agent-md",
3
+ "version": "0.2.0",
4
+ "private": true,
5
+ "type": "module",
6
+ "description": "AGENT.md 人格配置 —— 像 VS Code 那样用 Markdown 配置模型人格/性格:全局一份 + 每个项目一份(项目覆盖全局),可在设置页可视化编辑,也能一键打开原文件。",
7
+ "keywords": [
8
+ "deepseek",
9
+ "deepseek-harness",
10
+ "dsh",
11
+ "dsh-plugin",
12
+ "agent",
13
+ "persona",
14
+ "agent-md"
15
+ ],
16
+ "main": "lib/index.js",
17
+ "exports": {
18
+ ".": "./lib/index.js",
19
+ "./client": "./lib/client.js",
20
+ "./cordis.patch.yml": "./cordis.patch.yml",
21
+ "./package.json": "./package.json"
22
+ },
23
+ "files": [
24
+ "lib",
25
+ "cordis.patch.yml",
26
+ "README.md"
27
+ ],
28
+ "peerDependencies": {
29
+ "@deepseek-ai/cordis": "^4.0.1",
30
+ "react": "^18.3.1"
31
+ },
32
+ "dsh": {
33
+ "bundle": {
34
+ "patch": "./cordis.patch.yml"
35
+ },
36
+ "client": {
37
+ "platform": "web",
38
+ "inject": []
39
+ }
40
+ },
41
+ "repository": {
42
+ "type": "git",
43
+ "url": "git+https://github.com/wwsmiler1-bit/dsh-agent-md.git"
44
+ },
45
+ "homepage": "https://github.com/wwsmiler1-bit/dsh-agent-md#readme",
46
+ "bugs": {
47
+ "url": "https://github.com/wwsmiler1-bit/dsh-agent-md/issues"
48
+ },
49
+ "license": "MIT"
50
+ }
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 c1overzz
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,18 @@
1
+ # 第三方代码与署名说明
2
+
3
+ 本插件(`dsh-bili-scroll` / 刷B站)本体以 **MIT** 协议发布,正文见仓库根目录的 `LICENSE`。
4
+
5
+ ## 内含第三方代码
6
+
7
+ - 目录:`vendor/bilibili-mcp/`
8
+ - 项目:**bilibili-mcp**
9
+ - 许可证:**MIT**,Copyright (c) 2026 AGI_Ananas
10
+ - 完整许可见该目录下的 `LICENSE`
11
+
12
+ ## 关于版权署名
13
+
14
+ `LICENSE` 第一行写的是 `Copyright (c) 2026 c1overzz`。
15
+ 如果你要基于本仓库做二次分发,保留这一行和 MIT 正文即可,不必另行取得授权(MIT 本身就允许改、再发、商用)。
16
+
17
+ ---
18
+ *本文件只是说明,不构成额外限制。*
@@ -0,0 +1,20 @@
1
+ # ============================================================================
2
+ # dsh-bili-scroll —— DSH bundle patch(插件**自带**的挂载声明)
3
+ # ============================================================================
4
+ # 这就是"标准 DSH 插件"的样子:包自己声明要往 profile 的配置树里插什么。
5
+ # 装上之后,profile 只要在 `dsh.profile.bundles` 里列出本包名即生效,
6
+ # 不用再手改 profile 自己的 cordis.patch.yml:
7
+ #
8
+ # dsh plugin --profile web add dsh-bili-scroll
9
+ # (本地开发时用:dsh plugin --profile web add link:<你自己的插件目录>)
10
+ #
11
+ # 组成顺序:每个 bundle 的 patch 按 `dsh.profile.bundles` 顺序叠
12
+ # → 再叠 profile 自己那一层的 cordis.patch.yml(只有那层是热重载)
13
+ # ============================================================================
14
+
15
+ - insert:
16
+ - id: bili-scroll
17
+ name: dsh-bili-scroll
18
+ config:
19
+ # 真正的用户配置在插件自己的 config 里(设置页可改),这里只放默认值
20
+ enabled: true