liangzimixin 0.3.33 → 0.3.35

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
@@ -18067,6 +18067,23 @@ function inferFileNameFromUrl(url2) {
18067
18067
 
18068
18068
  // src/channel/outbound.ts
18069
18069
  var log4 = createLogger("channel/outbound");
18070
+ var messageEncryptionStatus = /* @__PURE__ */ new Map();
18071
+ var activeChatMessage = /* @__PURE__ */ new Map();
18072
+ function setInboundEncryptionStatus(chatId, messageId, isEncrypted) {
18073
+ messageEncryptionStatus.set(messageId, isEncrypted);
18074
+ activeChatMessage.set(chatId, messageId);
18075
+ }
18076
+ function clearInboundEncryptionStatus(chatId, messageId) {
18077
+ messageEncryptionStatus.delete(messageId);
18078
+ if (activeChatMessage.get(chatId) === messageId) {
18079
+ activeChatMessage.delete(chatId);
18080
+ }
18081
+ }
18082
+ function getOutboundEncryptionStatus(chatId) {
18083
+ const messageId = activeChatMessage.get(chatId);
18084
+ if (!messageId) return void 0;
18085
+ return messageEncryptionStatus.get(messageId);
18086
+ }
18070
18087
  var messagePipeGetter = null;
18071
18088
  function setMessagePipeGetter(getter) {
18072
18089
  messagePipeGetter = getter;
@@ -18099,11 +18116,13 @@ var quantumImOutbound = {
18099
18116
  }
18100
18117
  const messagePipe = messagePipeGetter();
18101
18118
  const chatId = parseChannelAddress(to);
18119
+ const isEncrypted = getOutboundEncryptionStatus(chatId);
18102
18120
  await messagePipe.sendMessage({
18103
18121
  chatId,
18104
18122
  senderId: chatId,
18105
18123
  msgType: "markdown",
18106
- content: JSON.stringify({ content: text })
18124
+ content: JSON.stringify({ content: text }),
18125
+ skipEncrypt: isEncrypted === false
18107
18126
  });
18108
18127
  return { channel: CHANNEL_ID, messageId: "", chatId };
18109
18128
  },
@@ -18118,6 +18137,7 @@ var quantumImOutbound = {
18118
18137
  const sdkRuntime = sdkRuntimeGetter();
18119
18138
  const chatId = parseChannelAddress(to);
18120
18139
  const fileCfg = pluginConfigGetter().file;
18140
+ const isEncrypted = getOutboundEncryptionStatus(chatId);
18121
18141
  const result = await resolveAndUploadMedia({
18122
18142
  mediaUrl: mediaUrl ?? void 0,
18123
18143
  tokenManager: tokenManagerGetter(),
@@ -18129,7 +18149,8 @@ var quantumImOutbound = {
18129
18149
  chatId,
18130
18150
  maxFileSizeMb: fileCfg.maxFileSizeMb,
18131
18151
  chunkSizeMb: fileCfg.chunkSizeMb,
18132
- timeoutMs: fileCfg.fetchTimeoutMs
18152
+ timeoutMs: fileCfg.fetchTimeoutMs,
18153
+ skipEncrypt: isEncrypted === false
18133
18154
  });
18134
18155
  if (result.warning) {
18135
18156
  log4.warn("sendMedia:degraded", { chatId, warning: result.warning });
@@ -18533,6 +18554,7 @@ var InboundPipeline = class {
18533
18554
  });
18534
18555
  return;
18535
18556
  }
18557
+ setInboundEncryptionStatus(msg.chatId, msg.messageId, msg.isEncrypted ?? false);
18536
18558
  if (detectAbort(context.text)) {
18537
18559
  log12.info("\u26D4 \u68C0\u6D4B\u5230\u4E2D\u6B62\u6307\u4EE4", {
18538
18560
  messageId: msg.messageId,
@@ -18600,6 +18622,7 @@ var InboundPipeline = class {
18600
18622
  \u56DE\u590D\u6570: counts?.final ?? 0,
18601
18623
  \u8017\u65F6ms: durationMs
18602
18624
  });
18625
+ clearInboundEncryptionStatus(msg.chatId, msg.messageId);
18603
18626
  } catch (err) {
18604
18627
  const durationMs = Date.now() - startMs;
18605
18628
  log12.error("\u274C \u6D88\u606F\u5904\u7406\u5931\u8D25", {
@@ -18610,6 +18633,7 @@ var InboundPipeline = class {
18610
18633
  stack: err.stack,
18611
18634
  durationMs
18612
18635
  });
18636
+ clearInboundEncryptionStatus(msg.chatId, msg.messageId);
18613
18637
  }
18614
18638
  }
18615
18639
  };
@@ -4162,6 +4162,23 @@ function inferFileNameFromUrl(url2) {
4162
4162
 
4163
4163
  // src/channel/outbound.ts
4164
4164
  var log4 = createLogger("channel/outbound");
4165
+ var messageEncryptionStatus = /* @__PURE__ */ new Map();
4166
+ var activeChatMessage = /* @__PURE__ */ new Map();
4167
+ function setInboundEncryptionStatus(chatId, messageId, isEncrypted) {
4168
+ messageEncryptionStatus.set(messageId, isEncrypted);
4169
+ activeChatMessage.set(chatId, messageId);
4170
+ }
4171
+ function clearInboundEncryptionStatus(chatId, messageId) {
4172
+ messageEncryptionStatus.delete(messageId);
4173
+ if (activeChatMessage.get(chatId) === messageId) {
4174
+ activeChatMessage.delete(chatId);
4175
+ }
4176
+ }
4177
+ function getOutboundEncryptionStatus(chatId) {
4178
+ const messageId = activeChatMessage.get(chatId);
4179
+ if (!messageId) return void 0;
4180
+ return messageEncryptionStatus.get(messageId);
4181
+ }
4165
4182
  var messagePipeGetter = null;
4166
4183
  function setMessagePipeGetter(getter) {
4167
4184
  messagePipeGetter = getter;
@@ -4194,11 +4211,13 @@ var quantumImOutbound = {
4194
4211
  }
4195
4212
  const messagePipe = messagePipeGetter();
4196
4213
  const chatId = parseChannelAddress(to);
4214
+ const isEncrypted = getOutboundEncryptionStatus(chatId);
4197
4215
  await messagePipe.sendMessage({
4198
4216
  chatId,
4199
4217
  senderId: chatId,
4200
4218
  msgType: "markdown",
4201
- content: JSON.stringify({ content: text })
4219
+ content: JSON.stringify({ content: text }),
4220
+ skipEncrypt: isEncrypted === false
4202
4221
  });
4203
4222
  return { channel: CHANNEL_ID, messageId: "", chatId };
4204
4223
  },
@@ -4213,6 +4232,7 @@ var quantumImOutbound = {
4213
4232
  const sdkRuntime = sdkRuntimeGetter();
4214
4233
  const chatId = parseChannelAddress(to);
4215
4234
  const fileCfg = pluginConfigGetter().file;
4235
+ const isEncrypted = getOutboundEncryptionStatus(chatId);
4216
4236
  const result = await resolveAndUploadMedia({
4217
4237
  mediaUrl: mediaUrl ?? void 0,
4218
4238
  tokenManager: tokenManagerGetter(),
@@ -4224,7 +4244,8 @@ var quantumImOutbound = {
4224
4244
  chatId,
4225
4245
  maxFileSizeMb: fileCfg.maxFileSizeMb,
4226
4246
  chunkSizeMb: fileCfg.chunkSizeMb,
4227
- timeoutMs: fileCfg.fetchTimeoutMs
4247
+ timeoutMs: fileCfg.fetchTimeoutMs,
4248
+ skipEncrypt: isEncrypted === false
4228
4249
  });
4229
4250
  if (result.warning) {
4230
4251
  log4.warn("sendMedia:degraded", { chatId, warning: result.warning });
@@ -20326,6 +20347,7 @@ var InboundPipeline = class {
20326
20347
  });
20327
20348
  return;
20328
20349
  }
20350
+ setInboundEncryptionStatus(msg.chatId, msg.messageId, msg.isEncrypted ?? false);
20329
20351
  if (detectAbort(context.text)) {
20330
20352
  log24.info("\u26D4 \u68C0\u6D4B\u5230\u4E2D\u6B62\u6307\u4EE4", {
20331
20353
  messageId: msg.messageId,
@@ -20393,6 +20415,7 @@ var InboundPipeline = class {
20393
20415
  \u56DE\u590D\u6570: counts?.final ?? 0,
20394
20416
  \u8017\u65F6ms: durationMs
20395
20417
  });
20418
+ clearInboundEncryptionStatus(msg.chatId, msg.messageId);
20396
20419
  } catch (err) {
20397
20420
  const durationMs = Date.now() - startMs;
20398
20421
  log24.error("\u274C \u6D88\u606F\u5904\u7406\u5931\u8D25", {
@@ -20403,6 +20426,7 @@ var InboundPipeline = class {
20403
20426
  stack: err.stack,
20404
20427
  durationMs
20405
20428
  });
20429
+ clearInboundEncryptionStatus(msg.chatId, msg.messageId);
20406
20430
  }
20407
20431
  }
20408
20432
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "liangzimixin",
3
- "version": "0.3.33",
3
+ "version": "0.3.35",
4
4
  "description": "Quantum-encrypted IM channel plugin for OpenClaw",
5
5
  "type": "module",
6
6
  "main": "dist/index.cjs",