Skip to main content
A

dsh-wechat-access

applepinea/dsh-wechat-access

Personal WeChat channel for dsh: connects to a local agent-wechat daemon over HTTP instead of bundling a client, with SSE event intake and cursor resume, async sends with idempotency keys, local message archive, private and group AI replies with batching and image understanding, group @ mentions and self-recall, plus 28 wx_* tools covering memory, emotion, endocrine, virtual life, stickers, Steam, weather and web search. Owner-only tools stay owner-only. The first-run panel links to agent-wechat downloads and shows the wx tokens create command. Its HTTP routes have no DSH access check, so a web page open in your browser could call them.

Install

dsh plugin --profile web add github:applepinea/dsh-wechat-access

README

dsh-wechat-access

把 DeepSeek Harness 接到微信。

这个插件不自己实现微信协议,而是连本机运行的 agent-wechat 守护进程: 它负责登录、收发和媒体传输,插件负责人格、记忆、情绪、内分泌、虚拟生活和群聊判断。

如果你要的是 QQ,那是另一个插件:dsh-qq-access。


一、装之前先搞清楚两件事

1. 这个插件不会自己启动微信

它只是 agent-wechat 的客户端。所以顺序永远是:

先有 agent-wechat 在跑  →  再有这个插件

如果你还没装 agent-wechat,先去 它的 releases 装桌面端。

2. 它和 NapCat 那套没有关系

dsh-qq-access 用 NapCat 接 QQ,这个插件用 agent-wechat 接微信。 两者可以同时运行,互不干扰:一个占 6174 之外的端口,一个连 6174。


二、安装步骤

第 1 步:把 agent-wechat 跑起来

两种方式,任选其一:

方式 A:桌面端(推荐)

到 agent-wechat Releases 下载对应平台的安装包,装上后打开它。

方式 B:命令行

npm install -g --allow-scripts=@agent-wechat/cli @agent-wechat/cli
wx serve                                   # 终端 1:守护进程,保持运行
wx accounts create --alias me              # 终端 2:建一个账号槽位
wx auth login                              # 扫码登录

确认登录成功:

wx status

看到 authenticated: true 和 connection: online 就对了。

注意:守护进程必须一直开着。关掉它,插件就连不上了。

第 2 步:建一个插件专用 token

wx tokens create dsh-wechat-access \
  --accounts '*' \
  --scopes read --scopes send --scopes media --scopes read-state

输出长这样:

{
  "grant": { "id": "aa716fcd-...", "name": "dsh-wechat-access", "scopes": [...] },
  "token": "wx tokens create 的输出(64 位十六进制)"
}

复制那个 token。它只显示这一次。

为什么不用 admin 权限? 插件没有任何管理类操作。只给 read / send / media / read-state 就够收发消息了。万一插件被攻破,对方也改不了你的账号安全设置。

实测验证过:拿这个 token 去调建 token 的接口会返回 403。

第 3 步:装插件

dsh plugin add dsh-wechat-access

或者从本地 tgz 安装:

dsh plugin add ./dsh-wechat-access-0.0.3.tgz

第 4 步:在面板里填两样东西

打开 DSH → 侧边栏 微信接入,首次会看到「首次配置」屏:

字段填什么
服务地址http://127.0.0.1:6174/v1(默认值,一般不用改)
API token第 2 步拿到的那个 64 位字符串
管理员微信号可留空。填了就能用另一个号私聊管理插件

点「生成配置」,然后重载插件。

第 5 步:确认连上了

重载后如果一切正常,面板会显示完整设置页,顶部状态是已连接。

如果显示「还没连上微信」,跳到下面的排错表。


三、排错

面板上「还没连上微信」时,按这个顺序查:

#检查什么怎么确认
1agent-wechat 在跑吗任务栏有图标;或 wx status 能返回
2账号登录了吗wx status 里 connection: online
3地址对吗默认 http://127.0.0.1:6174/v1,端口要和守护进程实际监听一致
4token 对吗重新 wx tokens create 生成一个,替换进去

常见现象

现象原因处理
面板显示「还没连上微信」守护进程没起 / 没登录 / token 错按上表 1–4 排查
能连上但收不到消息事件流断了看面板事件流状态;重启 agent-wechat
发消息一直转圈发送是异步 job,等 accepted 超时检查微信是否真的在线
群里 @全体失败只有群主/管理员能用普通成员会拿到 403,这是微信限制

日志在哪

插件自己的日志走宿主 logger,在 DSH 的开发者工具 Console 里能看到, 前缀是 [dsh-wechat-access]。


四、配置说明

完整示例见 examples/config.example.json。

关键配置

