liangzimixin 0.3.60 → 0.3.62

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 CHANGED
@@ -17992,17 +17992,40 @@ var Metrics = class {
17992
17992
  timestamp: (/* @__PURE__ */ new Date()).toISOString()
17993
17993
  };
17994
17994
  }
17995
+ /** 上次输出时的计数器快照 — 用于增量比对 */
17996
+ lastCounterSnapshot = /* @__PURE__ */ new Map();
17997
+ /** 上次输出时的直方图采样计数 — 用于增量比对 */
17998
+ lastHistogramCount = /* @__PURE__ */ new Map();
17995
17999
  /**
17996
- * 启动定期日志输出。
17997
- * @param intervalMs - 输出间隔 (ms),默认 60000 (1 分钟)
18000
+ * 启动定期日志输出 (增量模式)。
18001
+ * 仅在有新数据变化时才输出,空闲期间静默。
18002
+ * @param intervalMs - 检查间隔 (ms),默认 60000 (1 分钟)
17998
18003
  */
17999
18004
  startPeriodicLog(intervalMs = 6e4) {
18000
18005
  if (this.started) return;
18001
18006
  this.started = true;
18002
18007
  this.logTimer = setInterval(() => {
18008
+ let hasChanges = false;
18009
+ for (const [name, count] of this.counters) {
18010
+ if ((this.lastCounterSnapshot.get(name) ?? 0) !== count) {
18011
+ hasChanges = true;
18012
+ break;
18013
+ }
18014
+ }
18015
+ if (!hasChanges) {
18016
+ for (const [name, hist] of this.histograms) {
18017
+ if ((this.lastHistogramCount.get(name) ?? 0) !== hist.count) {
18018
+ hasChanges = true;
18019
+ break;
18020
+ }
18021
+ }
18022
+ }
18023
+ if (!hasChanges) return;
18003
18024
  const snap = this.snapshot();
18004
- if (Object.keys(snap.counters).length > 0 || Object.keys(snap.histograms).length > 0) {
18005
- log3.info("\u{1F4CA} metrics snapshot", snap);
18025
+ log3.info("\u{1F4CA} metrics snapshot", snap);
18026
+ this.lastCounterSnapshot = new Map(this.counters);
18027
+ for (const [name, hist] of this.histograms) {
18028
+ this.lastHistogramCount.set(name, hist.count);
18006
18029
  }
18007
18030
  }, intervalMs);
18008
18031
  if (this.logTimer && typeof this.logTimer === "object" && "unref" in this.logTimer) {
@@ -19696,6 +19719,7 @@ var quantumImPlugin = {
19696
19719
  setTokenManagerGetter(() => instance.tokenManager);
19697
19720
  setPluginConfigGetter(() => instance.config);
19698
19721
  log16.info(`liangzimixin[${ctx.accountId}] started \u2713`);
19722
+ log16.info("\u{1F389} \u6B22\u8FCE\u4F7F\u7528\u91CF\u5B50\u5BC6\u4FE1\u9F99\u867E\uFF0C\u60A8\u5DF2\u6210\u529F\u8FDE\u63A5\u667A\u80FD\u52A9\u7406");
19699
19723
  await new Promise((resolve3) => {
19700
19724
  if (ctx.abortSignal?.aborted) {
19701
19725
  resolve3();
@@ -4065,17 +4065,40 @@ var Metrics = class {
4065
4065
  timestamp: (/* @__PURE__ */ new Date()).toISOString()
4066
4066
  };
4067
4067
  }
4068
+ /** 上次输出时的计数器快照 — 用于增量比对 */
4069
+ lastCounterSnapshot = /* @__PURE__ */ new Map();
4070
+ /** 上次输出时的直方图采样计数 — 用于增量比对 */
4071
+ lastHistogramCount = /* @__PURE__ */ new Map();
4068
4072
  /**
4069
- * 启动定期日志输出。
4070
- * @param intervalMs - 输出间隔 (ms),默认 60000 (1 分钟)
4073
+ * 启动定期日志输出 (增量模式)。
4074
+ * 仅在有新数据变化时才输出,空闲期间静默。
4075
+ * @param intervalMs - 检查间隔 (ms),默认 60000 (1 分钟)
4071
4076
  */
4072
4077
  startPeriodicLog(intervalMs = 6e4) {
4073
4078
  if (this.started) return;
4074
4079
  this.started = true;
4075
4080
  this.logTimer = setInterval(() => {
4081
+ let hasChanges = false;
4082
+ for (const [name, count] of this.counters) {
4083
+ if ((this.lastCounterSnapshot.get(name) ?? 0) !== count) {
4084
+ hasChanges = true;
4085
+ break;
4086
+ }
4087
+ }
4088
+ if (!hasChanges) {
4089
+ for (const [name, hist] of this.histograms) {
4090
+ if ((this.lastHistogramCount.get(name) ?? 0) !== hist.count) {
4091
+ hasChanges = true;
4092
+ break;
4093
+ }
4094
+ }
4095
+ }
4096
+ if (!hasChanges) return;
4076
4097
  const snap = this.snapshot();
4077
- if (Object.keys(snap.counters).length > 0 || Object.keys(snap.histograms).length > 0) {
4078
- log3.info("\u{1F4CA} metrics snapshot", snap);
4098
+ log3.info("\u{1F4CA} metrics snapshot", snap);
4099
+ this.lastCounterSnapshot = new Map(this.counters);
4100
+ for (const [name, hist] of this.histograms) {
4101
+ this.lastHistogramCount.set(name, hist.count);
4079
4102
  }
4080
4103
  }, intervalMs);
4081
4104
  if (this.logTimer && typeof this.logTimer === "object" && "unref" in this.logTimer) {
@@ -21926,6 +21949,7 @@ var quantumImPlugin = {
21926
21949
  setTokenManagerGetter(() => instance.tokenManager);
21927
21950
  setPluginConfigGetter(() => instance.config);
21928
21951
  log29.info(`liangzimixin[${ctx.accountId}] started \u2713`);
21952
+ log29.info("\u{1F389} \u6B22\u8FCE\u4F7F\u7528\u91CF\u5B50\u5BC6\u4FE1\u9F99\u867E\uFF0C\u60A8\u5DF2\u6210\u529F\u8FDE\u63A5\u667A\u80FD\u52A9\u7406");
21929
21953
  await new Promise((resolve3) => {
21930
21954
  if (ctx.abortSignal?.aborted) {
21931
21955
  resolve3();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "liangzimixin",
3
- "version": "0.3.60",
3
+ "version": "0.3.62",
4
4
  "description": "Quantum-encrypted IM channel plugin for OpenClaw",
5
5
  "type": "module",
6
6
  "main": "dist/index.cjs",