@xmanrui/dsh-im 5.8.0 → 5.9.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.en.md +42 -7
- package/README.md +53 -7
- package/docs/preset-workspaces.md +37 -0
- package/lib/client.js +34 -2
- package/lib/index.js +329 -326
- package/package.json +3 -1
- package/plugin-src/client/connection-error.js +1 -1
- package/plugin-src/host/channels/dingtalk/production.mjs +2 -1
- package/plugin-src/host/channels/feishu/production.mjs +2 -1
- package/plugin-src/host/channels/matrix/production.mjs +2 -1
- package/plugin-src/host/channels/qq/production.mjs +2 -1
- package/plugin-src/host/channels/shared/binding-events.mjs +130 -0
- package/plugin-src/host/channels/shared/production.mjs +32 -3
- package/plugin-src/host/channels/slack/production.mjs +2 -1
- package/plugin-src/host/channels/wecom/production.mjs +2 -1
- package/plugin-src/host/channels/wecom-app/production.mjs +2 -1
- package/plugin-src/host/channels/weixin/production.mjs +2 -1
- package/plugin-src/host/channels/whatsapp/production.mjs +2 -1
- package/plugin-src/host/delivery-adapter.mjs +122 -1
- package/plugin-src/host/delivery-service.mjs +40 -0
- package/plugin-src/host/ds-bot-client.mjs +28 -2
- package/plugin-src/host/index.mjs +24 -1
- package/plugin-src/host/modern-harness-api.mjs +3 -0
- package/scripts/telegram-menu-scopes.mjs +57 -0
- package/scripts/verify-interface-language.mjs +60 -15
- package/src/channels/dingtalk/dingtalk-bridge.mjs +2 -3
- package/src/channels/dingtalk/dingtalk-menu.mjs +4 -5
- package/src/channels/email/transports/imap-smtp.mjs +21 -11
- package/src/channels/feishu/bridge.mjs +46 -10
- package/src/channels/feishu/feishu-cards.mjs +96 -25
- package/src/channels/qq/qq-menu.mjs +3 -4
- package/src/channels/shared/action-card.mjs +331 -0
- package/src/channels/shared/bot-workspace-store.mjs +123 -8
- package/src/channels/shared/command-catalog.mjs +20 -5
- package/src/channels/shared/conversation/describe.mjs +116 -0
- package/src/channels/shared/conversation-state-store.mjs +62 -0
- package/src/channels/shared/diagnostic-details.mjs +38 -0
- package/src/channels/shared/harness-approval.mjs +58 -13
- package/src/channels/shared/harness-client.mjs +13 -0
- package/src/channels/shared/harness-session-binding.mjs +13 -1
- package/src/channels/shared/i18n-en/feishu.mjs +6 -0
- package/src/channels/shared/i18n-en/shared-a.mjs +9 -0
- package/src/channels/shared/i18n-en/telegram.mjs +14 -0
- package/src/channels/shared/i18n-ru/feishu.mjs +6 -0
- package/src/channels/shared/i18n-ru/shared-a.mjs +9 -0
- package/src/channels/shared/i18n-ru/telegram.mjs +14 -0
- package/src/channels/shared/model-command.mjs +5 -0
- package/src/channels/shared/preset-workspaces.mjs +48 -0
- package/src/channels/shared/qr-encoding-error.mjs +8 -2
- package/src/channels/shared/status-command.mjs +159 -0
- package/src/channels/shared/text-harness-bridge.mjs +86 -4
- package/src/channels/shared/workspace-command.mjs +20 -12
- package/src/channels/shared/workspace-session.mjs +30 -5
- package/src/channels/telegram/approval-card.mjs +379 -0
- package/src/channels/telegram/telegram-api.mjs +10 -1
- package/src/channels/telegram/telegram-bridge.mjs +7 -0
- package/src/channels/telegram/telegram-runtime.mjs +125 -13
- package/src/channels/wecom/wecom-bridge.mjs +5 -3
package/README.en.md
CHANGED
|
@@ -259,6 +259,40 @@ See the [Proactive Delivery Guide](PROACTIVE_DELIVERY.en.md) ([简体中文](PRO
|
|
|
259
259
|
|
|
260
260
|
DSH versions supporting global panels show **IM bots** in the left sidebar, using a thin monochrome outline of the catalog's linked speech bubbles to open the full management panel. Settings → IM bots and the plugin detail page's Open IM bots action remain available. Shells can also embed the panel through the optional `dshImClient` service. See the [client integration guide](docs/client-integration.md) for the contract, compatibility requirements and lifecycle example.
|
|
261
261
|
|
|
262
|
+
### Session → conversation lookup (host service)
|
|
263
|
+
|
|
264
|
+
Other plugins may receive only a Session id while needing to know which channel, bot, chat, or topic owns it. The host service `dshIm` exposes a read-only lookup for that purpose:
|
|
265
|
+
|
|
266
|
+
```js
|
|
267
|
+
const info = await dshIm.describeConversation(sessionId);
|
|
268
|
+
// null — the Session is not owned by an IM conversation
|
|
269
|
+
// otherwise:
|
|
270
|
+
// { channel, botId, botName, conversationKey, chatType,
|
|
271
|
+
// chatId, threadId, chatTitle,
|
|
272
|
+
// senderId, senderName, senderUsername, senderIsBot }
|
|
273
|
+
```
|
|
274
|
+
|
|
275
|
+
- Read-only: no network access, session creation, blocking reply, or thrown error; unknown Sessions return `null`.
|
|
276
|
+
- Data comes from the plugin's state files (`sessions`) and bot configuration; no new core fields are required.
|
|
277
|
+
- `chatType` is `group`, `thread`, or `dm`; a `direct:dm:<id>` key supplies `<id>` as `senderId`.
|
|
278
|
+
- The first lookup logs one line per Session; later lookups do not repeat it.
|
|
279
|
+
- The bridge remembers the last inbound author's id, name, username, and bot flag in the bot state, without storing message text.
|
|
280
|
+
|
|
281
|
+
### The two binding events
|
|
282
|
+
|
|
283
|
+
A binding change is announced synchronously, so a subscriber keeps its own session → identity table without asking back:
|
|
284
|
+
|
|
285
|
+
| Event | Emitted when | Payload |
|
|
286
|
+
| --- | --- | --- |
|
|
287
|
+
| `dsh-im/session-pre-bind` | a conversation is bound to a session, before `session.create` | `channel`, `botId`, `sessionId`, `conversationKey`, `chatType`, `chatId`, `threadId`, `senderId`, `senderName` |
|
|
288
|
+
| `dsh-im/session-unbind` | the conversation no longer points at its session: it moved to another one, or the binding was cleared | the same fields without the author; `sessionId` is the old session that was detached |
|
|
289
|
+
|
|
290
|
+
- Both are synchronous, and the order is detach-then-bind, so a subscriber reads one straight line.
|
|
291
|
+
- Only committed writes announce anything: a refused write (`false`) or a rewrite of the same session emits no `unbind`.
|
|
292
|
+
- Clearing one binding (`clearSession`) or every binding (`clearSessions`) emits a `session-unbind` per conversation.
|
|
293
|
+
- A throwing subscriber never breaks message handling.
|
|
294
|
+
- A detach does not erase the session's identity: keeping the row (with a `superseded_at`, for instance) still lets a scheduled task that owns that session deliver into the original chat — only "who owns this conversation" has to be answered from the latest bind.
|
|
295
|
+
|
|
262
296
|
### Context enhancement
|
|
263
297
|
|
|
264
298
|
[Read the context enhancement guide](docs/context-enhancement.md)
|
|
@@ -321,6 +355,11 @@ DingTalk menus use a shared template built into the plugin; no template setup is
|
|
|
321
355
|
|
|
322
356
|
## Other features
|
|
323
357
|
|
|
358
|
+
### Group new sessions by Agent Preset
|
|
359
|
+
|
|
360
|
+
Set `groupByAgentPreset: true` in the plugin Host config to opt in (off by default). A per-channel value overrides the plugin default. An explicit preset creates or reuses a named `presets/<preset-id>` workspace under the default IM directory for new sessions. Existing chats retain their history and location; manual workspaces, conversation overrides and Feishu directory isolation take priority. See [configuration and behavior](docs/preset-workspaces.md).
|
|
361
|
+
|
|
362
|
+
|
|
324
363
|
- **Image understanding**: built-in channels with image input support can send JPEG, PNG, WebP, and GIF files sent as images to Harness, with an optional text description. Originals are saved in the workspace (default 30 MB per image, 20 images per message). Model copies are resized or compressed within configurable 5 MB per-image and 20 MB total budgets, with workspace-file fallback when necessary. Configure these limits in General settings → Attachments → Image input. iMessage's MVP supports text DMs only.
|
|
325
364
|
- **Switch workspaces from a bot card**: every bot card on the settings page shows its current Harness workspace. Enter an existing absolute directory path directly or open the directory picker. Switching clears only that bot's old chat mappings; it never deletes, empties, or archives old Sessions. Replies already in progress may finish, while later messages use the new workspace.
|
|
326
365
|
- **Default directory and ungrouped sessions**: bots using the default share `$DSH_HOME/im`, while retaining separate chat-to-Session mappings. The plugin creates no workspace group for this directory. Use `/sessions` to list its ungrouped sessions and `/session <Session ID>` or `/session N` to bind an ordinary session. New sessions in other directories use the existing workspace grouping mechanism; switching back to the default directory creates ungrouped sessions again. Existing bot directories are not migrated automatically.
|
|
@@ -416,13 +455,12 @@ To pin one language regardless of who is reading the interface, set `language` i
|
|
|
416
455
|
|
|
417
456
|
## Contact
|
|
418
457
|
|
|
419
|
-
Join the
|
|
458
|
+
Join the QQ community group, or reach me by email, Xiaohongshu, or WhatsApp.
|
|
420
459
|
|
|
421
460
|
<table>
|
|
422
461
|
<tr>
|
|
423
462
|
<th align="center">Email</th>
|
|
424
|
-
<th align="center">
|
|
425
|
-
<th align="center">WeChat</th>
|
|
463
|
+
<th align="center">QQ Group</th>
|
|
426
464
|
<th align="center">Xiaohongshu</th>
|
|
427
465
|
<th align="center">WhatsApp</th>
|
|
428
466
|
</tr>
|
|
@@ -431,10 +469,7 @@ Join the WeCom community group, or reach me by email, WeChat, Xiaohongshu, or Wh
|
|
|
431
469
|
<a href="mailto:longmanr307@gmail.com">longmanr307@gmail.com</a>
|
|
432
470
|
</td>
|
|
433
471
|
<td align="center" valign="top">
|
|
434
|
-
<a href="docs/images/
|
|
435
|
-
</td>
|
|
436
|
-
<td align="center" valign="top">
|
|
437
|
-
<a href="docs/images/weixin.jpg"><img src="docs/images/weixin.jpg" alt="WeChat QR code" width="240"></a>
|
|
472
|
+
<a href="docs/images/QQ.png"><img src="docs/images/QQ.png" alt="dsh-im QQ group QR code" width="240"></a>
|
|
438
473
|
</td>
|
|
439
474
|
<td align="center" valign="top">
|
|
440
475
|
<a href="docs/images/xhs.jpg"><img src="docs/images/xhs.jpg" alt="Xiaohongshu QR code" width="240"></a>
|
package/README.md
CHANGED
|
@@ -261,6 +261,51 @@ Logo 由 dsh-im 的浏览器适配显示,无需修改 DSH。适配保留原始
|
|
|
261
261
|
|
|
262
262
|
支持全局面板的 DSH 在左侧边栏提供「IM机器人」,沿用插件页的双对话框造型,以单色细线图标显示,点击打开完整 IM 管理面板。原「设置 → IM机器人」和插件详情页的「打开 IM机器人」入口保留。宿主也可通过可选客户端服务 `dshImClient` 嵌入面板;接口、兼容要求与接入示例见[客户端接入文档](docs/client-integration.md)。
|
|
263
263
|
|
|
264
|
+
### 会话 → 对话反查(宿主服务)
|
|
265
|
+
|
|
266
|
+
其他插件常常只拿得到会话 id,却需要知道这个会话属于哪个渠道、哪个机器人、哪个群和哪个话题。宿主服务 `dshIm` 为此提供一个只读方法:
|
|
267
|
+
|
|
268
|
+
```js
|
|
269
|
+
const info = await dshIm.describeConversation(sessionId);
|
|
270
|
+
// null —— 该会话不属于任何 IM 对话
|
|
271
|
+
// 否则:
|
|
272
|
+
// { channel, botId, botName, conversationKey, chatType,
|
|
273
|
+
// chatId, threadId, chatTitle,
|
|
274
|
+
// senderId, senderName, senderUsername, senderIsBot }
|
|
275
|
+
```
|
|
276
|
+
|
|
277
|
+
- 只读:不访问网络、不创建会话、不阻塞回复,也不抛错;未知会话返回 `null`。
|
|
278
|
+
- 数据全部来自插件自己的状态文件(`sessions` 映射)与机器人配置,不要求内核新增字段。
|
|
279
|
+
- `chatType` 为 `group`、`thread` 或 `dm`;`direct:dm:<id>` 形式的键会把 `<id>` 填进 `senderId`。
|
|
280
|
+
- 每个会话首次反查写一行日志 `[dsh-im] describeConversation session=… chat=… sender=…`,之后不再重复。
|
|
281
|
+
- 发言人会被记住:桥接在把消息交给会话之前,把 `senderId`、显示名、`username` 与「是否机器人」写进机器人状态文件(`authors`),每条新消息覆盖前一条,只保留身份、不保留文本;因此重启后仍然可读。
|
|
282
|
+
- 私聊的 `senderId` 还可以从键 `direct:dm:<id>` 推出,即使作者记录缺失也有值;群聊作者在第一条入站消息之前为 `null`。
|
|
283
|
+
|
|
284
|
+
同一个反查还有一个同步版本,供在同步上下文里组装的场景使用(例如系统提示词的渲染):
|
|
285
|
+
|
|
286
|
+
```js
|
|
287
|
+
const info = dshIm.describeConversationSync(sessionId);
|
|
288
|
+
```
|
|
289
|
+
|
|
290
|
+
- 没有 `await`:只读本进程已经加载的机器人状态,绝不发起加载、访问网络或启动账户查询。
|
|
291
|
+
- 因此该机器人状态尚未加载时返回 `null` —— 调用方要自己决定「未知」意味着什么;异步版本会在需要时加载并给出 `botName`,同步版本 `botName` 恒为 `null`。
|
|
292
|
+
- 已经处理过消息的机器人,其状态一定在内存里,所以活跃会话的第一次提示词组装就能拿到身份。
|
|
293
|
+
|
|
294
|
+
### 对话绑定的两个事件
|
|
295
|
+
|
|
296
|
+
写入绑定时,通道会同步发出事件,订阅方不必反查就能维持自己的「会话 → 身份」表:
|
|
297
|
+
|
|
298
|
+
| 事件 | 何时发出 | 载荷 |
|
|
299
|
+
| --- | --- | --- |
|
|
300
|
+
| `dsh-im/session-pre-bind` | 对话绑定到某个会话,且在 `session.create` 之前 | `channel`、`botId`、`sessionId`、`conversationKey`、`chatType`、`chatId`、`threadId`、`senderId`、`senderName` |
|
|
301
|
+
| `dsh-im/session-unbind` | 对话不再指向原会话:切换到另一个会话,或绑定被清除 | 同上,但没有作者字段;`sessionId` 是被解绑的旧会话 |
|
|
302
|
+
|
|
303
|
+
- 两个事件同步发出,顺序是「先解绑旧的、再绑定新的」,订阅方能一条线读完。
|
|
304
|
+
- 只有真正提交的写入才会发事件:写入被拒绝(返回 `false`)或写成同一个会话时不发 `unbind`。
|
|
305
|
+
- 清除一个会话绑定(`clearSession`)和清除全部绑定(`clearSessions`)同样会按对话逐个发 `session-unbind`。
|
|
306
|
+
- 订阅方抛错不影响消息处理。
|
|
307
|
+
- 解绑不代表会话的身份消失:把它留在自己的表里(例如带 `superseded_at`)仍可让独占该会话的定时任务继续投递到原来的对话,只是「谁拥有这个对话」要按最新一次绑定算。
|
|
308
|
+
|
|
264
309
|
### 上下文增强
|
|
265
310
|
|
|
266
311
|
[查看上下文增强说明](docs/上下文增强.md)
|
|
@@ -323,6 +368,11 @@ Web 与机器人可同时处理同一审批,先提交的「批准一次」或
|
|
|
323
368
|
|
|
324
369
|
## 其它功能
|
|
325
370
|
|
|
371
|
+
### 按 Agent Preset 自动分组
|
|
372
|
+
|
|
373
|
+
在插件 Host 配置中设置 `groupByAgentPreset: true`(默认关闭),也可在某个渠道配置中单独启用或关闭。选择明确的 Agent Preset 后,在默认 IM 目录下创建或复用 `presets/<preset-id>` 工作区,标题使用 Preset 名称;后续新会话进入该分组。已有聊天保留原历史和位置,手动目录、会话级目录和飞书目录隔离优先。详见 [配置和行为](docs/preset-workspaces.md)。
|
|
374
|
+
|
|
375
|
+
|
|
326
376
|
- **图片识别**:支持图片输入的内置渠道都可以把 JPEG、PNG、WebP,以及以图片文件方式发送的 GIF 交给 Harness;图片可以附带文字说明。默认每张原图最多接收 30 MB、每条消息最多 20 张;原图保存到会话工作区,模型副本自动缩放或压缩到单张 5 MB、总计 20 MB 以内,仍超限或模型不支持图片时按文件交给模型处理。这四项限制可在「通用设置 → 附件 → 图片输入」调整,对后续消息生效;原图沿用附件保留时长。调高模型输入上限会增加请求体积、处理耗时和模型成本,也仍受平台及宿主限制。iMessage 首版仅支持文本私聊。
|
|
327
377
|
- **在机器人卡片切换工作区**:设置页中的每张机器人卡片都会显示当前 Harness 工作区。可以直接填写已有目录的绝对路径,也可以打开目录选择器。切换只清除该机器人的旧聊天映射,不会删除、清空或归档旧 Session;已经开始的回复可以继续完成,后续消息使用新工作区。
|
|
328
378
|
- **默认目录与未分组会话**:所有使用默认值的机器人共用 `$DSH_HOME/im`,但各自保存聊天与会话的绑定。插件不会为该目录创建工作区分组;`/sessions` 可以列出该目录的未分组会话,`/session <Session ID>` 或 `/session N` 可以绑定普通会话。切换到其他目录后,新会话按现有机制加入对应工作区分组;切回默认目录后新会话归入「未分组」。已有机器人的目录不会自动迁移。
|
|
@@ -419,13 +469,12 @@ dsh web --trusted-host dsh.example.com
|
|
|
419
469
|
|
|
420
470
|
## 联系方式
|
|
421
471
|
|
|
422
|
-
|
|
472
|
+
欢迎加入 QQ群,或通过邮箱、小红书或 WhatsApp 联系我。
|
|
423
473
|
|
|
424
474
|
<table>
|
|
425
475
|
<tr>
|
|
426
476
|
<th align="center">邮箱</th>
|
|
427
|
-
<th align="center"
|
|
428
|
-
<th align="center">微信</th>
|
|
477
|
+
<th align="center">QQ群</th>
|
|
429
478
|
<th align="center">小红书</th>
|
|
430
479
|
<th align="center">WhatsApp</th>
|
|
431
480
|
</tr>
|
|
@@ -434,10 +483,7 @@ dsh web --trusted-host dsh.example.com
|
|
|
434
483
|
<a href="mailto:longmanr307@gmail.com">longmanr307@gmail.com</a>
|
|
435
484
|
</td>
|
|
436
485
|
<td align="center" valign="top">
|
|
437
|
-
<a href="docs/images/
|
|
438
|
-
</td>
|
|
439
|
-
<td align="center" valign="top">
|
|
440
|
-
<a href="docs/images/weixin.jpg"><img src="docs/images/weixin.jpg" alt="微信二维码" width="240"></a>
|
|
486
|
+
<a href="docs/images/QQ.png"><img src="docs/images/QQ.png" alt="dsh-im QQ群二维码" width="240"></a>
|
|
441
487
|
</td>
|
|
442
488
|
<td align="center" valign="top">
|
|
443
489
|
<a href="docs/images/xhs.jpg"><img src="docs/images/xhs.jpg" alt="小红书二维码" width="240"></a>
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# Agent Preset workspace groups
|
|
2
|
+
|
|
3
|
+
## 中文
|
|
4
|
+
|
|
5
|
+
这是插件 Host 配置选项,默认关闭,不自动迁移任何已有聊天。在 Host 的插件配置(例如所用 profile 的 `cordis.patch.yml` 中该插件的 `config`)中加入:
|
|
6
|
+
|
|
7
|
+
```yaml
|
|
8
|
+
- insert:
|
|
9
|
+
- id: xmanrui-dsh-im
|
|
10
|
+
name: '@xmanrui/dsh-im'
|
|
11
|
+
config:
|
|
12
|
+
groupByAgentPreset: true
|
|
13
|
+
feishu:
|
|
14
|
+
groupByAgentPreset: false
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
根选项为渠道默认;渠道值可以覆盖它。修改后重启 Host,再在机器人设置中选择明确的 Agent Preset。选择 Preset 时创建或复用分组,已有明确 Preset 的机器人会在下一次创建会话时创建分组。关闭选项不会删除目录或移动会话。
|
|
18
|
+
|
|
19
|
+
- 仅默认 IM 工作目录(`<DSH_HOME>/im`)参与自动分组。目录为 `presets/<preset-id>`,工作区标题使用 Preset 的展示名称。
|
|
20
|
+
- 跟随 Host 默认时不创建分组。自选机器人目录、`/conv` 会话目录和飞书会话目录隔离优先,不会被分组覆盖。Matrix 的默认目录为自选目录,需显式使用默认 IM 目录才参与。
|
|
21
|
+
- 只影响后续新会话;已有会话的历史、绑定和位置保留。支持 `/new` 的渠道可发送 `/new` 后再提问;其他渠道使用其现有新会话操作。
|
|
22
|
+
- `/sessions`、`/session N` 和会话选择菜单使用当前已绑定会话的实际目录,重启或修改 Preset 后也保留旧会话的目录。同一自动分组内切换会话不会修改机器人默认目录或清除其他聊天;`/new` 后会话列表跟随后续新会话使用的 Preset 分组。
|
|
23
|
+
- 相同目录和 Preset 复用同一个分组,不按展示标题合并其他工作区;同名时附加 Preset ID,用户手动重命名后保留名称。
|
|
24
|
+
- 分组是 Harness 工作区,意味着同组新会话共享一个文件目录;各机器人、私聊及群聊仍保留各自会话历史。这不是用户权限或数据隔离功能。
|
|
25
|
+
- 保存 Preset 时若工作区创建或改名失败,Preset 设置不保存;已有会话不受影响。会话创建失败会正常返回错误,不退回未分组悄悄执行。
|
|
26
|
+
|
|
27
|
+
## English
|
|
28
|
+
|
|
29
|
+
This is an opt-in **Host plugin configuration** setting, off by default. In the plugin's `config` (for example in the active profile's `cordis.patch.yml`), set `groupByAgentPreset: true`. The YAML example above enables it globally and disables it for Feishu. Restart the Host after changing configuration; existing settings UI and preset commands continue to select the preset.
|
|
30
|
+
|
|
31
|
+
Only an explicitly selected preset and the default `<DSH_HOME>/im` directory participate. Selecting a preset creates or reuses `presets/<preset-id>` as a registered Harness workspace, named with the preset's display label. Already-selected presets are grouped on the next new session. Inherited Host defaults, manual bot directories, conversation workspace overrides and Feishu conversation directory isolation take priority.
|
|
32
|
+
|
|
33
|
+
Existing chats, bindings and history stay in place. On supported channels use `/new`, then ask again, to create a new session. Turning the option off neither deletes directories nor moves chats. A renamed group retains its title; unrelated same-name workspaces are never merged.
|
|
34
|
+
|
|
35
|
+
`/sessions`, `/session N` and session menus use the bound session's actual workspace, including after a restart or preset change. Selecting another session in the same automatic group preserves the bot's default directory and other chat bindings. After `/new`, the list follows the preset group for future sessions.
|
|
36
|
+
|
|
37
|
+
This is a real workspace directory shared by newly grouped sessions, not an access-control boundary. Bot and conversation histories remain separate. A registration failure surfaces as an error rather than silently running in the wrong directory; a failed preset save keeps the previous selection.
|
package/lib/client.js
CHANGED
|
@@ -595,7 +595,7 @@ var React48 = __toESM(require("react"), 1);
|
|
|
595
595
|
// package.json
|
|
596
596
|
var package_default = {
|
|
597
597
|
name: "@xmanrui/dsh-im",
|
|
598
|
-
version: "5.
|
|
598
|
+
version: "5.9.0",
|
|
599
599
|
icon: "./assets/logo-plugin-message-link-gradient.webp",
|
|
600
600
|
description: "\u628A\u5FAE\u4FE1\u3001\u98DE\u4E66\u3001\u4F01\u5FAE\u3001\u9489\u9489\u3001QQ\u3001Telegram\u3001WhatsApp\u3001Slack\u3001Discord\u3001Matrix\u63A5\u5165DSH\u3002 Connect Telegram, WhatsApp, Slack, Discord, Matrix, WeChat, Feishu, WeCom, DingTalk, and QQ to DSH.",
|
|
601
601
|
keywords: [
|
|
@@ -651,6 +651,7 @@ var package_default = {
|
|
|
651
651
|
"lib",
|
|
652
652
|
"locale/*.json",
|
|
653
653
|
"plugin-src",
|
|
654
|
+
"scripts/telegram-menu-scopes.mjs",
|
|
654
655
|
"scripts/verify-interface-language.mjs",
|
|
655
656
|
"scripts/verify-injected-context.mjs",
|
|
656
657
|
"scripts/verify-lan-management.mjs",
|
|
@@ -662,6 +663,7 @@ var package_default = {
|
|
|
662
663
|
"PROACTIVE_DELIVERY.md",
|
|
663
664
|
"PROACTIVE_DELIVERY.en.md",
|
|
664
665
|
"docs/client-integration.md",
|
|
666
|
+
"docs/preset-workspaces.md",
|
|
665
667
|
"LICENSE",
|
|
666
668
|
"README.md",
|
|
667
669
|
"README.en.md",
|
|
@@ -4488,6 +4490,32 @@ var CONFIG_ISSUE_LABELS = Object.freeze({
|
|
|
4488
4490
|
"unexpected-field": "\u5F53\u524D\u914D\u7F6E\u7248\u672C\u4E0D\u5141\u8BB8\u6B64\u5B57\u6BB5\u3002"
|
|
4489
4491
|
});
|
|
4490
4492
|
var CONFIG_FIELD = /^(?:\$|version|accounts(?:\[\d{1,10}\](?:\.(?:accountId|ownerUserId|botId|tokenRef|baseUrl))?)?|(?:workspaces|agentPresets|models)(?:\[\d{1,10}\]\.(?:key|value))?|deliveryTargets(?:\[\d{1,10}\]\.(?:key|targets(?:\[\d{1,10}\])?))?)$/;
|
|
4493
|
+
var DIAGNOSTIC_MESSAGE_SHAPES = [
|
|
4494
|
+
// `QRCode.toDataURL is not a function`, `PNG.sync.write is not a constructor`
|
|
4495
|
+
/^(?:[A-Za-z_$][\w$]*\.)*[A-Za-z_$][\w$]* is not a (?:function|constructor)$/u,
|
|
4496
|
+
// node-qrcode validating its argument
|
|
4497
|
+
/^String required as first argument$/u,
|
|
4498
|
+
// property access on undefined inside the encoder
|
|
4499
|
+
/^Cannot read propert(?:y|ies) .{1,100}$/u,
|
|
4500
|
+
// zlib: `invalid stored block lengths`, `incorrect header check`, `Invalid data`
|
|
4501
|
+
/^(?:invalid|incorrect|unexpected|unknown|bad)\s+[A-Za-z][A-Za-z0-9 _-]{2,80}$/iu,
|
|
4502
|
+
// pngjs / buffer: `padding not multiple of block size`, `buffer write failed`
|
|
4503
|
+
/^[A-Za-z][A-Za-z0-9 _-]{2,60}(?: not multiple of block size| failed)$/u
|
|
4504
|
+
];
|
|
4505
|
+
var DIAGNOSTIC_MESSAGE_DENY = /(?:token|secret|password|passwd|authorization|bearer|cookie)/iu;
|
|
4506
|
+
var DIAGNOSTIC_MESSAGE_URL = /\b(?:[a-z][a-z0-9+.-]*:\/\/)\S*/iu;
|
|
4507
|
+
var DIAGNOSTIC_MESSAGE_EMAIL = /[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+/u;
|
|
4508
|
+
var DIAGNOSTIC_MESSAGE_OPAQUE = /\b[A-Za-z0-9_\-+/=]{32,}\b/u;
|
|
4509
|
+
function safeDiagnosticMessage(value) {
|
|
4510
|
+
if (typeof value !== "string") return void 0;
|
|
4511
|
+
const text8 = value.replace(/[\u0000-\u001f\u007f]/gu, " ").replace(/\s+/gu, " ").trim();
|
|
4512
|
+
if (!/^[\x20-\x7e]+$/u.test(text8)) return void 0;
|
|
4513
|
+
if (!DIAGNOSTIC_MESSAGE_SHAPES.some((shape) => shape.test(text8))) return void 0;
|
|
4514
|
+
if (DIAGNOSTIC_MESSAGE_DENY.test(text8)) return void 0;
|
|
4515
|
+
if (DIAGNOSTIC_MESSAGE_URL.test(text8) || DIAGNOSTIC_MESSAGE_EMAIL.test(text8)) return void 0;
|
|
4516
|
+
if (DIAGNOSTIC_MESSAGE_OPAQUE.test(text8)) return void 0;
|
|
4517
|
+
return text8;
|
|
4518
|
+
}
|
|
4491
4519
|
function normalizeDiagnosticDetails(value) {
|
|
4492
4520
|
if (!value || typeof value !== "object" || Array.isArray(value)) return {};
|
|
4493
4521
|
const result2 = {};
|
|
@@ -4530,6 +4558,10 @@ function normalizeDiagnosticDetails(value) {
|
|
|
4530
4558
|
if (typeof provider === "string" && /^-?\d{1,12}$/.test(provider)) result2.providerCode = provider;
|
|
4531
4559
|
if (typeof value.pluginVersion === "string" && /^\d+\.\d+\.\d+(?:-[A-Za-z0-9.-]+)?$/.test(value.pluginVersion) && value.pluginVersion.length <= 64) result2.pluginVersion = value.pluginVersion;
|
|
4532
4560
|
if (["succeeded", "failed", "not-attempted", "unknown"].includes(value.rollback)) result2.rollback = value.rollback;
|
|
4561
|
+
if (typeof value.causeMessage === "string") {
|
|
4562
|
+
const message = safeDiagnosticMessage(value.causeMessage);
|
|
4563
|
+
if (message) result2.causeMessage = message;
|
|
4564
|
+
}
|
|
4533
4565
|
if (typeof value.hint === "string" && value.hint.trim()) result2.hint = value.hint.trim().slice(0, 500);
|
|
4534
4566
|
return result2;
|
|
4535
4567
|
}
|
|
@@ -4605,7 +4637,7 @@ function formatConnectionDiagnostic(value) {
|
|
|
4605
4637
|
localizeText(error.message),
|
|
4606
4638
|
details.hint ? localizeText(details.hint) : null,
|
|
4607
4639
|
localizeText("\u9519\u8BEF\u7801") + ": " + error.code,
|
|
4608
|
-
...["channel", "operation", "stage", "method", "transport", "submissionState", "attempts", "lastFailureReason", "reason", "reasons", "errorTypes", "qrEncoder", "qrRenderer", "host", "durationMs", "timeoutMs", "nodeVersion", "dshVersion", "platform", "dependencies", "proxyConfigured", "truncated", "httpStatus", "providerCode", "resource", "file", "field", "issue", "referenceId", "occurredAt", "rollback", "pluginVersion"].filter((field2) => details[field2] !== void 0).map((field2) => `${field2}: ${typeof details[field2] === "object" ? JSON.stringify(details[field2]) : details[field2]}`)
|
|
4640
|
+
...["channel", "operation", "stage", "method", "transport", "submissionState", "attempts", "lastFailureReason", "reason", "reasons", "errorTypes", "causeMessage", "qrEncoder", "qrRenderer", "host", "durationMs", "timeoutMs", "nodeVersion", "dshVersion", "platform", "dependencies", "proxyConfigured", "truncated", "httpStatus", "providerCode", "resource", "file", "field", "issue", "referenceId", "occurredAt", "rollback", "pluginVersion"].filter((field2) => details[field2] !== void 0).map((field2) => `${field2}: ${typeof details[field2] === "object" ? JSON.stringify(details[field2]) : details[field2]}`)
|
|
4609
4641
|
].filter(Boolean).join("\n");
|
|
4610
4642
|
}
|
|
4611
4643
|
function ConnectionError({ error: value, warning = false, showMessage = true }) {
|