liangzimixin 0.3.59 → 0.3.60

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
@@ -19767,6 +19767,8 @@ function createQuantumPlug() {
19767
19767
  return {
19768
19768
  async init() {
19769
19769
  const s = loadSdk();
19770
+ const sdkLogDir = (0, import_node_path.resolve)(__dirname, "quantum-sdk", "log");
19771
+ (0, import_node_fs.mkdirSync)(sdkLogDir, { recursive: true });
19770
19772
  await s.init();
19771
19773
  log17.info("Quantum SDK initialized \u2713");
19772
19774
  },
@@ -20785,6 +20787,8 @@ var MessagePipe = class _MessagePipe {
20785
20787
  quantumAccount;
20786
20788
  /** 消息加密模式 */
20787
20789
  encryptionMode;
20790
+ /** CryptoEngine 是否处于 passthrough 模式 (crypto 初始化失败或未启用) */
20791
+ cryptoIsPassthrough;
20788
20792
  /** 入站并发控制信号量 */
20789
20793
  inboundSemaphore;
20790
20794
  /** 出站速率限制器 */
@@ -20797,6 +20801,7 @@ var MessagePipe = class _MessagePipe {
20797
20801
  this.messageServiceBaseUrl = deps.messageServiceBaseUrl;
20798
20802
  this.quantumAccount = deps.quantumAccount;
20799
20803
  this.encryptionMode = deps.encryptionMode;
20804
+ this.cryptoIsPassthrough = deps.cryptoIsPassthrough ?? false;
20800
20805
  this.inboundSemaphore = new Semaphore({
20801
20806
  maxConcurrency: deps.maxInboundConcurrency ?? 5,
20802
20807
  maxWaiting: deps.maxWaitingQueue ?? 15
@@ -21165,6 +21170,17 @@ var MessagePipe = class _MessagePipe {
21165
21170
  await this.sendHintMessage(callbackData, HINT_NO_QUANTUM_ACCOUNT);
21166
21171
  return;
21167
21172
  }
21173
+ if (this.cryptoIsPassthrough) {
21174
+ log25.error("\u26A0\uFE0F quantum_only: CryptoEngine \u5904\u4E8E passthrough \u6A21\u5F0F\uFF0C\u65E0\u6CD5\u89E3\u5BC6\u6D88\u606F", {
21175
+ msgUid: callbackData.msgUid,
21176
+ reason: "crypto init failed, engine degraded to passthrough"
21177
+ });
21178
+ await this.sendHintMessage(
21179
+ callbackData,
21180
+ "\u26A0\uFE0F \u91CF\u5B50\u52A0\u5BC6\u670D\u52A1\u6682\u65F6\u4E0D\u53EF\u7528\uFF0C\u65E0\u6CD5\u5904\u7406\u52A0\u5BC6\u6D88\u606F\u3002\u8BF7\u7A0D\u540E\u91CD\u8BD5\u6216\u8054\u7CFB\u7BA1\u7406\u5458\u3002"
21181
+ );
21182
+ return;
21183
+ }
21168
21184
  if (!isEncrypted) {
21169
21185
  log25.info("\u26A0\uFE0F quantum_only: \u6536\u5230\u660E\u6587\u6D88\u606F\uFF0C\u62D2\u7EDD\u5904\u7406", { msgUid: callbackData.msgUid });
21170
21186
  await this.sendHintMessage(callbackData, HINT_PLAINTEXT_NOT_SUPPORTED);
@@ -21181,9 +21197,14 @@ var MessagePipe = class _MessagePipe {
21181
21197
  }
21182
21198
  } else {
21183
21199
  if (isEncrypted) {
21184
- if (!this.quantumAccount) {
21185
- log25.info("\u26A0\uFE0F quantum_and_plain: \u6536\u5230\u52A0\u5BC6\u6D88\u606F\u4F46\u672A\u914D\u7F6E quantumAccount", { msgUid: callbackData.msgUid });
21186
- await this.sendHintMessage(callbackData, HINT_NO_QUANTUM_ACCOUNT);
21200
+ if (!this.quantumAccount || this.cryptoIsPassthrough) {
21201
+ const reason = !this.quantumAccount ? "\u672A\u914D\u7F6E quantumAccount" : "CryptoEngine \u5904\u4E8E passthrough \u6A21\u5F0F (crypto \u521D\u59CB\u5316\u5931\u8D25)";
21202
+ log25.warn("\u26A0\uFE0F quantum_and_plain: \u65E0\u6CD5\u89E3\u5BC6\u52A0\u5BC6\u6D88\u606F", {
21203
+ msgUid: callbackData.msgUid,
21204
+ reason
21205
+ });
21206
+ const hintText = this.cryptoIsPassthrough ? "\u26A0\uFE0F \u91CF\u5B50\u52A0\u5BC6\u670D\u52A1\u6682\u65F6\u4E0D\u53EF\u7528\uFF0C\u65E0\u6CD5\u89E3\u5BC6\u52A0\u5BC6\u6D88\u606F\u3002\u8BF7\u53D1\u9001\u660E\u6587\u6D88\u606F\uFF0C\u6216\u7A0D\u540E\u91CD\u8BD5\u3002" : HINT_NO_QUANTUM_ACCOUNT;
21207
+ await this.sendHintMessage(callbackData, hintText);
21187
21208
  return;
21188
21209
  }
21189
21210
  try {
@@ -21913,6 +21934,7 @@ async function startPlugin(accountConfig, internalOverrides) {
21913
21934
  messageServiceBaseUrl: config2.message.messageServiceBaseUrl,
21914
21935
  quantumAccount: accountConfig.quantumAccount,
21915
21936
  encryptionMode: accountConfig.encryptionMode,
21937
+ cryptoIsPassthrough: cryptoEngine.isPassthrough(),
21916
21938
  maxInboundConcurrency: config2.transport.maxInboundConcurrency,
21917
21939
  maxWaitingQueue: config2.transport.maxWaitingQueue,
21918
21940
  rateLimitPerSecond: config2.message.rateLimitPerSecond,
package/dist/index.d.cts CHANGED
@@ -865,6 +865,8 @@ declare class MessagePipe {
865
865
  private readonly quantumAccount?;
866
866
  /** 消息加密模式 */
867
867
  private readonly encryptionMode;
868
+ /** CryptoEngine 是否处于 passthrough 模式 (crypto 初始化失败或未启用) */
869
+ private readonly cryptoIsPassthrough;
868
870
  /** 入站并发控制信号量 */
869
871
  private readonly inboundSemaphore;
870
872
  /** 出站速率限制器 */
@@ -881,6 +883,8 @@ declare class MessagePipe {
881
883
  quantumAccount?: string;
882
884
  /** 消息加密模式 */
883
885
  encryptionMode: 'quantum_only' | 'quantum_and_plain';
886
+ /** CryptoEngine 是否处于 passthrough 模式 — 由 index.ts 初始化时传入 */
887
+ cryptoIsPassthrough?: boolean;
884
888
  /** 入站最大并发处理数 */
885
889
  maxInboundConcurrency?: number;
886
890
  /** 入站等待队列上限 */
@@ -18750,6 +18750,8 @@ function createQuantumPlug() {
18750
18750
  return {
18751
18751
  async init() {
18752
18752
  const s = loadSdk();
18753
+ const sdkLogDir = (0, import_node_path.resolve)(__dirname, "quantum-sdk", "log");
18754
+ (0, import_node_fs.mkdirSync)(sdkLogDir, { recursive: true });
18753
18755
  await s.init();
18754
18756
  log8.info("Quantum SDK initialized \u2713");
18755
18757
  },
@@ -19768,6 +19770,8 @@ var MessagePipe = class _MessagePipe {
19768
19770
  quantumAccount;
19769
19771
  /** 消息加密模式 */
19770
19772
  encryptionMode;
19773
+ /** CryptoEngine 是否处于 passthrough 模式 (crypto 初始化失败或未启用) */
19774
+ cryptoIsPassthrough;
19771
19775
  /** 入站并发控制信号量 */
19772
19776
  inboundSemaphore;
19773
19777
  /** 出站速率限制器 */
@@ -19780,6 +19784,7 @@ var MessagePipe = class _MessagePipe {
19780
19784
  this.messageServiceBaseUrl = deps.messageServiceBaseUrl;
19781
19785
  this.quantumAccount = deps.quantumAccount;
19782
19786
  this.encryptionMode = deps.encryptionMode;
19787
+ this.cryptoIsPassthrough = deps.cryptoIsPassthrough ?? false;
19783
19788
  this.inboundSemaphore = new Semaphore({
19784
19789
  maxConcurrency: deps.maxInboundConcurrency ?? 5,
19785
19790
  maxWaiting: deps.maxWaitingQueue ?? 15
@@ -20148,6 +20153,17 @@ var MessagePipe = class _MessagePipe {
20148
20153
  await this.sendHintMessage(callbackData, HINT_NO_QUANTUM_ACCOUNT);
20149
20154
  return;
20150
20155
  }
20156
+ if (this.cryptoIsPassthrough) {
20157
+ log16.error("\u26A0\uFE0F quantum_only: CryptoEngine \u5904\u4E8E passthrough \u6A21\u5F0F\uFF0C\u65E0\u6CD5\u89E3\u5BC6\u6D88\u606F", {
20158
+ msgUid: callbackData.msgUid,
20159
+ reason: "crypto init failed, engine degraded to passthrough"
20160
+ });
20161
+ await this.sendHintMessage(
20162
+ callbackData,
20163
+ "\u26A0\uFE0F \u91CF\u5B50\u52A0\u5BC6\u670D\u52A1\u6682\u65F6\u4E0D\u53EF\u7528\uFF0C\u65E0\u6CD5\u5904\u7406\u52A0\u5BC6\u6D88\u606F\u3002\u8BF7\u7A0D\u540E\u91CD\u8BD5\u6216\u8054\u7CFB\u7BA1\u7406\u5458\u3002"
20164
+ );
20165
+ return;
20166
+ }
20151
20167
  if (!isEncrypted) {
20152
20168
  log16.info("\u26A0\uFE0F quantum_only: \u6536\u5230\u660E\u6587\u6D88\u606F\uFF0C\u62D2\u7EDD\u5904\u7406", { msgUid: callbackData.msgUid });
20153
20169
  await this.sendHintMessage(callbackData, HINT_PLAINTEXT_NOT_SUPPORTED);
@@ -20164,9 +20180,14 @@ var MessagePipe = class _MessagePipe {
20164
20180
  }
20165
20181
  } else {
20166
20182
  if (isEncrypted) {
20167
- if (!this.quantumAccount) {
20168
- log16.info("\u26A0\uFE0F quantum_and_plain: \u6536\u5230\u52A0\u5BC6\u6D88\u606F\u4F46\u672A\u914D\u7F6E quantumAccount", { msgUid: callbackData.msgUid });
20169
- await this.sendHintMessage(callbackData, HINT_NO_QUANTUM_ACCOUNT);
20183
+ if (!this.quantumAccount || this.cryptoIsPassthrough) {
20184
+ const reason = !this.quantumAccount ? "\u672A\u914D\u7F6E quantumAccount" : "CryptoEngine \u5904\u4E8E passthrough \u6A21\u5F0F (crypto \u521D\u59CB\u5316\u5931\u8D25)";
20185
+ log16.warn("\u26A0\uFE0F quantum_and_plain: \u65E0\u6CD5\u89E3\u5BC6\u52A0\u5BC6\u6D88\u606F", {
20186
+ msgUid: callbackData.msgUid,
20187
+ reason
20188
+ });
20189
+ const hintText = this.cryptoIsPassthrough ? "\u26A0\uFE0F \u91CF\u5B50\u52A0\u5BC6\u670D\u52A1\u6682\u65F6\u4E0D\u53EF\u7528\uFF0C\u65E0\u6CD5\u89E3\u5BC6\u52A0\u5BC6\u6D88\u606F\u3002\u8BF7\u53D1\u9001\u660E\u6587\u6D88\u606F\uFF0C\u6216\u7A0D\u540E\u91CD\u8BD5\u3002" : HINT_NO_QUANTUM_ACCOUNT;
20190
+ await this.sendHintMessage(callbackData, hintText);
20170
20191
  return;
20171
20192
  }
20172
20193
  try {
@@ -20973,6 +20994,7 @@ async function startPlugin(accountConfig, internalOverrides) {
20973
20994
  messageServiceBaseUrl: config2.message.messageServiceBaseUrl,
20974
20995
  quantumAccount: accountConfig.quantumAccount,
20975
20996
  encryptionMode: accountConfig.encryptionMode,
20997
+ cryptoIsPassthrough: cryptoEngine.isPassthrough(),
20976
20998
  maxInboundConcurrency: config2.transport.maxInboundConcurrency,
20977
20999
  maxWaitingQueue: config2.transport.maxWaitingQueue,
20978
21000
  rateLimitPerSecond: config2.message.rateLimitPerSecond,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "liangzimixin",
3
- "version": "0.3.59",
3
+ "version": "0.3.60",
4
4
  "description": "Quantum-encrypted IM channel plugin for OpenClaw",
5
5
  "type": "module",
6
6
  "main": "dist/index.cjs",