@xmanrui/dsh-im 4.24.1 → 4.26.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.
Files changed (49) hide show
  1. package/PROACTIVE_DELIVERY.en.md +12 -4
  2. package/PROACTIVE_DELIVERY.md +12 -4
  3. package/README.en.md +11 -3
  4. package/README.md +11 -3
  5. package/THIRD_PARTY_NOTICES.md +2 -0
  6. package/lib/client.js +654 -311
  7. package/lib/index.js +298 -289
  8. package/package.json +7 -8
  9. package/plugin-src/client/channel-logos.js +11 -0
  10. package/plugin-src/client/channels/matrix/api.js +11 -0
  11. package/plugin-src/client/channels/matrix/index.js +151 -0
  12. package/plugin-src/client/channels/matrix/styles.js +36 -0
  13. package/plugin-src/client/global-settings.js +26 -14
  14. package/plugin-src/client/i18n.js +20 -0
  15. package/plugin-src/client/index.js +20 -0
  16. package/plugin-src/client/session-channel-logos.js +2 -1
  17. package/plugin-src/client/styles.js +19 -3
  18. package/plugin-src/client/update-panel.js +31 -11
  19. package/plugin-src/host/channels/matrix/index.mjs +31 -0
  20. package/plugin-src/host/channels/matrix/production.mjs +227 -0
  21. package/plugin-src/host/channels/matrix/rpc.mjs +228 -0
  22. package/plugin-src/host/channels/shared/access-policy-production.mjs +1 -1
  23. package/plugin-src/host/channels/shared/startup-error.mjs +2 -1
  24. package/plugin-src/host/delivery-adapter.mjs +18 -0
  25. package/plugin-src/host/delivery-rpc.mjs +7 -2
  26. package/plugin-src/host/delivery-service.mjs +8 -2
  27. package/plugin-src/host/delivery-suggestions.mjs +13 -0
  28. package/plugin-src/host/index.mjs +3 -0
  29. package/scripts/verify-injected-context.mjs +120 -0
  30. package/scripts/verify-lan-management.mjs +1 -1
  31. package/scripts/verify-package.mjs +6 -1
  32. package/src/channels/feishu/feishu-runtime.mjs +13 -3
  33. package/src/channels/matrix/matrix-api.mjs +696 -0
  34. package/src/channels/matrix/matrix-bridge.mjs +20 -0
  35. package/src/channels/matrix/matrix-config-store.mjs +356 -0
  36. package/src/channels/matrix/matrix-controller.mjs +404 -0
  37. package/src/channels/matrix/matrix-crypto-store.mjs +279 -0
  38. package/src/channels/matrix/matrix-crypto.mjs +1014 -0
  39. package/src/channels/matrix/matrix-harness-client.mjs +11 -0
  40. package/src/channels/matrix/matrix-normalize.mjs +357 -0
  41. package/src/channels/matrix/matrix-rich-text.mjs +313 -0
  42. package/src/channels/matrix/matrix-runtime.mjs +900 -0
  43. package/src/channels/shared/command-catalog.mjs +1 -1
  44. package/src/channels/shared/i18n-en/image-input.mjs +1 -0
  45. package/src/channels/shared/i18n-en/matrix.mjs +75 -0
  46. package/src/channels/shared/i18n-en.mjs +2 -0
  47. package/src/channels/shared/injected-context.mjs +3 -3
  48. package/src/channels/shared/session-channel-labels.mjs +1 -0
  49. package/src/channels/shared/text-harness-bridge.mjs +3 -0
@@ -1,6 +1,6 @@
1
1
  import { t } from './i18n.mjs';
2
2
 
3
- const TEXT_CHANNELS = Object.freeze(['telegram', 'slack', 'discord', 'whatsapp']);
3
+ const TEXT_CHANNELS = Object.freeze(['telegram', 'slack', 'discord', 'whatsapp', 'matrix']);
4
4
 
