@michengai/dsh-im-connect 0.1.0 → 0.1.2

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.
Files changed (103) hide show
  1. package/README.en.md +224 -0
  2. package/README.md +204 -19
  3. package/assets/branding/dsh-banner.png +0 -0
  4. package/assets/screenshots/dingtalk-chat.jpg +0 -0
  5. package/assets/screenshots/feishu-chat.jpg +0 -0
  6. package/assets/screenshots/qq-chat.jpg +0 -0
  7. package/assets/screenshots/settings-channels.png +0 -0
  8. package/assets/screenshots/telegram-chat.jpg +0 -0
  9. package/assets/screenshots/wecom-chat.jpg +0 -0
  10. package/assets/screenshots/wecom-qr.png +0 -0
  11. package/assets/screenshots/weixin-chat.jpg +0 -0
  12. package/assets/screenshots/workspace-channels.png +0 -0
  13. package/client.js +158 -82
  14. package/lib/channels/dingtalk-card.d.ts +2 -1
  15. package/lib/channels/dingtalk-card.d.ts.map +1 -1
  16. package/lib/channels/dingtalk-card.js +13 -5
  17. package/lib/channels/dingtalk-card.js.map +1 -1
  18. package/lib/channels/dingtalk.d.ts +19 -0
  19. package/lib/channels/dingtalk.d.ts.map +1 -1
  20. package/lib/channels/dingtalk.js +30 -16
  21. package/lib/channels/dingtalk.js.map +1 -1
  22. package/lib/channels/factory.d.ts.map +1 -1
  23. package/lib/channels/factory.js +3 -0
  24. package/lib/channels/factory.js.map +1 -1
  25. package/lib/channels/feishu.d.ts.map +1 -1
  26. package/lib/channels/feishu.js +5 -2
  27. package/lib/channels/feishu.js.map +1 -1
  28. package/lib/channels/meta.d.ts.map +1 -1
  29. package/lib/channels/meta.js +11 -0
  30. package/lib/channels/meta.js.map +1 -1
  31. package/lib/channels/qq.d.ts +9 -0
  32. package/lib/channels/qq.d.ts.map +1 -0
  33. package/lib/channels/qq.js +279 -0
  34. package/lib/channels/qq.js.map +1 -0
  35. package/lib/channels/qr/hub.d.ts +4 -1
  36. package/lib/channels/qr/hub.d.ts.map +1 -1
  37. package/lib/channels/qr/hub.js +27 -0
  38. package/lib/channels/qr/hub.js.map +1 -1
  39. package/lib/channels/qr/qq.d.ts +18 -0
  40. package/lib/channels/qr/qq.d.ts.map +1 -0
  41. package/lib/channels/qr/qq.js +86 -0
  42. package/lib/channels/qr/qq.js.map +1 -0
  43. package/lib/channels/qr/shared.d.ts +3 -0
  44. package/lib/channels/qr/shared.d.ts.map +1 -1
  45. package/lib/channels/qr/shared.js.map +1 -1
  46. package/lib/channels/telegram.d.ts.map +1 -1
  47. package/lib/channels/telegram.js +39 -8
  48. package/lib/channels/telegram.js.map +1 -1
  49. package/lib/channels/wecom.d.ts +1 -0
  50. package/lib/channels/wecom.d.ts.map +1 -1
  51. package/lib/channels/wecom.js +35 -15
  52. package/lib/channels/wecom.js.map +1 -1
  53. package/lib/channels/weixin.d.ts.map +1 -1
  54. package/lib/channels/weixin.js +9 -18
  55. package/lib/channels/weixin.js.map +1 -1
  56. package/lib/client.js +158 -82
  57. package/lib/engine/gateway.d.ts +3 -10
  58. package/lib/engine/gateway.d.ts.map +1 -1
  59. package/lib/engine/gateway.js +54 -65
  60. package/lib/engine/gateway.js.map +1 -1
  61. package/lib/engine/quiet-logger.d.ts +9 -0
  62. package/lib/engine/quiet-logger.d.ts.map +1 -0
  63. package/lib/engine/quiet-logger.js +26 -0
  64. package/lib/engine/quiet-logger.js.map +1 -0
  65. package/lib/engine/reply-stream.d.ts +25 -0
  66. package/lib/engine/reply-stream.d.ts.map +1 -0
  67. package/lib/engine/reply-stream.js +62 -0
  68. package/lib/engine/reply-stream.js.map +1 -0
  69. package/lib/engine/session-id.d.ts +1 -1
  70. package/lib/engine/session-id.d.ts.map +1 -1
  71. package/lib/engine/session-id.js +1 -1
  72. package/lib/engine/session-id.js.map +1 -1
  73. package/lib/engine/types.d.ts +0 -2
  74. package/lib/engine/types.d.ts.map +1 -1
  75. package/lib/index.d.ts +0 -1
  76. package/lib/index.d.ts.map +1 -1
  77. package/lib/index.js +0 -2
  78. package/lib/index.js.map +1 -1
  79. package/lib/manager.d.ts +1 -12
  80. package/lib/manager.d.ts.map +1 -1
  81. package/lib/manager.js +165 -167
  82. package/lib/manager.js.map +1 -1
  83. package/package.json +15 -4
  84. package/src/channels/dingtalk-card.ts +13 -6
  85. package/src/channels/dingtalk.ts +43 -18
  86. package/src/channels/factory.ts +8 -2
  87. package/src/channels/feishu.ts +6 -2
  88. package/src/channels/meta.ts +13 -0
  89. package/src/channels/qq.ts +302 -0
  90. package/src/channels/qr/hub.ts +27 -3
  91. package/src/channels/qr/qq.ts +91 -0
  92. package/src/channels/qr/shared.ts +4 -0
  93. package/src/channels/telegram.ts +39 -9
  94. package/src/channels/wecom.ts +37 -16
  95. package/src/channels/weixin.ts +44 -52
  96. package/src/engine/gateway.ts +316 -325
  97. package/src/engine/quiet-logger.ts +23 -0
  98. package/src/engine/reply-stream.ts +67 -0
  99. package/src/engine/session-id.ts +3 -2
  100. package/src/engine/types.ts +1 -3
  101. package/src/index.ts +2 -5
  102. package/src/manager.ts +542 -569
  103. package/src/engine/access.ts +0 -17
