memory-braid 0.3.6 → 0.3.7

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "memory-braid",
3
- "version": "0.3.6",
3
+ "version": "0.3.7",
4
4
  "description": "OpenClaw memory plugin that augments local memory with Mem0, bootstrap import, reconcile, and capture.",
5
5
  "type": "module",
6
6
  "main": "./src/index.ts",
package/src/index.ts CHANGED
@@ -439,6 +439,34 @@ const memoryBraidPlugin = {
439
439
  return;
440
440
  }
441
441
 
442
+ if (!statePaths) {
443
+ const resolvedStateDir = api.runtime.state.resolveStateDir();
444
+ if (resolvedStateDir) {
445
+ const lazyStatePaths = createStatePaths(resolvedStateDir);
446
+ try {
447
+ await ensureStateDir(lazyStatePaths);
448
+ statePaths = lazyStatePaths;
449
+ mem0.setStateDir(resolvedStateDir);
450
+ entityExtraction.setStateDir(resolvedStateDir);
451
+ log.info("memory_braid.state.ready", {
452
+ runId,
453
+ reason: "lazy_capture",
454
+ stateDir: resolvedStateDir,
455
+ });
456
+ } catch (err) {
457
+ log.warn("memory_braid.capture.skip", {
458
+ runId,
459
+ reason: "state_init_failed",
460
+ workspaceHash: scope.workspaceHash,
461
+ agentId: scope.agentId,
462
+ sessionKey: scope.sessionKey,
463
+ error: err instanceof Error ? err.message : String(err),
464
+ });
465
+ return;
466
+ }
467
+ }
468
+ }
469
+
442
470
  if (!statePaths) {
443
471
  log.warn("memory_braid.capture.skip", {
444
472
  runId,
@@ -157,6 +157,20 @@ function isSqliteBindingsError(error: unknown): boolean {
157
157
  return /Could not locate the bindings file/i.test(message) || /node_sqlite3\.node/i.test(message);
158
158
  }
159
159
 
160
+ export function isMem0DeleteNotFoundError(error: unknown): boolean {
161
+ const message = asErrorMessage(error).toLowerCase();
162
+ if (!message) {
163
+ return false;
164
+ }
165
+
166
+ return (
167
+ /\bmemory\b.*\bnot found\b/.test(message) ||
168
+ /\bnot found\b.*\bmemory\b/.test(message) ||
169
+ /\bmemory\b.*\bdoes not exist\b/.test(message) ||
170
+ /\bno such memory\b/.test(message)
171
+ );
172
+ }
173
+
160
174
  function createLocalRequire(): NodeJS.Require {
161
175
  return createRequire(import.meta.url);
162
176
  }
@@ -738,6 +752,21 @@ export class Mem0Adapter {
738
752
  });
739
753
  return true;
740
754
  } catch (err) {
755
+ const missingRemote = isMem0DeleteNotFoundError(err);
756
+ if (missingRemote) {
757
+ this.log.debug("memory_braid.mem0.response", {
758
+ runId: params.runId,
759
+ action: "delete",
760
+ mode: prepared.mode,
761
+ workspaceHash: params.scope.workspaceHash,
762
+ agentId: params.scope.agentId,
763
+ memoryId: params.memoryId,
764
+ durMs: Date.now() - startedAt,
765
+ alreadyMissing: true,
766
+ });
767
+ return true;
768
+ }
769
+
741
770
  this.log.warn("memory_braid.mem0.error", {
742
771
  runId: params.runId,
743
772
  action: "delete",