dsh-message-gateway 0.1.33 → 0.1.35

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.en.md CHANGED
@@ -4,11 +4,11 @@
4
4
 
5
5
  ![dsh-message-gateway UI Preview](assets/screenshot.png)
6
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.
7
+ A message-platform gateway plugin for the DSH Web GUI: a "Message platforms" entry in the sidebar's "Workspaces" row, immediately left of the search icon, 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
8
 
9
9
  ## Features
10
10
 
11
- - **Sidebar entry**: a "📮 Message platforms" button below "New session" opens the full-screen manager (close with ESC or by clicking the backdrop)
11
+ - **Sidebar entry**: a "📮 Message platforms" icon button in the sidebar's "Workspaces" row, **immediately left of the search icon** (in line with the official search / view / add buttons), opens the full-screen manager (close with ESC or by clicking the backdrop)
12
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
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
14
  - **Telegram bot**: save a Bot Token to enable long polling, supporting text streaming and `sendPhoto` **proactive image push**
@@ -47,6 +47,12 @@ A message-platform gateway plugin for the DSH Web GUI: a "Message platforms" ent
47
47
  - **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**
48
48
  - **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.
49
49
  - **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
50
+ - **Image & file attachment receiving (all platforms)**: each platform parses and downloads attachments according to its official documentation and hands them to the Agent
51
+ - **Images** → stored in the attachment store and passed to the model as **multimodal content** (the model can actually see the picture)
52
+ - **Any other file** (PDF / Excel / Word / archives …) → handed to the Agent as a handle of "file name + byte size + **read-only path**", which the Agent reads with its file tools
53
+ - Covered: WeCom AI bot (`image` / `file` / `video` / `mixed`), Feishu (`image` / `file` / `audio` / `media` / rich-text `post`), DingTalk (`picture` / `richText` / `audio` / `video` / `file`), Telegram (`photo` / `document` / `animation` / `video` / `voice` / `audio` / `video_note` / `sticker`, including `caption`), Discord (`attachments[]`), QQ bot (`attachments[]`, with quoted-message recursion and voice `asr_refer_text`), WeChat iLink (`item_list` image / voice / file / video, with CDN AES decryption), Email (standard MIME attachments, RFC 2231 Chinese filenames, base64 / quoted-printable decoding)
54
+ - **Never silently dropped**: any unrecognised message type gets a user-visible notice (e.g. "received this message type, not supported yet") — you will never send something and get no response at all
55
+ - Each platform has its own **official limits** — see "[Platform limits](#platform-limits-official-not-our-bug)" below
50
56
  - **Multilingual**: Chinese / English / Español, following the DSH Web UI language; defaults to Simplified Chinese
51
57
  - Light / dark theme follows the DSH Web GUI
52
58
 
@@ -65,7 +71,7 @@ A message-platform gateway plugin for the DSH Web GUI: a "Message platforms" ent
65
71
  dsh plugin --profile web add dsh-message-gateway
66
72
  ```
67
73
 
68
- 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).
74
+ Restart `dsh web` — the "📮 Message platforms" icon button appears in the sidebar's "Workspaces" row, just left of the search icon. 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).
69
75
 
70
76
  ## Config
71
77
 
@@ -78,6 +84,29 @@ All options have defaults and the plugin works out of the box; tune them via `ds
78
84
  | `autoStartWecom` | boolean | `true` | Auto-connect the WeCom AI bot from saved credentials at startup |
79
85
  | `groupReply` | boolean | `true` | Reply to group messages (false = single chats only) |
80
86
 
