@jeik/dingtalk-connector 0.8.26 → 0.8.27-fix2
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/dist/entry-bundled.mjs +1 -1
- package/dist/{gateway-methods--aKsyMs-.mjs → gateway-methods-CfTm9PW_.mjs} +1 -1
- package/dist/gateway-methods-UECIpwQ9.mjs +2 -0
- package/dist/index.mjs +2 -2
- package/dist/{message-handler-DLWxae1K.mjs → message-handler-a7kE1IEx.mjs} +12 -4
- package/dist/{messaging-WleKf54h.mjs → messaging-Dvlan9M0.mjs} +5 -1
- package/dist/{runtime-BdF5tr4a.mjs → runtime-BGp1YsZg.mjs} +2 -2
- package/package.json +1 -1
- package/src/core/message-handler.ts +32 -16
- package/src/reply-dispatcher.ts +1 -1
- package/src/services/messaging/card.ts +2 -0
- package/dist/gateway-methods-BQd4E0Sk.mjs +0 -2
package/dist/entry-bundled.mjs
CHANGED
|
@@ -23,7 +23,7 @@ var entry_bundled_default = defineBundledChannelEntry({
|
|
|
23
23
|
exportName: "setDingtalkRuntime"
|
|
24
24
|
},
|
|
25
25
|
async registerFull(api) {
|
|
26
|
-
const { registerGatewayMethods } = await import("./gateway-methods-
|
|
26
|
+
const { registerGatewayMethods } = await import("./gateway-methods-UECIpwQ9.mjs");
|
|
27
27
|
registerGatewayMethods(api);
|
|
28
28
|
}
|
|
29
29
|
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { a as resolveDingtalkAccount, t as listDingtalkAccountIds } from "./accounts-BAzdqkAV.mjs";
|
|
2
2
|
import { t as dingtalkHttp } from "./http-client-DFWZgO1n.mjs";
|
|
3
3
|
import { r as getAccessToken, t as DINGTALK_API } from "./utils-CIfI_3Jh.mjs";
|
|
4
|
-
import { c as prepareMultiBotMentions, d as finishAICard, i as sendProactive, s as buildBotMentionTable } from "./messaging-
|
|
4
|
+
import { c as prepareMultiBotMentions, d as finishAICard, i as sendProactive, s as buildBotMentionTable } from "./messaging-Dvlan9M0.mjs";
|
|
5
5
|
import { d as getUnionId, h as recallEmotionReply } from "./utils-legacy-DQ3HeGHh.mjs";
|
|
6
6
|
//#region src/docs.ts
|
|
7
7
|
var DingtalkDocsClient = class {
|
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { a as initDingtalkPluginConfigSchema, i as dingtalkPlugin, n as setDingtalkRuntime } from "./runtime-
|
|
2
|
-
import { t as registerGatewayMethods } from "./gateway-methods
|
|
1
|
+
import { a as initDingtalkPluginConfigSchema, i as dingtalkPlugin, n as setDingtalkRuntime } from "./runtime-BGp1YsZg.mjs";
|
|
2
|
+
import { t as registerGatewayMethods } from "./gateway-methods-CfTm9PW_.mjs";
|
|
3
3
|
//#region index.ts
|
|
4
4
|
/**
|
|
5
5
|
* 检测同一 plugin id 在多个路径被加载的情况。
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { a as resolveDingtalkAccount } from "./accounts-BAzdqkAV.mjs";
|
|
2
|
-
import { r as CHANNEL_ID, t as getDingtalkRuntime } from "./runtime-
|
|
2
|
+
import { r as CHANNEL_ID, t as getDingtalkRuntime } from "./runtime-BGp1YsZg.mjs";
|
|
3
3
|
import { n as createLoggerFromConfig } from "./logger-mZ9OSbmD.mjs";
|
|
4
4
|
import { t as dingtalkHttp } from "./http-client-DFWZgO1n.mjs";
|
|
5
5
|
import { i as getOapiAccessToken } from "./utils-CIfI_3Jh.mjs";
|
|
6
|
-
import { S as finalClean, _ as FINAL_TAG, a as sendTextMessage, b as estimateTokens, d as finishAICard, g as unregisterActiveCard, h as streamAICard, i as sendProactive, m as registerActiveCard, p as isQpsLimitError, r as sendMessage, t as sendMarkdownMessage, u as createAICardForTarget, v as PROCESS_TAG, x as extractFinal, y as displayClean } from "./messaging-
|
|
6
|
+
import { S as finalClean, _ as FINAL_TAG, a as sendTextMessage, b as estimateTokens, d as finishAICard, g as unregisterActiveCard, h as streamAICard, i as sendProactive, m as registerActiveCard, p as isQpsLimitError, r as sendMessage, t as sendMarkdownMessage, u as createAICardForTarget, v as PROCESS_TAG, x as extractFinal, y as displayClean } from "./messaging-Dvlan9M0.mjs";
|
|
7
7
|
import { a as QUEUE_BUSY_ACK_PHRASES, n as normalizeSlashCommand, t as buildSessionContext } from "./session-DJ4jYqPv.mjs";
|
|
8
8
|
import { c as formatSenderRoles, f as getUserProfile, h as recallEmotionReply, l as getAccessToken, o as formatHiredDateShanghai, r as addEmotionReply, s as formatSenderDisplayLabel, t as DINGTALK_API, u as getOapiAccessToken$1 } from "./utils-legacy-DQ3HeGHh.mjs";
|
|
9
9
|
import "./chunk-upload-BBQgGtcZ.mjs";
|
|
@@ -2265,11 +2265,19 @@ async function handleDingTalkMessageInternal(params) {
|
|
|
2265
2265
|
}
|
|
2266
2266
|
} catch (err) {
|
|
2267
2267
|
log?.error?.(`SDK dispatch 失败: ${err.message}`);
|
|
2268
|
-
|
|
2268
|
+
const errorText = matchModelErrorText(err.message, { includeCatchAll: true }) ?? `⚠️ 抱歉,处理请求时出错: ${err.message}`;
|
|
2269
|
+
let cardSuccess = false;
|
|
2270
|
+
if (earlyCard) try {
|
|
2271
|
+
await finishAICard(earlyCard, errorText, config, log, void 0, void 0, data.conversationId);
|
|
2272
|
+
cardSuccess = true;
|
|
2273
|
+
} catch (cardErr) {
|
|
2274
|
+
log?.error?.(`更新错误卡片失败: ${cardErr.message}`);
|
|
2275
|
+
}
|
|
2276
|
+
if (!cardSuccess) try {
|
|
2269
2277
|
const token = await getAccessToken(config);
|
|
2270
2278
|
const body = {
|
|
2271
2279
|
msgtype: "text",
|
|
2272
|
-
text: { content:
|
|
2280
|
+
text: { content: errorText }
|
|
2273
2281
|
};
|
|
2274
2282
|
if (!isDirect) body.at = {
|
|
2275
2283
|
atUserIds: [senderId],
|
|
@@ -429,8 +429,12 @@ async function finishAICard(card, content, config, log, contentVar, skipInputing
|
|
|
429
429
|
return;
|
|
430
430
|
} catch (retryErr) {
|
|
431
431
|
log?.error?.(`[DingTalk][AICard] FINISHED 重试失败:${retryErr.message}`);
|
|
432
|
+
throw retryErr;
|
|
432
433
|
}
|
|
433
|
-
} else
|
|
434
|
+
} else {
|
|
435
|
+
log?.error?.(`[DingTalk][AICard] FINISHED 更新失败:${err.message}`);
|
|
436
|
+
throw err;
|
|
437
|
+
}
|
|
434
438
|
}
|
|
435
439
|
}
|
|
436
440
|
//#endregion
|
|
@@ -3,7 +3,7 @@ import { a as resolveDingtalkAccount, c as addWildcardAllowFrom, d as hasConfigu
|
|
|
3
3
|
import { t as createLogger } from "./logger-mZ9OSbmD.mjs";
|
|
4
4
|
import { t as dingtalkHttp } from "./http-client-DFWZgO1n.mjs";
|
|
5
5
|
import "./utils-CIfI_3Jh.mjs";
|
|
6
|
-
import { S as finalClean, f as getActiveCardForConversation, n as sendMediaToDingTalk, o as sendTextToDingTalk } from "./messaging-
|
|
6
|
+
import { S as finalClean, f as getActiveCardForConversation, n as sendMediaToDingTalk, o as sendTextToDingTalk } from "./messaging-Dvlan9M0.mjs";
|
|
7
7
|
import { createRequire } from "node:module";
|
|
8
8
|
import { z, z as z$1 } from "zod";
|
|
9
9
|
//#region src/secret-input.ts
|
|
@@ -955,7 +955,7 @@ async function monitorDingtalkProvider(opts = {}) {
|
|
|
955
955
|
const log = createLogger(cfg.channels?.["dingtalk-connector"]?.debug ?? false);
|
|
956
956
|
const [accountsModule, monitorAccountModule, monitorSingleModule] = await Promise.all([
|
|
957
957
|
import("./accounts-BQptOmgB.mjs"),
|
|
958
|
-
import("./message-handler-
|
|
958
|
+
import("./message-handler-a7kE1IEx.mjs"),
|
|
959
959
|
import("./connection-fc6B4z4G.mjs")
|
|
960
960
|
]);
|
|
961
961
|
const { resolveDingtalkAccount, listEnabledDingtalkAccounts } = accountsModule;
|
package/package.json
CHANGED
|
@@ -56,13 +56,13 @@ import {
|
|
|
56
56
|
uploadAndReplaceFileMarkers
|
|
57
57
|
} from "../services/media/index.ts";
|
|
58
58
|
import { sendProactive, type AICardTarget } from "../services/messaging/index.ts";
|
|
59
|
-
import { createAICardForTarget, streamAICard, registerActiveCard, type AICardInstance } from "../services/messaging/card.ts";
|
|
59
|
+
import { createAICardForTarget, streamAICard, finishAICard, registerActiveCard, type AICardInstance } from "../services/messaging/card.ts";
|
|
60
60
|
import {
|
|
61
61
|
collectCardLookupIds,
|
|
62
62
|
lookupCardContent,
|
|
63
63
|
} from "../services/messaging/card-content-cache.ts";
|
|
64
64
|
import { QUEUE_BUSY_ACK_PHRASES } from "../utils/constants.ts";
|
|
65
|
-
import { createDingtalkReplyDispatcher } from "../reply-dispatcher.ts";
|
|
65
|
+
import { createDingtalkReplyDispatcher, matchModelErrorText } from "../reply-dispatcher.ts";
|
|
66
66
|
import { normalizeSlashCommand } from "../utils/session.ts";
|
|
67
67
|
import { getDingtalkRuntime } from "../runtime.ts";
|
|
68
68
|
import { dingtalkHttp } from '../utils/http-client.ts';
|
|
@@ -1906,20 +1906,36 @@ export async function handleDingTalkMessageInternal(params: HandleMessageParams)
|
|
|
1906
1906
|
} catch (err: any) {
|
|
1907
1907
|
log?.error?.(`SDK dispatch 失败: ${err.message}`);
|
|
1908
1908
|
|
|
1909
|
-
//
|
|
1910
|
-
|
|
1911
|
-
|
|
1912
|
-
|
|
1913
|
-
|
|
1914
|
-
|
|
1915
|
-
|
|
1916
|
-
|
|
1917
|
-
|
|
1918
|
-
|
|
1919
|
-
|
|
1920
|
-
}
|
|
1921
|
-
}
|
|
1922
|
-
|
|
1909
|
+
// 解析上游错误文本(例如 503 No available channel),匹配中文提示文案
|
|
1910
|
+
const errorText = matchModelErrorText(err.message, { includeCatchAll: true }) ?? `⚠️ 抱歉,处理请求时出错: ${err.message}`;
|
|
1911
|
+
|
|
1912
|
+
// 如果已经建了 AI Card,则更新报错状态到 Card,避免停留在"正在召唤大模型"
|
|
1913
|
+
let cardSuccess = false;
|
|
1914
|
+
if (earlyCard) {
|
|
1915
|
+
try {
|
|
1916
|
+
await finishAICard(earlyCard, errorText, config, log, undefined, undefined, data.conversationId);
|
|
1917
|
+
cardSuccess = true;
|
|
1918
|
+
} catch (cardErr: any) {
|
|
1919
|
+
log?.error?.(`更新错误卡片失败: ${cardErr.message}`);
|
|
1920
|
+
}
|
|
1921
|
+
}
|
|
1922
|
+
|
|
1923
|
+
if (!cardSuccess) {
|
|
1924
|
+
// 降级:发送错误文本消息
|
|
1925
|
+
try {
|
|
1926
|
+
const token = await getAccessToken(config);
|
|
1927
|
+
const body: any = {
|
|
1928
|
+
msgtype: 'text',
|
|
1929
|
+
text: { content: errorText }
|
|
1930
|
+
};
|
|
1931
|
+
if (!isDirect) body.at = { atUserIds: [senderId], isAtAll: false };
|
|
1932
|
+
|
|
1933
|
+
await dingtalkHttp.post(sessionWebhook, body, {
|
|
1934
|
+
headers: { 'x-acs-dingtalk-access-token': token, 'Content-Type': 'application/json' },
|
|
1935
|
+
});
|
|
1936
|
+
} catch (fallbackErr: any) {
|
|
1937
|
+
log?.error?.(`错误消息发送也失败: ${fallbackErr.message}`);
|
|
1938
|
+
}
|
|
1923
1939
|
}
|
|
1924
1940
|
}
|
|
1925
1941
|
|
package/src/reply-dispatcher.ts
CHANGED
|
@@ -239,7 +239,7 @@ const MODEL_ERROR_CATCH_ALL: [RegExp, string] = [/.{20,}/, MODEL_ERROR_GENERIC];
|
|
|
239
239
|
* @param opts.includeCatchAll 为 true 时启用万能兜底
|
|
240
240
|
* @returns 命中则返回中文提示,未命中返回 null
|
|
241
241
|
*/
|
|
242
|
-
function matchModelErrorText(
|
|
242
|
+
export function matchModelErrorText(
|
|
243
243
|
source: string,
|
|
244
244
|
opts?: { includeCatchAll?: boolean },
|
|
245
245
|
): string | null {
|
|
@@ -674,9 +674,11 @@ export async function finishAICard(
|
|
|
674
674
|
log?.error?.(
|
|
675
675
|
`[DingTalk][AICard] FINISHED 重试失败:${retryErr.message}`,
|
|
676
676
|
);
|
|
677
|
+
throw retryErr;
|
|
677
678
|
}
|
|
678
679
|
} else {
|
|
679
680
|
log?.error?.(`[DingTalk][AICard] FINISHED 更新失败:${err.message}`);
|
|
681
|
+
throw err;
|
|
680
682
|
}
|
|
681
683
|
}
|
|
682
684
|
}
|