@xmanrui/dsh-im 5.5.0 → 5.7.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/README.en.md +24 -8
- package/README.md +24 -8
- package/assets/sponsors/88api.jpg +0 -0
- package/lib/client.js +328 -243
- package/lib/index.js +317 -317
- package/package.json +4 -4
- 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 +12 -7
- package/plugin-src/client/channels/shared/token-channel.js +18 -11
- 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 +12 -3
- 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 +57 -34
- package/plugin-src/client/i18n.js +211 -124
- package/plugin-src/client/session-channel-logos.js +8 -0
- package/plugin-src/host/delivery-suggestions.mjs +2 -0
- package/plugin-src/host/update-service.mjs +44 -13
- package/scripts/verify-package.mjs +1 -1
- package/src/channels/dingtalk/dingtalk-bridge.mjs +1 -0
- package/src/channels/feishu/bridge.mjs +25 -3
- package/src/channels/feishu/feishu-cards.mjs +1 -45
- package/src/channels/feishu/feishu-runtime.mjs +13 -1
- package/src/channels/feishu/slash-command-panel.mjs +2 -5
- package/src/channels/qq/markdown-reply.mjs +5 -2
- package/src/channels/qq/qq-bridge.mjs +42 -2
- package/src/channels/shared/bot-workspace-store.mjs +1 -1
- package/src/channels/shared/command-catalog.mjs +8 -5
- 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 +12 -6
- package/src/channels/shared/i18n-en/shared-b.mjs +5 -0
- package/src/channels/shared/i18n-en/shared-c.mjs +3 -0
- package/src/channels/shared/i18n-en/telegram.mjs +6 -0
- package/src/channels/shared/i18n-ru/shared-b.mjs +5 -0
- package/src/channels/shared/i18n-ru/shared-c.mjs +3 -0
- package/src/channels/shared/i18n-ru/telegram.mjs +5 -0
- package/src/channels/shared/message-failure.mjs +5 -2
- package/src/channels/shared/session-error.mjs +8 -0
- package/src/channels/shared/text-harness-bridge.mjs +201 -3
- package/src/channels/shared/workspace-command.mjs +41 -16
- package/src/channels/shared/workspace-labels.mjs +65 -0
- package/src/channels/shared/workspace-session.mjs +24 -4
- package/src/channels/slack/slack-api.mjs +21 -5
- package/src/channels/slack/slack-runtime.mjs +69 -20
- package/src/channels/telegram/telegram-api.mjs +31 -2
- package/src/channels/telegram/telegram-bridge.mjs +58 -0
- package/src/channels/telegram/telegram-runtime.mjs +85 -3
- package/src/channels/wecom/wecom-bridge.mjs +1 -0
- package/src/channels/wecom/wecom-controller.mjs +89 -1
- package/src/channels/wecom-app/wecom-app-bridge.mjs +1 -0
- package/src/channels/weixin/weixin-bridge.mjs +1 -0
|
@@ -145,6 +145,8 @@ const UNWATCH_COMMAND = /^\/unwatch(?:\s+([^\s]+))?$/i;
|
|
|
145
145
|
const WATCHLIST_COMMAND = /^\/watchlist$/i;
|
|
146
146
|
const SESSION_LIST_PREFIX = /^\/(?:sessionlist|sessions)(?:\s|$)/i;
|
|
147
147
|
const WORKSPACE_LIST_COMMAND = /^\/(?:workspacelist|workspaces|wsl)$/i;
|
|
148
|
+
// After the merge a bare /workspace or /ws opens the same picker card.
|
|
149
|
+
const BARE_WORKSPACE_COMMAND = /^\/(?:workspace|ws)$/i;
|
|
148
150
|
const NUMBER_REPLY = /^\d{1,2}$/;
|
|
149
151
|
/** A displayed menu stays number-tappable for this long. */
|
|
150
152
|
const MENU_TTL_MS = 10 * 60_000;
|
|
@@ -1894,7 +1896,7 @@ export class FeishuHarnessBridge {
|
|
|
1894
1896
|
);
|
|
1895
1897
|
return;
|
|
1896
1898
|
}
|
|
1897
|
-
if (WORKSPACE_LIST_COMMAND.test(commandText)) {
|
|
1899
|
+
if (BARE_WORKSPACE_COMMAND.test(commandText) || WORKSPACE_LIST_COMMAND.test(commandText)) {
|
|
1898
1900
|
await this.#showWorkspaces({ chatId: event.message.chat_id, key, replyTo: event.message.message_id });
|
|
1899
1901
|
return;
|
|
1900
1902
|
}
|
|
@@ -2016,7 +2018,12 @@ export class FeishuHarnessBridge {
|
|
|
2016
2018
|
}
|
|
2017
2019
|
throw error;
|
|
2018
2020
|
} finally {
|
|
2019
|
-
|
|
2021
|
+
// Synced questions (including DS Bot's ask_user) outlive the turn that
|
|
2022
|
+
// presented them. Only turn-owned questions belong to this cleanup;
|
|
2023
|
+
// their failed-delivery/error paths must still resolve by cancellation.
|
|
2024
|
+
if (this.#pendingInteractions.get(key)?.lifecycle !== 'session-sync') {
|
|
2025
|
+
await this.#cancelPendingInteraction(key);
|
|
2026
|
+
}
|
|
2020
2027
|
await this.#approvals.closeRoute(key);
|
|
2021
2028
|
this.#voiceTurns.delete(key);
|
|
2022
2029
|
}
|
|
@@ -5564,6 +5571,7 @@ export class FeishuHarnessBridge {
|
|
|
5564
5571
|
let completed;
|
|
5565
5572
|
try {
|
|
5566
5573
|
completed = await askInWorkspaceSession({
|
|
5574
|
+
onNotice: (notice) => this.#send(chatId, notice, { replyTo: messageId }),
|
|
5567
5575
|
deferredDelivery: () => ({ coordinator: this.#deferred, chatId, replyToMessageId: messageId }),
|
|
5568
5576
|
harness: this.#harness,
|
|
5569
5577
|
state: this.#state,
|
|
@@ -5814,6 +5822,7 @@ export class FeishuHarnessBridge {
|
|
|
5814
5822
|
const { content, contextEnhanced } = prompt;
|
|
5815
5823
|
if (!this.#channel?.stream) {
|
|
5816
5824
|
const { sessionId, answer, artifacts = [] } = await askInWorkspaceSession({
|
|
5825
|
+
onNotice: (notice) => this.#send(chatId, notice, { replyTo: messageId }),
|
|
5817
5826
|
deferredDelivery: () => ({ coordinator: this.#deferred, chatId, replyToMessageId: messageId }),
|
|
5818
5827
|
harness: this.#harness,
|
|
5819
5828
|
state: this.#state,
|
|
@@ -5897,6 +5906,7 @@ export class FeishuHarnessBridge {
|
|
|
5897
5906
|
},
|
|
5898
5907
|
};
|
|
5899
5908
|
const completed = await askInWorkspaceSession({
|
|
5909
|
+
onNotice: (notice) => this.#send(chatId, notice, { replyTo: messageId }),
|
|
5900
5910
|
deferredDelivery: () => ({ coordinator: this.#deferred, chatId, replyToMessageId: messageId }),
|
|
5901
5911
|
harness: this.#harness,
|
|
5902
5912
|
state: this.#state,
|
|
@@ -5972,6 +5982,7 @@ export class FeishuHarnessBridge {
|
|
|
5972
5982
|
|
|
5973
5983
|
this.#logger.warn?.('[dsh-feishu] native stream unavailable; using text fallback:', error.message);
|
|
5974
5984
|
const { sessionId, answer, artifacts = [] } = await askInWorkspaceSession({
|
|
5985
|
+
onNotice: (notice) => this.#send(chatId, notice, { replyTo: messageId }),
|
|
5975
5986
|
deferredDelivery: () => ({ coordinator: this.#deferred, chatId, replyToMessageId: messageId }),
|
|
5976
5987
|
harness: this.#harness,
|
|
5977
5988
|
state: this.#state,
|
|
@@ -6322,7 +6333,9 @@ export class FeishuHarnessBridge {
|
|
|
6322
6333
|
Promise.resolve(completion).then(finish, finish);
|
|
6323
6334
|
try {
|
|
6324
6335
|
await validate();
|
|
6325
|
-
await this.#handleInteraction(interaction, {
|
|
6336
|
+
await this.#handleInteraction(interaction, {
|
|
6337
|
+
...context, validate, onClear: cleanup, lifecycle: 'session-sync',
|
|
6338
|
+
});
|
|
6326
6339
|
if (finished) finish(); // A completion during delivery must not leave a pending behind.
|
|
6327
6340
|
const available = !finished && this.#pendingInteractions.get(context.key)?.interactionId === interaction.interactionId;
|
|
6328
6341
|
if (!available) cleanup();
|
|
@@ -6342,6 +6355,7 @@ export class FeishuHarnessBridge {
|
|
|
6342
6355
|
receiveIdType,
|
|
6343
6356
|
validate,
|
|
6344
6357
|
onClear,
|
|
6358
|
+
lifecycle = 'turn',
|
|
6345
6359
|
}) {
|
|
6346
6360
|
if (await this.#approvals.handleRequested(interaction, this.#approvalContext({
|
|
6347
6361
|
key, actor, chatId, requiresMention, replyToMessageId,
|
|
@@ -6419,6 +6433,7 @@ export class FeishuHarnessBridge {
|
|
|
6419
6433
|
receiveIdType,
|
|
6420
6434
|
validate,
|
|
6421
6435
|
onClear,
|
|
6436
|
+
lifecycle,
|
|
6422
6437
|
queue: null,
|
|
6423
6438
|
claimedReplyMessageId: null,
|
|
6424
6439
|
submitting: false,
|
|
@@ -6568,6 +6583,13 @@ export class FeishuHarnessBridge {
|
|
|
6568
6583
|
if (!pending || pending.kind !== 'question') return;
|
|
6569
6584
|
this.#rememberResolvedInteraction(key, pending);
|
|
6570
6585
|
try {
|
|
6586
|
+
// A synced question is owned by its upstream provider, not this IM turn.
|
|
6587
|
+
// Withdraw the IM route so the provider also releases its delivery state;
|
|
6588
|
+
// DS Bot's answer endpoint does not accept a Harness cancellation answer.
|
|
6589
|
+
if (pending.lifecycle === 'session-sync' && pending.interaction.withdraw) {
|
|
6590
|
+
await pending.interaction.withdraw();
|
|
6591
|
+
return;
|
|
6592
|
+
}
|
|
6571
6593
|
await pending.interaction.respond({
|
|
6572
6594
|
ok: false,
|
|
6573
6595
|
error: {
|
|
@@ -14,8 +14,8 @@
|
|
|
14
14
|
* without button callbacks.
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
|
-
import { posix, win32 } from 'node:path';
|
|
18
17
|
import { t } from '../shared/i18n.mjs';
|
|
18
|
+
import { workspaceLabels } from '../shared/workspace-labels.mjs';
|
|
19
19
|
import { normalizeFeishuStepCardPanels } from './step-push-mode.mjs';
|
|
20
20
|
|
|
21
21
|
export const MENU_PAGE_SIZE = 10;
|
|
@@ -97,50 +97,6 @@ function safeTitle(value) {
|
|
|
97
97
|
return cleanTitle(value) || t('暂无标题');
|
|
98
98
|
}
|
|
99
99
|
|
|
100
|
-
const WORKSPACE_LABEL_LENGTH = 22;
|
|
101
|
-
|
|
102
|
-
/** Display labels only: paths and their snapshot order remain the callback identity. */
|
|
103
|
-
function workspaceLabels(paths, titles = {}) {
|
|
104
|
-
const entries = paths.map((path) => {
|
|
105
|
-
const api = /^[a-z]:[\\/]|^\\\\/iu.test(path) ? win32 : posix;
|
|
106
|
-
const normalized = api.normalize(path);
|
|
107
|
-
const name = cleanTitle(api.basename(normalized) || api.parse(normalized).root);
|
|
108
|
-
const base = (typeof titles[path] === 'string' && cleanTitle(titles[path])) || name;
|
|
109
|
-
return {
|
|
110
|
-
api, base, label: base, parent: api.dirname(normalized),
|
|
111
|
-
context: base === name ? '' : api.basename(normalized),
|
|
112
|
-
};
|
|
113
|
-
});
|
|
114
|
-
const counts = () => {
|
|
115
|
-
const result = new Map();
|
|
116
|
-
for (const { label } of entries) result.set(label, (result.get(label) ?? 0) + 1);
|
|
117
|
-
return result;
|
|
118
|
-
};
|
|
119
|
-
// Grow only ambiguous path suffixes; stop at the root even if display text collides.
|
|
120
|
-
for (;;) {
|
|
121
|
-
const repeated = counts();
|
|
122
|
-
let changed = false;
|
|
123
|
-
for (const entry of entries) {
|
|
124
|
-
if (repeated.get(entry.label) < 2 || entry.parent === null) continue;
|
|
125
|
-
const { api, parent } = entry;
|
|
126
|
-
entry.context = api.join(api.basename(parent) || parent, entry.context);
|
|
127
|
-
entry.label = `${entry.base} · ${cleanTitle(entry.context)}`;
|
|
128
|
-
const next = api.dirname(parent);
|
|
129
|
-
entry.parent = next === parent ? null : next;
|
|
130
|
-
changed = true;
|
|
131
|
-
}
|
|
132
|
-
if (!changed) break;
|
|
133
|
-
}
|
|
134
|
-
for (const entry of entries) {
|
|
135
|
-
const chars = Array.from(entry.label);
|
|
136
|
-
if (chars.length > WORKSPACE_LABEL_LENGTH) {
|
|
137
|
-
entry.label = `${chars.slice(0, 11).join('')}…${chars.slice(-10).join('')}`;
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
const repeated = counts();
|
|
141
|
-
return entries.map(({ label }) => ({ label, numbered: repeated.get(label) > 1 }));
|
|
142
|
-
}
|
|
143
|
-
|
|
144
100
|
function cardWith(headerText, elements) {
|
|
145
101
|
return JSON.stringify({
|
|
146
102
|
schema: '2.0',
|
|
@@ -948,7 +948,19 @@ export class FeishuRuntime {
|
|
|
948
948
|
wsClient?.close({ force: true });
|
|
949
949
|
const bridge = this.#bridge;
|
|
950
950
|
this.#bridge = null;
|
|
951
|
-
|
|
951
|
+
let timer;
|
|
952
|
+
try {
|
|
953
|
+
const idle = await Promise.race([
|
|
954
|
+
(bridge?.waitForIdle() ?? Promise.resolve()).then(() => true),
|
|
955
|
+
new Promise((resolve) => {
|
|
956
|
+
timer = setTimeout(() => resolve(false), 2_000);
|
|
957
|
+
timer.unref?.();
|
|
958
|
+
}),
|
|
959
|
+
]);
|
|
960
|
+
if (!idle) this.#logger.warn?.('[dsh-feishu] bridge idle wait timed out after 2000ms; continuing cleanup');
|
|
961
|
+
} finally {
|
|
962
|
+
clearTimeout(timer);
|
|
963
|
+
}
|
|
952
964
|
this.#client = null;
|
|
953
965
|
this.#status.feishuLongConnectionState = preserveError ? 'failed' : 'idle';
|
|
954
966
|
this.#status.slashCommandRegistration = 'idle';
|
|
@@ -32,16 +32,13 @@ export const SLASH_COMMAND_MANIFEST = Object.freeze([
|
|
|
32
32
|
{ command: 'compact', icon: 'ai-block_outlined', default: '压缩当前会话上下文', en_us: 'Compact the current session' },
|
|
33
33
|
{ command: 'clear', icon: 'clear_outlined', default: '清空当前会话上下文', en_us: 'Clear the current session context' },
|
|
34
34
|
{ command: 'sessionlist', icon: 'chat-ai_outlined', default: '列出会话', en_us: 'List sessions' },
|
|
35
|
-
{ command: '
|
|
36
|
-
{ command: 'workspaces', icon: 'folder_outlined', default: '列出工作区', en_us: 'List workspaces' },
|
|
37
|
-
{ command: 'wsl', icon: 'folder_outlined', default: '列出工作区', en_us: 'List workspaces' },
|
|
38
|
-
{ command: 'ws', icon: 'folder_outlined', default: '切换工作区', en_us: 'Switch workspace' },
|
|
35
|
+
{ command: 'ws', icon: 'folder_outlined', default: '查看并切换工作区', en_us: 'View and switch workspace' },
|
|
39
36
|
{ command: 'watch', icon: 'flag_outlined', default: '关注一个会话', en_us: 'Watch a session' },
|
|
40
37
|
{ command: 'unwatch', icon: 'clear_outlined', default: '取消关注会话', en_us: 'Unwatch a session' },
|
|
41
38
|
{ command: 'watchlist', icon: 'flag_outlined', default: '查看关注列表', en_us: 'List watched sessions' },
|
|
42
39
|
{ command: 'archived', icon: 'folder_outlined', default: '设置归档会话显隐(on/off)', en_us: 'Show or hide archived sessions (on/off)' },
|
|
43
40
|
{ command: 'history', icon: 'chat-ai_outlined', default: '查看最近历史消息(仅私聊)', en_us: 'Show recent history (private chats only)' },
|
|
44
|
-
{ command: 'workspace', icon: 'folder_outlined', default: '
|
|
41
|
+
{ command: 'workspace', icon: 'folder_outlined', default: '查看并切换工作区', en_us: 'View and switch workspace' },
|
|
45
42
|
{ command: 'conv', icon: 'folder_outlined', default: '设置当前对话专属工作区', en_us: 'Set the workspace for this conversation' },
|
|
46
43
|
{ command: 'session', icon: 'chat-ai_outlined', default: '绑定已有会话', en_us: 'Bind an existing session' },
|
|
47
44
|
{ command: 'models', icon: 'ai-functions_outlined', default: '列出可用模型', en_us: 'List available models' },
|
|
@@ -42,11 +42,14 @@ function sendPlainText(bot, target, content, msgSeq) {
|
|
|
42
42
|
* 以 markdown(msg_type=2)发送回复;单条被平台拒绝时回退纯文本(msg_type=0)。
|
|
43
43
|
* 返回每条消息的平台响应,供调用方提取 provider message ids。
|
|
44
44
|
*/
|
|
45
|
-
export async function sendMarkdownReply(bot, target, text, { logger, signal, requireComplete = false } = {}) {
|
|
45
|
+
export async function sendMarkdownReply(bot, target, text, { logger, signal, requireComplete = false, passiveRepliesUsed = 0 } = {}) {
|
|
46
46
|
const chunks = chunkMarkdownParts(text);
|
|
47
47
|
const results = [];
|
|
48
48
|
const firstMsgSeq = nextMsgSeq();
|
|
49
|
-
|
|
49
|
+
// Earlier replies to the same msg_id (for example a timeout notice) spend
|
|
50
|
+
// part of QQ's passive budget; at least one slot is kept for this reply.
|
|
51
|
+
const passiveLimit = target?.msgId
|
|
52
|
+
? Math.max(1, PASSIVE_REPLY_LIMIT[target.scope] - passiveRepliesUsed) : null;
|
|
50
53
|
const overflow = passiveLimit !== null && chunks.length > passiveLimit;
|
|
51
54
|
const passiveContentCount = overflow ? passiveLimit - 1 : chunks.length;
|
|
52
55
|
const proactiveTarget = target?.msgId
|
|
@@ -71,6 +71,7 @@ import {
|
|
|
71
71
|
COMMAND_PERMISSION_DENIED_MESSAGE,
|
|
72
72
|
evaluateInboundAccess,
|
|
73
73
|
} from '../shared/inbound-access.mjs';
|
|
74
|
+
import { ApiError } from '@tencent-connect/qqbot-nodejs';
|
|
74
75
|
import { sendMarkdownReply } from './markdown-reply.mjs';
|
|
75
76
|
import {
|
|
76
77
|
isQqMenuCommand, parseQqMenuCommand, QqMenuStore,
|
|
@@ -269,6 +270,28 @@ export function qqInboundMessage(message, { fetchImpl = fetch } = {}) {
|
|
|
269
270
|
};
|
|
270
271
|
}
|
|
271
272
|
|
|
273
|
+
// QQ accepts passive replies to an inbound msg_id for a bounded window
|
|
274
|
+
// (C2C 60 min, group 5 min). Proactive C2C/group sends are quota-limited and
|
|
275
|
+
// are often refused, so a late result keeps the passive route while the
|
|
276
|
+
// window is still open and only falls back to proactive delivery after it.
|
|
277
|
+
const PASSIVE_REPLY_WINDOW_MS = Object.freeze({ c2c: 60 * 60_000, group: 5 * 60_000 });
|
|
278
|
+
const PASSIVE_REPLY_MARGIN_MS = 30_000;
|
|
279
|
+
|
|
280
|
+
function deferredQqTarget(message, target, acceptedAt) {
|
|
281
|
+
const route = { scope: target.scope, targetId: target.targetId };
|
|
282
|
+
const msgId = nonEmptyString(target.msgId);
|
|
283
|
+
if (!msgId || !PASSIVE_REPLY_WINDOW_MS[target.scope]) return route;
|
|
284
|
+
const sentAt = Date.parse(message?.timestamp ?? '');
|
|
285
|
+
return { ...route, msgId, receivedAt: Number.isFinite(sentAt) ? Math.min(sentAt, acceptedAt) : acceptedAt };
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
export function deferredDeliveryTarget(target, now = Date.now()) {
|
|
289
|
+
const route = { scope: target?.scope, targetId: target?.targetId };
|
|
290
|
+
const window = PASSIVE_REPLY_WINDOW_MS[target?.scope];
|
|
291
|
+
if (!nonEmptyString(target?.msgId) || !window || !Number.isFinite(target?.receivedAt)) return route;
|
|
292
|
+
return now - target.receivedAt < window - PASSIVE_REPLY_MARGIN_MS ? { ...route, msgId: target.msgId } : route;
|
|
293
|
+
}
|
|
294
|
+
|
|
272
295
|
function nonEmptyString(value) {
|
|
273
296
|
return typeof value === 'string' && value.trim() ? value.trim() : null;
|
|
274
297
|
}
|
|
@@ -896,7 +919,22 @@ export class QqHarnessBridge {
|
|
|
896
919
|
}
|
|
897
920
|
|
|
898
921
|
async #deliverDeferredOutcome(entry, outcome) {
|
|
899
|
-
|
|
922
|
+
const text = deferredOutcomeText(outcome);
|
|
923
|
+
const target = deferredDeliveryTarget(entry.target);
|
|
924
|
+
if (!target.msgId) {
|
|
925
|
+
await sendMarkdownReply(this.#bot, target, text, { logger: this.#logger });
|
|
926
|
+
return true;
|
|
927
|
+
}
|
|
928
|
+
try {
|
|
929
|
+
// The timeout notice already answered this msg_id once.
|
|
930
|
+
await sendMarkdownReply(this.#bot, target, text, { logger: this.#logger, passiveRepliesUsed: 1 });
|
|
931
|
+
} catch (error) {
|
|
932
|
+
// Nothing was sent and QQ definitely refused the passive reply (window
|
|
933
|
+
// closed early or budget spent), so the proactive route cannot duplicate it.
|
|
934
|
+
if (!(error instanceof ApiError) || !(error.httpStatus >= 400 && error.httpStatus < 500)) throw error;
|
|
935
|
+
this.#logger.warn?.('[dsh-im:qq] passive deferred reply was refused; retrying proactively:', error);
|
|
936
|
+
await sendMarkdownReply(this.#bot, { scope: target.scope, targetId: target.targetId }, text, { logger: this.#logger });
|
|
937
|
+
}
|
|
900
938
|
return true;
|
|
901
939
|
}
|
|
902
940
|
|
|
@@ -1155,6 +1193,7 @@ export class QqHarnessBridge {
|
|
|
1155
1193
|
batchSubmission = null,
|
|
1156
1194
|
} = {}) {
|
|
1157
1195
|
if (this.#signal?.aborted) return;
|
|
1196
|
+
const acceptedAt = Date.now();
|
|
1158
1197
|
const messageId = nonEmptyString(message?.messageId);
|
|
1159
1198
|
const sender = nonEmptyString(message?.senderId);
|
|
1160
1199
|
if (!messageId || !sender || message.senderIsBot === true) return;
|
|
@@ -1272,7 +1311,8 @@ export class QqHarnessBridge {
|
|
|
1272
1311
|
// already own.
|
|
1273
1312
|
await this.#markPendingSubmitted(key, messageId);
|
|
1274
1313
|
({ answer, artifacts = [] } = await askInWorkspaceSession({
|
|
1275
|
-
|
|
1314
|
+
onNotice: (notice) => this.#bot.sendText(target, notice),
|
|
1315
|
+
deferredDelivery: () => ({ coordinator: this.#deferred, target: deferredQqTarget(message, target, acceptedAt) }),
|
|
1276
1316
|
harness: this.#harness,
|
|
1277
1317
|
state: this.#state,
|
|
1278
1318
|
key,
|
|
@@ -1651,7 +1651,7 @@ export function createBotWorkspaceScope(
|
|
|
1651
1651
|
const dsBinding = (key) => workspaces.dsBotBindingFor?.(botId, key);
|
|
1652
1652
|
const assertNoDsBinding = (key) => {
|
|
1653
1653
|
if (dsBinding(key)) {
|
|
1654
|
-
throw deliveryTargetError('ds-bot-bound', '请先在“绑定
|
|
1654
|
+
throw deliveryTargetError('ds-bot-bound', t('请先在“绑定 DS Bot”中解除绑定,再切换会话或工作目录。'));
|
|
1655
1655
|
}
|
|
1656
1656
|
};
|
|
1657
1657
|
const presetSettings = async (catalog = agentPresetCatalog) => {
|
|
@@ -35,18 +35,21 @@ export const SHARED_COMMAND_CATALOG = Object.freeze([
|
|
|
35
35
|
defineCatalogCommand('history', '查看最近历史消息(仅私聊)', [
|
|
36
36
|
'/history [数量] 查看最近历史消息(默认 3 条,最多 5 条)',
|
|
37
37
|
], { privateOnly: true }),
|
|
38
|
-
|
|
38
|
+
// Merged listing+switch command: no argument opens the picker, an argument
|
|
39
|
+
// switches directly. /wsl and friends stay accepted but leave the menu so
|
|
40
|
+
// there is one workspace entry to choose from.
|
|
41
|
+
defineCatalogCommand('workspace', '查看或切换工作区', [
|
|
42
|
+
'/workspace 或 /ws 查看可切换的工作区(点按钮切换)',
|
|
39
43
|
'/workspace 工作区序号或绝对路径 切换工作区',
|
|
40
|
-
], { aliases: ['ws'] }),
|
|
44
|
+
], { aliases: [{ name: 'ws', menuVisible: false }] }),
|
|
41
45
|
defineCatalogCommand('conv', '设置当前对话专属工作区', [
|
|
42
46
|
'/conv 或 /conversation 查看当前对话工作区',
|
|
43
47
|
'/conv 工作区绝对路径或序号 设置当前对话专属工作区',
|
|
44
48
|
'/conv clear 清除专属工作区,回到 bot 默认工作区',
|
|
45
49
|
], { aliases: ['conversation', 'thread'] }),
|
|
46
50
|
defineCatalogCommand('workspacelist', '列出工作区绝对路径', [
|
|
47
|
-
'/workspacelist
|
|
48
|
-
|
|
49
|
-
], { aliases: ['workspaces', 'wsl'] }),
|
|
51
|
+
'/workspacelist、/wsl、/workspaces 工作区列表别名(等同 /ws)',
|
|
52
|
+
], { aliases: ['workspaces', 'wsl'], menuVisible: false }),
|
|
50
53
|
defineCatalogCommand('sessionlist', '列出会话 ID 和标题', [
|
|
51
54
|
'/sessionlist 或 /sessions [工作区序号或绝对路径] 列出会话 ID 和标题',
|
|
52
55
|
'/sessionlist --limit N 仅列出当前工作区前 N 个会话',
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { randomUUID } from 'node:crypto';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* One structured log line per failed or unconfirmed delivery.
|
|
5
|
+
*
|
|
6
|
+
* The reference id in the notice a user sees (`MF-…`) used to live only on
|
|
7
|
+
* screen: when a real `CHANNEL_DELIVERY_UNCERTAIN` notice appeared, nothing in
|
|
8
|
+
* the log explained it, so the id the user quoted back could not be traced.
|
|
9
|
+
* This module writes the same id, the attempt history and the full text of the
|
|
10
|
+
* part that failed into the local log, so the next occurrence is diagnosable.
|
|
11
|
+
*
|
|
12
|
+
* The line is a single string on purpose: a logger that pretty-prints an object
|
|
13
|
+
* would break it across many lines and make it impossible to grep by id.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
/** `MF-` plus eight characters of a UUID: the id a user can quote back. */
|
|
17
|
+
export function createFailureReferenceId() {
|
|
18
|
+
return `MF-${randomUUID().slice(0, 8).toUpperCase()}`;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
// A bot token looks like `1234:AA…` and must never reach a log line. Only
|
|
22
|
+
// platform descriptions pass through the scrubber; message text is logged
|
|
23
|
+
// verbatim because "what could not be sent" is the whole point of the record.
|
|
24
|
+
const TOKEN_SHAPE = /bot\d+:[A-Za-z0-9_-]{20,}/gu;
|
|
25
|
+
|
|
26
|
+
function safeText(value) {
|
|
27
|
+
return typeof value === 'string' && value ? value.replace(TOKEN_SHAPE, 'bot<redacted>') : null;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function attemptRecord(value) {
|
|
31
|
+
if (!value || typeof value !== 'object') return null;
|
|
32
|
+
const status = Number(value.status);
|
|
33
|
+
const retryAfter = Number(value.retry_after ?? value.retryAfter);
|
|
34
|
+
const attempt = Number(value.attempt);
|
|
35
|
+
return {
|
|
36
|
+
attempt: Number.isInteger(attempt) ? attempt : null,
|
|
37
|
+
method: typeof value.method === 'string' && value.method ? value.method : null,
|
|
38
|
+
status: Number.isInteger(status) ? status : null,
|
|
39
|
+
description: safeText(value.description ?? value.message),
|
|
40
|
+
retry_after: Number.isFinite(retryAfter) ? retryAfter : null,
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
function partRecord(value) {
|
|
45
|
+
if (!value || typeof value !== 'object') return null;
|
|
46
|
+
const index = Number(value.index);
|
|
47
|
+
const text = typeof value.text === 'string' ? value.text : null;
|
|
48
|
+
const length = Number(value.length);
|
|
49
|
+
const messageId = value.message_id ?? value.messageId ?? null;
|
|
50
|
+
return {
|
|
51
|
+
index: Number.isInteger(index) ? index : null,
|
|
52
|
+
length: Number.isInteger(length) ? length : (text?.length ?? 0),
|
|
53
|
+
message_id: messageId === null || messageId === undefined ? null : String(messageId),
|
|
54
|
+
// The text is kept for parts the platform never confirmed: those are the
|
|
55
|
+
// ones nobody can find in the chat afterwards.
|
|
56
|
+
...(text ? { text } : {}),
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Build the log line for one failure object that carries a `referenceId`.
|
|
62
|
+
*
|
|
63
|
+
* `evidence` is what the channel could observe about the send itself (attempt
|
|
64
|
+
* history, per-part message ids, chat topic, markup mode). Channels without it
|
|
65
|
+
* still get a line, just a shorter one.
|
|
66
|
+
*/
|
|
67
|
+
export function deliveryFailureLogLine(channelKey, failure, evidence = null) {
|
|
68
|
+
const detail = evidence && typeof evidence === 'object' ? evidence : {};
|
|
69
|
+
const attempts = (Array.isArray(detail.attempts) ? detail.attempts : [])
|
|
70
|
+
.map(attemptRecord)
|
|
71
|
+
.filter(Boolean);
|
|
72
|
+
const parts = (Array.isArray(detail.parts) ? detail.parts : [])
|
|
73
|
+
.map(partRecord)
|
|
74
|
+
.filter(Boolean);
|
|
75
|
+
const failedPart = Number(detail.failed_part ?? detail.failedPart);
|
|
76
|
+
const record = {
|
|
77
|
+
referenceId: failure?.referenceId ?? null,
|
|
78
|
+
code: failure?.code ?? null,
|
|
79
|
+
reason: failure?.reason ?? null,
|
|
80
|
+
provider_reason: safeText(detail.provider_reason ?? detail.reason),
|
|
81
|
+
deliveryOutcome: detail.deliveryOutcome ?? failure?.deliveryOutcome ?? null,
|
|
82
|
+
attempt_count: attempts.length,
|
|
83
|
+
attempts,
|
|
84
|
+
chat_id: detail.chat_id === undefined || detail.chat_id === null ? null : String(detail.chat_id),
|
|
85
|
+
message_thread_id: Number.isInteger(detail.message_thread_id) ? detail.message_thread_id : null,
|
|
86
|
+
parse_mode: detail.parse_mode ?? null,
|
|
87
|
+
failed_part: Number.isInteger(failedPart) ? failedPart : null,
|
|
88
|
+
parts,
|
|
89
|
+
};
|
|
90
|
+
return `[dsh-im:${channelKey}] delivery failed [${failure?.referenceId ?? 'unknown'}]: `
|
|
91
|
+
+ JSON.stringify(record);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/** Failure codes that describe a send, not something that happened before it. */
|
|
95
|
+
const DELIVERY_FAILURE_CODES = new Set([
|
|
96
|
+
'CHANNEL_DELIVERY',
|
|
97
|
+
'CHANNEL_DELIVERY_UNCERTAIN',
|
|
98
|
+
'CHANNEL_PERMISSION',
|
|
99
|
+
'CHANNEL_RATE_LIMIT',
|
|
100
|
+
]);
|
|
101
|
+
|
|
102
|
+
/** Emit the line through whatever logger the channel was given. */
|
|
103
|
+
export function logDeliveryFailure(logger, channelKey, failure, evidence = null) {
|
|
104
|
+
if (!failure?.referenceId) return null;
|
|
105
|
+
// Other failures already log their own diagnostics; this line exists for the
|
|
106
|
+
// notices whose reference id would otherwise never reach the log.
|
|
107
|
+
if (!evidence && !DELIVERY_FAILURE_CODES.has(failure.code)) return null;
|
|
108
|
+
const line = deliveryFailureLogLine(channelKey, failure, evidence);
|
|
109
|
+
(logger?.error ?? logger?.warn)?.call(logger, line);
|
|
110
|
+
return line;
|
|
111
|
+
}
|
|
@@ -13,6 +13,7 @@ const STAGES = new Set([
|
|
|
13
13
|
'runtime.prepare', 'activation', 'harness.check', 'connection.start', 'connection.poll', 'connection.stop', 'status.read', 'rollback', 'management.request',
|
|
14
14
|
]);
|
|
15
15
|
const REASONS = new Set([
|
|
16
|
+
'session-log-corrupt',
|
|
16
17
|
'stream-closed-before-open', 'stream-failed-before-open', 'stream-failed',
|
|
17
18
|
'ENOTFOUND', 'EAI_AGAIN', 'ECONNREFUSED', 'ECONNRESET', 'EHOSTUNREACH', 'ENETUNREACH', 'ETIMEDOUT', 'EPIPE',
|
|
18
19
|
'UND_ERR_CONNECT_TIMEOUT', 'UND_ERR_HEADERS_TIMEOUT', 'UND_ERR_BODY_TIMEOUT', 'UND_ERR_SOCKET',
|
|
@@ -25,7 +25,7 @@ import { t } from './i18n.mjs';
|
|
|
25
25
|
import { watchHarnessMux } from './harness-mux.mjs';
|
|
26
26
|
import { extractConnectionEvidence, messageDiagnosticError } from './connection-error.mjs';
|
|
27
27
|
import { PromptFailureTracker } from './prompt-failure-tracker.mjs';
|
|
28
|
-
import { isSessionNotFound } from './session-error.mjs';
|
|
28
|
+
import { isSessionLogCorrupt, isSessionNotFound } from './session-error.mjs';
|
|
29
29
|
|
|
30
30
|
// Every channel plugin runs in the same Host process. Sharing ownership by
|
|
31
31
|
// Host identity (or an explicitly configured HTTP origin) prevents clients
|
|
@@ -1406,9 +1406,15 @@ export class HarnessClient {
|
|
|
1406
1406
|
}
|
|
1407
1407
|
|
|
1408
1408
|
// A diagnostic recheck must not hide the original failure or cancellation.
|
|
1409
|
-
async #
|
|
1409
|
+
async #confirmedSessionError(sessionId, options, cause) {
|
|
1410
1410
|
try {
|
|
1411
1411
|
if (await this.#isSessionArchived(sessionId, options)) return sessionArchivedError(sessionId, cause);
|
|
1412
|
+
if (isSessionLogCorrupt(cause)) {
|
|
1413
|
+
return Object.assign(new Error('Stored Session log is unreadable', { cause }), {
|
|
1414
|
+
code: 'session-unreadable', method: cause.method,
|
|
1415
|
+
details: { reason: 'session-log-corrupt' },
|
|
1416
|
+
});
|
|
1417
|
+
}
|
|
1412
1418
|
} catch (error) {
|
|
1413
1419
|
if (options?.signal?.aborted) throw options.signal.reason ?? error;
|
|
1414
1420
|
}
|
|
@@ -1422,7 +1428,7 @@ export class HarnessClient {
|
|
|
1422
1428
|
if (options?.signal?.aborted) throw options.signal.reason ?? error;
|
|
1423
1429
|
if (error instanceof HarnessRpcError
|
|
1424
1430
|
&& (['internal', 'gateway/internal'].includes(error.code) || isSessionNotFound(error.code))) {
|
|
1425
|
-
throw await this.#
|
|
1431
|
+
throw await this.#confirmedSessionError(payload.sessionId, { signal: options?.signal }, error) ?? error;
|
|
1426
1432
|
}
|
|
1427
1433
|
throw error;
|
|
1428
1434
|
}
|
|
@@ -2098,7 +2104,7 @@ export class HarnessClient {
|
|
|
2098
2104
|
if (!ownership?.stopRequested && !harnessTurnSucceeded(tracker.reason)) {
|
|
2099
2105
|
const failure = harnessTurnError(tracker.reason);
|
|
2100
2106
|
if (failure.code === 'turn-blocked') {
|
|
2101
|
-
throw await this.#
|
|
2107
|
+
throw await this.#confirmedSessionError(sessionId, { signal }, failure) ?? failure;
|
|
2102
2108
|
}
|
|
2103
2109
|
throw failure;
|
|
2104
2110
|
}
|
|
@@ -2132,7 +2138,7 @@ export class HarnessClient {
|
|
|
2132
2138
|
.map((event) => event.seq));
|
|
2133
2139
|
if (blockedSeq > checkedBlockedSeq) {
|
|
2134
2140
|
checkedBlockedSeq = blockedSeq;
|
|
2135
|
-
const archived = await this.#
|
|
2141
|
+
const archived = await this.#confirmedSessionError(sessionId, { signal });
|
|
2136
2142
|
if (archived) throw archived;
|
|
2137
2143
|
}
|
|
2138
2144
|
}
|
|
@@ -2140,7 +2146,7 @@ export class HarnessClient {
|
|
|
2140
2146
|
if (Date.now() - lastProgressAt < timeoutMs) continue;
|
|
2141
2147
|
|
|
2142
2148
|
if (!ownership?.stopRequested) {
|
|
2143
|
-
const archived = await this.#
|
|
2149
|
+
const archived = await this.#confirmedSessionError(sessionId, { signal });
|
|
2144
2150
|
if (archived) throw archived;
|
|
2145
2151
|
}
|
|
2146
2152
|
|
|
@@ -83,6 +83,11 @@ export default {
|
|
|
83
83
|
'否': 'No',
|
|
84
84
|
'用法:/workspace 工作区序号或绝对路径':
|
|
85
85
|
'Usage: /workspace Workspace index or absolute path',
|
|
86
|
+
'查看或切换工作区': 'View or switch Workspace',
|
|
87
|
+
'/workspace 或 /ws 查看可切换的工作区(点按钮切换)':
|
|
88
|
+
'/workspace or /ws View switchable Workspaces (tap a button to switch)',
|
|
89
|
+
'/workspacelist、/wsl、/workspaces 工作区列表别名(等同 /ws)':
|
|
90
|
+
'/workspacelist, /wsl, /workspaces Workspace-list aliases (same as /ws)',
|
|
86
91
|
'当前机器人暂不支持切换工作区。': 'This bot does not support switching Workspaces yet.',
|
|
87
92
|
'工作区已切换为:{workspace}': 'Workspace switched to: {workspace}',
|
|
88
93
|
'{message}\n用法:/workspace 工作区序号或绝对路径':
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
// English translations (shared-c area). Keys are exact Chinese literals passed to t().
|
|
2
2
|
export default {
|
|
3
|
+
'请先在“绑定 DS Bot”中解除绑定,再切换会话或工作目录。': 'Unbind in “Bind DS Bot” before switching the Session or working directory.',
|
|
4
|
+
'当前会话日志已损坏,无法继续读取。请先到 DSH 查看任务状态,再发送 /new 创建新会话;原会话记录会保留。': 'The current Session log is corrupt and cannot be read. Check the task status in DSH before sending /new to create a new Session; the original records will be preserved.',
|
|
5
|
+
'绑定会话的日志已损坏,已切换到新会话并继续处理本条消息。原会话记录已保留,历史上下文不会自动带入。': 'The bound Session log is corrupt. Switched to a new Session to continue processing this message. The original records are preserved; previous context is not carried over automatically.',
|
|
3
6
|
'微信': 'Weixin',
|
|
4
7
|
'飞书': 'Feishu',
|
|
5
8
|
'钉钉': 'DingTalk',
|
|
@@ -8,6 +8,12 @@ export default {
|
|
|
8
8
|
'开启一个全新会话': 'Start a brand-new Session',
|
|
9
9
|
'压缩当前会话的较早上下文': 'Compact the earlier context of the current Session',
|
|
10
10
|
'切换工作区': 'Switch Workspace',
|
|
11
|
+
// /ws workspace picker card: one tap switches, the pressed card is re-marked in place.
|
|
12
|
+
'选择要切换的工作区(共 {count} 个):': 'Choose a Workspace to switch to ({count} total):',
|
|
13
|
+
'这个列表已过期,请重新发送 /ws。': 'This list has expired. Send /ws again.',
|
|
14
|
+
'正在切换工作区,请稍候。': 'Switching Workspaces, one moment.',
|
|
15
|
+
'已经在工作区:{workspace}': 'Already in this Workspace: {workspace}',
|
|
16
|
+
'暂时无法切换工作区,请稍后重试。': 'Could not switch Workspaces right now. Try again later.',
|
|
11
17
|
'列出工作区绝对路径': 'List Workspace absolute paths',
|
|
12
18
|
'列出会话 ID 和标题': 'List Session IDs and titles',
|
|
13
19
|
'将当前聊天绑定到指定会话': 'Bind the current chat to a specific Session',
|
|
@@ -75,6 +75,11 @@ export default {
|
|
|
75
75
|
'否': 'Нет',
|
|
76
76
|
'用法:/workspace 工作区序号或绝对路径':
|
|
77
77
|
'Использование: /workspace <номер или абсолютный путь рабочей области>',
|
|
78
|
+
'查看或切换工作区': 'Просмотреть или переключить рабочую область',
|
|
79
|
+
'/workspace 或 /ws 查看可切换的工作区(点按钮切换)':
|
|
80
|
+
'/workspace или /ws Показать доступные рабочие области (нажмите кнопку для переключения)',
|
|
81
|
+
'/workspacelist、/wsl、/workspaces 工作区列表别名(等同 /ws)':
|
|
82
|
+
'/workspacelist, /wsl, /workspaces Псевдонимы списка рабочих областей (как /ws)',
|
|
78
83
|
'当前机器人暂不支持切换工作区。': 'Этот бот пока не поддерживает переключение рабочей области.',
|
|
79
84
|
'工作区已切换为:{workspace}': 'Рабочая область переключена на: {workspace}',
|
|
80
85
|
'{message}\n用法:/workspace 工作区序号或绝对路径':
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
// Russian translations (shared-c area). Keys are exact Chinese literals passed to t().
|
|
2
2
|
export default {
|
|
3
|
+
'请先在“绑定 DS Bot”中解除绑定,再切换会话或工作目录。': 'Сначала снимите привязку в разделе «Привязать DS Bot», затем смените сессию или рабочий каталог.',
|
|
4
|
+
'当前会话日志已损坏,无法继续读取。请先到 DSH 查看任务状态,再发送 /new 创建新会话;原会话记录会保留。': 'Журнал текущей сессии повреждён и не может быть прочитан. Проверьте состояние задачи в DSH, прежде чем отправлять /new для создания новой сессии; исходные записи будут сохранены.',
|
|
5
|
+
'绑定会话的日志已损坏,已切换到新会话并继续处理本条消息。原会话记录已保留,历史上下文不会自动带入。': 'Журнал привязанной сессии повреждён. Выполнено переключение на новую сессию для обработки этого сообщения. Исходные записи сохранены; предыдущий контекст автоматически не переносится.',
|
|
3
6
|
'微信': 'Weixin',
|
|
4
7
|
'飞书': 'Feishu',
|
|
5
8
|
'钉钉': 'DingTalk',
|
|
@@ -6,6 +6,11 @@ export default {
|
|
|
6
6
|
'开启一个全新会话': 'Начать новую сессию',
|
|
7
7
|
'压缩当前会话的较早上下文': 'Сжать ранний контекст текущей сессии',
|
|
8
8
|
'切换工作区': 'Переключить рабочую область',
|
|
9
|
+
'选择要切换的工作区(共 {count} 个):': 'Выберите рабочую область (всего: {count}):',
|
|
10
|
+
'这个列表已过期,请重新发送 /ws。': 'Этот список устарел. Отправьте /ws ещё раз.',
|
|
11
|
+
'正在切换工作区,请稍候。': 'Рабочая область переключается. Подождите.',
|
|
12
|
+
'已经在工作区:{workspace}': 'Уже в рабочей области: {workspace}',
|
|
13
|
+
'暂时无法切换工作区,请稍后重试。': 'Не удалось переключить рабочую область. Повторите попытку позже.',
|
|
9
14
|
'列出工作区绝对路径': 'Показать абсолютные пути рабочих областей',
|
|
10
15
|
'列出会话 ID 和标题': 'Показать ID и заголовки сессий',
|
|
11
16
|
'将当前聊天绑定到指定会话': 'Привязать текущий чат к указанной сессии',
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { isSessionNotFound } from './session-error.mjs';
|
|
2
2
|
import { connectionHint, extractConnectionEvidence, messageDiagnosticError, runtimeDiagnosticDetails } from './connection-error.mjs';
|
|
3
|
+
import { createFailureReferenceId } from './delivery-failure-log.mjs';
|
|
3
4
|
import { diagnosticFields } from './diagnostic-details.mjs';
|
|
4
|
-
import { randomUUID } from 'node:crypto';
|
|
5
5
|
|
|
6
6
|
import { t } from './i18n.mjs';
|
|
7
7
|
|
|
@@ -75,6 +75,8 @@ const FAILURE_MESSAGES = Object.freeze({
|
|
|
75
75
|
'任务被意外中断,本次未完成。请重试。',
|
|
76
76
|
SESSION_NOT_FOUND:
|
|
77
77
|
'当前会话已不存在。请发送 /new 创建新会话后重试。',
|
|
78
|
+
SESSION_UNREADABLE:
|
|
79
|
+
'当前会话日志已损坏,无法继续读取。请先到 DSH 查看任务状态,再发送 /new 创建新会话;原会话记录会保留。',
|
|
78
80
|
SESSION_ARCHIVED:
|
|
79
81
|
'当前会话已归档,无法继续处理。有命令权限时可发送 /new 创建新会话;否则请联系管理员在 DSH 中取消归档,或为你开启命令权限。',
|
|
80
82
|
SESSION_BUSY:
|
|
@@ -147,6 +149,7 @@ function failureCode(error, details) {
|
|
|
147
149
|
if (code === 'turn-blocked') return 'TURN_BLOCKED';
|
|
148
150
|
if (['turn-interrupted', 'turn-aborted'].includes(code)) return 'TURN_INTERRUPTED';
|
|
149
151
|
if (isSessionNotFound(code)) return 'SESSION_NOT_FOUND';
|
|
152
|
+
if (code === 'session-unreadable') return 'SESSION_UNREADABLE';
|
|
150
153
|
if (code === 'session-archived') return 'SESSION_ARCHIVED';
|
|
151
154
|
if (code === 'agent-busy') return 'SESSION_BUSY';
|
|
152
155
|
if (code === 'workspace-session-stale') return 'SESSION_STALE';
|
|
@@ -198,7 +201,7 @@ function transportFailureCode(error, details) {
|
|
|
198
201
|
function safeReferenceId(value) {
|
|
199
202
|
return typeof value === 'string' && /^[A-Z0-9-]{6,40}$/u.test(value)
|
|
200
203
|
? value
|
|
201
|
-
:
|
|
204
|
+
: createFailureReferenceId();
|
|
202
205
|
}
|
|
203
206
|
|
|
204
207
|
function safeFailureReason(value) {
|