87
+ ## Platform limits (official — not our bug)
88
+
89
+ Every limit below comes from the **official API capability boundary of the platform itself** (each one can be verified in that platform's documentation). They are not bugs in this plugin, and they **cannot be worked around by changing the plugin**:
90
+
91
+ | Platform | Official limit | Notes |
92
+ | --- | --- | --- |
93
+ | WeCom AI bot | **Image messages are private-chat only** | Official docs: `image` is single-chat only; in a **group, @-mentioning the bot with a picture arrives as `mixed`** (rich text + image). This plugin handles both |
94
+ | WeCom AI bot | Media URLs are valid for **5 minutes**, `aeskey` is unique per link | Official docs require downloading immediately; an expired URL can only be re-sent by the user |
95
+ | WeCom AI bot | File / video callback limit **100MB** | Official limit |
96
+ | DingTalk | **Group @-mentions cannot receive `audio` / `video` / `file`** | Official docs: groups only support `text` / `picture` / `richText`; voice, video and files work **only in private chats** |
97
+ | DingTalk | `downloadCode` expires | Official docs require exchanging it for a download URL promptly; otherwise `invalidParameter.robotCode.downloadCode` |
98
+ | Feishu | **Stickers (`sticker`) cannot be downloaded** | Official docs state sticker resources are not available; this plugin replies with a visible notice |
99
+ | Feishu | Rich-text / card resources and merged-forward sub-messages cannot be downloaded | Official limitation (returns `234043`) |
100
+ | Telegram | **20MB download limit** | Official docs: bots can download files up to 20MB; beyond that requires a self-hosted **Local Bot API Server**. This plugin reports that it did not download |
101
+ | Discord | **`MESSAGE_CONTENT` privileged intent is required** | Official docs: without it, `content` / `embeds` / `attachments` are **always empty arrays** and the plugin cannot see attachments. Apply and get approved in the Discord Developer Portal |
102
+ | Discord | External embeds are not downloaded | By design this plugin **does not fetch** user-supplied external links (SSRF safety); it only passes the title and URL to the Agent as text |
103
+ | QQ bot | Request headers and validity of the inbound attachment `url` are **undocumented** | This plugin performs a plain HTTPS GET (official docs specify no special header and no TTL) |
104
+ | WeChat iLink | **No public official documentation** | This protocol is an internal / semi-open Tencent interface; field names and the decryption flow here are taken from the **official Tencent npm package source**. Trustworthy, but not a documented contract — the platform may change silently |
105
+ | All platforms | **Video / voice are not "seen" or "heard"** | Models cannot natively understand audio or video. This plugin delivers them as **files** (name + read-only path) so the Agent can read or transcribe them with tools |
106
+ | Email | `8bit` / `binary` encoded attachments are read as text literals | This plugin's IMAP implementation fetches parts as text literals; `base64` / `quoted-printable` (the vast majority of real attachments) decode exactly, `8bit`/`binary` is a rare edge case |
107
+
108
+ > If what you are seeing is **not** in the table above, it is probably a plugin issue — please [open an Issue](https://github.com/a792883583/dsh-message-gateway/issues).
109
+
81
110
  ## Docs
82
111
 
83
112
  - [Architecture & extension guide](docs/architecture.md) (how to add a platform connector)
package/README.es.md CHANGED
@@ -4,11 +4,11 @@
4
4
 
5
5
  ![Vista previa de dsh-message-gateway](assets/screenshot.png)
6
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.
7
+ Un plugin de pasarela de mensajería para la GUI web de DSH: una entrada "Plataformas de mensajería" en la fila "Espacios de trabajo" de la barra lateral, justo a la izquierda del icono de búsqueda, 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
8
 
9
9
  ## Características
10
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)
11
+ - **Entrada en la barra lateral**: un botón de icono "📮 Plataformas de mensajería" en la fila "Espacios de trabajo", **justo a la izquierda del icono de búsqueda** (alineado con los botones oficiales de búsqueda / vista / añadir), abre el gestor a pantalla completa (cierre con ESC o haciendo clic en el fondo)
12
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
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
14
  - **Bot de Telegram**: guarde un Bot Token para sondeo largo, admite streaming y `sendPhoto` para **envío proactivo de imágenes**
@@ -47,6 +47,12 @@ Un plugin de pasarela de mensajería para la GUI web de DSH: una entrada "Plataf
47
47
  - **Reglas de enrutado de mensajes** (`routes`)
48
48
  - **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)
49
49
  - **Endpoint de recepción de webhooks**: `POST /gateway/webhook/in`
