dsh-qq-bot: Using QQ Official Bot API to Connect Group Chats and Private Chats to DSH Agent

Preface

Running agents in DeepSeek Harness (DSH) typically involves CLI or Web interfaces. If you want colleagues or users to chat directly in QQ without introducing third-party bot frameworks like mirai or go-cqhttp, you need a plugin that connects directly to the WebSocket gateway and REST API provided by the QQ Open Platform, mapping each conversation to an independent DSH Agent.

Below is an introduction to the community plugin dsh-qq-bot (maintainer sindo-s). It uses the official channel, employing Node.js built-in WebSocket and fetch for connectivity and data transmission. It belongs to the Workflow category of plugins within the DSH ecosystem.

What is this

dsh-qq-bot is a standard DSH plugin: it connects QQ group chats and private chats to independent DSH Agents via the QQ Open Platform’s official WebSocket gateway and REST API. The original description is: DeepSeek Harness plugin bridging QQ official Bot API to dsh agents (no third-party bot framework).

It does not rely on Desktop Next; it reuses the host DSH’s Agents, default models, tools, and attachment services. It can run on Linux servers or containers using environment variables and independent profiles, requiring no inbound ports to be exposed for this plugin (only outbound WebSocket/HTTPS is needed).

Core Features

Verified capabilities include:

  1. Conversation Isolation: Each QQ group or user corresponds to an independent Agent session; messages are correlated by Harness turn, and events are deduplicated upon gateway reconnection.
  2. Built-in Commands: /new, /stop, /tools, /help; /whoami (or /id) is available for self-discovery of OpenIDs, facilitating whitelist configuration.
  3. Security Defaults: publicMode defaults to false; only OpenIDs in allowGroups / allowUsers can access the Agent. If the whitelist is empty, normal messages are rejected. enableWhoami is enabled by default for convenient initial configuration.
  4. Tool Boundaries: The QQ Agent does not inherit all host tools by default; qq_send can only send to the current session. Tools are whitelisted via allowedTools by their registered names; corresponding plugins or MCPs must be installed in DSH first.
  5. Image Input: Users can send images in private chats or group chats (requires a vision model and host attachments service). Audio, video, files, and other types are not supported (see README for known limitations).
  6. Reliability: Includes single-flight session creation, token refresh merging, gateway exponential backoff, Unicode-based sharding for oversized text, etc. Details can be found in the “Reliability Strategies” section of the project README.

The current package version is 0.3.2 (package.json), declaring compatibility with DSH 0.1.5-rc.2 and 0.1.6-alpha.2, Cordis 4.0.2 / Schemastery 3.18.2. License: MIT.

Prerequisites

  1. Node.js 22.6 or higher.
  2. DeepSeek Harness is already running, with default provider/model configured.
  3. A bot has been created on the QQ Open Platform, obtaining AppID and AppSecret; the bot is online, or the test group/user has been added to the sandbox.
  4. Installation and execution use the same DSH_HOME, profile, and system user. QQ credentials are provided via environment variables or configuration files; the plugin does not automatically load .env.

Credential environment variables (set in the process starting DSH):

# PowerShell
$env:QQ_BOT_APP_ID = 'your AppID'
$env:QQ_BOT_APP_SECRET = 'your AppSecret'
# Bash
export QQ_BOT_APP_ID='your AppID'
export QQ_BOT_APP_SECRET='your AppSecret'

Installation and Activation

Source Code Debugging (Patch Method)

Run dependency installation and the wizard in the plugin source directory, then start DSH with an absolute path patch:

npm ci
npm run setup
npm run doctor

Start the installed DSH (replace the path with the absolute path to your cordis.yml):

dsh web --patch "/absolute/path/to/dsh-qq-bot/cordis.yml"

If running from DSH source code, execute in the DSH repository directory:

pnpm dsh web --patch "/absolute/path/to/dsh-qq-bot/cordis.yml"

The wizard generates a configuration containing absolute plugin paths; AppSecret input is not echoed, and existing files are not overwritten. To save the configuration elsewhere:

npm run setup -- --output qq.local.yml

Installing as a DSH Plugin Bundle

Follow DSH official packaging standards. Build in the source directory and install to a specific profile (example profile name is qq, tarball name varies by version, e.g., dsh-qq-bot-0.3.2.tgz):

npm ci
npm pack
dsh plugin --profile qq add /absolute/path/to/dsh-qq-bot-0.3.2.tgz
npm run setup -- --bundle --output cordis.yml
npm run doctor
dsh --profile qq --patch /absolute/path/to/cordis.yml

