@jeik/dingtalk-connector 0.8.27-fix1 → 0.8.27-fix3

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.
@@ -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-BQd4E0Sk.mjs");
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-WleKf54h.mjs";
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 {
@@ -0,0 +1,2 @@
1
+ import { t as registerGatewayMethods } from "./gateway-methods-CfTm9PW_.mjs";
2
+ export { registerGatewayMethods };
package/dist/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
- import { a as initDingtalkPluginConfigSchema, i as dingtalkPlugin, n as setDingtalkRuntime } from "./runtime-C7zQrH65.mjs";
2
- import { t as registerGatewayMethods } from "./gateway-methods--aKsyMs-.mjs";
1
+ import { a as initDingtalkPluginConfigSchema, i as dingtalkPlugin, n as setDingtalkRuntime } from "./runtime-8WBX1FSq.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-C7zQrH65.mjs";
2
+ import { r as CHANNEL_ID, t as getDingtalkRuntime } from "./runtime-8WBX1FSq.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-WleKf54h.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-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,28 +2265,29 @@ async function handleDingTalkMessageInternal(params) {
2265
2265
  }
2266
2266
  } catch (err) {
2267
2267
  log?.error?.(`SDK dispatch 失败: ${err.message}`);
2268
- const errorText = matchModelErrorText(err.message, { includeCatchAll: true }) ?? `⚠️ 抱歉,处理请求时出错: ${err.message}`;
2269
- if (earlyCard) try {
2270
- await finishAICard(earlyCard, errorText, config, log, void 0, void 0, data.conversationId);
2271
- } catch (cardErr) {
2272
- log?.error?.(`更新错误卡片失败: ${cardErr.message}`);
2273
- }
2274
- else try {
2275
- const token = await getAccessToken(config);
2276
- const body = {
2277
- msgtype: "text",
2278
- text: { content: errorText }
2279
- };
2280
- if (!isDirect) body.at = {
2281
- atUserIds: [senderId],
2282
- isAtAll: false
2283
- };
2284
- await dingtalkHttp.post(sessionWebhook, body, { headers: {
2285
- "x-acs-dingtalk-access-token": token,
2286
- "Content-Type": "application/json"
2287
- } });
2288
- } catch (fallbackErr) {
2289
- log?.error?.(`错误消息发送也失败: ${fallbackErr.message}`);
2268
+ if (replyOptions?.onError) {
2269
+ log?.info?.(`[DingTalk] 统一错误定稿:调用 replyOptions.onError 处理同步异常`);
2270
+ await replyOptions.onError(err, { kind: "invoke" });
2271
+ } else {
2272
+ const errorText = matchModelErrorText(err.message, { includeCatchAll: true }) ?? `⚠️ 抱歉,处理请求时出错: ${err.message}`;
2273
+ log?.warn?.(`[DingTalk] replyOptions.onError 不存在,走极端兜底纯文本发送`);
2274
+ try {
2275
+ const token = await getAccessToken(config);
2276
+ const body = {
2277
+ msgtype: "text",
2278
+ text: { content: errorText }
2279
+ };
2280
+ if (!isDirect) body.at = {
2281
+ atUserIds: [senderId],
2282
+ isAtAll: false
2283
+ };
2284
+ await dingtalkHttp.post(sessionWebhook, body, { headers: {
2285
+ "x-acs-dingtalk-access-token": token,
2286
+ "Content-Type": "application/json"
2287
+ } });
2288
+ } catch (fallbackErr) {
2289
+ log?.error?.(`错误消息发送也失败: ${fallbackErr.message}`);
2290
+ }
2290
2291
  }
2291
2292
  }
2292
2293
  try {
@@ -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 log?.error?.(`[DingTalk][AICard] FINISHED 更新失败:${err.message}`);
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-WleKf54h.mjs";
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-31oFEtyt.mjs"),
958
+ import("./message-handler-CCbPqctq.mjs"),
959
959
  import("./connection-fc6B4z4G.mjs")
960
960
  ]);
961
961
  const { resolveDingtalkAccount, listEnabledDingtalkAccounts } = accountsModule;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jeik/dingtalk-connector",
3
- "version": "0.8.27-fix1",
3
+ "version": "0.8.27-fix3",
4
4
  "description": "OpenClaw DingTalk channel plugin (fork) | 钉钉 OpenClaw 渠道插件(fork 自官方,含标记/卡片渲染修复)",
5
5
  "type": "module",
6
6
  "exports": {
@@ -1906,18 +1906,14 @@ export async function handleDingTalkMessageInternal(params: HandleMessageParams)
1906
1906
  } catch (err: any) {
1907
1907
  log?.error?.(`SDK dispatch 失败: ${err.message}`);
1908
1908
 
1909
- // 解析上游错误文本(例如 503 No available channel),匹配中文提示文案
1910
- const errorText = matchModelErrorText(err.message, { includeCatchAll: true }) ?? `⚠️ 抱歉,处理请求时出错: ${err.message}`;
1911
-
1912
- // 如果已经建了 AI Card,则更新报错状态到 Card,避免停留在"正在召唤大模型"
1913
- if (earlyCard) {
1914
- try {
1915
- await finishAICard(earlyCard, errorText, config, log, undefined, undefined, data.conversationId);
1916
- } catch (cardErr: any) {
1917
- log?.error?.(`更新错误卡片失败: ${cardErr.message}`);
1918
- }
1909
+ // 使用与正常回放相同的底层逻辑统一处理错误定稿
1910
+ if (replyOptions?.onError) {
1911
+ log?.info?.(`[DingTalk] 统一错误定稿:调用 replyOptions.onError 处理同步异常`);
1912
+ await replyOptions.onError(err, { kind: 'invoke' });
1919
1913
  } else {
1920
- // 降级:发送错误文本消息
1914
+ // 极端兜底(理论上必有 onError)
1915
+ const errorText = matchModelErrorText(err.message, { includeCatchAll: true }) ?? `⚠️ 抱歉,处理请求时出错: ${err.message}`;
1916
+ log?.warn?.(`[DingTalk] replyOptions.onError 不存在,走极端兜底纯文本发送`);
1921
1917
  try {
1922
1918
  const token = await getAccessToken(config);
1923
1919
  const body: any = {
@@ -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
  }
@@ -1,2 +0,0 @@
1
- import { t as registerGatewayMethods } from "./gateway-methods--aKsyMs-.mjs";
2
- export { registerGatewayMethods };