@xmanrui/dsh-im 5.9.1 → 5.10.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/PROACTIVE_DELIVERY.en.md +33 -9
- package/PROACTIVE_DELIVERY.md +33 -9
- package/README.en.md +3 -2
- package/README.md +4 -3
- package/lib/client.js +550 -125
- package/lib/index.js +323 -323
- package/package.json +1 -1
- package/plugin-src/client/delivery-settings.js +2 -0
- package/plugin-src/client/delivery-sync-settings.js +269 -0
- package/plugin-src/client/global-settings.js +45 -7
- package/plugin-src/client/i18n-ru.js +27 -0
- package/plugin-src/client/i18n.js +27 -0
- package/plugin-src/client/index.js +17 -1
- package/plugin-src/client/model-setting.js +6 -3
- package/plugin-src/client/styles.js +16 -0
- package/plugin-src/host/channels/feishu/production.mjs +11 -27
- package/plugin-src/host/channels/shared/workspace-rpc.mjs +1 -0
- package/plugin-src/host/delivery-adapter.mjs +35 -20
- package/plugin-src/host/delivery-service.mjs +100 -1
- package/plugin-src/host/delivery-suggestions.mjs +28 -0
- package/plugin-src/host/delivery-sync-rpc.mjs +100 -0
- package/plugin-src/host/host-language-rpc.mjs +16 -2
- package/plugin-src/host/host-language.mjs +29 -0
- package/plugin-src/host/index.mjs +22 -0
- package/plugin-src/host/session-sync-coordinator.mjs +288 -121
- package/plugin-src/host/session-sync-targets.mjs +71 -0
- package/scripts/verify-package.mjs +14 -5
- package/src/channels/qq/qq-bridge.mjs +9 -0
- package/src/channels/qq/state-store.mjs +42 -0
- package/src/channels/shared/action-card.mjs +83 -7
- package/src/channels/shared/bot-workspace-store.mjs +100 -8
- package/src/channels/shared/delivery-sync-settings-store.mjs +86 -0
- package/src/channels/shared/delivery-sync-settings.mjs +122 -0
- package/src/channels/shared/harness-client.mjs +148 -90
- package/src/channels/shared/i18n-en/diagnostics.mjs +1 -0
- package/src/channels/shared/i18n-en/shared-b.mjs +6 -0
- package/src/channels/shared/i18n-ru/diagnostics.mjs +1 -0
- package/src/channels/shared/i18n-ru/shared-b.mjs +5 -0
- package/src/channels/shared/interface-language-store.mjs +49 -10
- package/src/channels/shared/interface-language.mjs +19 -1
- package/src/channels/shared/model-setting.mjs +6 -3
- package/src/channels/shared/workspace-session.mjs +13 -1
- package/src/channels/telegram/telegram-api.mjs +19 -1
package/PROACTIVE_DELIVERY.en.md
CHANGED
|
@@ -78,18 +78,42 @@ Assume the Feishu bot has already received a message in the alert group:
|
|
|
78
78
|
|
|
79
79
|
If the group Chat ID is edited later, callers can continue using the same `botId + release-alerts` pair.
|
|
80
80
|
|
|
81
|
-
## Two-way sync for
|
|
81
|
+
## Two-way sync for any Session conversation
|
|
82
82
|
|
|
83
|
-
|
|
83
|
+
Session sync needs no delivery target in advance: the address comes from the Session's current chat binding, that is, the conversation key this Session has in a connected chat (a direct message, a group, a Slack thread, a Telegram forum topic, a Discord channel). **General settings → Delivery** is the only place where the sync is switched on; the delivery-targets page is only for manual delivery and for the candidate range of synced approvals and questions.
|
|
84
84
|
|
|
85
|
-
1.
|
|
86
|
-
2. After
|
|
87
|
-
3.
|
|
88
|
-
4.
|
|
85
|
+
1. Ordinary prompts and `/steer` inside that chat keep using the normal reply path. They are neither duplicated nor forwarded to another target.
|
|
86
|
+
2. After a successful turn from another source, only the **final answer** is sent to the chat — the text after the last tool call, not every step joined together and not the talk that precedes the tools: a turn submitted in the DSH Web GUI, a scheduled task (`schedule`, `deliveryMode: host`), an answered-question receipt, or a turn started by an internal notice such as `subagent-settled`.
|
|
87
|
+
3. Whether the Web input itself is mirrored into the chat and whether model answers are delivered is decided by **General settings → Delivery**; the two prefix icons apply to the mirrored input and to the answer respectively.
|
|
88
|
+
4. Only text the reader submitted in the DSH Web GUI is mirrored: the context snapshot the Host injects, schedule reminders, and internal notices are never echoed, and only the model answer is delivered. When the input mirror cannot be sent, that turn's answer is withheld too.
|
|
89
|
+
5. A channel that renders the answer itself — the Feishu process card — owns that delivery: the card carries the final answer, and plain text follows only when the card did not confirm it. One answer therefore reaches the chat once, never as a card and a copy of the same text. With both switches off, the card stops together with the text, because both read the same switches.
|
|
90
|
+
6. The address is read from the current binding before every delivery, so it follows `/session` changes and `/new` automatically; a Session with no binding is not delivered and raises no error, but the miss is logged with the Session, the channel and the conversation key — never the message body — so an empty chat stays diagnosable.
|
|
89
91
|
|
|
90
|
-
|
|
92
|
+
A service injection never decides where the turn came from: the context snapshot the Host prepends, a schedule reminder or an internal notice is only "one message of this turn", never proof that a service started it. The answer is delivered as a service turn only when no message of the turn came from the reader (the Web GUI or this chat); as soon as one message came from this chat, the chat answers for itself and the sync delivers nothing at all.
|
|
91
93
|
|
|
92
|
-
|
|
94
|
+
The **Two-way Session sync** switch on a delivery target now only affects the candidate range of synced approvals and questions; it is no longer a precondition for Session sync. That candidate range stays private-chat only: mirrored text follows any route the channel persisted (a group, a Slack thread, a Telegram forum topic, a Discord channel), but a question or an approval is offered in a private chat only, because in a group any member could answer it. The first version mirrors current-Host text only—no images, files, cards, tool progress, approvals, or history. A channel with an explicit remote `harnessBaseUrl` is still unsupported.
|
|
95
|
+
|
|
96
|
+
## Delivery settings
|
|
97
|
+
|
|
98
|
+
**General settings → Delivery** stores plugin-wide settings rather than per-bot ones, in `<dshHome>/integrations/dsh-im/delivery-sync-settings.json`:
|
|
99
|
+
|
|
100
|
+
```json
|
|
101
|
+
{
|
|
102
|
+
"version": 1,
|
|
103
|
+
"deliverySync": {
|
|
104
|
+
"mirrorUserInput": false,
|
|
105
|
+
"deliverModelAnswers": false,
|
|
106
|
+
"inputIcon": "",
|
|
107
|
+
"modelIcon": ""
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
- `mirrorUserInput`: mirror user text submitted in the Web GUI into the chat the Session is bound to; off by default. While it is off nothing is echoed, but the model answer is still delivered.
|
|
113
|
+
- `deliverModelAnswers`: deliver model answers of turns that did not start in this chat; off by default, like the input mirror. Both switches are off in a fresh install, and an unreadable document is treated as both off: the coordinator logs a warning and delivers nothing rather than starting to mirror on its own.
|
|
114
|
+
- `inputIcon` / `modelIcon`: prefix icons for the mirrored input and for the model answer. Trimmed, at most 32 characters, no line breaks or control characters; an invalid value becomes the empty string, and an empty icon means no prefix. A non-empty icon renders as "icon, blank line, text".
|
|
115
|
+
|
|
116
|
+
The settings page reads and writes this document through `settings.delivery-sync.get` / `settings.delivery-sync.set` (`set` applies only the fields it carries, and all four are optional). `settings.language.set` switches the message language between "same as the DSH interface" and `zh`/`en`/`ru`: the explicit choice outranks the DSH interface language, and the plugin `language` option still outranks both.
|
|
93
117
|
|
|
94
118
|
## Native fields for all nine channels
|
|
95
119
|
|
|
@@ -192,7 +216,7 @@ await ctx.dshIm.send(botId, targetId, '# Daily report\n\n**Checks complete**', {
|
|
|
192
216
|
|
|
193
217
|
Channels apply their own message limits and splitting. Feishu proactive cards retain their existing unsplit behavior and do not automatically resend as text after rejection or an uncertain result. Other newly added fallback paths only handle local formatting errors or definite format rejection; they do not resend accepted chunks or retry ambiguous network outcomes. Older Hosts may ignore `format`; load the updated plugin on the Host.
|
|
194
218
|
|
|
195
|
-
Session sync requests Markdown for final assistant
|
|
219
|
+
Session sync requests Markdown for the final assistant answer and plain text for mirrored Web input. Both follow the Session binding through the ordinary delivery path and no longer use Feishu's dedicated mirror cards, so Feishu receives that same text.
|
|
196
220
|
|
|
197
221
|
A same-Host plugin may also list the saved targets for one bot:
|
|
198
222
|
|
package/PROACTIVE_DELIVERY.md
CHANGED
|
@@ -78,18 +78,42 @@
|
|
|
78
78
|
|
|
79
79
|
以后即使编辑并更换群 Chat ID,调用方仍可继续使用同一组 `botId + release-alerts`。
|
|
80
80
|
|
|
81
|
-
##
|
|
81
|
+
## 会话双向同步
|
|
82
82
|
|
|
83
|
-
|
|
83
|
+
会话同步不需要预先创建投递目标:地址取自 Session 当前的聊天绑定,也就是这个 Session 在某个已接入聊天里的会话键(私聊、群聊、Slack Thread、Telegram Topic、Discord 频道等)。是否同步由「通用设置 → 投递」决定,这是唯一的开关位置;「投递目标」页只服务于手动投递,以及同步审批和同步提问的候选范围。
|
|
84
84
|
|
|
85
|
-
1.
|
|
86
|
-
2.
|
|
87
|
-
3.
|
|
88
|
-
4.
|
|
85
|
+
1. 在该聊天里的普通提问和 `/steer` 仍走原回复链,不会被同步逻辑重复发送或转发到其他目标。
|
|
86
|
+
2. 其他来源的 Turn 成功完成后,只投递**最终回答**——最后一次工具调用之后的文字,而不是各 step 拼接的全文,也不是工具调用之前的寒暄:Web GUI 中提交的 Turn、定时任务(`schedule`、`deliveryMode: host`)、待答问题回执,以及 `subagent-settled` 等内部通知发起的 Turn。
|
|
87
|
+
3. 是否把 Web 中输入的文字本身也镜像到聊天、是否投递模型回答,由「通用设置 → 投递」决定;两个前缀图标分别作用于镜像的输入与模型回答。
|
|
88
|
+
4. 只有读者自己在 Web GUI 里提交的文字才会被镜像:Host 注入的上下文快照、定时提醒和内部通知都不会回显,只投递模型回答。镜像发送失败时,该 Turn 的回答也不再投递。
|
|
89
|
+
5. 渠道自己渲染回答时(飞书过程卡片),卡片就是这次投递:最终回答写在卡片里,只有卡片没能确认,才补发一条纯文字。同一条回答因此只会到达聊天一次,不会既在卡片里又以文字重发一遍。两个全局开关关闭时,卡片与文字一起停发,因为两者读的是同一份开关。
|
|
90
|
+
6. 地址在每次投递前从当前绑定读取,因此自动跟随 `/session` 切换与 `/new`;没有绑定的 Session 不会投递,也不会报错,但会写一条不含消息正文的日志(Session、渠道与会话 Key),方便排查为什么聊天没有收到内容。
|
|
89
91
|
|
|
90
|
-
|
|
92
|
+
服务注入不会决定 Turn 的来源:Host 在每个 Turn 前注入的上下文快照、定时提醒与内部通知只是「这是本 Turn 的一条消息」,不会把 Turn 判成服务发起的。只有整个 Turn 都没有一条来自读者(Web 或本聊天)的消息时,才按服务发起的 Turn 投递回答;只要其中一条消息来自本聊天,该 Turn 就由聊天自己回答,同步逻辑完全不投递。
|
|
91
93
|
|
|
92
|
-
|
|
94
|
+
投递目标行上原有的「会话双向同步」开关现在只影响同步审批与同步提问的候选范围,不再是会话同步的前提;这个候选范围仍然只限私聊:镜像文字可以跟随渠道持久化的任意路由(群聊、Slack Thread、Telegram Topic、Discord 频道),但同步审批与同步提问只在私聊中提出,因为在群里任何成员都能替读者作答。首版仅同步当前 Host 的文字,不同步图片、文件、卡片、工具过程、审批或历史消息。显式配置了远程 `harnessBaseUrl` 的渠道也不支持。
|
|
95
|
+
|
|
96
|
+
## 投递设置
|
|
97
|
+
|
|
98
|
+
「通用设置 → 投递」保存的是全局设置,不属于单个机器人,写入 `<dshHome>/integrations/dsh-im/delivery-sync-settings.json`:
|
|
99
|
+
|
|
100
|
+
```json
|
|
101
|
+
{
|
|
102
|
+
"version": 1,
|
|
103
|
+
"deliverySync": {
|
|
104
|
+
"mirrorUserInput": false,
|
|
105
|
+
"deliverModelAnswers": false,
|
|
106
|
+
"inputIcon": "",
|
|
107
|
+
"modelIcon": ""
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
- `mirrorUserInput`:把在 Web GUI 中提交的用户文字镜像到该 Session 绑定的聊天;默认关闭。关闭时不发送输入,模型回答照常投递。
|
|
113
|
+
- `deliverModelAnswers`:投递「非本聊天发起」的 Turn 的模型回答;默认关闭,与输入镜像一致。全新安装两项都是关闭的;设置文件无法读取时同样按两项关闭处理——协调器只记录一条警告,不会自行开始镜像。
|
|
114
|
+
- `inputIcon` / `modelIcon`:镜像输入与模型回答的前缀图标。去除首尾空白,最长 32 个字符,不允许多行或控制字符;无效值按空字符串处理,空字符串表示不加前缀。非空时消息格式为「图标 + 空行 + 文字」。
|
|
115
|
+
|
|
116
|
+
同机设置页通过 `settings.delivery-sync.get` / `settings.delivery-sync.set` 读写这份设置(`set` 只应用传入的字段,四个字段都可选)。消息语言通过 `settings.language.set` 在「跟随 DSH 界面语言」与 `zh`/`en`/`ru` 之间切换:显式选择优先于 DSH 界面语言,插件 `language` 选项仍然优先于两者。
|
|
93
117
|
|
|
94
118
|
## 九渠道手动填写字段
|
|
95
119
|
|
|
@@ -192,7 +216,7 @@ await ctx.dshIm.send(botId, targetId, '# 每日报告\n\n**检查完成**', {
|
|
|
192
216
|
|
|
193
217
|
长消息按渠道限制分段。飞书主动卡片保留原有不自动分段的行为,平台拒绝或结果未知时不自动改发文本。其他新增回退仅针对本地格式处理错误或明确的格式拒绝,不重发已成功的分段,不因网络结果未知而改格式重试。旧 Host 可能忽略 `format`,需要加载更新后的插件。
|
|
194
218
|
|
|
195
|
-
会话同步的最终助手回答请求 Markdown
|
|
219
|
+
会话同步的最终助手回答请求 Markdown,镜像的 Web 输入使用纯文本,两者都按 Session 绑定地址走普通投递路径,不再经由飞书专用的镜像卡片:飞书收到的就是同一份文本。
|
|
196
220
|
|
|
197
221
|
同 Host 插件也可以列出某个机器人的已保存目标:
|
|
198
222
|
|
package/README.en.md
CHANGED
|
@@ -274,9 +274,10 @@ const info = await dshIm.describeConversation(sessionId);
|
|
|
274
274
|
|
|
275
275
|
- Read-only: no network access, session creation, blocking reply, or thrown error; unknown Sessions return `null`.
|
|
276
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
|
|
277
|
+
- `chatType` is `group`, `thread`, or `dm`. Without an author record, `senderId` is derived from the key only where the key names the user: Matrix `direct:dm:<userId>`, `p2p:<id>` (Feishu, Weixin, WeCom app, DingTalk), QQ `c2c:<openid>`, and `direct:<id>` on Telegram and WeCom. On Slack, Discord, WhatsApp, iMessage and others `direct:<id>` names the DM channel, so it is reported as `chatId` and `senderId` stays `null`.
|
|
278
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
|
|
279
|
+
- The bridge remembers the last inbound author's id and bot flag in the bot state, without storing message text. The display name and username are stored only when context enhancement is enabled for that chat kind (or the channel already exposes a speaker name, as Matrix does); otherwise they are `null`.
|
|
280
|
+
- Links inserted from conversation keys into numeric chat/topic fields are **Telegram-only**; QQ and other channels must use their native route fields and must not be treated as Telegram links.
|
|
280
281
|
|
|
281
282
|
### The two binding events
|
|
282
283
|
|
package/README.md
CHANGED
|
@@ -276,10 +276,11 @@ const info = await dshIm.describeConversation(sessionId);
|
|
|
276
276
|
|
|
277
277
|
- 只读:不访问网络、不创建会话、不阻塞回复,也不抛错;未知会话返回 `null`。
|
|
278
278
|
- 数据全部来自插件自己的状态文件(`sessions` 映射)与机器人配置,不要求内核新增字段。
|
|
279
|
-
- `chatType` 为 `group`、`thread` 或 `dm
|
|
279
|
+
- `chatType` 为 `group`、`thread` 或 `dm`。没有作者记录时,只有当键本身标识用户时才从键推出 `senderId`:Matrix `direct:dm:<userId>`、`p2p:<id>`(飞书、微信、企业微信自建应用、钉钉)、QQ `c2c:<openid>`,以及 Telegram 和企业微信的 `direct:<id>`。Slack、Discord、WhatsApp、iMessage 等渠道的 `direct:<id>` 标识的是私聊频道,因此放进 `chatId`,`senderId` 保持 `null`。
|
|
280
280
|
- 每个会话首次反查写一行日志 `[dsh-im] describeConversation session=… chat=… sender=…`,之后不再重复。
|
|
281
|
-
- 发言人会被记住:桥接在把消息交给会话之前,把 `senderId
|
|
282
|
-
-
|
|
281
|
+
- 发言人会被记住:桥接在把消息交给会话之前,把 `senderId` 与「是否机器人」写进机器人状态文件(`authors`);显示名和 `username` 只有在该聊天类型启用了上下文增强(或渠道本身提供发言人名称,如 Matrix)时才记录,否则为 `null`,每条新消息覆盖前一条,只保留身份、不保留文本;因此重启后仍然可读。
|
|
282
|
+
- 上述渠道的私聊 `senderId` 即使作者记录缺失也能从键推出;群聊作者在第一条入站消息之前为 `null`。
|
|
283
|
+
- 由对话键插入数字聊天/话题字段的链接是 **Telegram 专用**;QQ 和其他渠道必须使用各自的原生 route 字段,不能把它们当作 Telegram 链接。
|
|
283
284
|
|
|
284
285
|
同一个反查还有一个同步版本,供在同步上下文里组装的场景使用(例如系统提示词的渲染):
|
|
285
286
|
|