dsh-connect 0.7.2 → 0.8.0
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.
- package/README.md +68 -32
- package/README.zh.md +67 -31
- package/client/client.js +387 -0
- package/client/client.js.map +7 -0
- package/client/settings-client.mjs +177 -0
- package/examples/minimal.config.json +16 -0
- package/lib/channels/dingtalk/adapter.d.ts +59 -0
- package/lib/channels/dingtalk/adapter.d.ts.map +1 -0
- package/lib/channels/dingtalk/adapter.js +123 -0
- package/lib/channels/dingtalk/adapter.js.map +1 -0
- package/lib/channels/dingtalk/i18n.d.ts +14 -0
- package/lib/channels/dingtalk/i18n.d.ts.map +1 -0
- package/lib/channels/dingtalk/i18n.js +16 -0
- package/lib/channels/dingtalk/i18n.js.map +1 -0
- package/lib/channels/dingtalk/index.d.ts +127 -0
- package/lib/channels/dingtalk/index.d.ts.map +1 -0
- package/lib/channels/dingtalk/index.js +144 -0
- package/lib/channels/dingtalk/index.js.map +1 -0
- package/lib/channels/dingtalk/message.d.ts +49 -0
- package/lib/channels/dingtalk/message.d.ts.map +1 -0
- package/lib/channels/dingtalk/message.js +43 -0
- package/lib/channels/dingtalk/message.js.map +1 -0
- package/lib/channels/dingtalk/stomp.d.ts +36 -0
- package/lib/channels/dingtalk/stomp.d.ts.map +1 -0
- package/lib/channels/dingtalk/stomp.js +107 -0
- package/lib/channels/dingtalk/stomp.js.map +1 -0
- package/lib/channels/dingtalk/stream.d.ts +53 -0
- package/lib/channels/dingtalk/stream.d.ts.map +1 -0
- package/lib/channels/dingtalk/stream.js +199 -0
- package/lib/channels/dingtalk/stream.js.map +1 -0
- package/lib/channels/dingtalk/webhook.d.ts +84 -0
- package/lib/channels/dingtalk/webhook.d.ts.map +1 -0
- package/lib/channels/dingtalk/webhook.js +143 -0
- package/lib/channels/dingtalk/webhook.js.map +1 -0
- package/lib/channels/feishu/adapter.d.ts +139 -0
- package/lib/channels/feishu/adapter.d.ts.map +1 -0
- package/lib/channels/feishu/adapter.js +677 -0
- package/lib/channels/feishu/adapter.js.map +1 -0
- package/lib/channels/feishu/i18n.d.ts +28 -0
- package/lib/channels/feishu/i18n.d.ts.map +1 -0
- package/lib/channels/feishu/i18n.js +40 -0
- package/lib/channels/feishu/i18n.js.map +1 -0
- package/lib/channels/feishu/index.d.ts +61 -0
- package/lib/channels/feishu/index.d.ts.map +1 -0
- package/lib/channels/feishu/index.js +77 -0
- package/lib/channels/feishu/index.js.map +1 -0
- package/lib/channels/feishu/onboard.d.ts +16 -0
- package/lib/channels/feishu/onboard.d.ts.map +1 -0
- package/lib/channels/feishu/onboard.js +86 -0
- package/lib/channels/feishu/onboard.js.map +1 -0
- package/lib/channels/telegram/adapter.d.ts +70 -0
- package/lib/channels/telegram/adapter.d.ts.map +1 -0
- package/lib/channels/telegram/adapter.js +454 -0
- package/lib/channels/telegram/adapter.js.map +1 -0
- package/lib/channels/telegram/client.d.ts +115 -0
- package/lib/channels/telegram/client.d.ts.map +1 -0
- package/lib/channels/telegram/client.js +198 -0
- package/lib/channels/telegram/client.js.map +1 -0
- package/lib/channels/telegram/i18n.d.ts +14 -0
- package/lib/channels/telegram/i18n.d.ts.map +1 -0
- package/lib/channels/telegram/i18n.js +18 -0
- package/lib/channels/telegram/i18n.js.map +1 -0
- package/lib/channels/telegram/index.d.ts +46 -0
- package/lib/channels/telegram/index.d.ts.map +1 -0
- package/lib/channels/telegram/index.js +54 -0
- package/lib/channels/telegram/index.js.map +1 -0
- package/lib/channels/web/adapter.d.ts +103 -0
- package/lib/channels/web/adapter.d.ts.map +1 -0
- package/lib/channels/web/adapter.js +161 -0
- package/lib/channels/web/adapter.js.map +1 -0
- package/lib/channels/web/index.d.ts +47 -0
- package/lib/channels/web/index.d.ts.map +1 -0
- package/lib/channels/web/index.js +59 -0
- package/lib/channels/web/index.js.map +1 -0
- package/lib/index.d.ts +68 -11
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +141 -8
- package/lib/index.js.map +1 -1
- package/lib/runner.d.ts +1 -2
- package/lib/runner.d.ts.map +1 -1
- package/lib/runner.js.map +1 -1
- package/lib/service.d.ts +1 -1
- package/lib/service.d.ts.map +1 -1
- package/lib/service.js +1 -1
- package/lib/service.js.map +1 -1
- package/lib/settings/channels.d.ts +51 -0
- package/lib/settings/channels.d.ts.map +1 -0
- package/lib/settings/channels.js +101 -0
- package/lib/settings/channels.js.map +1 -0
- package/lib/settings/credential-store.d.ts +39 -0
- package/lib/settings/credential-store.d.ts.map +1 -0
- package/lib/settings/credential-store.js +68 -0
- package/lib/settings/credential-store.js.map +1 -0
- package/lib/settings/index.d.ts +14 -0
- package/lib/settings/index.d.ts.map +1 -0
- package/lib/settings/index.js +14 -0
- package/lib/settings/index.js.map +1 -0
- package/lib/settings/rpc-client.d.ts +36 -0
- package/lib/settings/rpc-client.d.ts.map +1 -0
- package/lib/settings/rpc-client.js +45 -0
- package/lib/settings/rpc-client.js.map +1 -0
- package/lib/settings/settings-model.d.ts +107 -0
- package/lib/settings/settings-model.d.ts.map +1 -0
- package/lib/settings/settings-model.js +110 -0
- package/lib/settings/settings-model.js.map +1 -0
- package/lib/settings/settings-rpc.d.ts +62 -0
- package/lib/settings/settings-rpc.d.ts.map +1 -0
- package/lib/settings/settings-rpc.js +90 -0
- package/lib/settings/settings-rpc.js.map +1 -0
- package/lib/settings/settings-service.d.ts +27 -0
- package/lib/settings/settings-service.d.ts.map +1 -0
- package/lib/settings/settings-service.js +103 -0
- package/lib/settings/settings-service.js.map +1 -0
- package/package.json +48 -6
package/README.md
CHANGED
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
English | [中文](README.zh.md)
|
|
4
4
|
|
|
5
|
-
The **
|
|
5
|
+
The **all-in-one plugin** for connecting [DeepSeek Harness](https://github.com/deepseek-ai/deepseek-harness) (**DSH**) agents to chat platforms (Feishu / Lark, Telegram, DingTalk, and the Web mirror; more to come): session binding, agent driving, streaming reply bridging, interactive menu cards, local commands, and the web-settings stack.
|
|
6
6
|
|
|
7
|
-
>
|
|
7
|
+
> One install, one config block: the core `connect` service, every channel adapter (feishu / telegram / dingtalk / web), and the web-settings stack all live in this single package. Enable the channels you use via the `channels` selector. The former split packages (`dsh-connect-feishu`, `dsh-connect-telegram`, `dsh-connect-dingtalk`, `dsh-connect-web`) and the `dsh-connect-all` bundle no longer exist.
|
|
8
8
|
|
|
9
9
|
## Overview
|
|
10
10
|
|
|
@@ -37,31 +37,28 @@ The plugin runs on the DSH **Host plane** (process-level singleton services), no
|
|
|
37
37
|
Plugin management is a thin wrapper over pnpm in the DSH profile:
|
|
38
38
|
|
|
39
39
|
```sh
|
|
40
|
-
# Install (core +
|
|
41
|
-
dsh plugin --profile web add dsh-connect
|
|
42
|
-
|
|
43
|
-
# Optional: Web mirror monitor
|
|
44
|
-
dsh plugin --profile web add dsh-connect-web
|
|
40
|
+
# Install the single all-in-one plugin (core + all channel adapters + web-settings)
|
|
41
|
+
dsh plugin --profile web add dsh-connect
|
|
45
42
|
```
|
|
46
43
|
|
|
47
44
|
**Upgrade**
|
|
48
45
|
|
|
49
46
|
```sh
|
|
50
|
-
dsh plugin --profile web update dsh-connect
|
|
47
|
+
dsh plugin --profile web update dsh-connect
|
|
51
48
|
```
|
|
52
49
|
|
|
53
|
-
**Disable** — override the bundle-registered
|
|
50
|
+
**Disable** — override the bundle-registered entry with `disabled: true` in the profile patch (see `~/.dsh/profiles/<profile>/cordis.patch.yml`):
|
|
54
51
|
|
|
55
52
|
```yaml
|
|
56
|
-
- id: connect
|
|
53
|
+
- id: connect
|
|
57
54
|
name: dsh-connect
|
|
58
55
|
disabled: true
|
|
59
56
|
```
|
|
60
57
|
|
|
61
|
-
**Complete removal** — uninstall the
|
|
58
|
+
**Complete removal** — uninstall the package and delete the data it created:
|
|
62
59
|
|
|
63
60
|
```sh
|
|
64
|
-
dsh plugin --profile web remove dsh-connect
|
|
61
|
+
dsh plugin --profile web remove dsh-connect
|
|
65
62
|
# then remove the plugin data (see "Permissions & data" below):
|
|
66
63
|
rm -rf .dsh-connect # binding route store (stateDir)
|
|
67
64
|
rm -f ~/.dsh/.dsh-connect/feishu-credentials.json
|
|
@@ -70,30 +67,31 @@ rm -f ~/.dsh/.dsh-connect/feishu-credentials.json
|
|
|
70
67
|
## Quick start
|
|
71
68
|
|
|
72
69
|
1. **Install the plugins** (see above).
|
|
73
|
-
2. **Add the minimal config** to `~/.dsh/profiles/<profile>/cordis.patch.yml` (also see [`examples/profile-cordis.patch.yml`](../../examples/profile-cordis.patch.yml)). The
|
|
70
|
+
2. **Add the minimal config** to `~/.dsh/profiles/<profile>/cordis.patch.yml` (also see [`examples/profile-cordis.patch.yml`](../../examples/profile-cordis.patch.yml)). The plugin registers itself via its bundle manifest, so only override its config — do **not** `insert` it again (a duplicate id crashes dsh at boot):
|
|
74
71
|
|
|
75
72
|
```yaml
|
|
76
73
|
- id: connect
|
|
77
74
|
name: dsh-connect
|
|
78
75
|
# workDir: D:\your\workdir # agent working directory (default: process cwd)
|
|
79
|
-
- id: connect-feishu
|
|
80
|
-
name: dsh-connect-feishu
|
|
81
76
|
config:
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
77
|
+
channels: [feishu] # which channels to activate; omit = all built-in
|
|
78
|
+
# channelDefaults: { language: zh } # keys applied to every channel that doesn't set its own
|
|
79
|
+
feishu:
|
|
80
|
+
appId: cli_xxxx
|
|
81
|
+
appSecret: cli_secret_xxxx
|
|
82
|
+
transport: websocket
|
|
83
|
+
requireMention: true
|
|
84
|
+
dmMode: open
|
|
87
85
|
```
|
|
88
86
|
|
|
89
|
-
3. **Start the host** — `dsh web` (or `dsh run`). With no credentials configured, `
|
|
87
|
+
3. **Start the host** — `dsh web` (or `dsh run`). With no credentials configured, the `feishu` channel enters **one-click onboarding**: scan the QR / open the link from the log to authorize the bot.
|
|
90
88
|
4. **Send a message** to the bot in Feishu. The bot replies with a streaming card; `/help` lists all commands; the conversation also appears in the DSH Web GUI automatically (auto-mirror).
|
|
91
89
|
|
|
92
90
|
A fully reproducible example is the `examples/` folder plus `docs/feishu-setup.md` (Feishu app creation, event subscriptions, publishing).
|
|
93
91
|
|
|
94
92
|
## Configuration
|
|
95
93
|
|
|
96
|
-
Configuration lives in the DSH profile patch (`cordis.patch.yml`) under
|
|
94
|
+
Configuration lives in the DSH profile patch (`cordis.patch.yml`) under the plugin's `config:`. `dsh.shared.config.json` in the project root (or its parent) can supply workspace/state defaults that take precedence for those keys.
|
|
97
95
|
|
|
98
96
|
### `dsh-connect` (core)
|
|
99
97
|
|
|
@@ -112,7 +110,15 @@ Configuration lives in the DSH profile patch (`cordis.patch.yml`) under each plu
|
|
|
112
110
|
| `notifyLevel` | `important` | Default notification level: `full` (stream everything) / `important` (key milestones) / `result` (answer only); per-chat override via settings menu or `/notify` |
|
|
113
111
|
| `progressTimeoutMs` | `300000` | Proactive progress-notice interval (ms): when a turn has sent no standalone card/text for this long, a status card reports the latest milestone; `0` disables; per-chat override via settings menu or `/progress` |
|
|
114
112
|
|
|
115
|
-
###
|
|
113
|
+
### Shared (all channels)
|
|
114
|
+
|
|
115
|
+
| Key | Default | Description |
|
|
116
|
+
|---|---|---|
|
|
117
|
+
| `channels` | all built-in | Which channels to activate: `feishu` / `telegram` / `dingtalk` / `web`. Omit to activate all built-in channels. |
|
|
118
|
+
| `channelDefaults` | `{}` | Keys applied to every channel that doesn't set its own (e.g. `{ language: "zh" }`). |
|
|
119
|
+
| `settingsStatePath` | — | Optional path for the web-settings pane to persist non-secret config (e.g. `.dsh-connect/settings.json`). |
|
|
120
|
+
|
|
121
|
+
### `feishu` (Feishu / Lark channel)
|
|
116
122
|
|
|
117
123
|
| Key | Default | Description |
|
|
118
124
|
|---|---|---|
|
|
@@ -137,6 +143,35 @@ Configuration lives in the DSH profile patch (`cordis.patch.yml`) under each plu
|
|
|
137
143
|
|
|
138
144
|
**Sensitive items** — `appSecret`, `verificationToken`, `encryptKey`, and `feishu-credentials.json`. Prefer environment variables or one-click onboarding; keep them out of version control.
|
|
139
145
|
|
|
146
|
+
### `telegram` (Telegram channel)
|
|
147
|
+
|
|
148
|
+
| Key | Default | Description |
|
|
149
|
+
|---|---|---|
|
|
150
|
+
| `botToken` | env `TELEGRAM_BOT_TOKEN` | Telegram bot token from @BotFather (**secret**) |
|
|
151
|
+
| `requireMention` | `true` | Groups only respond when the bot is @mentioned (or replying to the bot's own message) |
|
|
152
|
+
| `pollingTimeoutSeconds` | `50` | `getUpdates` long-poll timeout in seconds |
|
|
153
|
+
| `baseUrl` | — | Optional Bot API base URL override (e.g. a local Bot API server) |
|
|
154
|
+
| `language` | `zh` | User-facing message language: `zh` / `en` |
|
|
155
|
+
|
|
156
|
+
### `dingtalk` (DingTalk channel)
|
|
157
|
+
|
|
158
|
+
| Key | Default | Description |
|
|
159
|
+
|---|---|---|
|
|
160
|
+
| `webhookUrl` | env `DINGTALK_WEBHOOK_URL` | Group custom-robot webhook URL (proactive push) |
|
|
161
|
+
| `secret` | env `DINGTALK_WEBHOOK_SECRET` | Signing secret (`SEC…`) only when signing is enabled |
|
|
162
|
+
| `stream.clientId` / `stream.clientSecret` | env `DINGTALK_STREAM_CLIENT_ID` / `DINGTALK_STREAM_CLIENT_SECRET` | Bidirectional stream-mode app credentials (**secret**, nested under `stream`) |
|
|
163
|
+
| `stream.requireMention` | `true` | Group replies need an @-mention (stream mode) |
|
|
164
|
+
| `defaultAt` | — | Default @-mentions merged into every push (`{ mobiles, userIds, all }`) |
|
|
165
|
+
| `language` | `zh` | User-facing message language: `zh` / `en` |
|
|
166
|
+
|
|
167
|
+
### `web` (Web mirror channel)
|
|
168
|
+
|
|
169
|
+
| Key | Default | Description |
|
|
170
|
+
|---|---|---|
|
|
171
|
+
| `pollIntervalMs` | `1000` | Mirror-session polling interval (ms) |
|
|
172
|
+
|
|
173
|
+
Environment variables (`FEISHU_*`, `TELEGRAM_*`, `DINGTALK_*`, `DSH_CONNECT_STATE_DIR`, `DSH_HOME`) and the DSH credential store are the preferred way to supply per-channel secrets — the web settings pane writes them to the credential store and `injectSecrets` populates them on load.
|
|
174
|
+
|
|
140
175
|
## Permissions & data
|
|
141
176
|
|
|
142
177
|
- **Files written**
|
|
@@ -168,31 +203,32 @@ Logs come from the DSH host logger (run `dsh web` in a terminal); plugin message
|
|
|
168
203
|
|
|
169
204
|
## Development
|
|
170
205
|
|
|
171
|
-
This is a pnpm workspace;
|
|
206
|
+
This is a pnpm workspace; `dsh-connect` is the single package under `packages/`:
|
|
172
207
|
|
|
173
208
|
```
|
|
174
209
|
packages/
|
|
175
|
-
connect/ # this package —
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
210
|
+
connect/ # this package — the all-in-one plugin
|
|
211
|
+
src/ # core: runner, service, binding, commands, i18n, menus …
|
|
212
|
+
src/channels/ # channel adapters: feishu / telegram / dingtalk / web
|
|
213
|
+
src/settings/ # web-settings stack: host RPC, credential store, settings service/pane
|
|
214
|
+
test/ # node:test suites (run-all.mjs imports every suite)
|
|
215
|
+
client/ # web-settings frontend plugin
|
|
180
216
|
```
|
|
181
217
|
|
|
182
218
|
```sh
|
|
183
219
|
pnpm install
|
|
184
220
|
|
|
185
|
-
# build & typecheck
|
|
221
|
+
# build & typecheck the package
|
|
186
222
|
pnpm --filter dsh-connect build
|
|
187
223
|
pnpm --filter dsh-connect typecheck
|
|
188
224
|
|
|
189
|
-
# unit tests (node:test)
|
|
225
|
+
# unit tests (node:test) — run-all.mjs imports every suite in-process
|
|
190
226
|
pnpm test
|
|
191
227
|
# or run one suite
|
|
192
228
|
node packages/connect/test/unit.test.mjs
|
|
193
229
|
```
|
|
194
230
|
|
|
195
|
-
**Structure** — `src/runner.ts` owns the per-chat agent driver and the streaming bridge (`applyStreamChunk` is the pure, unit-tested chunk assembler); `src/service.ts` owns the adapter registry and routing; `src/i18n.ts` holds the `zh`/`en` dictionaries (keep keys in sync across both); `src/binding.ts` is the route store.
|
|
231
|
+
**Structure** — `src/runner.ts` owns the per-chat agent driver and the streaming bridge (`applyStreamChunk` is the pure, unit-tested chunk assembler); `src/service.ts` owns the adapter registry and routing; `src/channels/` holds the feishu / telegram / dingtalk / web channel adapters; `src/settings/` holds the web-settings stack (host RPC, credential store, settings service); `src/i18n.ts` holds the `zh`/`en` dictionaries (keep keys in sync across both); `src/binding.ts` is the route store.
|
|
196
232
|
|
|
197
233
|
**Contributing** — PRs welcome at [github.com/IvanWu2015/dsh-connect](https://github.com/IvanWu2015/dsh-connect). For user-facing strings, add the key to both `zh` and `en` in `src/i18n.ts`. Release notes live in `CHANGELOG.md`; see `docs/PUBLISHING.md` for the release flow.
|
|
198
234
|
|
package/README.zh.md
CHANGED
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
[English](README.md) | 中文
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
**多合一插件**,将 [DeepSeek Harness](https://github.com/deepseek-ai/deepseek-harness)(**DSH**)智能体连接到聊天平台(飞书 / Lark、Telegram、钉钉,以及 Web 镜像,更多平台陆续到来):会话绑定、智能体驱动、流式回复桥接、交互式菜单卡片、本地命令,以及 Web 设置栈。
|
|
6
6
|
|
|
7
|
-
>
|
|
7
|
+
> 一次安装、一份配置:核心 `connect` 服务、全部通道适配器(feishu / telegram / dingtalk / web)以及 Web 设置栈都内置在这个包里。通过 `channels` 选择器启用你要用的通道。此前的拆分包(`dsh-connect-feishu`、`dsh-connect-telegram`、`dsh-connect-dingtalk`、`dsh-connect-web`)与 `dsh-connect-all` 合集已不存在。
|
|
8
8
|
|
|
9
9
|
## 概述
|
|
10
10
|
|
|
@@ -37,31 +37,28 @@
|
|
|
37
37
|
插件管理是 DSH profile 中对 pnpm 的轻量封装:
|
|
38
38
|
|
|
39
39
|
```sh
|
|
40
|
-
#
|
|
41
|
-
dsh plugin --profile web add dsh-connect
|
|
42
|
-
|
|
43
|
-
# Optional: Web mirror monitor
|
|
44
|
-
dsh plugin --profile web add dsh-connect-web
|
|
40
|
+
# 安装唯一的多合一插件(核心 + 全部通道适配器 + Web 设置)
|
|
41
|
+
dsh plugin --profile web add dsh-connect
|
|
45
42
|
```
|
|
46
43
|
|
|
47
44
|
**升级**
|
|
48
45
|
|
|
49
46
|
```sh
|
|
50
|
-
dsh plugin --profile web update dsh-connect
|
|
47
|
+
dsh plugin --profile web update dsh-connect
|
|
51
48
|
```
|
|
52
49
|
|
|
53
50
|
**禁用** —— 在 profile patch 中将 bundle 注册的条目覆盖为 `disabled: true`(参见 `~/.dsh/profiles/<profile>/cordis.patch.yml`):
|
|
54
51
|
|
|
55
52
|
```yaml
|
|
56
|
-
- id: connect
|
|
53
|
+
- id: connect
|
|
57
54
|
name: dsh-connect
|
|
58
55
|
disabled: true
|
|
59
56
|
```
|
|
60
57
|
|
|
61
|
-
**彻底移除** ——
|
|
58
|
+
**彻底移除** —— 卸载软件包并删除它产生的数据:
|
|
62
59
|
|
|
63
60
|
```sh
|
|
64
|
-
dsh plugin --profile web remove dsh-connect
|
|
61
|
+
dsh plugin --profile web remove dsh-connect
|
|
65
62
|
# then remove the plugin data (see "Permissions & data" below):
|
|
66
63
|
rm -rf .dsh-connect # binding route store (stateDir)
|
|
67
64
|
rm -f ~/.dsh/.dsh-connect/feishu-credentials.json
|
|
@@ -70,30 +67,31 @@ rm -f ~/.dsh/.dsh-connect/feishu-credentials.json
|
|
|
70
67
|
## 快速开始
|
|
71
68
|
|
|
72
69
|
1. **安装插件**(见上文)。
|
|
73
|
-
2. **添加最小配置**到 `~/.dsh/profiles/<profile>/cordis.patch.yml`(另见 [`examples/profile-cordis.patch.yml`](../../examples/profile-cordis.patch.yml)
|
|
70
|
+
2. **添加最小配置**到 `~/.dsh/profiles/<profile>/cordis.patch.yml`(另见 [`examples/profile-cordis.patch.yml`](../../examples/profile-cordis.patch.yml))。该插件会通过其 bundle 清单自动注册,因此这里只需要**覆盖(override)**它的配置——**不要**再用 `insert` 重新插入(重复的 `id` 会让 dsh 启动失败):
|
|
74
71
|
|
|
75
72
|
```yaml
|
|
76
73
|
- id: connect
|
|
77
74
|
name: dsh-connect
|
|
78
75
|
# workDir: D:\your\workdir # agent working directory (default: process cwd)
|
|
79
|
-
- id: connect-feishu
|
|
80
|
-
name: dsh-connect-feishu
|
|
81
76
|
config:
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
77
|
+
channels: [feishu] # 启用哪些通道;省略 = 全部内置
|
|
78
|
+
# channelDefaults: { language: zh } # 应用到未单独设置该键的每个通道
|
|
79
|
+
feishu:
|
|
80
|
+
appId: cli_xxxx
|
|
81
|
+
appSecret: cli_secret_xxxx
|
|
82
|
+
transport: websocket
|
|
83
|
+
requireMention: true
|
|
84
|
+
dmMode: open
|
|
87
85
|
```
|
|
88
86
|
|
|
89
|
-
3. **启动宿主** —— `dsh web`(或 `dsh run`)。未配置凭据时,`
|
|
87
|
+
3. **启动宿主** —— `dsh web`(或 `dsh run`)。未配置凭据时,`feishu` 通道会进入**一键开通**流程:扫描日志中的二维码 / 打开链接以授权机器人。
|
|
90
88
|
4. **在飞书中给机器人发一条消息**。机器人以流式卡片回复;`/help` 列出所有命令;会话也会自动出现在 DSH Web GUI 中(自动镜像)。
|
|
91
89
|
|
|
92
90
|
一个完全可复现的示例是 `examples/` 文件夹加上 `docs/feishu-setup.zh.md`(飞书应用创建、事件订阅、发布)。
|
|
93
91
|
|
|
94
92
|
## 配置
|
|
95
93
|
|
|
96
|
-
配置位于 DSH profile patch(`cordis.patch.yml
|
|
94
|
+
配置位于 DSH profile patch(`cordis.patch.yml`)中该插件的 `config:` 下。项目根目录(或其父目录)中的 `dsh.shared.config.json` 可以提供工作区/状态默认值,并对这些键具有更高优先级。
|
|
97
95
|
|
|
98
96
|
### `dsh-connect`(核心)
|
|
99
97
|
|
|
@@ -112,7 +110,15 @@ rm -f ~/.dsh/.dsh-connect/feishu-credentials.json
|
|
|
112
110
|
| `notifyLevel` | `important` | 默认通知级别:`full`(全部流式输出)/ `important`(关键节点)/ `result`(仅结果);可通过设置菜单或 `/notify` 按聊天覆盖 |
|
|
113
111
|
| `progressTimeoutMs` | `300000` | 主动进度通知间隔(毫秒):当一轮对话在此时间内没有发送独立卡片/文本时,状态卡片会报告最新节点;`0` 表示禁用;可通过设置菜单或 `/progress` 按聊天覆盖 |
|
|
114
112
|
|
|
115
|
-
###
|
|
113
|
+
### 公共(所有通道)
|
|
114
|
+
|
|
115
|
+
| 键 | 默认值 | 说明 |
|
|
116
|
+
|---|---|---|
|
|
117
|
+
| `channels` | 全部内置 | 启用哪些通道:`feishu` / `telegram` / `dingtalk` / `web`。省略则启用全部内置通道。 |
|
|
118
|
+
| `channelDefaults` | `{}` | 应用到未单独设置该键的每个通道(如 `{ language: "zh" }`)。 |
|
|
119
|
+
| `settingsStatePath` | — | Web 设置面板持久化非密钥配置的路径(如 `.dsh-connect/settings.json`)。 |
|
|
120
|
+
|
|
121
|
+
### `feishu`(飞书 / Lark 通道)
|
|
116
122
|
|
|
117
123
|
| 键 | 默认值 | 说明 |
|
|
118
124
|
|---|---|---|
|
|
@@ -137,6 +143,35 @@ rm -f ~/.dsh/.dsh-connect/feishu-credentials.json
|
|
|
137
143
|
|
|
138
144
|
**敏感项** —— `appSecret`、`verificationToken`、`encryptKey` 和 `feishu-credentials.json`。优先使用环境变量或一键开通;切勿将它们提交到版本控制。
|
|
139
145
|
|
|
146
|
+
### `telegram`(Telegram 通道)
|
|
147
|
+
|
|
148
|
+
| 键 | 默认值 | 说明 |
|
|
149
|
+
|---|---|---|
|
|
150
|
+
| `botToken` | 环境变量 `TELEGRAM_BOT_TOKEN` | 来自 @BotFather 的机器人 token(**机密**) |
|
|
151
|
+
| `requireMention` | `true` | 群聊仅在 @提及机器人(或回复机器人自己发的消息)时响应 |
|
|
152
|
+
| `pollingTimeoutSeconds` | `50` | `getUpdates` 长轮询超时(秒) |
|
|
153
|
+
| `baseUrl` | — | 可选:Bot API 基地址覆盖(如本地 Bot API 服务器) |
|
|
154
|
+
| `language` | `zh` | 面向用户的消息语言:`zh` / `en` |
|
|
155
|
+
|
|
156
|
+
### `dingtalk`(钉钉通道)
|
|
157
|
+
|
|
158
|
+
| 键 | 默认值 | 说明 |
|
|
159
|
+
|---|---|---|
|
|
160
|
+
| `webhookUrl` | 环境变量 `DINGTALK_WEBHOOK_URL` | 群自定义机器人 webhook(主动推送) |
|
|
161
|
+
| `secret` | 环境变量 `DINGTALK_WEBHOOK_SECRET` | 仅启用加签时的 `SEC…` 密钥 |
|
|
162
|
+
| `stream.clientId` / `stream.clientSecret` | 环境变量 `DINGTALK_STREAM_CLIENT_ID` / `DINGTALK_STREAM_CLIENT_SECRET` | 双向 stream 模式应用凭据(**机密**,嵌套在 `stream` 下) |
|
|
163
|
+
| `stream.requireMention` | `true` | 群回复需要 @提及(stream 模式) |
|
|
164
|
+
| `defaultAt` | — | 每次推送默认合并的 @列表(`{ mobiles, userIds, all }`) |
|
|
165
|
+
| `language` | `zh` | 面向用户的消息语言:`zh` / `en` |
|
|
166
|
+
|
|
167
|
+
### `web`(Web 镜像通道)
|
|
168
|
+
|
|
169
|
+
| 键 | 默认值 | 说明 |
|
|
170
|
+
|---|---|---|
|
|
171
|
+
| `pollIntervalMs` | `1000` | 镜像会话轮询间隔(毫秒) |
|
|
172
|
+
|
|
173
|
+
环境变量(`FEISHU_*`、`TELEGRAM_*`、`DINGTALK_*`、`DSH_CONNECT_STATE_DIR`、`DSH_HOME`)与 DSH 凭据库是提供各通道密钥的推荐方式——Web 设置面板把密钥写入凭据库,加载时由 `injectSecrets` 注入。
|
|
174
|
+
|
|
140
175
|
## 权限与数据
|
|
141
176
|
|
|
142
177
|
- **写入的文件**
|
|
@@ -168,31 +203,32 @@ rm -f ~/.dsh/.dsh-connect/feishu-credentials.json
|
|
|
168
203
|
|
|
169
204
|
## 开发
|
|
170
205
|
|
|
171
|
-
这是一个 pnpm workspace
|
|
206
|
+
这是一个 pnpm workspace;`dsh-connect` 是 `packages/` 下的**唯一**包:
|
|
172
207
|
|
|
173
208
|
```
|
|
174
209
|
packages/
|
|
175
|
-
connect/ # 本包 —
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
210
|
+
connect/ # 本包 — 多合一插件
|
|
211
|
+
src/ # 核心:runner、service、binding、commands、i18n、menus …
|
|
212
|
+
src/channels/ # 通道适配器:feishu / telegram / dingtalk / web
|
|
213
|
+
src/settings/ # Web 设置栈:宿主 RPC、凭据库、设置服务/面板
|
|
214
|
+
test/ # node:test 套件(run-all.mjs 导入每个套件)
|
|
215
|
+
client/ # Web 设置前端插件
|
|
180
216
|
```
|
|
181
217
|
|
|
182
218
|
```sh
|
|
183
219
|
pnpm install
|
|
184
220
|
|
|
185
|
-
# build & typecheck
|
|
221
|
+
# build & typecheck the package
|
|
186
222
|
pnpm --filter dsh-connect build
|
|
187
223
|
pnpm --filter dsh-connect typecheck
|
|
188
224
|
|
|
189
|
-
# unit tests (node:test)
|
|
225
|
+
# unit tests (node:test) — run-all.mjs 进程内导入每个套件
|
|
190
226
|
pnpm test
|
|
191
227
|
# or run one suite
|
|
192
228
|
node packages/connect/test/unit.test.mjs
|
|
193
229
|
```
|
|
194
230
|
|
|
195
|
-
**结构** —— `src/runner.ts` 负责每个聊天的智能体驱动与流式桥接(`applyStreamChunk` 是纯函数、有单元测试的块组装器);`src/service.ts` 负责适配器注册表与路由;`src/i18n.ts` 存放 `zh`/`en` 词典(两种语言的关键字需保持同步);`src/binding.ts` 是路由存储。
|
|
231
|
+
**结构** —— `src/runner.ts` 负责每个聊天的智能体驱动与流式桥接(`applyStreamChunk` 是纯函数、有单元测试的块组装器);`src/service.ts` 负责适配器注册表与路由;`src/channels/` 存放 feishu / telegram / dingtalk / web 通道适配器;`src/settings/` 存放 Web 设置栈(宿主 RPC、凭据库、设置服务);`src/i18n.ts` 存放 `zh`/`en` 词典(两种语言的关键字需保持同步);`src/binding.ts` 是路由存储。
|
|
196
232
|
|
|
197
233
|
**贡献** —— 欢迎在 [github.com/IvanWu2015/dsh-connect](https://github.com/IvanWu2015/dsh-connect) 提交 PR。对于面向用户的字符串,请在 `src/i18n.ts` 中同时为 `zh` 和 `en` 添加关键字。发布说明在 `CHANGELOG.md` 中;发布流程参见 `docs/PUBLISHING.zh.md`。
|
|
198
234
|
|