{
  "wechat": {
    "baseUrl": "http://127.0.0.1:6174/v1",
    "token": "wx tokens create 的输出",
    "accountId": "",
    "timeoutMs": 20000,
    "resumeEvents": true
  }
}
字段说明
baseUrl守护进程地址。只允许本机回环
token至少 16 位,不能含换行
accountId留空 = 自动选当前在线的账号;多账号才需要填
resumeEvents断线后是否用游标续传,默认开

为什么地址只能填本机

拿到 token 就等于能以你的微信身份发消息、读全部聊天记录。 把这样的接口暴露到网络上,风险远大于便利。

守护进程在另一台机器上时,正确做法是在本机做 SSH 端口转发, 让插件仍然连 127.0.0.1。

回复范围

{
  "reply": {
    "private": true,
    "group": "off"
  }
}

group 有四个档位:

值行为
off群里只归档,不说话(默认)
mention只有被 @ 或被引用才回
smart按「像在跟人说话 + 提问 + 兴趣词」打分,够阈值才回
all每条都回

访问控制:开箱默认拒绝

装好之后没有任何人会触发回复,包括私聊和群聊。这是刻意的安全默认。

{
  "access": {
    "privateMode": "allowlist",   // 默认
    "groupMode": "allowlist",     // 默认
    "privateIds": [],             // 空 = 不回应任何私聊
    "groupIds": []                // 空 = 不回应任何群
  }
}

要在某个会话里启用,必须把这个人 / 这个群加进白名单:

{
  "access": {
    "privateMode": "allowlist",
    "privateIds": ["wxid_friend"],
    "groupMode": "allowlist",
    "groupIds": ["12345678@chatroom"]
  }
}

reply.group 控制「群里什么时候回」,access 控制「对谁回」—— 两道门都过了才会真的回复。想完全关掉某一类会话,把对应 mode 设成 disabled。


五、工具清单

28 个,全部以 wx_ 开头。

类别工具
状态wx_status
读wx_list_contacts wx_list_conversations wx_read_history wx_search_messages wx_get_message wx_get_user_info wx_get_avatar wx_get_group_members wx_group_member_info
发wx_send_message wx_send_image wx_generate_image wx_meme_send
其它wx_recall_message wx_meme_search wx_meme_collect
内在wx_emotion_status wx_emotion_adjust wx_memory_status wx_memory_save wx_endocrine wx_life_status wx_life_generate
外部wx_web_search wx_web_extract wx_web_batch wx_steam_status

微信没有、所以移除了的

QQ 空间(6 个工具)、戳一戳、名片点赞、群精华、禁言成员、 QQ 系统表情、复读消息、改他人群昵称。

微信只能改自己在群里的昵称,而且没有对应的写入接口暴露, 所以这一项也降级成只读。


六、和 QQ 版的实现差别

dsh-qq-accessdsh-wechat-access
传输NapCat HTTP + 本地上报端口agent-wechat /v1 HTTP
收消息本地 HTTP 服务器收推送SSE 事件流(message.committed 后回查正文)
断线补漏定时轮询 history游标重放,天然可续传
发送同步返回 message_id异步 job,轮询到 accepted
去重归档回查服务端 Idempotency-Key
撤回只需 message_id必须 messageId + serverId
图片直接把 URL 丢给 NapCat先 /uploads 再 /sends

实测踩到的坑(文档没写的)

这些是照文档写会踩、照实测才对的:

文档实际
/events?cursor=X?after=X
事件名 message.receivedmessage.committed
POST /recallsPOST /messages/{id}/recall,要带 serverId
消息里直接带 media空数组,要单独 GET /messages/{id}/media
发送返回 remoteOutcomestate: queued → accepted

七、已知限制

  • 语音、视频只存占位符([语音] / [视频]),不转写、不下载。
  • 群昵称:微信没有「读自己群名片」的独立接口,提示词里的 selfCard 恒为空。
  • @全体成员:只有群主/管理员能用,普通成员调用会 403。
  • 引用回复:需要 messageId 和 serverId 成对,缺一个会 422。
  • 历史消息:agent-wechat 只能读本地 profile 里已有的,拉不到服务端更早的记录。
  • 贴纸发送:能力表里写支持,但 Rust 客户端 scope 表写 Sticker sending is disabled。实测待确认。

八、许可

GNU General Public License v3.0 or later(GPL-3.0-or-later),全文见 LICENSE。

简单说:

  • ✅ 可以自由使用、修改、分发,包括商用
  • ✅ 分发时必须公开源码,且同样用 GPL-3.0 授权
  • ❌ 不能把它改成闭源再发布

第三方组件

组件许可说明
dsh-fatfish-endocrineMIT内分泌引擎,位于 lib/endocrine/。MIT 与 GPL-3.0 兼容,可并入本项目
agent-wechat见其仓库不是本项目的依赖,插件只通过 HTTP 与它通信,不包含其代码

Related plugins