@xmanrui/dsh-im 5.4.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/lib/client.js +2293 -444
- package/lib/index.js +402 -335
- 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/styles.js +4 -0
- package/plugin-src/client/channels/telegram/thinking-traces.js +138 -5
- package/plugin-src/client/delivery-settings.js +2 -2
- package/plugin-src/client/i18n-ru.js +1615 -0
- package/plugin-src/client/i18n.js +71 -0
- 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 +17 -5
- package/src/channels/feishu/bridge.mjs +83 -5
- 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/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/harness-client.mjs +5 -4
- 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 +2 -2
- package/src/channels/shared/i18n-en/shared-c.mjs +3 -2
- 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-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/telegram/config-store.mjs +34 -1
- package/src/channels/telegram/telegram-api.mjs +211 -32
- package/src/channels/telegram/telegram-bridge.mjs +4 -1
- package/src/channels/telegram/telegram-controller.mjs +29 -0
- package/src/channels/telegram/telegram-runtime.mjs +507 -176
- package/src/channels/telegram/voice.mjs +250 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xmanrui/dsh-im",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.5.0",
|
|
4
4
|
"icon": "./assets/logo-plugin-message-link-gradient.webp",
|
|
5
5
|
"description": "把微信、飞书、企微、钉钉、QQ、Telegram、WhatsApp、Slack、Discord、Matrix接入DSH。 Connect Telegram, WhatsApp, Slack, Discord, Matrix, WeChat, Feishu, WeCom, DingTalk, and QQ to DSH.",
|
|
6
6
|
"keywords": [
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ConnectionError } from './connection-error.js';
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
|
|
4
|
-
import { h,
|
|
4
|
+
import { h, imLocale } from './i18n.js';
|
|
5
5
|
|
|
6
6
|
export const BotSettingsContext = React.createContext(Object.freeze({
|
|
7
7
|
openBotSettings() {},
|
|
@@ -50,9 +50,13 @@ export function BotSettingsButton({
|
|
|
50
50
|
h('span', { className: 'dim-moreSettingsChevron', 'aria-hidden': 'true' })));
|
|
51
51
|
}
|
|
52
52
|
|
|
53
|
+
// Date formatting follows the interface language, not English-vs-not: a
|
|
54
|
+
// Russian reader is served ru-RU numerals and month names, not Chinese ones.
|
|
55
|
+
const INTL_LOCALES = Object.freeze({ zh: 'zh-CN', en: 'en-US', ru: 'ru-RU' });
|
|
56
|
+
|
|
53
57
|
function messageErrorTime(value) {
|
|
54
58
|
try {
|
|
55
|
-
return new Intl.DateTimeFormat(
|
|
59
|
+
return new Intl.DateTimeFormat(INTL_LOCALES[imLocale()] ?? 'en-US', {
|
|
56
60
|
year: 'numeric',
|
|
57
61
|
month: '2-digit',
|
|
58
62
|
day: '2-digit',
|
|
@@ -6,6 +6,12 @@ import { normalizeModelCatalog, normalizeModelSelection, SET_MODEL_ENDPOINT } fr
|
|
|
6
6
|
import { normalizeLastMessageError } from '../../last-message-error.js';
|
|
7
7
|
import { normalizeAccessPolicy } from '../../../../src/channels/shared/access-policy.mjs';
|
|
8
8
|
import { normalizeContextEnhancementConfig } from '../../../../src/channels/shared/context-enhancement.mjs';
|
|
9
|
+
import {
|
|
10
|
+
normalizeThinkingIntervalSeconds,
|
|
11
|
+
normalizeThinkingNumbering,
|
|
12
|
+
SET_THINKING_CADENCE_ENDPOINT,
|
|
13
|
+
} from '../../../../src/channels/shared/thinking-cadence.mjs';
|
|
14
|
+
import { normalizeSendLimitPerMinute, SET_SEND_LIMIT_ENDPOINT } from '../../../../src/channels/shared/send-limit.mjs';
|
|
9
15
|
|
|
10
16
|
const ACCOUNT_STATES = new Set(['connected', 'connecting', 'offline', 'error']);
|
|
11
17
|
|
|
@@ -41,6 +47,8 @@ export const TOKEN_BOT_ENDPOINTS = Object.freeze({
|
|
|
41
47
|
setAccessPolicy: 'bot.access-policy.set',
|
|
42
48
|
setAlias: 'bot.alias.set',
|
|
43
49
|
setThinkingTraces: 'bot.thinking-traces.set',
|
|
50
|
+
setThinkingCadence: SET_THINKING_CADENCE_ENDPOINT,
|
|
51
|
+
setSendLimit: SET_SEND_LIMIT_ENDPOINT,
|
|
44
52
|
});
|
|
45
53
|
|
|
46
54
|
export function createTokenChannelApi(channel, connectionSummary, {
|
|
@@ -74,6 +82,11 @@ export function createTokenChannelApi(channel, connectionSummary, {
|
|
|
74
82
|
busyMessageMode: normalizeBusyMessageMode(value.busyMessageMode), contextEnhancement: normalizeContextEnhancementConfig(value.contextEnhancement),
|
|
75
83
|
// Absent from the backend means ON; only an explicit false opts out.
|
|
76
84
|
thinkingTraces: value.thinkingTraces !== false,
|
|
85
|
+
// Absent or unusable falls back to the same defaults the backend applies.
|
|
86
|
+
thinkingNumbering: normalizeThinkingNumbering(value.thinkingNumbering),
|
|
87
|
+
thinkingIntervalSeconds: normalizeThinkingIntervalSeconds(value.thinkingIntervalSeconds),
|
|
88
|
+
// Absent or unusable falls back to the same default the backend applies.
|
|
89
|
+
sendLimitPerMinute: normalizeSendLimitPerMinute(value.sendLimitPerMinute),
|
|
77
90
|
...(Object.hasOwn(value, 'accessPolicy')
|
|
78
91
|
? { accessPolicy: normalizeAccessPolicy(value.accessPolicy) }
|
|
79
92
|
: {}),
|
|
@@ -15,6 +15,10 @@ const CSS = String.raw`
|
|
|
15
15
|
.dim-accountSettingsSwitch:checked { border-color: #229ed9; background: #229ed9; }
|
|
16
16
|
.dim-accountSettingsSwitch:checked::before { transform: translateX(13px); background: #fff; }
|
|
17
17
|
.dim-accountSettingsSwitch:disabled { opacity: 0.5; cursor: not-allowed; }
|
|
18
|
+
.dim-accountSettingsSelect { flex: none; min-width: 0; max-width: 60%; margin: 0; padding: 4px 6px; border: 1px solid var(--dsw-alias-border-l2, #dfe1e5); border-radius: 6px; background: var(--dsw-alias-bg-layer-1, #fff); color: var(--dsw-alias-label-primary, #1f2329); font: inherit; font-size: 13px; line-height: 20px; }
|
|
19
|
+
.dim-accountSettingsSelect:disabled { opacity: 0.5; cursor: not-allowed; }
|
|
20
|
+
.dim-accountSettingsNumber { appearance: textfield; flex: none; width: 64px; margin: 0; padding: 4px 6px; border: 1px solid var(--dsw-alias-border-l2, #dfe1e5); border-radius: 6px; background: var(--dsw-alias-bg-layer-1, #fff); color: var(--dsw-alias-label-primary, #1f2329); font: inherit; font-size: 13px; line-height: 20px; text-align: center; }
|
|
21
|
+
.dim-accountSettingsNumber:disabled { opacity: 0.5; cursor: not-allowed; }
|
|
18
22
|
@media (prefers-reduced-motion: reduce) { .dim-accountSettingsSwitch::before { transition: none; } }
|
|
19
23
|
`;
|
|
20
24
|
|
|
@@ -1,13 +1,112 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* 会话行为设置块:思考过程留痕、帧编号、帧节奏与消息发送上限(Telegram 专属)。
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
4
|
+
* 开启留痕后,机器人把 agent 的推理与工具调用作为独立的 💭/🔧 消息实时发出来,
|
|
5
|
+
* 最终答案单独成条;关闭留痕后使用常规占位符进度,完成时删除占位符并发送答案。
|
|
6
|
+
* 一轮里可能产生几十帧,所以另外两个设置决定这串消息的样子:编号让顺序可见,
|
|
7
|
+
* 节奏把突发合并成最新一帧,而不是排一队过期的消息。
|
|
6
8
|
*/
|
|
9
|
+
import { normalizeThinkingIntervalSeconds } from '../../../../src/channels/shared/thinking-cadence.mjs';
|
|
10
|
+
import { DEFAULT_SEND_LIMIT_PER_MINUTE } from '../../../../src/channels/shared/send-limit.mjs';
|
|
7
11
|
import { h } from '../../i18n.js';
|
|
12
|
+
import * as React from 'react';
|
|
8
13
|
|
|
9
|
-
|
|
14
|
+
/** 0 表示不限制;其余是常见的步长,最大一分钟。 */
|
|
15
|
+
export const THINKING_INTERVAL_OPTIONS = Object.freeze([
|
|
16
|
+
0, 1, 2, 3, 5, 7, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60,
|
|
17
|
+
]);
|
|
18
|
+
|
|
19
|
+
/** 配置里可能存着列表外的值(旧配置或手工编辑),补一个选项而不是静默改成 0。 */
|
|
20
|
+
function intervalValues(saved) {
|
|
21
|
+
if (THINKING_INTERVAL_OPTIONS.includes(saved)) return THINKING_INTERVAL_OPTIONS;
|
|
22
|
+
return [...THINKING_INTERVAL_OPTIONS, saved].sort((left, right) => left - right);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function SendLimitField({ account, busy, saving, onCommit }) {
|
|
26
|
+
const saved = Number.isInteger(account.sendLimitPerMinute)
|
|
27
|
+
? account.sendLimitPerMinute
|
|
28
|
+
: DEFAULT_SEND_LIMIT_PER_MINUTE;
|
|
29
|
+
const [value, setValue] = React.useState(String(saved));
|
|
30
|
+
// A save from another tab, or a reconnect, rewrites the stored value.
|
|
31
|
+
React.useEffect(() => { setValue(String(saved)); }, [saved]);
|
|
32
|
+
const commit = () => {
|
|
33
|
+
const numeric = Number(value.trim());
|
|
34
|
+
if (!value.trim() || !Number.isFinite(numeric) || Math.round(numeric) === saved) {
|
|
35
|
+
setValue(String(saved));
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
onCommit?.(Math.round(numeric));
|
|
39
|
+
};
|
|
40
|
+
return h('label', { className: 'dim-accountSettingsRow' },
|
|
41
|
+
h('span', { className: 'dim-accountSettingsText' },
|
|
42
|
+
h('span', { className: 'dim-accountSettingsLabel' }, '消息发送上限'),
|
|
43
|
+
h('span', { className: 'dim-accountSettingsHelp' },
|
|
44
|
+
'每个聊天每分钟的消息数;机器人会等待而不是丢弃')),
|
|
45
|
+
h('input', {
|
|
46
|
+
type: 'number',
|
|
47
|
+
min: 1,
|
|
48
|
+
max: 30,
|
|
49
|
+
step: 1,
|
|
50
|
+
className: 'dim-accountSettingsNumber',
|
|
51
|
+
value,
|
|
52
|
+
disabled: Boolean(busy) || saving,
|
|
53
|
+
onChange: (event) => { setValue(event.target.value); },
|
|
54
|
+
onBlur: commit,
|
|
55
|
+
onKeyDown: (event) => {
|
|
56
|
+
if (event.key !== 'Enter') return;
|
|
57
|
+
event.preventDefault();
|
|
58
|
+
commit();
|
|
59
|
+
},
|
|
60
|
+
}));
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export function ThinkingTracesSettings({
|
|
64
|
+
account, busy, onSave, rpcCall, endpoints, onChanged,
|
|
65
|
+
}) {
|
|
10
66
|
const checked = account.thinkingTraces !== false;
|
|
67
|
+
const storedNumbering = account.thinkingNumbering === true;
|
|
68
|
+
const storedInterval = normalizeThinkingIntervalSeconds(account.thinkingIntervalSeconds);
|
|
69
|
+
// 两个新控件共用一个 RPC,所以各自提交时都要带上对方的当前值。
|
|
70
|
+
const [draft, setDraft] = React.useState({
|
|
71
|
+
thinkingNumbering: storedNumbering,
|
|
72
|
+
thinkingIntervalSeconds: storedInterval,
|
|
73
|
+
});
|
|
74
|
+
// 另一个标签页保存过、或重连之后,服务端存的值才是准的。
|
|
75
|
+
React.useEffect(() => {
|
|
76
|
+
setDraft({ thinkingNumbering: storedNumbering, thinkingIntervalSeconds: storedInterval });
|
|
77
|
+
}, [storedNumbering, storedInterval]);
|
|
78
|
+
const [saving, setSaving] = React.useState(false);
|
|
79
|
+
const endpoint = endpoints?.setThinkingCadence;
|
|
80
|
+
const commit = async (patch) => {
|
|
81
|
+
if (typeof rpcCall !== 'function' || !endpoint) return;
|
|
82
|
+
const next = { ...draft, ...patch };
|
|
83
|
+
setDraft(next);
|
|
84
|
+
setSaving(true);
|
|
85
|
+
try {
|
|
86
|
+
const response = await rpcCall(endpoint, { botId: account.botId, ...next });
|
|
87
|
+
if (response && response.ok === false) throw new Error(response.error?.message ?? '请求失败');
|
|
88
|
+
await onChanged?.({ silent: true });
|
|
89
|
+
} catch {
|
|
90
|
+
// 服务端存的值仍然作准:界面回到它,免得显示一个没保存的节奏。
|
|
91
|
+
setDraft({ thinkingNumbering: storedNumbering, thinkingIntervalSeconds: storedInterval });
|
|
92
|
+
} finally {
|
|
93
|
+
setSaving(false);
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
const sendLimitEndpoint = endpoints?.setSendLimit;
|
|
97
|
+
const commitSendLimit = async (sendLimitPerMinute) => {
|
|
98
|
+
if (typeof rpcCall !== 'function' || !sendLimitEndpoint) return;
|
|
99
|
+
setSaving(true);
|
|
100
|
+
try {
|
|
101
|
+
const response = await rpcCall(sendLimitEndpoint, { botId: account.botId, sendLimitPerMinute });
|
|
102
|
+
if (response && response.ok === false) throw new Error(response.error?.message ?? '请求失败');
|
|
103
|
+
await onChanged?.({ silent: true });
|
|
104
|
+
} catch {
|
|
105
|
+
// The stored value stays authoritative; the next reload shows it again.
|
|
106
|
+
} finally {
|
|
107
|
+
setSaving(false);
|
|
108
|
+
}
|
|
109
|
+
};
|
|
11
110
|
return h('div', { className: 'dim-accountSettings' },
|
|
12
111
|
h('h4', { className: 'dim-accountSettingsTitle' }, '会话行为'),
|
|
13
112
|
h('label', { className: 'dim-accountSettingsRow' },
|
|
@@ -21,5 +120,39 @@ export function ThinkingTracesSettings({ account, busy, onSave }) {
|
|
|
21
120
|
checked,
|
|
22
121
|
disabled: Boolean(busy),
|
|
23
122
|
onChange: (event) => { onSave?.({ thinkingTraces: event.target.checked }); },
|
|
24
|
-
}))
|
|
123
|
+
})),
|
|
124
|
+
h('label', { className: 'dim-accountSettingsRow' },
|
|
125
|
+
h('span', { className: 'dim-accountSettingsText' },
|
|
126
|
+
h('span', { className: 'dim-accountSettingsLabel' }, '编号思考帧'),
|
|
127
|
+
h('span', { className: 'dim-accountSettingsHelp' },
|
|
128
|
+
'在每帧前加上本轮序号;被节奏跳过的帧也计数,所以编号会跳号(需先打开思考过程留痕)')),
|
|
129
|
+
h('input', {
|
|
130
|
+
type: 'checkbox',
|
|
131
|
+
className: 'dim-accountSettingsSwitch',
|
|
132
|
+
checked: draft.thinkingNumbering,
|
|
133
|
+
disabled: Boolean(busy) || saving,
|
|
134
|
+
onChange: (event) => { void commit({ thinkingNumbering: event.target.checked }); },
|
|
135
|
+
})),
|
|
136
|
+
h('label', { className: 'dim-accountSettingsRow' },
|
|
137
|
+
h('span', { className: 'dim-accountSettingsText' },
|
|
138
|
+
h('span', { className: 'dim-accountSettingsLabel' }, '最多每隔多久发送一帧(秒)'),
|
|
139
|
+
h('span', { className: 'dim-accountSettingsHelp' },
|
|
140
|
+
'突发时只发送窗口里最新的一帧,过期的帧丢弃,不排队也不重发')),
|
|
141
|
+
h('select', {
|
|
142
|
+
className: 'dim-accountSettingsSelect',
|
|
143
|
+
value: String(draft.thinkingIntervalSeconds),
|
|
144
|
+
disabled: Boolean(busy) || saving,
|
|
145
|
+
onChange: (event) => {
|
|
146
|
+
void commit({ thinkingIntervalSeconds: Number(event.target.value) });
|
|
147
|
+
},
|
|
148
|
+
}, intervalValues(draft.thinkingIntervalSeconds).map((value) => h('option', {
|
|
149
|
+
key: value,
|
|
150
|
+
value: String(value),
|
|
151
|
+
}, value === 0 ? '不限制(0)' : String(value))))),
|
|
152
|
+
h(SendLimitField, {
|
|
153
|
+
account,
|
|
154
|
+
busy: Boolean(busy),
|
|
155
|
+
saving,
|
|
156
|
+
onCommit: commitSendLimit,
|
|
157
|
+
}));
|
|
25
158
|
}
|
|
@@ -8,7 +8,7 @@ import { FeishuGroupSettingsPage } from './channels/feishu/group-settings.js';
|
|
|
8
8
|
import { FeishuVoiceSettingsPage } from './channels/feishu/voice-settings.js';
|
|
9
9
|
import { FeishuSlashPanelSettingsPage } from './channels/feishu/slash-panel-settings.js';
|
|
10
10
|
import { TelegramGroupTriggersSettings } from './channels/telegram/group-triggers-settings.js';
|
|
11
|
-
import { h,
|
|
11
|
+
import { h, imLocale, localizeText } from './i18n.js';
|
|
12
12
|
|
|
13
13
|
export const DELIVERY_RPC_CHANNEL = '/dsh-im-delivery';
|
|
14
14
|
|
|
@@ -833,7 +833,7 @@ export function DeliveryTargetSettingsPage({
|
|
|
833
833
|
account.botName || '机器人设置'),
|
|
834
834
|
h('a', {
|
|
835
835
|
className: 'dim-deliveryDocsLink',
|
|
836
|
-
href:
|
|
836
|
+
href: imLocale() === 'zh' ? DELIVERY_DOCS_URL.zh : DELIVERY_DOCS_URL.en,
|
|
837
837
|
target: '_blank',
|
|
838
838
|
rel: 'noopener noreferrer',
|
|
839
839
|
'aria-label': '打开主动投递使用文档',
|