First, configure DSH default provider/model in that profile. The --bundle mode generates an override entry for id: qq-bot; do not mix it with the “insert entry” of the source mode. The release package also provides dsh-qq-bot setup and dsh-qq-bot doctor executable entry points.

Headless Server / Independent Profile

Non-interactive initialization of bundle configuration:

npm ci
npm pack
dsh plugin --profile qq add /absolute/path/to/dsh-qq-bot-0.3.2.tgz
npm run init -- --bundle --output cordis.yml

After setting QQ credential variables in the same runtime environment:

npm run doctor
dsh --profile qq --patch /absolute/path/to/cordis.yml

init does not read credentials from environment variables; the generated configuration defaults to whitelist-only. Interactive configuration is still available via npm run setup -- --bundle.

Configuration Check

npm run doctor performs offline checks on YAML, QQ entries, credential existence, field types, and ranges. It does not print credentials or call QQ APIs. Example for a custom file:

npm run doctor -- --output qq.local.yml

Main configuration fields (excerpt; see README for full table):

Field Default Description
enabled true Whether to connect to QQ
appId / clientSecret empty If empty, reads QQ_BOT_APP_ID / QQ_BOT_APP_SECRET
sandbox false Whether to use Sandbox API
publicMode false Whether to allow all QQ users to access
allowGroups / allowUsers [] Allowed group_openid / user_openid
allowedTools [] Host tool registration names the QQ Agent can inherit

DSH patches replace the entire config, so when editing the overlay, you must retain all configurations required by that layer.

Typical Usage

Configuring Whitelist with /whoami

If you don’t know the OpenID initially, leave the whitelist empty. Keep publicMode: false and enableWhoami: true. After starting:

  1. Send /whoami via private chat to the bot to get user_openid; or @ the bot in a test group and send /whoami to get group_openid.
  2. Copy the allowUsers or allowGroups snippet from the reply to cordis.yml, save, and reload the plugin.
  3. In a sandbox environment, you must also add the corresponding group/user to the sandbox list on the QQ Open Platform.

OpenID is not a QQ number or group number and is only valid for the current bot AppID. If normal messages have no response but /whoami works, it is likely that the OpenID was not added to the whitelist.

Managing Sessions and Tools in QQ

Command Function
/new Destroy current Agent, create new session on next message
/stop Cancel current task and clear queued messages
/tools View tools that are allowed and loaded, or configured but not loaded
/help Show help

If capabilities like web search are needed, install the tool in the host first, then write the exact registration name into allowedTools, for example:

allowedTools:
  - web_search

Send /tools in QQ to confirm status. Do not expose Shell, arbitrary file writing, or credential-related tools on public bots.

DSH Desktop Next (WSL)

The plugin must be installed in the current WSL distribution and the active slot’s DSH_HOME of Desktop Next, using the runtime’s built-in dsh plugin --profile web add <tarball>. QQ configuration is written in the id: qq-bot override entry of home/profiles/web/cordis.patch.yml; if credentials are not ready, set enabled: false and enable it after filling them in. Core upgrades may switch slots; after upgrading, confirm that the plugin and QQ configuration have been migrated.

Scenarios and Notes

Who it is for: Users who have already configured models and tools on DSH and want to use QQ official Bot capabilities for internal testing or small-scale collaboration; those who need independent Agent sessions for each group/user and can accept text and image input (audio/video files are not supported currently).

Execution Permissions: The plugin is loaded in the current dsh process. The tools the Agent can call depend on allowedTools and the services already loaded by the host. Before installation, you should read the GitHub repository source code and the MIT license to confirm that the credential and whitelist policies meet your security requirements. Only set publicMode: true when you are confident about the bot and tool capabilities.

Ecosystem Note: DeepSeek Harness adopts an “everything is a plugin” extension approach; the SkillHub Plugin Directory is a community site and has no official affiliation with DeepSeek / High-Flyer.

Conclusion

dsh-qq-bot connects the QQ Open Platform official gateway and REST API to DSH Agents without binding to third-party bot frameworks. It is suitable for providing controlled QQ conversation entry points in CLI, Web, servers, or Desktop Next WSL runtimes. See the project README for more configuration, troubleshooting tables, and development check commands.

羽毛球分组比赛记分
小程序二维码

欢迎使用《羽毛球分组比赛记分》微信小程序

Xiaoye