package/README.en.md ADDED
@@ -0,0 +1,224 @@
1
+ <p align="center">
2
+ <img src="assets/branding/dsh-banner.png" alt="DSH IM Connect" width="100%">
3
+ </p>
4
+
5
+ <div align="center">
6
+
7
+ # DSH IM Connect
8
+
9
+ **Connect Feishu, DingTalk, WeCom, WeChat, QQ, and Telegram to local DeepSeek Harness**
10
+
11
+ [简体中文](README.md) · [Apache-2.0](LICENSE)
12
+
13
+ [![License: Apache-2.0](https://img.shields.io/badge/License-Apache--2.0-blue.svg)](LICENSE)
14
+ [![npm package](https://img.shields.io/npm/v/%40michengai%2Fdsh-im-connect.svg?label=npm%20package)](https://www.npmjs.com/package/@michengai/dsh-im-connect)
15
+ [![DSH Web Plugin](https://img.shields.io/badge/DSH%20Web-Plugin-0f766e.svg)](https://github.com/MichengAI/dsh-im-connect)
16
+ [![Node.js 22 or later](https://img.shields.io/badge/Node.js-22%20or%20later-339933.svg?logo=node.js&logoColor=white)](https://nodejs.org/)
17
+ [![Channels](https://img.shields.io/badge/channels-7-238636.svg)](#-supported-channels)
18
+ </div>
19
+
20
+ > DSH IM Connect is a community-maintained DeepSeek Harness (DSH) plugin, not an official DeepSeek AI product.
21
+
22
+ ## Features
23
+
24
+ - Connect DingTalk, Feishu, Lark, WeChat, WeCom, QQ, and Telegram from **Settings → IM Assistant**.
25
+ - Each IM chat maps to an independent DSH session under the workspace **Channels** tab, never mixed into web **Tasks**.
26
+ - Send work, read replies, and approve tools from the phone; model and permission follow the local DSH profile.
27
+ - Bind by QR code or credentials. Secrets go into DSH `ctx.credentials`, not `channels.json`.
28
+ - Paste one sentence into DSH, Codex, or WorkBuddy and let that agent install the plugin locally.
29
+
30
+ ## 📡 Supported channels
31
+
32
+ <p align="center">
33
+ <code>🔔 DingTalk</code>&nbsp;
34
+ <code>🐦 Feishu</code>&nbsp;
35
+ <code>🌐 Lark</code>&nbsp;
36
+ <code>💬 WeChat</code>&nbsp;
37
+ <code>🏢 WeCom</code>&nbsp;
38
+ <code>🐧 QQ</code>&nbsp;
39
+ <code>✈️ Telegram</code>
40
+ </p>
41
+
42
+ | Channel | Status | How to connect | You need |
43
+ |---|---|---|---|
44
+ | 🔔 **DingTalk** | ✅ Ready | QR, or Client ID / Secret | DingTalk open-platform bot; replies prefer AI Card |
45
+ | 🐦 **Feishu** | ✅ Ready | QR only; creates the bot automatically | Feishu account |
46
+ | 🌐 **Lark** | ✅ Ready | QR only | Lark account |
47
+ | 💬 **WeChat** | ✅ Ready* | Official iLink QR | Dedicated account recommended; DM only |
48
+ | 🏢 **WeCom** | ✅ Ready | QR (recommended), or Bot ID / Secret | WeCom intelligent bot |
49
+ | 🐧 **QQ** | ✅ Ready | QR, or AppID / AppSecret | QQ Open Platform bot, not a personal QQ account |
50
+ | ✈️ **Telegram** | ✅ Ready | Bot Token only | `@BotFather`; do not enable Webhook on the same bot |
51
+
52
+ ✅ Ready = text in and out works | *WeChat = official iLink only, no reverse-engineered personal protocol | Groups still require an @ mention
53
+
54
+ ## Screenshots
55
+
56
+ Connect channels in **Settings → IM Assistant**. Unconnected cards show **Configure**; connected cards show a toggle and status:
57
+
58
+ ![IM Assistant settings](assets/screenshots/settings-channels.png)
59
+
60
+ The workspace splits **Tasks** and **Channels**. IM sessions appear only under **Channels**:
61
+
62
+ ![Workspace channel sidebar](assets/screenshots/workspace-channels.png)
63
+
64
+ WeCom and other QR channels support scan-to-bind:
65
+
66
+ ![WeCom QR binding](assets/screenshots/wecom-qr.png)
67
+
68
+ After connecting, drive the local assistant from each IM:
69
+
70
+ <p align="center">
71
+ <img src="assets/screenshots/wecom-chat.jpg" width="220" alt="WeCom chat">
72
+ <img src="assets/screenshots/weixin-chat.jpg" width="220" alt="WeChat chat">
73
+ <img src="assets/screenshots/dingtalk-chat.jpg" width="220" alt="DingTalk chat">
74
+ </p>
75
+ <p align="center">
76
+ <img src="assets/screenshots/feishu-chat.jpg" width="220" alt="Feishu chat">
77
+ <img src="assets/screenshots/qq-chat.jpg" width="220" alt="QQ chat">
78
+ <img src="assets/screenshots/telegram-chat.jpg" width="220" alt="Telegram chat">
79
+ </p>
80
+
81
+ ## Prerequisites
82
+
83
+ - A working DeepSeek Harness Web installation with `dsh` available in PowerShell.
84
+ - Examples use the `web` profile; replace it with the target profile.
85
+ - Source installation and development require Node.js 22+. npm installation does not require running `npm install` in an arbitrary directory.
86
+ - After install, restart `dsh web` and hard-refresh the browser before opening **Settings → IM Assistant**.
87
+
88
+ ## Installation
89
+
90
+ `dsh plugin add` forwards to `pnpm add` in the profile directory. Without a version and official registry, a local mirror or minimum-release-age policy can leave you on an older build.
91
+
92
+ ### Ask another agent to install it
93
+
94
+ This plugin runs inside DeepSeek Harness Web. Copy one of the sentences below into DSH, Codex, or WorkBuddy and let that agent install it into your local `web` profile.
95
+
96
+ From npm:
97
+
98
+ ```text
99
+ Install the latest DSH plugin @michengai/dsh-im-connect into my local web profile using the official npm registry: dsh plugin --profile web add @michengai/dsh-im-connect@latest --registry=https://registry.npmjs.org/. Then run dsh --profile web --dump-config, confirm im-connect is mounted, and remind me to restart DSH Web, hard-refresh the browser, and open Settings → IM Assistant.
100
+ ```
101
+
102
+ From source:
103
+
104
+ ```text
105
+ Install the DSH plugin from source at https://github.com/MichengAI/dsh-im-connect: clone it, run npm install and npm test, then run dsh plugin --profile web add . from that directory. Do not copy lib by itself. Then run dsh --profile web --dump-config, confirm im-connect is mounted, and remind me to restart DSH Web, hard-refresh the browser, and open Settings → IM Assistant.
106
+ ```
107
+
108
+ | Product | How to use it |
109
+ | --- | --- |
110
+ | DSH | Send one of the sentences above to the current session. |
111
+ | Codex | Send one of the sentences above to Codex and let it install locally. |
112
+ | WorkBuddy | Send one of the sentences above to WorkBuddy; for a source install you can also paste `https://github.com/MichengAI/dsh-im-connect`. |
113
+
114
+ Codex and WorkBuddy only install the plugin. After that, open DSH Web and use **Settings → IM Assistant**.
115
+
116
+ You can also run the same npm command yourself:
117
+
118
+ ```powershell
119
+ dsh plugin --profile web add @michengai/dsh-im-connect@latest --registry=https://registry.npmjs.org/
120
+ ```
121
+
122
+ If `dsh` is not on PATH, replace the leading `dsh` with `npx --yes @deepseek-ai/dsh`.
123
+
124
+ ### Install the latest package from the official npm registry
125
+
126
+ Run this from any PowerShell directory:
127
+
128
+ ```powershell
129
+ [Console]::OutputEncoding = [System.Text.Encoding]::UTF8
130
+ $OutputEncoding = [System.Text.Encoding]::UTF8
131
+ dsh plugin --profile web add @michengai/dsh-im-connect@latest --registry=https://registry.npmjs.org/
132
+ dsh --profile web --dump-config
133
+ ```
134
+
135
+ To pin a release, replace `@latest` with a version such as `@0.1.1`.
136
+
137
+ The configuration output should contain `im-connect`. Restart DSH Web and hard-refresh the browser. Do not copy client files manually: `dsh plugin add` also applies `cordis.patch.yml`.
138
+
139
+ ### Install from source
140
+
141
+ Use this for debugging or unpublished changes. The cloned directory becomes the plugin source path:
142
+
143
+ ```powershell
144
+ [Console]::OutputEncoding = [System.Text.Encoding]::UTF8
145
+ $OutputEncoding = [System.Text.Encoding]::UTF8
146
+ Set-Location D:\Repository\deepseek-harness-plugin
147
+ git clone https://github.com/MichengAI/dsh-im-connect.git
148
+ Set-Location .\dsh-im-connect
149
+ npm install
150
+ npm test
151
+ dsh plugin --profile web add .
152
+ dsh --profile web --dump-config
153
+ ```
154
+
155
+ Restart DSH Web and hard-refresh the browser. `dsh plugin ... add .` reads the package metadata and `cordis.patch.yml`; do not install by copying `lib` directly.
156
+
157
+ ## Usage
158
+
159
+ Open **Settings → IM Assistant**, choose the workspace, permission, and model, then connect a channel. The full guide is [使用说明](docs/02-产品与业务/04-使用说明.md).
160
+
161
+ | Goal | Action | Notes |
162
+ | --- | --- | --- |
163
+ | Connect a channel | Select **Configure** on an unconnected card, then scan or enter credentials | Feishu / Lark / WeChat are QR-only; Telegram needs a Bot Token |
164
+ | Pause receiving | Turn off the connected-card toggle | Credentials stay; inbound messages pause |
165
+ | Send work from IM | Type in a DM; in groups, mention the bot | Each chat has its own channel session |
166
+ | Split input | End with `..` to continue, `!!` to flush now | Default merge window is about 5 seconds |
167
+ | Start a new session | Send `/new` or `/clear` | Affects only the current IM chat |
168
+ | Status / help | Send `/status` or `/help` | Scoped to the current channel session |
169
+ | Approve a tool | Reply `批准` or `拒绝` | Also accepts `yes` / `no` / `allow` / `reject` |
170
+ | Review on the web | Open the workspace **Channels** tab | IM sessions never appear under **Tasks** |
171
+
172
+ DingTalk replies prefer official AI Card streaming and fall back to plain text. Do not enable Webhook on the same Telegram bot.
173
+
174
+ ## Permissions and safety limits
175
+
176
+ | Item | Current behavior |
177
+ | --- | --- |
178
+ | Access | Open. Anyone in a DM or group can drive the assistant; groups still require a mention |
179
+ | Management API | Loopback only (`localhost`, `127.0.0.1`, `[::1]`) |
180
+ | Secrets | Prefer DSH `ctx.credentials`; otherwise `%DSH_HOME%\dsh-im-connect\secrets.json` |
181
+ | Channel state | `channels.json` stores enablement and credential refs, not raw secrets |
182
+ | Browser payloads | Never include tokens, secrets, App Secrets, or raw user identifiers |
183
+ | WeChat protocol | Official iLink only; no reverse-engineered personal WeChat protocol |
184
+ | Tool approval | Reply in the same IM chat; cross-chat approval is rejected |
185
+
186
+ Do not expose DSH Web beyond this machine. Permission presets follow the host sandbox-policy; `full-access` does not wrap a sandbox.
187
+
188
+ ## Secondary development
189
+
190
+ This repository develops in `src` and builds to `lib`:
191
+
192
+ - [src\index.ts](src/index.ts): host entry, config, and lifecycle.
193
+ - [src\manager.ts](src/manager.ts): channel start/stop, loopback API, and credential persistence.
194
+ - [src\engine](src/engine): session routing, slash commands, approval, splitting, and outbound push.
195
+ - [src\channels](src/channels): DingTalk, Feishu, Lark, WeChat, WeCom, QQ, and Telegram adapters.
196
+ - `client.js`: settings page and workspace channel sidebar.
197
+ - `tests\*.test.mjs`: routing, QR, credentials, QQ, delivery, and sidebar tests.
198
+
199
+ After changing the source, test and install from the local directory:
200
+
201
+ ```powershell
202
+ [Console]::OutputEncoding = [System.Text.Encoding]::UTF8
203
+ $OutputEncoding = [System.Text.Encoding]::UTF8
204
+ npm test
205
+ dsh plugin --profile web add .
206
+ ```
207
+
208
+ When changing channel or session logic, keep the engine platform-agnostic, keep adapters from creating agents, and keep web tasks separate from IM channels.
209
+
210
+ ## Validation
211
+
212
+ ```powershell
213
+ [Console]::OutputEncoding = [System.Text.Encoding]::UTF8
214
+ $OutputEncoding = [System.Text.Encoding]::UTF8
215
+ npm test
216
+ ```
217
+
218
+ `prepublishOnly` runs the tests before publishing.
219
+
220
+ ## Documentation and license
221
+
222
+ Project status, usage boundaries, architecture, and iteration records begin at the [documentation entry point](docs/00-交接入口/00-阅读导航.md). The detailed operational guide is [使用说明](docs/02-产品与业务/04-使用说明.md).
223
+
224
+ Licensed under [Apache License 2.0](LICENSE).
package/README.md CHANGED
@@ -1,39 +1,224 @@
1
- # dsh-im-connect
1
+ <p align="center">
2
+ <img src="assets/branding/dsh-banner.png" alt="DSH IM Connect" width="100%">
3
+ </p>
2
4
 
3
- DeepSeek Harness 的 IM 助理。工作区对标千问办公:任务和频道分列。
5
+ <div align="center">
4
6
 
5
- 阅读文档:[交接入口](docs/00-交接入口/00-阅读导航.md)
7
+ # DSH IM Connect
8
+
9
+ **把飞书、钉钉、企业微信、微信、QQ、Telegram 接到本机 DeepSeek Harness**
10
+
11
+ [English](README.en.md) · [Apache-2.0](LICENSE)
12
+
13
+ [![许可证:Apache-2.0](https://img.shields.io/badge/许可证-Apache--2.0-blue.svg)](LICENSE)
14
+ [![npm package](https://img.shields.io/npm/v/%40michengai%2Fdsh-im-connect.svg?label=npm%20package)](https://www.npmjs.com/package/@michengai/dsh-im-connect)
15
+ [![DSH Web Plugin](https://img.shields.io/badge/DSH%20Web-Plugin-0f766e.svg)](https://github.com/MichengAI/dsh-im-connect)
16
+ [![Node.js 22 or later](https://img.shields.io/badge/Node.js-22%20or%20later-339933.svg?logo=node.js&logoColor=white)](https://nodejs.org/)
17
+ [![Channels](https://img.shields.io/badge/channels-7-238636.svg)](#-支持的渠道)
18
+ </div>
19
+
20
+ > DSH IM Connect 是社区维护的 DeepSeek Harness(DSH)插件,并非 DeepSeek AI 官方产品。
21
+
22
+ ## 功能概览
23
+
24
+ - 在「设置 → IM助理」里连接钉钉、飞书、Lark、微信、企业微信、QQ、Telegram。
25
+ - 每个 IM 聊天对应一条独立 DSH 会话,出现在工作区「频道」,不会混进网页「任务」。
26
+ - 手机里直接下任务、看回复、批准工具;模型和权限跟随本机 DSH。
27
+ - 支持扫码绑定或手动填凭据;敏感字段写入 DSH `ctx.credentials`,不会进 `channels.json`。
28
+ - 可把一句话复制到 DSH、Codex 或 WorkBuddy,让对方代装到本机 DSH。
29
+
30
+ ## 📡 支持的渠道
31
+
32
+ <p align="center">
33
+ <code>🔔 钉钉</code>&nbsp;
34
+ <code>🐦 飞书</code>&nbsp;
35
+ <code>🌐 Lark</code>&nbsp;
36
+ <code>💬 微信</code>&nbsp;
37
+ <code>🏢 企业微信</code>&nbsp;
38
+ <code>🐧 QQ</code>&nbsp;
39
+ <code>✈️ Telegram</code>
40
+ </p>
41
+
42
+ | 渠道 | 状态 | 接入方式 | 需要 |
43
+ |---|---|---|---|
44
+ | 🔔 **钉钉** | ✅ 可用 | 扫码,或 Client ID / Secret | 钉钉开放平台机器人;回复优先走 AI Card |
45
+ | 🐦 **飞书** | ✅ 可用 | 仅扫码,自动创建机器人 | 飞书账号 |
46
+ | 🌐 **Lark** | ✅ 可用 | 仅扫码 | Lark 国际版账号 |
47
+ | 💬 **微信** | ✅ 可用* | 官方 iLink 扫码 | 建议专用小号;仅私聊 |
48
+ | 🏢 **企业微信** | ✅ 可用 | 扫码(推荐),或 Bot ID / Secret | 企业微信智能机器人 |
49
+ | 🐧 **QQ** | ✅ 可用 | 扫码,或 AppID / AppSecret | QQ 开放平台机器人,不是个人号 |
50
+ | ✈️ **Telegram** | ✅ 可用 | 仅填 Bot Token | `@BotFather`;同一 Bot 不要同时开 Webhook |
51
+
52
+ ✅ 可用 = 文字收发可用 | *微信 = 只走腾讯官方 iLink,不做逆向个人号 | 群聊都需要 @ 机器人才回复
53
+
54
+ ## 界面预览
55
+
56
+ 在「设置 → IM助理」连接渠道。未连接显示「配置」,已连接显示开关和状态:
57
+
58
+ ![IM 助理设置页](assets/screenshots/settings-channels.png)
59
+
60
+ 工作区左侧「任务 / 频道」分列。IM 会话只出现在「频道」:
61
+
62
+ ![工作区频道侧栏](assets/screenshots/workspace-channels.png)
63
+
64
+ 企业微信等渠道支持扫码快捷绑定:
65
+
66
+ ![企业微信扫码绑定](assets/screenshots/wecom-qr.png)
67
+
68
+ 连上后,可在各 IM 里直接驱动本机助手:
69
+
70
+ <p align="center">
71
+ <img src="assets/screenshots/wecom-chat.jpg" width="220" alt="企业微信对话">
72
+ <img src="assets/screenshots/weixin-chat.jpg" width="220" alt="微信对话">
73
+ <img src="assets/screenshots/dingtalk-chat.jpg" width="220" alt="钉钉对话">
74
+ </p>
75
+ <p align="center">
76
+ <img src="assets/screenshots/feishu-chat.jpg" width="220" alt="飞书对话">
77
+ <img src="assets/screenshots/qq-chat.jpg" width="220" alt="QQ 对话">
78
+ <img src="assets/screenshots/telegram-chat.jpg" width="220" alt="Telegram 对话">
79
+ </p>
80
+
81
+ ## 前置条件
82
+
83
+ - 已可正常运行 DeepSeek Harness Web,且可在 PowerShell 中使用 `dsh`。
84
+ - 以下示例使用 `web` profile;请替换为实际目标 profile。
85
+ - 从源码安装或二次开发需要 Node.js 22+;仅从 npm 安装无需在任意目录执行 `npm install`。
86
+ - 安装后必须重启 `dsh web`,并在浏览器硬刷新,才能看到「设置 → IM助理」。
6
87
 
7
88
  ## 安装
8
89
 
90
+ `dsh plugin add` 会转发到 profile 目录里的 `pnpm add`。不写版本、不指定官方源时,本机镜像和最短发布间隔可能让你停在旧版。
91
+
92
+ ### 交给其他 Agent 一句话安装
93
+
94
+ 本插件运行在 DeepSeek Harness Web 里。把下面其中一句复制到 DSH、Codex 或 WorkBuddy,让它代你安装到本机 `web` profile。
95
+
96
+ 从 npm 安装:
97
+
98
+ ```text
99
+ 请把 DSH 插件 @michengai/dsh-im-connect 最新版装进本机 web profile,使用官方 npm 源执行:dsh plugin --profile web add @michengai/dsh-im-connect@latest --registry=https://registry.npmjs.org/。装完执行 dsh --profile web --dump-config,确认已挂载 im-connect,并提醒我重启 DSH Web 后硬刷新浏览器,打开「设置 → IM助理」。
9
100
  ```
10
- dsh plugin --profile web add @michengai/dsh-im-connect
101
+
102
+ 从源码安装:
103
+
104
+ ```text
105
+ 请从 https://github.com/MichengAI/dsh-im-connect 安装 DSH 插件:克隆仓库,执行 npm install 和 npm test,再在该目录执行 dsh plugin --profile web add .。不要只复制 lib。然后执行 dsh --profile web --dump-config,确认已挂载 im-connect,并提醒我重启 DSH Web 后硬刷新浏览器,打开「设置 → IM助理」。
11
106
  ```
12
107
 
13
- 重启 `dsh web`,打开「设置 → IM助理」。
108
+ | 产品 | 怎么用 |
109
+ | --- | --- |
110
+ | DSH | 把上面其中一句发给当前会话。 |
111
+ | Codex | 把上面其中一句发给 Codex,让它在本机执行安装。 |
112
+ | WorkBuddy | 把上面其中一句发给 WorkBuddy;源码安装也可同时粘贴仓库地址 `https://github.com/MichengAI/dsh-im-connect`。 |
113
+
114
+ Codex 和 WorkBuddy 只负责代装;装好后仍要打开 DSH Web 使用「设置 → IM助理」。
14
115
 
15
- 飞书 / Lark、钉钉、企业微信还需要在本机或 profile 里安装可选依赖:
116
+ 也可以自己执行同一条 npm 命令:
16
117
 
118
+ ```powershell
119
+ dsh plugin --profile web add @michengai/dsh-im-connect@latest --registry=https://registry.npmjs.org/
17
120
  ```
18
- npm install @larksuiteoapi/node-sdk dingtalk-stream @wecom/aibot-node-sdk
121
+
122
+ 未把 `dsh` 装进 PATH 时,把开头的 `dsh` 换成 `npx --yes @deepseek-ai/dsh`。
123
+
124
+ ### 从官方 npm 安装最新版
125
+
126
+ 在任意 PowerShell 目录执行:
127
+
128
+ ```powershell
129
+ [Console]::OutputEncoding = [System.Text.Encoding]::UTF8
130
+ $OutputEncoding = [System.Text.Encoding]::UTF8
131
+ dsh plugin --profile web add @michengai/dsh-im-connect@latest --registry=https://registry.npmjs.org/
132
+ dsh --profile web --dump-config
133
+ ```
134
+
135
+ 需要钉死某一版时,把 `@latest` 换成具体版本,例如 `@0.1.1`。
136
+
137
+ 配置输出中应包含 `im-connect`。安装后重启 DSH Web 并在浏览器硬刷新。不要手工复制客户端文件,`dsh plugin add` 会同时应用 `cordis.patch.yml`。
138
+
139
+ ### 从源码安装
140
+
141
+ 适用于调试或使用未发布改动。克隆后的本地路径就是插件安装路径:
142
+
143
+ ```powershell
144
+ [Console]::OutputEncoding = [System.Text.Encoding]::UTF8
145
+ $OutputEncoding = [System.Text.Encoding]::UTF8
146
+ Set-Location D:\Repository\deepseek-harness-plugin
147
+ git clone https://github.com/MichengAI/dsh-im-connect.git
148
+ Set-Location .\dsh-im-connect
149
+ npm install
150
+ npm test
151
+ dsh plugin --profile web add .
152
+ dsh --profile web --dump-config
19
153
  ```
20
154
 
21
- 微信走官方 iLink 扫码;Telegram 填 Bot Token。同一 Bot 不要同时开 Webhook。
155
+ 完成后重启 DSH Web 并硬刷新浏览器。`dsh plugin ... add .` 会读取当前目录的包信息和 `cordis.patch.yml`;不要改为直接复制 `lib` 目录。
156
+
157
+ ## 使用
158
+
159
+ 打开「设置 → IM助理」,先选工作区、权限和模型,再连接渠道。详细步骤见 [使用说明](docs/02-产品与业务/04-使用说明.md)。
160
+
161
+ | 目标 | 操作 | 说明 |
162
+ | --- | --- | --- |
163
+ | 连接渠道 | 未连接卡片点「配置」,扫码或填写凭据 | 飞书 / Lark / 微信仅扫码;Telegram 仅填 Bot Token |
164
+ | 暂停接收 | 关闭已连接卡片上的开关 | 凭据保留,只是暂时不收消息 |
165
+ | 在 IM 里下任务 | 私聊直接发文字;群聊需要 @ 机器人 | 每个聊天对应一条独立频道会话 |
166
+ | 分段输入 | 结尾加 `..` 表示还有后续,`!!` 表示立即提交 | 默认约 5 秒合并窗口 |
167
+ | 新开会话 | 发送 `/new` 或 `/clear` | 只影响当前 IM 聊天,不影响网页任务 |
168
+ | 查看状态 / 帮助 | 发送 `/status` 或 `/help` | 只作用于当前频道会话 |
169
+ | 批准工具 | 回复「批准」或「拒绝」 | 也接受 `yes` / `no` / `allow` / `reject` |
170
+ | 在网页里回看 | 打开工作区「频道」页签 | IM 会话不会出现在「任务」里 |
22
171
 
23
- ## 行为
172
+ 钉钉回复优先走官方 AI Card 流式卡片;创建失败则回退普通文本。Telegram 同一 Bot 不要同时开 Webhook。
24
173
 
25
- - 每个 IM 聊天对应一条独立 DSH 会话,不进入网页「任务」
26
- - `/help` `/status` `/new` `/clear`
27
- - 默认跟随当前网页模型;企业内部默认放行,群聊仍需 @ 才会回复
28
- - 需要工具批准时,在聊天里回「批准」或「拒绝」
29
- - 钉钉回复走官方 AI Card 流式卡片;创建失败则回退普通文本
174
+ ## 权限与安全边界
30
175
 
31
- 敏感字段优先写入 DSH `ctx.credentials`;没有该服务时落到 `%DSH_HOME%\dsh-im-connect\secrets.json`,不进 `channels.json`。
176
+ | 项 | 当前行为 |
177
+ | --- | --- |
178
+ | 用户准入 | 全放开。私聊和群聊都可驱动助手;群聊仍只响应 @ |
179
+ | 管理接口 | 仅本机回环(`localhost` / `127.0.0.1` / `[::1]`) |
180
+ | 敏感字段 | 优先写入 DSH `ctx.credentials`;没有该服务时落到 `%DSH_HOME%\dsh-im-connect\secrets.json` |
181
+ | 渠道状态 | `channels.json` 只保存启用状态和凭据引用,不保存明文 Secret |
182
+ | 浏览器回包 | 不返回 token、secret、App Secret 或原始用户标识 |
183
+ | 微信协议 | 只走腾讯官方 iLink,不使用逆向个人微信协议 |
184
+ | 工具批准 | 在对应 IM 聊天里回复,不能跨会话批准 |
32
185
 
33
- ## 开发
186
+ 不要把 DSH Web 暴露到非本机地址。权限预设依赖 Host 的 sandbox-policy;`full-access` 不套沙箱。
34
187
 
188
+ ## 二次开发
189
+
190
+ 本仓库用 `src` 开发,构建到 `lib`:
191
+
192
+ - [src\index.ts](src/index.ts):Host 入口、配置和生命周期。
193
+ - [src\manager.ts](src/manager.ts):渠道启停、本机 API、凭据落盘。
194
+ - [src\engine](src/engine):会话路由、斜杠命令、审批、分片和回推。
195
+ - [src\channels](src/channels):钉钉、飞书、Lark、微信、企业微信、QQ、Telegram 适配器。
196
+ - `client.js`:设置页和工作区频道侧栏。
197
+ - `tests\*.test.mjs`:路由、扫码、凭据、QQ、投递和侧栏测试。
198
+
199
+ 修改后运行测试并以本地目录安装验证:
200
+
201
+ ```powershell
202
+ [Console]::OutputEncoding = [System.Text.Encoding]::UTF8
203
+ $OutputEncoding = [System.Text.Encoding]::UTF8
204
+ npm test
205
+ dsh plugin --profile web add .
35
206
  ```
207
+
208
+ 修改渠道或会话逻辑时,必须保持:引擎不写死平台名、渠道不创建 agent、网页任务与 IM 频道分列。
209
+
210
+ ## 验证
211
+
212
+ ```powershell
213
+ [Console]::OutputEncoding = [System.Text.Encoding]::UTF8
214
+ $OutputEncoding = [System.Text.Encoding]::UTF8
36
215
  npm test
37
- ```
38
-
39
-
216
+ ```
217
+
218
+ `prepublishOnly` 会在发布前自动执行测试。
219
+
220
+ ## 项目文档与许可证
221
+
222
+ 项目状态、使用边界、技术架构和迭代记录从[文档交接入口](docs/00-交接入口/00-阅读导航.md)开始。详细操作说明见 [使用说明](docs/02-产品与业务/04-使用说明.md)。
223
+
224
+ 本项目采用 [Apache License 2.0](LICENSE)。
Binary file
Binary file
Binary file