liangzimixin 0.3.38 → 0.3.40
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 +39 -13
- package/dist/index.d.cts +4 -0
- package/dist/setup-entry.cjs +39 -13
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -17569,7 +17569,7 @@ var import_plugin_sdk3 = require("openclaw/plugin-sdk");
|
|
|
17569
17569
|
|
|
17570
17570
|
// src/file/media.ts
|
|
17571
17571
|
var path = __toESM(require("path"), 1);
|
|
17572
|
-
var fs = __toESM(require("fs"), 1);
|
|
17572
|
+
var fs = __toESM(require("fs/promises"), 1);
|
|
17573
17573
|
|
|
17574
17574
|
// src/types.ts
|
|
17575
17575
|
var EncryptionStrategy = /* @__PURE__ */ ((EncryptionStrategy2) => {
|
|
@@ -17827,8 +17827,8 @@ async function uploadMedia(params) {
|
|
|
17827
17827
|
if (Buffer.isBuffer(file2)) {
|
|
17828
17828
|
buffer = file2;
|
|
17829
17829
|
} else {
|
|
17830
|
-
const { readFile:
|
|
17831
|
-
buffer = await
|
|
17830
|
+
const { readFile: readFile3 } = await import("fs/promises");
|
|
17831
|
+
buffer = await readFile3(file2);
|
|
17832
17832
|
}
|
|
17833
17833
|
const maxBytes = maxFileSizeMb * 1024 * 1024;
|
|
17834
17834
|
if (buffer.length > maxBytes) {
|
|
@@ -18042,7 +18042,7 @@ async function resolveAndUploadMedia(params) {
|
|
|
18042
18042
|
const filePath = mediaUrl.startsWith("file://") ? mediaUrl.slice(7) : mediaUrl;
|
|
18043
18043
|
log3.info("media:source=local", { filePath });
|
|
18044
18044
|
validateLocalPath(filePath, allowedLocalRoots);
|
|
18045
|
-
buffer = fs.
|
|
18045
|
+
buffer = await fs.readFile(filePath);
|
|
18046
18046
|
if (!params.fileName) {
|
|
18047
18047
|
fileName = path.basename(filePath);
|
|
18048
18048
|
}
|
|
@@ -20305,6 +20305,8 @@ var ConnectionManager = class {
|
|
|
20305
20305
|
options;
|
|
20306
20306
|
/** 心跳定时器 */
|
|
20307
20307
|
heartbeatTimer = null;
|
|
20308
|
+
/** pong 超时定时器 — 每次 ping 后独立计时 */
|
|
20309
|
+
pongTimeoutTimer = null;
|
|
20308
20310
|
/** 当前重连尝试次数 */
|
|
20309
20311
|
reconnectAttempts = 0;
|
|
20310
20312
|
/** 是否处于运行状态 */
|
|
@@ -20372,6 +20374,7 @@ var ConnectionManager = class {
|
|
|
20372
20374
|
});
|
|
20373
20375
|
this.client.on("pong", () => {
|
|
20374
20376
|
this.pongReceived = true;
|
|
20377
|
+
this.clearPongTimeout();
|
|
20375
20378
|
log22.info("heartbeat: pong received");
|
|
20376
20379
|
});
|
|
20377
20380
|
}
|
|
@@ -20394,14 +20397,30 @@ var ConnectionManager = class {
|
|
|
20394
20397
|
this.pongReceived = false;
|
|
20395
20398
|
this.client.ping();
|
|
20396
20399
|
log22.info("heartbeat: ping sent");
|
|
20400
|
+
this.clearPongTimeout();
|
|
20401
|
+
this.pongTimeoutTimer = setTimeout(() => {
|
|
20402
|
+
if (!this.pongReceived && this.running) {
|
|
20403
|
+
log22.warn("heartbeat: pong timeout (independent timer), closing connection");
|
|
20404
|
+
this.client.close(4e3, "pong timeout");
|
|
20405
|
+
this.scheduleReconnect();
|
|
20406
|
+
}
|
|
20407
|
+
}, this.options.heartbeatTimeoutMs);
|
|
20397
20408
|
}, this.options.heartbeatIntervalMs);
|
|
20398
20409
|
}
|
|
20410
|
+
/** 清除 pong 超时定时器 */
|
|
20411
|
+
clearPongTimeout() {
|
|
20412
|
+
if (this.pongTimeoutTimer) {
|
|
20413
|
+
clearTimeout(this.pongTimeoutTimer);
|
|
20414
|
+
this.pongTimeoutTimer = null;
|
|
20415
|
+
}
|
|
20416
|
+
}
|
|
20399
20417
|
/** 停止心跳定时器 */
|
|
20400
20418
|
stopHeartbeat() {
|
|
20401
20419
|
if (this.heartbeatTimer) {
|
|
20402
20420
|
clearInterval(this.heartbeatTimer);
|
|
20403
20421
|
this.heartbeatTimer = null;
|
|
20404
20422
|
}
|
|
20423
|
+
this.clearPongTimeout();
|
|
20405
20424
|
}
|
|
20406
20425
|
/** 调度重连 (防止并发重连) */
|
|
20407
20426
|
scheduleReconnect() {
|
|
@@ -20851,15 +20870,22 @@ async function startPlugin(accountConfig, internalOverrides) {
|
|
|
20851
20870
|
log25.info("Config built \u2713", { pluginId: config2.pluginId });
|
|
20852
20871
|
let cryptoEngine;
|
|
20853
20872
|
if (config2.crypto.enabled && accountConfig.quantumAccount) {
|
|
20854
|
-
|
|
20855
|
-
|
|
20856
|
-
|
|
20857
|
-
|
|
20858
|
-
|
|
20859
|
-
|
|
20860
|
-
|
|
20861
|
-
|
|
20862
|
-
|
|
20873
|
+
try {
|
|
20874
|
+
cryptoEngine = new CryptoEngine(
|
|
20875
|
+
{
|
|
20876
|
+
appId: accountConfig.appId,
|
|
20877
|
+
quantumAccount: accountConfig.quantumAccount
|
|
20878
|
+
},
|
|
20879
|
+
config2.env
|
|
20880
|
+
);
|
|
20881
|
+
await cryptoEngine.init();
|
|
20882
|
+
log25.info("Crypto initialized \u2713");
|
|
20883
|
+
} catch (err) {
|
|
20884
|
+
log25.warn("Crypto init failed, falling back to passthrough mode", {
|
|
20885
|
+
error: err instanceof Error ? err.message : String(err)
|
|
20886
|
+
});
|
|
20887
|
+
cryptoEngine = CryptoEngine.createPassthrough();
|
|
20888
|
+
}
|
|
20863
20889
|
} else {
|
|
20864
20890
|
cryptoEngine = CryptoEngine.createPassthrough();
|
|
20865
20891
|
const reason = !config2.crypto.enabled ? "disabled by config" : "quantumAccount not provided";
|
package/dist/index.d.cts
CHANGED
|
@@ -855,6 +855,8 @@ declare class ConnectionManager {
|
|
|
855
855
|
private readonly options;
|
|
856
856
|
/** 心跳定时器 */
|
|
857
857
|
private heartbeatTimer;
|
|
858
|
+
/** pong 超时定时器 — 每次 ping 后独立计时 */
|
|
859
|
+
private pongTimeoutTimer;
|
|
858
860
|
/** 当前重连尝试次数 */
|
|
859
861
|
private reconnectAttempts;
|
|
860
862
|
/** 是否处于运行状态 */
|
|
@@ -881,6 +883,8 @@ declare class ConnectionManager {
|
|
|
881
883
|
private registerEvents;
|
|
882
884
|
/** 启动心跳保活 — 定时发送 WebSocket Ping 帧 */
|
|
883
885
|
private startHeartbeat;
|
|
886
|
+
/** 清除 pong 超时定时器 */
|
|
887
|
+
private clearPongTimeout;
|
|
884
888
|
/** 停止心跳定时器 */
|
|
885
889
|
private stopHeartbeat;
|
|
886
890
|
/** 调度重连 (防止并发重连) */
|
package/dist/setup-entry.cjs
CHANGED
|
@@ -3658,7 +3658,7 @@ var import_plugin_sdk3 = require("openclaw/plugin-sdk");
|
|
|
3658
3658
|
|
|
3659
3659
|
// src/file/media.ts
|
|
3660
3660
|
var path = __toESM(require("path"), 1);
|
|
3661
|
-
var fs = __toESM(require("fs"), 1);
|
|
3661
|
+
var fs = __toESM(require("fs/promises"), 1);
|
|
3662
3662
|
|
|
3663
3663
|
// src/types.ts
|
|
3664
3664
|
var FileServiceError = class extends Error {
|
|
@@ -3922,8 +3922,8 @@ async function uploadMedia(params) {
|
|
|
3922
3922
|
if (Buffer.isBuffer(file2)) {
|
|
3923
3923
|
buffer = file2;
|
|
3924
3924
|
} else {
|
|
3925
|
-
const { readFile:
|
|
3926
|
-
buffer = await
|
|
3925
|
+
const { readFile: readFile3 } = await import("fs/promises");
|
|
3926
|
+
buffer = await readFile3(file2);
|
|
3927
3927
|
}
|
|
3928
3928
|
const maxBytes = maxFileSizeMb * 1024 * 1024;
|
|
3929
3929
|
if (buffer.length > maxBytes) {
|
|
@@ -4137,7 +4137,7 @@ async function resolveAndUploadMedia(params) {
|
|
|
4137
4137
|
const filePath = mediaUrl.startsWith("file://") ? mediaUrl.slice(7) : mediaUrl;
|
|
4138
4138
|
log3.info("media:source=local", { filePath });
|
|
4139
4139
|
validateLocalPath(filePath, allowedLocalRoots);
|
|
4140
|
-
buffer = fs.
|
|
4140
|
+
buffer = await fs.readFile(filePath);
|
|
4141
4141
|
if (!params.fileName) {
|
|
4142
4142
|
fileName = path.basename(filePath);
|
|
4143
4143
|
}
|
|
@@ -19364,6 +19364,8 @@ var ConnectionManager = class {
|
|
|
19364
19364
|
options;
|
|
19365
19365
|
/** 心跳定时器 */
|
|
19366
19366
|
heartbeatTimer = null;
|
|
19367
|
+
/** pong 超时定时器 — 每次 ping 后独立计时 */
|
|
19368
|
+
pongTimeoutTimer = null;
|
|
19367
19369
|
/** 当前重连尝试次数 */
|
|
19368
19370
|
reconnectAttempts = 0;
|
|
19369
19371
|
/** 是否处于运行状态 */
|
|
@@ -19431,6 +19433,7 @@ var ConnectionManager = class {
|
|
|
19431
19433
|
});
|
|
19432
19434
|
this.client.on("pong", () => {
|
|
19433
19435
|
this.pongReceived = true;
|
|
19436
|
+
this.clearPongTimeout();
|
|
19434
19437
|
log13.info("heartbeat: pong received");
|
|
19435
19438
|
});
|
|
19436
19439
|
}
|
|
@@ -19453,14 +19456,30 @@ var ConnectionManager = class {
|
|
|
19453
19456
|
this.pongReceived = false;
|
|
19454
19457
|
this.client.ping();
|
|
19455
19458
|
log13.info("heartbeat: ping sent");
|
|
19459
|
+
this.clearPongTimeout();
|
|
19460
|
+
this.pongTimeoutTimer = setTimeout(() => {
|
|
19461
|
+
if (!this.pongReceived && this.running) {
|
|
19462
|
+
log13.warn("heartbeat: pong timeout (independent timer), closing connection");
|
|
19463
|
+
this.client.close(4e3, "pong timeout");
|
|
19464
|
+
this.scheduleReconnect();
|
|
19465
|
+
}
|
|
19466
|
+
}, this.options.heartbeatTimeoutMs);
|
|
19456
19467
|
}, this.options.heartbeatIntervalMs);
|
|
19457
19468
|
}
|
|
19469
|
+
/** 清除 pong 超时定时器 */
|
|
19470
|
+
clearPongTimeout() {
|
|
19471
|
+
if (this.pongTimeoutTimer) {
|
|
19472
|
+
clearTimeout(this.pongTimeoutTimer);
|
|
19473
|
+
this.pongTimeoutTimer = null;
|
|
19474
|
+
}
|
|
19475
|
+
}
|
|
19458
19476
|
/** 停止心跳定时器 */
|
|
19459
19477
|
stopHeartbeat() {
|
|
19460
19478
|
if (this.heartbeatTimer) {
|
|
19461
19479
|
clearInterval(this.heartbeatTimer);
|
|
19462
19480
|
this.heartbeatTimer = null;
|
|
19463
19481
|
}
|
|
19482
|
+
this.clearPongTimeout();
|
|
19464
19483
|
}
|
|
19465
19484
|
/** 调度重连 (防止并发重连) */
|
|
19466
19485
|
scheduleReconnect() {
|
|
@@ -19980,15 +19999,22 @@ async function startPlugin(accountConfig, internalOverrides) {
|
|
|
19980
19999
|
log16.info("Config built \u2713", { pluginId: config2.pluginId });
|
|
19981
20000
|
let cryptoEngine;
|
|
19982
20001
|
if (config2.crypto.enabled && accountConfig.quantumAccount) {
|
|
19983
|
-
|
|
19984
|
-
|
|
19985
|
-
|
|
19986
|
-
|
|
19987
|
-
|
|
19988
|
-
|
|
19989
|
-
|
|
19990
|
-
|
|
19991
|
-
|
|
20002
|
+
try {
|
|
20003
|
+
cryptoEngine = new CryptoEngine(
|
|
20004
|
+
{
|
|
20005
|
+
appId: accountConfig.appId,
|
|
20006
|
+
quantumAccount: accountConfig.quantumAccount
|
|
20007
|
+
},
|
|
20008
|
+
config2.env
|
|
20009
|
+
);
|
|
20010
|
+
await cryptoEngine.init();
|
|
20011
|
+
log16.info("Crypto initialized \u2713");
|
|
20012
|
+
} catch (err) {
|
|
20013
|
+
log16.warn("Crypto init failed, falling back to passthrough mode", {
|
|
20014
|
+
error: err instanceof Error ? err.message : String(err)
|
|
20015
|
+
});
|
|
20016
|
+
cryptoEngine = CryptoEngine.createPassthrough();
|
|
20017
|
+
}
|
|
19992
20018
|
} else {
|
|
19993
20019
|
cryptoEngine = CryptoEngine.createPassthrough();
|
|
19994
20020
|
const reason = !config2.crypto.enabled ? "disabled by config" : "quantumAccount not provided";
|