Skip to content
dsh.fish
Bundle

@deepseek-ai/dsh-wx-msg-tool

DSH 微信消息工具插件:微信 iLink(ClawBot) 协议扫码登录与消息收发,设置页扫码登录并保存 api-token

Source
yauntyour
stars
1 stars
License
MIT
Updated
Updated 14 days ago

Readme

# @deepseek-ai/dsh-wx-msg-tool

DSH 微信消息工具插件(微信 ClawBot / iLink 协议):设置页扫码登录并自动保存 api-token,提供 `wx_login` / `wx_send` / `wx_poll` / `wx_status` 四个工具,让 DSH 直接收发微信消息。

基于腾讯官方开放的微信 ClawBot(iLink,智联)Bot API(`ilinkai.weixin.qq.com`),HTTP/JSON 协议,无 SDK 依赖、无 Hook、无封号风险。使用前请阅读并遵守《微信ClawBot功能使用条款》。

## 功能

- **设置页扫码登录**:DSH Web 设置页新增「微信消息」页 —— 点「扫码登录」由浏览器本地 canvas 绘制二维码(腾讯返回的 `qrcode_img_content` 是 liteapp 交互页 URL 而非图片,且禁止 iframe 嵌入,故插件内置零依赖 QR 编码器按该 URL 编码,与官方页面渲染等价),手机微信扫码确认后 api-token 自动保存(设置文档 `secret` 字段 + `<DSH_HOME>/plugins/wx-msg-tool/state.json`,仅存本机,浏览器永远拿不到 token)。设置页通过插件自有 HTTP 通道(`/wx-msg/state`、`/wx-msg/login`、`/wx-msg/config`)与宿主通信——官方 settings 线上通道只暴露核心命名空间(`WEB_SETTINGS_NAMESPACES`),第三方设置页需要自带通道(与 dsh-better-sidebar 同模式)。
- **工具(4 个)**:

| 工具 | 说明 |
|---|---|
| `wx_login` | `qrcode` 发起扫码登录(headless 可用)/ `status` 查登录态 / `logout` 退出并清除 token |
| `wx_send` | 发送文本消息;`to` 与 `context_token` 取自 `wx_poll` 返回的消息(回话关联必需) |
| `wx_poll` | 收取消息:关闭自动轮询时直连服务器长轮询,开启时读取后台监控收件箱 |
| `wx_status` | 通道状态:登录态 / token 是否存在 / 监控状态 / 收件箱条数 |

- **后台自动长轮询**:设置页开启后,宿主进程持续长轮询并把消息暂存到收件箱(`inbox.jsonl`),供后续 `wx_poll` 取走;会话过期(errcode -14)自动停轮询并提示重新登录。
- **自动会话回复(Clawbot 闭环)**:设置页开启「收到消息自动触发 DSH 会话回复」后,每条微信消息驱动一轮真实 DSH 会话——每用户一个持久会话(`chats.json` 记录会话 ID,重启后 resume 续聊),用默认模型跑完一轮后把助手的回复自动发回微信(带原消息的 `context_token` 关联会话)。注意会消耗模型调用;bot 无法给没有会话的用户发首条消息(iLink 协议限制,需对方先发一条消息)。
- **headless 兼容**:web 端登录后 token 落盘,headless profile 可直接复用;也可用环境变量 `WX_MSG_API_TOKEN` / `WX_MSG_BASE_URL` / `WX_MSG_AUTO_POLL=1` 覆盖。

## 安装

### 1. Profile Bundle(推荐)

```sh
# 构建并打包(产物 DSH-WX-Msg-Tool/deepseek-ai-dsh-wx-msg-tool-1.1.0.tgz)
cd DSH-WX-Msg-Tool && npm install --ignore-scripts && npm run build && npm pack

# 挂载到 web profile(设置页在 web 端)
dsh plugin --profile web add "D:/Developments/Workspace/DSH-WX-Msg-Tool/deepseek-ai-dsh-wx-msg-tool-1.1.0.tgz"

# 一次性任务/headless 也需要时
dsh plugin --profile headless add "D:/Developments/Workspace/DSH-WX-Msg-Tool/deepseek-ai-dsh-wx-msg-tool-1.1.0.tgz"
```

> 挂载后需重启 `dsh web`(profile 组合在启动时加载)。开发期构建依赖说明见下文「开发」。

### 2. 验证安装

```sh
dsh --profile web --dump-config | grep -A2 wx-msg-tool
# 客户端产物路由(浏览器同源访问)
curl -s "http://127.0.0.1:3080/plugins/@deepseek-ai/dsh-wx-msg-tool/client.js" | head -5
```

Install

dsh plugin --profile web add github:yauntyour/DSH-WX-Msg-Tool

Profile: web

  • This package builds from source on install. pnpm will ask you to allow its build script — that is permission to run the package’s code on your machine, outside the agent sandbox. Only allow sources you trust.
  • This source has no pinned commit, so a later push upstream changes what installs. Prefer pinning a commit.
Source