@xmanrui/dsh-im 5.4.0 → 5.6.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 +15 -0
- package/PROACTIVE_DELIVERY.md +15 -0
- package/README.en.md +46 -5
- package/README.md +46 -5
- package/lib/client.js +2579 -664
- package/lib/index.js +406 -339
- package/package.json +4 -4
- package/plugin-src/client/channel-card-meta.js +6 -2
- package/plugin-src/client/channels/dingtalk/index.js +12 -9
- package/plugin-src/client/channels/feishu/group-settings.js +5 -5
- package/plugin-src/client/channels/feishu/index.js +33 -25
- package/plugin-src/client/channels/qq/index.js +5 -5
- package/plugin-src/client/channels/shared/token-api.js +25 -7
- package/plugin-src/client/channels/shared/token-channel.js +18 -11
- package/plugin-src/client/channels/telegram/styles.js +4 -0
- package/plugin-src/client/channels/telegram/thinking-traces.js +138 -5
- package/plugin-src/client/channels/wecom/index.js +5 -5
- package/plugin-src/client/channels/wecom-app/index.js +3 -3
- package/plugin-src/client/channels/weixin/index.js +2 -2
- package/plugin-src/client/channels/whatsapp/index.js +6 -6
- package/plugin-src/client/credential-binding.js +3 -2
- package/plugin-src/client/delivery-settings.js +4 -4
- package/plugin-src/client/ds-bot-settings.js +3 -3
- package/plugin-src/client/global-settings.js +5 -2
- package/plugin-src/client/i18n-ru.js +1637 -0
- package/plugin-src/client/i18n.js +281 -124
- package/plugin-src/client/index.js +8 -1
- package/plugin-src/host/channels/shared/production.mjs +5 -0
- package/plugin-src/host/channels/shared/rpc.mjs +21 -0
- package/plugin-src/host/channels/shared/send-limit-rpc.mjs +13 -0
- package/plugin-src/host/channels/shared/thinking-cadence-rpc.mjs +16 -0
- package/plugin-src/host/channels/telegram/production.mjs +7 -0
- package/plugin-src/host/delivery-adapter.mjs +41 -33
- package/plugin-src/host/delivery-service.mjs +42 -0
- package/plugin-src/host/ds-bot-client.mjs +31 -18
- package/plugin-src/host/ds-bot-question-sync.mjs +78 -0
- package/plugin-src/host/index.mjs +3 -0
- package/plugin-src/host/modern-harness-api.mjs +53 -8
- package/plugin-src/host/session-sync-coordinator.mjs +5 -5
- package/scripts/verify-package.mjs +18 -6
- package/src/channels/dingtalk/dingtalk-bridge.mjs +1 -0
- package/src/channels/feishu/bridge.mjs +107 -7
- package/src/channels/feishu/feishu-cards.mjs +1 -45
- package/src/channels/feishu/feishu-runtime.mjs +10 -0
- package/src/channels/feishu/multi-bot-controller.mjs +12 -0
- package/src/channels/feishu/slash-command-panel.mjs +2 -5
- package/src/channels/qq/qq-bridge.mjs +1 -0
- package/src/channels/shared/AGENTS.md +19 -0
- package/src/channels/shared/bot-workspace-store.mjs +1 -1
- package/src/channels/shared/clear-command.mjs +2 -1
- package/src/channels/shared/command-catalog.mjs +8 -5
- package/src/channels/shared/compact-command.mjs +2 -1
- package/src/channels/shared/conversation-queue.mjs +49 -0
- package/src/channels/shared/deferred-delivery-coordinator.mjs +2 -1
- package/src/channels/shared/delivery-failure-log.mjs +111 -0
- package/src/channels/shared/diagnostic-details.mjs +1 -0
- package/src/channels/shared/harness-client.mjs +16 -9
- package/src/channels/shared/history-command.mjs +2 -1
- package/src/channels/shared/i18n-en/shared-a.mjs +2 -2
- package/src/channels/shared/i18n-en/shared-b.mjs +7 -2
- package/src/channels/shared/i18n-en/shared-c.mjs +6 -2
- package/src/channels/shared/i18n-en/telegram.mjs +6 -0
- package/src/channels/shared/i18n-ru/diagnostics.mjs +104 -0
- package/src/channels/shared/i18n-ru/dingtalk.mjs +96 -0
- package/src/channels/shared/i18n-ru/discord.mjs +10 -0
- package/src/channels/shared/i18n-ru/email.mjs +23 -0
- package/src/channels/shared/i18n-ru/feishu.mjs +374 -0
- package/src/channels/shared/i18n-ru/image-input.mjs +25 -0
- package/src/channels/shared/i18n-ru/matrix.mjs +73 -0
- package/src/channels/shared/i18n-ru/office.mjs +27 -0
- package/src/channels/shared/i18n-ru/permission.mjs +45 -0
- package/src/channels/shared/i18n-ru/qq.mjs +88 -0
- package/src/channels/shared/i18n-ru/shared-a.mjs +236 -0
- package/src/channels/shared/i18n-ru/shared-b.mjs +262 -0
- package/src/channels/shared/i18n-ru/shared-c.mjs +176 -0
- package/src/channels/shared/i18n-ru/slack.mjs +22 -0
- package/src/channels/shared/i18n-ru/telegram.mjs +30 -0
- package/src/channels/shared/i18n-ru/wecom-app.mjs +43 -0
- package/src/channels/shared/i18n-ru/wecom.mjs +79 -0
- package/src/channels/shared/i18n-ru/weixin.mjs +275 -0
- package/src/channels/shared/i18n-ru/whatsapp.mjs +18 -0
- package/src/channels/shared/i18n-ru.mjs +48 -0
- package/src/channels/shared/i18n.mjs +47 -12
- package/src/channels/shared/inbound-access.mjs +1 -1
- package/src/channels/shared/interface-language.mjs +3 -3
- package/src/channels/shared/message-failure.mjs +8 -4
- package/src/channels/shared/model-command.mjs +2 -1
- package/src/channels/shared/permission-command.mjs +2 -1
- package/src/channels/shared/send-limit.mjs +38 -0
- package/src/channels/shared/session-error.mjs +11 -0
- package/src/channels/shared/status-reaction.mjs +2 -0
- package/src/channels/shared/text-harness-bridge.mjs +205 -3
- package/src/channels/shared/thinking-cadence.mjs +36 -0
- package/src/channels/shared/workspace-command.mjs +43 -17
- package/src/channels/shared/workspace-labels.mjs +65 -0
- package/src/channels/shared/workspace-session.mjs +24 -4
- package/src/channels/telegram/config-store.mjs +34 -1
- package/src/channels/telegram/telegram-api.mjs +240 -32
- package/src/channels/telegram/telegram-bridge.mjs +62 -1
- package/src/channels/telegram/telegram-controller.mjs +29 -0
- package/src/channels/telegram/telegram-runtime.mjs +592 -179
- package/src/channels/telegram/voice.mjs +250 -0
- package/src/channels/wecom/wecom-bridge.mjs +1 -0
- package/src/channels/wecom-app/wecom-app-bridge.mjs +1 -0
- package/src/channels/weixin/weixin-bridge.mjs +1 -0
|
@@ -1,18 +1,74 @@
|
|
|
1
1
|
import imageInput from '../../src/channels/shared/i18n-en/image-input.mjs';
|
|
2
2
|
import diagnostics from '../../src/channels/shared/i18n-en/diagnostics.mjs';
|
|
3
3
|
import weixinDiagnostics from '../../src/channels/weixin/connection-error.en.mjs';
|
|
4
|
+
import { RU } from './i18n-ru.js';
|
|
4
5
|
import * as React from 'react';
|
|
5
6
|
|
|
6
7
|
export const IM_LOCALE_NAMESPACE = 'dsh-im';
|
|
7
8
|
|
|
9
|
+
// Sentences the settings UI composes itself: the dictionaries carry them as
|
|
10
|
+
// templates with `{name}` placeholders, looked up like any other key and filled in
|
|
11
|
+
// after translation (see localizeTemplate), so word order belongs to the target
|
|
12
|
+
// language instead of the Chinese sentence it was assembled from.
|
|
13
|
+
const COMPOSED = Object.freeze({
|
|
14
|
+
'使用 Bot Token 接入 {channel} 机器人': 'Connect a {channel} bot with a Bot Token',
|
|
15
|
+
'已接入的 {channel} 机器人': 'Connected {channel} bots',
|
|
16
|
+
'正在读取 {channel} 机器人状态…': 'Loading {channel} bot status…',
|
|
17
|
+
'无法读取 {channel} 机器人状态': 'Could not load {channel} bot status',
|
|
18
|
+
'尚未接入 {channel} 机器人': 'No {channel} bot connected yet',
|
|
19
|
+
'手动接入{channel}机器人': 'Connect {channel} bot manually',
|
|
20
|
+
'{channel} 设置': '{channel} settings',
|
|
21
|
+
'{name}机器人设置': '{name} bot settings',
|
|
22
|
+
'{channel}机器人': '{channel} bot',
|
|
23
|
+
'{channel} 服务返回了无法识别的响应': '{channel} service returned an unrecognized response',
|
|
24
|
+
'{channel} 操作失败': '{channel} operation failed',
|
|
25
|
+
'{channel}连接尚未就绪': '{channel} connection is not ready',
|
|
26
|
+
'{channel} 服务没有返回有效的机器人列表': '{channel} service did not return a valid bot list',
|
|
27
|
+
'{channel}操作失败,请稍后重试': '{channel} operation failed; try again later',
|
|
28
|
+
'{channel} 设置页缺少 RPC 连接': 'The {channel} settings are missing an RPC connection',
|
|
29
|
+
'{subject}运行正常': '{subject} is healthy',
|
|
30
|
+
'{connected} / {configured} 在线': '{connected}/{configured} online',
|
|
31
|
+
'已接入 {configured} 个机器人,其中 {connected} 个在线': '{connected} of {configured} bots online',
|
|
32
|
+
'从 DeepSeek Harness 移除“{name}”?': 'Remove “{name}” from DeepSeek Harness?',
|
|
33
|
+
'从 DeepSeek Harness 移除{name}': 'Remove {name} from DeepSeek Harness',
|
|
34
|
+
'移除{name}': 'Remove {name}',
|
|
35
|
+
'{bot}操作失败,请查看机器人状态。': '{bot} operation failed. Check the bot status.',
|
|
36
|
+
'这会停止消息连接,并删除本机保存的 {credentials}、机器人配置及会话映射。{platform}中的机器人不会被自动删除。': 'This stops the message connection and removes the locally stored {credentials}, bot configuration, and session mappings. The bot in {platform} is not deleted.',
|
|
37
|
+
'{bot}的飞书授权流程': 'Feishu authorization flow for {bot}',
|
|
38
|
+
'用于为{bot}补全权限与回调的一次性授权二维码': 'One-time QR code for completing permissions and the callback for {bot}',
|
|
39
|
+
'用于为{bot}开通群消息权限的一次性授权二维码': 'One-time QR code for granting group-message permission to {bot}',
|
|
40
|
+
'正在为「{bot}」补全权限与回调': 'Completing permissions and the callback for “{bot}”',
|
|
41
|
+
'正在为「{bot}」开通群消息权限': 'Granting group-message permission to “{bot}”',
|
|
42
|
+
'为{bot}补全权限与回调': 'Complete permissions and the callback for {bot}',
|
|
43
|
+
'{bot}的权限与回调已补全。': 'Permissions and the callback completed for {bot}.',
|
|
44
|
+
'{bot}的权限补全二维码已生成,请使用飞书扫码。': 'Permission-completion QR code generated for {bot}. Scan it with Feishu.',
|
|
45
|
+
'{bot}的群消息权限二维码已生成,请使用飞书确认。': 'Group-message permission QR code generated for {bot}. Confirm it with Feishu.',
|
|
46
|
+
'{bot}已开通群消息权限,并启用“响应所有群消息”。': '{bot} now has group-message permission and “Respond to all group messages” is enabled.',
|
|
47
|
+
'{bot}已连接,可以在飞书中开始聊天。': '{bot} is connected and ready to chat in Feishu.',
|
|
48
|
+
'{bot}连接检查完成。': '{bot} connection check completed.',
|
|
49
|
+
'{bot}已重新连接。': '{bot} reconnected.',
|
|
50
|
+
'{bot}已从此 DeepSeek Harness 移除;飞书开放平台中的应用未被删除。': '{bot} was removed from this DeepSeek Harness. The app in Feishu Open Platform was not deleted.',
|
|
51
|
+
'{bot}移除失败,请重试。': '{bot} could not be removed; try again.',
|
|
52
|
+
'检查连接{name}': 'Check connection {name}',
|
|
53
|
+
'重试连接{name}': 'Reconnect {name}',
|
|
54
|
+
'二维码剩余 {remaining}': 'QR code expires in {remaining}',
|
|
55
|
+
'连接检查失败:{error}(参考号:{reference})': 'Connection check failed: {error} (reference: {reference})',
|
|
56
|
+
'连接检查失败:{error}': 'Connection check failed: {error}',
|
|
57
|
+
'操作失败:{error}': 'Operation failed: {error}',
|
|
58
|
+
'状态刷新失败:{error}': 'Status refresh failed: {error}',
|
|
59
|
+
'状态自动刷新失败:{error}': 'Automatic status refresh failed: {error}',
|
|
60
|
+
'请输入 -1、0 或 1~{max} 之间的整数。': 'Enter -1, 0, or an integer from 1 to {max}.',
|
|
61
|
+
});
|
|
62
|
+
|
|
8
63
|
const EN = Object.freeze({
|
|
64
|
+
...COMPOSED,
|
|
9
65
|
"私聊对象": "Private chat",
|
|
10
66
|
"选择私聊对象": "Select a private chat",
|
|
11
67
|
"仅支持已经建立会话的私聊,请先与机器人私聊后刷新。": "Only established private chats are supported. Message the bot privately, then refresh.",
|
|
12
68
|
"选择 DS Bot 和私聊对象,直接使用 Bot 的会话。": "Choose a DS Bot and a private chat to use the Bot’s session.",
|
|
13
69
|
"还没有可绑定的私聊。先给这个机器人发一条私聊消息,再点击刷新。": "No private chats yet. Send this bot a private message, then refresh.",
|
|
14
70
|
|
|
15
|
-
"绑定
|
|
71
|
+
"绑定 DS Bot": "Bind DS Bot",
|
|
16
72
|
"正在检测 DS Bot…": "Checking DS Bot…",
|
|
17
73
|
"选择 DS Bot": "Select DS Bot",
|
|
18
74
|
"暂无可选 DS Bot": "No available DS Bots",
|
|
@@ -25,7 +81,7 @@ const EN = Object.freeze({
|
|
|
25
81
|
"DS Bot 尚未启用,请在 DSH 插件管理中启用后刷新。": "DS Bot is disabled. Enable it in DSH plugin management, then refresh.",
|
|
26
82
|
"暂时无法读取 DS Bot,请检查插件是否正常运行后重试。": "Unable to read DS Bot. Check that the plugin is running, then retry.",
|
|
27
83
|
"DS Bot 当前由其他 Host 管理,请在运行它的 Host 中绑定。": "DS Bot is managed by another Host. Bind it on that Host.",
|
|
28
|
-
"绑定
|
|
84
|
+
"绑定 DS Bot 仅支持当前 Host 的会话,请先检查机器人的 Harness 连接设置。": "DS Bot binding requires the current Host. Check the bot’s Harness connection settings.",
|
|
29
85
|
"所选 DS Bot 已不存在,请刷新后重新选择。": "The selected DS Bot no longer exists. Refresh and select another.",
|
|
30
86
|
"绑定设置保存失败,请刷新后重试。": "Could not save the binding. Refresh and retry.",
|
|
31
87
|
"绑定已保存。": "Binding saved.",
|
|
@@ -687,13 +743,6 @@ const EN = Object.freeze({
|
|
|
687
743
|
'飞书服务返回的应用更新信息缺少 botId': 'Feishu app-update status is missing the bot ID',
|
|
688
744
|
'飞书服务返回了不匹配的注册进度': 'Feishu returned registration progress for a different operation',
|
|
689
745
|
'此机器人': 'this bot',
|
|
690
|
-
'用于为${botName}开通群消息权限的一次性授权二维码': 'One-time QR code for granting group-message permission to ${botName}',
|
|
691
|
-
'正在为「${botName}」开通群消息权限': 'Granting group-message permission to “${botName}”',
|
|
692
|
-
'${botName ?? "机器人"}的权限补全二维码已生成,请使用飞书扫码。': 'Permission-completion QR code generated for ${botName ?? "bot"}. Scan it with Feishu.',
|
|
693
|
-
'${botName ?? "机器人"}的群消息权限二维码已生成,请使用飞书确认。': 'Group-message permission QR code generated for ${botName ?? "bot"}. Confirm it with Feishu.',
|
|
694
|
-
'${targetBotName}已开通群消息权限,并启用“响应所有群消息”。': '${targetBotName} now has group-message permission and “Respond to all group messages” is enabled.',
|
|
695
|
-
'${targetBot.bot.name}已开通群消息权限,并启用“响应所有群消息”。': '${targetBot.bot.name} now has group-message permission and “Respond to all group messages” is enabled.',
|
|
696
|
-
'${targetBot.bot.name}已连接,可以在飞书中开始聊天。': '${targetBot.bot.name} is connected and ready to chat in Feishu.',
|
|
697
746
|
'已取消补全权限与回调。': 'Completing permissions and the callback was cancelled.',
|
|
698
747
|
'已取消群消息权限授权。': 'Group-message permission authorization was cancelled.',
|
|
699
748
|
'权限与回调已更新,但暂时无法确认机器人连接状态': 'Permissions and the callback were updated, but the bot connection could not be confirmed yet',
|
|
@@ -838,6 +887,15 @@ const EN = Object.freeze({
|
|
|
838
887
|
'思考过程留痕': 'Thinking traces',
|
|
839
888
|
'实时显示思考步骤与工具调用,最终答案单独成条': 'Show thinking steps and tool calls as they happen; the final answer arrives as its own message',
|
|
840
889
|
'请提交有效的思考过程留痕设置。': 'Submit a valid thinking-traces setting.',
|
|
890
|
+
'编号思考帧': 'Number trace frames',
|
|
891
|
+
'在每帧前加上本轮序号;被节奏跳过的帧也计数,所以编号会跳号(需先打开思考过程留痕)': 'Prefix each frame with its number in the turn; paced-away frames still count, so numbers jump. Requires thinking traces.',
|
|
892
|
+
'最多每隔多久发送一帧(秒)': 'Send at most one frame every (seconds)',
|
|
893
|
+
'突发时只发送窗口里最新的一帧,过期的帧丢弃,不排队也不重发': 'A burst sends only its latest frame; stale frames are dropped, not queued or resent',
|
|
894
|
+
'不限制(0)': 'No limit (0)',
|
|
895
|
+
'请提交有效的思考帧节奏设置。': 'Submit a valid trace cadence setting.',
|
|
896
|
+
'消息发送上限': 'Message limit',
|
|
897
|
+
'每个聊天每分钟的消息数;机器人会等待而不是丢弃': 'Per chat, messages per minute; the bot waits instead of dropping',
|
|
898
|
+
'请提交有效的消息发送上限。': 'Submit a valid message limit.',
|
|
841
899
|
'正在使用{name}…': 'Using {name}…',
|
|
842
900
|
'访问模式': 'Access mode',
|
|
843
901
|
'Telegram 访问模式': 'Telegram access mode',
|
|
@@ -933,7 +991,6 @@ const EN = Object.freeze({
|
|
|
933
991
|
'钉钉扫码服务没有返回有效的绑定任务': 'DingTalk did not return a valid setup attempt',
|
|
934
992
|
'钉钉 Stream 长连接运行正常': 'DingTalk Stream connection is healthy',
|
|
935
993
|
'钉钉服务没有返回有效的机器人列表': 'DingTalk did not return a valid bot list',
|
|
936
|
-
'${totals.connected} / ${totals.configured} 在线': '${totals.connected} / ${totals.configured} online',
|
|
937
994
|
'用于把钉钉机器人接入 DeepSeek Harness 的一次性二维码': 'One-time QR code for connecting a DingTalk bot to DeepSeek Harness',
|
|
938
995
|
'二维码已过期\\n请重新生成': 'QR code expired\\nGenerate a new one',
|
|
939
996
|
'机器人已创建,正在建立消息连接': 'Bot created. Starting the message connection',
|
|
@@ -949,18 +1006,13 @@ const EN = Object.freeze({
|
|
|
949
1006
|
'飞书服务没有返回连接状态': 'Feishu did not return connection status',
|
|
950
1007
|
'飞书服务没有返回创建进度': 'Feishu did not return creation progress',
|
|
951
1008
|
'飞书服务返回了未知的创建状态': 'Feishu returned an unknown creation status',
|
|
952
|
-
'已接入 ${totals.configured} 个机器人,其中 ${totals.connected} 个在线': '${totals.connected} of ${totals.configured} bots online',
|
|
953
1009
|
'尚未接入机器人': 'No bot connected yet',
|
|
954
1010
|
'用于新增 DeepSeek Harness 飞书机器人的一次性授权二维码': 'One-time authorization QR code for adding a Feishu bot to DeepSeek Harness',
|
|
955
1011
|
'请刷新后重新扫码': 'Refresh and scan again',
|
|
956
|
-
'${connected ? "检查连接" : "重试连接"}${bot.name}': '${connected ? "Check connection" : "Reconnect"} ${bot.name}',
|
|
957
1012
|
'无法读取飞书机器人': 'Could not load Feishu bots',
|
|
958
1013
|
'授权二维码已生成,请使用飞书扫码。': 'Authorization QR code generated. Scan it with Feishu.',
|
|
959
1014
|
'飞书机器人凭据已绑定。': 'Feishu bot credentials connected.',
|
|
960
1015
|
'已取消添加机器人。': 'Adding the bot was cancelled.',
|
|
961
|
-
'${newBot.bot.name}已连接,可以在飞书中开始聊天。': '${newBot.bot.name} is connected and ready to chat in Feishu.',
|
|
962
|
-
'${bot.name}操作失败,请查看机器人状态。': '${bot.name} operation failed. Check the bot status.',
|
|
963
|
-
'${bot.name}已从此 DeepSeek Harness 移除;飞书开放平台中的应用未被删除。': '${bot.name} was removed from this DeepSeek Harness. The app in Feishu Open Platform was not deleted.',
|
|
964
1016
|
'无法读取连接状态': 'Could not load connection status',
|
|
965
1017
|
'QQ 服务没有返回扫码绑定进度': 'QQ did not return QR setup progress',
|
|
966
1018
|
'QQ 扫码服务没有返回有效的绑定任务': 'QQ did not return a valid setup attempt',
|
|
@@ -971,10 +1023,6 @@ const EN = Object.freeze({
|
|
|
971
1023
|
'QQ 服务没有返回有效的机器人列表': 'QQ did not return a valid bot list',
|
|
972
1024
|
'尚未绑定 QQ 机器人': 'No QQ bot connected yet',
|
|
973
1025
|
'用于绑定 QQ 机器人的一次性二维码': 'One-time QR code for connecting a QQ bot',
|
|
974
|
-
'${channel}${connectionSummary}运行正常': '${channel}${connectionSummary} is healthy',
|
|
975
|
-
'${channel} 服务没有返回有效的机器人列表': '${channel} did not return a valid bot list',
|
|
976
|
-
'使用 Bot Token 接入 ${channel} 机器人': 'Connect a ${channel} bot with a Bot Token',
|
|
977
|
-
'${model.totals.connected} / ${model.totals.configured} 在线': '${model.totals.connected}/${model.totals.configured} online',
|
|
978
1026
|
' Bot API 长轮询': ' Bot API long polling',
|
|
979
1027
|
'企业微信服务没有返回扫码绑定进度': 'WeCom did not return QR setup progress',
|
|
980
1028
|
'企业微信扫码服务没有返回有效的绑定任务': 'WeCom did not return a valid setup attempt',
|
|
@@ -1005,7 +1053,6 @@ const EN = Object.freeze({
|
|
|
1005
1053
|
'用于把微信机器人绑定到 DeepSeek Harness 的一次性二维码': 'One-time QR code for connecting a WeChat bot to DeepSeek Harness',
|
|
1006
1054
|
'保持本页打开,等待消息长轮询变为在线': 'Keep this page open until long polling is online',
|
|
1007
1055
|
'微信二维码已生成,请使用手机微信扫描。': 'WeChat QR code generated. Scan it with WeChat on your phone.',
|
|
1008
|
-
'移除失败:${presentError(error).message}': 'Removal failed: ${presentError(error).message}',
|
|
1009
1056
|
'无法读取微信状态': 'Could not load WeChat status',
|
|
1010
1057
|
'WhatsApp 服务没有返回扫码进度': 'WhatsApp did not return QR setup progress',
|
|
1011
1058
|
'WhatsApp 服务没有返回有效的扫码任务': 'WhatsApp did not return a valid setup attempt',
|
|
@@ -1129,7 +1176,6 @@ const EN = Object.freeze({
|
|
|
1129
1176
|
'永久保留,不会自动清理': 'Keep forever; nothing is removed automatically',
|
|
1130
1177
|
'每 Turn 结束后立即清理': 'Cleaned up as soon as each turn ends',
|
|
1131
1178
|
'小时后自动清理': 'hours until automatic cleanup',
|
|
1132
|
-
'请输入 -1、0 或 1~${INBOUND_TTL_MAX_HOURS} 之间的整数。': 'Enter -1, 0, or an integer from 1 to ${INBOUND_TTL_MAX_HOURS}.',
|
|
1133
1179
|
'设置保存失败,请稍后重试。': 'Could not save the setting. Try again later.',
|
|
1134
1180
|
'已保存': 'Saved',
|
|
1135
1181
|
'通用设置暂不可用。': 'General settings are unavailable.',
|
|
@@ -1259,131 +1305,242 @@ export const zh = Object.freeze(Object.fromEntries(
|
|
|
1259
1305
|
Object.keys(EN).map((key) => [key, key === '$locale' ? 'zh' : key]),
|
|
1260
1306
|
));
|
|
1261
1307
|
|
|
1308
|
+
// Russian, narrowed to the keys this UI asks for: the shared Host modules it is
|
|
1309
|
+
// built from also carry strings no settings surface renders, and a namespace
|
|
1310
|
+
// dictionary holding keys the English one does not know would let a mistyped
|
|
1311
|
+
// Chinese key hide behind a lookup that happens to miss. The English text is the
|
|
1312
|
+
// last resort for a key the narrowed dictionary somehow lost.
|
|
1313
|
+
export const ru = Object.freeze(Object.fromEntries(
|
|
1314
|
+
Object.keys(EN).map((key) => [key, RU[key] ?? EN[key]]),
|
|
1315
|
+
));
|
|
1316
|
+
|
|
1262
1317
|
let translate = (key) => key;
|
|
1263
1318
|
|
|
1264
1319
|
export function setImTranslator(next) {
|
|
1265
1320
|
translate = typeof next === 'function' ? next : (key) => key;
|
|
1266
1321
|
}
|
|
1267
1322
|
|
|
1323
|
+
// The language these dictionaries are rendering in. Read through the `$locale`
|
|
1324
|
+
// entry rather than a snapshot taken at load time, so a locale whose dictionary
|
|
1325
|
+
// registers later is still reported correctly. Anything unrecognized means
|
|
1326
|
+
// Chinese, the identity language.
|
|
1327
|
+
export function imLocale() {
|
|
1328
|
+
const id = translate('$locale');
|
|
1329
|
+
return id === 'en' || id === 'ru' ? id : 'zh';
|
|
1330
|
+
}
|
|
1331
|
+
|
|
1268
1332
|
export function isEnglish() {
|
|
1269
1333
|
return translate('$locale') === 'en';
|
|
1270
1334
|
}
|
|
1271
1335
|
|
|
1272
|
-
|
|
1336
|
+
export const IM_RUSSIAN_LANGUAGE = Object.freeze({ id: 'ru', label: 'Русский', fallback: 'en' });
|
|
1337
|
+
|
|
1338
|
+
/**
|
|
1339
|
+
* Register Russian with the DSH locale registry: the definition makes it
|
|
1340
|
+
* selectable and chains its lookups to English, and the dictionary goes in as
|
|
1341
|
+
* one single-locale entry because `ru` is a language pack rather than one of the
|
|
1342
|
+
* two built-in locales.
|
|
1343
|
+
*
|
|
1344
|
+
* The definition is skipped when the id is already occupied — another language
|
|
1345
|
+
* pack may have registered `ru` first, and an occupied id is a hard error there.
|
|
1346
|
+
* The dictionary is registered either way, so Russian strings still resolve.
|
|
1347
|
+
*
|
|
1348
|
+
* @param locale - the client `locale` service.
|
|
1349
|
+
* @returns an idempotent disposer for both registrations.
|
|
1350
|
+
*/
|
|
1351
|
+
export function installImRussianLocale(locale) {
|
|
1352
|
+
if (typeof locale?.register !== 'function') return () => {};
|
|
1353
|
+
const disposers = [];
|
|
1354
|
+
const defined = (locale.getLocale?.()?.locales ?? []).some(
|
|
1355
|
+
(entry) => entry?.id === IM_RUSSIAN_LANGUAGE.id,
|
|
1356
|
+
);
|
|
1357
|
+
if (!defined && typeof locale.addLanguage === 'function') {
|
|
1358
|
+
try {
|
|
1359
|
+
disposers.push(locale.addLanguage(IM_RUSSIAN_LANGUAGE));
|
|
1360
|
+
} catch (error) {
|
|
1361
|
+
// The id may have been taken between the check and this call; that pack
|
|
1362
|
+
// owns the definition now, and registering the dictionary is still safe.
|
|
1363
|
+
if (!/already registered/iu.test(String(error?.message ?? ''))) throw error;
|
|
1364
|
+
}
|
|
1365
|
+
}
|
|
1366
|
+
disposers.push(locale.register(IM_LOCALE_NAMESPACE, IM_RUSSIAN_LANGUAGE.id, ru));
|
|
1367
|
+
return () => {
|
|
1368
|
+
// Reverse order: the dictionary goes before the definition that chains to it.
|
|
1369
|
+
for (const dispose of disposers.reverse()) {
|
|
1370
|
+
try {
|
|
1371
|
+
dispose?.();
|
|
1372
|
+
} catch {
|
|
1373
|
+
// A registry that already dropped the entry must not block teardown.
|
|
1374
|
+
}
|
|
1375
|
+
}
|
|
1376
|
+
};
|
|
1377
|
+
}
|
|
1378
|
+
|
|
1379
|
+
/**
|
|
1380
|
+
* Localise a channel name the way the settings UI writes it: "微信" becomes
|
|
1381
|
+
* "WeChat" in English and Russian alike, while a name that is already Latin
|
|
1382
|
+
* ("Telegram") is handed back unchanged.
|
|
1383
|
+
*/
|
|
1384
|
+
export function channelName(value) {
|
|
1273
1385
|
return localizeText(value);
|
|
1274
1386
|
}
|
|
1275
1387
|
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
configHint[3] ? localizeText(configHint[3]) : '',
|
|
1388
|
+
// A broken WeChat configuration: the prefix, a `{file}` template sentence and an
|
|
1389
|
+
// optional counter sentence, each resolved in the active language.
|
|
1390
|
+
function configHint(match) {
|
|
1391
|
+
return [
|
|
1392
|
+
localizeText(match[1].trim()),
|
|
1393
|
+
translate('请检查微信渠道数据目录中的 {file},修复后重启 DSH;“重新读取”不会重新加载配置。').replace('{file}', match[2]),
|
|
1394
|
+
match[3] ? localizeText(match[3]) : '',
|
|
1284
1395
|
].filter(Boolean).join(' ');
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1396
|
+
}
|
|
1397
|
+
|
|
1398
|
+
// Sentences composed outside the settings UI — a bot status or an RPC error that the
|
|
1399
|
+
// host, or an IM platform, has already assembled — arrive as one string with no key
|
|
1400
|
+
// to look up, so they are recognised by the Chinese shape they are built from. The
|
|
1401
|
+
// client's own sentences are not here: they are template keys in the dictionaries
|
|
1402
|
+
// (see COMPOSED and localizeTemplate), which keeps this table to the text that really
|
|
1403
|
+
// has no key. Every rule carries a rendering per locale; `en` and `ru` are both
|
|
1404
|
+
// mandatory, because a rule with an English column only is exactly what left a
|
|
1405
|
+
// Russian reader looking at Chinese. Chinese needs no column of its own.
|
|
1406
|
+
const DYNAMIC_RULES = Object.freeze([
|
|
1407
|
+
{
|
|
1408
|
+
pattern: /^微信配置格式错误:(config\.json|workspaces\.json)。请查看诊断详情,修复后重启 DSH。$/,
|
|
1409
|
+
// Both dictionaries already hold this sentence as a `{file}` template, so the
|
|
1410
|
+
// rendering goes through the lookup rather than restating the text here.
|
|
1411
|
+
en: (match) => EN['微信配置格式错误:{file}。请查看诊断详情,修复后重启 DSH。'].replace('{file}', match[1]),
|
|
1412
|
+
ru: (match) => translate('微信配置格式错误:{file}。请查看诊断详情,修复后重启 DSH。').replace('{file}', match[1]),
|
|
1413
|
+
},
|
|
1414
|
+
{
|
|
1415
|
+
pattern: /^(.*?)请检查微信渠道数据目录中的 (config\.json|workspaces\.json),修复后重启 DSH;“重新读取”不会重新加载配置。\s*(字段位置中的序号从 0 开始,按文件中的条目顺序计数,不包含真实账号标识。)?$/,
|
|
1416
|
+
en: (match) => configHint(match),
|
|
1417
|
+
ru: (match) => configHint(match),
|
|
1418
|
+
},
|
|
1419
|
+
{
|
|
1420
|
+
pattern: /^增强提示词不得超过 (\d+) 个字符。$/,
|
|
1421
|
+
en: (match) => `Guidance must not exceed ${match[1]} characters.`,
|
|
1422
|
+
ru: (match) => `Подсказка для контекста не должна превышать ${match[1]} символов.`,
|
|
1423
|
+
},
|
|
1424
|
+
{
|
|
1425
|
+
pattern: /^一次最多只能处理 (\d+) 张图片。$/,
|
|
1426
|
+
en: (match) => `A message can contain at most ${match[1]} images.`,
|
|
1427
|
+
ru: (match) => `В одном сообщении может быть не больше ${match[1]} изображений.`,
|
|
1428
|
+
},
|
|
1429
|
+
{
|
|
1430
|
+
pattern: /^图片下载失败(HTTP (.+)),请重新发送后再试。$/,
|
|
1431
|
+
en: (match) => `The image download failed (HTTP ${match[1]}). Send it again.`,
|
|
1432
|
+
ru: (match) => `Не удалось скачать изображение (HTTP ${match[1]}). Отправьте его заново.`,
|
|
1433
|
+
},
|
|
1434
|
+
]);
|
|
1435
|
+
|
|
1436
|
+
// Chinese fragments that survive inside messages no rule above recognises. Each row
|
|
1437
|
+
// carries the source fragment and its rendering per locale, so the last-resort path
|
|
1438
|
+
// is a table too rather than an English-only swap list.
|
|
1439
|
+
const DYNAMIC_PHRASES = Object.freeze([
|
|
1440
|
+
['企业微信', 'WeCom', 'WeCom'],
|
|
1441
|
+
['DeepSeek Harness', 'DeepSeek Harness', 'DeepSeek Harness'],
|
|
1442
|
+
['WhatsApp', 'WhatsApp', 'WhatsApp'],
|
|
1443
|
+
['iMessage', 'iMessage', 'iMessage'],
|
|
1444
|
+
['macOS Messages', 'macOS Messages', 'macOS Messages'],
|
|
1445
|
+
['Telegram', 'Telegram', 'Telegram'],
|
|
1446
|
+
['Discord', 'Discord', 'Discord'],
|
|
1447
|
+
['Slack', 'Slack', 'Slack'],
|
|
1448
|
+
['飞书', 'Feishu', 'Feishu'],
|
|
1449
|
+
['钉钉', 'DingTalk', 'DingTalk'],
|
|
1450
|
+
['微信', 'WeChat', 'WeChat'],
|
|
1451
|
+
['机器人', 'bot', 'бот'],
|
|
1452
|
+
['账号', 'account', 'аккаунт'],
|
|
1453
|
+
['应用', 'app', 'приложение'],
|
|
1454
|
+
['凭据', 'credentials', 'учётные данные'],
|
|
1455
|
+
['服务返回了无法识别的响应', 'service returned an unrecognized response', 'сервис вернул нераспознанный ответ'],
|
|
1456
|
+
['服务没有返回有效的机器人列表', 'service did not return a valid bot list', 'сервис не вернул список ботов'],
|
|
1457
|
+
['操作失败,请稍后重试', 'operation failed; try again later', 'операция не удалась, попробуйте позже'],
|
|
1458
|
+
['操作失败', 'operation failed', 'операция не удалась'],
|
|
1459
|
+
['连接尚未就绪', 'connection is not ready', 'подключение ещё не готово'],
|
|
1460
|
+
['没有接入完成', 'was not connected', 'подключить не удалось'],
|
|
1461
|
+
['没有绑定完成', 'was not connected', 'подключить не удалось'],
|
|
1462
|
+
['设置页缺少 RPC 连接', 'settings are missing an RPC connection', 'в настройках нет подключения RPC'],
|
|
1463
|
+
['设置', 'settings', 'настройки'],
|
|
1464
|
+
['连接检查完成', 'connection check completed', 'проверка подключения завершена'],
|
|
1465
|
+
['仍未连接,插件会继续自动重试', 'is still offline; the plugin will keep retrying', 'всё ещё не подключён, плагин продолжит попытки'],
|
|
1466
|
+
['已重新连接', 'reconnected', 'переподключено'],
|
|
1467
|
+
['移除失败,请重试', 'could not be removed; try again', 'удалить не удалось, попробуйте снова'],
|
|
1468
|
+
['已连接,可以开始聊天', 'is connected and ready to chat', 'подключён, можно начинать переписку'],
|
|
1469
|
+
['已连接,可以开始发送消息', 'is connected and ready for messages', 'подключён и готов отправлять сообщения'],
|
|
1470
|
+
['服务请求失败', 'service request failed', 'запрос к сервису не удался'],
|
|
1471
|
+
// Failure reasons the host embeds in a message: they arrive as a captured phrase
|
|
1472
|
+
// inside an already localised sentence, so they need a translation of their own.
|
|
1473
|
+
['网络中断', 'network down', 'сеть недоступна'],
|
|
1474
|
+
['请求超时', 'request timed out', 'истекло время ожидания'],
|
|
1475
|
+
['超时', 'timed out', 'истекло время ожидания'],
|
|
1476
|
+
['服务不可用', 'service unavailable', 'сервис недоступен'],
|
|
1477
|
+
['连接被拒绝', 'connection refused', 'соединение отклонено'],
|
|
1478
|
+
['未授权', 'unauthorized', 'нет авторизации'],
|
|
1479
|
+
['响应格式错误', 'malformed response', 'неверный формат ответа'],
|
|
1480
|
+
['连接遇到问题', 'connection encountered a problem', 'проблема с подключением'],
|
|
1481
|
+
['正在读取', 'Loading ', 'Загружаем '],
|
|
1482
|
+
['连接状态', 'connection status', 'состояние подключения'],
|
|
1483
|
+
['二维码', 'QR code', 'QR-код'],
|
|
1484
|
+
]);
|
|
1485
|
+
|
|
1486
|
+
// The rules and their renderings, exposed so a test can hold every pattern to the
|
|
1487
|
+
// same per-locale contract instead of trusting the order of the chain below.
|
|
1488
|
+
export const IM_DYNAMIC_RULES = DYNAMIC_RULES;
|
|
1489
|
+
export const IM_DYNAMIC_PHRASES = DYNAMIC_PHRASES;
|
|
1357
1490
|
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
[
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
['服务请求失败', 'service request failed'], ['连接遇到问题', 'connection encountered a problem'],
|
|
1376
|
-
['正在读取', 'Loading '], ['连接状态', 'connection status'], ['二维码', 'QR code'],
|
|
1377
|
-
];
|
|
1491
|
+
/**
|
|
1492
|
+
* Localise a sentence the UI composed at runtime, e.g. `已接入的 Telegram 机器人`.
|
|
1493
|
+
*
|
|
1494
|
+
* @param text - the composed sentence, in the language the patterns are written in.
|
|
1495
|
+
* @param locale - `'en'`, `'ru'` or `'zh'`; anything else is served English, and
|
|
1496
|
+
* Chinese is the identity language, so its text travels untouched.
|
|
1497
|
+
* @returns the sentence in the requested locale, or `text` when nothing matches.
|
|
1498
|
+
*/
|
|
1499
|
+
export function translateDynamic(text, locale = imLocale()) {
|
|
1500
|
+
if (locale === 'zh') return text;
|
|
1501
|
+
const column = locale === 'ru' ? 'ru' : 'en';
|
|
1502
|
+
for (const rule of DYNAMIC_RULES) {
|
|
1503
|
+
const match = rule.pattern.exec(text);
|
|
1504
|
+
if (!match) continue;
|
|
1505
|
+
return (rule[column] ?? rule.en)(match);
|
|
1506
|
+
}
|
|
1507
|
+
const at = column === 'ru' ? 2 : 1;
|
|
1378
1508
|
let output = text;
|
|
1379
|
-
for (const
|
|
1509
|
+
for (const row of DYNAMIC_PHRASES) output = output.replaceAll(row[0], row[at]);
|
|
1380
1510
|
return output;
|
|
1381
1511
|
}
|
|
1382
1512
|
|
|
1513
|
+
const TEMPLATE_PLACEHOLDER = /\{(\w+)\}/gu;
|
|
1514
|
+
|
|
1515
|
+
/**
|
|
1516
|
+
* Localise a sentence the settings UI composes itself, from a template key both
|
|
1517
|
+
* dictionaries carry: `已接入的 {channel} 机器人`. The key is looked up like any other
|
|
1518
|
+
* string — so a Russian reader gets the Russian sentence — and the values are filled
|
|
1519
|
+
* in afterwards, which keeps the word order of the translation instead of the
|
|
1520
|
+
* Chinese one the sentence was assembled from. A key neither dictionary knows comes
|
|
1521
|
+
* back as the key with its placeholders still visible, the same identity the rest of
|
|
1522
|
+
* the module falls back to.
|
|
1523
|
+
*
|
|
1524
|
+
* @param key - the Chinese template, e.g. `尚未接入 {channel} 机器人`.
|
|
1525
|
+
* @param values - one value per placeholder; a missing one keeps its braces so the
|
|
1526
|
+
* gap is visible instead of silently empty.
|
|
1527
|
+
*/
|
|
1528
|
+
export function localizeTemplate(key, values) {
|
|
1529
|
+
if (typeof key !== 'string') return key;
|
|
1530
|
+
const template = translate(key);
|
|
1531
|
+
if (values == null) return template;
|
|
1532
|
+
return template.replace(TEMPLATE_PLACEHOLDER, (placeholder, name) => (
|
|
1533
|
+
Object.hasOwn(values, name) ? String(values[name]) : placeholder
|
|
1534
|
+
));
|
|
1535
|
+
}
|
|
1536
|
+
|
|
1383
1537
|
export function localizeText(value) {
|
|
1384
1538
|
if (typeof value !== 'string') return value;
|
|
1385
1539
|
const exact = translate(value);
|
|
1386
|
-
if (exact !== value
|
|
1540
|
+
if (exact !== value) return exact;
|
|
1541
|
+
// A whole-string lookup missing means the UI composed the sentence at runtime.
|
|
1542
|
+
// Chinese is the identity language, so `translateDynamic` hands the text back in
|
|
1543
|
+
// its own language there and renders it in the active locale everywhere else.
|
|
1387
1544
|
return translateDynamic(value);
|
|
1388
1545
|
}
|
|
1389
1546
|
|
|
@@ -58,7 +58,7 @@ import { installEmailStyles } from './channels/email/styles.js';
|
|
|
58
58
|
import { MATRIX_RPC_CHANNEL } from './channels/matrix/api.js';
|
|
59
59
|
import { MatrixSettingsTab } from './channels/matrix/index.js';
|
|
60
60
|
import { installMatrixStyles } from './channels/matrix/styles.js';
|
|
61
|
-
import { en, h, IM_LOCALE_NAMESPACE, setImTranslator, zh } from './i18n.js';
|
|
61
|
+
import { en, h, IM_LOCALE_NAMESPACE, installImRussianLocale, setImTranslator, zh } from './i18n.js';
|
|
62
62
|
import {
|
|
63
63
|
HOST_LANGUAGE_RPC_CHANNEL,
|
|
64
64
|
installInterfaceLanguageMirror,
|
|
@@ -456,6 +456,13 @@ export function apply(ctx) {
|
|
|
456
456
|
() => ctx.locale.register(IM_LOCALE_NAMESPACE, { zh, en }),
|
|
457
457
|
'im-settings: bilingual dictionaries',
|
|
458
458
|
);
|
|
459
|
+
// Russian is a language pack rather than a built-in locale: it needs its own
|
|
460
|
+
// definition so it shows up in the Language row, and its lookups chain to
|
|
461
|
+
// English before falling back to the Chinese key itself.
|
|
462
|
+
ctx.effect(
|
|
463
|
+
() => installImRussianLocale(ctx.locale),
|
|
464
|
+
'im-settings: Russian language pack',
|
|
465
|
+
);
|
|
459
466
|
const t = ctx.locale.bind(IM_LOCALE_NAMESPACE);
|
|
460
467
|
setImTranslator(t);
|
|
461
468
|
|
|
@@ -189,6 +189,11 @@ export async function createTokenProductionController(ctx, config, internals, de
|
|
|
189
189
|
harness: workspaceScope.harness,
|
|
190
190
|
state: workspaceScope.state,
|
|
191
191
|
groupHistory: internals.groupHistory ?? (['telegram', 'discord'].includes(channel) ? getGroupHistoryStore(ctx, config) : undefined),
|
|
192
|
+
// A transport that carries voice notes composes its own transcriber
|
|
193
|
+
// from Host services; without one voice messages stay textless.
|
|
194
|
+
...(typeof definitions.createVoiceTranscriber === 'function'
|
|
195
|
+
? { voice: definitions.createVoiceTranscriber(ctx, config, internals) }
|
|
196
|
+
: {}),
|
|
192
197
|
contextEnhancement: { botId, getSettings: () => workspaces.contextEnhancementFor(botId) },
|
|
193
198
|
accessPolicy: accessPolicyProvider(workspaces, botId, { channel, config: botConfig }),
|
|
194
199
|
replyTimeoutMs: config.replyTimeoutMs ?? 600_000,
|
|
@@ -17,6 +17,8 @@ import {
|
|
|
17
17
|
} from './agent-preset-rpc.mjs';
|
|
18
18
|
import { SET_MODEL_ENDPOINT, validModelPayload } from './model-setting-rpc.mjs';
|
|
19
19
|
import { SET_THINKING_TRACES_ENDPOINT, validThinkingTracesPayload } from './thinking-traces-rpc.mjs';
|
|
20
|
+
import { SET_THINKING_CADENCE_ENDPOINT, validThinkingCadencePayload } from './thinking-cadence-rpc.mjs';
|
|
21
|
+
import { SET_SEND_LIMIT_ENDPOINT, validSendLimitPayload } from './send-limit-rpc.mjs';
|
|
20
22
|
|
|
21
23
|
export const TOKEN_BOT_ENDPOINTS = Object.freeze({
|
|
22
24
|
status: 'connection.status',
|
|
@@ -31,6 +33,8 @@ export const TOKEN_BOT_ENDPOINTS = Object.freeze({
|
|
|
31
33
|
setAccessPolicy: SET_ACCESS_POLICY_ENDPOINT,
|
|
32
34
|
setAlias: SET_ALIAS_ENDPOINT,
|
|
33
35
|
setThinkingTraces: SET_THINKING_TRACES_ENDPOINT,
|
|
36
|
+
setThinkingCadence: SET_THINKING_CADENCE_ENDPOINT,
|
|
37
|
+
setSendLimit: SET_SEND_LIMIT_ENDPOINT,
|
|
34
38
|
});
|
|
35
39
|
|
|
36
40
|
const ENDPOINTS = Object.freeze(Object.values(TOKEN_BOT_ENDPOINTS));
|
|
@@ -109,6 +113,14 @@ function payloadFailure(endpoint, payload) {
|
|
|
109
113
|
return validThinkingTracesPayload(payload)
|
|
110
114
|
? null : '请提交有效的思考过程留痕设置。';
|
|
111
115
|
}
|
|
116
|
+
if (endpoint === TOKEN_BOT_ENDPOINTS.setThinkingCadence) {
|
|
117
|
+
return validThinkingCadencePayload(payload)
|
|
118
|
+
? null : '请提交有效的思考帧节奏设置。';
|
|
119
|
+
}
|
|
120
|
+
if (endpoint === TOKEN_BOT_ENDPOINTS.setSendLimit) {
|
|
121
|
+
return validSendLimitPayload(payload)
|
|
122
|
+
? null : '请提交有效的消息发送上限。';
|
|
123
|
+
}
|
|
112
124
|
return 'Unknown bot endpoint.';
|
|
113
125
|
}
|
|
114
126
|
|
|
@@ -212,6 +224,15 @@ export function createTokenBotRpcHandler(controller, { channel }) {
|
|
|
212
224
|
} else if (endpoint === TOKEN_BOT_ENDPOINTS.setThinkingTraces) {
|
|
213
225
|
if (typeof controller.setThinkingTraces !== 'function') throw new Error('Thinking traces update is unavailable');
|
|
214
226
|
value = await controller.setThinkingTraces(payload.botId, payload.thinkingTraces);
|
|
227
|
+
} else if (endpoint === TOKEN_BOT_ENDPOINTS.setThinkingCadence) {
|
|
228
|
+
if (typeof controller.setThinkingCadence !== 'function') throw new Error('Thinking trace cadence update is unavailable');
|
|
229
|
+
value = await controller.setThinkingCadence(payload.botId, {
|
|
230
|
+
thinkingNumbering: payload.thinkingNumbering,
|
|
231
|
+
thinkingIntervalSeconds: payload.thinkingIntervalSeconds,
|
|
232
|
+
});
|
|
233
|
+
} else if (endpoint === TOKEN_BOT_ENDPOINTS.setSendLimit) {
|
|
234
|
+
if (typeof controller.setSendLimitPerMinute !== 'function') throw new Error('Send limit update is unavailable');
|
|
235
|
+
value = await controller.setSendLimitPerMinute(payload.botId, payload.sendLimitPerMinute);
|
|
215
236
|
} else {
|
|
216
237
|
value = await controller.deleteBot(payload.botId);
|
|
217
238
|
}
|