@joshuaswarren/openclaw-engram 9.0.99 → 9.0.102

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.js CHANGED
@@ -13980,13 +13980,20 @@ Use this context naturally when relevant. Never quote or expose this memory cont
13980
13980
  api.registerService({
13981
13981
  id: "openclaw-engram",
13982
13982
  start: async () => {
13983
- if (globalThis[ENGRAM_INIT_PROMISE]) {
13984
- await globalThis[ENGRAM_INIT_PROMISE];
13985
- if (globalThis[ENGRAM_SERVICE_STARTED]) return;
13986
- }
13987
- if (globalThis[ENGRAM_SERVICE_STARTED]) {
13988
- log.debug("openclaw-engram: service.start() called again \u2014 skipping duplicate init");
13989
- return;
13983
+ for (; ; ) {
13984
+ while (globalThis[ENGRAM_INIT_PROMISE]) {
13985
+ try {
13986
+ await globalThis[ENGRAM_INIT_PROMISE];
13987
+ } catch {
13988
+ }
13989
+ if (globalThis[ENGRAM_SERVICE_STARTED]) return;
13990
+ }
13991
+ if (globalThis[ENGRAM_SERVICE_STARTED]) {
13992
+ log.debug("openclaw-engram: service.start() called again \u2014 skipping duplicate init");
13993
+ return;
13994
+ }
13995
+ if (globalThis[ENGRAM_INIT_PROMISE]) continue;
13996
+ break;
13990
13997
  }
13991
13998
  didCountStart = true;
13992
13999
  const initPromise = (async () => {
@@ -14018,6 +14025,7 @@ Use this context naturally when relevant. Never quote or expose this memory cont
14018
14025
  }
14019
14026
  }
14020
14027
  if (!didCountStart) return;
14028
+ globalThis[ENGRAM_SERVICE_STARTED] = true;
14021
14029
  log.info("engram memory system ready");
14022
14030
  } catch (err) {
14023
14031
  try {
@@ -14031,7 +14039,6 @@ Use this context naturally when relevant. Never quote or expose this memory cont
14031
14039
  }
14032
14040
  })();
14033
14041
  globalThis[ENGRAM_INIT_PROMISE] = initPromise;
14034
- globalThis[ENGRAM_SERVICE_STARTED] = true;
14035
14042
  try {
14036
14043
  await initPromise;
14037
14044
  } finally {
@@ -14054,9 +14061,26 @@ Use this context naturally when relevant. Never quote or expose this memory cont
14054
14061
  }
14055
14062
  delete globalThis[ENGRAM_ACCESS_HTTP_SERVER];
14056
14063
  delete globalThis[ENGRAM_ACCESS_SERVICE];
14057
- globalThis[ENGRAM_REGISTERED_GUARD] = false;
14058
- globalThis[ENGRAM_HOOK_APIS] = /* @__PURE__ */ new WeakSet();
14059
- globalThis[ENGRAM_SERVICE_STARTED] = false;
14064
+ const currentInitPromise = globalThis[ENGRAM_INIT_PROMISE];
14065
+ let secondaryTookOver = false;
14066
+ if (!currentInitPromise) {
14067
+ globalThis[ENGRAM_REGISTERED_GUARD] = false;
14068
+ } else {
14069
+ try {
14070
+ await currentInitPromise;
14071
+ } catch {
14072
+ }
14073
+ await new Promise((resolve) => queueMicrotask(resolve));
14074
+ if (globalThis[ENGRAM_INIT_PROMISE] || globalThis[ENGRAM_SERVICE_STARTED]) {
14075
+ secondaryTookOver = true;
14076
+ }
14077
+ }
14078
+ if (!secondaryTookOver) {
14079
+ globalThis[ENGRAM_HOOK_APIS] = /* @__PURE__ */ new WeakSet();
14080
+ }
14081
+ if (!secondaryTookOver) {
14082
+ globalThis[ENGRAM_SERVICE_STARTED] = false;
14083
+ }
14060
14084
  log.info("stopped");
14061
14085
  }
14062
14086
  });