feat: support WeChat as a first-class IM channel

WeChat needs a QR-paired path instead of bot-token setup, so the adapter layer now includes the iLink protocol calls, desktop pairing UI, server-side bind/unbind APIs, and shared IM command behavior. Empty project history falls back to the user's default work directory so mobile /new works without pre-opening a desktop project.

Constraint: Tencent iLink login returns a URL that the desktop UI must render as a QR image locally
Constraint: IM adapters should keep /new, /projects, status, permission, and default workdir behavior consistent across WeChat, Feishu, and Telegram
Rejected: Require users to paste absolute project paths for first WeChat sessions | mobile onboarding should work from the default user working directory
Confidence: high
Scope-risk: moderate
Directive: Do not change WeChat polling back to overlapping intervals; getupdates is a long-poll endpoint and must remain serialized
Tested: Real WeChat QR scan, inbound /status, outbound reply, and unbind E2E
Tested: bun run check:adapters
Tested: bun run quality:pr
Not-tested: Re-scan live WeChat after the default-workdir fallback tweak; covered by adapter config tests and PR gate
This commit is contained in:
程序员阿江(Relakkes)
2026-05-03 17:38:08 +08:00
parent 915d6f413e
commit a627bb19f2
29 changed files with 1521 additions and 49 deletions
+8 -1
View File
@@ -5,6 +5,7 @@
用户文档已经迁移到 `docs/`,并且以 Desktop Webapp 配置流程为准:
- `docs/im/index.md`
- `docs/im/wechat.md`
- `docs/im/telegram.md`
- `docs/im/feishu.md`
@@ -24,7 +25,7 @@ Desktop Webapp Settings
注意两点:
- IM 配置和配对都在 Desktop Webapp 的 `Settings -> IM 接入`
- Webapp 不会自动启动 Adapter 进程,仍需手动运行 `bun run telegram` 或 `bun run feishu`
- Webapp 不会自动启动 Adapter 进程,仍需手动运行 `bun run wechat`、`bun run telegram` 或 `bun run feishu`
## 快速启动
@@ -34,6 +35,8 @@ bun install
bun run telegram
# 或
bun run feishu
# 或
bun run wechat
```
## 开发
@@ -46,6 +49,7 @@ bun test
bun test common/
bun test telegram/
bun test feishu/
bun test wechat/
```
### 目录结构
@@ -59,6 +63,9 @@ adapters/
├── feishu/
│ ├── media.ts # FeishuMediaService(@larksuiteoapi/node-sdk 封装)
│ └── extract-payload.ts # 入站 im.message.receive_v1 事件解析
├── wechat/
│ ├── protocol.ts # 微信 iLink QR 登录 / getupdates / sendmessage 协议封装
│ └── index.ts # 微信文本聊天 Adapter
├── package.json
├── tsconfig.json
└── README.md