@cxyhhhhh/dsh-qqbot 0.1.0 → 0.3.0-dev.202608160954

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 (177) hide show
  1. package/.orange-ci.yml +68 -0
  2. package/CHANGELOG.md +39 -0
  3. package/LICENSE +21 -0
  4. package/README.md +37 -93
  5. package/README_EN.md +142 -0
  6. package/a.txt +14 -0
  7. package/cordis.patch.yml +11 -3
  8. package/dist/commands/help.d.ts +11 -0
  9. package/dist/commands/help.d.ts.map +1 -0
  10. package/dist/commands/help.js +21 -0
  11. package/dist/commands/help.js.map +1 -0
  12. package/dist/commands/index.d.ts +13 -0
  13. package/dist/commands/index.d.ts.map +1 -0
  14. package/dist/commands/index.js +27 -0
  15. package/dist/commands/index.js.map +1 -0
  16. package/dist/commands/misc.d.ts +12 -0
  17. package/dist/commands/misc.d.ts.map +1 -0
  18. package/dist/commands/misc.js +30 -0
  19. package/dist/commands/misc.js.map +1 -0
  20. package/dist/commands/model.d.ts +7 -0
  21. package/dist/commands/model.d.ts.map +1 -0
  22. package/dist/commands/model.js +58 -0
  23. package/dist/commands/model.js.map +1 -0
  24. package/dist/commands/session.d.ts +10 -0
  25. package/dist/commands/session.d.ts.map +1 -0
  26. package/dist/commands/session.js +26 -0
  27. package/dist/commands/session.js.map +1 -0
  28. package/dist/commands/status.d.ts +8 -0
  29. package/dist/commands/status.d.ts.map +1 -0
  30. package/dist/commands/status.js +24 -0
  31. package/dist/commands/status.js.map +1 -0
  32. package/dist/commands/types.d.ts +12 -0
  33. package/dist/commands/types.d.ts.map +1 -0
  34. package/dist/commands/types.js +2 -0
  35. package/dist/commands/types.js.map +1 -0
  36. package/dist/config.d.ts +24 -2
  37. package/dist/config.d.ts.map +1 -1
  38. package/dist/config.js +17 -1
  39. package/dist/config.js.map +1 -1
  40. package/dist/features/history-store.d.ts +8 -0
  41. package/dist/features/history-store.d.ts.map +1 -0
  42. package/dist/features/history-store.js +24 -0
  43. package/dist/features/history-store.js.map +1 -0
  44. package/dist/gateway/bootstrap.d.ts +12 -0
  45. package/dist/gateway/bootstrap.d.ts.map +1 -0
  46. package/dist/gateway/bootstrap.js +73 -0
  47. package/dist/gateway/bootstrap.js.map +1 -0
  48. package/dist/gateway/index.d.ts +3 -0
  49. package/dist/gateway/index.d.ts.map +1 -0
  50. package/dist/gateway/index.js +3 -0
  51. package/dist/gateway/index.js.map +1 -0
  52. package/dist/gateway/middleware-setup.d.ts +12 -0
  53. package/dist/gateway/middleware-setup.d.ts.map +1 -0
  54. package/dist/gateway/middleware-setup.js +80 -0
  55. package/dist/gateway/middleware-setup.js.map +1 -0
  56. package/dist/index.d.ts +1 -0
  57. package/dist/index.d.ts.map +1 -1
  58. package/dist/index.js +27 -70
  59. package/dist/index.js.map +1 -1
  60. package/dist/middleware/attachment.d.ts +11 -0
  61. package/dist/middleware/attachment.d.ts.map +1 -0
  62. package/dist/middleware/attachment.js +17 -0
  63. package/dist/middleware/attachment.js.map +1 -0
  64. package/dist/model/index.d.ts +10 -0
  65. package/dist/model/index.d.ts.map +1 -0
  66. package/dist/model/index.js +9 -0
  67. package/dist/model/index.js.map +1 -0
  68. package/dist/model/model-resolver.d.ts +88 -0
  69. package/dist/model/model-resolver.d.ts.map +1 -0
  70. package/dist/model/model-resolver.js +151 -0
  71. package/dist/model/model-resolver.js.map +1 -0
  72. package/dist/model/prefs-store.d.ts +24 -0
  73. package/dist/model/prefs-store.d.ts.map +1 -0
  74. package/dist/model/prefs-store.js +94 -0
  75. package/dist/model/prefs-store.js.map +1 -0
  76. package/dist/model/settings-reader.d.ts +19 -0
  77. package/dist/model/settings-reader.d.ts.map +1 -0
  78. package/dist/model/settings-reader.js +76 -0
  79. package/dist/model/settings-reader.js.map +1 -0
  80. package/dist/model/types.d.ts +15 -0
  81. package/dist/model/types.d.ts.map +1 -0
  82. package/dist/model/types.js +5 -0
  83. package/dist/model/types.js.map +1 -0
  84. package/dist/session/idle-evictor.d.ts +18 -0
  85. package/dist/session/idle-evictor.d.ts.map +1 -0
  86. package/dist/session/idle-evictor.js +31 -0
  87. package/dist/session/idle-evictor.js.map +1 -0
  88. package/dist/session/index.d.ts +9 -0
  89. package/dist/session/index.d.ts.map +1 -0
  90. package/dist/session/index.js +8 -0
  91. package/dist/session/index.js.map +1 -0
  92. package/dist/session/session-manager.d.ts +44 -0
  93. package/dist/session/session-manager.d.ts.map +1 -0
  94. package/dist/session/session-manager.js +340 -0
  95. package/dist/session/session-manager.js.map +1 -0
  96. package/dist/{session-manager.d.ts → session/types.d.ts} +59 -41
  97. package/dist/session/types.d.ts.map +1 -0
  98. package/dist/session/types.js +2 -0
  99. package/dist/session/types.js.map +1 -0
  100. package/dist/setup.d.ts +24 -0
  101. package/dist/setup.d.ts.map +1 -0
  102. package/dist/setup.js +170 -0
  103. package/dist/setup.js.map +1 -0
  104. package/dist/shared/index.d.ts +7 -0
  105. package/dist/shared/index.d.ts.map +1 -0
  106. package/dist/shared/index.js +7 -0
  107. package/dist/shared/index.js.map +1 -0
  108. package/dist/shared/scope.d.ts +14 -0
  109. package/dist/shared/scope.d.ts.map +1 -0
  110. package/dist/shared/scope.js +12 -0
  111. package/dist/shared/scope.js.map +1 -0
  112. package/dist/shared/send-helper.d.ts +11 -0
  113. package/dist/shared/send-helper.d.ts.map +1 -0
  114. package/dist/shared/send-helper.js +13 -0
  115. package/dist/shared/send-helper.js.map +1 -0
  116. package/dist/shared/utils.d.ts +24 -0
  117. package/dist/shared/utils.d.ts.map +1 -0
  118. package/dist/shared/utils.js +77 -0
  119. package/dist/shared/utils.js.map +1 -0
  120. package/dist/transport/attachment.d.ts +18 -0
  121. package/dist/transport/attachment.d.ts.map +1 -0
  122. package/dist/transport/attachment.js +106 -0
  123. package/dist/transport/attachment.js.map +1 -0
  124. package/dist/transport/chunker.d.ts.map +1 -0
  125. package/dist/{chunker.js → transport/chunker.js} +0 -5
  126. package/dist/transport/chunker.js.map +1 -0
  127. package/dist/transport/events.d.ts +80 -0
  128. package/dist/transport/events.d.ts.map +1 -0
  129. package/dist/transport/events.js +62 -0
  130. package/dist/transport/events.js.map +1 -0
  131. package/dist/transport/inbound.d.ts +8 -0
  132. package/dist/transport/inbound.d.ts.map +1 -0
  133. package/dist/transport/inbound.js +248 -0
  134. package/dist/transport/inbound.js.map +1 -0
  135. package/dist/transport/index.d.ts +10 -0
  136. package/dist/transport/index.d.ts.map +1 -0
  137. package/dist/transport/index.js +10 -0
  138. package/dist/transport/index.js.map +1 -0
  139. package/dist/transport/outbound-buffer.d.ts +37 -0
  140. package/dist/transport/outbound-buffer.d.ts.map +1 -0
  141. package/dist/transport/outbound-buffer.js +63 -0
  142. package/dist/transport/outbound-buffer.js.map +1 -0
  143. package/dist/transport/outbound.d.ts +30 -0
  144. package/dist/transport/outbound.d.ts.map +1 -0
  145. package/dist/transport/outbound.js +143 -0
  146. package/dist/transport/outbound.js.map +1 -0
  147. package/dist/transport/streaming-writer.d.ts +47 -0
  148. package/dist/transport/streaming-writer.d.ts.map +1 -0
  149. package/dist/transport/streaming-writer.js +110 -0
  150. package/dist/transport/streaming-writer.js.map +1 -0
  151. package/dist/transport/tool-presenter.d.ts +38 -0
  152. package/dist/transport/tool-presenter.d.ts.map +1 -0
  153. package/dist/transport/tool-presenter.js +117 -0
  154. package/dist/transport/tool-presenter.js.map +1 -0
  155. package/dist/types.d.ts +11 -0
  156. package/dist/types.d.ts.map +1 -1
  157. package/package.json +12 -5
  158. package/scripts/prepare-test-pkg.js +23 -0
  159. package/tiezi.md +34 -0
  160. package/dist/chunker.d.ts.map +0 -1
  161. package/dist/chunker.js.map +0 -1
  162. package/dist/inbound.d.ts +0 -8
  163. package/dist/inbound.d.ts.map +0 -1
  164. package/dist/inbound.js +0 -71
  165. package/dist/inbound.js.map +0 -1
  166. package/dist/mention.d.ts +0 -15
  167. package/dist/mention.d.ts.map +0 -1
  168. package/dist/mention.js +0 -25
  169. package/dist/mention.js.map +0 -1
  170. package/dist/outbound.d.ts +0 -28
  171. package/dist/outbound.d.ts.map +0 -1
  172. package/dist/outbound.js +0 -162
  173. package/dist/outbound.js.map +0 -1
  174. package/dist/session-manager.d.ts.map +0 -1
  175. package/dist/session-manager.js +0 -201
  176. package/dist/session-manager.js.map +0 -1
  177. /package/dist/{chunker.d.ts → transport/chunker.d.ts} +0 -0