5
5
  function defineCatalogCommand(name, description, help, { aliases = [], ...options } = {}) {
6
6
  return Object.freeze({
@@ -11,6 +11,7 @@ export default {
11
11
  "模型图片总量上限 (MB)": "Model total image limit (MB)",
12
12
  "每条消息最多图片数": "Maximum images per message",
13
13
  "图片输入": "Image input",
14
+ "查看图片输入说明": "View image input details",
14
15
  "适用于支持图片的聊天渠道。原图按附件保留时长保存,发送给模型的副本会自动缩放或压缩;无法直接发送时交给模型按文件处理。": "Applies to chat channels that support images. Originals follow attachment retention settings. Model copies are resized or compressed automatically; images that cannot be sent directly are provided as files.",
15
16
  "保存图片设置": "Save image settings",
16
17
  "正在读取图片设置…": "Loading image settings…"
@@ -0,0 +1,75 @@
1
+ // English translations (matrix area). Keys are exact Chinese literals passed to t().
2
+ export default {
3
+ 'Matrix机器人': 'Matrix bot',
4
+ 'Matrix机器人凭据缺失,请移除后重新接入。':
5
+ 'Matrix bot credentials are missing. Remove the bot and connect it again.',
6
+ 'Matrix机器人凭据缺失,请重新输入凭据。':
7
+ 'Matrix bot credentials are missing. Enter the credentials again.',
8
+ 'Matrix 连接未就绪,插件会自动重试。':
9
+ 'The Matrix connection is not ready yet. The plugin will retry automatically.',
10
+ 'Matrix 长轮询接收和 Harness 回复全部正常。':
11
+ 'Matrix long polling and Harness replies are all working.',
12
+ 'Matrix 连接当前离线。':
13
+ 'The Matrix connection is currently offline.',
14
+ 'Matrix 长轮询尚未建立,请检查 homeserver 与凭据。':
15
+ 'The Matrix long poll has not been established. Check the homeserver URL and the credentials.',
16
+ 'Matrix 正在处理消息;当前存在未恢复的连接。':
17
+ 'Matrix is processing messages; some connections have not recovered yet.',
18
+
19
+ 'Matrix homeserver 地址无效,请填写 https:// 或 http:// 开头的完整地址。':
20
+ 'The Matrix homeserver URL is invalid. Enter a full URL starting with https:// or http://.',
21
+ 'Matrix 凭据不完整:请提供访问令牌,或用户 ID 与密码的组合。':
22
+ 'Incomplete Matrix credentials: provide an access token, or a user id together with a password.',
23
+ 'Matrix 用户 ID 无效,请使用 @user:server 形式。':
24
+ 'The Matrix user id is invalid. Use the @user:server form.',
25
+ 'Matrix 访问令牌无效或已失效,请在 homeserver 重新签发后重试。':
26
+ 'The Matrix access token is invalid or expired. Issue a new one on the homeserver and try again.',
27
+ 'Matrix homeserver 暂时无法访问,请确认网络与地址后重试。':
28
+ 'The Matrix homeserver is temporarily unreachable. Check the network and the URL, then retry.',
29
+ 'Matrix whoami 未返回用户身份,请改用用户 ID 与密码接入。':
30
+ 'The Matrix whoami call returned no user identity. Connect with a user id and password instead.',
31
+ 'Matrix 用户名或密码不正确,请核对后重试。':
32
+ 'The Matrix user id or password is incorrect. Verify it and try again.',
33
+ 'Matrix homeserver 暂不支持密码登录,请改用访问令牌接入。':
34
+ 'The Matrix homeserver does not support password login. Connect with an access token instead.',
35
+
36
+ 'Matrix 配置的 device_id 与服务端实际设备不一致,以服务端设备为准。':
37
+ 'The configured Matrix device_id differs from the actual server-side device; the server device wins.',
38
+ 'Matrix whoami 返回的用户 {verified} 与配置的用户 {configured} 不一致,以 whoami 结果为准。':
39
+ 'The user {verified} returned by Matrix whoami differs from the configured user {configured}; the whoami result wins.',
40
+ 'Matrix 配置的 device_id {configured} 与令牌绑定设备 {verified} 不一致,令牌仅能为其设备共享密钥,以令牌设备为准。':
41
+ 'The configured device_id {configured} differs from the device {verified} bound to the token. A token can share keys only for its own device; the token device wins.',
42
+
43
+ '端到端加密模式为 required,但未配置加密状态存储,已拒绝建立加密连接。':
44
+ 'End-to-end encryption mode is required, but no crypto state storage is configured, so the encrypted connection was refused.',
45
+ 'Matrix 端到端加密未配置状态存储,加密房间消息将明确降级跳过。':
46
+ 'Matrix end-to-end encryption has no crypto state storage configured; encrypted room messages will be visibly skipped.',
47
+ '端到端加密模式为 required,但加密引擎启动失败,已拒绝建立加密连接:{reason}':
48
+ 'End-to-end encryption mode is required, but the crypto engine failed to start, so the encrypted connection was refused: {reason}',
49
+ 'Matrix 端到端加密引擎启动失败,加密房间消息将明确降级跳过。':
50
+ 'The Matrix crypto engine failed to start; encrypted room messages will be visibly skipped.',
51
+ 'Matrix 端到端加密引擎已就绪,设备密钥与一次性密钥已注册。':
52
+ 'The Matrix crypto engine is ready; device keys and one-time keys are registered.',
53
+ '端到端加密未启用或不可用,加密房间 {room} 的密文会被明确降级跳过。':
54
+ 'End-to-end encryption is off or unavailable; ciphertext from the encrypted room {room} is visibly skipped.',
55
+ 'Matrix 加密状态绑定于设备 {stored},与当前令牌设备 {active} 不符;请先修复设备配置,切勿删除加密状态文件后静默重建设备。':
56
+ 'The Matrix crypto state is bound to device {stored}, which differs from the current token device {active}; fix the device configuration first. Do not silently rebuild the device by deleting the crypto state file.',
57
+ 'Matrix 设备加密身份不完整,无法建立端到端加密会话。':
58
+ 'The Matrix device encryption identity is incomplete; an end-to-end encryption session cannot be established.',
59
+ 'Matrix 加密引擎尚未就绪。': 'The Matrix crypto engine is not ready yet.',
60
+ 'Matrix 收到的时间戳持续远落后于本机时间,检测到本机时钟超前,请校准系统时间后重启机器人。':
61
+ 'Matrix event timestamps keep lagging far behind the local clock; the local clock is ahead. Calibrate the system time and restart the bot.',
62
+
63
+ 'Matrix 拒绝了来自未授权用户 {inviter} 的入房邀请 {room}。':
64
+ 'Matrix declined the room invite {room} from the unauthorized user {inviter}.',
65
+ 'Matrix 已按授权邀请加入房间 {room}。': 'Matrix joined room {room} after an authorized invite.',
66
+ 'Matrix 已婉拒失效房间的遗留邀请 {room}。': 'Matrix declined the stale invite for the dead room {room}.',
67
+ 'Matrix 无法为该用户创建私聊房间。': 'Matrix could not create a private chat room for this user.',
68
+
69
+ '结果文件内容为空或下载失败。': 'The result file is empty or failed to download.',
70
+ '结果文件超过 Matrix 媒体大小上限。': 'The result file exceeds the Matrix media size limit.',
71
+ 'Matrix 媒体上传失败。': 'The Matrix media upload failed.',
72
+ 'Matrix 文件消息发送失败。': 'The Matrix file message could not be sent.',
73
+ '结果文件「{name}」已生成,但 Matrix homeserver 拒绝了媒体上传,请检查其媒体大小限制与上传权限。':
74
+ 'The result file “{name}” was produced, but the Matrix homeserver rejected the media upload. Check its media size limit and upload permissions.',
75
+ };
@@ -18,6 +18,7 @@ import slack from './i18n-en/slack.mjs';
18
18
  import telegram from './i18n-en/telegram.mjs';
19
19
  import discord from './i18n-en/discord.mjs';
20
20
  import whatsapp from './i18n-en/whatsapp.mjs';
21
+ import matrix from './i18n-en/matrix.mjs';
21
22
  import office from './i18n-en/office.mjs';
22
23
  import email from './i18n-en/email.mjs';
23
24
 
@@ -38,6 +39,7 @@ export const EN = Object.freeze(Object.assign(
38
39
  telegram,
39
40
  discord,
40
41
  whatsapp,
42
+ matrix,
41
43
  office,
42
44
  email,
43
45
  ));
@@ -252,7 +252,7 @@ export function splitLeadingInjectedContext(text, options = {}) {
252
252
  }
253
253
 
254
254
  /**
255
- * Build the plugin-sourced context message for one parsed block.
255
+ * Build one context message with the producer-owned source kind required by V4.
256
256
  * @param block - one parsed block.
257
257
  * @param newId - identity factory for the new message.
258
258
  * @param plugin - source plugin name recorded on it.
@@ -260,8 +260,8 @@ export function splitLeadingInjectedContext(text, options = {}) {
260
260
  */
261
261
  function contextMessage(block, newId, plugin) {
262
262
  const source = block.form === 'notice' && typeof block.summary === 'string'
263
- ? { kind: 'plugin', plugin, form: 'notice', summary: block.summary }
264
- : { kind: 'plugin', plugin, form: block.form };
263
+ ? { kind: `plugin:${plugin}`, form: 'notice', summary: block.summary }
264
+ : { kind: `plugin:${plugin}`, form: block.form };
265
265
  return {
266
266
  id: newId(),
267
267
  role: 'user',
@@ -9,6 +9,7 @@ export const SESSION_CHANNEL_LABELS = Object.freeze(Object.fromEntries(Object.en
9
9
  discord: ['Discord', 'Discord'],
10
10
  whatsapp: ['WhatsApp', 'WhatsApp'],
11
11
  imessage: ['iMessage', 'iMessage'],
12
+ matrix: ['Matrix', 'Matrix'],
12
13
  office: ['AI Office', 'AI Office'],
13
14
  }).map(([channel, labels]) => [channel, Object.freeze(labels)])));
14
15
 
@@ -114,6 +114,9 @@ function artifactFailureText(fileName, error, descriptor) {
114
114
  if (descriptor?.key === 'telegram') {
115
115
  return t('结果文件「{name}」已生成,但 Telegram 不允许机器人在当前聊天发送文档,请检查聊天权限。', { name });
116
116
  }
117
+ if (descriptor?.key === 'matrix') {
118
+ return t('结果文件「{name}」已生成,但 Matrix homeserver 拒绝了媒体上传,请检查其媒体大小限制与上传权限。', { name });
119
+ }
117
120
  return t('结果文件「{name}」已生成,但当前机器人没有文件发送权限,请检查渠道权限。', { name });
118
121
  case 'artifact-too-large':
119
122
  return t('结果文件「{name}」超过当前渠道大小上限,未发送。', { name });