liangzimixin 0.3.3 → 0.3.5
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/index.cjs +91 -20
- package/dist/index.d.cts +23 -4
- package/dist/setup-entry.cjs +91 -20
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -17458,20 +17458,48 @@ var AccountConfigSchema = external_exports.object({
|
|
|
17458
17458
|
* 🟡 Bot 自己的用户 ID — 用于 anti-loop 检查
|
|
17459
17459
|
* 如果不填,需要通过其他 API 在运行时获取。
|
|
17460
17460
|
*/
|
|
17461
|
-
botUserId: external_exports.string().optional()
|
|
17461
|
+
botUserId: external_exports.string().optional(),
|
|
17462
|
+
/** 🟡 部署环境 — staging=联调, production=线上 */
|
|
17463
|
+
env: external_exports.enum(["staging", "production"]).optional()
|
|
17462
17464
|
}).transform((raw) => ({
|
|
17463
17465
|
appId: raw.appId,
|
|
17464
17466
|
appSecret: raw.appSecret,
|
|
17465
17467
|
quantumAccount: raw["quantum-account"],
|
|
17466
17468
|
quantumAppId: raw["quantum-appId"],
|
|
17467
17469
|
quantumAppSecret: raw["quantum-appSecret"],
|
|
17468
|
-
botUserId: raw.botUserId
|
|
17470
|
+
botUserId: raw.botUserId,
|
|
17471
|
+
env: raw.env
|
|
17469
17472
|
}));
|
|
17473
|
+
var ENV_PRESETS = {
|
|
17474
|
+
/** 联调环境 */
|
|
17475
|
+
staging: {
|
|
17476
|
+
apiBaseUrl: "https://mxpre.zdxlz.com:1443/open-apis/v1",
|
|
17477
|
+
wsBaseUrl: "wss://mxpre.zdxlz.com:1443/open-apis/v1",
|
|
17478
|
+
msgBaseUrl: "https://mxpre.zdxlz.com:1443/open-apis/v1",
|
|
17479
|
+
fileBaseUrl: "https://mxpre.zdxlz.com:1443/open-apis/v1"
|
|
17480
|
+
},
|
|
17481
|
+
/** 线上环境 */
|
|
17482
|
+
production: {
|
|
17483
|
+
apiBaseUrl: "https://imtwo.zdxlz.com/open-apis/v1",
|
|
17484
|
+
wsBaseUrl: "wss://imtwo.zdxlz.com/open-apis/v1",
|
|
17485
|
+
msgBaseUrl: "https://imtwo.zdxlz.com/open-apis/v1",
|
|
17486
|
+
fileBaseUrl: "https://imtwo.zdxlz.com/open-apis/v1"
|
|
17487
|
+
}
|
|
17488
|
+
};
|
|
17489
|
+
function resolveEnv(accountEnv) {
|
|
17490
|
+
if (accountEnv) return accountEnv;
|
|
17491
|
+
const raw = (process.env.LZMX_ENV || "").trim().toLowerCase();
|
|
17492
|
+
if (raw === "staging" || raw === "test" || raw === "dev") return "staging";
|
|
17493
|
+
return "production";
|
|
17494
|
+
}
|
|
17495
|
+
var CURRENT_ENV = resolveEnv();
|
|
17496
|
+
var PRESET = ENV_PRESETS[CURRENT_ENV];
|
|
17470
17497
|
var DEFAULT_INTERNAL_CONFIG = {
|
|
17471
17498
|
pluginId: CHANNEL_ID,
|
|
17499
|
+
env: CURRENT_ENV,
|
|
17472
17500
|
logLevel: "info",
|
|
17473
17501
|
transport: {
|
|
17474
|
-
wsUrl: process.env.LZMX_WS_URL ||
|
|
17502
|
+
wsUrl: process.env.LZMX_WS_URL || PRESET.wsBaseUrl,
|
|
17475
17503
|
heartbeatIntervalMs: 3e4,
|
|
17476
17504
|
heartbeatTimeoutMs: 1e4,
|
|
17477
17505
|
reconnectBaseMs: 1e3,
|
|
@@ -17483,7 +17511,7 @@ var DEFAULT_INTERNAL_CONFIG = {
|
|
|
17483
17511
|
}
|
|
17484
17512
|
},
|
|
17485
17513
|
auth: {
|
|
17486
|
-
serverUrl: process.env.LZMX_AUTH_URL ||
|
|
17514
|
+
serverUrl: process.env.LZMX_AUTH_URL || PRESET.apiBaseUrl,
|
|
17487
17515
|
refreshAheadMs: 3e5
|
|
17488
17516
|
},
|
|
17489
17517
|
crypto: {
|
|
@@ -17492,10 +17520,10 @@ var DEFAULT_INTERNAL_CONFIG = {
|
|
|
17492
17520
|
envKey: "QUANTUM_ENCRYPTION_KEY"
|
|
17493
17521
|
},
|
|
17494
17522
|
message: {
|
|
17495
|
-
messageServiceBaseUrl: process.env.LZMX_MSG_URL ||
|
|
17523
|
+
messageServiceBaseUrl: process.env.LZMX_MSG_URL || PRESET.msgBaseUrl
|
|
17496
17524
|
},
|
|
17497
17525
|
file: {
|
|
17498
|
-
fileServiceBaseUrl: process.env.LZMX_FILE_URL ||
|
|
17526
|
+
fileServiceBaseUrl: process.env.LZMX_FILE_URL || PRESET.fileBaseUrl,
|
|
17499
17527
|
maxFileSizeMb: 30,
|
|
17500
17528
|
chunkSizeMb: 5,
|
|
17501
17529
|
allowedLocalRoots: ["/tmp/openclaw"],
|
|
@@ -17504,7 +17532,28 @@ var DEFAULT_INTERNAL_CONFIG = {
|
|
|
17504
17532
|
}
|
|
17505
17533
|
};
|
|
17506
17534
|
function buildPluginConfig(accountConfig, internalOverrides) {
|
|
17507
|
-
const
|
|
17535
|
+
const env = resolveEnv(accountConfig.env);
|
|
17536
|
+
const preset = ENV_PRESETS[env];
|
|
17537
|
+
const envAwareDefaults = {
|
|
17538
|
+
...DEFAULT_INTERNAL_CONFIG,
|
|
17539
|
+
env,
|
|
17540
|
+
transport: {
|
|
17541
|
+
...DEFAULT_INTERNAL_CONFIG.transport,
|
|
17542
|
+
wsUrl: process.env.LZMX_WS_URL || preset.wsBaseUrl
|
|
17543
|
+
},
|
|
17544
|
+
auth: {
|
|
17545
|
+
...DEFAULT_INTERNAL_CONFIG.auth,
|
|
17546
|
+
serverUrl: process.env.LZMX_AUTH_URL || preset.apiBaseUrl
|
|
17547
|
+
},
|
|
17548
|
+
message: {
|
|
17549
|
+
messageServiceBaseUrl: process.env.LZMX_MSG_URL || preset.msgBaseUrl
|
|
17550
|
+
},
|
|
17551
|
+
file: {
|
|
17552
|
+
...DEFAULT_INTERNAL_CONFIG.file,
|
|
17553
|
+
fileServiceBaseUrl: process.env.LZMX_FILE_URL || preset.fileBaseUrl
|
|
17554
|
+
}
|
|
17555
|
+
};
|
|
17556
|
+
const internal = { ...envAwareDefaults, ...internalOverrides };
|
|
17508
17557
|
return {
|
|
17509
17558
|
...internal,
|
|
17510
17559
|
credentials: accountConfig
|
|
@@ -17971,7 +18020,7 @@ async function resolveAndUploadMedia(params) {
|
|
|
17971
18020
|
};
|
|
17972
18021
|
}
|
|
17973
18022
|
const msgType = fileType;
|
|
17974
|
-
const contentPayload = fileType === "file" ? {
|
|
18023
|
+
const contentPayload = fileType === "file" ? { fileId: uploadResult.fileKey, fileName, size: uploadResult.fileSize } : { fileId: uploadResult.fileKey };
|
|
17975
18024
|
await messagePipe.sendMessage({
|
|
17976
18025
|
chatId,
|
|
17977
18026
|
senderId: chatId,
|
|
@@ -17981,7 +18030,7 @@ async function resolveAndUploadMedia(params) {
|
|
|
17981
18030
|
});
|
|
17982
18031
|
log3.info("media:sent", {
|
|
17983
18032
|
chatId,
|
|
17984
|
-
|
|
18033
|
+
fileId: uploadResult.fileKey,
|
|
17985
18034
|
msgType
|
|
17986
18035
|
});
|
|
17987
18036
|
return {
|
|
@@ -18108,20 +18157,20 @@ ${body}` : body || raw.content;
|
|
|
18108
18157
|
}
|
|
18109
18158
|
case "image": {
|
|
18110
18159
|
const c = parsed;
|
|
18111
|
-
fileId = c?.
|
|
18160
|
+
fileId = c?.fileId;
|
|
18112
18161
|
text = c?.altText ?? (fileId ? `` : "[image]");
|
|
18113
18162
|
break;
|
|
18114
18163
|
}
|
|
18115
18164
|
case "file": {
|
|
18116
18165
|
const c = parsed;
|
|
18117
|
-
fileId = c?.
|
|
18118
|
-
fileName = c?.
|
|
18166
|
+
fileId = c?.fileId;
|
|
18167
|
+
fileName = c?.fileName;
|
|
18119
18168
|
text = fileName ? `[File: ${fileName}]` : "[file]";
|
|
18120
18169
|
break;
|
|
18121
18170
|
}
|
|
18122
18171
|
case "voice": {
|
|
18123
18172
|
const c = parsed;
|
|
18124
|
-
fileId = c?.
|
|
18173
|
+
fileId = c?.fileId;
|
|
18125
18174
|
const durationMs = c?.duration;
|
|
18126
18175
|
const durationStr = durationMs != null ? ` ${(durationMs / 1e3).toFixed(1)}s` : "";
|
|
18127
18176
|
text = `[Voice${durationStr}]`;
|
|
@@ -18129,7 +18178,7 @@ ${body}` : body || raw.content;
|
|
|
18129
18178
|
}
|
|
18130
18179
|
case "video": {
|
|
18131
18180
|
const c = parsed;
|
|
18132
|
-
fileId = c?.
|
|
18181
|
+
fileId = c?.fileId;
|
|
18133
18182
|
const durationMs = c?.duration;
|
|
18134
18183
|
const durationStr = durationMs != null ? ` ${(durationMs / 1e3).toFixed(1)}s` : "";
|
|
18135
18184
|
text = `[Video${durationStr}]`;
|
|
@@ -18489,6 +18538,13 @@ var QUANTUM_IM_CONFIG_JSON_SCHEMA = {
|
|
|
18489
18538
|
type: "string",
|
|
18490
18539
|
title: "Bot \u7528\u6237 ID",
|
|
18491
18540
|
description: "\u7528\u4E8E anti-loop \u68C0\u67E5\uFF0C\u9632\u6B62\u5904\u7406\u81EA\u5DF1\u53D1\u9001\u7684\u6D88\u606F"
|
|
18541
|
+
},
|
|
18542
|
+
env: {
|
|
18543
|
+
type: "string",
|
|
18544
|
+
title: "\u90E8\u7F72\u73AF\u5883",
|
|
18545
|
+
description: "\u9009\u62E9\u5BF9\u63A5\u7684\u670D\u52A1\u5668\u73AF\u5883\u3002staging = \u8054\u8C03\u73AF\u5883\uFF0Cproduction = \u7EBF\u4E0A\u73AF\u5883",
|
|
18546
|
+
enum: ["staging", "production"],
|
|
18547
|
+
default: "production"
|
|
18492
18548
|
}
|
|
18493
18549
|
}
|
|
18494
18550
|
};
|
|
@@ -19752,11 +19808,18 @@ var MessagePipe = class {
|
|
|
19752
19808
|
log21.warn("inbound:data-parse-error", { error: err.message });
|
|
19753
19809
|
return;
|
|
19754
19810
|
}
|
|
19755
|
-
if (callbackData.eventType !== "
|
|
19811
|
+
if (callbackData.eventType !== "callback:direct") {
|
|
19756
19812
|
log21.debug("inbound:event-ignored", { eventType: callbackData.eventType });
|
|
19757
19813
|
return;
|
|
19758
19814
|
}
|
|
19759
|
-
const msg =
|
|
19815
|
+
const msg = {
|
|
19816
|
+
messageId: callbackData.msgUid,
|
|
19817
|
+
chatId: callbackData.groupId || callbackData.userId,
|
|
19818
|
+
senderId: callbackData.userId,
|
|
19819
|
+
msgType: callbackData.type,
|
|
19820
|
+
content: JSON.stringify(callbackData.content),
|
|
19821
|
+
timestamp: Date.now()
|
|
19822
|
+
};
|
|
19760
19823
|
log21.debug("inbound:frame", { messageId: msg.messageId, eventType: callbackData.eventType });
|
|
19761
19824
|
if (this.dedup.isDuplicate(msg.messageId)) {
|
|
19762
19825
|
log21.debug("inbound:dedup-hit", { messageId: msg.messageId });
|
|
@@ -19817,10 +19880,14 @@ var ConnectionManager = class {
|
|
|
19817
19880
|
this.running = true;
|
|
19818
19881
|
this.reconnectAttempts = 0;
|
|
19819
19882
|
const token = await tokenFn();
|
|
19883
|
+
const wsUrl = url2.replace(/\/+$/, "") + "/events/stream";
|
|
19820
19884
|
await this.client.connect({
|
|
19821
|
-
url:
|
|
19885
|
+
url: wsUrl,
|
|
19822
19886
|
token,
|
|
19823
|
-
headers:
|
|
19887
|
+
headers: {
|
|
19888
|
+
"Authorization": token,
|
|
19889
|
+
...this.appId ? { "X-App-ID": this.appId } : {}
|
|
19890
|
+
}
|
|
19824
19891
|
});
|
|
19825
19892
|
this.client.on("close", () => {
|
|
19826
19893
|
if (this.running) {
|
|
@@ -19873,10 +19940,14 @@ var ConnectionManager = class {
|
|
|
19873
19940
|
this.reconnectAttempts++;
|
|
19874
19941
|
try {
|
|
19875
19942
|
const token = await this.tokenFn();
|
|
19943
|
+
const wsUrl = this.url.replace(/\/+$/, "") + "/events/stream";
|
|
19876
19944
|
await this.client.connect({
|
|
19877
|
-
url:
|
|
19945
|
+
url: wsUrl,
|
|
19878
19946
|
token,
|
|
19879
|
-
headers:
|
|
19947
|
+
headers: {
|
|
19948
|
+
"Authorization": token,
|
|
19949
|
+
...this.appId ? { "X-App-ID": this.appId } : {}
|
|
19950
|
+
}
|
|
19880
19951
|
});
|
|
19881
19952
|
this.reconnectAttempts = 0;
|
|
19882
19953
|
this.startHeartbeat();
|
package/dist/index.d.cts
CHANGED
|
@@ -22,6 +22,10 @@ declare const AccountConfigSchema: z.ZodPipe<z.ZodObject<{
|
|
|
22
22
|
'quantum-appId': z.ZodString;
|
|
23
23
|
'quantum-appSecret': z.ZodString;
|
|
24
24
|
botUserId: z.ZodOptional<z.ZodString>;
|
|
25
|
+
env: z.ZodOptional<z.ZodEnum<{
|
|
26
|
+
staging: "staging";
|
|
27
|
+
production: "production";
|
|
28
|
+
}>>;
|
|
25
29
|
}, z.core.$strip>, z.ZodTransform<{
|
|
26
30
|
appId: string;
|
|
27
31
|
appSecret: string;
|
|
@@ -29,6 +33,7 @@ declare const AccountConfigSchema: z.ZodPipe<z.ZodObject<{
|
|
|
29
33
|
quantumAppId: string;
|
|
30
34
|
quantumAppSecret: string;
|
|
31
35
|
botUserId: string | undefined;
|
|
36
|
+
env: "staging" | "production" | undefined;
|
|
32
37
|
}, {
|
|
33
38
|
appId: string;
|
|
34
39
|
appSecret: string;
|
|
@@ -36,12 +41,17 @@ declare const AccountConfigSchema: z.ZodPipe<z.ZodObject<{
|
|
|
36
41
|
'quantum-appId': string;
|
|
37
42
|
'quantum-appSecret': string;
|
|
38
43
|
botUserId?: string | undefined;
|
|
44
|
+
env?: "staging" | "production" | undefined;
|
|
39
45
|
}>>;
|
|
40
46
|
type AccountConfig = z.output<typeof AccountConfigSchema>;
|
|
47
|
+
/** 支持的部署环境 */
|
|
48
|
+
type DeployEnv = 'staging' | 'production';
|
|
41
49
|
/** 运维级内部配置 — 由运维提供,直接在代码或环境变量中设定 */
|
|
42
50
|
interface InternalConfig {
|
|
43
51
|
/** 🟡 插件唯一标识 */
|
|
44
52
|
pluginId: string;
|
|
53
|
+
/** 🟡 当前部署环境 */
|
|
54
|
+
env: DeployEnv;
|
|
45
55
|
/** 🟡 日志级别 */
|
|
46
56
|
logLevel: 'debug' | 'info' | 'warn' | 'error';
|
|
47
57
|
transport: {
|
|
@@ -114,6 +124,8 @@ interface PluginConfig extends InternalConfig {
|
|
|
114
124
|
/**
|
|
115
125
|
* 合并用户配置与内部配置,生成完整的运行时配置。
|
|
116
126
|
*
|
|
127
|
+
* 如果用户在 openclaw.json 中指定了 env 字段,会自动切换到对应环境的 URL 预设。
|
|
128
|
+
*
|
|
117
129
|
* @param accountConfig - 已解析的用户账户配置
|
|
118
130
|
* @param internalOverrides - 可选的内部配置覆盖(用于测试或特殊部署)
|
|
119
131
|
*/
|
|
@@ -146,10 +158,10 @@ interface InboundMessage {
|
|
|
146
158
|
* 根据 msgType 解析为对应的 Content 类型:
|
|
147
159
|
* - text: `{"content": "你好"}`
|
|
148
160
|
* - markdown: `{"title": "标题", "content": "正文", "recommendations": [...]}`
|
|
149
|
-
* - image: `{"
|
|
150
|
-
* - file: `{"
|
|
151
|
-
* - voice: `{"
|
|
152
|
-
* - video: `{"
|
|
161
|
+
* - image: `{"fileId": "xxx", "width": 1920, "height": 1200}`
|
|
162
|
+
* - file: `{"fileId": "xxx", "fileName": "test.xlsx", "size": 9763}`
|
|
163
|
+
* - voice: `{"fileId": "xxx", "duration": 2914.23}`
|
|
164
|
+
* - video: `{"fileId": "xxx", "duration": 5291667.32, "width": 1200}`
|
|
153
165
|
* - system: `{"text": "用户已加入会话"}`
|
|
154
166
|
*/
|
|
155
167
|
content: string;
|
|
@@ -1035,6 +1047,13 @@ declare const QUANTUM_IM_CONFIG_JSON_SCHEMA: {
|
|
|
1035
1047
|
readonly title: "Bot 用户 ID";
|
|
1036
1048
|
readonly description: "用于 anti-loop 检查,防止处理自己发送的消息";
|
|
1037
1049
|
};
|
|
1050
|
+
readonly env: {
|
|
1051
|
+
readonly type: "string";
|
|
1052
|
+
readonly title: "部署环境";
|
|
1053
|
+
readonly description: "选择对接的服务器环境。staging = 联调环境,production = 线上环境";
|
|
1054
|
+
readonly enum: readonly ["staging", "production"];
|
|
1055
|
+
readonly default: "production";
|
|
1056
|
+
};
|
|
1038
1057
|
};
|
|
1039
1058
|
};
|
|
1040
1059
|
|
package/dist/setup-entry.cjs
CHANGED
|
@@ -4120,7 +4120,7 @@ async function resolveAndUploadMedia(params) {
|
|
|
4120
4120
|
};
|
|
4121
4121
|
}
|
|
4122
4122
|
const msgType = fileType;
|
|
4123
|
-
const contentPayload = fileType === "file" ? {
|
|
4123
|
+
const contentPayload = fileType === "file" ? { fileId: uploadResult.fileKey, fileName, size: uploadResult.fileSize } : { fileId: uploadResult.fileKey };
|
|
4124
4124
|
await messagePipe.sendMessage({
|
|
4125
4125
|
chatId,
|
|
4126
4126
|
senderId: chatId,
|
|
@@ -4130,7 +4130,7 @@ async function resolveAndUploadMedia(params) {
|
|
|
4130
4130
|
});
|
|
4131
4131
|
log3.info("media:sent", {
|
|
4132
4132
|
chatId,
|
|
4133
|
-
|
|
4133
|
+
fileId: uploadResult.fileKey,
|
|
4134
4134
|
msgType
|
|
4135
4135
|
});
|
|
4136
4136
|
return {
|
|
@@ -18014,20 +18014,48 @@ var AccountConfigSchema = external_exports.object({
|
|
|
18014
18014
|
* 🟡 Bot 自己的用户 ID — 用于 anti-loop 检查
|
|
18015
18015
|
* 如果不填,需要通过其他 API 在运行时获取。
|
|
18016
18016
|
*/
|
|
18017
|
-
botUserId: external_exports.string().optional()
|
|
18017
|
+
botUserId: external_exports.string().optional(),
|
|
18018
|
+
/** 🟡 部署环境 — staging=联调, production=线上 */
|
|
18019
|
+
env: external_exports.enum(["staging", "production"]).optional()
|
|
18018
18020
|
}).transform((raw) => ({
|
|
18019
18021
|
appId: raw.appId,
|
|
18020
18022
|
appSecret: raw.appSecret,
|
|
18021
18023
|
quantumAccount: raw["quantum-account"],
|
|
18022
18024
|
quantumAppId: raw["quantum-appId"],
|
|
18023
18025
|
quantumAppSecret: raw["quantum-appSecret"],
|
|
18024
|
-
botUserId: raw.botUserId
|
|
18026
|
+
botUserId: raw.botUserId,
|
|
18027
|
+
env: raw.env
|
|
18025
18028
|
}));
|
|
18029
|
+
var ENV_PRESETS = {
|
|
18030
|
+
/** 联调环境 */
|
|
18031
|
+
staging: {
|
|
18032
|
+
apiBaseUrl: "https://mxpre.zdxlz.com:1443/open-apis/v1",
|
|
18033
|
+
wsBaseUrl: "wss://mxpre.zdxlz.com:1443/open-apis/v1",
|
|
18034
|
+
msgBaseUrl: "https://mxpre.zdxlz.com:1443/open-apis/v1",
|
|
18035
|
+
fileBaseUrl: "https://mxpre.zdxlz.com:1443/open-apis/v1"
|
|
18036
|
+
},
|
|
18037
|
+
/** 线上环境 */
|
|
18038
|
+
production: {
|
|
18039
|
+
apiBaseUrl: "https://imtwo.zdxlz.com/open-apis/v1",
|
|
18040
|
+
wsBaseUrl: "wss://imtwo.zdxlz.com/open-apis/v1",
|
|
18041
|
+
msgBaseUrl: "https://imtwo.zdxlz.com/open-apis/v1",
|
|
18042
|
+
fileBaseUrl: "https://imtwo.zdxlz.com/open-apis/v1"
|
|
18043
|
+
}
|
|
18044
|
+
};
|
|
18045
|
+
function resolveEnv(accountEnv) {
|
|
18046
|
+
if (accountEnv) return accountEnv;
|
|
18047
|
+
const raw = (process.env.LZMX_ENV || "").trim().toLowerCase();
|
|
18048
|
+
if (raw === "staging" || raw === "test" || raw === "dev") return "staging";
|
|
18049
|
+
return "production";
|
|
18050
|
+
}
|
|
18051
|
+
var CURRENT_ENV = resolveEnv();
|
|
18052
|
+
var PRESET = ENV_PRESETS[CURRENT_ENV];
|
|
18026
18053
|
var DEFAULT_INTERNAL_CONFIG = {
|
|
18027
18054
|
pluginId: CHANNEL_ID,
|
|
18055
|
+
env: CURRENT_ENV,
|
|
18028
18056
|
logLevel: "info",
|
|
18029
18057
|
transport: {
|
|
18030
|
-
wsUrl: process.env.LZMX_WS_URL ||
|
|
18058
|
+
wsUrl: process.env.LZMX_WS_URL || PRESET.wsBaseUrl,
|
|
18031
18059
|
heartbeatIntervalMs: 3e4,
|
|
18032
18060
|
heartbeatTimeoutMs: 1e4,
|
|
18033
18061
|
reconnectBaseMs: 1e3,
|
|
@@ -18039,7 +18067,7 @@ var DEFAULT_INTERNAL_CONFIG = {
|
|
|
18039
18067
|
}
|
|
18040
18068
|
},
|
|
18041
18069
|
auth: {
|
|
18042
|
-
serverUrl: process.env.LZMX_AUTH_URL ||
|
|
18070
|
+
serverUrl: process.env.LZMX_AUTH_URL || PRESET.apiBaseUrl,
|
|
18043
18071
|
refreshAheadMs: 3e5
|
|
18044
18072
|
},
|
|
18045
18073
|
crypto: {
|
|
@@ -18048,10 +18076,10 @@ var DEFAULT_INTERNAL_CONFIG = {
|
|
|
18048
18076
|
envKey: "QUANTUM_ENCRYPTION_KEY"
|
|
18049
18077
|
},
|
|
18050
18078
|
message: {
|
|
18051
|
-
messageServiceBaseUrl: process.env.LZMX_MSG_URL ||
|
|
18079
|
+
messageServiceBaseUrl: process.env.LZMX_MSG_URL || PRESET.msgBaseUrl
|
|
18052
18080
|
},
|
|
18053
18081
|
file: {
|
|
18054
|
-
fileServiceBaseUrl: process.env.LZMX_FILE_URL ||
|
|
18082
|
+
fileServiceBaseUrl: process.env.LZMX_FILE_URL || PRESET.fileBaseUrl,
|
|
18055
18083
|
maxFileSizeMb: 30,
|
|
18056
18084
|
chunkSizeMb: 5,
|
|
18057
18085
|
allowedLocalRoots: ["/tmp/openclaw"],
|
|
@@ -18060,7 +18088,28 @@ var DEFAULT_INTERNAL_CONFIG = {
|
|
|
18060
18088
|
}
|
|
18061
18089
|
};
|
|
18062
18090
|
function buildPluginConfig(accountConfig, internalOverrides) {
|
|
18063
|
-
const
|
|
18091
|
+
const env = resolveEnv(accountConfig.env);
|
|
18092
|
+
const preset = ENV_PRESETS[env];
|
|
18093
|
+
const envAwareDefaults = {
|
|
18094
|
+
...DEFAULT_INTERNAL_CONFIG,
|
|
18095
|
+
env,
|
|
18096
|
+
transport: {
|
|
18097
|
+
...DEFAULT_INTERNAL_CONFIG.transport,
|
|
18098
|
+
wsUrl: process.env.LZMX_WS_URL || preset.wsBaseUrl
|
|
18099
|
+
},
|
|
18100
|
+
auth: {
|
|
18101
|
+
...DEFAULT_INTERNAL_CONFIG.auth,
|
|
18102
|
+
serverUrl: process.env.LZMX_AUTH_URL || preset.apiBaseUrl
|
|
18103
|
+
},
|
|
18104
|
+
message: {
|
|
18105
|
+
messageServiceBaseUrl: process.env.LZMX_MSG_URL || preset.msgBaseUrl
|
|
18106
|
+
},
|
|
18107
|
+
file: {
|
|
18108
|
+
...DEFAULT_INTERNAL_CONFIG.file,
|
|
18109
|
+
fileServiceBaseUrl: process.env.LZMX_FILE_URL || preset.fileBaseUrl
|
|
18110
|
+
}
|
|
18111
|
+
};
|
|
18112
|
+
const internal = { ...envAwareDefaults, ...internalOverrides };
|
|
18064
18113
|
return {
|
|
18065
18114
|
...internal,
|
|
18066
18115
|
credentials: accountConfig
|
|
@@ -19010,11 +19059,18 @@ var MessagePipe = class {
|
|
|
19010
19059
|
log12.warn("inbound:data-parse-error", { error: err.message });
|
|
19011
19060
|
return;
|
|
19012
19061
|
}
|
|
19013
|
-
if (callbackData.eventType !== "
|
|
19062
|
+
if (callbackData.eventType !== "callback:direct") {
|
|
19014
19063
|
log12.debug("inbound:event-ignored", { eventType: callbackData.eventType });
|
|
19015
19064
|
return;
|
|
19016
19065
|
}
|
|
19017
|
-
const msg =
|
|
19066
|
+
const msg = {
|
|
19067
|
+
messageId: callbackData.msgUid,
|
|
19068
|
+
chatId: callbackData.groupId || callbackData.userId,
|
|
19069
|
+
senderId: callbackData.userId,
|
|
19070
|
+
msgType: callbackData.type,
|
|
19071
|
+
content: JSON.stringify(callbackData.content),
|
|
19072
|
+
timestamp: Date.now()
|
|
19073
|
+
};
|
|
19018
19074
|
log12.debug("inbound:frame", { messageId: msg.messageId, eventType: callbackData.eventType });
|
|
19019
19075
|
if (this.dedup.isDuplicate(msg.messageId)) {
|
|
19020
19076
|
log12.debug("inbound:dedup-hit", { messageId: msg.messageId });
|
|
@@ -19075,10 +19131,14 @@ var ConnectionManager = class {
|
|
|
19075
19131
|
this.running = true;
|
|
19076
19132
|
this.reconnectAttempts = 0;
|
|
19077
19133
|
const token = await tokenFn();
|
|
19134
|
+
const wsUrl = url2.replace(/\/+$/, "") + "/events/stream";
|
|
19078
19135
|
await this.client.connect({
|
|
19079
|
-
url:
|
|
19136
|
+
url: wsUrl,
|
|
19080
19137
|
token,
|
|
19081
|
-
headers:
|
|
19138
|
+
headers: {
|
|
19139
|
+
"Authorization": token,
|
|
19140
|
+
...this.appId ? { "X-App-ID": this.appId } : {}
|
|
19141
|
+
}
|
|
19082
19142
|
});
|
|
19083
19143
|
this.client.on("close", () => {
|
|
19084
19144
|
if (this.running) {
|
|
@@ -19131,10 +19191,14 @@ var ConnectionManager = class {
|
|
|
19131
19191
|
this.reconnectAttempts++;
|
|
19132
19192
|
try {
|
|
19133
19193
|
const token = await this.tokenFn();
|
|
19194
|
+
const wsUrl = this.url.replace(/\/+$/, "") + "/events/stream";
|
|
19134
19195
|
await this.client.connect({
|
|
19135
|
-
url:
|
|
19196
|
+
url: wsUrl,
|
|
19136
19197
|
token,
|
|
19137
|
-
headers:
|
|
19198
|
+
headers: {
|
|
19199
|
+
"Authorization": token,
|
|
19200
|
+
...this.appId ? { "X-App-ID": this.appId } : {}
|
|
19201
|
+
}
|
|
19138
19202
|
});
|
|
19139
19203
|
this.reconnectAttempts = 0;
|
|
19140
19204
|
this.startHeartbeat();
|
|
@@ -19589,6 +19653,13 @@ var QUANTUM_IM_CONFIG_JSON_SCHEMA = {
|
|
|
19589
19653
|
type: "string",
|
|
19590
19654
|
title: "Bot \u7528\u6237 ID",
|
|
19591
19655
|
description: "\u7528\u4E8E anti-loop \u68C0\u67E5\uFF0C\u9632\u6B62\u5904\u7406\u81EA\u5DF1\u53D1\u9001\u7684\u6D88\u606F"
|
|
19656
|
+
},
|
|
19657
|
+
env: {
|
|
19658
|
+
type: "string",
|
|
19659
|
+
title: "\u90E8\u7F72\u73AF\u5883",
|
|
19660
|
+
description: "\u9009\u62E9\u5BF9\u63A5\u7684\u670D\u52A1\u5668\u73AF\u5883\u3002staging = \u8054\u8C03\u73AF\u5883\uFF0Cproduction = \u7EBF\u4E0A\u73AF\u5883",
|
|
19661
|
+
enum: ["staging", "production"],
|
|
19662
|
+
default: "production"
|
|
19592
19663
|
}
|
|
19593
19664
|
}
|
|
19594
19665
|
};
|
|
@@ -19702,20 +19773,20 @@ ${body}` : body || raw.content;
|
|
|
19702
19773
|
}
|
|
19703
19774
|
case "image": {
|
|
19704
19775
|
const c = parsed;
|
|
19705
|
-
fileId = c?.
|
|
19776
|
+
fileId = c?.fileId;
|
|
19706
19777
|
text = c?.altText ?? (fileId ? `` : "[image]");
|
|
19707
19778
|
break;
|
|
19708
19779
|
}
|
|
19709
19780
|
case "file": {
|
|
19710
19781
|
const c = parsed;
|
|
19711
|
-
fileId = c?.
|
|
19712
|
-
fileName = c?.
|
|
19782
|
+
fileId = c?.fileId;
|
|
19783
|
+
fileName = c?.fileName;
|
|
19713
19784
|
text = fileName ? `[File: ${fileName}]` : "[file]";
|
|
19714
19785
|
break;
|
|
19715
19786
|
}
|
|
19716
19787
|
case "voice": {
|
|
19717
19788
|
const c = parsed;
|
|
19718
|
-
fileId = c?.
|
|
19789
|
+
fileId = c?.fileId;
|
|
19719
19790
|
const durationMs = c?.duration;
|
|
19720
19791
|
const durationStr = durationMs != null ? ` ${(durationMs / 1e3).toFixed(1)}s` : "";
|
|
19721
19792
|
text = `[Voice${durationStr}]`;
|
|
@@ -19723,7 +19794,7 @@ ${body}` : body || raw.content;
|
|
|
19723
19794
|
}
|
|
19724
19795
|
case "video": {
|
|
19725
19796
|
const c = parsed;
|
|
19726
|
-
fileId = c?.
|
|
19797
|
+
fileId = c?.fileId;
|
|
19727
19798
|
const durationMs = c?.duration;
|
|
19728
19799
|
const durationStr = durationMs != null ? ` ${(durationMs / 1e3).toFixed(1)}s` : "";
|
|
19729
19800
|
text = `[Video${durationStr}]`;
|