dsh-message-gateway 0.1.24 → 0.1.26

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/LICENSE CHANGED
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2026 dsh-message-gateway contributors
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ MIT License
2
+
3
+ Copyright (c) 2026 dsh-message-gateway contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.en.md CHANGED
@@ -1,96 +1,96 @@
1
- # dsh-message-gateway
2
-
3
- [中文](README.md) · [Español](README.es.md)
4
-
5
- ![dsh-message-gateway UI Preview](assets/screenshot.png)
6
-
7
- A message-platform gateway plugin for the DSH Web GUI: a "Message platforms" entry below the "New session" button opens a full-screen manager for multi-platform message connectors — credential save, connection tests, status monitoring — plus a built-in persistent bridge for the WeCom AI bot: external messages drive the DSH assistant through a dedicated agent session, and replies stream back token by token. Also provides a universal proactive messaging API supporting Markdown text and native image attachments.
8
-
9
- ## Features
10
-
11
- - **Sidebar entry**: a "📮 Message platforms" button below "New session" opens the full-screen manager (close with ESC or by clicking the backdrop)
12
- - **Multi-platform connectors**: Telegram / Discord / QQ bot / WeCom / WeCom AI bot / WeChat (external Wechaty gateway) / WeChat Official Account / WhatsApp / Email / DingTalk / Feishu / Bark / ServerChan / Webhooks
13
- - **WeCom AI bot**: fill in `botId + secret` to establish an official SDK WebSocket connection; supports streaming replies, media upload, and **proactive image/file push**
14
- - **Telegram bot**: save a Bot Token to enable long polling, supporting text streaming and `sendPhoto` **proactive image push**
15
- - **Discord bot**: save a Bot Token to connect via Gateway, supporting channels/DMs and `files` attachment **proactive image push**
16
- - **DingTalk Bot**: configure custom bot Webhook & optional HMAC Secret; supports Markdown text and public image URL rendering
17
- - **Feishu / Lark Bot**: configure custom bot Webhook & optional Secret signature for text and card delivery
18
- - **Bark (iOS)**: fill in Device Key for instant push notifications with rich image banners (public URL)
19
- - **ServerChan**: fill in SendKey for push notifications to WeChat / mobile channels with Markdown image URLs
20
- - **QQ bot**: save appId + secret to connect to the open-platform gateway; passive replies + streaming edits
21
- - **WeCom app**: fill in CorpID/AgentID/Secret plus callback Token/EncodingAESKey for auto-dialogues
22
- - **WeChat Official Account**: fill in AppID/Secret plus callback Token for follower dialogues
23
- - **WhatsApp**: fill in Token + Phone Number ID for WhatsApp webhook dialogues
24
- - **Email**: fill in IMAP (993/143) + SMTP (465/587/25) for threaded email conversations
25
- - **Universal proactive push channel**: `POST /gateway/push` (for cron jobs, automation scripts, and pipelines):
26
- - Request body:
27
- - `platform`: target platform (`wecom-aibot` / `telegram` / `discord` / `dingtalk` / `feishu` / `bark` / `serverchan` / `email`)
28
- - `target`: destination target (single-chat userid or group id for `wecom-aibot`; numeric chatId for `telegram`; channelId for `discord`; deviceKey for `bark`, etc.)
29
- - `content`: optional text content (supports Markdown)
30
- - `title`: optional title (email subject or notification prefix)
31
- - `image`: optional image data (**Base64** data or accessible `http(s)://` image URL)
32
- - `filename`: optional image filename (defaults to `image.png`)
33
- - Highlights:
34
- - Text and image can be pushed together or separately
35
- - `wecom-aibot`, `telegram`, and `discord` support uploading raw local binary buffers directly
36
- - `bark`, `dingtalk`, and `serverchan` automatically adapt to public image URLs
37
- - **Credential management**: plaintext is persisted only to `~/.dsh/gateway.json` (mode 600, atomic write); `/gateway/list` never returns credential plaintext, only a `configured` flag
38
- - **Secret redaction**: message content written to logs / console is automatically masked for likely secrets (`sk-` prefixed keys, GitHub tokens, `Bearer`, `password=` assignments, PEM private keys, and other common patterns), so secrets in bot conversations never leak into log files
39
- - **Connection tests**: real per-platform checks — Telegram/Discord via Bot API, QQ via access_token, WeCom via gettoken, WeChat MP via cgi-bin/token, WhatsApp via Graph API, Email via IMAP TCP banner, WeCom AI bot via the official SDK long connection (authenticated = pass)
40
- - **WeCom AI bot persistent bridge**: official SDK WebSocket long connection with exponential backoff reconnect; incoming text messages are injected into an isolated dedicated agent session that wakes the DSH driver; replies stream back as chunks and finalize via `response_url`
41
- - **Group-chat @mention stripping**: the leading `@bot-name` is removed before the assistant sees the message
42
- - **Slash commands**: `/help` / `/time` / `/status` / `/stats` (Chinese aliases: 帮助/菜单/时间/状态/统计)
43
- - **Enter-chat welcome**: optional configuration (`welcomeReply`, defaults to `false` for zero disturbance; when set to `true`, auto-replies a greeting when a user enters single chat for the first time that day)
44
- - **Proactive send channel**: `POST /gateway/send` (`{"chatid": "...", "content": "..."}`) sends markdown messages as the bot
45
- - **Message routing rules** (plugin config `routes`): route messages by "platform + keyword prefix" to a specific **agent preset** (isolated session) with an optional **dedicated model / skill**
46
- - **Agent push tool** (`send_chat_message`): automatically registers a universal message-pushing tool for DSH agents, allowing AI assistants to proactively send summaries, task results, or alerts (including screenshots and text) to WeCom, Telegram, Discord, DingTalk, etc.
47
- - **Webhook receive endpoint**: `POST /gateway/webhook/in` accepts messages from external systems, injects them into the dedicated agent session and returns the full reply synchronously; optional HMAC-SHA256 signature validation
48
- - **Multilingual**: Chinese / English / Español, following the DSH Web UI language; defaults to Simplified Chinese
49
- - Light / dark theme follows the DSH Web GUI
50
-
51
- ## Usage
52
-
53
- 1. Open DSH Web (`dsh web`) and click the "Message platforms" button in the sidebar
54
- 2. Pick a platform on the left, fill in credentials on the right
55
- 3. Click **Save**: credentials are persisted and a connection test runs automatically, refreshing the status immediately
56
- 4. Click **Test connection**: tests the current form values without saving
57
- 5. Saving `botId + secret` for the WeCom AI bot establishes the persistent bridge right away; deleting the config disconnects it
58
-
59
- ## Install
60
-
61
- ```sh
62
- # From npm (generic plugin, usable by any DSH user)
63
- dsh plugin --profile web add dsh-message-gateway
64
- ```
65
-
66
- Restart `dsh web` — the "Message platforms" button appears below "New session" in the sidebar. Open the page, pick a platform, fill in credentials and click **Save** — for the WeCom AI bot, saving `botId + secret` establishes the persistent bridge immediately and you can chat with the bot in WeCom right away (same as web: per-chat sessions + automatic context compression).
67
-
68
- ## Config
69
-
70
- All options have defaults and the plugin works out of the box; tune them via `dsh plugin config` or the profile config file:
71
-
72
- | Option | Type | Default | Description |
73
- | --- | --- | --- | --- |
74
- | `botLocale` | `zh` \| `en` | `zh` | Bot reply language |
75
- | `maxChatAgents` | number | `40` | Max chat sessions kept per bot; oldest is evicted beyond this |
76
- | `autoStartWecom` | boolean | `true` | Auto-connect the WeCom AI bot from saved credentials at startup |
77
- | `groupReply` | boolean | `true` | Reply to group messages (false = single chats only) |
78
-
79
- ## Docs
80
-
81
- - [Architecture & extension guide](docs/architecture.md) (how to add a platform connector)
82
- - [Webhook receive endpoint contract](docs/webhooks.md)
83
- - [WeChat (Wechaty) HTTP gateway contract](docs/wechaty-gateway.md)
84
-
85
- ## Architecture
86
-
87
- - **Host half** (`lib/index.js`): `/gateway/*` routes (list / save / delete / test / wechat-status) + `BridgeManager` (agent session injection and event-stream polling) + `WecomBridge` (SDK long-connection lifecycle) + `gateway-store` (credential persistence)
88
- - **Client half** (`lib/client.js`): sidebar button mount + full-screen platform manager (React, loaded via the `__ModuleLoader__` closure)
89
-
90
- ## Feedback
91
-
92
- Found a bug or have a feature request? Open an issue on [GitHub Issues](https://github.com/a792883583/dsh-message-gateway/issues) — your feedback helps us make the plugin better.
93
-
94
- ## License
95
-
1
+ # dsh-message-gateway
2
+
3
+ [中文](README.md) · [Español](README.es.md)
4
+
5
+ ![dsh-message-gateway UI Preview](assets/screenshot.png)
6
+
7
+ A message-platform gateway plugin for the DSH Web GUI: a "Message platforms" entry below the "New session" button opens a full-screen manager for multi-platform message connectors — credential save, connection tests, status monitoring — plus a built-in persistent bridge for the WeCom AI bot: external messages drive the DSH assistant through a dedicated agent session, and replies stream back token by token. Also provides a universal proactive messaging API supporting Markdown text and native image attachments.
8
+
9
+ ## Features
10
+
11
+ - **Sidebar entry**: a "📮 Message platforms" button below "New session" opens the full-screen manager (close with ESC or by clicking the backdrop)
12
+ - **Multi-platform connectors**: Telegram / Discord / QQ bot / WeCom / WeCom AI bot / WeChat (external Wechaty gateway) / WeChat Official Account / WhatsApp / Email / DingTalk / Feishu / Bark / ServerChan / Webhooks
13
+ - **WeCom AI bot**: fill in `botId + secret` to establish an official SDK WebSocket connection; supports streaming replies, media upload, and **proactive image/file push**
14
+ - **Telegram bot**: save a Bot Token to enable long polling, supporting text streaming and `sendPhoto` **proactive image push**
15
+ - **Discord bot**: save a Bot Token to connect via Gateway, supporting channels/DMs and `files` attachment **proactive image push**
16
+ - **DingTalk Bot**: configure custom bot Webhook & optional HMAC Secret; supports Markdown text and public image URL rendering
17
+ - **Feishu / Lark Bot**: configure custom bot Webhook & optional Secret signature for text and card delivery
18
+ - **Bark (iOS)**: fill in Device Key for instant push notifications with rich image banners (public URL)
19
+ - **ServerChan**: fill in SendKey for push notifications to WeChat / mobile channels with Markdown image URLs
20
+ - **QQ bot**: save appId + secret to connect to the open-platform gateway; passive replies + streaming edits
21
+ - **WeCom app**: fill in CorpID/AgentID/Secret plus callback Token/EncodingAESKey for auto-dialogues
22
+ - **WeChat Official Account**: fill in AppID/Secret plus callback Token for follower dialogues
23
+ - **WhatsApp**: fill in Token + Phone Number ID for WhatsApp webhook dialogues
24
+ - **Email**: fill in IMAP (993/143) + SMTP (465/587/25) for threaded email conversations
25
+ - **Universal proactive push channel**: `POST /gateway/push` (for cron jobs, automation scripts, and pipelines):
26
+ - Request body:
27
+ - `platform`: target platform (`wecom-aibot` / `telegram` / `discord` / `dingtalk` / `feishu` / `bark` / `serverchan` / `email`)
28
+ - `target`: destination target (single-chat userid or group id for `wecom-aibot`; numeric chatId for `telegram`; channelId for `discord`; deviceKey for `bark`, etc.)
29
+ - `content`: optional text content (supports Markdown)
30
+ - `title`: optional title (email subject or notification prefix)
31
+ - `image`: optional image data (**Base64** data or accessible `http(s)://` image URL)
32
+ - `filename`: optional image filename (defaults to `image.png`)
33
+ - Highlights:
34
+ - Text and image can be pushed together or separately
35
+ - `wecom-aibot`, `telegram`, and `discord` support uploading raw local binary buffers directly
36
+ - `bark`, `dingtalk`, and `serverchan` automatically adapt to public image URLs
37
+ - **Credential management**: plaintext is persisted only to `~/.dsh/gateway.json` (mode 600, atomic write); `/gateway/list` never returns credential plaintext, only a `configured` flag
38
+ - **Secret redaction**: message content written to logs / console is automatically masked for likely secrets (`sk-` prefixed keys, GitHub tokens, `Bearer`, `password=` assignments, PEM private keys, and other common patterns), so secrets in bot conversations never leak into log files
39
+ - **Connection tests**: real per-platform checks — Telegram/Discord via Bot API, QQ via access_token, WeCom via gettoken, WeChat MP via cgi-bin/token, WhatsApp via Graph API, Email via IMAP TCP banner, WeCom AI bot via the official SDK long connection (authenticated = pass)
40
+ - **WeCom AI bot persistent bridge**: official SDK WebSocket long connection with exponential backoff reconnect; incoming text messages are injected into an isolated dedicated agent session that wakes the DSH driver; replies stream back as chunks and finalize via `response_url`
41
+ - **Group-chat @mention stripping**: the leading `@bot-name` is removed before the assistant sees the message
42
+ - **Slash commands**: `/help` / `/time` / `/status` / `/stats` (Chinese aliases: 帮助/菜单/时间/状态/统计)
43
+ - **Enter-chat welcome**: optional configuration (`welcomeReply`, defaults to `false` for zero disturbance; when set to `true`, auto-replies a greeting when a user enters single chat for the first time that day)
44
+ - **Proactive send channel**: `POST /gateway/send` (`{"chatid": "...", "content": "..."}`) sends markdown messages as the bot
45
+ - **Message routing rules** (plugin config `routes`): route messages by "platform + keyword prefix" to a specific **agent preset** (isolated session) with an optional **dedicated model / skill**
46
+ - **Agent push tool** (`send_chat_message`): automatically registers a universal message-pushing tool for DSH agents, allowing AI assistants to proactively send summaries, task results, or alerts (including screenshots and text) to WeCom, Telegram, Discord, DingTalk, etc.
47
+ - **Webhook receive endpoint**: `POST /gateway/webhook/in` accepts messages from external systems, injects them into the dedicated agent session and returns the full reply synchronously; optional HMAC-SHA256 signature validation
48
+ - **Multilingual**: Chinese / English / Español, following the DSH Web UI language; defaults to Simplified Chinese
49
+ - Light / dark theme follows the DSH Web GUI
50
+
51
+ ## Usage
52
+
53
+ 1. Open DSH Web (`dsh web`) and click the "Message platforms" button in the sidebar
54
+ 2. Pick a platform on the left, fill in credentials on the right
55
+ 3. Click **Save**: credentials are persisted and a connection test runs automatically, refreshing the status immediately
56
+ 4. Click **Test connection**: tests the current form values without saving
57
+ 5. Saving `botId + secret` for the WeCom AI bot establishes the persistent bridge right away; deleting the config disconnects it
58
+
59
+ ## Install
60
+
61
+ ```sh
62
+ # From npm (generic plugin, usable by any DSH user)
63
+ dsh plugin --profile web add dsh-message-gateway
64
+ ```
65
+
66
+ Restart `dsh web` — the "Message platforms" button appears below "New session" in the sidebar. Open the page, pick a platform, fill in credentials and click **Save** — for the WeCom AI bot, saving `botId + secret` establishes the persistent bridge immediately and you can chat with the bot in WeCom right away (same as web: per-chat sessions + automatic context compression).
67
+
68
+ ## Config
69
+
70
+ All options have defaults and the plugin works out of the box; tune them via `dsh plugin config` or the profile config file:
71
+
72
+ | Option | Type | Default | Description |
73
+ | --- | --- | --- | --- |
74
+ | `botLocale` | `zh` \| `en` | `zh` | Bot reply language |
75
+ | `maxChatAgents` | number | `40` | Max chat sessions kept per bot; oldest is evicted beyond this |
76
+ | `autoStartWecom` | boolean | `true` | Auto-connect the WeCom AI bot from saved credentials at startup |
77
+ | `groupReply` | boolean | `true` | Reply to group messages (false = single chats only) |
78
+
79
+ ## Docs
80
+
81
+ - [Architecture & extension guide](docs/architecture.md) (how to add a platform connector)
82
+ - [Webhook receive endpoint contract](docs/webhooks.md)
83
+ - [WeChat (Wechaty) HTTP gateway contract](docs/wechaty-gateway.md)
84
+
85
+ ## Architecture
86
+
87
+ - **Host half** (`lib/index.js`): `/gateway/*` routes (list / save / delete / test / wechat-status) + `BridgeManager` (agent session injection and event-stream polling) + `WecomBridge` (SDK long-connection lifecycle) + `gateway-store` (credential persistence)
88
+ - **Client half** (`lib/client.js`): sidebar button mount + full-screen platform manager (React, loaded via the `__ModuleLoader__` closure)
89
+
90
+ ## Feedback
91
+
92
+ Found a bug or have a feature request? Open an issue on [GitHub Issues](https://github.com/a792883583/dsh-message-gateway/issues) — your feedback helps us make the plugin better.
93
+
94
+ ## License
95
+
96
96
  MIT
package/README.es.md CHANGED
@@ -1,96 +1,96 @@
1
- # dsh-message-gateway
2
-
3
- [中文](README.md) · [English](README.en.md)
4
-
5
- ![Vista previa de dsh-message-gateway](assets/screenshot.png)
6
-
7
- Un plugin de pasarela de mensajería para la GUI web de DSH: una entrada "Plataformas de mensajería" debajo del botón "Nueva sesión" abre un gestor a pantalla completa para conectores de mensajería multiplataforma — guardado de credenciales, pruebas de conexión, monitoreo de estado — más un puente persistente integrado para el bot de IA de WeCom: los mensajes externos impulsan al asistente de DSH a través de una sesión de agente dedicada, y las respuestas se transmiten token a token. También proporciona una API universal de push proactivo que admite texto Markdown e imágenes nativas.
8
-
9
- ## Características
10
-
11
- - **Entrada en la barra lateral**: un botón "📮 Plataformas de mensajería" debajo de "Nueva sesión" abre el gestor a pantalla completa (cierre con ESC o haciendo clic en el fondo)
12
- - **Conectores multiplataforma**: Telegram / Discord / Bot de QQ / WeCom / Bot de IA de WeCom / WeChat (pasarela Wechaty externa) / Cuenta oficial de WeChat / WhatsApp / Email / DingTalk / Feishu / Bark / ServerChan / Webhooks
13
- - **Bot de IA de WeCom**: rellene `botId + secret` para conexión WebSocket persistente; admite respuestas en streaming, subida de medios y **envío proactivo de imágenes/archivos**
14
- - **Bot de Telegram**: guarde un Bot Token para sondeo largo, admite streaming y `sendPhoto` para **envío proactivo de imágenes**
15
- - **Bot de Discord**: guarde un Bot Token para conectar vía Gateway, admite canales/DMs y adjuntos `files` para **envío proactivo de imágenes**
16
- - **Bot de DingTalk**: configure Webhook y Secret opcional; admite Markdown y URL de imagen pública
17
- - **Bot de Feishu / Lark**: configure Webhook y Secret opcional para entrega de mensajes y tarjetas
18
- - **Bark (iOS)**: ingrese la Device Key para notificaciones instantáneas con banners de imágenes ricas (URL pública)
19
- - **ServerChan**: configure SendKey para notificaciones a WeChat con URLs de imágenes en Markdown
20
- - **Bot de QQ**: guarde appId + secret para conectar a la plataforma abierta; respuestas pasivas + edición en streaming
21
- - **App de WeCom**: rellene CorpID/AgentID/Secret más Token/EncodingAESKey de callback
22
- - **Cuenta oficial de WeChat**: rellene AppID/Secret más Token de callback
23
- - **WhatsApp**: rellene Token + Phone Number ID para webhooks de WhatsApp
24
- - **Email**: rellene IMAP (993/143) + SMTP (465/587/25) para correos en hilos
25
- - **Canal de push proactivo universal**: `POST /gateway/push` (para tareas programadas, scripts de automatización y pipelines):
26
- - Cuerpo de la petición:
27
- - `platform`: plataforma destino (`wecom-aibot` / `telegram` / `discord` / `dingtalk` / `feishu` / `bark` / `serverchan` / `email`)
28
- - `target`: destino (userid o grupo para `wecom-aibot`; chatId numérico para `telegram`; channelId para `discord`; deviceKey para `bark`, etc.)
29
- - `content`: texto opcional (admite Markdown)
30
- - `title`: título opcional (asunto de correo o prefijo de notificación)
31
- - `image`: imagen opcional (datos en **Base64** o URL accesible `http(s)://`)
32
- - `filename`: nombre de archivo opcional (por defecto `image.png`)
33
- - Destacados:
34
- - El texto y la imagen se pueden enviar juntos o por separado
35
- - `wecom-aibot`, `telegram` y `discord` admiten la carga directa de buffers binarios locales
36
- - `bark`, `dingtalk` y `serverchan` se adaptan automáticamente al modo de URL pública
37
- - **Gestión de credenciales**: el texto plano se guarda solo en `~/.dsh/gateway.json` (modo 600, escritura atómica); `/gateway/list` nunca devuelve credenciales, solo un marcador `configured`
38
- - **Redacción de secretos**: el contenido de los mensajes escrito en registros / consola se enmascara automáticamente ante posibles secretos
39
- - **Pruebas de conexión**: comprobaciones reales por plataforma — Telegram/Discord vía Bot API, QQ vía access_token, WeCom vía gettoken, cuenta oficial vía cgi-bin/token, WhatsApp vía Graph API, Email vía banner TCP de IMAP, Bot de IA de WeCom vía la conexión larga del SDK oficial
40
- - **Puente persistente del Bot de IA de WeCom**: conexión larga WebSocket del SDK oficial con reconexión por retroceso exponencial
41
- - **Eliminación de menciones @ en grupos**
42
- - **Comandos de barra**: `/help` / `/time` / `/status` / `/stats`
43
- - **Mensaje de bienvenida opcional**
44
- - **Canal de envío proactivo**: `POST /gateway/send`
45
- - **Reglas de enrutado de mensajes** (`routes`)
46
- - **Herramienta de push para agentes** (`send_chat_message`): registra automáticamente una herramienta para que los agentes envíen resúmenes, resultados o alertas (incluyendo imágenes y capturas de pantalla)
47
- - **Endpoint de recepción de webhooks**: `POST /gateway/webhook/in`
48
- - **Multilingüe**: chino / inglés / español, siguiendo el idioma de la interfaz web de DSH
49
- - Tema claro / oscuro siguiendo la GUI web de DSH
50
-
51
- ## Uso
52
-
53
- 1. Abra DSH Web (`dsh web`) y haga clic en el botón "Plataformas de mensajería" de la barra lateral
54
- 2. Elija una plataforma a la izquierda y complete las credenciales a la derecha
55
- 3. Haga clic en **Guardar**: las credenciales se persisten y se ejecuta automáticamente una prueba de conexión, actualizando el estado al instante
56
- 4. Haga clic en **Probar conexión**: prueba los valores actuales del formulario sin guardarlos
57
- 5. Guardar `botId + secret` del Bot de IA de WeCom establece el puente persistente de inmediato; eliminar la configuración lo desconecta
58
-
59
- ## Instalación
60
-
61
- ```sh
62
- # Desde npm (plugin genérico, utilizable por cualquier usuario de DSH)
63
- dsh plugin --profile web add dsh-message-gateway
64
- ```
65
-
66
- Reinicie `dsh web`: el botón "Plataformas de mensajería" aparece debajo de "Nueva sesión" en la barra lateral. Abra la página, elija una plataforma, complete las credenciales y haga clic en **Guardar** — para el Bot de IA de WeCom, guardar `botId + secret` establece el puente persistente de inmediato y puede chatear con el bot en WeCom al momento (igual que en la web: sesiones por chat + compresión automática de contexto).
67
-
68
- ## Configuración
69
-
70
- Todas las opciones tienen valores por defecto y el plugin funciona de inmediato; ajústelas vía `dsh plugin config` o el archivo de configuración del perfil:
71
-
72
- | Opción | Tipo | Por defecto | Descripción |
73
- | --- | --- | --- | --- |
74
- | `botLocale` | `zh` \| `en` | `zh` | Idioma de las respuestas del bot |
75
- | `maxChatAgents` | number | `40` | Máximo de sesiones de chat por bot; se elimina la más antigua al superarlo |
76
- | `autoStartWecom` | boolean | `true` | Conectar automáticamente el Bot de IA de WeCom con las credenciales guardadas al iniciar |
77
- | `groupReply` | boolean | `true` | Responder mensajes de grupo (false = solo chats individuales) |
78
-
79
- ## Documentación
80
-
81
- - [Arquitectura y guía de extensión](docs/architecture.md) (cómo añadir un conector de plataforma)
82
- - [Contrato del endpoint de recepción de webhooks](docs/webhooks.md)
83
- - [Contrato de la pasarela HTTP de WeChat (Wechaty)](docs/wechaty-gateway.md)
84
-
85
- ## Arquitectura
86
-
87
- - **Mitad host** (`lib/index.js`): rutas `/gateway/*` (list / save / delete / test / wechat-status) + `BridgeManager` (inyección de sesión de agente y sondeo del flujo de eventos) + `WecomBridge` (ciclo de vida de la conexión larga del SDK) + `gateway-store` (persistencia de credenciales)
88
- - **Mitad cliente** (`lib/client.js`): montaje del botón de la barra lateral + gestor a pantalla completa (React, cargado vía el cierre de `__ModuleLoader__`)
89
-
90
- ## Comentarios
91
-
92
- ¿Encontró un error o tiene una sugerencia? Abra un issue en [GitHub Issues](https://github.com/a792883583/dsh-message-gateway/issues) — sus comentarios nos ayudan a mejorar el plugin.
93
-
94
- ## Licencia
95
-
1
+ # dsh-message-gateway
2
+
3
+ [中文](README.md) · [English](README.en.md)
4
+
5
+ ![Vista previa de dsh-message-gateway](assets/screenshot.png)
6
+
7
+ Un plugin de pasarela de mensajería para la GUI web de DSH: una entrada "Plataformas de mensajería" debajo del botón "Nueva sesión" abre un gestor a pantalla completa para conectores de mensajería multiplataforma — guardado de credenciales, pruebas de conexión, monitoreo de estado — más un puente persistente integrado para el bot de IA de WeCom: los mensajes externos impulsan al asistente de DSH a través de una sesión de agente dedicada, y las respuestas se transmiten token a token. También proporciona una API universal de push proactivo que admite texto Markdown e imágenes nativas.
8
+
9
+ ## Características
10
+
11
+ - **Entrada en la barra lateral**: un botón "📮 Plataformas de mensajería" debajo de "Nueva sesión" abre el gestor a pantalla completa (cierre con ESC o haciendo clic en el fondo)
12
+ - **Conectores multiplataforma**: Telegram / Discord / Bot de QQ / WeCom / Bot de IA de WeCom / WeChat (pasarela Wechaty externa) / Cuenta oficial de WeChat / WhatsApp / Email / DingTalk / Feishu / Bark / ServerChan / Webhooks
13
+ - **Bot de IA de WeCom**: rellene `botId + secret` para conexión WebSocket persistente; admite respuestas en streaming, subida de medios y **envío proactivo de imágenes/archivos**
14
+ - **Bot de Telegram**: guarde un Bot Token para sondeo largo, admite streaming y `sendPhoto` para **envío proactivo de imágenes**
15
+ - **Bot de Discord**: guarde un Bot Token para conectar vía Gateway, admite canales/DMs y adjuntos `files` para **envío proactivo de imágenes**
16
+ - **Bot de DingTalk**: configure Webhook y Secret opcional; admite Markdown y URL de imagen pública
17
+ - **Bot de Feishu / Lark**: configure Webhook y Secret opcional para entrega de mensajes y tarjetas
18
+ - **Bark (iOS)**: ingrese la Device Key para notificaciones instantáneas con banners de imágenes ricas (URL pública)
19
+ - **ServerChan**: configure SendKey para notificaciones a WeChat con URLs de imágenes en Markdown
20
+ - **Bot de QQ**: guarde appId + secret para conectar a la plataforma abierta; respuestas pasivas + edición en streaming
21
+ - **App de WeCom**: rellene CorpID/AgentID/Secret más Token/EncodingAESKey de callback
22
+ - **Cuenta oficial de WeChat**: rellene AppID/Secret más Token de callback
23
+ - **WhatsApp**: rellene Token + Phone Number ID para webhooks de WhatsApp
24
+ - **Email**: rellene IMAP (993/143) + SMTP (465/587/25) para correos en hilos
25
+ - **Canal de push proactivo universal**: `POST /gateway/push` (para tareas programadas, scripts de automatización y pipelines):
26
+ - Cuerpo de la petición:
27
+ - `platform`: plataforma destino (`wecom-aibot` / `telegram` / `discord` / `dingtalk` / `feishu` / `bark` / `serverchan` / `email`)
28
+ - `target`: destino (userid o grupo para `wecom-aibot`; chatId numérico para `telegram`; channelId para `discord`; deviceKey para `bark`, etc.)
29
+ - `content`: texto opcional (admite Markdown)
30
+ - `title`: título opcional (asunto de correo o prefijo de notificación)
31
+ - `image`: imagen opcional (datos en **Base64** o URL accesible `http(s)://`)
32
+ - `filename`: nombre de archivo opcional (por defecto `image.png`)
33
+ - Destacados:
34
+ - El texto y la imagen se pueden enviar juntos o por separado
35
+ - `wecom-aibot`, `telegram` y `discord` admiten la carga directa de buffers binarios locales
36
+ - `bark`, `dingtalk` y `serverchan` se adaptan automáticamente al modo de URL pública
37
+ - **Gestión de credenciales**: el texto plano se guarda solo en `~/.dsh/gateway.json` (modo 600, escritura atómica); `/gateway/list` nunca devuelve credenciales, solo un marcador `configured`
38
+ - **Redacción de secretos**: el contenido de los mensajes escrito en registros / consola se enmascara automáticamente ante posibles secretos
39
+ - **Pruebas de conexión**: comprobaciones reales por plataforma — Telegram/Discord vía Bot API, QQ vía access_token, WeCom vía gettoken, cuenta oficial vía cgi-bin/token, WhatsApp vía Graph API, Email vía banner TCP de IMAP, Bot de IA de WeCom vía la conexión larga del SDK oficial
40
+ - **Puente persistente del Bot de IA de WeCom**: conexión larga WebSocket del SDK oficial con reconexión por retroceso exponencial
41
+ - **Eliminación de menciones @ en grupos**
42
+ - **Comandos de barra**: `/help` / `/time` / `/status` / `/stats`
43
+ - **Mensaje de bienvenida opcional**
44
+ - **Canal de envío proactivo**: `POST /gateway/send`
45
+ - **Reglas de enrutado de mensajes** (`routes`)
46
+ - **Herramienta de push para agentes** (`send_chat_message`): registra automáticamente una herramienta para que los agentes envíen resúmenes, resultados o alertas (incluyendo imágenes y capturas de pantalla)
47
+ - **Endpoint de recepción de webhooks**: `POST /gateway/webhook/in`
48
+ - **Multilingüe**: chino / inglés / español, siguiendo el idioma de la interfaz web de DSH
49
+ - Tema claro / oscuro siguiendo la GUI web de DSH
50
+
51
+ ## Uso
52
+
53
+ 1. Abra DSH Web (`dsh web`) y haga clic en el botón "Plataformas de mensajería" de la barra lateral
54
+ 2. Elija una plataforma a la izquierda y complete las credenciales a la derecha
55
+ 3. Haga clic en **Guardar**: las credenciales se persisten y se ejecuta automáticamente una prueba de conexión, actualizando el estado al instante
56
+ 4. Haga clic en **Probar conexión**: prueba los valores actuales del formulario sin guardarlos
57
+ 5. Guardar `botId + secret` del Bot de IA de WeCom establece el puente persistente de inmediato; eliminar la configuración lo desconecta
58
+
59
+ ## Instalación
60
+
61
+ ```sh
62
+ # Desde npm (plugin genérico, utilizable por cualquier usuario de DSH)
63
+ dsh plugin --profile web add dsh-message-gateway
64
+ ```
65
+
66
+ Reinicie `dsh web`: el botón "Plataformas de mensajería" aparece debajo de "Nueva sesión" en la barra lateral. Abra la página, elija una plataforma, complete las credenciales y haga clic en **Guardar** — para el Bot de IA de WeCom, guardar `botId + secret` establece el puente persistente de inmediato y puede chatear con el bot en WeCom al momento (igual que en la web: sesiones por chat + compresión automática de contexto).
67
+
68
+ ## Configuración
69
+
70
+ Todas las opciones tienen valores por defecto y el plugin funciona de inmediato; ajústelas vía `dsh plugin config` o el archivo de configuración del perfil:
71
+
72
+ | Opción | Tipo | Por defecto | Descripción |
73
+ | --- | --- | --- | --- |
74
+ | `botLocale` | `zh` \| `en` | `zh` | Idioma de las respuestas del bot |
75
+ | `maxChatAgents` | number | `40` | Máximo de sesiones de chat por bot; se elimina la más antigua al superarlo |
76
+ | `autoStartWecom` | boolean | `true` | Conectar automáticamente el Bot de IA de WeCom con las credenciales guardadas al iniciar |
77
+ | `groupReply` | boolean | `true` | Responder mensajes de grupo (false = solo chats individuales) |
78
+
79
+ ## Documentación
80
+
81
+ - [Arquitectura y guía de extensión](docs/architecture.md) (cómo añadir un conector de plataforma)
82
+ - [Contrato del endpoint de recepción de webhooks](docs/webhooks.md)
83
+ - [Contrato de la pasarela HTTP de WeChat (Wechaty)](docs/wechaty-gateway.md)
84
+
85
+ ## Arquitectura
86
+
87
+ - **Mitad host** (`lib/index.js`): rutas `/gateway/*` (list / save / delete / test / wechat-status) + `BridgeManager` (inyección de sesión de agente y sondeo del flujo de eventos) + `WecomBridge` (ciclo de vida de la conexión larga del SDK) + `gateway-store` (persistencia de credenciales)
88
+ - **Mitad cliente** (`lib/client.js`): montaje del botón de la barra lateral + gestor a pantalla completa (React, cargado vía el cierre de `__ModuleLoader__`)
89
+
90
+ ## Comentarios
91
+
92
+ ¿Encontró un error o tiene una sugerencia? Abra un issue en [GitHub Issues](https://github.com/a792883583/dsh-message-gateway/issues) — sus comentarios nos ayudan a mejorar el plugin.
93
+
94
+ ## Licencia
95
+
96
96
  MIT