@xmanrui/dsh-im 5.3.0 → 5.5.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 +44 -3
- package/README.md +44 -3
- package/THIRD_PARTY_NOTICES.md +209 -0
- package/docs/client-integration.md +2 -2
- package/lib/client.js +3737 -433
- package/lib/index.js +415 -344
- package/package.json +1 -1
- package/plugin-src/client/channel-card-meta.js +6 -2
- package/plugin-src/client/channels/shared/token-api.js +13 -0
- package/plugin-src/client/channels/telegram/group-triggers-settings.js +393 -0
- 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/delivery-settings.js +23 -3
- package/plugin-src/client/ds-bot-avatar-data.js +537 -0
- package/plugin-src/client/ds-bot-avatar.js +55 -0
- package/plugin-src/client/ds-bot-session-avatars.js +77 -0
- package/plugin-src/client/ds-bot-settings.js +194 -0
- package/plugin-src/client/i18n-ru.js +1615 -0
- package/plugin-src/client/i18n.js +130 -1
- package/plugin-src/client/index.js +20 -2
- package/plugin-src/client/plugin-page.js +3 -8
- package/plugin-src/client/styles.js +25 -5
- package/plugin-src/host/channels/dingtalk/production.mjs +2 -1
- package/plugin-src/host/channels/feishu/production.mjs +13 -5
- package/plugin-src/host/channels/qq/production.mjs +2 -1
- package/plugin-src/host/channels/shared/group-triggers-rpc.mjs +110 -0
- package/plugin-src/host/channels/shared/production.mjs +12 -1
- 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/slack/production.mjs +2 -1
- package/plugin-src/host/channels/telegram/index.mjs +1 -0
- package/plugin-src/host/channels/telegram/production.mjs +9 -0
- package/plugin-src/host/channels/telegram/rpc.mjs +17 -2
- package/plugin-src/host/channels/wecom/production.mjs +4 -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 +129 -41
- package/plugin-src/host/delivery-rpc.mjs +33 -1
- package/plugin-src/host/delivery-service.mjs +112 -1
- package/plugin-src/host/delivery-suggestions.mjs +11 -0
- package/plugin-src/host/ds-bot-client.mjs +87 -0
- package/plugin-src/host/ds-bot-question-sync.mjs +78 -0
- package/plugin-src/host/index.mjs +8 -1
- 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 +17 -5
- package/src/channels/feishu/bridge.mjs +83 -5
- package/src/channels/feishu/feishu-cards.mjs +11 -7
- package/src/channels/feishu/feishu-runtime.mjs +10 -0
- package/src/channels/feishu/multi-bot-controller.mjs +12 -0
- package/src/channels/shared/AGENTS.md +19 -0
- package/src/channels/shared/bot-workspace-store.mjs +136 -7
- package/src/channels/shared/clear-command.mjs +2 -1
- 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/group-history-store.mjs +26 -0
- package/src/channels/shared/harness-client.mjs +5 -4
- package/src/channels/shared/history-command.mjs +2 -1
- package/src/channels/shared/i18n-en/feishu.mjs +1 -0
- package/src/channels/shared/i18n-en/shared-a.mjs +2 -2
- package/src/channels/shared/i18n-en/shared-b.mjs +2 -2
- package/src/channels/shared/i18n-en/shared-c.mjs +3 -2
- package/src/channels/shared/i18n-en/wecom.mjs +4 -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 +257 -0
- package/src/channels/shared/i18n-ru/shared-c.mjs +173 -0
- package/src/channels/shared/i18n-ru/slack.mjs +22 -0
- package/src/channels/shared/i18n-ru/telegram.mjs +25 -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 +3 -2
- 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-binding-lock.mjs +2 -0
- package/src/channels/shared/session-error.mjs +3 -0
- package/src/channels/shared/status-reaction.mjs +2 -0
- package/src/channels/shared/text-harness-bridge.mjs +4 -0
- package/src/channels/shared/thinking-cadence.mjs +36 -0
- package/src/channels/shared/workspace-command.mjs +2 -1
- package/src/channels/shared/workspace-session.mjs +5 -1
- package/src/channels/telegram/config-store.mjs +38 -1
- package/src/channels/telegram/group-triggers.mjs +229 -0
- package/src/channels/telegram/telegram-api.mjs +223 -32
- package/src/channels/telegram/telegram-bridge.mjs +4 -1
- package/src/channels/telegram/telegram-controller.mjs +139 -1
- package/src/channels/telegram/telegram-runtime.mjs +522 -178
- package/src/channels/telegram/voice.mjs +250 -0
- package/src/channels/wecom/stream-supervisor.mjs +184 -0
- package/src/channels/wecom/wecom-bridge.mjs +25 -11
- package/src/channels/wecom/wecom-runtime.mjs +12 -1
|
@@ -1,11 +1,39 @@
|
|
|
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
|
|
|
8
9
|
const EN = Object.freeze({
|
|
10
|
+
"私聊对象": "Private chat",
|
|
11
|
+
"选择私聊对象": "Select a private chat",
|
|
12
|
+
"仅支持已经建立会话的私聊,请先与机器人私聊后刷新。": "Only established private chats are supported. Message the bot privately, then refresh.",
|
|
13
|
+
"选择 DS Bot 和私聊对象,直接使用 Bot 的会话。": "Choose a DS Bot and a private chat to use the Bot’s session.",
|
|
14
|
+
"还没有可绑定的私聊。先给这个机器人发一条私聊消息,再点击刷新。": "No private chats yet. Send this bot a private message, then refresh.",
|
|
15
|
+
|
|
16
|
+
"绑定bot": "Bind bot",
|
|
17
|
+
"正在检测 DS Bot…": "Checking DS Bot…",
|
|
18
|
+
"选择 DS Bot": "Select DS Bot",
|
|
19
|
+
"暂无可选 DS Bot": "No available DS Bots",
|
|
20
|
+
"暂无可选私聊对象": "No available private chats",
|
|
21
|
+
"已绑定的 DS Bot 和私聊对象不可重复选择,解除绑定后可重新选择。": "Bound DS Bots and private chats cannot be selected again. Unbind them to make them available.",
|
|
22
|
+
"所选 DS Bot 或私聊对象已绑定,请刷新后重新选择。": "The selected DS Bot or private chat is already bound. Refresh and choose again.",
|
|
23
|
+
"解除绑定": "Unbind",
|
|
24
|
+
"已绑定": "Bound",
|
|
25
|
+
"未安装 DS Bot,请先在 DSH 插件管理中安装 ds-bot,然后刷新。": "DS Bot is not installed. Install ds-bot in DSH plugin management, then refresh.",
|
|
26
|
+
"DS Bot 尚未启用,请在 DSH 插件管理中启用后刷新。": "DS Bot is disabled. Enable it in DSH plugin management, then refresh.",
|
|
27
|
+
"暂时无法读取 DS Bot,请检查插件是否正常运行后重试。": "Unable to read DS Bot. Check that the plugin is running, then retry.",
|
|
28
|
+
"DS Bot 当前由其他 Host 管理,请在运行它的 Host 中绑定。": "DS Bot is managed by another Host. Bind it on that Host.",
|
|
29
|
+
"绑定bot仅支持当前 Host 的会话,请先检查机器人的 Harness 连接设置。": "Bot binding requires the current Host. Check the bot’s Harness connection settings.",
|
|
30
|
+
"所选 DS Bot 已不存在,请刷新后重新选择。": "The selected DS Bot no longer exists. Refresh and select another.",
|
|
31
|
+
"绑定设置保存失败,请刷新后重试。": "Could not save the binding. Refresh and retry.",
|
|
32
|
+
"绑定已保存。": "Binding saved.",
|
|
33
|
+
"已解除绑定,聊天记录保留。": "Binding removed. Chat history is preserved.",
|
|
34
|
+
"还没有 DS Bot,请先在 DS Bot 中创建机器人后刷新。": "No bots yet. Create a bot in DS Bot, then refresh.",
|
|
35
|
+
"DS Bot 暂不可用": "DS Bot unavailable",
|
|
36
|
+
|
|
9
37
|
...weixinDiagnostics,
|
|
10
38
|
...diagnostics,
|
|
11
39
|
...imageInput,
|
|
@@ -67,7 +95,6 @@ const EN = Object.freeze({
|
|
|
67
95
|
'macOS Messages 权限': 'macOS Messages permissions',
|
|
68
96
|
'IM机器人': 'IM bots',
|
|
69
97
|
'打开 IM机器人': 'Open IM bots',
|
|
70
|
-
'返回插件详情': 'Back to plugin details',
|
|
71
98
|
'IM机器人设置': 'IM bot settings',
|
|
72
99
|
'IM 面板加载失败': 'Could not load the IM panel',
|
|
73
100
|
'更多机器人设置': 'More bot settings',
|
|
@@ -78,6 +105,38 @@ const EN = Object.freeze({
|
|
|
78
105
|
'机器人设置': 'Bot settings',
|
|
79
106
|
'机器人设置页签': 'Bot settings tabs',
|
|
80
107
|
'投递设置': 'Delivery settings',
|
|
108
|
+
'机器人群聊行为': 'Bot in groups',
|
|
109
|
+
'新群聊默认设置': 'Default for new groups',
|
|
110
|
+
'响应条件': 'React to',
|
|
111
|
+
'不响应': 'Do not react',
|
|
112
|
+
'被 @ 或回复时(任何人)': 'Mention or reply, anyone',
|
|
113
|
+
'被 @ 或回复时(仅名单成员)': 'Mention or reply, listed members only',
|
|
114
|
+
'所有消息(任何人)': 'All messages, anyone',
|
|
115
|
+
'所有消息(仅名单成员)': 'All messages, listed members only',
|
|
116
|
+
'成员名单': 'Members list',
|
|
117
|
+
'名单为空:该模式不会响应任何成员。': 'The list is empty, so nobody can trigger the bot in this mode.',
|
|
118
|
+
'当前模式不使用名单。': 'This mode does not use the list.',
|
|
119
|
+
'群 ID': 'Group',
|
|
120
|
+
'标题': 'Title',
|
|
121
|
+
'最近活动': 'Last activity',
|
|
122
|
+
'(默认)': ' (default)',
|
|
123
|
+
'× 移除': '× Remove',
|
|
124
|
+
'自定义': 'Customize',
|
|
125
|
+
'添加群聊': 'Add group',
|
|
126
|
+
'群 ID、@用户名或消息链接': 'Group ID, @username or message link',
|
|
127
|
+
'支持数字 ID、@用户名、t.me/<name> 或 t.me/c/<id>/<msg>;真实 ID 通过 getChat 解析。': 'Accepts a numeric ID, @username, t.me/<name> or t.me/c/<id>/<msg>; the real ID is resolved through getChat.',
|
|
128
|
+
'+ 添加': '+ Add',
|
|
129
|
+
'保存群聊设置': 'Save group settings',
|
|
130
|
+
'已从列表移除,保存后生效。': 'Removed from the list. Save to apply.',
|
|
131
|
+
'已添加,保存后生效。': 'Added. Save to apply.',
|
|
132
|
+
'已添加。Telegram 未确认该群(机器人可能还不在群里),保存后生效。': 'Added without Telegram confirmation (the bot may not be in that group yet). Save to apply.',
|
|
133
|
+
'群聊设置已保存。': 'Group settings saved.',
|
|
134
|
+
'正在读取群聊设置…': 'Loading group settings…',
|
|
135
|
+
'无法读取群聊设置,请稍后重试。': 'Unable to read group settings. Try again.',
|
|
136
|
+
'无法保存群聊设置,请稍后重试。': 'Unable to save group settings. Try again.',
|
|
137
|
+
'无法读取或保存群聊设置,请稍后重试。': 'Unable to read or save group settings. Try again.',
|
|
138
|
+
'无法解析该群聊,请重试或填写数字群 ID。': 'Could not resolve this group. Try again or enter the numeric group ID.',
|
|
139
|
+
'该群已在列表中,请编辑上方的卡片。': 'This group is already in the list. Edit its card above instead.',
|
|
81
140
|
'访问设置': 'Access settings',
|
|
82
141
|
'查看访问权限说明': 'View access permission details',
|
|
83
142
|
'允许所有用户': 'Allow all users',
|
|
@@ -780,6 +839,15 @@ const EN = Object.freeze({
|
|
|
780
839
|
'思考过程留痕': 'Thinking traces',
|
|
781
840
|
'实时显示思考步骤与工具调用,最终答案单独成条': 'Show thinking steps and tool calls as they happen; the final answer arrives as its own message',
|
|
782
841
|
'请提交有效的思考过程留痕设置。': 'Submit a valid thinking-traces setting.',
|
|
842
|
+
'编号思考帧': 'Number trace frames',
|
|
843
|
+
'在每帧前加上本轮序号;被节奏跳过的帧也计数,所以编号会跳号(需先打开思考过程留痕)': 'Prefix each frame with its number in the turn; paced-away frames still count, so numbers jump. Requires thinking traces.',
|
|
844
|
+
'最多每隔多久发送一帧(秒)': 'Send at most one frame every (seconds)',
|
|
845
|
+
'突发时只发送窗口里最新的一帧,过期的帧丢弃,不排队也不重发': 'A burst sends only its latest frame; stale frames are dropped, not queued or resent',
|
|
846
|
+
'不限制(0)': 'No limit (0)',
|
|
847
|
+
'请提交有效的思考帧节奏设置。': 'Submit a valid trace cadence setting.',
|
|
848
|
+
'消息发送上限': 'Message limit',
|
|
849
|
+
'每个聊天每分钟的消息数;机器人会等待而不是丢弃': 'Per chat, messages per minute; the bot waits instead of dropping',
|
|
850
|
+
'请提交有效的消息发送上限。': 'Submit a valid message limit.',
|
|
783
851
|
'正在使用{name}…': 'Using {name}…',
|
|
784
852
|
'访问模式': 'Access mode',
|
|
785
853
|
'Telegram 访问模式': 'Telegram access mode',
|
|
@@ -1201,16 +1269,77 @@ export const zh = Object.freeze(Object.fromEntries(
|
|
|
1201
1269
|
Object.keys(EN).map((key) => [key, key === '$locale' ? 'zh' : key]),
|
|
1202
1270
|
));
|
|
1203
1271
|
|
|
1272
|
+
// Russian, narrowed to the keys this UI asks for: the shared Host modules it is
|
|
1273
|
+
// built from also carry strings no settings surface renders, and a namespace
|
|
1274
|
+
// dictionary holding keys the English one does not know would let a mistyped
|
|
1275
|
+
// Chinese key hide behind a lookup that happens to miss. The English text is the
|
|
1276
|
+
// last resort for a key the narrowed dictionary somehow lost.
|
|
1277
|
+
export const ru = Object.freeze(Object.fromEntries(
|
|
1278
|
+
Object.keys(EN).map((key) => [key, RU[key] ?? EN[key]]),
|
|
1279
|
+
));
|
|
1280
|
+
|
|
1204
1281
|
let translate = (key) => key;
|
|
1205
1282
|
|
|
1206
1283
|
export function setImTranslator(next) {
|
|
1207
1284
|
translate = typeof next === 'function' ? next : (key) => key;
|
|
1208
1285
|
}
|
|
1209
1286
|
|
|
1287
|
+
// The language these dictionaries are rendering in. Read through the `$locale`
|
|
1288
|
+
// entry rather than a snapshot taken at load time, so a locale whose dictionary
|
|
1289
|
+
// registers later is still reported correctly. Anything unrecognized means
|
|
1290
|
+
// Chinese, the identity language.
|
|
1291
|
+
export function imLocale() {
|
|
1292
|
+
const id = translate('$locale');
|
|
1293
|
+
return id === 'en' || id === 'ru' ? id : 'zh';
|
|
1294
|
+
}
|
|
1295
|
+
|
|
1210
1296
|
export function isEnglish() {
|
|
1211
1297
|
return translate('$locale') === 'en';
|
|
1212
1298
|
}
|
|
1213
1299
|
|
|
1300
|
+
export const IM_RUSSIAN_LANGUAGE = Object.freeze({ id: 'ru', label: 'Русский', fallback: 'en' });
|
|
1301
|
+
|
|
1302
|
+
/**
|
|
1303
|
+
* Register Russian with the DSH locale registry: the definition makes it
|
|
1304
|
+
* selectable and chains its lookups to English, and the dictionary goes in as
|
|
1305
|
+
* one single-locale entry because `ru` is a language pack rather than one of the
|
|
1306
|
+
* two built-in locales.
|
|
1307
|
+
*
|
|
1308
|
+
* The definition is skipped when the id is already occupied — another language
|
|
1309
|
+
* pack may have registered `ru` first, and an occupied id is a hard error there.
|
|
1310
|
+
* The dictionary is registered either way, so Russian strings still resolve.
|
|
1311
|
+
*
|
|
1312
|
+
* @param locale - the client `locale` service.
|
|
1313
|
+
* @returns an idempotent disposer for both registrations.
|
|
1314
|
+
*/
|
|
1315
|
+
export function installImRussianLocale(locale) {
|
|
1316
|
+
if (typeof locale?.register !== 'function') return () => {};
|
|
1317
|
+
const disposers = [];
|
|
1318
|
+
const defined = (locale.getLocale?.()?.locales ?? []).some(
|
|
1319
|
+
(entry) => entry?.id === IM_RUSSIAN_LANGUAGE.id,
|
|
1320
|
+
);
|
|
1321
|
+
if (!defined && typeof locale.addLanguage === 'function') {
|
|
1322
|
+
try {
|
|
1323
|
+
disposers.push(locale.addLanguage(IM_RUSSIAN_LANGUAGE));
|
|
1324
|
+
} catch (error) {
|
|
1325
|
+
// The id may have been taken between the check and this call; that pack
|
|
1326
|
+
// owns the definition now, and registering the dictionary is still safe.
|
|
1327
|
+
if (!/already registered/iu.test(String(error?.message ?? ''))) throw error;
|
|
1328
|
+
}
|
|
1329
|
+
}
|
|
1330
|
+
disposers.push(locale.register(IM_LOCALE_NAMESPACE, IM_RUSSIAN_LANGUAGE.id, ru));
|
|
1331
|
+
return () => {
|
|
1332
|
+
// Reverse order: the dictionary goes before the definition that chains to it.
|
|
1333
|
+
for (const dispose of disposers.reverse()) {
|
|
1334
|
+
try {
|
|
1335
|
+
dispose?.();
|
|
1336
|
+
} catch {
|
|
1337
|
+
// A registry that already dropped the entry must not block teardown.
|
|
1338
|
+
}
|
|
1339
|
+
}
|
|
1340
|
+
};
|
|
1341
|
+
}
|
|
1342
|
+
|
|
1214
1343
|
function channelName(value) {
|
|
1215
1344
|
return localizeText(value);
|
|
1216
1345
|
}
|
|
@@ -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,
|
|
@@ -80,6 +80,7 @@ import {
|
|
|
80
80
|
} from './loopback-recovery.js';
|
|
81
81
|
import { installImStyles } from './styles.js';
|
|
82
82
|
import { installSessionChannelLogos } from './session-channel-logos.js';
|
|
83
|
+
import { installDsBotSessionAvatars } from './ds-bot-session-avatars.js';
|
|
83
84
|
import { UpdatePanel, UPDATE_RPC_CHANNEL } from './update-panel.js';
|
|
84
85
|
import { WorkspaceDirectoryPickerContext } from './workspace-editor.js';
|
|
85
86
|
import { IMPanelErrorBoundary } from './panel-error-boundary.js';
|
|
@@ -455,6 +456,13 @@ export function apply(ctx) {
|
|
|
455
456
|
() => ctx.locale.register(IM_LOCALE_NAMESPACE, { zh, en }),
|
|
456
457
|
'im-settings: bilingual dictionaries',
|
|
457
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
|
+
);
|
|
458
466
|
const t = ctx.locale.bind(IM_LOCALE_NAMESPACE);
|
|
459
467
|
setImTranslator(t);
|
|
460
468
|
|
|
@@ -470,6 +478,14 @@ export function apply(ctx) {
|
|
|
470
478
|
);
|
|
471
479
|
|
|
472
480
|
ctx.effect(() => installSessionChannelLogos(), 'im-settings: Session channel logos');
|
|
481
|
+
let dsBotAvatars;
|
|
482
|
+
ctx.effect(() => {
|
|
483
|
+
dsBotAvatars = installDsBotSessionAvatars(ctx, {
|
|
484
|
+
rpcCall: (endpoint, payload, signal) =>
|
|
485
|
+
callManagementRpc(ctx.connection, DELIVERY_RPC_CHANNEL, endpoint, payload, signal),
|
|
486
|
+
});
|
|
487
|
+
return () => { dsBotAvatars.dispose(); dsBotAvatars = null; };
|
|
488
|
+
}, 'im-settings: bound DS Bot session avatars');
|
|
473
489
|
|
|
474
490
|
ctx.effect(() => {
|
|
475
491
|
const disposers = [
|
|
@@ -497,8 +513,10 @@ export function apply(ctx) {
|
|
|
497
513
|
const managementRpc = async (connection, channel, endpoint, payload, signal) => {
|
|
498
514
|
const result = await callManagementRpc(connection, channel, endpoint, payload, signal);
|
|
499
515
|
if (result?.ok === true) {
|
|
516
|
+
const dsBotRead = channel === DELIVERY_RPC_CHANNEL && endpoint === 'ds-bot.status';
|
|
517
|
+
if (channel === DELIVERY_RPC_CHANNEL && ['ds-bot.bind', 'ds-bot.unbind'].includes(endpoint)) dsBotAvatars?.refresh();
|
|
500
518
|
if (endpoint === SIDEBAR_SETTINGS_ENDPOINTS.set) sidebarSync?.apply(result);
|
|
501
|
-
else if (endpoint !== SIDEBAR_SETTINGS_ENDPOINTS.get) sidebarSync?.refresh();
|
|
519
|
+
else if (!dsBotRead && endpoint !== SIDEBAR_SETTINGS_ENDPOINTS.get) sidebarSync?.refresh();
|
|
502
520
|
}
|
|
503
521
|
return result;
|
|
504
522
|
};
|
|
@@ -13,11 +13,9 @@ function OpenImAction({ subject, packageName, onOpen, t }) {
|
|
|
13
13
|
}, t('打开 IM机器人'));
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
function ImPluginPage({ renderPanel
|
|
16
|
+
function ImPluginPage({ renderPanel }) {
|
|
17
17
|
return h('div', { className: 'dim-pluginPage' },
|
|
18
18
|
h('div', { className: 'dim-pluginPageContent' },
|
|
19
|
-
h('button', { type: 'button', className: 'dim-pluginBack', onClick: onBack },
|
|
20
|
-
h('span', { 'aria-hidden': true }, '‹'), t('返回插件详情')),
|
|
21
19
|
renderPanel()));
|
|
22
20
|
}
|
|
23
21
|
|
|
@@ -47,14 +45,11 @@ export function installImPluginPage(ctx, { packageName, renderPanel, sidebarVisi
|
|
|
47
45
|
},
|
|
48
46
|
};
|
|
49
47
|
if (typeof ctx.inject !== 'function') return controller;
|
|
50
|
-
ctx.inject(['layout'
|
|
48
|
+
ctx.inject(['layout'], (pageCtx) =>
|
|
51
49
|
pageCtx.slots.inject('main', () => {
|
|
52
50
|
const unregisterPage = pageCtx.slots.register({
|
|
53
51
|
name: 'main', key: IM_MAIN_PANEL_ID, locale: IM_LOCALE_NAMESPACE,
|
|
54
|
-
inject: () => ({
|
|
55
|
-
renderPanel,
|
|
56
|
-
onBack: () => pageCtx.pluginNavigation.openBundle(packageName),
|
|
57
|
-
}),
|
|
52
|
+
inject: () => ({ renderPanel }),
|
|
58
53
|
}, ImPluginPage);
|
|
59
54
|
let stopSidebar = null;
|
|
60
55
|
const update = () => {
|
|
@@ -4,13 +4,10 @@ const CSS = String.raw`
|
|
|
4
4
|
.dim-sidebarIcon { display: block; flex: none; }
|
|
5
5
|
.dim-pluginOpen { display: inline-flex; align-items: center; justify-content: center; min-height: 36px; padding: 7px 14px; border: 1px solid var(--dsw-alias-border-l2, #dfe1e5); border-radius: 8px; color: var(--dsw-alias-label-primary, #1f2329); background: var(--dsw-alias-bg-layer-1, #fff); font: inherit; font-size: 13px; line-height: 20px; cursor: pointer; }
|
|
6
6
|
.dim-pluginOpen:hover { background: var(--dsw-alias-interactive-bg-hover, #f7f8fa); }
|
|
7
|
-
.dim-pluginOpen:focus-visible
|
|
7
|
+
.dim-pluginOpen:focus-visible { outline: 2px solid var(--dsw-alias-state-business-primary, #3370ff); outline-offset: 3px; }
|
|
8
8
|
.dim-pluginPage { height: 100%; min-height: 0; overflow: auto; box-sizing: border-box; padding: 24px clamp(16px, 4vw, 48px) 32px; color: var(--dsw-alias-label-primary, #1f2329); }
|
|
9
9
|
.dim-pluginPageContent { max-width: 1080px; margin: 0 auto; }
|
|
10
|
-
|
|
11
|
-
.dim-pluginBack:hover { color: var(--dsw-alias-label-primary, #1f2329); background: var(--dsw-alias-interactive-bg-hover, #f7f8fa); }
|
|
12
|
-
.dim-pluginBack > span { font-size: 22px; line-height: 20px; }
|
|
13
|
-
@media (pointer: coarse) { .dim-pluginOpen, .dim-pluginBack { min-height: 44px; } }
|
|
10
|
+
@media (pointer: coarse) { .dim-pluginOpen { min-height: 44px; } }
|
|
14
11
|
.dim-connectionDiagnostic { min-width: 0; width: 100%; color: var(--dsw-alias-label-secondary, #646a73); overflow-wrap: anywhere; font-size: 13px; line-height: 1.6; }
|
|
15
12
|
.dim-connectionDiagnostic[data-warning="true"] { color: var(--dsw-alias-state-warn-primary, #d97706); }
|
|
16
13
|
.dim-connectionDiagnostic p { margin: 4px 0; }
|
|
@@ -602,6 +599,25 @@ const CSS = String.raw`
|
|
|
602
599
|
.dim-targetField input[readonly] { color: var(--dsw-alias-label-secondary, #646a73); background: var(--dsw-alias-bg-module-platform, #f7f8fa); }
|
|
603
600
|
.dim-targetFormError { margin: 10px 0 0; font-size: 12px; line-height: 18px; }
|
|
604
601
|
.dim-targetFormActions { display: flex; justify-content: flex-end; gap: 7px; margin-top: 12px; }
|
|
602
|
+
.dim-dsBotForm { margin-top: 20px; }
|
|
603
|
+
.dim-dsBotForm .dim-targetFormGrid { grid-template-columns: repeat(auto-fit, minmax(min(220px, 100%), 1fr)); margin-top: 0; gap: 16px; }
|
|
604
|
+
.dim-dsBotForm .dim-targetFormActions { margin-top: 16px; }
|
|
605
|
+
.dim-targetRow.dim-dsBotBinding { grid-template-columns: minmax(0, 1fr) max-content; align-items: center; }
|
|
606
|
+
.dim-dsBotDestination { margin: 3px 0 0; color: var(--dsw-alias-label-secondary, #646a73); font-size: 12px; line-height: 18px; overflow-wrap: anywhere; }
|
|
607
|
+
.dim-dsBotNotice { margin: 20px 0 0; color: var(--dsw-alias-label-secondary, #646a73); font-size: 12px; line-height: 20px; }
|
|
608
|
+
.dim-dsBotNotice p { margin: 0 0 10px; }
|
|
609
|
+
.dim-dsBotSettings > .dim-targetFeedback { margin-top: 12px; }
|
|
610
|
+
.dim-dsBotAvatar { display: block; flex: none; object-fit: cover; border-radius: 5px; }
|
|
611
|
+
.dim-dsBotBoundIdentity { display: flex; align-items: center; gap: 10px; min-width: 0; }
|
|
612
|
+
.dim-dsBotPicker { position: relative; min-width: 0; }
|
|
613
|
+
.dim-dsBotPickerTrigger { display: flex; align-items: center; gap: 8px; width: 100%; height: 34px; padding: 0 9px; border: 1px solid var(--dsw-alias-border-l2, #dfe1e5); border-radius: 7px; color: var(--dsw-alias-label-primary, #1f2329); background: var(--dsw-alias-bg-layer-1, #fff); font: inherit; font-size: 12px; text-align: left; cursor: pointer; }
|
|
614
|
+
.dim-dsBotPickerName { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
615
|
+
.dim-dsBotPickerTrigger:focus-visible { outline: 2px solid color-mix(in srgb, var(--dsw-alias-state-business-primary, #3370ff) 28%, transparent); border-color: var(--dsw-alias-state-business-primary, #3370ff); }
|
|
616
|
+
.dim-dsBotPickerTrigger:disabled { opacity: .5; cursor: not-allowed; }
|
|
617
|
+
.dim-dsBotOptions { position: absolute; z-index: 20; inset: calc(100% + 5px) 0 auto; max-height: 240px; overflow-y: auto; padding: 4px; border: 1px solid var(--dsw-alias-border-l2, #dfe1e5); border-radius: 9px; background: var(--dsw-alias-bg-layer-1, #fff); box-shadow: 0 5px 18px rgb(0 0 0 / 10%); }
|
|
618
|
+
.dim-dsBotOptions > button { display: flex; align-items: center; gap: 8px; width: 100%; min-height: 36px; padding: 5px 8px; border: 0; border-radius: 6px; background: transparent; color: var(--dsw-alias-label-primary, #1f2329); font: inherit; font-size: 12px; text-align: left; cursor: pointer; }
|
|
619
|
+
.dim-dsBotOptions > button[data-active="true"] { background: var(--dsw-alias-interactive-bg-hover, #eef0f3); }
|
|
620
|
+
.dim-dsBotOptions > button[aria-selected="true"] { color: var(--dsw-alias-state-business-primary, #3370ff); }
|
|
605
621
|
.dim-accessPage { min-width: 0; display: grid; gap: 14px; }
|
|
606
622
|
.dim-accessScene { position: relative; min-width: 0; margin: 0; padding: 16px; border: 1px solid var(--dsw-alias-border-l2, #dfe1e5); border-radius: 12px; background: var(--dsw-alias-bg-layer-3, #fff); }
|
|
607
623
|
.dim-accessScene > legend { padding: 0 6px; color: var(--dsw-alias-label-primary, #1f2329); font-size: 15px; line-height: 22px; font-weight: 650; }
|
|
@@ -612,6 +628,10 @@ const CSS = String.raw`
|
|
|
612
628
|
.dim-accessControls[data-mode="allowlist"] { grid-template-columns: minmax(0, 1fr); }
|
|
613
629
|
.dim-accessField { min-width: 0; display: grid; align-content: start; gap: 5px; color: var(--dsw-alias-label-secondary, #646a73); font-size: 11px; line-height: 16px; }
|
|
614
630
|
.dim-accessField input, .dim-accessField select { width: 100%; min-width: 0; height: 36px; padding: 0 9px; border: 1px solid var(--dsw-alias-border-l2, #dfe1e5); border-radius: 7px; color: var(--dsw-alias-label-primary, #1f2329); background: var(--dsw-alias-bg-layer-1, #fff); font: inherit; font-size: 12px; }
|
|
631
|
+
.dim-accessField textarea { width: 100%; min-width: 0; padding: 7px 9px; border: 1px solid var(--dsw-alias-border-l2, #dfe1e5); border-radius: 7px; color: var(--dsw-alias-label-primary, #1f2329); background: var(--dsw-alias-bg-layer-1, #fff); font: inherit; font-size: 12px; line-height: 18px; resize: vertical; }
|
|
632
|
+
.dim-accessField textarea:focus { outline: 2px solid color-mix(in srgb, var(--dsw-alias-state-business-primary, #3370ff) 28%, transparent); border-color: var(--dsw-alias-state-business-primary, #3370ff); }
|
|
633
|
+
.dim-accessField textarea:disabled { opacity: .6; }
|
|
634
|
+
.dim-groupTriggerValue { color: var(--dsw-alias-label-primary, #1f2329); font-size: 12px; line-height: 18px; overflow-wrap: anywhere; }
|
|
615
635
|
.dim-accessField input:focus, .dim-accessField select:focus { outline: 2px solid color-mix(in srgb, var(--dsw-alias-state-business-primary, #3370ff) 28%, transparent); border-color: var(--dsw-alias-state-business-primary, #3370ff); }
|
|
616
636
|
.dim-accessUsers { min-width: 0; margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--dsw-alias-border-l1, #eef0f3); }
|
|
617
637
|
.dim-accessUsersHeading { position: relative; min-width: 0; display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
|
|
@@ -129,6 +129,7 @@ export async function createProductionController(ctx, config = {}, internals = {
|
|
|
129
129
|
initialAccessPolicy: initialAccessPolicyFor('dingtalk', botConfig),
|
|
130
130
|
});
|
|
131
131
|
const workspaceScope = createBotWorkspaceScope(harness, {
|
|
132
|
+
dsBot: config.deliveryService?.dsBot,
|
|
132
133
|
botId, workspaces, state, agentPresetCatalog,
|
|
133
134
|
});
|
|
134
135
|
return new Runtime({
|
|
@@ -180,7 +181,7 @@ export async function createProductionController(ctx, config = {}, internals = {
|
|
|
180
181
|
}).start();
|
|
181
182
|
return {
|
|
182
183
|
controller,
|
|
183
|
-
deliveryAdapter: createDeliveryAdapter({
|
|
184
|
+
deliveryAdapter: createDeliveryAdapter({ dsBot: config.deliveryService?.dsBot,
|
|
184
185
|
channel: 'dingtalk', workspaces, coreController, stateFor,
|
|
185
186
|
}),
|
|
186
187
|
ready: supervisor.ready,
|
|
@@ -32,7 +32,7 @@ import {
|
|
|
32
32
|
import { prepareBotWorkspace } from '../../../../src/channels/shared/default-workspace.mjs';
|
|
33
33
|
import { listAgentPresetCatalog } from '../../../../src/channels/shared/agent-preset.mjs';
|
|
34
34
|
import { listModelCatalog } from '../../../../src/channels/shared/model-setting.mjs';
|
|
35
|
-
import { createDeliveryAdapter } from '../../delivery-adapter.mjs';
|
|
35
|
+
import { createDeliveryAdapter, configuredSessionSyncTargets, sessionSyncTarget } from '../../delivery-adapter.mjs';
|
|
36
36
|
import {
|
|
37
37
|
accessPolicyProvider,
|
|
38
38
|
initialAccessPolicyFor,
|
|
@@ -173,16 +173,23 @@ export async function createProductionController(ctx, config = {}, internals = {
|
|
|
173
173
|
const sessionSyncTargetsFor = async (sessionId) => {
|
|
174
174
|
if (typeof workspaces.listSessionSyncTargets !== 'function') return [];
|
|
175
175
|
const matches = [];
|
|
176
|
-
for (const entry of workspaces
|
|
176
|
+
for (const entry of configuredSessionSyncTargets(workspaces)) {
|
|
177
177
|
let state;
|
|
178
178
|
try {
|
|
179
179
|
state = await stateForBotId(entry.botId);
|
|
180
180
|
} catch {
|
|
181
181
|
continue;
|
|
182
182
|
}
|
|
183
|
-
|
|
183
|
+
let bound;
|
|
184
|
+
try {
|
|
185
|
+
bound = entry.dsBotId
|
|
186
|
+
? (await config.deliveryService?.dsBot?.resolve(entry.dsBotId))?.sessionId
|
|
187
|
+
: state?.snapshot?.().sessions?.[entry.conversationKey];
|
|
188
|
+
} catch {
|
|
189
|
+
continue;
|
|
190
|
+
}
|
|
184
191
|
if (bound !== sessionId) continue;
|
|
185
|
-
const target =
|
|
192
|
+
const target = sessionSyncTarget('feishu', workspaces, entry);
|
|
186
193
|
const openId = target?.route?.openId;
|
|
187
194
|
if (openId) matches.push({ openId, botId: entry.botId, targetId: entry.targetId });
|
|
188
195
|
}
|
|
@@ -235,6 +242,7 @@ export async function createProductionController(ctx, config = {}, internals = {
|
|
|
235
242
|
initialAccessPolicy: newBotAccessPolicyFor('feishu', botConfig),
|
|
236
243
|
});
|
|
237
244
|
const workspaceScope = createBotWorkspaceScope(harness, {
|
|
245
|
+
dsBot: config.deliveryService?.dsBot,
|
|
238
246
|
botId: id, workspaces, state, agentPresetCatalog,
|
|
239
247
|
});
|
|
240
248
|
// 语音是可选渠道能力:凭据读取失败时静默禁用,不阻断机器人连接。
|
|
@@ -319,7 +327,7 @@ export async function createProductionController(ctx, config = {}, internals = {
|
|
|
319
327
|
}).start();
|
|
320
328
|
return {
|
|
321
329
|
controller,
|
|
322
|
-
deliveryAdapter: createDeliveryAdapter({
|
|
330
|
+
deliveryAdapter: createDeliveryAdapter({ dsBot: config.deliveryService?.dsBot,
|
|
323
331
|
channel: 'feishu', workspaces, coreController, stateFor: stateForBotId,
|
|
324
332
|
}),
|
|
325
333
|
ready: supervisor.ready,
|
|
@@ -122,6 +122,7 @@ export async function createProductionController(ctx, config = {}, internals = {
|
|
|
122
122
|
initialAccessPolicy: newBotAccessPolicyFor('qq', botConfig),
|
|
123
123
|
});
|
|
124
124
|
const workspaceScope = createBotWorkspaceScope(harness, {
|
|
125
|
+
dsBot: config.deliveryService?.dsBot,
|
|
125
126
|
botId, workspaces, state, agentPresetCatalog,
|
|
126
127
|
});
|
|
127
128
|
return new Runtime({
|
|
@@ -173,7 +174,7 @@ export async function createProductionController(ctx, config = {}, internals = {
|
|
|
173
174
|
}).start();
|
|
174
175
|
return {
|
|
175
176
|
controller,
|
|
176
|
-
deliveryAdapter: createDeliveryAdapter({ channel: 'qq', workspaces, coreController, stateFor }),
|
|
177
|
+
deliveryAdapter: createDeliveryAdapter({ dsBot: config.deliveryService?.dsBot, channel: 'qq', workspaces, coreController, stateFor }),
|
|
177
178
|
ready: supervisor.ready,
|
|
178
179
|
async close() {
|
|
179
180
|
await supervisor.close();
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Management RPC for Telegram's per-group reply rules.
|
|
3
|
+
*
|
|
4
|
+
* Kept out of `TOKEN_BOT_ENDPOINTS`: those are shared by every token channel,
|
|
5
|
+
* and per-group triggers only exist for Telegram.
|
|
6
|
+
*/
|
|
7
|
+
import { normalizeGroupTriggers } from '../../../../src/channels/telegram/group-triggers.mjs';
|
|
8
|
+
|
|
9
|
+
export const GROUP_TRIGGERS_ENDPOINTS = Object.freeze({
|
|
10
|
+
get: 'bot.group-triggers.get',
|
|
11
|
+
set: 'bot.group-triggers.set',
|
|
12
|
+
resolve: 'bot.group-triggers.resolve',
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
const ENDPOINTS = Object.freeze(Object.values(GROUP_TRIGGERS_ENDPOINTS));
|
|
16
|
+
const BOT_ID = /^[A-Za-z0-9_-]{1,128}$/;
|
|
17
|
+
const MAX_REFERENCE_LENGTH = 2_048;
|
|
18
|
+
|
|
19
|
+
function isRecord(value) {
|
|
20
|
+
return value !== null && typeof value === 'object' && !Array.isArray(value);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function exactKeys(value, allowed) {
|
|
24
|
+
return isRecord(value) && Object.keys(value).every((key) => allowed.includes(key));
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function validBotId(value) {
|
|
28
|
+
return typeof value === 'string' && BOT_ID.test(value);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function validRemoved(value) {
|
|
32
|
+
return value === undefined || (Array.isArray(value)
|
|
33
|
+
&& value.every((entry) => typeof entry === 'string' && entry.trim().length > 0 && entry.length <= 64));
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/** Normalized rules, or null when the payload cannot be saved. */
|
|
37
|
+
export function validGroupTriggersConfig(value) {
|
|
38
|
+
try {
|
|
39
|
+
return normalizeGroupTriggers(value);
|
|
40
|
+
} catch {
|
|
41
|
+
return null;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export function validGroupTriggersPayload(endpoint, payload) {
|
|
46
|
+
if (!isRecord(payload)) return false;
|
|
47
|
+
if (endpoint === GROUP_TRIGGERS_ENDPOINTS.get) {
|
|
48
|
+
return exactKeys(payload, ['botId']) && validBotId(payload.botId);
|
|
49
|
+
}
|
|
50
|
+
if (endpoint === GROUP_TRIGGERS_ENDPOINTS.set) {
|
|
51
|
+
return exactKeys(payload, ['botId', 'config', 'removed'])
|
|
52
|
+
&& validBotId(payload.botId)
|
|
53
|
+
&& validGroupTriggersConfig(payload.config) !== null
|
|
54
|
+
&& validRemoved(payload.removed);
|
|
55
|
+
}
|
|
56
|
+
return exactKeys(payload, ['botId', 'input'])
|
|
57
|
+
&& validBotId(payload.botId)
|
|
58
|
+
&& typeof payload.input === 'string'
|
|
59
|
+
&& payload.input.trim().length > 0
|
|
60
|
+
&& payload.input.length <= MAX_REFERENCE_LENGTH;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
function operationError(error) {
|
|
64
|
+
if (error?.code === 'group-triggers-invalid') {
|
|
65
|
+
return { code: 'group-triggers-invalid', message: error.message };
|
|
66
|
+
}
|
|
67
|
+
return {
|
|
68
|
+
code: 'group-triggers-failed',
|
|
69
|
+
message: typeof error?.message === 'string' && error.message
|
|
70
|
+
? error.message : 'Group trigger settings are unavailable.',
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Handle one of the group-trigger endpoints.
|
|
76
|
+
*
|
|
77
|
+
* Returns null for any other endpoint so the caller can fall through to the
|
|
78
|
+
* regular token-bot handler.
|
|
79
|
+
*/
|
|
80
|
+
export function createGroupTriggersRpcHandler(controller) {
|
|
81
|
+
return async (endpoint, payload, signal) => {
|
|
82
|
+
if (!ENDPOINTS.includes(endpoint)) return null;
|
|
83
|
+
if (signal?.aborted) {
|
|
84
|
+
return { ok: false, error: { code: 'cancelled', message: 'The request was cancelled.' } };
|
|
85
|
+
}
|
|
86
|
+
if (!validGroupTriggersPayload(endpoint, payload)) {
|
|
87
|
+
return { ok: false, error: { code: 'bad-request', message: 'Invalid group trigger request.' } };
|
|
88
|
+
}
|
|
89
|
+
try {
|
|
90
|
+
if (endpoint === GROUP_TRIGGERS_ENDPOINTS.get) {
|
|
91
|
+
if (typeof controller.groupTriggersPanel !== 'function') throw new Error('Group trigger settings are unavailable.');
|
|
92
|
+
return { ok: true, value: await controller.groupTriggersPanel(payload.botId) };
|
|
93
|
+
}
|
|
94
|
+
if (endpoint === GROUP_TRIGGERS_ENDPOINTS.set) {
|
|
95
|
+
if (typeof controller.updateGroupTriggers !== 'function') throw new Error('Group trigger settings are unavailable.');
|
|
96
|
+
return {
|
|
97
|
+
ok: true,
|
|
98
|
+
value: await controller.updateGroupTriggers(payload.botId, {
|
|
99
|
+
config: payload.config,
|
|
100
|
+
removed: payload.removed ?? [],
|
|
101
|
+
}),
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
if (typeof controller.resolveGroupTrigger !== 'function') throw new Error('Group lookup is unavailable.');
|
|
105
|
+
return { ok: true, value: await controller.resolveGroupTrigger(payload.botId, payload.input) };
|
|
106
|
+
} catch (error) {
|
|
107
|
+
return { ok: false, error: operationError(error) };
|
|
108
|
+
}
|
|
109
|
+
};
|
|
110
|
+
}
|
|
@@ -135,6 +135,11 @@ export async function createTokenProductionController(ctx, config, internals, de
|
|
|
135
135
|
const coreController = new ResolvedController({
|
|
136
136
|
credentials: ctx.credentials,
|
|
137
137
|
configStore: observedConfigStore,
|
|
138
|
+
// Channel settings scoped per chat need the archived group list (titles and
|
|
139
|
+
// real chat IDs) to offer something better than a blank form.
|
|
140
|
+
...(definitions.controllerGroupHistory ? {
|
|
141
|
+
groupHistory: internals.groupHistory ?? getGroupHistoryStore(ctx, config),
|
|
142
|
+
} : {}),
|
|
138
143
|
logger,
|
|
139
144
|
...(internals.inspectToken ? { inspectToken: internals.inspectToken } : {}),
|
|
140
145
|
// Optional per-channel hook: a channel whose own settings also express an
|
|
@@ -162,6 +167,7 @@ export async function createTokenProductionController(ctx, config, internals, de
|
|
|
162
167
|
const state = await stateFor(botId);
|
|
163
168
|
await ensureWorkspace(botId, botConfig);
|
|
164
169
|
const workspaceScope = createBotWorkspaceScope(harness, {
|
|
170
|
+
dsBot: config.deliveryService?.dsBot,
|
|
165
171
|
botId, workspaces, state, agentPresetCatalog,
|
|
166
172
|
});
|
|
167
173
|
const persistTokens = typeof definitions.persistBotCredential === 'function'
|
|
@@ -183,6 +189,11 @@ export async function createTokenProductionController(ctx, config, internals, de
|
|
|
183
189
|
harness: workspaceScope.harness,
|
|
184
190
|
state: workspaceScope.state,
|
|
185
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
|
+
: {}),
|
|
186
197
|
contextEnhancement: { botId, getSettings: () => workspaces.contextEnhancementFor(botId) },
|
|
187
198
|
accessPolicy: accessPolicyProvider(workspaces, botId, { channel, config: botConfig }),
|
|
188
199
|
replyTimeoutMs: config.replyTimeoutMs ?? 600_000,
|
|
@@ -227,7 +238,7 @@ export async function createTokenProductionController(ctx, config, internals, de
|
|
|
227
238
|
return {
|
|
228
239
|
controller,
|
|
229
240
|
...(supportsDeliveryChannel(channel) ? {
|
|
230
|
-
deliveryAdapter: createDeliveryAdapter({ channel, workspaces, coreController, stateFor }),
|
|
241
|
+
deliveryAdapter: createDeliveryAdapter({ dsBot: config.deliveryService?.dsBot, channel, workspaces, coreController, stateFor }),
|
|
231
242
|
} : {}),
|
|
232
243
|
ready: supervisor.ready,
|
|
233
244
|
async close() {
|
|
@@ -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
|
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export { SET_SEND_LIMIT_ENDPOINT } from '../../../../src/channels/shared/send-limit.mjs';
|
|
2
|
+
|
|
3
|
+
export function validSendLimitPayload(payload) {
|
|
4
|
+
if (!payload || typeof payload !== 'object' || Array.isArray(payload)
|
|
5
|
+
|| Reflect.ownKeys(payload).length !== 2
|
|
6
|
+
|| !Object.hasOwn(payload, 'botId') || !Object.hasOwn(payload, 'sendLimitPerMinute')
|
|
7
|
+
|| typeof payload.botId !== 'string'
|
|
8
|
+
|| !/^[A-Za-z0-9_-]{1,128}$/.test(payload.botId)) return false;
|
|
9
|
+
// The value is only checked for shape: the controller clamps it, so a bad
|
|
10
|
+
// form entry can never leave a bot unusable.
|
|
11
|
+
const value = payload.sendLimitPerMinute;
|
|
12
|
+
return typeof value === 'number' || typeof value === 'string';
|
|
13
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export { SET_THINKING_CADENCE_ENDPOINT } from '../../../../src/channels/shared/thinking-cadence.mjs';
|
|
2
|
+
|
|
3
|
+
export function validThinkingCadencePayload(payload) {
|
|
4
|
+
if (!payload || typeof payload !== 'object' || Array.isArray(payload)
|
|
5
|
+
|| Reflect.ownKeys(payload).length !== 3
|
|
6
|
+
|| !Object.hasOwn(payload, 'botId')
|
|
7
|
+
|| !Object.hasOwn(payload, 'thinkingNumbering')
|
|
8
|
+
|| !Object.hasOwn(payload, 'thinkingIntervalSeconds')
|
|
9
|
+
|| typeof payload.botId !== 'string'
|
|
10
|
+
|| !/^[A-Za-z0-9_-]{1,128}$/.test(payload.botId)
|
|
11
|
+
|| typeof payload.thinkingNumbering !== 'boolean') return false;
|
|
12
|
+
// The interval is only checked for shape: the controller clamps it, so a bad
|
|
13
|
+
// form entry can never leave a bot stuck at an unusable pace.
|
|
14
|
+
const value = payload.thinkingIntervalSeconds;
|
|
15
|
+
return typeof value === 'number' || typeof value === 'string';
|
|
16
|
+
}
|