50
+ - **Recepción de imágenes y archivos adjuntos (todas las plataformas)**: cada plataforma analiza y descarga los adjuntos según su documentación oficial y los entrega al Agente
51
+ - **Imágenes** → se guardan en el almacén de adjuntos y se pasan al modelo como **contenido multimodal** (el modelo ve realmente la imagen)
52
+ - **Cualquier otro archivo** (PDF / Excel / Word / comprimidos…) → se entrega al Agente como un descriptor de «nombre + tamaño + **ruta de solo lectura**», que el Agente lee con sus herramientas de archivos
53
+ - Cubierto: bot de WeCom (`image` / `file` / `video` / `mixed`), Feishu (`image` / `file` / `audio` / `media` / texto enriquecido `post`), DingTalk (`picture` / `richText` / `audio` / `video` / `file`), Telegram (`photo` / `document` / `animation` / `video` / `voice` / `audio` / `video_note` / `sticker`, con `caption`), Discord (`attachments[]`), bot de QQ (`attachments[]`, con recursión de mensajes citados y `asr_refer_text` de voz), WeChat iLink (`item_list` imagen / voz / archivo / vídeo, con descifrado AES del CDN), Email (adjuntos MIME estándar, nombres chinos RFC 2231, decodificación base64 / quoted-printable)
54
+ - **Nunca se descarta en silencio**: cualquier tipo de mensaje no reconocido recibe un aviso visible (p. ej. «se recibió este tipo de mensaje, aún no compatible») — nunca enviarás algo sin recibir respuesta
55
+ - Cada plataforma tiene sus propios **límites oficiales** — ver «[Límites oficiales de las plataformas](#límites-oficiales-de-las-plataformas-no-son-un-fallo-del-plugin)» abajo
50
56
  - **Multilingüe**: chino / inglés / español, siguiendo el idioma de la interfaz web de DSH
51
57
  - Tema claro / oscuro siguiendo la GUI web de DSH
52
58
 
@@ -65,7 +71,7 @@ Un plugin de pasarela de mensajería para la GUI web de DSH: una entrada "Plataf
65
71
  dsh plugin --profile web add dsh-message-gateway
66
72
  ```
67
73
 
68
- 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).
74
+ Reinicie `dsh web`: el botón de icono "📮 Plataformas de mensajería" aparece en la fila "Espacios de trabajo" de la barra lateral, justo a la izquierda del icono de búsqueda. 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).
69
75
 
70
76
  ## Configuración
71
77
 
@@ -78,6 +84,29 @@ Todas las opciones tienen valores por defecto y el plugin funciona de inmediato;
78
84
  | `autoStartWecom` | boolean | `true` | Conectar automáticamente el Bot de IA de WeCom con las credenciales guardadas al iniciar |
79
85
  | `groupReply` | boolean | `true` | Responder mensajes de grupo (false = solo chats individuales) |
80
86
 
87
+ ## Límites oficiales de las plataformas (no son un fallo del plugin)
88
+
89
+ Todos los límites siguientes provienen de la **frontera de capacidad de la API oficial de cada plataforma** (verificable en su documentación). No son fallos de este plugin y **no se pueden evitar modificándolo**:
90
+
91
+ | Plataforma | Límite oficial | Notas |
92
+ | --- | --- | --- |
93
+ | Bot de WeCom | **Los mensajes de imagen solo funcionan en chat privado** | Documentación oficial: `image` solo en chat privado; en un **grupo, mencionar al bot con una imagen llega como `mixed`** (texto enriquecido + imagen). Este plugin admite ambos |
94
+ | Bot de WeCom | Las URL de medios valen **5 minutos**, `aeskey` es único por enlace | La documentación exige descargar de inmediato; si caduca, el usuario debe reenviarlo |
95
+ | Bot de WeCom | Límite de callback de archivo / vídeo **100MB** | Límite oficial |
96
+ | DingTalk | **Las menciones en grupo no reciben `audio` / `video` / `file`** | Documentación oficial: los grupos solo admiten `text` / `picture` / `richText`; voz, vídeo y archivos solo en **chat privado** |
97
+ | DingTalk | `downloadCode` caduca | Hay que canjearlo por una URL de descarga cuanto antes; si no, `invalidParameter.robotCode.downloadCode` |
98
+ | Feishu | **Los stickers (`sticker`) no se pueden descargar** | La documentación oficial no ofrece recursos de sticker; este plugin responde con un aviso visible |
99
+ | Feishu | Recursos de texto enriquecido / tarjetas y submensajes reenviados no se pueden descargar | Limitación oficial (devuelve `234043`) |
100
+ | Telegram | **Límite de descarga de 20MB** | Documentación oficial: los bots descargan hasta 20MB; más requiere un **Local Bot API Server** propio. Este plugin avisa de que no lo descargó |
101
+ | Discord | **Se requiere el intent privilegiado `MESSAGE_CONTENT`** | Documentación oficial: sin él, `content` / `embeds` / `attachments` están **siempre vacíos** y el plugin no ve los adjuntos. Solicítalo y espera aprobación en el portal de desarrolladores |
102
+ | Discord | Los embeds externos no se descargan | Por diseño este plugin **no descarga** enlaces externos proporcionados por el usuario (seguridad SSRF); solo pasa título y URL al Agente como texto |
103
+ | Bot de QQ | Los encabezados y la validez de la `url` de adjuntos **no están documentados** | Este plugin hace un GET HTTPS normal (la documentación no exige encabezados especiales ni indica caducidad) |
104
+ | WeChat iLink | **Sin documentación oficial pública** | Es una interfaz interna / semipública de Tencent; los nombres de campo y el descifrado provienen del **paquete npm oficial de Tencent**. Fiables, pero sin contrato documentado: la plataforma puede cambiar sin aviso |
105
+ | Todas | **El vídeo / la voz no se "ven" ni se "oyen"** | Los modelos no entienden audio o vídeo de forma nativa. Este plugin los entrega como **archivos** (nombre + ruta de solo lectura) para que el Agente los lea o transcriba con herramientas |
106
+ | Email | Los adjuntos con codificación `8bit` / `binary` se leen como literales de texto | La implementación IMAP obtiene las partes como literales de texto; `base64` / `quoted-printable` (la inmensa mayoría) se decodifican con exactitud, `8bit`/`binary` es un caso raro |
107
+
108
+ > Si lo que ves **no** aparece en esta tabla, probablemente sea un fallo del plugin — abre un [Issue](https://github.com/a792883583/dsh-message-gateway/issues).
109
+
81
110
  ## Documentación
82
111
 
83
112
  - [Arquitectura y guía de extensión](docs/architecture.md) (cómo añadir un conector de plataforma)
package/README.md CHANGED
@@ -4,11 +4,11 @@
4
4
 
5
5
  ![dsh-message-gateway 功能界面](assets/screenshot.png)
6
6
 
7
- DSH Web GUI 的消息平台网关插件:在侧边栏「新会话」按钮下方提供「消息平台」入口,全屏管理多平台消息连接器——凭据保存、连接测试、状态监控,并内置企业微信智能机器人的常驻桥接:外部消息经专用 agent 会话驱动 DSH 助手,回复按 token 流式回发;同时提供全平台通用主动图文推送通道(支持发送 Markdown 文本与多模态原生图片)。
7
+ DSH Web GUI 的消息平台网关插件:在侧边栏「工作区」行、紧贴搜索图标左侧提供「消息平台」入口,全屏管理多平台消息连接器——凭据保存、连接测试、状态监控,并内置企业微信智能机器人的常驻桥接:外部消息经专用 agent 会话驱动 DSH 助手,回复按 token 流式回发;同时提供全平台通用主动图文推送通道(支持发送 Markdown 文本与多模态原生图片)。
8
8
 
9
9
  ## 功能
10
10
 
11
- - **侧边栏入口**:「新会话」按钮下方新增「📮 消息平台」按钮,点击打开全屏管理页(ESC / 点击遮罩关闭)
11
+ - **侧边栏入口**:侧边栏「工作区」行、**紧贴搜索图标左侧**新增「📮 消息平台」图标按钮(与官方搜索 / 视图 / 添加图标排成一行),点击打开全屏管理页(ESC / 点击遮罩关闭)
12
12
  - **多平台连接器**:Telegram / Discord / QQ 机器人 / 企业微信 / 企业微信智能机器人 / 微信(外部 Wechaty 网关)/ 微信公众号 / WhatsApp / Email / 钉钉 / 飞书 / Bark / Server酱 / Webhooks
13
13
  - **企业微信智能机器人**:填 `botId + secret` 保存即建立官方 SDK WebSocket 常驻连接;支持文本流式对话、素材上传与**主动图片/文件推送**
14
14
  - **Telegram 机器人**:填 Bot Token 保存即启用长轮询,与机器人对话即可使用,支持 `sendPhoto` **主动图片推送**
@@ -48,6 +48,12 @@ DSH Web GUI 的消息平台网关插件:在侧边栏「新会话」按钮下
48
48
  - **斜杠命令**:`/help` / `/time` / `/status` / `/stats`(含中文别名:帮助/菜单/时间/状态/统计);`/stats` 展示各平台桥连接状态与活跃会话数
49
49
  - **Agent 主动推送工具**(`send_chat_message`):自动向 DSH 注册通用推送工具,AI 助手在对话中可自主调用该工具将总结、任务结果或告警(含文字与图片截图)推送至企业微信、Telegram、Discord、钉钉等平台
50
50
  - **Webhook 接收端点**:`POST /gateway/webhook/in` 接收外部系统消息(`text` / `content` / `message` 任一字段),注入专用 agent 会话并同步返回完整回复;可配置 HMAC-SHA256 签名密钥校验(契约见 [docs/webhooks.md](docs/webhooks.md))
51
+ - **图片与文件附件接收(全平台)**:各平台按官方文档解析并下载用户发来的附件,交给 Agent 处理
52
+ - **图片** → 存入附件库并以**多模态**交给模型(可直接识别画面内容)
53
+ - **其它文件**(PDF / Excel / Word / 压缩包等任意类型)→ 以「文件名 + 字节数 + **只读路径**」句柄交给 Agent,Agent 用文件工具读取处理
54
+ - 已接入:企业微信智能机器人(`image` / `file` / `video` / `mixed` 图文混排)、飞书(`image` / `file` / `audio` / `media` / 富文本 `post`)、钉钉(`picture` / `richText` / `audio` / `video` / `file`)、Telegram(`photo` / `document` / `animation` / `video` / `voice` / `audio` / `video_note` / `sticker`,含 `caption` 说明文字)、Discord(`attachments[]`)、QQ 机器人(`attachments[]`,含引用消息递归与语音 `asr_refer_text`)、微信 ilink(`item_list` 图片 / 语音 / 文件 / 视频,含 CDN AES 解密)、Email(标准 MIME 附件,支持 RFC 2231 中文文件名与 base64 / quoted-printable 解码)
55
+ - **绝不静默丢弃**:任何未识别的消息类型都会收到一条用户可见的提示(如「收到该类型消息,暂不支持处理」),不会出现"发了消息却毫无响应"的情况
56
+ - 各平台存在**官方侧限制**,见下方「[各平台官方限制](#各平台官方限制非本插件缺陷)」
51
57
  - **微信个人号(可选外部网关)**:对接本机 Wechaty HTTP 网关的扫码登录与状态轮询(契约见 [docs/wechaty-gateway.md](docs/wechaty-gateway.md))
52
58
  - **多语言**:中文 / English / Español,自动跟随 DSH Web 界面语言(西班牙语浏览器自动切换),默认简体中文
53
59
  - 明暗主题跟随 DSH Web GUI
@@ -67,7 +73,7 @@ DSH Web GUI 的消息平台网关插件:在侧边栏「新会话」按钮下
67
73
  dsh plugin --profile web add dsh-message-gateway
68
74
  ```
69
75
 
70
- 重启 `dsh web`,侧边栏「新会话」按钮下方即出现「消息平台」按钮。打开页面,选择平台、
76
+ 重启 `dsh web`,侧边栏「工作区」那一行、**搜索图标左侧**即出现「📮 消息平台」图标按钮。打开页面,选择平台、
71
77
  填入凭据并「保存」——企业微信智能机器人填 `botId + secret` 后立即建立常驻连接,即可
72
78
  直接在企微里和机器人对话(与 Web 对话一致:每聊天独立会话 + 上下文自动压缩)。
73
79
 
@@ -83,6 +89,30 @@ dsh plugin --profile web add dsh-message-gateway
83
89
  | `autoStartWecom` | boolean | `true` | 启动时自动用已保存的企业微信智能机器人凭据连接 |
84
90
  | `groupReply` | boolean | `true` | 是否回复群聊消息(false 时只处理单聊) |
85
91
 
92
+ ## 各平台官方限制(非本插件缺陷)
93
+
94
+ 下列限制**全部来自各平台官方接口的能力边界**(每条都可在官方文档中查证),不是本插件的 bug。
95
+ 遇到这些行为时,请对照本表判断——它们**无法通过改插件绕过**:
96
+
97
+ | 平台 | 官方限制 | 说明 |
98
+ | --- | --- | --- |
99
+ | 企业微信智能机器人 | **图片消息仅单聊可用** | 官方文档明确:`image` 类型仅支持单聊;**群聊里 @机器人 配图走 `mixed`(图文混排)**,本插件已同时接入两者 |
100
+ | 企业微信智能机器人 | 媒体 URL **5 分钟内有效**、`aeskey` 每个链接唯一 | 官方要求收到事件后立即下载,URL 过期只能请用户重发 |
101
+ | 企业微信智能机器人 | 文件 / 视频回调上限 **100MB** | 官方限制 |
102
+ | 钉钉 | **群聊 @机器人 收不到 `audio` / `video` / `file`** | 官方文档明确:群聊仅支持 `text` / `picture` / `richText`;语音、视频、文件**只在单聊**(人与机器人会话)可用 |
103
+ | 钉钉 | `downloadCode` 有时效 | 官方要求收到后尽快换取下载链接,过期报 `invalidParameter.robotCode.downloadCode` |
104
+ | 飞书 | **表情包(`sticker`)不支持下载** | 官方文档明确不支持获取表情包资源;本插件会给出可见提示 |
105
+ | 飞书 | 富文本 / 卡片内资源、合并转发子消息不支持下载 | 官方限制(传对应 ID 返回 `234043`) |
106
+ | Telegram | **下载上限 20MB** | 官方文档明确:Bot 下载文件上限 20MB,超出需自建 **Local Bot API Server**;本插件会提示未下载 |
107
+ | Discord | **必须开启 `MESSAGE_CONTENT` 特权意图** | 官方文档明确:未开启时 `content` / `embeds` / `attachments` 等字段**恒为空数组**,插件拿不到附件。需在 Discord 开发者后台申请并通过审核 |
108
+ | Discord | 外链嵌入(embeds)不下载 | 用户粘贴的外链由本插件**刻意不抓取**(避免 SSRF 风险),只把标题与链接作为文本交给 Agent |
109
+ | QQ 机器人 | 接收侧附件 `url` 的请求头要求与有效期**官方未说明** | 本插件按普通 HTTPS GET 实现(官方文档未要求特殊请求头,也未给出有效期) |
110
+ | 微信 ilink | **无公开官方文档** | 该协议为腾讯内部/半开放接口;本插件字段名与解密流程取自**腾讯官方 npm 包源码**,可信但无文档承诺,平台可能无通知变更 |
111
+ | 全平台 | **视频 / 语音不是"看画面 / 听声音"** | 模型无法直接理解音视频内容。本插件将其作为**文件**交给 Agent(提供文件名 + 只读路径),Agent 可用工具读取文件本体或转写后再处理 |
112
+ | Email | `8bit` / `binary` 编码的附件按文本 literal 读取 | 本插件 IMAP 实现以文本字面量获取 part,对 `base64` / `quoted-printable`(实际绝大多数附件)解码精确;`8bit`/`binary` 属罕见情形 |
113
+
114
+ > 如果你遇到的现象**不在上表中**,那可能是本插件的问题——欢迎[提 Issue](https://github.com/a792883583/dsh-message-gateway/issues)。
115
+
86
116
  ## 文档
87
117
 
88
118
  - [架构与扩展指南](docs/architecture.md)(如何新增平台连接器)
package/lib/client.js CHANGED
@@ -33,6 +33,7 @@ __export(index_exports, {
33
33
  });
34
34
  module.exports = __toCommonJS(index_exports);
35
35
  var import_react4 = require("react");
36
+ var import_react_dom = require("react-dom");
36
37
  var import_client = require("react-dom/client");
37
38
 
38
39
  // src/client/api.ts
@@ -829,16 +830,46 @@ function GatewayPage(props) {
829
830
 
830
831
  // src/client/index.ts
831
832
  var inject = ["locale"];
832
- var NEW_SESSION_SELECTOR = '[class*="newSession"]';
833
833
  var BUTTON_STYLE = `
834
- .dsh-gw-open { display:flex; align-items:center; gap:8px; width:100%; padding:8px 12px;
835
- border:none; background:transparent; color:inherit; cursor:pointer;
836
- font-size:12px; font-weight:500; border-radius:8px; margin-top:2px; box-sizing:border-box;
837
- transition: all 0.15s ease; }
838
- .dsh-gw-open:hover { background:rgba(128,128,128,0.1); }
839
- .dsh-gw-open .icon { font-size:15px; flex:none; display:flex; align-items:center; justify-content:center; }
840
- .dsh-gw-open .label { flex:1; min-width:0; overflow:hidden; text-overflow:ellipsis;
841
- white-space:nowrap; text-align:left; }
834
+ /* \u6D88\u606F\u5E73\u53F0\u5165\u53E3\u6309\u94AE\uFF1A\u6837\u5F0F\u5BF9\u9F50\u5B98\u65B9 workspace \u63D2\u4EF6\u7684 searchButton\u3002
835
+ wide\uFF08\u5BBD\u680F\uFF0928x28 \u5706\u5F62 / --dsw-alias-label-secondary\uFF1B
836
+ rail\uFF08\u6536\u8D77\uFF0936x36 \u5706\u5F62 / --dsw-alias-label-primary\uFF08\u5B98\u65B9\u5728\u6536\u8D77\u65F6\u653E\u5927\u5E76\u63D0\u4EAE\uFF09\u3002 */
837
+ .dsh-gw-open {
838
+ display:inline-flex; align-items:center; justify-content:center;
839
+ width:28px; height:28px; flex:none; padding:0; margin:0;
840
+ border:none; background:transparent; color:var(--dsw-alias-label-secondary);
841
+ cursor:pointer; border-radius:50%; box-sizing:border-box;
842
+ transition: background 0.15s ease, color 0.15s ease;
843
+ }
844
+ .dsh-gw-open:hover { background:var(--dsw-alias-interactive-bg-hover); }
845
+ .dsh-gw-open:focus-visible { outline:2px solid var(--dsw-alias-label-primary); outline-offset:1px; }
846
+ .dsh-gw-open svg { display:block; }
847
+
848
+ /* \u4F4D\u7F6E\uFF1A\u672C\u5165\u53E3\u662F\u8BE5\u884C\u6700\u5DE6\u4FA7\u7684\u6CE8\u5165\u9879\uFF0C\u7531\u5B83\u627F\u62C5 margin-left:auto \u5438\u6536\u5269\u4F59\u7A7A\u95F4\uFF0C
849
+ \u4ECE\u800C\u4E0E\u540E\u9762\u7684\u65E5\u5386 / \u641C\u7D22\u56FE\u6807\u7D27\u8D34\u6210\u6392\u3002
850
+ \u6CE8\u610F\uFF1A\u591A\u4E2A auto \u4F1A\u88AB flex **\u5E73\u5206**\u5269\u4F59\u7A7A\u95F4\uFF08\u66FE\u56E0\u6B64\u51FA\u73B0 100+px \u7A7A\u6863\uFF09\uFF0C
851
+ \u6240\u4EE5\u5F53\u65E5\u5386\u5165\u53E3\u7D27\u968F\u5176\u540E\u65F6\uFF0C\u5FC5\u987B\u8BA9\u5B83\u4EA4\u51FA auto\u3002 */
852
+ [data-gateway-host] { display:flex; align-items:center; flex:none; margin-left:auto; }
853
+ [data-gateway-host] + [data-reminder-host] { margin-left:0; }
854
+ [data-gateway-host] + [class*="searchSlot"] { margin-left:0 !important; }
855
+
856
+ /* rail\uFF08\u4FA7\u8FB9\u680F\u6536\u8D77\uFF09\u6A21\u5F0F\uFF1A\u8DDF\u968F\u5B98\u65B9 36x36 / primary \u8272 / \u4E0B\u8FB9\u8DDD 12px\u3002 */
857
+ [class*="rail"] [data-gateway-host] { margin:0 0 12px; }
858
+ [class*="rail"] .dsh-gw-open { width:36px; height:36px; color:var(--dsw-alias-label-primary); }
859
+ [class*="rail"] .dsh-gw-open svg { width:18px; height:18px; }
860
+
861
+ /* \u60AC\u505C\u63D0\u793A\uFF1Aportal \u5230 body\uFF0C\u7ED5\u5F00 sectionHeader \u7684 overflow:hidden \u88C1\u526A\u3002 */
862
+ .dsh-gw-tip {
863
+ position:fixed; z-index:9999; pointer-events:none; white-space:nowrap;
864
+ padding:4px 8px; border-radius:6px; font-size:12px; line-height:1.4;
865
+ /* \u4FA7\u8FB9\u680F tooltip \u5B98\u65B9 token\uFF1A\u6D45\u8272\u4E3B\u9898 #f5f6f7\uFF08\u6D45\u5E95\u6DF1\u5B57\uFF09\u3001\u6DF1\u8272\u4E3B\u9898 #353638\uFF08\u6DF1\u5E95\u6D45\u5B57\uFF09\u3002
866
+ \u6B64\u524D\u8BEF\u7528\u4E0D\u5B58\u5728\u7684 --dsw-alias-bg-elevated \u2192 \u56DE\u9000\u6210\u767D\u5E95\uFF0C\u6DF1\u8272\u6A21\u5F0F\u4E0B\u53D8\u6210
867
+ \u300C\u767D\u5E95 + \u6D45\u8272\u5B57\u300D\u800C\u770B\u4E0D\u89C1\u3002 */
868
+ background:var(--dsw-specific-tip, #f5f6f7);
869
+ color:var(--dsw-alias-label-primary, #0f1115);
870
+ border:1px solid var(--dsw-alias-border-l4, rgba(128,128,128,0.28));
871
+ box-shadow:0 4px 12px rgba(0,0,0,0.12);
872
+ }
842
873
  `;
843
874
  var styleInjected2 = false;
844
875
  function ensureButtonStyle() {
@@ -853,17 +884,53 @@ function GatewayApp(props) {
853
884
  const { api } = props;
854
885
  const t2 = useT();
855
886
  const [open, setOpen] = (0, import_react4.useState)(false);
887
+ const [tip, setTip] = (0, import_react4.useState)(null);
888
+ const btnRef = (0, import_react4.useRef)(null);
856
889
  const close = (0, import_react4.useCallback)(() => setOpen(false), []);
857
890
  ensureButtonStyle();
891
+ const label = t2("gateway.title");
892
+ const showTip = (0, import_react4.useCallback)(() => {
893
+ const el = btnRef.current;
894
+ if (el === null) return;
895
+ const r = el.getBoundingClientRect();
896
+ const inRail = el.closest('[class*="rail"]') !== null;
897
+ if (inRail) {
898
+ setTip({ left: r.right + 8, top: r.top + r.height / 2, transform: "translateY(-50%)" });
899
+ } else {
900
+ setTip({ left: r.left + r.width / 2, top: r.bottom + 6, transform: "translateX(-50%)" });
901
+ }
902
+ }, []);
903
+ const hideTip = (0, import_react4.useCallback)(() => setTip(null), []);
858
904
  return (0, import_react4.createElement)(
859
905
  "div",
860
906
  null,
861
907
  (0, import_react4.createElement)(
862
908
  "button",
863
- { type: "button", className: "dsh-gw-open", title: t2("gateway.open"), onClick: () => setOpen(true) },
864
- (0, import_react4.createElement)("span", { className: "icon" }, (0, import_react4.createElement)(InboxIcon, { size: 16 })),
865
- (0, import_react4.createElement)("span", { className: "label" }, t2("gateway.title"))
909
+ {
910
+ ref: btnRef,
911
+ type: "button",
912
+ className: "dsh-gw-open",
913
+ "aria-label": label,
914
+ onClick: () => setOpen(true),
915
+ onMouseEnter: showTip,
916
+ onMouseLeave: hideTip,
917
+ onFocus: showTip,
918
+ onBlur: hideTip
919
+ },
920
+ (0, import_react4.createElement)(InboxIcon, { size: 16 })
866
921
  ),
922
+ tip !== null ? (0, import_react_dom.createPortal)(
923
+ (0, import_react4.createElement)(
924
+ "div",
925
+ {
926
+ className: "dsh-gw-tip",
927
+ role: "tooltip",
928
+ style: { left: tip.left, top: tip.top, transform: tip.transform }
929
+ },
930
+ label
931
+ ),
932
+ document.body
933
+ ) : null,
867
934
  open ? (0, import_react4.createElement)(GatewayPage, { api, onClose: close }) : null
868
935
  );
869
936
  }
@@ -883,20 +950,36 @@ function apply(ctx) {
883
950
  if (disposed) return;
884
951
  root.render((0, import_react4.createElement)(GatewayApp, { api }));
885
952
  };
953
+ const resolveAnchor = () => {
954
+ const reminder = document.querySelector("[data-reminder-host]");
955
+ if (reminder !== null) return reminder;
956
+ const searchSlot = document.querySelector('[class*="searchSlot"]');
957
+ if (searchSlot !== null) return searchSlot;
958
+ const searchBtn = document.querySelector('[class*="searchButton"]');
959
+ return searchBtn?.parentElement ?? null;
960
+ };
961
+ const isPlacedCorrectly = () => {
962
+ if (!host.isConnected) return false;
963
+ const anchor = resolveAnchor();
964
+ if (anchor === null) return false;
965
+ return host.nextElementSibling === anchor;
966
+ };
967
+ const mount = () => {
968
+ if (isPlacedCorrectly()) return true;
969
+ document.querySelectorAll("[data-gateway-host]").forEach((node) => {
970
+ if (node !== host) node.remove();
971
+ });
972
+ const anchor = resolveAnchor();
973
+ if (anchor === null || anchor.parentElement === null) return false;
974
+ anchor.before(host);
975
+ render();
976
+ return true;
977
+ };
886
978
  let raf = 0;
887
979
  let polling = true;
888
980
  const poll = () => {
889
981
  if (disposed || !polling) return;
890
- if (!host.isConnected) {
891
- const btn = document.querySelector(NEW_SESSION_SELECTOR);
892
- if (btn !== null && btn.parentElement !== null) {
893
- btn.after(host);
894
- render();
895
- polling = false;
896
- console.debug("[dsh-message-gateway] mounted after newSession");
897
- return;
898
- }
899
- } else {
982
+ if (mount()) {
900
983
  polling = false;
901
984
  return;
902
985
  }
@@ -905,13 +988,11 @@ function apply(ctx) {
905
988
  raf = requestAnimationFrame(poll);
906
989
  const fallback = window.setInterval(() => {
907
990
  if (disposed) return;
908
- if (!host.isConnected) {
909
- polling = true;
910
- raf = requestAnimationFrame(poll);
911
- }
912
- }, 5e3);
991
+ if (!isPlacedCorrectly()) mount();
992
+ }, 1e3);
913
993
  return () => {
914
994
  disposed = true;
995
+ polling = false;
915
996
  cancelAnimationFrame(raf);
916
997
  window.clearInterval(fallback);
917
998
  try {