@zaofan/dsh-qqbot 0.9.5 β 1.0.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/README.md +394 -311
- package/README_EN.md +313 -281
- package/client/qqbot-settings.js +3214 -2986
- package/dist/channel-tools.d.ts +1 -1
- package/dist/channel-tools.d.ts.map +1 -1
- package/dist/channel-tools.js +134 -3
- package/dist/channel-tools.js.map +1 -1
- package/dist/commands/approve.d.ts +17 -0
- package/dist/commands/approve.d.ts.map +1 -0
- package/dist/commands/approve.js +24 -0
- package/dist/commands/approve.js.map +1 -0
- package/dist/commands/botplay.d.ts +15 -0
- package/dist/commands/botplay.d.ts.map +1 -0
- package/dist/commands/botplay.js +34 -0
- package/dist/commands/botplay.js.map +1 -0
- package/dist/commands/exit.d.ts +7 -0
- package/dist/commands/exit.d.ts.map +1 -0
- package/dist/commands/exit.js +85 -0
- package/dist/commands/exit.js.map +1 -0
- package/dist/commands/index.d.ts.map +1 -1
- package/dist/commands/index.js +14 -1
- package/dist/commands/index.js.map +1 -1
- package/dist/commands/permission.d.ts +18 -0
- package/dist/commands/permission.d.ts.map +1 -0
- package/dist/commands/permission.js +43 -0
- package/dist/commands/permission.js.map +1 -0
- package/dist/commands/session.d.ts +5 -1
- package/dist/commands/session.d.ts.map +1 -1
- package/dist/commands/session.js +51 -5
- package/dist/commands/session.js.map +1 -1
- package/dist/config.d.ts +55 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +75 -0
- package/dist/config.js.map +1 -1
- package/dist/features/approval-switch.d.ts +22 -0
- package/dist/features/approval-switch.d.ts.map +1 -0
- package/dist/features/approval-switch.js +10 -0
- package/dist/features/approval-switch.js.map +1 -0
- package/dist/features/botplay.d.ts +141 -0
- package/dist/features/botplay.d.ts.map +1 -0
- package/dist/features/botplay.js +547 -0
- package/dist/features/botplay.js.map +1 -0
- package/dist/features/extension-store.d.ts +27 -0
- package/dist/features/extension-store.d.ts.map +1 -0
- package/dist/features/extension-store.js +152 -0
- package/dist/features/extension-store.js.map +1 -0
- package/dist/features/qq-approval.d.ts.map +1 -1
- package/dist/features/qq-approval.js +3 -1
- package/dist/features/qq-approval.js.map +1 -1
- package/dist/gateway/bootstrap.d.ts.map +1 -1
- package/dist/gateway/bootstrap.js +60 -1
- package/dist/gateway/bootstrap.js.map +1 -1
- package/dist/gateway/debounce.d.ts.map +1 -1
- package/dist/gateway/debounce.js +4 -2
- package/dist/gateway/debounce.js.map +1 -1
- package/dist/gateway/middleware-setup.d.ts +1 -1
- package/dist/gateway/middleware-setup.d.ts.map +1 -1
- package/dist/gateway/middleware-setup.js +10 -2
- package/dist/gateway/middleware-setup.js.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +19 -2
- package/dist/index.js.map +1 -1
- package/dist/model/model-resolver.d.ts +12 -0
- package/dist/model/model-resolver.d.ts.map +1 -1
- package/dist/model/model-resolver.js +24 -0
- package/dist/model/model-resolver.js.map +1 -1
- package/dist/model/prefs-store.d.ts +16 -0
- package/dist/model/prefs-store.d.ts.map +1 -1
- package/dist/model/prefs-store.js +48 -0
- package/dist/model/prefs-store.js.map +1 -1
- package/dist/session/session-manager.d.ts +37 -0
- package/dist/session/session-manager.d.ts.map +1 -1
- package/dist/session/session-manager.js +168 -16
- package/dist/session/session-manager.js.map +1 -1
- package/package.json +1 -1
package/README_EN.md
CHANGED
|
@@ -1,281 +1,313 @@
|
|
|
1
|
-
# @zaofan/dsh-qqbot
|
|
2
|
-
|
|
3
|
-
An **enhanced fork** of the QQ Bot IM plugin for [deepseek-harness](https://github.com/deepseek-ai/deepseek-harness) (dsh): it drives the dsh agent loop with the QQ messaging platform as the frontend protocol, adding a local sticker library, rich media send/recall, scheduled tasks, multi-instance personas, and a visual settings panel.
|
|
4
|
-
|
|
5
|
-
π¦ Repo: [gcry13067381632-jpg/dsh-qqbot](https://github.com/gcry13067381632-jpg/dsh-qqbot) (forked from [tencent-connect/dsh-qqbot](https://github.com/tencent-connect/dsh-qqbot))
|
|
6
|
-
|
|
7
|
-
[δΈζζζ‘£](./README.md) | English
|
|
8
|
-
|
|
9
|
-
## π This fork (enhanced edition)
|
|
10
|
-
|
|
11
|
-
**In one line**: bring your dsh-powered QQ bot to life β it auto-collects stickers from group chats, picks and sends the right one when the mood hits, speaks up on schedule, and lets you run several bots with different personalities from one computer.
|
|
12
|
-
|
|
13
|
-
This repo is an enhanced fork of [@tencent-connect/dsh-qqbot](https://github.com/tencent-connect/dsh-qqbot) (changes live outside the upstream source β reinstalling/upgrading upstream will wipe them).
|
|
14
|
-
|
|
15
|
-
### What she does for you
|
|
16
|
-
|
|
17
|
-
**π€³ Group images become her sticker library automatically** β saved locally with dedup ("to-sort / favorite / trash"). Say *"send something happy"* and she searches, picks and sends on her own β with guardrails (no posting into a cold chat, rate limits, no repeat stickers).
|
|
18
|
-
|
|
19
|
-
**β° She speaks up on time** β schedule a daily greeting, or tell her *"remind me to drink water in 30 seconds"* and she actually will.
|
|
20
|
-
|
|
21
|
-
**π§βπ€βπ§ Many bots, many personalities, one computer** β each with its own AppID, persona and working directory (stickers / timers / gates fully isolated). Adding one is a QR scan away in the Web panel.
|
|
22
|
-
|
|
23
|
-
**π¬ Floating dock: her pocket console**
|
|
24
|
-
The little ball at the corner of the settings panel opens a whole control deck: **π¬ Chat** (replay a group/DM conversation QQ-style β bubbles + avatars, zoomable images, inline local video, SILK voice converted to MP3 in pure JS, file download cards; compose text / images / files right below, long messages auto-split into safe chunks that never get swallowed by QQ); **π₯ join-request approval**, **π mute** (when she is a group admin, she pings you on join requests β reply "approve/reject"); **βοΈ Outbound** (adaptive-active: recent human messages get quoted replies first, bursts auto-switch to independent messages, scheduled/background pushes never get dropped).
|
|
25
|
-
|
|
26
|
-
**π‘οΈ Group-admin helper** β join approval + mute management over official APIs, with human-readable errors (not an admin / cannot mute the ownerβ¦).
|
|
27
|
-
|
|
28
|
-
**π₯οΈ No config-file surgery** β reply pacing, sticker gates, scheduled wake-ups, outbound mode and per-bot personas are all in the panel; saving applies live (only adding/removing bots needs a restart). There is even a βοΈ persona editor to tweak her "personality file" right in the browser.
|
|
29
|
-
|
|
30
|
-
**π¦ Clean & lean** β drive image sending / recall from plain text (`[MEDIA:image|path]` / `[RECALL]`); the repo contains no bot credentials or private data.
|
|
31
|
-
|
|
32
|
-
### πΈ Showcase
|
|
33
|
-
|
|
34
|
-
Left: the dsh runtime backend β reasoning, tool calls and token usage are fully visible (paired with the `reply_gate` gate tool, the bot decides on its own whether to speak or stay silently idle);
|
|
35
|
-
Middle: real QQ group conversation β hide-and-seek role-play, replying when it should and staying quiet when it shouldn't;
|
|
36
|
-
Right: sticker-battle in action β the bot answers with stickers from its own library, image and text sent as separate messages.
|
|
37
|
-
|
|
38
|
-

|
|
39
|
-
|
|
40
|
-

|
|
41
|
-
|
|
42
|
-

|
|
43
|
-
|
|
44
|
-
### For developers
|
|
45
|
-
- Standard tools available inside QQ sessions: `send_media` / `recall_message` / `list_stickers` / `sticker_tag` / `sticker_untagged` / `schedule_timer` / `schedule_cancel` β¦, routed per bot account.
|
|
46
|
-
- **Group admin tools** (`group_join_requests` / `group_approve_join` / `group_mute_state` / `group_mute_member` β¦): join-request approval and mute management β requires the bot to be a group admin; inside a group session the current group is used, elsewhere the configured `manageGroup` applies.
|
|
47
|
-
- **Plain text can send media or recall messages**: writing `[MEDIA:image|path-or-url]` in a reply turns it into a real image message (`voice`/`video`/`file` work the same); a lone `[RECALL]` line recalls the bot's own last message.
|
|
48
|
-
- Host-level fixes (workspace session attachment, upstream PR #21) are included β idempotent and fully fail-soft.
|
|
49
|
-
|
|
50
|
-
> π‘οΈ This repo contains **no** bot credentials, sticker data, logs or personal paths (cleaned before publishing). Inject AppID/AppSecret via env vars or the Web panel β **never commit them**.
|
|
51
|
-
|
|
52
|
-
### Build & deploy
|
|
53
|
-
|
|
54
|
-
```bash
|
|
55
|
-
npm install # install deps (peer deps resolved by the dsh host)
|
|
56
|
-
node node_modules/typescript/lib/tsc.js -p tsconfig.json # or npm run build
|
|
57
|
-
# then copy dist/ over your dsh profile's
|
|
58
|
-
# node_modules/@tencent-connect/dsh-qqbot/dist/ and restart dsh
|
|
59
|
-
```
|
|
60
|
-
|
|
61
|
-
See the upstream "Installation" section below (`dsh plugin add` + QR onboarding both work).
|
|
62
|
-
|
|
63
|
-
---
|
|
64
|
-
|
|
65
|
-
## Architecture
|
|
66
|
-
|
|
67
|
-
```
|
|
68
|
-
QQ User β QQ WebSocket β dsh-im-qqbot β ctx.agents β dsh agent loop β LLM
|
|
69
|
-
β β
|
|
70
|
-
βββ session/event βββββββββββ
|
|
71
|
-
(assistant reply β QQ sendMarkdown)
|
|
72
|
-
```
|
|
73
|
-
|
|
74
|
-
## Installation
|
|
75
|
-
|
|
76
|
-
> β οΈ **Install into the `web` profile** (host of the `dsh web` settings panel); other profiles get a bare
|
|
77
|
-
> environment with no settings UI. Do **not** `add @tencent-connect/dsh-qqbot` β that installs the upstream
|
|
78
|
-
> official version (without this fork's features).
|
|
79
|
-
>
|
|
80
|
-
> β
**Single package, everything included**: QQ bot + the Web settings panel (host bridge + settings UI) all
|
|
81
|
-
> ship in this one package β after install, dsh Web β Settings shows a "QQ bot (im-qqbot)" page (one per bot
|
|
82
|
-
> instance). **No separate dsh-qqbot-settings install needed.**
|
|
83
|
-
|
|
84
|
-
### Method 1 (after npm release): one command
|
|
85
|
-
|
|
86
|
-
```powershell
|
|
87
|
-
npx @deepseek-ai/dsh plugin --profile web add @zaofan/dsh-qqbot
|
|
88
|
-
```
|
|
89
|
-
|
|
90
|
-
> Until it is published to npm, use Method 2 below.
|
|
91
|
-
|
|
92
|
-
### Method 2: from source (recommended for now)
|
|
93
|
-
|
|
94
|
-
**Windows (one-click script)**:
|
|
95
|
-
|
|
96
|
-
```powershell
|
|
97
|
-
git clone https://github.com/gcry13067381632-jpg/dsh-qqbot.git
|
|
98
|
-
cd dsh-qqbot
|
|
99
|
-
.\install.ps1 # npm install/build -> pack -> add tarball -> prints restart steps
|
|
100
|
-
```
|
|
101
|
-
|
|
102
|
-
> If script execution is blocked: `powershell -ExecutionPolicy Bypass -File .\install.ps1`
|
|
103
|
-
|
|
104
|
-
**macOS / Linux (manual)**:
|
|
105
|
-
|
|
106
|
-
```bash
|
|
107
|
-
git clone https://github.com/gcry13067381632-jpg/dsh-qqbot.git
|
|
108
|
-
cd dsh-qqbot
|
|
109
|
-
npm install && npm run build
|
|
110
|
-
pnpm pack --pack-destination /tmp
|
|
111
|
-
npx @deepseek-ai/dsh plugin --profile web add /tmp/zaofan-dsh-qqbot-0.4.0.tgz
|
|
112
|
-
```
|
|
113
|
-
|
|
114
|
-
> π‘ Why a tarball instead of `add <source dir>`? Lessons from real installs:
|
|
115
|
-
> β a directory path containing spaces gets split at the spaces on Windows (pnpm reports `- isn't supported`);
|
|
116
|
-
> β‘ `add <dir>` becomes a pnpm link (junction), so the plugin can't locate the profile by its code location,
|
|
117
|
-
> and scanned credentials cannot be persisted (env-var-only fallback).
|
|
118
|
-
|
|
119
|
-
### Troubleshooting: npm install fails with ERESOLVE (backported from upstream PR #42)
|
|
120
|
-
|
|
121
|
-
A fresh `npm install` may fail with `ERESOLVE could not resolve`. Cause: peer deps like
|
|
122
|
-
`@deepseek-ai/dsh-tools` / `dsh-agent` are still on prerelease (-rc) version lines, and npm 7+
|
|
123
|
-
strict resolution rejects non-intersecting combinations. **This is an upstream version-line issue, not a plugin bug.** Two workarounds:
|
|
124
|
-
|
|
125
|
-
```bash
|
|
126
|
-
npm install --legacy-peer-deps # install-time resolution only; runtime behavior unchanged
|
|
127
|
-
# or: install deps, then build & pack manually (peers are resolved by the dsh host)
|
|
128
|
-
```
|
|
129
|
-
|
|
130
|
-
> Tracked: once upstream #37 is fixed and version lines converge, this section can be removed.
|
|
131
|
-
|
|
132
|
-
### First launch & binding
|
|
133
|
-
|
|
134
|
-
Start `dsh web`. If credentials are missing, the **QR flow** starts automatically: a QR code is printed in the
|
|
135
|
-
terminal β scan it with the QQ mobile app β credentials are saved and survive restarts (you can also use
|
|
136
|
-
"QR bind" / edit accounts in the settings panel at any time).
|
|
137
|
-
|
|
138
|
-

|
|
139
|
-
|
|
140
|
-
> **Note**: Use `0.4.0` or later for browser-link scanning, which avoids QR code misalignment in some terminals.
|
|
141
|
-
|
|
142
|
-
### Don't have a QQ bot yet? Register one (get AppID / AppSecret)
|
|
143
|
-
|
|
144
|
-
1. Open the [QQ Open Platform](https://q.qq.com) and sign in with your QQ account;
|
|
145
|
-
2. Go to "Bot" β "Create Bot" and fill in name, avatar and description;
|
|
146
|
-
3. After creation, copy the **AppID** and **AppSecret** from the bot detail page;
|
|
147
|
-
4. Enter them in dsh Web β Settings β "QQ bot" β "Accounts & presets" and save
|
|
148
|
-
(or set env vars `QQBOT_APPID` / `QQBOT_SECRET`);
|
|
149
|
-
5. Enable the needed **single-chat / group-chat** message permissions on the platform
|
|
150
|
-
(group chat usually requires a use-case review).
|
|
151
|
-
|
|
152
|
-
> π‘ Easier: once the bot exists, just use the **QR scan bind** on first launch β no need to type credentials.
|
|
153
|
-
|
|
154
|
-
### For developers: --patch dev mode
|
|
155
|
-
|
|
156
|
-
```bash
|
|
157
|
-
export QQBOT_APPID="yourAppID" QQBOT_SECRET="yourAppSecret"
|
|
158
|
-
npx @deepseek-ai/dsh web --patch /path/to/dsh-qqbot/cordis.dev.yml
|
|
159
|
-
```
|
|
160
|
-
|
|
161
|
-
## Remote approval over QQ (optional)
|
|
162
|
-
|
|
163
|
-
When an Agent tool needs access **outside the workspace**, dsh raises a permission request. With this
|
|
164
|
-
feature on, the bot forwards the request to the **QQ conversation of the task's initiator**, and you
|
|
165
|
-
allow/deny right from QQ:
|
|
166
|
-
|
|
167
|
-
> β οΈ **DSH permission request**
|
|
168
|
-
> Tool: pwsh
|
|
169
|
-
> Reason: needs access outside the workspace
|
|
170
|
-
>
|
|
171
|
-
> Allow this operation: `/approve A1B2C3`
|
|
172
|
-
> Deny this operation: `/deny A1B2C3`
|
|
173
|
-
> One-time only; auto-denied after 120 s.
|
|
174
|
-
|
|
175
|
-
**Enable** (either way; takes effect for new requests right after saving, no restart needed):
|
|
176
|
-
- **Web settings panel**: Settings β "QQ bot" β β€ QQ remote approval β tick it on;
|
|
177
|
-
- or add two lines to the instance `config` in `cordis.patch.yml`, then restart:
|
|
178
|
-
|
|
179
|
-
```yaml
|
|
180
|
-
- id: im-qqbot
|
|
181
|
-
config:
|
|
182
|
-
enableApprovals: true # default false
|
|
183
|
-
approvalTimeoutMs: 120000 # wait window; auto-deny on timeout
|
|
184
|
-
```
|
|
185
|
-
|
|
186
|
-
**Security boundaries**: one-time code; only the **initiator in the same conversation** may decide
|
|
187
|
-
(others in a group chat cannot approve even if they see the code); grants only the current operation;
|
|
188
|
-
auto-cancelled when the agent is cancelled or dsh exits.
|
|
189
|
-
|
|
190
|
-
> Idea source: QQ-approval design of wang-22-code/dsh-qqbot-bridge (host dsh `approval/request`
|
|
191
|
-
> standard event β the same wiring used by official dsh-acp and the Web approval dialog).
|
|
192
|
-
|
|
193
|
-
## Configuration
|
|
194
|
-
|
|
195
|
-
| Config | Type | Default | Description |
|
|
196
|
-
|------|------|--------|------|
|
|
197
|
-
| `appId` | string | **required** | QQ Bot AppID (or via `QQBOT_APPID` env var) |
|
|
198
|
-
| `appSecret` | string | **required** | QQ Bot AppSecret (or via `QQBOT_SECRET` env var) |
|
|
199
|
-
| `provider` | string | `deepseek-official` | LLM provider name |
|
|
200
|
-
| `model` | string | `deepseek-chat` | Model name |
|
|
201
|
-
| `preset` | string | - | Agent preset id |
|
|
202
|
-
| `cwd` | string | `process.cwd()` | Agent working directory |
|
|
203
|
-
| `requireMention` | boolean | `true` | Whether group messages require @bot to trigger |
|
|
204
|
-
| `groupPrompt` | string | - | Extra system prompt for group chats |
|
|
205
|
-
| `directPrompt` | string | - | Extra system prompt for direct chats |
|
|
206
|
-
| `textChunkLimit` | number | `4500` | Max chars per message |
|
|
207
|
-
| `sessionIdleTimeout` | number | `1800000` | Session idle timeout (ms), default 30 min |
|
|
208
|
-
| `debug` | boolean | `false` | Debug mode |
|
|
209
|
-
|
|
210
|
-
## Built-in Commands
|
|
211
|
-
|
|
212
|
-
| Command | Description |
|
|
213
|
-
|------|------|
|
|
214
|
-
| `/bot-reset` | Reset the current session (clear context) |
|
|
215
|
-
| `/bot-model` | View or switch model |
|
|
216
|
-
| `/bot-status` | View current session status |
|
|
217
|
-
| `/bot-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
βββ
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
#
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
#
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
#
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
#
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
```
|
|
278
|
-
|
|
279
|
-
##
|
|
280
|
-
|
|
281
|
-
|
|
1
|
+
# @zaofan/dsh-qqbot
|
|
2
|
+
|
|
3
|
+
An **enhanced fork** of the QQ Bot IM plugin for [deepseek-harness](https://github.com/deepseek-ai/deepseek-harness) (dsh): it drives the dsh agent loop with the QQ messaging platform as the frontend protocol, adding a local sticker library, rich media send/recall, scheduled tasks, multi-instance personas, and a visual settings panel.
|
|
4
|
+
|
|
5
|
+
π¦ Repo: [gcry13067381632-jpg/dsh-qqbot](https://github.com/gcry13067381632-jpg/dsh-qqbot) (forked from [tencent-connect/dsh-qqbot](https://github.com/tencent-connect/dsh-qqbot))
|
|
6
|
+
|
|
7
|
+
[δΈζζζ‘£](./README.md) | English
|
|
8
|
+
|
|
9
|
+
## π This fork (enhanced edition)
|
|
10
|
+
|
|
11
|
+
**In one line**: bring your dsh-powered QQ bot to life β it auto-collects stickers from group chats, picks and sends the right one when the mood hits, speaks up on schedule, and lets you run several bots with different personalities from one computer.
|
|
12
|
+
|
|
13
|
+
This repo is an enhanced fork of [@tencent-connect/dsh-qqbot](https://github.com/tencent-connect/dsh-qqbot) (changes live outside the upstream source β reinstalling/upgrading upstream will wipe them).
|
|
14
|
+
|
|
15
|
+
### What she does for you
|
|
16
|
+
|
|
17
|
+
**π€³ Group images become her sticker library automatically** β saved locally with dedup ("to-sort / favorite / trash"). Say *"send something happy"* and she searches, picks and sends on her own β with guardrails (no posting into a cold chat, rate limits, no repeat stickers).
|
|
18
|
+
|
|
19
|
+
**β° She speaks up on time** β schedule a daily greeting, or tell her *"remind me to drink water in 30 seconds"* and she actually will.
|
|
20
|
+
|
|
21
|
+
**π§βπ€βπ§ Many bots, many personalities, one computer** β each with its own AppID, persona and working directory (stickers / timers / gates fully isolated). Adding one is a QR scan away in the Web panel.
|
|
22
|
+
|
|
23
|
+
**π¬ Floating dock: her pocket console**
|
|
24
|
+
The little ball at the corner of the settings panel opens a whole control deck: **π¬ Chat** (replay a group/DM conversation QQ-style β bubbles + avatars, zoomable images, inline local video, SILK voice converted to MP3 in pure JS, file download cards; compose text / images / files right below, long messages auto-split into safe chunks that never get swallowed by QQ); **π₯ join-request approval**, **π mute** (when she is a group admin, she pings you on join requests β reply "approve/reject"); **βοΈ Outbound** (adaptive-active: recent human messages get quoted replies first, bursts auto-switch to independent messages, scheduled/background pushes never get dropped).
|
|
25
|
+
|
|
26
|
+
**π‘οΈ Group-admin helper** β join approval + mute management over official APIs, with human-readable errors (not an admin / cannot mute the ownerβ¦).
|
|
27
|
+
|
|
28
|
+
**π₯οΈ No config-file surgery** β reply pacing, sticker gates, scheduled wake-ups, outbound mode and per-bot personas are all in the panel; saving applies live (only adding/removing bots needs a restart). There is even a βοΈ persona editor to tweak her "personality file" right in the browser.
|
|
29
|
+
|
|
30
|
+
**π¦ Clean & lean** β drive image sending / recall from plain text (`[MEDIA:image|path]` / `[RECALL]`); the repo contains no bot credentials or private data.
|
|
31
|
+
|
|
32
|
+
### πΈ Showcase
|
|
33
|
+
|
|
34
|
+
Left: the dsh runtime backend β reasoning, tool calls and token usage are fully visible (paired with the `reply_gate` gate tool, the bot decides on its own whether to speak or stay silently idle);
|
|
35
|
+
Middle: real QQ group conversation β hide-and-seek role-play, replying when it should and staying quiet when it shouldn't;
|
|
36
|
+
Right: sticker-battle in action β the bot answers with stickers from its own library, image and text sent as separate messages.
|
|
37
|
+
|
|
38
|
+

|
|
39
|
+
|
|
40
|
+

|
|
41
|
+
|
|
42
|
+

|
|
43
|
+
|
|
44
|
+
### For developers
|
|
45
|
+
- Standard tools available inside QQ sessions: `send_media` / `recall_message` / `list_stickers` / `sticker_tag` / `sticker_untagged` / `schedule_timer` / `schedule_cancel` β¦, routed per bot account.
|
|
46
|
+
- **Group admin tools** (`group_join_requests` / `group_approve_join` / `group_mute_state` / `group_mute_member` β¦): join-request approval and mute management β requires the bot to be a group admin; inside a group session the current group is used, elsewhere the configured `manageGroup` applies.
|
|
47
|
+
- **Plain text can send media or recall messages**: writing `[MEDIA:image|path-or-url]` in a reply turns it into a real image message (`voice`/`video`/`file` work the same); a lone `[RECALL]` line recalls the bot's own last message.
|
|
48
|
+
- Host-level fixes (workspace session attachment, upstream PR #21) are included β idempotent and fully fail-soft.
|
|
49
|
+
|
|
50
|
+
> π‘οΈ This repo contains **no** bot credentials, sticker data, logs or personal paths (cleaned before publishing). Inject AppID/AppSecret via env vars or the Web panel β **never commit them**.
|
|
51
|
+
|
|
52
|
+
### Build & deploy
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
npm install # install deps (peer deps resolved by the dsh host)
|
|
56
|
+
node node_modules/typescript/lib/tsc.js -p tsconfig.json # or npm run build
|
|
57
|
+
# then copy dist/ over your dsh profile's
|
|
58
|
+
# node_modules/@tencent-connect/dsh-qqbot/dist/ and restart dsh
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
See the upstream "Installation" section below (`dsh plugin add` + QR onboarding both work).
|
|
62
|
+
|
|
63
|
+
---
|
|
64
|
+
|
|
65
|
+
## Architecture
|
|
66
|
+
|
|
67
|
+
```
|
|
68
|
+
QQ User β QQ WebSocket β dsh-im-qqbot β ctx.agents β dsh agent loop β LLM
|
|
69
|
+
β β
|
|
70
|
+
βββ session/event βββββββββββ
|
|
71
|
+
(assistant reply β QQ sendMarkdown)
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
## Installation
|
|
75
|
+
|
|
76
|
+
> β οΈ **Install into the `web` profile** (host of the `dsh web` settings panel); other profiles get a bare
|
|
77
|
+
> environment with no settings UI. Do **not** `add @tencent-connect/dsh-qqbot` β that installs the upstream
|
|
78
|
+
> official version (without this fork's features).
|
|
79
|
+
>
|
|
80
|
+
> β
**Single package, everything included**: QQ bot + the Web settings panel (host bridge + settings UI) all
|
|
81
|
+
> ship in this one package β after install, dsh Web β Settings shows a "QQ bot (im-qqbot)" page (one per bot
|
|
82
|
+
> instance). **No separate dsh-qqbot-settings install needed.**
|
|
83
|
+
|
|
84
|
+
### Method 1 (after npm release): one command
|
|
85
|
+
|
|
86
|
+
```powershell
|
|
87
|
+
npx @deepseek-ai/dsh plugin --profile web add @zaofan/dsh-qqbot
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
> Until it is published to npm, use Method 2 below.
|
|
91
|
+
|
|
92
|
+
### Method 2: from source (recommended for now)
|
|
93
|
+
|
|
94
|
+
**Windows (one-click script)**:
|
|
95
|
+
|
|
96
|
+
```powershell
|
|
97
|
+
git clone https://github.com/gcry13067381632-jpg/dsh-qqbot.git
|
|
98
|
+
cd dsh-qqbot
|
|
99
|
+
.\install.ps1 # npm install/build -> pack -> add tarball -> prints restart steps
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
> If script execution is blocked: `powershell -ExecutionPolicy Bypass -File .\install.ps1`
|
|
103
|
+
|
|
104
|
+
**macOS / Linux (manual)**:
|
|
105
|
+
|
|
106
|
+
```bash
|
|
107
|
+
git clone https://github.com/gcry13067381632-jpg/dsh-qqbot.git
|
|
108
|
+
cd dsh-qqbot
|
|
109
|
+
npm install && npm run build
|
|
110
|
+
pnpm pack --pack-destination /tmp
|
|
111
|
+
npx @deepseek-ai/dsh plugin --profile web add /tmp/zaofan-dsh-qqbot-0.4.0.tgz
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
> π‘ Why a tarball instead of `add <source dir>`? Lessons from real installs:
|
|
115
|
+
> β a directory path containing spaces gets split at the spaces on Windows (pnpm reports `- isn't supported`);
|
|
116
|
+
> β‘ `add <dir>` becomes a pnpm link (junction), so the plugin can't locate the profile by its code location,
|
|
117
|
+
> and scanned credentials cannot be persisted (env-var-only fallback).
|
|
118
|
+
|
|
119
|
+
### Troubleshooting: npm install fails with ERESOLVE (backported from upstream PR #42)
|
|
120
|
+
|
|
121
|
+
A fresh `npm install` may fail with `ERESOLVE could not resolve`. Cause: peer deps like
|
|
122
|
+
`@deepseek-ai/dsh-tools` / `dsh-agent` are still on prerelease (-rc) version lines, and npm 7+
|
|
123
|
+
strict resolution rejects non-intersecting combinations. **This is an upstream version-line issue, not a plugin bug.** Two workarounds:
|
|
124
|
+
|
|
125
|
+
```bash
|
|
126
|
+
npm install --legacy-peer-deps # install-time resolution only; runtime behavior unchanged
|
|
127
|
+
# or: install deps, then build & pack manually (peers are resolved by the dsh host)
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
> Tracked: once upstream #37 is fixed and version lines converge, this section can be removed.
|
|
131
|
+
|
|
132
|
+
### First launch & binding
|
|
133
|
+
|
|
134
|
+
Start `dsh web`. If credentials are missing, the **QR flow** starts automatically: a QR code is printed in the
|
|
135
|
+
terminal β scan it with the QQ mobile app β credentials are saved and survive restarts (you can also use
|
|
136
|
+
"QR bind" / edit accounts in the settings panel at any time).
|
|
137
|
+
|
|
138
|
+

|
|
139
|
+
|
|
140
|
+
> **Note**: Use `0.4.0` or later for browser-link scanning, which avoids QR code misalignment in some terminals.
|
|
141
|
+
|
|
142
|
+
### Don't have a QQ bot yet? Register one (get AppID / AppSecret)
|
|
143
|
+
|
|
144
|
+
1. Open the [QQ Open Platform](https://q.qq.com) and sign in with your QQ account;
|
|
145
|
+
2. Go to "Bot" β "Create Bot" and fill in name, avatar and description;
|
|
146
|
+
3. After creation, copy the **AppID** and **AppSecret** from the bot detail page;
|
|
147
|
+
4. Enter them in dsh Web β Settings β "QQ bot" β "Accounts & presets" and save
|
|
148
|
+
(or set env vars `QQBOT_APPID` / `QQBOT_SECRET`);
|
|
149
|
+
5. Enable the needed **single-chat / group-chat** message permissions on the platform
|
|
150
|
+
(group chat usually requires a use-case review).
|
|
151
|
+
|
|
152
|
+
> π‘ Easier: once the bot exists, just use the **QR scan bind** on first launch β no need to type credentials.
|
|
153
|
+
|
|
154
|
+
### For developers: --patch dev mode
|
|
155
|
+
|
|
156
|
+
```bash
|
|
157
|
+
export QQBOT_APPID="yourAppID" QQBOT_SECRET="yourAppSecret"
|
|
158
|
+
npx @deepseek-ai/dsh web --patch /path/to/dsh-qqbot/cordis.dev.yml
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
## Remote approval over QQ (optional)
|
|
162
|
+
|
|
163
|
+
When an Agent tool needs access **outside the workspace**, dsh raises a permission request. With this
|
|
164
|
+
feature on, the bot forwards the request to the **QQ conversation of the task's initiator**, and you
|
|
165
|
+
allow/deny right from QQ:
|
|
166
|
+
|
|
167
|
+
> β οΈ **DSH permission request**
|
|
168
|
+
> Tool: pwsh
|
|
169
|
+
> Reason: needs access outside the workspace
|
|
170
|
+
>
|
|
171
|
+
> Allow this operation: `/approve A1B2C3`
|
|
172
|
+
> Deny this operation: `/deny A1B2C3`
|
|
173
|
+
> One-time only; auto-denied after 120 s.
|
|
174
|
+
|
|
175
|
+
**Enable** (either way; takes effect for new requests right after saving, no restart needed):
|
|
176
|
+
- **Web settings panel**: Settings β "QQ bot" β β€ QQ remote approval β tick it on;
|
|
177
|
+
- or add two lines to the instance `config` in `cordis.patch.yml`, then restart:
|
|
178
|
+
|
|
179
|
+
```yaml
|
|
180
|
+
- id: im-qqbot
|
|
181
|
+
config:
|
|
182
|
+
enableApprovals: true # default false
|
|
183
|
+
approvalTimeoutMs: 120000 # wait window; auto-deny on timeout
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
**Security boundaries**: one-time code; only the **initiator in the same conversation** may decide
|
|
187
|
+
(others in a group chat cannot approve even if they see the code); grants only the current operation;
|
|
188
|
+
auto-cancelled when the agent is cancelled or dsh exits.
|
|
189
|
+
|
|
190
|
+
> Idea source: QQ-approval design of wang-22-code/dsh-qqbot-bridge (host dsh `approval/request`
|
|
191
|
+
> standard event β the same wiring used by official dsh-acp and the Web approval dialog).
|
|
192
|
+
|
|
193
|
+
## Configuration
|
|
194
|
+
|
|
195
|
+
| Config | Type | Default | Description |
|
|
196
|
+
|------|------|--------|------|
|
|
197
|
+
| `appId` | string | **required** | QQ Bot AppID (or via `QQBOT_APPID` env var) |
|
|
198
|
+
| `appSecret` | string | **required** | QQ Bot AppSecret (or via `QQBOT_SECRET` env var) |
|
|
199
|
+
| `provider` | string | `deepseek-official` | LLM provider name |
|
|
200
|
+
| `model` | string | `deepseek-chat` | Model name |
|
|
201
|
+
| `preset` | string | - | Agent preset id |
|
|
202
|
+
| `cwd` | string | `process.cwd()` | Agent working directory |
|
|
203
|
+
| `requireMention` | boolean | `true` | Whether group messages require @bot to trigger |
|
|
204
|
+
| `groupPrompt` | string | - | Extra system prompt for group chats |
|
|
205
|
+
| `directPrompt` | string | - | Extra system prompt for direct chats |
|
|
206
|
+
| `textChunkLimit` | number | `4500` | Max chars per message |
|
|
207
|
+
| `sessionIdleTimeout` | number | `1800000` | Session idle timeout (ms), default 30 min |
|
|
208
|
+
| `debug` | boolean | `false` | Debug mode |
|
|
209
|
+
|
|
210
|
+
## Built-in Commands
|
|
211
|
+
|
|
212
|
+
| Command | Description |
|
|
213
|
+
|------|------|
|
|
214
|
+
| `/bot-reset` | Reset the current session (clear context) |
|
|
215
|
+
| `/bot-model` | View or switch model |
|
|
216
|
+
| `/bot-status` | View current session status |
|
|
217
|
+
| `/bot-restart` | Self-restart the dsh host (~4s, auto relaunch) |
|
|
218
|
+
| `/botplay` | List assembled interactive events; `/botplay <name>` triggers a keyboard card |
|
|
219
|
+
| `/bot-help` | View all commands |
|
|
220
|
+
|
|
221
|
+
## User Extensions (custom slash commands / QQ tools) (v0.9.8+)
|
|
222
|
+
|
|
223
|
+
Extensions live under the **account workspace** (never inside the plugin package), so upgrading the plugin never overwrites them.
|
|
224
|
+
|
|
225
|
+
```
|
|
226
|
+
.qqbot-extensions/
|
|
227
|
+
βββ commands/ # custom slash commands (take effect after /bot-restart)
|
|
228
|
+
βββ tools/ # custom QQ tools callable by the AI (hot-reload via /tools-reload)
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
**Slash command** (`.qqbot-extensions/commands/hello.mjs`):
|
|
232
|
+
```js
|
|
233
|
+
export default {
|
|
234
|
+
name: ['hello', 'δ½ ε₯½'],
|
|
235
|
+
description: 'say hi',
|
|
236
|
+
handler: (ctx) => `π hi ${ctx.command.raw || ''}`.trim(),
|
|
237
|
+
};
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
**QQ tool** (`.qqbot-extensions/tools/roll_dice.mjs`):
|
|
241
|
+
```js
|
|
242
|
+
export default {
|
|
243
|
+
name: 'roll_dice',
|
|
244
|
+
description: 'roll an N-sided die',
|
|
245
|
+
inputSchema: { sides: { type: 'integer', description: 'sides, default 6' } }, // optional params: no `required` key
|
|
246
|
+
run: async (args, env) => ({ ok: true, msg: `π² ${1 + Math.floor(Math.random() * 6)}` }),
|
|
247
|
+
};
|
|
248
|
+
```
|
|
249
|
+
Then run `/tools-reload` (or ask the AI to call the `tools_reload` tool). Commands need a host restart.
|
|
250
|
+
|
|
251
|
+
## Core Modules
|
|
252
|
+
|
|
253
|
+
```
|
|
254
|
+
src/
|
|
255
|
+
βββ index.ts # Cordis plugin entry (async apply)
|
|
256
|
+
βββ config.ts # Config schema
|
|
257
|
+
βββ types.ts # Global types
|
|
258
|
+
βββ setup.ts # Credential binding (QR)
|
|
259
|
+
βββ transport/ # Transport layer
|
|
260
|
+
β βββ inbound.ts # QQ inbound message β agent.followup()
|
|
261
|
+
β βββ outbound.ts # session/event β QQ sendMarkdown
|
|
262
|
+
β βββ outbound-buffer.ts # Streaming buffer
|
|
263
|
+
β βββ chunker.ts # Markdown chunking
|
|
264
|
+
βββ session/ # Session management
|
|
265
|
+
β βββ session-manager.ts # QQ peer β Agent mapping
|
|
266
|
+
β βββ idle-evictor.ts # Idle eviction
|
|
267
|
+
βββ model/ # Model routing
|
|
268
|
+
β βββ model-resolver.ts # Route resolution
|
|
269
|
+
β βββ prefs-store.ts # Per-peer preference persistence
|
|
270
|
+
β βββ settings-reader.ts # settings.yaml read-only
|
|
271
|
+
βββ shared/ # Shared utilities
|
|
272
|
+
β βββ utils.ts # Common helpers
|
|
273
|
+
β βββ scope.ts # scope/peer extraction
|
|
274
|
+
β βββ send-helper.ts # Chunked send
|
|
275
|
+
βββ commands/ # Slash commands
|
|
276
|
+
βββ typings/ # External module declarations
|
|
277
|
+
```
|
|
278
|
+
|
|
279
|
+
## Session Routing
|
|
280
|
+
|
|
281
|
+
sessionKey: `qqbot:${appId}:${scope}:${peerId}`, with the SessionId derived deterministically via SHA-256 so sessions survive restarts.
|
|
282
|
+
|
|
283
|
+
Resolution strategy: in-process reuse β persisted resume β fresh create.
|
|
284
|
+
|
|
285
|
+
## Design Principles
|
|
286
|
+
|
|
287
|
+
- **Pure Cordis plugin** β follows the dsh "Plugins, not loop changes" principle
|
|
288
|
+
- **Declarative dependencies** β `inject = ['agents']`, no direct coupling to other plugins
|
|
289
|
+
- **Session isolation** β one independent Agent per QQ direct user / group
|
|
290
|
+
- **Preset support** β mount presets (toolkits, prompts, etc.) via the `agent-presets` service
|
|
291
|
+
- **Idle eviction** β auto-dispose Agents on timeout to prevent memory leaks
|
|
292
|
+
- **Markdown output** β replies sent as Markdown with code-block/table-aware chunking
|
|
293
|
+
|
|
294
|
+
## Local Development
|
|
295
|
+
|
|
296
|
+
```bash
|
|
297
|
+
# Install dependencies
|
|
298
|
+
pnpm install
|
|
299
|
+
|
|
300
|
+
# Build
|
|
301
|
+
pnpm build
|
|
302
|
+
|
|
303
|
+
# Dev mode (watch)
|
|
304
|
+
pnpm dev
|
|
305
|
+
|
|
306
|
+
# Debug via --patch
|
|
307
|
+
export QQBOT_APPID="xxx" QQBOT_SECRET="xxx"
|
|
308
|
+
npx @deepseek-ai/dsh web --patch /path/to/dsh-qqbot/cordis.dev.yml
|
|
309
|
+
```
|
|
310
|
+
|
|
311
|
+
## License
|
|
312
|
+
|
|
313
|
+
[MIT](./LICENSE)
|