liangzimixin 0.3.75 → 0.3.77

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
@@ -18741,6 +18741,44 @@ function destroyEncryptionMaps() {
18741
18741
  messageEncryptionStatus.destroy();
18742
18742
  activeChatMessage.destroy();
18743
18743
  }
18744
+ var _readyResolve = null;
18745
+ var _readyPromise = null;
18746
+ function initReadyGate() {
18747
+ _readyPromise = new Promise((resolve3) => {
18748
+ _readyResolve = resolve3;
18749
+ });
18750
+ }
18751
+ initReadyGate();
18752
+ function markOutboundReady() {
18753
+ if (_readyResolve) {
18754
+ _readyResolve();
18755
+ _readyResolve = null;
18756
+ _readyPromise = null;
18757
+ }
18758
+ }
18759
+ function resetOutbound() {
18760
+ messagePipeGetter = null;
18761
+ sdkRuntimeGetter = null;
18762
+ tokenManagerGetter = null;
18763
+ pluginConfigGetter = null;
18764
+ initReadyGate();
18765
+ }
18766
+ var READY_TIMEOUT_MS = 12e4;
18767
+ async function waitForReady() {
18768
+ if (!_readyPromise) return true;
18769
+ log7.info("outbound: waiting for dependencies to initialize...");
18770
+ return new Promise((resolve3) => {
18771
+ const timer = setTimeout(() => {
18772
+ log7.error(`outbound: dependencies not ready after ${READY_TIMEOUT_MS}ms`);
18773
+ resolve3(false);
18774
+ }, READY_TIMEOUT_MS);
18775
+ _readyPromise.then(() => {
18776
+ clearTimeout(timer);
18777
+ log7.info("outbound: dependencies ready \u2713");
18778
+ resolve3(true);
18779
+ });
18780
+ });
18781
+ }
18744
18782
  function getOutboundEncryptionStatus(chatId) {
18745
18783
  const messageId = activeChatMessage.get(chatId);
18746
18784
  if (!messageId) return void 0;
@@ -18777,8 +18815,11 @@ var quantumImOutbound = {
18777
18815
  return { channel: CHANNEL_ID, messageId: "", chatId: to };
18778
18816
  }
18779
18817
  if (!messagePipeGetter) {
18780
- log7.error("outbound:sendText failed, messagePipe not initialized");
18781
- return { channel: CHANNEL_ID, messageId: "", chatId: to };
18818
+ const ready = await waitForReady();
18819
+ if (!ready || !messagePipeGetter) {
18820
+ log7.error("outbound:sendText failed, messagePipe not initialized");
18821
+ return { channel: CHANNEL_ID, messageId: "", chatId: to };
18822
+ }
18782
18823
  }
18783
18824
  const messagePipe = messagePipeGetter();
18784
18825
  const chatId = parseChannelAddress(to);
@@ -18798,8 +18839,11 @@ var quantumImOutbound = {
18798
18839
  sendMedia: async ({ cfg, to, text, mediaUrl, mediaLocalRoots, accountId }) => {
18799
18840
  log7.info("sendMedia called", { to, mediaUrl });
18800
18841
  if (!messagePipeGetter || !sdkRuntimeGetter || !tokenManagerGetter || !pluginConfigGetter) {
18801
- log7.error("outbound:sendMedia failed, dependencies not initialized");
18802
- return { channel: CHANNEL_ID, messageId: "", chatId: to };
18842
+ const ready = await waitForReady();
18843
+ if (!messagePipeGetter || !sdkRuntimeGetter || !tokenManagerGetter || !pluginConfigGetter) {
18844
+ log7.error("outbound:sendMedia failed, dependencies not initialized after wait");
18845
+ return { channel: CHANNEL_ID, messageId: "", chatId: to };
18846
+ }
18803
18847
  }
18804
18848
  const messagePipe = messagePipeGetter();
18805
18849
  const sdkRuntime = sdkRuntimeGetter();
@@ -19875,6 +19919,11 @@ var quantumImPlugin = {
19875
19919
  const instance = await startPlugin(resolved.credentials);
19876
19920
  activeInstance = instance;
19877
19921
  const { config: config2 } = instance;
19922
+ setMessagePipeGetter(() => instance.messagePipe);
19923
+ setSdkRuntimeGetter(() => getPluginRuntime());
19924
+ setTokenManagerGetter(() => instance.tokenManager);
19925
+ setPluginConfigGetter(() => instance.config);
19926
+ markOutboundReady();
19878
19927
  await instance.connectionManager.start(
19879
19928
  config2.transport.wsUrl,
19880
19929
  () => instance.tokenManager.getValidToken(),
@@ -19892,10 +19941,6 @@ var quantumImPlugin = {
19892
19941
  instance.messagePipe.onMessage((msg) => {
19893
19942
  pipeline.handle(msg);
19894
19943
  });
19895
- setMessagePipeGetter(() => instance.messagePipe);
19896
- setSdkRuntimeGetter(() => getPluginRuntime());
19897
- setTokenManagerGetter(() => instance.tokenManager);
19898
- setPluginConfigGetter(() => instance.config);
19899
19944
  log16.info(`liangzimixin[${ctx.accountId}] started \u2713`);
19900
19945
  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");
19901
19946
  await new Promise((resolve3) => {
@@ -22318,6 +22363,7 @@ async function startPlugin(accountConfig, internalOverrides) {
22318
22363
  tokenManager.shutdown();
22319
22364
  metrics.stop();
22320
22365
  destroyEncryptionMaps();
22366
+ resetOutbound();
22321
22367
  log29.info("Shutdown complete \u2713");
22322
22368
  }
22323
22369
  };
@@ -4812,6 +4812,44 @@ function destroyEncryptionMaps() {
4812
4812
  messageEncryptionStatus.destroy();
4813
4813
  activeChatMessage.destroy();
4814
4814
  }
4815
+ var _readyResolve = null;
4816
+ var _readyPromise = null;
4817
+ function initReadyGate() {
4818
+ _readyPromise = new Promise((resolve3) => {
4819
+ _readyResolve = resolve3;
4820
+ });
4821
+ }
4822
+ initReadyGate();
4823
+ function markOutboundReady() {
4824
+ if (_readyResolve) {
4825
+ _readyResolve();
4826
+ _readyResolve = null;
4827
+ _readyPromise = null;
4828
+ }
4829
+ }
4830
+ function resetOutbound() {
4831
+ messagePipeGetter = null;
4832
+ sdkRuntimeGetter = null;
4833
+ tokenManagerGetter = null;
4834
+ pluginConfigGetter = null;
4835
+ initReadyGate();
4836
+ }
4837
+ var READY_TIMEOUT_MS = 12e4;
4838
+ async function waitForReady() {
4839
+ if (!_readyPromise) return true;
4840
+ log7.info("outbound: waiting for dependencies to initialize...");
4841
+ return new Promise((resolve3) => {
4842
+ const timer = setTimeout(() => {
4843
+ log7.error(`outbound: dependencies not ready after ${READY_TIMEOUT_MS}ms`);
4844
+ resolve3(false);
4845
+ }, READY_TIMEOUT_MS);
4846
+ _readyPromise.then(() => {
4847
+ clearTimeout(timer);
4848
+ log7.info("outbound: dependencies ready \u2713");
4849
+ resolve3(true);
4850
+ });
4851
+ });
4852
+ }
4815
4853
  function getOutboundEncryptionStatus(chatId) {
4816
4854
  const messageId = activeChatMessage.get(chatId);
4817
4855
  if (!messageId) return void 0;
@@ -4848,8 +4886,11 @@ var quantumImOutbound = {
4848
4886
  return { channel: CHANNEL_ID, messageId: "", chatId: to };
4849
4887
  }
4850
4888
  if (!messagePipeGetter) {
4851
- log7.error("outbound:sendText failed, messagePipe not initialized");
4852
- return { channel: CHANNEL_ID, messageId: "", chatId: to };
4889
+ const ready = await waitForReady();
4890
+ if (!ready || !messagePipeGetter) {
4891
+ log7.error("outbound:sendText failed, messagePipe not initialized");
4892
+ return { channel: CHANNEL_ID, messageId: "", chatId: to };
4893
+ }
4853
4894
  }
4854
4895
  const messagePipe = messagePipeGetter();
4855
4896
  const chatId = parseChannelAddress(to);
@@ -4869,8 +4910,11 @@ var quantumImOutbound = {
4869
4910
  sendMedia: async ({ cfg, to, text, mediaUrl, mediaLocalRoots, accountId }) => {
4870
4911
  log7.info("sendMedia called", { to, mediaUrl });
4871
4912
  if (!messagePipeGetter || !sdkRuntimeGetter || !tokenManagerGetter || !pluginConfigGetter) {
4872
- log7.error("outbound:sendMedia failed, dependencies not initialized");
4873
- return { channel: CHANNEL_ID, messageId: "", chatId: to };
4913
+ const ready = await waitForReady();
4914
+ if (!messagePipeGetter || !sdkRuntimeGetter || !tokenManagerGetter || !pluginConfigGetter) {
4915
+ log7.error("outbound:sendMedia failed, dependencies not initialized after wait");
4916
+ return { channel: CHANNEL_ID, messageId: "", chatId: to };
4917
+ }
4874
4918
  }
4875
4919
  const messagePipe = messagePipeGetter();
4876
4920
  const sdkRuntime = sdkRuntimeGetter();
@@ -21281,6 +21325,7 @@ async function startPlugin(accountConfig, internalOverrides) {
21281
21325
  tokenManager.shutdown();
21282
21326
  metrics.stop();
21283
21327
  destroyEncryptionMaps();
21328
+ resetOutbound();
21284
21329
  log20.info("Shutdown complete \u2713");
21285
21330
  }
21286
21331
  };
@@ -22252,6 +22297,11 @@ var quantumImPlugin = {
22252
22297
  const instance = await startPlugin(resolved.credentials);
22253
22298
  activeInstance = instance;
22254
22299
  const { config: config2 } = instance;
22300
+ setMessagePipeGetter(() => instance.messagePipe);
22301
+ setSdkRuntimeGetter(() => getPluginRuntime());
22302
+ setTokenManagerGetter(() => instance.tokenManager);
22303
+ setPluginConfigGetter(() => instance.config);
22304
+ markOutboundReady();
22255
22305
  await instance.connectionManager.start(
22256
22306
  config2.transport.wsUrl,
22257
22307
  () => instance.tokenManager.getValidToken(),
@@ -22269,10 +22319,6 @@ var quantumImPlugin = {
22269
22319
  instance.messagePipe.onMessage((msg) => {
22270
22320
  pipeline.handle(msg);
22271
22321
  });
22272
- setMessagePipeGetter(() => instance.messagePipe);
22273
- setSdkRuntimeGetter(() => getPluginRuntime());
22274
- setTokenManagerGetter(() => instance.tokenManager);
22275
- setPluginConfigGetter(() => instance.config);
22276
22322
  log29.info(`liangzimixin[${ctx.accountId}] started \u2713`);
22277
22323
  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");
22278
22324
  await new Promise((resolve3) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "liangzimixin",
3
- "version": "0.3.75",
3
+ "version": "0.3.77",
4
4
  "description": "Quantum-encrypted IM channel plugin for OpenClaw",
5
5
  "type": "module",
6
6
  "main": "dist/index.cjs",
@@ -7,7 +7,7 @@ REM liangzimixin install script (Windows)
7
7
  REM Usage: liangzimixin_install.bat <appId> <appSecret> [quantumAccount]
8
8
  REM ============================================================
9
9
 
10
- set "SCRIPT_VERSION=0.3.75"
10
+ set "SCRIPT_VERSION=0.3.77"
11
11
  set "NPM_PACKAGE=liangzimixin"
12
12
 
13
13
  set "SKIP_SELF_UPDATE=0"
@@ -6,7 +6,7 @@ set -euo pipefail
6
6
  # 用法: ./liangzimixin_install.sh <appId> <appSecret> [quantumAccount]
7
7
  # ============================================================
8
8
 
9
- SCRIPT_VERSION="0.3.75"
9
+ SCRIPT_VERSION="0.3.77"
10
10
  NPM_PACKAGE="liangzimixin"
11
11
 
12
12
  # ── 颜色 ──────────────────────────────────────────────────────