package/.orange-ci.yml ADDED
@@ -0,0 +1,68 @@
1
+ $:
2
+ tag_push:
3
+ - services:
4
+ - docker
5
+ docker:
6
+ image: node:24
7
+ runner:
8
+ network: devnet
9
+ stages:
10
+ - name: 安装依赖
11
+ script: npm install
12
+ - name: 构建项目
13
+ script: npm run build
14
+ - name: 配置 npm 官方源
15
+ script: npm config set registry https://registry.npmjs.org
16
+ - name: 配置 token
17
+ imports: https://git.woa.com/qq-ai/web/secret/blob/master/envs/npm/npmjs.txt
18
+ script: npm config set //registry.npmjs.org/:_authToken=$NPM_TOKEN
19
+ - name: 设置 npm 包版本号
20
+ script: npm version ${ORANGE_BRANCH} --no-git-tag-version --allow-same-version
21
+ - name: 发布 npm 包
22
+ script: npm publish --access public
23
+ - name: 生成通知
24
+ script: echo "@tencent-connect/dsh-qqbot@${ORANGE_BRANCH} 发布成功" > message.txt
25
+ - name: 发送通知
26
+ type: wework:message
27
+ options:
28
+ fromFile: message.txt
29
+
30
+ # ── master 分支:MR 检查 ──
31
+ master:
32
+ merge_request:
33
+ - docker:
34
+ image: node:24
35
+ wework:
36
+ silent: true
37
+ stages:
38
+ - name: 安装依赖
39
+ script: npm install
40
+ - name: TypeScript 类型检查
41
+ script: npx tsc --noEmit
42
+
43
+ # ── feat/fix 分支 push:内网发布 dev 版本 ──
44
+ (feat|fix)/**:
45
+ push:
46
+ - docker:
47
+ image: node:24
48
+ runner:
49
+ network: devnet
50
+ stages:
51
+ - name: 安装依赖
52
+ script: npm install
53
+ - name: 构建项目
54
+ script: npm run build
55
+ - name: 设置测试包名
56
+ script: npm run ci:prepare-test-pkg
57
+ - name: 设置测试版本
58
+ script: npm version "0.0.0-dev.${ORANGE_COMMIT_SHORT}" --no-git-tag-version
59
+ - name: 发布 npm 包
60
+ image: tencentcom/npm:latest
61
+ imports: https://git.woa.com/qq-ai/web/secret/blob/master/envs/npm/public.txt
62
+ settings:
63
+ username: $USER
64
+ password: $PWD
65
+ email: $EMAIL
66
+ registry: https://mirrors.tencent.com/npm/
67
+ folder: ./
68
+ tag: dev
package/CHANGELOG.md ADDED
@@ -0,0 +1,39 @@
1
+ # Changelog
2
+
3
+ 本文件从产品视角记录 dsh-qqbot 的重要更新,聚焦用户可感知的变化。
4
+
5
+ 格式遵循 [Keep a Changelog](https://keepachangelog.com/zh-CN/1.0.0/)。
6
+
7
+ ## [0.3.0] - 2026-08-15
8
+
9
+ ### 新功能
10
+
11
+ - **文件理解**:给机器人发送文件,它会自动下载并理解文件内容,支持解压、读取、分析等操作。
12
+ - **流式回复**:回复内容实时逐段显示,无需等待全部生成,体验更流畅自然。
13
+ - **过程可见**:机器人执行任务(运行命令、读写文件)时,用户可以看到它在做什么,不再是一个"黑盒"。
14
+ - **出错提示**:任务异常结束时,机器人会明确告知错误原因,不再出现"半截回复"或"毫无反应"。
15
+
16
+ ### 体验优化
17
+
18
+ - 群聊中正确显示发言者昵称,不再显示一串看不懂的字符。
19
+ - 群聊回复后自动清理历史上下文,避免多轮对话相互干扰。
20
+ - 语音消息识别后只保留文字,不再附带无效链接。
21
+ - 机器人现在会"真正动手"了:面对「下载、解压、安装」这类请求,会用工具实际执行,而不是只复述操作步骤。
22
+
23
+ ### 问题修复
24
+
25
+ - 修复机器人无法读写文件的问题(此前工作目录配置错误)。
26
+ - 修复流式回复中可能出现的重复内容、分片过少等显示问题。
27
+
28
+ ## [0.1.0] - 2026-08-14
29
+
30
+ ### 新功能
31
+
32
+ - **首个版本**:QQ 机器人接入 AI 助手,支持私聊与群聊对话。
33
+ - **模型切换**:支持切换不同的 AI 模型。
34
+ - **常用指令**:内置帮助、状态查询、会话管理等指令。
35
+ - **扫码绑定**:首次使用扫码即可完成机器人绑定,配置简单。
36
+
37
+ ### 问题修复
38
+
39
+ - 修复配置解析问题。
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Tencent Connect
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.
package/README.md CHANGED
@@ -1,6 +1,8 @@
1
1
  # @tencent-connect/dsh-qqbot
2
2
 
3
- 基于 [deepseek-harness](../deepseek-harness) (dsh) 的 QQ Bot IM 插件,将 QQ 消息平台作为 dsh agent 的前端协议驱动。
3
+ 基于 [deepseek-harness](https://github.com/deepseek-ai/deepseek-harness) (dsh) 的 QQ Bot IM 插件,将 QQ 消息平台作为 dsh agent 的前端协议驱动。
4
+
5
+ 中文 | [English](./README_EN.md)
4
6
 
5
7
  ## 架构
6
8
 
@@ -13,45 +15,19 @@ QQ 用户 → QQ WebSocket → dsh-im-qqbot → ctx.agents → dsh agent loop
13
15
 
14
16
  ## 安装
15
17
 
16
- ### 方式一:一键安装脚本
17
-
18
- ```bash
19
- # 安装默认包最新版本
20
- sh install.sh
21
-
22
- # 指定版本
23
- sh install.sh --version 0.2.0
24
-
25
- # 指定包名
26
- sh install.sh --pkg @myorg/my-qqbot-plugin
27
-
28
- # 指定包名 + 版本
29
- sh install.sh --pkg @myorg/my-qqbot-plugin --version 1.0.0
30
-
31
- # 指定 npm registry
32
- sh install.sh --registry https://registry.npmmirror.com
33
-
34
- # 查看帮助
35
- sh install.sh --help
36
- ```
37
-
38
- 脚本自动完成 dsh/pnpm 预检 + profile 初始化 + 插件注册。
39
-
40
- ### 方式二:手动执行
18
+ ### 方式一:手动执行
41
19
 
42
20
  ```bash
43
21
  # 安装到 profile
44
22
  dsh plugin --profile qqbot add @tencent-connect/dsh-qqbot
45
23
 
46
- # 配置环境变量
47
- export QQBOT_APPID="你的AppID"
48
- export QQBOT_SECRET="你的AppSecret"
49
-
50
24
  # 启动
51
25
  dsh --profile qqbot
52
26
  ```
53
27
 
54
- ### 方式三:本地路径安装
28
+ 首次启动时,插件检测到凭据未配置会自动进入扫码引导:终端输出二维码 → 手机 QQ 扫码绑定 → 凭据自动保存到 profile,后续启动无需再次扫码。
29
+
30
+ ### 方式二:本地路径安装
55
31
 
56
32
  ```bash
57
33
  # 构建
@@ -95,36 +71,44 @@ pnpm dsh web --patch /path/to/dsh-qqbot/cordis.dev.yml
95
71
 
96
72
  | 命令 | 说明 |
97
73
  |------|------|
98
- | `/reset` | 重置当前会话(清除上下文) |
99
- | `/clear` | 同 `/reset` |
74
+ | `/bot-reset` | 重置当前会话(清除上下文) |
75
+ | `/bot-model` | 查看或切换模型 |
76
+ | `/bot-status` | 查看当前会话状态 |
77
+ | `/bot-help` | 查看所有指令 |
100
78
 
101
79
  ## 核心模块
102
80
 
103
81
  ```
104
82
  src/
105
- ├── index.ts # Cordis 插件入口(async apply)
106
- ├── config.ts # 配置 Schema
107
- ├── session-manager.ts # QQ peer → Agent 映射(get → resume → create)
108
- ├── inbound.ts # QQ 入站消息 → agent.followup()
109
- ├── outbound.ts # session/event → QQ sendMarkdown
110
- ├── mention.ts # @mention 检测/清理
111
- ├── chunker.ts # Markdown 文本切分(代码块/表格感知)
112
- └── types.ts # 内部类型定义
83
+ ├── index.ts # Cordis 插件入口(async apply)
84
+ ├── config.ts # 配置 Schema
85
+ ├── types.ts # 全局类型定义
86
+ ├── setup.ts # 凭据绑定(扫码)
87
+ ├── transport/ # 传输层
88
+ │ ├── inbound.ts # QQ 入站消息 → agent.followup()
89
+ │ ├── outbound.ts # session/event → QQ sendMarkdown
90
+ │ ├── outbound-buffer.ts # 流式缓冲
91
+ │ └── chunker.ts # Markdown 文本切分
92
+ ├── session/ # 会话管理层
93
+ │ ├── session-manager.ts # QQ peer → Agent 映射
94
+ │ └── idle-evictor.ts # 闲置回收
95
+ ├── model/ # 模型路由层
96
+ │ ├── model-resolver.ts # 路由解析
97
+ │ ├── prefs-store.ts # per-peer 偏好持久化
98
+ │ └── settings-reader.ts # settings.yaml 只读
99
+ ├── shared/ # 共享工具
100
+ │ ├── utils.ts # 通用函数
101
+ │ ├── scope.ts # scope/peer 提取
102
+ │ └── send-helper.ts # 分块发送
103
+ ├── commands/ # 斜杠命令
104
+ └── typings/ # 外部模块声明
113
105
  ```
114
106
 
115
107
  ## 会话路由
116
108
 
117
- sessionKey 格式: `qqbot:${appId}:${kind}:${peerId}`
118
-
119
- - c2c (私聊): `qqbot:102901613:c2c:B9CE1DEEC46B...`
120
- - group (群聊): `qqbot:102901613:group:16FA861B01EE...`
121
-
122
- SessionId 由 sessionKey 确定性派生(SHA-256),保证同一用户/群的消息始终路由到同一 agent,重启后可恢复会话。
109
+ sessionKey: `qqbot:${appId}:${scope}:${peerId}`,由 SHA-256 确定性派生 SessionId,重启后可恢复。
123
110
 
124
- 会话解析策略(三级降级):
125
- 1. **进程内复用** — `agents.get(sessionId)`
126
- 2. **持久化恢复** — `agents.resume({ resumeSessionId, setup })`
127
- 3. **全新创建** — `agents.create({ sessionId, meta, setup })`
111
+ 解析策略:进程内复用 → 持久化恢复 → 全新创建。
128
112
 
129
113
  ## 设计原则
130
114
 
@@ -153,46 +137,6 @@ export QQBOT_APPID="xxx" QQBOT_SECRET="xxx"
153
137
  pnpm dsh web --patch /path/to/dsh-qqbot/cordis.dev.yml
154
138
  ```
155
139
 
156
- ### 断点调试
140
+ ## License
157
141
 
158
- ```bash
159
- node --inspect ./node_modules/.bin/dsh --profile headless \
160
- --patch /path/to/dsh-qqbot/cordis.dev.yml
161
- ```
162
-
163
- ### VS Code launch.json
164
-
165
- ```json
166
- {
167
- "version": "0.2.0",
168
- "configurations": [
169
- {
170
- "name": "dsh + qqbot (patch)",
171
- "type": "node",
172
- "request": "launch",
173
- "cwd": "/path/to/deepseek-harness",
174
- "runtimeExecutable": "pnpm",
175
- "runtimeArgs": ["dsh", "web", "--patch", "/path/to/dsh-qqbot/cordis.dev.yml"],
176
- "env": {
177
- "QQBOT_APPID": "你的AppID",
178
- "QQBOT_SECRET": "你的AppSecret",
179
- "DEEPSEEK_API_KEY": "sk-xxx"
180
- },
181
- "console": "integratedTerminal"
182
- }
183
- ]
184
- }
185
- ```
186
-
187
- ## 发布
188
-
189
- ```bash
190
- pnpm build
191
- npm publish --access public
192
- ```
193
-
194
- 安装后用户通过以下命令添加到 dsh:
195
-
196
- ```bash
197
- dsh plugin --profile qqbot add @tencent-connect/dsh-qqbot
198
- ```
142
+ [MIT](./LICENSE)
package/README_EN.md ADDED
@@ -0,0 +1,142 @@
1
+ # @tencent-connect/dsh-qqbot
2
+
3
+ A QQ Bot IM plugin for [deepseek-harness](https://github.com/deepseek-ai/deepseek-harness) (dsh), driving the dsh agent loop with the QQ messaging platform as the frontend protocol.
4
+
5
+ [中文文档](./README.md) | English
6
+
7
+ ## Architecture
8
+
9
+ ```
10
+ QQ User → QQ WebSocket → dsh-im-qqbot → ctx.agents → dsh agent loop → LLM
11
+ ↑ │
12
+ └── session/event ──────────┘
13
+ (assistant reply → QQ sendMarkdown)
14
+ ```
15
+
16
+ ## Installation
17
+
18
+ ### Method 1: Manual
19
+
20
+ ```bash
21
+ # Add to a profile
22
+ dsh plugin --profile qqbot add @tencent-connect/dsh-qqbot
23
+
24
+ # Start
25
+ dsh --profile qqbot
26
+ ```
27
+
28
+ On first launch, the plugin detects missing credentials and automatically starts the QR flow: a QR code is printed in the terminal → scan it with the QQ mobile app → credentials are saved to the profile, so subsequent launches require no re-scan.
29
+
30
+ ### Method 2: Local path
31
+
32
+ ```bash
33
+ # Build
34
+ cd /path/to/dsh-qqbot
35
+ pnpm install && pnpm build
36
+
37
+ # Add to a profile (local path)
38
+ dsh plugin --profile qqbot add /path/to/dsh-qqbot
39
+
40
+ # Start
41
+ export QQBOT_APPID="yourAppID" QQBOT_SECRET="yourAppSecret"
42
+ dsh --profile qqbot
43
+ ```
44
+
45
+ ### Method 3: --patch dev mode
46
+
47
+ ```bash
48
+ cd /path/to/deepseek-harness
49
+ export QQBOT_APPID="yourAppID" QQBOT_SECRET="yourAppSecret"
50
+ pnpm dsh web --patch /path/to/dsh-qqbot/cordis.dev.yml
51
+ ```
52
+
53
+ ## Configuration
54
+
55
+ | Config | Type | Default | Description |
56
+ |------|------|--------|------|
57
+ | `appId` | string | **required** | QQ Bot AppID (or via `QQBOT_APPID` env var) |
58
+ | `appSecret` | string | **required** | QQ Bot AppSecret (or via `QQBOT_SECRET` env var) |
59
+ | `provider` | string | `deepseek-official` | LLM provider name |
60
+ | `model` | string | `deepseek-chat` | Model name |
61
+ | `preset` | string | - | Agent preset id |
62
+ | `cwd` | string | `process.cwd()` | Agent working directory |
63
+ | `requireMention` | boolean | `true` | Whether group messages require @bot to trigger |
64
+ | `groupPrompt` | string | - | Extra system prompt for group chats |
65
+ | `directPrompt` | string | - | Extra system prompt for direct chats |
66
+ | `textChunkLimit` | number | `4500` | Max chars per message |
67
+ | `sessionIdleTimeout` | number | `1800000` | Session idle timeout (ms), default 30 min |
68
+ | `debug` | boolean | `false` | Debug mode |
69
+
70
+ ## Built-in Commands
71
+
72
+ | Command | Description |
73
+ |------|------|
74
+ | `/bot-reset` | Reset the current session (clear context) |
75
+ | `/bot-model` | View or switch model |
76
+ | `/bot-status` | View current session status |
77
+ | `/bot-help` | View all commands |
78
+
79
+ ## Core Modules
80
+
81
+ ```
82
+ src/
83
+ ├── index.ts # Cordis plugin entry (async apply)
84
+ ├── config.ts # Config schema
85
+ ├── types.ts # Global types
86
+ ├── setup.ts # Credential binding (QR)
87
+ ├── transport/ # Transport layer
88
+ │ ├── inbound.ts # QQ inbound message → agent.followup()
89
+ │ ├── outbound.ts # session/event → QQ sendMarkdown
90
+ │ ├── outbound-buffer.ts # Streaming buffer
91
+ │ └── chunker.ts # Markdown chunking
92
+ ├── session/ # Session management
93
+ │ ├── session-manager.ts # QQ peer → Agent mapping
94
+ │ └── idle-evictor.ts # Idle eviction
95
+ ├── model/ # Model routing
96
+ │ ├── model-resolver.ts # Route resolution
97
+ │ ├── prefs-store.ts # Per-peer preference persistence
98
+ │ └── settings-reader.ts # settings.yaml read-only
99
+ ├── shared/ # Shared utilities
100
+ │ ├── utils.ts # Common helpers
101
+ │ ├── scope.ts # scope/peer extraction
102
+ │ └── send-helper.ts # Chunked send
103
+ ├── commands/ # Slash commands
104
+ └── typings/ # External module declarations
105
+ ```
106
+
107
+ ## Session Routing
108
+
109
+ sessionKey: `qqbot:${appId}:${scope}:${peerId}`, with the SessionId derived deterministically via SHA-256 so sessions survive restarts.
110
+
111
+ Resolution strategy: in-process reuse → persisted resume → fresh create.
112
+
113
+ ## Design Principles
114
+
115
+ - **Pure Cordis plugin** — follows the dsh "Plugins, not loop changes" principle
116
+ - **Declarative dependencies** — `inject = ['agents']`, no direct coupling to other plugins
117
+ - **Session isolation** — one independent Agent per QQ direct user / group
118
+ - **Preset support** — mount presets (toolkits, prompts, etc.) via the `agent-presets` service
119
+ - **Idle eviction** — auto-dispose Agents on timeout to prevent memory leaks
120
+ - **Markdown output** — replies sent as Markdown with code-block/table-aware chunking
121
+
122
+ ## Local Development
123
+
124
+ ```bash
125
+ # Install dependencies
126
+ pnpm install
127
+
128
+ # Build
129
+ pnpm build
130
+
131
+ # Dev mode (watch)
132
+ pnpm dev
133
+
134
+ # Debug via --patch (inside the dsh monorepo)
135
+ cd /path/to/deepseek-harness
136
+ export QQBOT_APPID="xxx" QQBOT_SECRET="xxx"
137
+ pnpm dsh web --patch /path/to/dsh-qqbot/cordis.dev.yml
138
+ ```
139
+
140
+ ## License
141
+
142
+ [MIT](./LICENSE)
package/a.txt ADDED
@@ -0,0 +1,14 @@
1
+ 一个让 QQ 机器人秒变 AI 智能体的插件,基于 DeepSeek Harness(dsh)构建。
2
+ 为什么值得一试
3
+ 零配置接入:首次启动扫码即可绑定机器人,无需折腾密钥
4
+ 专属会话:每个用户 / 群聊独立上下文,互不串扰,重启自动恢复
5
+ 随时切换模型:聊天里发条指令就能换模型,对话还不丢
6
+ 群聊不打扰:支持"@机器人 才响应",安静地待着
7
+  
8
+ 三步上手 
9
+ 开始前,请先根据 DeepSeek Harness 官方指引完成 dsh 的初始化和模型配置,确保环境就绪。
10
+  
11
+ 1. 安装到 dsh profile
12
+ npx @deepseek-ai/dsh plugin --profile qqbot add @tencent-connect/dsh-qqbot
13
+  2. 启动
14
+ npx @deepseek-ai/dsh --profile qqbot
package/cordis.patch.yml CHANGED
@@ -12,13 +12,21 @@
12
12
  # ── 插入 im-qqbot 插件行 ──
13
13
  - insert:
14
14
  - id: im-qqbot
15
- name: '@tencent-connect/dsh-qqbot'
15
+ name: '@cxyhhhhh/dsh-qqbot'
16
16
  config:
17
17
  appId: __FROM_ENV__
18
18
  appSecret: __FROM_ENV__
19
- provider: deepseek-official
20
- model: deepseek-chat
19
+ # provider/model 留空:从宿主默认模型路由继承
20
+ # 用户可通过 /model 命令在聊天中切换
21
21
  requireMention: true
22
22
  textChunkLimit: 4500
23
23
  sessionIdleTimeout: 1800000
24
+ maxQueue: 20
25
+ processingTimeoutMs: 120000
26
+ historyLimit: 10
27
+ access:
28
+ c2cMode: open
29
+ c2cAllow: []
30
+ groupMode: open
31
+ groupAllow: []
24
32
  debug: false
@@ -0,0 +1,11 @@
1
+ /**
2
+ * /bot-help — 查看所有指令以及用途
3
+ *
4
+ * 参考 openclaw-qqbot 的 bot-help.ts:遍历所有非隐藏命令,
5
+ * 用 <qqbot-cmd-input> 展示为可点击按钮,以 Markdown 格式发送。
6
+ */
7
+ import type { SlashCommand } from '@tencent-connect/qqbot-nodejs';
8
+ import type { CommandDeps } from './types.js';
9
+ /** /bot-help — 查看所有指令以及用途 */
10
+ export declare function helpCommand({ config }: CommandDeps, allCommands: () => SlashCommand[]): SlashCommand;
11
+ //# sourceMappingURL=help.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"help.d.ts","sourceRoot":"","sources":["../../src/commands/help.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAClE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAG9C,6BAA6B;AAC7B,wBAAgB,WAAW,CAAC,EAAE,MAAM,EAAE,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,YAAY,EAAE,GAAG,YAAY,CAkBpG"}
@@ -0,0 +1,21 @@
1
+ import { sendMarkdownChunked } from '../shared/index.js';
2
+ /** /bot-help — 查看所有指令以及用途 */
3
+ export function helpCommand({ config }, allCommands) {
4
+ return {
5
+ name: 'bot-help',
6
+ description: '查看所有指令以及用途',
7
+ handler: async (cmdCtx) => {
8
+ const lines = ['### QQBot插件内置指令', ''];
9
+ for (const cmd of allCommands()) {
10
+ const name = Array.isArray(cmd.name) ? cmd.name[0] : cmd.name;
11
+ if (cmd.hidden)
12
+ continue;
13
+ lines.push(`<qqbot-cmd-input text="/${name}" show="/${name}"/> ${cmd.description ?? ''}`);
14
+ }
15
+ lines.push('', '> dsh-qqbot v0.1.0');
16
+ await sendMarkdownChunked(cmdCtx, lines.join('\n'), config.textChunkLimit);
17
+ return { kind: 'noop' };
18
+ },
19
+ };
20
+ }
21
+ //# sourceMappingURL=help.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"help.js","sourceRoot":"","sources":["../../src/commands/help.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAEzD,6BAA6B;AAC7B,MAAM,UAAU,WAAW,CAAC,EAAE,MAAM,EAAe,EAAE,WAAiC;IACpF,OAAO;QACL,IAAI,EAAE,UAAU;QAChB,WAAW,EAAE,YAAY;QACzB,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE;YACxB,MAAM,KAAK,GAAG,CAAC,iBAAiB,EAAE,EAAE,CAAC,CAAC;YAEtC,KAAK,MAAM,GAAG,IAAI,WAAW,EAAE,EAAE,CAAC;gBAChC,MAAM,IAAI,GAAG,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC;gBAC9D,IAAI,GAAG,CAAC,MAAM;oBAAE,SAAS;gBACzB,KAAK,CAAC,IAAI,CAAC,2BAA2B,IAAI,YAAY,IAAI,OAAO,GAAG,CAAC,WAAW,IAAI,EAAE,EAAE,CAAC,CAAC;YAC5F,CAAC;YAED,KAAK,CAAC,IAAI,CAAC,EAAE,EAAE,oBAAoB,CAAC,CAAC;YACrC,MAAM,mBAAmB,CAAC,MAAM,EAAE,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC,cAAc,CAAC,CAAC;YAC3E,OAAO,EAAE,IAAI,EAAE,MAAe,EAAE,CAAC;QACnC,CAAC;KACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,13 @@
1
+ /**
2
+ * 斜杠命令注册中心
3
+ *
4
+ * 每个命令拆分为独立文件,此处仅编排。参考 openclaw-qqbot 的
5
+ * commands/index.ts 模式:工厂函数注入依赖,统一导出命令列表。
6
+ */
7
+ import type { SlashCommand } from '@tencent-connect/qqbot-nodejs';
8
+ import type { CommandDeps } from './types.js';
9
+ /**
10
+ * 构建标准命令列表
11
+ */
12
+ export declare function buildCommandList(deps: CommandDeps): SlashCommand[];
13
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/commands/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAClE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAO9C;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,WAAW,GAAG,YAAY,EAAE,CAmBlE"}
@@ -0,0 +1,27 @@
1
+ import { resetCommand, newCommand } from './session.js';
2
+ import { modelCommand } from './model.js';
3
+ import { statusCommand } from './status.js';
4
+ import { helpCommand } from './help.js';
5
+ import { pingCommand, versionCommand, stopCommand } from './misc.js';
6
+ /**
7
+ * 构建标准命令列表
8
+ */
9
+ export function buildCommandList(deps) {
10
+ const commands = [
11
+ // 会话
12
+ resetCommand(deps),
13
+ newCommand(deps),
14
+ // 模型
15
+ modelCommand(deps),
16
+ // 状态
17
+ statusCommand(deps),
18
+ // 杂项
19
+ pingCommand(),
20
+ versionCommand(deps),
21
+ stopCommand(),
22
+ ];
23
+ // help 需要访问完整列表(含自身),通过闭包惰性引用
24
+ commands.push(helpCommand(deps, () => commands));
25
+ return commands;
26
+ }
27
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/commands/index.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AACxD,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AACxC,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAErE;;GAEG;AACH,MAAM,UAAU,gBAAgB,CAAC,IAAiB;IAChD,MAAM,QAAQ,GAAmB;QAC/B,KAAK;QACL,YAAY,CAAC,IAAI,CAAC;QAClB,UAAU,CAAC,IAAI,CAAC;QAChB,KAAK;QACL,YAAY,CAAC,IAAI,CAAC;QAClB,KAAK;QACL,aAAa,CAAC,IAAI,CAAC;QACnB,KAAK;QACL,WAAW,EAAE;QACb,cAAc,CAAC,IAAI,CAAC;QACpB,WAAW,EAAE;KACd,CAAC;IAEF,8BAA8B;IAC9B,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,EAAE,GAAG,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAC;IAEjD,OAAO,QAAQ,CAAC;AAClB,CAAC"}
@@ -0,0 +1,12 @@
1
+ /**
2
+ * 杂项命令:/ping /version /stop
3
+ */
4
+ import type { SlashCommand } from '@tencent-connect/qqbot-nodejs';
5
+ import type { CommandDeps } from './types.js';
6
+ /** /bot-ping — 连通性测试 */
7
+ export declare function pingCommand(): SlashCommand;
8
+ /** /bot-version — 查看版本信息 */
9
+ export declare function versionCommand({ manager }: CommandDeps): SlashCommand;
10
+ /** /bot-stop — 中止当前生成(隐藏) */
11
+ export declare function stopCommand(): SlashCommand;
12
+ //# sourceMappingURL=misc.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"misc.d.ts","sourceRoot":"","sources":["../../src/commands/misc.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAClE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAE9C,wBAAwB;AACxB,wBAAgB,WAAW,IAAI,YAAY,CAM1C;AAED,4BAA4B;AAC5B,wBAAgB,cAAc,CAAC,EAAE,OAAO,EAAE,EAAE,WAAW,GAAG,YAAY,CAUrE;AAED,6BAA6B;AAC7B,wBAAgB,WAAW,IAAI,YAAY,CAO1C"}
@@ -0,0 +1,30 @@
1
+ /** /bot-ping — 连通性测试 */
2
+ export function pingCommand() {
3
+ return {
4
+ name: 'bot-ping',
5
+ description: '连通性测试',
6
+ handler: () => 'pong 🏓',
7
+ };
8
+ }
9
+ /** /bot-version — 查看版本信息 */
10
+ export function versionCommand({ manager }) {
11
+ return {
12
+ name: 'bot-version',
13
+ description: '查看版本信息',
14
+ handler: () => {
15
+ const current = manager.getEffectiveModel('c2c', '');
16
+ const modelInfo = current ? `${current.provider}/${current.model}` : '宿主默认';
17
+ return `dsh-qqbot v0.1.0 | model: ${modelInfo}`;
18
+ },
19
+ };
20
+ }
21
+ /** /bot-stop — 中止当前生成(隐藏) */
22
+ export function stopCommand() {
23
+ return {
24
+ name: 'bot-stop',
25
+ description: '中止当前生成',
26
+ hidden: true,
27
+ handler: () => ({ kind: 'noop' }),
28
+ };
29
+ }
30
+ //# sourceMappingURL=misc.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"misc.js","sourceRoot":"","sources":["../../src/commands/misc.ts"],"names":[],"mappings":"AAMA,wBAAwB;AACxB,MAAM,UAAU,WAAW;IACzB,OAAO;QACL,IAAI,EAAE,UAAU;QAChB,WAAW,EAAE,OAAO;QACpB,OAAO,EAAE,GAAG,EAAE,CAAC,SAAS;KACzB,CAAC;AACJ,CAAC;AAED,4BAA4B;AAC5B,MAAM,UAAU,cAAc,CAAC,EAAE,OAAO,EAAe;IACrD,OAAO;QACL,IAAI,EAAE,aAAa;QACnB,WAAW,EAAE,QAAQ;QACrB,OAAO,EAAE,GAAG,EAAE;YACZ,MAAM,OAAO,GAAG,OAAO,CAAC,iBAAiB,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;YACrD,MAAM,SAAS,GAAG,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,QAAQ,IAAI,OAAO,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC;YAC5E,OAAO,6BAA6B,SAAS,EAAE,CAAC;QAClD,CAAC;KACF,CAAC;AACJ,CAAC;AAED,6BAA6B;AAC7B,MAAM,UAAU,WAAW;IACzB,OAAO;QACL,IAAI,EAAE,UAAU;QAChB,WAAW,EAAE,QAAQ;QACrB,MAAM,EAAE,IAAI;QACZ,OAAO,EAAE,GAAG,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,MAAe,EAAE,CAAC;KAC3C,CAAC;AACJ,CAAC"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * 模型命令:/bot-model — 查看或切换模型
3
+ */
4
+ import type { SlashCommand } from '@tencent-connect/qqbot-nodejs';
5
+ import type { CommandDeps } from './types.js';
6
+ export declare function modelCommand({ manager, config }: CommandDeps): SlashCommand;
7
+ //# sourceMappingURL=model.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"model.d.ts","sourceRoot":"","sources":["../../src/commands/model.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAClE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAG9C,wBAAgB,YAAY,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE,EAAE,WAAW,GAAG,YAAY,CAgE3E"}