@jeik/dingtalk-connector 0.8.39 → 0.8.41
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/CHANGELOG.md +16 -0
- package/dist/{accounts-BAzdqkAV.mjs → accounts-D2M-GOtQ.mjs} +10 -1
- package/dist/{background-work-874-aK4-.mjs → background-work-Cok3Vmb4.mjs} +1 -1
- package/dist/{card-content-cache-CGggfgCg.mjs → card-content-cache-CRgMn6Ze.mjs} +2 -2
- package/dist/{channel-BbpJFyga.mjs → channel-hCmy5tOM.mjs} +11 -11
- package/dist/{chunk-upload-z185bTqH.mjs → chunk-upload-DlCT3BD7.mjs} +11 -3
- package/dist/{common-1-GDZ2h3.mjs → common-2Hn5Fx-d.mjs} +14 -5
- package/dist/compat-BhZoKOuf.mjs +32 -0
- package/dist/{connection-C7-3gzQW.mjs → connection-B6SZQzK-.mjs} +3 -3
- package/dist/{dws-delivery-context-BsTrxK68.mjs → dws-delivery-context-DWm03KM4.mjs} +1 -1
- package/dist/entry-bundled.mjs +3 -2
- package/dist/{gateway-methods-lTdxcCpO.mjs → gateway-methods-CXM2Z24O.mjs} +10 -8
- package/dist/{http-client-DFWZgO1n.mjs → http-client-ii7_j0AF.mjs} +7 -1
- package/dist/index.mjs +5 -4
- package/dist/{logger-CnBTcwyq.mjs → logger-CWZBxzcb.mjs} +8 -1
- package/dist/{media-3G_kHjld.mjs → media-C90EIqKj.mjs} +33 -25
- package/dist/{message-handler-DNgfzwqR.mjs → message-handler-C8yul27I.mjs} +52 -24
- package/dist/{messaging-DvW-2HJJ.mjs → messaging-CVB0q8Kz.mjs} +9 -9
- package/dist/rolldown-runtime-BCk198RA.mjs +15 -0
- package/dist/{session-DsDDfhMw.mjs → session-_6Ywf0sf.mjs} +21 -9
- package/dist/{utils-DXwaa6O-.mjs → utils-DIQU5Sf1.mjs} +24 -3
- package/dist/{utils-legacy-D9TCnrMR.mjs → utils-legacy-BQe4U9cR.mjs} +25 -7
- package/index.ts +3 -2
- package/openclaw.plugin.json +1 -1
- package/package.json +1 -1
- package/src/channel.ts +2 -2
- package/src/reply-dispatcher.ts +43 -8
- package/src/utils/compat.ts +41 -0
- package/src/utils/session.ts +23 -11
- package/dist/accounts-BQptOmgB.mjs +0 -2
- package/dist/card-content-cache-BsFPIwOr.mjs +0 -2
- package/dist/chunk-upload-CNlZg1SF.mjs +0 -2
- package/dist/common-DCVdWMiZ.mjs +0 -2
- package/dist/gateway-methods-DBRRhEk5.mjs +0 -2
- package/dist/http-client-CpnJHB89.mjs +0 -2
- package/dist/logger-D8H2IcYz.mjs +0 -2
- package/dist/media-o_kBcTXb.mjs +0 -2
- package/dist/utils-CNXrWqt1.mjs +0 -4
- package/dist/utils-legacy-vhmn24_Z.mjs +0 -3
- /package/dist/{game-xiyou-CKoWJobs.mjs → game-xiyou-DQd3u2jI.mjs} +0 -0
- /package/dist/{runtime-DDMzayvA.mjs → runtime-CQXd4Zgd.mjs} +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,22 @@ All notable changes to this project will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## [0.8.41] - 2026-09-02
|
|
9
|
+
|
|
10
|
+
### Fixes & Compatibility
|
|
11
|
+
|
|
12
|
+
- **彻底消除 `import.meta` 与顶层 Await 导致的跨环境兼容问题**:
|
|
13
|
+
- 移除 `src/reply-dispatcher.ts` 中的顶层 `await import("openclaw/plugin-sdk/channel-runtime")`;
|
|
14
|
+
- 新增 `src/utils/compat.ts` 跨环境适配模块,统一使用安全 `getSafeRequire` 与 `getCurrentModuleUrl` 替换裸 `import.meta.url` 与 `createRequire(import.meta.url)`;
|
|
15
|
+
- 杜绝在 Node 22 / Node 24 / jiti 源码转译器 Script 模式下触发 V8 引擎语法错误 `SyntaxError: Cannot use 'import.meta' outside a module`;
|
|
16
|
+
- 原生 `require()` 与 OpenClaw `jiti` 转译器均可 100% 成功加载。
|
|
17
|
+
|
|
18
|
+
## [0.8.40] - 2026-09-02
|
|
19
|
+
|
|
20
|
+
### Fixes
|
|
21
|
+
|
|
22
|
+
- **修复插件导入 SyntaxError (Cannot use 'import.meta' outside a module)** — 移除 `src/utils/session.ts` 中顶层 `await import`(Top-Level Await)。Top-Level Await 会导致 Node 的 `require(esm)` 抛出 `ERR_REQUIRE_ASYNC_MODULE` 并使 OpenClaw 的 CJS/jiti 加载回退链中报错。改为懒加载 `createRequire` 检测 SDK 中止命令,插件完全支持同步 `require` 加载。
|
|
23
|
+
|
|
8
24
|
## [0.8.39] - 2026-09-02
|
|
9
25
|
|
|
10
26
|
### Features & Fixes
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { t as __exportAll } from "./rolldown-runtime-BCk198RA.mjs";
|
|
1
2
|
//#region src/sdk/helpers.ts
|
|
2
3
|
/**
|
|
3
4
|
* 默认账号 ID
|
|
@@ -125,6 +126,14 @@ function formatDocsLink(path, label) {
|
|
|
125
126
|
}
|
|
126
127
|
//#endregion
|
|
127
128
|
//#region src/config/accounts.ts
|
|
129
|
+
var accounts_exports = /* @__PURE__ */ __exportAll({
|
|
130
|
+
listDingtalkAccountIds: () => listDingtalkAccountIds,
|
|
131
|
+
listEnabledDingtalkAccounts: () => listEnabledDingtalkAccounts,
|
|
132
|
+
resolveDefaultDingtalkAccountId: () => resolveDefaultDingtalkAccountId,
|
|
133
|
+
resolveDefaultDingtalkAccountSelection: () => resolveDefaultDingtalkAccountSelection,
|
|
134
|
+
resolveDingtalkAccount: () => resolveDingtalkAccount,
|
|
135
|
+
resolveDingtalkCredentials: () => resolveDingtalkCredentials
|
|
136
|
+
});
|
|
128
137
|
/**
|
|
129
138
|
* List all configured account IDs from the accounts field.
|
|
130
139
|
*/
|
|
@@ -265,4 +274,4 @@ function listEnabledDingtalkAccounts(cfg) {
|
|
|
265
274
|
});
|
|
266
275
|
}
|
|
267
276
|
//#endregion
|
|
268
|
-
export {
|
|
277
|
+
export { resolveDingtalkCredentials as a, createDefaultChannelRuntimeState as c, normalizeAccountId as d, resolveAllowlistProviderRuntimeGroupPolicy as f, resolveDingtalkAccount as i, formatDocsLink as l, listDingtalkAccountIds as n, DEFAULT_ACCOUNT_ID as o, resolveDefaultGroupPolicy as p, resolveDefaultDingtalkAccountId as r, addWildcardAllowFrom as s, accounts_exports as t, hasConfiguredSecretInput as u };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { r as isDingtalkDebug } from "./logger-
|
|
1
|
+
import { r as isDingtalkDebug } from "./logger-CWZBxzcb.mjs";
|
|
2
2
|
//#region src/services/messaging/card-content-cache.ts
|
|
3
3
|
/**
|
|
4
4
|
* AI / 交互卡片正文缓存
|
|
@@ -117,4 +117,4 @@ function lookupCardContent(params) {
|
|
|
117
117
|
return null;
|
|
118
118
|
}
|
|
119
119
|
//#endregion
|
|
120
|
-
export { lookupCardContent
|
|
120
|
+
export { collectCardLookupIds, lookupCardContent, rememberCardContent };
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { t as
|
|
5
|
-
import "./
|
|
6
|
-
import
|
|
7
|
-
import {
|
|
1
|
+
import { t as __exportAll } from "./rolldown-runtime-BCk198RA.mjs";
|
|
2
|
+
import { n as getSafeRequire } from "./compat-BhZoKOuf.mjs";
|
|
3
|
+
import { a as resolveDingtalkCredentials, c as createDefaultChannelRuntimeState, d as normalizeAccountId, f as resolveAllowlistProviderRuntimeGroupPolicy, i as resolveDingtalkAccount, l as formatDocsLink, n as listDingtalkAccountIds, o as DEFAULT_ACCOUNT_ID, p as resolveDefaultGroupPolicy, r as resolveDefaultDingtalkAccountId, s as addWildcardAllowFrom, u as hasConfiguredSecretInput } from "./accounts-D2M-GOtQ.mjs";
|
|
4
|
+
import { t as createLogger } from "./logger-CWZBxzcb.mjs";
|
|
5
|
+
import { t as dingtalkHttp } from "./http-client-ii7_j0AF.mjs";
|
|
6
|
+
import "./utils-DIQU5Sf1.mjs";
|
|
7
|
+
import { S as finalClean, f as getActiveCardForConversation, n as sendMediaToDingTalk, o as sendTextToDingTalk } from "./messaging-CVB0q8Kz.mjs";
|
|
8
8
|
import { z, z as z$1 } from "zod";
|
|
9
9
|
//#region src/secret-input.ts
|
|
10
10
|
function buildSecretInputSchema() {
|
|
@@ -969,9 +969,9 @@ async function monitorDingtalkProvider(opts = {}) {
|
|
|
969
969
|
if (!cfg) throw new Error("Config is required for DingTalk monitor");
|
|
970
970
|
const log = createLogger(cfg.channels?.["dingtalk-connector"]?.debug ?? false);
|
|
971
971
|
const [accountsModule, monitorAccountModule, monitorSingleModule] = await Promise.all([
|
|
972
|
-
import("./accounts-
|
|
973
|
-
import("./message-handler-
|
|
974
|
-
import("./connection-
|
|
972
|
+
import("./accounts-D2M-GOtQ.mjs").then((n) => n.t),
|
|
973
|
+
import("./message-handler-C8yul27I.mjs"),
|
|
974
|
+
import("./connection-B6SZQzK-.mjs")
|
|
975
975
|
]);
|
|
976
976
|
const { resolveDingtalkAccount, listEnabledDingtalkAccounts } = accountsModule;
|
|
977
977
|
const { handleDingTalkMessage } = monitorAccountModule;
|
|
@@ -1455,7 +1455,7 @@ const dingtalkPlugin = {
|
|
|
1455
1455
|
*/
|
|
1456
1456
|
function initDingtalkPluginConfigSchema() {
|
|
1457
1457
|
if (dingtalkPlugin.configSchema != null) return;
|
|
1458
|
-
const { buildChannelConfigSchema } =
|
|
1458
|
+
const { buildChannelConfigSchema } = getSafeRequire()("openclaw/plugin-sdk/core");
|
|
1459
1459
|
dingtalkPlugin.configSchema = buildChannelConfigSchema(DingtalkConfigBaseSchema);
|
|
1460
1460
|
}
|
|
1461
1461
|
//#endregion
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { t as
|
|
2
|
-
import {
|
|
1
|
+
import { t as __exportAll } from "./rolldown-runtime-BCk198RA.mjs";
|
|
2
|
+
import { t as createLogger } from "./logger-CWZBxzcb.mjs";
|
|
3
|
+
import { n as dingtalkOapiHttp } from "./http-client-ii7_j0AF.mjs";
|
|
3
4
|
import * as fs from "fs";
|
|
4
5
|
import * as path from "path";
|
|
5
6
|
import FormData from "form-data";
|
|
@@ -13,6 +14,13 @@ import FormData from "form-data";
|
|
|
13
14
|
* - 上传块:https://open.dingtalk.com/document/development/upload-file-blocks
|
|
14
15
|
* - 提交事务:https://open.dingtalk.com/document/development/submit-a-file-upload-transaction
|
|
15
16
|
*/
|
|
17
|
+
var chunk_upload_exports = /* @__PURE__ */ __exportAll({
|
|
18
|
+
CHUNK_CONFIG: () => CHUNK_CONFIG,
|
|
19
|
+
enableUploadTransaction: () => enableUploadTransaction,
|
|
20
|
+
submitUploadTransaction: () => submitUploadTransaction,
|
|
21
|
+
uploadFileBlock: () => uploadFileBlock,
|
|
22
|
+
uploadLargeFileByChunks: () => uploadLargeFileByChunks
|
|
23
|
+
});
|
|
16
24
|
const DINGTALK_OAPI = "https://oapi.dingtalk.com";
|
|
17
25
|
/** 分块上传配置 */
|
|
18
26
|
const CHUNK_CONFIG = {
|
|
@@ -190,4 +198,4 @@ async function uploadLargeFileByChunks(filePath, mediaType, oapiToken, debug = f
|
|
|
190
198
|
}
|
|
191
199
|
}
|
|
192
200
|
//#endregion
|
|
193
|
-
export {
|
|
201
|
+
export { chunk_upload_exports as n, CHUNK_CONFIG as t };
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { t as
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { t as __exportAll } from "./rolldown-runtime-BCk198RA.mjs";
|
|
2
|
+
import { t as createLogger } from "./logger-CWZBxzcb.mjs";
|
|
3
|
+
import { r as dingtalkUploadHttp } from "./http-client-ii7_j0AF.mjs";
|
|
4
|
+
import { t as CHUNK_CONFIG } from "./chunk-upload-DlCT3BD7.mjs";
|
|
4
5
|
import * as fs from "fs";
|
|
5
6
|
import * as path from "path";
|
|
6
7
|
import FormData from "form-data";
|
|
@@ -8,6 +9,14 @@ import FormData from "form-data";
|
|
|
8
9
|
/**
|
|
9
10
|
* 媒体处理公共工具和常量
|
|
10
11
|
*/
|
|
12
|
+
var common_exports = /* @__PURE__ */ __exportAll({
|
|
13
|
+
AUDIO_MARKER_PATTERN: () => AUDIO_MARKER_PATTERN,
|
|
14
|
+
DINGTALK_OAPI: () => DINGTALK_OAPI,
|
|
15
|
+
FILE_MARKER_PATTERN: () => FILE_MARKER_PATTERN,
|
|
16
|
+
VIDEO_MARKER_PATTERN: () => VIDEO_MARKER_PATTERN,
|
|
17
|
+
toLocalPath: () => toLocalPath,
|
|
18
|
+
uploadMediaToDingTalk: () => uploadMediaToDingTalk
|
|
19
|
+
});
|
|
11
20
|
/** 视频标记正则表达式 */
|
|
12
21
|
const VIDEO_MARKER_PATTERN = /\[DINGTALK_VIDEO\](.*?)\[\/DINGTALK_VIDEO\]/gs;
|
|
13
22
|
/** 音频标记正则表达式 */
|
|
@@ -48,7 +57,7 @@ async function uploadMediaToDingTalk(filePath, mediaType, oapiToken, maxSize = 2
|
|
|
48
57
|
if ((mediaType === "video" || mediaType === "file") && fileSize > CHUNK_CONFIG.SIZE_THRESHOLD) {
|
|
49
58
|
log?.info?.(`文件超过 20MB,使用分块上传:${absPath} (${fileSizeMB}MB)`);
|
|
50
59
|
try {
|
|
51
|
-
const { uploadLargeFileByChunks } = await import("./chunk-upload-
|
|
60
|
+
const { uploadLargeFileByChunks } = await import("./chunk-upload-DlCT3BD7.mjs").then((n) => n.n);
|
|
52
61
|
const downloadCode = await uploadLargeFileByChunks(absPath, mediaType, oapiToken, debugEnabled);
|
|
53
62
|
if (downloadCode) {
|
|
54
63
|
log?.info?.(`分块上传成功:${absPath}, download_code: ${downloadCode}`);
|
|
@@ -96,4 +105,4 @@ async function uploadMediaToDingTalk(filePath, mediaType, oapiToken, maxSize = 2
|
|
|
96
105
|
/** 钉钉 OAPI 常量 */
|
|
97
106
|
const DINGTALK_OAPI = "https://oapi.dingtalk.com";
|
|
98
107
|
//#endregion
|
|
99
|
-
export { toLocalPath as a,
|
|
108
|
+
export { toLocalPath as a, common_exports as i, FILE_MARKER_PATTERN as n, uploadMediaToDingTalk as o, VIDEO_MARKER_PATTERN as r, AUDIO_MARKER_PATTERN as t };
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { n as __require } from "./rolldown-runtime-BCk198RA.mjs";
|
|
2
|
+
import { createRequire } from "node:module";
|
|
3
|
+
import { pathToFileURL } from "node:url";
|
|
4
|
+
//#region src/utils/compat.ts
|
|
5
|
+
/**
|
|
6
|
+
* 获取跨运行环境(CJS / ESM / jiti)安全的 require 函数。
|
|
7
|
+
* 绝不使用裸 import.meta,避免在 CJS / Script 模式下触发 V8 解析器的 SyntaxError。
|
|
8
|
+
*/
|
|
9
|
+
function getSafeRequire(basePath) {
|
|
10
|
+
if (typeof __require === "function") return __require;
|
|
11
|
+
return createRequire(basePath || typeof __filename !== "undefined" && __filename || `${process.cwd()}/package.json`);
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* 获取当前模块的路径或 file:// URL,完全兼容 ESM 与 CJS/jiti。
|
|
15
|
+
*/
|
|
16
|
+
function getCurrentModuleUrl(fallbackName = "index.mjs") {
|
|
17
|
+
if (typeof __filename !== "undefined" && __filename) try {
|
|
18
|
+
return pathToFileURL(__filename).href;
|
|
19
|
+
} catch {
|
|
20
|
+
return `file://${__filename}`;
|
|
21
|
+
}
|
|
22
|
+
try {
|
|
23
|
+
const stack = (/* @__PURE__ */ new Error()).stack?.split("\n") || [];
|
|
24
|
+
for (const line of stack) {
|
|
25
|
+
const match = line.match(/(?:file:\/\/)?(\/[^:\s)]+\.(?:[cm]?[jt]sx?))/);
|
|
26
|
+
if (match && !match[1].includes("node:") && !match[1].includes("compat.")) return pathToFileURL(match[1]).href;
|
|
27
|
+
}
|
|
28
|
+
} catch {}
|
|
29
|
+
return `file://${process.cwd()}/dist/${fallbackName}`;
|
|
30
|
+
}
|
|
31
|
+
//#endregion
|
|
32
|
+
export { getSafeRequire as n, getCurrentModuleUrl as t };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { n as onBackgroundWorkCountChange, t as getActiveBackgroundWorkCount } from "./background-work-
|
|
1
|
+
import { r as checkAndMarkDingtalkMessage } from "./utils-legacy-BQe4U9cR.mjs";
|
|
2
|
+
import { n as onBackgroundWorkCountChange, t as getActiveBackgroundWorkCount } from "./background-work-Cok3Vmb4.mjs";
|
|
3
3
|
import * as fs from "fs";
|
|
4
4
|
//#region src/core/connection.ts
|
|
5
5
|
/**
|
|
@@ -72,7 +72,7 @@ async function monitorSingleAccount(opts) {
|
|
|
72
72
|
silenceDingtalkStreamConsoleNoise();
|
|
73
73
|
const clawdbotConfig = cfg;
|
|
74
74
|
const log = runtime?.log;
|
|
75
|
-
const { createLoggerFromConfig, setDingtalkDebug } = await import("./logger-
|
|
75
|
+
const { createLoggerFromConfig, setDingtalkDebug } = await import("./logger-CWZBxzcb.mjs").then((n) => n.i);
|
|
76
76
|
if (account.config?.debug) setDingtalkDebug(true);
|
|
77
77
|
const logger = createLoggerFromConfig(account.config, `DingTalk:${accountId}`);
|
|
78
78
|
if (!account.clientId || !account.clientSecret) throw new Error(`[DingTalk][${accountId}] Missing credentials: clientId=${account.clientId ? "present" : "MISSING"}, clientSecret=${account.clientSecret ? "present" : "MISSING"}. Please check your configuration in channels.dingtalk-connector.`);
|
package/dist/entry-bundled.mjs
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { t as getCurrentModuleUrl } from "./compat-BhZoKOuf.mjs";
|
|
1
2
|
import { defineBundledChannelEntry } from "openclaw/plugin-sdk/channel-entry-contract";
|
|
2
3
|
//#region entry-bundled.ts
|
|
3
4
|
/**
|
|
@@ -13,7 +14,7 @@ var entry_bundled_default = defineBundledChannelEntry({
|
|
|
13
14
|
id: "dingtalk-connector",
|
|
14
15
|
name: "DingTalk",
|
|
15
16
|
description: "DingTalk (钉钉) channel connector — Stream mode with AI Card streaming",
|
|
16
|
-
importMetaUrl:
|
|
17
|
+
importMetaUrl: getCurrentModuleUrl("entry-bundled.mjs"),
|
|
17
18
|
plugin: {
|
|
18
19
|
specifier: "./index.ts",
|
|
19
20
|
exportName: "dingtalkPlugin"
|
|
@@ -23,7 +24,7 @@ var entry_bundled_default = defineBundledChannelEntry({
|
|
|
23
24
|
exportName: "setDingtalkRuntime"
|
|
24
25
|
},
|
|
25
26
|
async registerFull(api) {
|
|
26
|
-
const { registerGatewayMethods } = await import("./gateway-methods-
|
|
27
|
+
const { registerGatewayMethods } = await import("./gateway-methods-CXM2Z24O.mjs").then((n) => n.t);
|
|
27
28
|
registerGatewayMethods(api);
|
|
28
29
|
}
|
|
29
30
|
});
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { d as
|
|
1
|
+
import { t as __exportAll } from "./rolldown-runtime-BCk198RA.mjs";
|
|
2
|
+
import { i as resolveDingtalkAccount, n as listDingtalkAccountIds } from "./accounts-D2M-GOtQ.mjs";
|
|
3
|
+
import { t as dingtalkHttp } from "./http-client-ii7_j0AF.mjs";
|
|
4
|
+
import { i as getAccessToken, n as DINGTALK_API } from "./utils-DIQU5Sf1.mjs";
|
|
5
|
+
import { c as prepareMultiBotMentions, d as finishAICard, i as sendProactive, s as buildBotMentionTable } from "./messaging-CVB0q8Kz.mjs";
|
|
6
|
+
import { d as recallEmotionReply, l as getUnionId } from "./utils-legacy-BQe4U9cR.mjs";
|
|
6
7
|
//#region src/docs.ts
|
|
7
8
|
var DingtalkDocsClient = class {
|
|
8
9
|
config;
|
|
@@ -202,6 +203,7 @@ var DingtalkDocsClient = class {
|
|
|
202
203
|
};
|
|
203
204
|
//#endregion
|
|
204
205
|
//#region src/gateway-methods.ts
|
|
206
|
+
var gateway_methods_exports = /* @__PURE__ */ __exportAll({ registerGatewayMethods: () => registerGatewayMethods });
|
|
205
207
|
/**
|
|
206
208
|
* Warn when accountId is not explicitly provided and multiple accounts exist.
|
|
207
209
|
* Returns the resolved account (unchanged), but emits a log warning so that
|
|
@@ -592,7 +594,7 @@ function registerGatewayMethods(api) {
|
|
|
592
594
|
});
|
|
593
595
|
const results = {};
|
|
594
596
|
if (cardInstanceId) try {
|
|
595
|
-
const { getAccessToken } = await import("./utils-legacy-
|
|
597
|
+
const { getAccessToken } = await import("./utils-legacy-BQe4U9cR.mjs").then((n) => n.f);
|
|
596
598
|
const token = await getAccessToken(account.config);
|
|
597
599
|
await finishAICard({
|
|
598
600
|
cardInstanceId: String(cardInstanceId),
|
|
@@ -752,7 +754,7 @@ function registerGatewayMethods(api) {
|
|
|
752
754
|
try {
|
|
753
755
|
const account = resolveDingtalkAccount({ cfg });
|
|
754
756
|
if (!account.config?.clientId || !account.config?.clientSecret) return respond(false, { error: "Not configured" });
|
|
755
|
-
const { getAccessToken } = await import("./utils-legacy-
|
|
757
|
+
const { getAccessToken } = await import("./utils-legacy-BQe4U9cR.mjs").then((n) => n.f);
|
|
756
758
|
await getAccessToken(account.config);
|
|
757
759
|
respond(true, {
|
|
758
760
|
ok: true,
|
|
@@ -768,4 +770,4 @@ function registerGatewayMethods(api) {
|
|
|
768
770
|
});
|
|
769
771
|
}
|
|
770
772
|
//#endregion
|
|
771
|
-
export { registerGatewayMethods as t };
|
|
773
|
+
export { registerGatewayMethods as n, gateway_methods_exports as t };
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { t as __exportAll } from "./rolldown-runtime-BCk198RA.mjs";
|
|
1
2
|
import axios from "axios";
|
|
2
3
|
//#region src/utils/http-client.ts
|
|
3
4
|
/**
|
|
@@ -13,6 +14,11 @@ import axios from "axios";
|
|
|
13
14
|
* const response = await dingtalkHttp.post('/api/endpoint', data);
|
|
14
15
|
* ```
|
|
15
16
|
*/
|
|
17
|
+
var http_client_exports = /* @__PURE__ */ __exportAll({
|
|
18
|
+
dingtalkHttp: () => dingtalkHttp,
|
|
19
|
+
dingtalkOapiHttp: () => dingtalkOapiHttp,
|
|
20
|
+
dingtalkUploadHttp: () => dingtalkUploadHttp
|
|
21
|
+
});
|
|
16
22
|
/** 钉钉新版 API 专用 HTTP 客户端(30 秒超时,用于 api.dingtalk.com) */
|
|
17
23
|
const dingtalkHttp = axios.create({
|
|
18
24
|
timeout: 3e4,
|
|
@@ -30,4 +36,4 @@ const dingtalkUploadHttp = axios.create({
|
|
|
30
36
|
maxBodyLength: Infinity
|
|
31
37
|
});
|
|
32
38
|
//#endregion
|
|
33
|
-
export { dingtalkOapiHttp as n, dingtalkUploadHttp as r, dingtalkHttp as t };
|
|
39
|
+
export { http_client_exports as i, dingtalkOapiHttp as n, dingtalkUploadHttp as r, dingtalkHttp as t };
|
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { n as
|
|
3
|
-
import {
|
|
1
|
+
import { t as getCurrentModuleUrl } from "./compat-BhZoKOuf.mjs";
|
|
2
|
+
import { n as dingtalkPlugin, r as initDingtalkPluginConfigSchema } from "./channel-hCmy5tOM.mjs";
|
|
3
|
+
import { n as setDingtalkRuntime } from "./runtime-CQXd4Zgd.mjs";
|
|
4
|
+
import { n as registerGatewayMethods } from "./gateway-methods-CXM2Z24O.mjs";
|
|
4
5
|
//#region index.ts
|
|
5
6
|
/**
|
|
6
7
|
* 检测同一 plugin id 在多个路径被加载的情况。
|
|
@@ -22,7 +23,7 @@ function recordAndCheckLoadPath(api) {
|
|
|
22
23
|
const store = g[DUPLICATE_LOAD_SYMBOL] ?? /* @__PURE__ */ new Map();
|
|
23
24
|
g[DUPLICATE_LOAD_SYMBOL] = store;
|
|
24
25
|
const pluginId = "dingtalk-connector";
|
|
25
|
-
const here =
|
|
26
|
+
const here = getCurrentModuleUrl("index.mjs");
|
|
26
27
|
const paths = store.get(pluginId) ?? /* @__PURE__ */ new Set();
|
|
27
28
|
paths.add(here);
|
|
28
29
|
store.set(pluginId, paths);
|
|
@@ -1,4 +1,11 @@
|
|
|
1
|
+
import { t as __exportAll } from "./rolldown-runtime-BCk198RA.mjs";
|
|
1
2
|
//#region src/utils/logger.ts
|
|
3
|
+
var logger_exports = /* @__PURE__ */ __exportAll({
|
|
4
|
+
createLogger: () => createLogger,
|
|
5
|
+
createLoggerFromConfig: () => createLoggerFromConfig,
|
|
6
|
+
isDingtalkDebug: () => isDingtalkDebug,
|
|
7
|
+
setDingtalkDebug: () => setDingtalkDebug
|
|
8
|
+
});
|
|
2
9
|
/**
|
|
3
10
|
* 日志工具模块
|
|
4
11
|
* 根据配置里的 debug 控制日志输出(无需环境变量)
|
|
@@ -69,4 +76,4 @@ function createLoggerFromConfig(config, prefix = "") {
|
|
|
69
76
|
return createLogger(!!config?.debug, prefix);
|
|
70
77
|
}
|
|
71
78
|
//#endregion
|
|
72
|
-
export { setDingtalkDebug as i, createLoggerFromConfig as n, isDingtalkDebug as r, createLogger as t };
|
|
79
|
+
export { setDingtalkDebug as a, logger_exports as i, createLoggerFromConfig as n, isDingtalkDebug as r, createLogger as t };
|
|
@@ -1,29 +1,37 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { n as
|
|
4
|
-
import {
|
|
1
|
+
import { n as __require, t as __exportAll } from "./rolldown-runtime-BCk198RA.mjs";
|
|
2
|
+
import { r as isDingtalkDebug } from "./logger-CWZBxzcb.mjs";
|
|
3
|
+
import { n as dingtalkOapiHttp, t as dingtalkHttp } from "./http-client-ii7_j0AF.mjs";
|
|
4
|
+
import { r as DINGTALK_OAPI } from "./utils-DIQU5Sf1.mjs";
|
|
5
5
|
import * as fs from "fs";
|
|
6
6
|
import * as os from "os";
|
|
7
7
|
import * as path from "path";
|
|
8
8
|
import FormData from "form-data";
|
|
9
|
-
//#region \0rolldown/runtime.js
|
|
10
|
-
var __defProp = Object.defineProperty;
|
|
11
|
-
var __exportAll = (all, no_symbols) => {
|
|
12
|
-
let target = {};
|
|
13
|
-
for (var name in all) __defProp(target, name, {
|
|
14
|
-
get: all[name],
|
|
15
|
-
enumerable: true
|
|
16
|
-
});
|
|
17
|
-
if (!no_symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
|
|
18
|
-
return target;
|
|
19
|
-
};
|
|
20
|
-
var __require = /* @__PURE__ */ createRequire(import.meta.url);
|
|
21
|
-
//#endregion
|
|
22
9
|
//#region src/services/media.ts
|
|
23
10
|
/**
|
|
24
11
|
* 钉钉媒体处理
|
|
25
12
|
* 支持图片、视频、音频、文件的上传和下载
|
|
26
13
|
*/
|
|
14
|
+
var media_exports = /* @__PURE__ */ __exportAll({
|
|
15
|
+
IMAGE_EXTENSIONS: () => IMAGE_EXTENSIONS,
|
|
16
|
+
LOCAL_IMAGE_RE: () => LOCAL_IMAGE_RE,
|
|
17
|
+
VIDEO_MARKER_PATTERN: () => VIDEO_MARKER_PATTERN,
|
|
18
|
+
extractVideoMetadata: () => extractVideoMetadata,
|
|
19
|
+
extractVideoThumbnail: () => extractVideoThumbnail,
|
|
20
|
+
hasResidualLocalMdImagesOutsideCode: () => hasResidualLocalMdImagesOutsideCode,
|
|
21
|
+
isLocalImageRef: () => isLocalImageRef,
|
|
22
|
+
logMediaIdTrace: () => logMediaIdTrace,
|
|
23
|
+
looksLikeRemoteUrl: () => looksLikeRemoteUrl,
|
|
24
|
+
processImagesForOutbound: () => processImagesForOutbound,
|
|
25
|
+
processLocalImages: () => processLocalImages,
|
|
26
|
+
processRawMediaPaths: () => processRawMediaPaths,
|
|
27
|
+
processVideoMarkers: () => processVideoMarkers,
|
|
28
|
+
sendAudioProactive: () => sendAudioProactive,
|
|
29
|
+
sendFileProactive: () => sendFileProactive,
|
|
30
|
+
sendVideoProactive: () => sendVideoProactive,
|
|
31
|
+
toLocalPath: () => toLocalPath,
|
|
32
|
+
uploadLocalImageWithFallback: () => uploadLocalImageWithFallback,
|
|
33
|
+
uploadMediaToDingTalk: () => uploadMediaToDingTalk
|
|
34
|
+
});
|
|
27
35
|
/** 图片文件扩展名 */
|
|
28
36
|
const IMAGE_EXTENSIONS = /\.(png|jpg|jpeg|gif|bmp|webp|tiff|svg)$/i;
|
|
29
37
|
/**
|
|
@@ -667,7 +675,7 @@ async function extractAudioDuration(filePath, log) {
|
|
|
667
675
|
*/
|
|
668
676
|
async function sendVideoMessage(config, sessionWebhook, fileName, mediaId, log, metadata) {
|
|
669
677
|
try {
|
|
670
|
-
const token = await (await import("./utils-
|
|
678
|
+
const token = await (await import("./utils-DIQU5Sf1.mjs").then((n) => n.t)).getAccessToken(config);
|
|
671
679
|
const videoMessage = {
|
|
672
680
|
msgtype: "video",
|
|
673
681
|
video: {
|
|
@@ -695,8 +703,8 @@ async function sendVideoMessage(config, sessionWebhook, fileName, mediaId, log,
|
|
|
695
703
|
*/
|
|
696
704
|
async function sendVideoProactive(config, target, videoMediaId, picMediaId, metadata, log) {
|
|
697
705
|
try {
|
|
698
|
-
const token = await (await import("./utils-
|
|
699
|
-
const { DINGTALK_API } = await import("./utils-
|
|
706
|
+
const token = await (await import("./utils-DIQU5Sf1.mjs").then((n) => n.t)).getAccessToken(config);
|
|
707
|
+
const { DINGTALK_API } = await import("./utils-DIQU5Sf1.mjs").then((n) => n.t);
|
|
700
708
|
const msgParam = {
|
|
701
709
|
duration: metadata?.duration.toString() || "60000",
|
|
702
710
|
videoMediaId,
|
|
@@ -741,8 +749,8 @@ async function sendVideoProactive(config, target, videoMediaId, picMediaId, meta
|
|
|
741
749
|
*/
|
|
742
750
|
async function sendAudioProactive(config, target, fileName, mediaId, log, durationMs) {
|
|
743
751
|
try {
|
|
744
|
-
const token = await (await import("./utils-
|
|
745
|
-
const { DINGTALK_API } = await import("./utils-
|
|
752
|
+
const token = await (await import("./utils-DIQU5Sf1.mjs").then((n) => n.t)).getAccessToken(config);
|
|
753
|
+
const { DINGTALK_API } = await import("./utils-DIQU5Sf1.mjs").then((n) => n.t);
|
|
746
754
|
const msgParam = {
|
|
747
755
|
mediaId,
|
|
748
756
|
duration: durationMs && durationMs > 0 ? durationMs.toString() : "60000"
|
|
@@ -779,8 +787,8 @@ async function sendAudioProactive(config, target, fileName, mediaId, log, durati
|
|
|
779
787
|
*/
|
|
780
788
|
async function sendFileProactive(config, target, fileInfo, mediaId, log) {
|
|
781
789
|
try {
|
|
782
|
-
const token = await (await import("./utils-
|
|
783
|
-
const { DINGTALK_API } = await import("./utils-
|
|
790
|
+
const token = await (await import("./utils-DIQU5Sf1.mjs").then((n) => n.t)).getAccessToken(config);
|
|
791
|
+
const { DINGTALK_API } = await import("./utils-DIQU5Sf1.mjs").then((n) => n.t);
|
|
784
792
|
const resolvedFileName = fileInfo.fileName || path.basename(fileInfo.path);
|
|
785
793
|
const msgParam = {
|
|
786
794
|
mediaId,
|
|
@@ -886,4 +894,4 @@ async function processRawMediaPaths(content, config, oapiToken, log, target) {
|
|
|
886
894
|
return processedContent;
|
|
887
895
|
}
|
|
888
896
|
//#endregion
|
|
889
|
-
export {
|
|
897
|
+
export { uploadMediaToDingTalk as a, processLocalImages as i, media_exports as n, processImagesForOutbound as r, logMediaIdTrace as t };
|
|
@@ -1,16 +1,17 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import { t as
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import "./
|
|
12
|
-
import
|
|
13
|
-
import { n as
|
|
1
|
+
import { n as getSafeRequire } from "./compat-BhZoKOuf.mjs";
|
|
2
|
+
import { i as resolveDingtalkAccount } from "./accounts-D2M-GOtQ.mjs";
|
|
3
|
+
import { t as CHANNEL_ID } from "./channel-hCmy5tOM.mjs";
|
|
4
|
+
import { n as createLoggerFromConfig, r as isDingtalkDebug } from "./logger-CWZBxzcb.mjs";
|
|
5
|
+
import { t as dingtalkHttp } from "./http-client-ii7_j0AF.mjs";
|
|
6
|
+
import { a as getOapiAccessToken } from "./utils-DIQU5Sf1.mjs";
|
|
7
|
+
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-CVB0q8Kz.mjs";
|
|
8
|
+
import { n as isAbortCommand, o as QUEUE_BUSY_ACK_PHRASES, r as normalizeSlashCommand, t as buildSessionContext } from "./session-_6Ywf0sf.mjs";
|
|
9
|
+
import { t as getDingtalkRuntime } from "./runtime-CQXd4Zgd.mjs";
|
|
10
|
+
import { a as formatSenderDisplayLabel, c as getOapiAccessToken$1, d as recallEmotionReply, i as formatHiredDateShanghai, n as addEmotionReply, o as formatSenderRoles, s as getAccessToken, t as DINGTALK_API, u as getUserProfile } from "./utils-legacy-BQe4U9cR.mjs";
|
|
11
|
+
import { r as trackBackgroundWork } from "./background-work-Cok3Vmb4.mjs";
|
|
12
|
+
import "./chunk-upload-DlCT3BD7.mjs";
|
|
13
|
+
import { a as toLocalPath, n as FILE_MARKER_PATTERN, o as uploadMediaToDingTalk, r as VIDEO_MARKER_PATTERN, t as AUDIO_MARKER_PATTERN } from "./common-2Hn5Fx-d.mjs";
|
|
14
|
+
import { collectCardLookupIds, lookupCardContent } from "./card-content-cache-CRgMn6Ze.mjs";
|
|
14
15
|
import * as fs from "fs";
|
|
15
16
|
import * as path from "path";
|
|
16
17
|
import * as os from "node:os";
|
|
@@ -64,7 +65,7 @@ function resolveAgentWorkspaceDir(cfg, agentId) {
|
|
|
64
65
|
* 直接复用 media.ts 权威实现,避免 reply 路径与 message 路径两套逻辑分叉。
|
|
65
66
|
*/
|
|
66
67
|
async function processLocalImages(content, oapiToken, log) {
|
|
67
|
-
const { processLocalImages: impl } = await import("./media-
|
|
68
|
+
const { processLocalImages: impl } = await import("./media-C90EIqKj.mjs").then((n) => n.n);
|
|
68
69
|
return impl(content, oapiToken, log);
|
|
69
70
|
}
|
|
70
71
|
//#endregion
|
|
@@ -187,7 +188,34 @@ async function uploadAndReplaceFileMarkers(content, sessionWebhook, config, oapi
|
|
|
187
188
|
}
|
|
188
189
|
//#endregion
|
|
189
190
|
//#region src/reply-dispatcher.ts
|
|
190
|
-
|
|
191
|
+
let channelRuntimeModule = null;
|
|
192
|
+
function getChannelRuntimeModule() {
|
|
193
|
+
if (!channelRuntimeModule) try {
|
|
194
|
+
const req = getSafeRequire();
|
|
195
|
+
for (const pkg of ["openclaw", "jeikclaw"]) try {
|
|
196
|
+
channelRuntimeModule = req(`${pkg}/plugin-sdk/channel-runtime`);
|
|
197
|
+
if (channelRuntimeModule) break;
|
|
198
|
+
} catch {}
|
|
199
|
+
} catch {}
|
|
200
|
+
return channelRuntimeModule || {};
|
|
201
|
+
}
|
|
202
|
+
function createReplyPrefixOptions(opts) {
|
|
203
|
+
const mod = getChannelRuntimeModule();
|
|
204
|
+
if (typeof mod.createReplyPrefixOptions === "function") return mod.createReplyPrefixOptions(opts);
|
|
205
|
+
return { ...opts };
|
|
206
|
+
}
|
|
207
|
+
function createTypingCallbacks(opts) {
|
|
208
|
+
const mod = getChannelRuntimeModule();
|
|
209
|
+
if (typeof mod.createTypingCallbacks === "function") return mod.createTypingCallbacks(opts);
|
|
210
|
+
return {
|
|
211
|
+
onTypingStart: () => {},
|
|
212
|
+
onTypingStop: () => {}
|
|
213
|
+
};
|
|
214
|
+
}
|
|
215
|
+
function logTypingFailure(opts) {
|
|
216
|
+
const mod = getChannelRuntimeModule();
|
|
217
|
+
if (typeof mod.logTypingFailure === "function") return mod.logTypingFailure(opts);
|
|
218
|
+
}
|
|
191
219
|
/**
|
|
192
220
|
* OpenClaw rawError → 钉钉中文提示。
|
|
193
221
|
*
|
|
@@ -615,13 +643,13 @@ function createDingtalkReplyDispatcher(params) {
|
|
|
615
643
|
finalText = await processLocalImages(finalText, oapiToken, log);
|
|
616
644
|
if (beforeImg !== finalText) log.info(`[DingTalk][LocalImage] closeStreaming 图片已处理 | ${beforeImg.length}→${finalText.length}`);
|
|
617
645
|
try {
|
|
618
|
-
const { hasResidualLocalMdImagesOutsideCode } = await import("./media-
|
|
646
|
+
const { hasResidualLocalMdImagesOutsideCode } = await import("./media-C90EIqKj.mjs").then((n) => n.n);
|
|
619
647
|
if (hasResidualLocalMdImagesOutsideCode(finalText)) log.warn(`[DingTalk][LocalImage] closeStreaming 定稿后仍有代码块外的本地 MD 图未上传,钉钉可能灰图`);
|
|
620
648
|
} catch {}
|
|
621
649
|
finalText = await processVideoMarkers(finalText, "", account.config, oapiToken, log, true, target);
|
|
622
650
|
finalText = await processAudioMarkers(finalText, "", account.config, oapiToken, log, true, target);
|
|
623
651
|
finalText = await uploadAndReplaceFileMarkers(finalText, "", account.config, oapiToken, log, true, target);
|
|
624
|
-
const { processRawMediaPaths } = await import("./media-
|
|
652
|
+
const { processRawMediaPaths } = await import("./media-C90EIqKj.mjs").then((n) => n.n);
|
|
625
653
|
finalText = await processRawMediaPaths(finalText, account.config, oapiToken, log, target);
|
|
626
654
|
log.info(`[DingTalk][closeStreaming] processRawMediaPaths 处理完成`);
|
|
627
655
|
} else log.warn(`[DingTalk][closeStreaming] oapiToken 为空,跳过媒体处理`);
|
|
@@ -635,7 +663,7 @@ function createDingtalkReplyDispatcher(params) {
|
|
|
635
663
|
}
|
|
636
664
|
} else log.info(`[DingTalk][closeStreaming] 养成系统:onCommandOutput 监听到 ${productsToProcess.size} 个 dws 产品: ${[...productsToProcess].join(", ")}`);
|
|
637
665
|
if (productsToProcess.size > 0) {
|
|
638
|
-
const { GamificationEngine } = await import("./game-xiyou-
|
|
666
|
+
const { GamificationEngine } = await import("./game-xiyou-DQd3u2jI.mjs");
|
|
639
667
|
const engine = GamificationEngine.getInstanceForUser(senderId);
|
|
640
668
|
if (engine.isEnabled()) {
|
|
641
669
|
const primaryProduct = [...productsToProcess][0];
|
|
@@ -850,7 +878,7 @@ function createDingtalkReplyDispatcher(params) {
|
|
|
850
878
|
const oapiToken = await getOapiAccessToken(account.config);
|
|
851
879
|
if (oapiToken) {
|
|
852
880
|
log.info(`[DingTalk][deliver] 检测到 final 响应,准备处理裸露文件路径`);
|
|
853
|
-
const { processRawMediaPaths } = await import("./media-
|
|
881
|
+
const { processRawMediaPaths } = await import("./media-C90EIqKj.mjs").then((n) => n.n);
|
|
854
882
|
text = await processRawMediaPaths(text, account.config, oapiToken, log, target);
|
|
855
883
|
log.info(`[DingTalk][deliver] 裸露文件路径处理完成`);
|
|
856
884
|
}
|
|
@@ -980,7 +1008,7 @@ function createDingtalkReplyDispatcher(params) {
|
|
|
980
1008
|
currentToolLine = "";
|
|
981
1009
|
await startStreaming();
|
|
982
1010
|
if (currentCardTarget) try {
|
|
983
|
-
const { FILE_MARKER_PATTERN, VIDEO_MARKER_PATTERN, AUDIO_MARKER_PATTERN } = await import("./common-
|
|
1011
|
+
const { FILE_MARKER_PATTERN, VIDEO_MARKER_PATTERN, AUDIO_MARKER_PATTERN } = await import("./common-2Hn5Fx-d.mjs").then((n) => n.i);
|
|
984
1012
|
await enqueueCardStream(buildCardContent().replace(FILE_MARKER_PATTERN, "").replace(VIDEO_MARKER_PATTERN, "").replace(AUDIO_MARKER_PATTERN, "").trim(), { force: true });
|
|
985
1013
|
} catch (err) {
|
|
986
1014
|
if (!isQpsLimitError(err)) log.error(`[DingTalk][onPartialReply] final-marker 刷卡失败:${err.message}`);
|
|
@@ -993,7 +1021,7 @@ function createDingtalkReplyDispatcher(params) {
|
|
|
993
1021
|
if (payload.text?.trim()) hasModelStreamText = true;
|
|
994
1022
|
currentToolLine = "";
|
|
995
1023
|
try {
|
|
996
|
-
const { FILE_MARKER_PATTERN, VIDEO_MARKER_PATTERN, AUDIO_MARKER_PATTERN } = await import("./common-
|
|
1024
|
+
const { FILE_MARKER_PATTERN, VIDEO_MARKER_PATTERN, AUDIO_MARKER_PATTERN } = await import("./common-2Hn5Fx-d.mjs").then((n) => n.i);
|
|
997
1025
|
await enqueueCardStream(buildCardContent().replace(FILE_MARKER_PATTERN, "").replace(VIDEO_MARKER_PATTERN, "").replace(AUDIO_MARKER_PATTERN, "").trim());
|
|
998
1026
|
} catch (err) {
|
|
999
1027
|
if (isQpsLimitError(err)) log.warn(`[DingTalk][onPartialReply] QPS 限流,已排队尾随重试 latestLen=${latestCardContent.length}`);
|
|
@@ -1037,7 +1065,7 @@ function createDingtalkReplyDispatcher(params) {
|
|
|
1037
1065
|
payload.output,
|
|
1038
1066
|
commandText
|
|
1039
1067
|
].filter(Boolean).join("\n") || "";
|
|
1040
|
-
if (/\bdws\b/i.test(fullCmd)) import("./dws-delivery-context-
|
|
1068
|
+
if (/\bdws\b/i.test(fullCmd)) import("./dws-delivery-context-DWm03KM4.mjs").then(({ maybeInjectDwsOutboundContext }) => maybeInjectDwsOutboundContext({
|
|
1041
1069
|
cfg,
|
|
1042
1070
|
accountConfig: account.config,
|
|
1043
1071
|
agentId,
|
|
@@ -2038,7 +2066,7 @@ async function handleDingTalkMessageInternal(params) {
|
|
|
2038
2066
|
const rawText = content.text || "";
|
|
2039
2067
|
let userContent = normalizeSlashCommand(rawText) || (content.imageUrls.length > 0 ? "请描述这张图片" : "");
|
|
2040
2068
|
try {
|
|
2041
|
-
const { GamificationEngine, isGamificationCommand } = await import("./game-xiyou-
|
|
2069
|
+
const { GamificationEngine, isGamificationCommand } = await import("./game-xiyou-DQd3u2jI.mjs");
|
|
2042
2070
|
if (isGamificationCommand(rawText)) {
|
|
2043
2071
|
const engine = GamificationEngine.getInstanceForUser(senderId);
|
|
2044
2072
|
if (rawText.trim().startsWith("/西游") || engine.isEnabled()) {
|
|
@@ -2356,7 +2384,7 @@ async function handleDingTalkMessageInternal(params) {
|
|
|
2356
2384
|
finalText = await processVideoMarkers(finalText, "", config, oapiToken, log, true, mediaTarget);
|
|
2357
2385
|
finalText = await processAudioMarkers(finalText, "", config, oapiToken, log, true, mediaTarget);
|
|
2358
2386
|
finalText = await uploadAndReplaceFileMarkers(finalText, "", config, oapiToken, log, true, mediaTarget);
|
|
2359
|
-
const { processRawMediaPaths } = await import("./media-
|
|
2387
|
+
const { processRawMediaPaths } = await import("./media-C90EIqKj.mjs").then((n) => n.n);
|
|
2360
2388
|
finalText = await processRawMediaPaths(finalText, config, oapiToken, log, mediaTarget);
|
|
2361
2389
|
}
|
|
2362
2390
|
const textToSend = finalText.trim() || "✅ 任务执行完成(无文本输出)";
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { i as
|
|
5
|
-
import { i as
|
|
1
|
+
import { n as createLoggerFromConfig, r as isDingtalkDebug } from "./logger-CWZBxzcb.mjs";
|
|
2
|
+
import { t as dingtalkHttp } from "./http-client-ii7_j0AF.mjs";
|
|
3
|
+
import { a as getOapiAccessToken, i as getAccessToken, n as DINGTALK_API } from "./utils-DIQU5Sf1.mjs";
|
|
4
|
+
import { i as MEDIA_MSG_TYPES } from "./session-_6Ywf0sf.mjs";
|
|
5
|
+
import { a as uploadMediaToDingTalk, i as processLocalImages, r as processImagesForOutbound, t as logMediaIdTrace } from "./media-C90EIqKj.mjs";
|
|
6
6
|
//#region src/services/reply-markers.ts
|
|
7
7
|
const PROCESS_TAG = "[-process-]";
|
|
8
8
|
const FINAL_TAG = "[-final-]";
|
|
@@ -371,7 +371,7 @@ async function finishAICard(card, content, config, log, contentVar, skipInputing
|
|
|
371
371
|
const fixedContent = ensureTableBlankLines(cleanContent);
|
|
372
372
|
log?.info?.(`[DingTalk][AICard] 开始 finish(一次性定稿,无流式回放),最终内容长度=${fixedContent.length}`);
|
|
373
373
|
try {
|
|
374
|
-
const { rememberCardContent } = await import("./card-content-cache-
|
|
374
|
+
const { rememberCardContent } = await import("./card-content-cache-CRgMn6Ze.mjs");
|
|
375
375
|
rememberCardContent({
|
|
376
376
|
text: fixedContent,
|
|
377
377
|
outTrackId: card.cardInstanceId,
|
|
@@ -876,7 +876,7 @@ async function resolveMediaSourceToLocalFile(mediaUrl, mediaLocalRoots, log) {
|
|
|
876
876
|
cleanup: tmp
|
|
877
877
|
};
|
|
878
878
|
}
|
|
879
|
-
const { toLocalPath } = await import("./media-
|
|
879
|
+
const { toLocalPath } = await import("./media-C90EIqKj.mjs").then((n) => n.n);
|
|
880
880
|
const _fs = await import("fs");
|
|
881
881
|
const _path = await import("path");
|
|
882
882
|
let resolved = toLocalPath(mediaUrl);
|
|
@@ -1143,7 +1143,7 @@ async function sendMediaToDingTalk(params) {
|
|
|
1143
1143
|
const fileName = mediaUrl.split("/").filter(Boolean).pop()?.split("?")[0] || "file";
|
|
1144
1144
|
if (mediaType === "video") {
|
|
1145
1145
|
const videoMarker = `[DINGTALK_VIDEO]{"path":"${resolvedMediaUrl}"}[/DINGTALK_VIDEO]`;
|
|
1146
|
-
const { processVideoMarkers } = await import("./media-
|
|
1146
|
+
const { processVideoMarkers } = await import("./media-C90EIqKj.mjs").then((n) => n.n);
|
|
1147
1147
|
await processVideoMarkers(videoMarker, "", config, oapiToken, console, true, targetParam);
|
|
1148
1148
|
return {
|
|
1149
1149
|
ok: true,
|
|
@@ -1162,7 +1162,7 @@ async function sendMediaToDingTalk(params) {
|
|
|
1162
1162
|
fileName,
|
|
1163
1163
|
fileType: ext && ext.length < 12 ? ext : "file"
|
|
1164
1164
|
};
|
|
1165
|
-
const { sendFileProactive } = await import("./media-
|
|
1165
|
+
const { sendFileProactive } = await import("./media-C90EIqKj.mjs").then((n) => n.n);
|
|
1166
1166
|
await sendFileProactive(config, targetParam, fileInfo, uploadResult.mediaId, log);
|
|
1167
1167
|
return {
|
|
1168
1168
|
ok: true,
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { createRequire } from "node:module";
|
|
2
|
+
//#region \0rolldown/runtime.js
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __exportAll = (all, no_symbols) => {
|
|
5
|
+
let target = {};
|
|
6
|
+
for (var name in all) __defProp(target, name, {
|
|
7
|
+
get: all[name],
|
|
8
|
+
enumerable: true
|
|
9
|
+
});
|
|
10
|
+
if (!no_symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
|
|
11
|
+
return target;
|
|
12
|
+
};
|
|
13
|
+
var __require = /* @__PURE__ */ createRequire(import.meta.url);
|
|
14
|
+
//#endregion
|
|
15
|
+
export { __require as n, __exportAll as t };
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { n as getSafeRequire } from "./compat-BhZoKOuf.mjs";
|
|
1
2
|
//#region src/utils/constants.ts
|
|
2
3
|
/**
|
|
3
4
|
* 常量定义模块
|
|
@@ -116,14 +117,24 @@ function buildSessionContext(params) {
|
|
|
116
117
|
groupSubject
|
|
117
118
|
};
|
|
118
119
|
}
|
|
119
|
-
/**
|
|
120
|
-
* 尝试动态加载 SDK 中的 isAbortRequestText
|
|
121
|
-
*/
|
|
122
120
|
let sdkIsAbortRequestText = null;
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
if (
|
|
126
|
-
|
|
121
|
+
let sdkLoadAttempted = false;
|
|
122
|
+
function getSdkAbortDetector() {
|
|
123
|
+
if (!sdkLoadAttempted) {
|
|
124
|
+
sdkLoadAttempted = true;
|
|
125
|
+
try {
|
|
126
|
+
const req = getSafeRequire();
|
|
127
|
+
for (const pkg of ["openclaw", "jeikclaw"]) try {
|
|
128
|
+
const mod = req(`${pkg}/plugin-sdk/command-primitives-runtime`);
|
|
129
|
+
if (typeof mod?.isAbortRequestText === "function") {
|
|
130
|
+
sdkIsAbortRequestText = mod.isAbortRequestText;
|
|
131
|
+
break;
|
|
132
|
+
}
|
|
133
|
+
} catch {}
|
|
134
|
+
} catch {}
|
|
135
|
+
}
|
|
136
|
+
return sdkIsAbortRequestText;
|
|
137
|
+
}
|
|
127
138
|
/**
|
|
128
139
|
* 检查消息是否是中止/停止任务命令
|
|
129
140
|
* 支持 /stop, stop, 停止, 暂停 等,以及群聊中带 @机器人 /stop 的情况
|
|
@@ -132,13 +143,14 @@ function isAbortCommand(text) {
|
|
|
132
143
|
if (!text) return false;
|
|
133
144
|
const trimmed = text.trim();
|
|
134
145
|
if (!trimmed) return false;
|
|
146
|
+
const detector = getSdkAbortDetector();
|
|
135
147
|
try {
|
|
136
|
-
if (
|
|
148
|
+
if (detector?.(trimmed)) return true;
|
|
137
149
|
} catch {}
|
|
138
150
|
const stripped = trimmed.replace(/@[^\s]+/g, "").trim();
|
|
139
151
|
if (stripped) {
|
|
140
152
|
try {
|
|
141
|
-
if (
|
|
153
|
+
if (detector?.(stripped)) return true;
|
|
142
154
|
} catch {}
|
|
143
155
|
const lower = stripped.toLowerCase().replace(/^[!/]/, "");
|
|
144
156
|
if (STOP_COMMANDS.some((cmd) => cmd.toLowerCase().replace(/^[!/]/, "") === lower)) return true;
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import "./
|
|
1
|
+
import { t as __exportAll } from "./rolldown-runtime-BCk198RA.mjs";
|
|
2
|
+
import { a as setDingtalkDebug, n as createLoggerFromConfig, r as isDingtalkDebug, t as createLogger } from "./logger-CWZBxzcb.mjs";
|
|
3
|
+
import { n as dingtalkOapiHttp, t as dingtalkHttp } from "./http-client-ii7_j0AF.mjs";
|
|
4
|
+
import { a as NEW_SESSION_COMMANDS, i as MEDIA_MSG_TYPES, n as isAbortCommand, o as QUEUE_BUSY_ACK_PHRASES, r as normalizeSlashCommand, s as STOP_COMMANDS, t as buildSessionContext } from "./session-_6Ywf0sf.mjs";
|
|
3
5
|
//#region src/utils/token.ts
|
|
4
6
|
const DINGTALK_API = "https://api.dingtalk.com";
|
|
5
7
|
const DINGTALK_OAPI = "https://oapi.dingtalk.com";
|
|
@@ -61,4 +63,23 @@ async function getOapiAccessToken(config) {
|
|
|
61
63
|
}
|
|
62
64
|
}
|
|
63
65
|
//#endregion
|
|
64
|
-
|
|
66
|
+
//#region src/utils/index.ts
|
|
67
|
+
var utils_exports = /* @__PURE__ */ __exportAll({
|
|
68
|
+
DINGTALK_API: () => DINGTALK_API,
|
|
69
|
+
DINGTALK_OAPI: () => DINGTALK_OAPI,
|
|
70
|
+
MEDIA_MSG_TYPES: () => MEDIA_MSG_TYPES,
|
|
71
|
+
NEW_SESSION_COMMANDS: () => NEW_SESSION_COMMANDS,
|
|
72
|
+
QUEUE_BUSY_ACK_PHRASES: () => QUEUE_BUSY_ACK_PHRASES,
|
|
73
|
+
STOP_COMMANDS: () => STOP_COMMANDS,
|
|
74
|
+
buildSessionContext: () => buildSessionContext,
|
|
75
|
+
createLogger: () => createLogger,
|
|
76
|
+
createLoggerFromConfig: () => createLoggerFromConfig,
|
|
77
|
+
getAccessToken: () => getAccessToken,
|
|
78
|
+
getOapiAccessToken: () => getOapiAccessToken,
|
|
79
|
+
isAbortCommand: () => isAbortCommand,
|
|
80
|
+
isDingtalkDebug: () => isDingtalkDebug,
|
|
81
|
+
normalizeSlashCommand: () => normalizeSlashCommand,
|
|
82
|
+
setDingtalkDebug: () => setDingtalkDebug
|
|
83
|
+
});
|
|
84
|
+
//#endregion
|
|
85
|
+
export { getOapiAccessToken as a, getAccessToken as i, DINGTALK_API as n, DINGTALK_OAPI as r, utils_exports as t };
|
|
@@ -1,5 +1,23 @@
|
|
|
1
|
-
import "./
|
|
1
|
+
import { t as __exportAll } from "./rolldown-runtime-BCk198RA.mjs";
|
|
2
2
|
//#region src/utils/utils-legacy.ts
|
|
3
|
+
var utils_legacy_exports = /* @__PURE__ */ __exportAll({
|
|
4
|
+
DEFAULT_ACCOUNT_ID: () => DEFAULT_ACCOUNT_ID,
|
|
5
|
+
DINGTALK_API: () => DINGTALK_API,
|
|
6
|
+
DINGTALK_OAPI: () => DINGTALK_OAPI,
|
|
7
|
+
addEmotionReply: () => addEmotionReply,
|
|
8
|
+
checkAndMarkDingtalkMessage: () => checkAndMarkDingtalkMessage,
|
|
9
|
+
cleanupProcessedMessages: () => cleanupProcessedMessages,
|
|
10
|
+
formatHiredDateShanghai: () => formatHiredDateShanghai,
|
|
11
|
+
formatSenderDisplayLabel: () => formatSenderDisplayLabel,
|
|
12
|
+
formatSenderRoles: () => formatSenderRoles,
|
|
13
|
+
getAccessToken: () => getAccessToken,
|
|
14
|
+
getOapiAccessToken: () => getOapiAccessToken,
|
|
15
|
+
getUnionId: () => getUnionId,
|
|
16
|
+
getUserProfile: () => getUserProfile,
|
|
17
|
+
isMessageProcessed: () => isMessageProcessed,
|
|
18
|
+
markMessageProcessed: () => markMessageProcessed,
|
|
19
|
+
recallEmotionReply: () => recallEmotionReply
|
|
20
|
+
});
|
|
3
21
|
/** 钉钉 API 常量 */
|
|
4
22
|
const DINGTALK_API = "https://api.dingtalk.com";
|
|
5
23
|
const DINGTALK_OAPI = "https://oapi.dingtalk.com";
|
|
@@ -18,7 +36,7 @@ async function getAccessToken(config) {
|
|
|
18
36
|
const key = cacheKey(config);
|
|
19
37
|
const cached = apiTokenCache.get(key);
|
|
20
38
|
if (cached && cached.expiryMs > now + 6e4) return cached.token;
|
|
21
|
-
const { dingtalkHttp } = await import("./http-client-
|
|
39
|
+
const { dingtalkHttp } = await import("./http-client-ii7_j0AF.mjs").then((n) => n.i);
|
|
22
40
|
const response = await dingtalkHttp.post(`${DINGTALK_API}/v1.0/oauth2/accessToken`, {
|
|
23
41
|
appKey: config.clientId,
|
|
24
42
|
appSecret: config.clientSecret
|
|
@@ -40,7 +58,7 @@ async function getOapiAccessToken(config) {
|
|
|
40
58
|
const key = cacheKey(config);
|
|
41
59
|
const cached = oapiTokenCache.get(key);
|
|
42
60
|
if (cached && cached.expiryMs > now + 6e4) return cached.token;
|
|
43
|
-
const { dingtalkOapiHttp } = await import("./http-client-
|
|
61
|
+
const { dingtalkOapiHttp } = await import("./http-client-ii7_j0AF.mjs").then((n) => n.i);
|
|
44
62
|
const resp = await dingtalkOapiHttp.get(`${DINGTALK_OAPI}/gettoken`, { params: {
|
|
45
63
|
appkey: config.clientId,
|
|
46
64
|
appsecret: config.clientSecret
|
|
@@ -147,7 +165,7 @@ async function getUserProfile(staffId, config, log) {
|
|
|
147
165
|
log?.warn?.("[DingTalk] getUserProfile: 无法获取 access_token");
|
|
148
166
|
return null;
|
|
149
167
|
}
|
|
150
|
-
const { dingtalkOapiHttp } = await import("./http-client-
|
|
168
|
+
const { dingtalkOapiHttp } = await import("./http-client-ii7_j0AF.mjs").then((n) => n.i);
|
|
151
169
|
let data;
|
|
152
170
|
try {
|
|
153
171
|
data = (await dingtalkOapiHttp.post(`https://oapi.dingtalk.com/topapi/v2/user/get`, {
|
|
@@ -272,7 +290,7 @@ async function addEmotionReply(config, data, log) {
|
|
|
272
290
|
if (!data.msgId || !data.conversationId) return;
|
|
273
291
|
try {
|
|
274
292
|
const token = await getAccessToken(config);
|
|
275
|
-
const { dingtalkHttp } = await import("./http-client-
|
|
293
|
+
const { dingtalkHttp } = await import("./http-client-ii7_j0AF.mjs").then((n) => n.i);
|
|
276
294
|
await dingtalkHttp.post(`${DINGTALK_API}/v1.0/robot/emotion/reply`, {
|
|
277
295
|
robotCode: data.robotCode ?? config.clientId,
|
|
278
296
|
openMsgId: data.msgId,
|
|
@@ -304,7 +322,7 @@ async function recallEmotionReply(config, data, log) {
|
|
|
304
322
|
if (!data.msgId || !data.conversationId) return;
|
|
305
323
|
try {
|
|
306
324
|
const token = await getAccessToken(config);
|
|
307
|
-
const { dingtalkHttp } = await import("./http-client-
|
|
325
|
+
const { dingtalkHttp } = await import("./http-client-ii7_j0AF.mjs").then((n) => n.i);
|
|
308
326
|
await dingtalkHttp.post(`${DINGTALK_API}/v1.0/robot/emotion/recall`, {
|
|
309
327
|
robotCode: data.robotCode ?? config.clientId,
|
|
310
328
|
openMsgId: data.msgId,
|
|
@@ -330,4 +348,4 @@ async function recallEmotionReply(config, data, log) {
|
|
|
330
348
|
}
|
|
331
349
|
}
|
|
332
350
|
//#endregion
|
|
333
|
-
export {
|
|
351
|
+
export { formatSenderDisplayLabel as a, getOapiAccessToken as c, recallEmotionReply as d, utils_legacy_exports as f, formatHiredDateShanghai as i, getUnionId as l, addEmotionReply as n, formatSenderRoles as o, checkAndMarkDingtalkMessage as r, getAccessToken as s, DINGTALK_API as t, getUserProfile as u };
|
package/index.ts
CHANGED
|
@@ -18,6 +18,7 @@ import type { OpenClawPluginApi } from "openclaw/plugin-sdk";
|
|
|
18
18
|
import { dingtalkPlugin, initDingtalkPluginConfigSchema } from "./src/channel.ts";
|
|
19
19
|
import { setDingtalkRuntime } from "./src/runtime.ts";
|
|
20
20
|
import { registerGatewayMethods } from "./src/gateway-methods.ts";
|
|
21
|
+
import { getCurrentModuleUrl } from "./src/utils/compat.ts";
|
|
21
22
|
|
|
22
23
|
export { dingtalkPlugin, initDingtalkPluginConfigSchema } from "./src/channel.ts";
|
|
23
24
|
export { setDingtalkRuntime } from "./src/runtime.ts";
|
|
@@ -45,8 +46,8 @@ function recordAndCheckLoadPath(api: OpenClawPluginApi): void {
|
|
|
45
46
|
g[DUPLICATE_LOAD_SYMBOL] = store;
|
|
46
47
|
|
|
47
48
|
const pluginId = "dingtalk-connector";
|
|
48
|
-
//
|
|
49
|
-
const here =
|
|
49
|
+
// 在 CJS 或 ESM 下解析当前模块路径,用于重复加载自检
|
|
50
|
+
const here = getCurrentModuleUrl("index.mjs");
|
|
50
51
|
const paths = store.get(pluginId) ?? new Set<string>();
|
|
51
52
|
paths.add(here);
|
|
52
53
|
store.set(pluginId, paths);
|
package/openclaw.plugin.json
CHANGED
package/package.json
CHANGED
package/src/channel.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { getSafeRequire } from "./utils/compat.ts";
|
|
2
2
|
import type {
|
|
3
3
|
ChannelPlugin,
|
|
4
4
|
ClawdbotConfig,
|
|
@@ -602,7 +602,7 @@ export const dingtalkPlugin: ChannelPlugin<ResolvedDingtalkAccount> = {
|
|
|
602
602
|
*/
|
|
603
603
|
export function initDingtalkPluginConfigSchema(): void {
|
|
604
604
|
if (dingtalkPlugin.configSchema != null) return;
|
|
605
|
-
const require_ =
|
|
605
|
+
const require_ = getSafeRequire();
|
|
606
606
|
const { buildChannelConfigSchema } = require_("openclaw/plugin-sdk/core");
|
|
607
607
|
(dingtalkPlugin as any).configSchema = buildChannelConfigSchema(DingtalkConfigBaseSchema);
|
|
608
608
|
}
|
package/src/reply-dispatcher.ts
CHANGED
|
@@ -17,14 +17,49 @@ interface ReplyPayload {
|
|
|
17
17
|
[key: string]: any;
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
20
|
+
import { getSafeRequire } from "./utils/compat.ts";
|
|
21
|
+
|
|
22
|
+
let channelRuntimeModule: any = null;
|
|
23
|
+
function getChannelRuntimeModule() {
|
|
24
|
+
if (!channelRuntimeModule) {
|
|
25
|
+
try {
|
|
26
|
+
const req = getSafeRequire();
|
|
27
|
+
for (const pkg of ["openclaw", "jeikclaw"]) {
|
|
28
|
+
try {
|
|
29
|
+
channelRuntimeModule = req(`${pkg}/plugin-sdk/channel-runtime`);
|
|
30
|
+
if (channelRuntimeModule) break;
|
|
31
|
+
} catch {}
|
|
32
|
+
}
|
|
33
|
+
} catch {}
|
|
34
|
+
}
|
|
35
|
+
return channelRuntimeModule || {};
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
function createReplyPrefixOptions(opts: any) {
|
|
39
|
+
const mod = getChannelRuntimeModule();
|
|
40
|
+
if (typeof mod.createReplyPrefixOptions === "function") {
|
|
41
|
+
return mod.createReplyPrefixOptions(opts);
|
|
42
|
+
}
|
|
43
|
+
return { ...opts };
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function createTypingCallbacks(opts: any) {
|
|
47
|
+
const mod = getChannelRuntimeModule();
|
|
48
|
+
if (typeof mod.createTypingCallbacks === "function") {
|
|
49
|
+
return mod.createTypingCallbacks(opts);
|
|
50
|
+
}
|
|
51
|
+
return {
|
|
52
|
+
onTypingStart: () => {},
|
|
53
|
+
onTypingStop: () => {},
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
function logTypingFailure(opts: any) {
|
|
58
|
+
const mod = getChannelRuntimeModule();
|
|
59
|
+
if (typeof mod.logTypingFailure === "function") {
|
|
60
|
+
return mod.logTypingFailure(opts);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
28
63
|
|
|
29
64
|
import { createLoggerFromConfig, isDingtalkDebug } from "./utils/logger.ts";
|
|
30
65
|
import { CHANNEL_ID } from "./channel.ts";
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { createRequire as nodeCreateRequire } from "node:module";
|
|
2
|
+
import { pathToFileURL } from "node:url";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* 获取跨运行环境(CJS / ESM / jiti)安全的 require 函数。
|
|
6
|
+
* 绝不使用裸 import.meta,避免在 CJS / Script 模式下触发 V8 解析器的 SyntaxError。
|
|
7
|
+
*/
|
|
8
|
+
export function getSafeRequire(basePath?: string): NodeRequire {
|
|
9
|
+
if (typeof require === "function") {
|
|
10
|
+
return require;
|
|
11
|
+
}
|
|
12
|
+
const resolvedPath =
|
|
13
|
+
basePath ||
|
|
14
|
+
(typeof __filename !== "undefined" && __filename) ||
|
|
15
|
+
`${process.cwd()}/package.json`;
|
|
16
|
+
return nodeCreateRequire(resolvedPath);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* 获取当前模块的路径或 file:// URL,完全兼容 ESM 与 CJS/jiti。
|
|
21
|
+
*/
|
|
22
|
+
export function getCurrentModuleUrl(fallbackName = "index.mjs"): string {
|
|
23
|
+
if (typeof __filename !== "undefined" && __filename) {
|
|
24
|
+
try {
|
|
25
|
+
return pathToFileURL(__filename).href;
|
|
26
|
+
} catch {
|
|
27
|
+
return `file://${__filename}`;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
try {
|
|
31
|
+
const err = new Error();
|
|
32
|
+
const stack = err.stack?.split("\n") || [];
|
|
33
|
+
for (const line of stack) {
|
|
34
|
+
const match = line.match(/(?:file:\/\/)?(\/[^:\s)]+\.(?:[cm]?[jt]sx?))/);
|
|
35
|
+
if (match && !match[1].includes("node:") && !match[1].includes("compat.")) {
|
|
36
|
+
return pathToFileURL(match[1]).href;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
} catch {}
|
|
40
|
+
return `file://${process.cwd()}/dist/${fallbackName}`;
|
|
41
|
+
}
|
package/src/utils/session.ts
CHANGED
|
@@ -134,17 +134,28 @@ export function buildSessionContext(params: {
|
|
|
134
134
|
};
|
|
135
135
|
}
|
|
136
136
|
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
*/
|
|
137
|
+
import { getSafeRequire } from './compat.ts';
|
|
138
|
+
|
|
140
139
|
let sdkIsAbortRequestText: ((text?: string, options?: any) => boolean) | null = null;
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
140
|
+
let sdkLoadAttempted = false;
|
|
141
|
+
|
|
142
|
+
function getSdkAbortDetector(): ((text?: string, options?: any) => boolean) | null {
|
|
143
|
+
if (!sdkLoadAttempted) {
|
|
144
|
+
sdkLoadAttempted = true;
|
|
145
|
+
try {
|
|
146
|
+
const req = getSafeRequire();
|
|
147
|
+
for (const pkg of ['openclaw', 'jeikclaw']) {
|
|
148
|
+
try {
|
|
149
|
+
const mod = req(`${pkg}/plugin-sdk/command-primitives-runtime`);
|
|
150
|
+
if (typeof mod?.isAbortRequestText === 'function') {
|
|
151
|
+
sdkIsAbortRequestText = mod.isAbortRequestText;
|
|
152
|
+
break;
|
|
153
|
+
}
|
|
154
|
+
} catch {}
|
|
155
|
+
}
|
|
156
|
+
} catch {}
|
|
145
157
|
}
|
|
146
|
-
|
|
147
|
-
// 忽略加载异常,走内联 fallback
|
|
158
|
+
return sdkIsAbortRequestText;
|
|
148
159
|
}
|
|
149
160
|
|
|
150
161
|
/**
|
|
@@ -157,15 +168,16 @@ export function isAbortCommand(text?: string): boolean {
|
|
|
157
168
|
if (!trimmed) return false;
|
|
158
169
|
|
|
159
170
|
// 1. SDK 原生判断
|
|
171
|
+
const detector = getSdkAbortDetector();
|
|
160
172
|
try {
|
|
161
|
-
if (
|
|
173
|
+
if (detector?.(trimmed)) return true;
|
|
162
174
|
} catch {}
|
|
163
175
|
|
|
164
176
|
// 2. 去除 @ 提及前缀后判断(针对群聊中 @机器人 /stop 的情况)
|
|
165
177
|
const stripped = trimmed.replace(/@[^\s]+/g, "").trim();
|
|
166
178
|
if (stripped) {
|
|
167
179
|
try {
|
|
168
|
-
if (
|
|
180
|
+
if (detector?.(stripped)) return true;
|
|
169
181
|
} catch {}
|
|
170
182
|
|
|
171
183
|
const lower = stripped.toLowerCase().replace(/^[!/]/, "");
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import { a as resolveDingtalkAccount, i as resolveDefaultDingtalkAccountSelection, n as listEnabledDingtalkAccounts, o as resolveDingtalkCredentials, r as resolveDefaultDingtalkAccountId, t as listDingtalkAccountIds } from "./accounts-BAzdqkAV.mjs";
|
|
2
|
-
export { listDingtalkAccountIds, listEnabledDingtalkAccounts, resolveDefaultDingtalkAccountId, resolveDefaultDingtalkAccountSelection, resolveDingtalkAccount, resolveDingtalkCredentials };
|
package/dist/common-DCVdWMiZ.mjs
DELETED
package/dist/logger-D8H2IcYz.mjs
DELETED
package/dist/media-o_kBcTXb.mjs
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import { _ as toLocalPath, d as processLocalImages, f as processRawMediaPaths, h as sendFileProactive, o as hasResidualLocalMdImagesOutsideCode, p as processVideoMarkers } from "./media-3G_kHjld.mjs";
|
|
2
|
-
export { hasResidualLocalMdImagesOutsideCode, processLocalImages, processRawMediaPaths, processVideoMarkers, sendFileProactive, toLocalPath };
|
package/dist/utils-CNXrWqt1.mjs
DELETED
|
File without changes
|
|
File without changes
|