@joshuaswarren/openclaw-engram 9.0.53 → 9.0.54

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
@@ -6780,7 +6780,7 @@ function serializeFrontmatter(fm) {
6780
6780
  lines.push(` - targetId: ${link.targetId}`);
6781
6781
  lines.push(` linkType: ${link.linkType}`);
6782
6782
  lines.push(` strength: ${link.strength}`);
6783
- if (link.reason) lines.push(` reason: "${link.reason.replace(/"/g, '\\"')}"`);
6783
+ if (link.reason) lines.push(` reason: ${JSON.stringify(link.reason)}`);
6784
6784
  }
6785
6785
  }
6786
6786
  if (fm.intentGoal) lines.push(`intentGoal: ${fm.intentGoal}`);
@@ -6795,6 +6795,18 @@ function serializeFrontmatter(fm) {
6795
6795
  lines.push("---");
6796
6796
  return lines.join("\n");
6797
6797
  }
6798
+ function parseLinkReasonValue(rawValue) {
6799
+ const legacyValue = rawValue.replace(/\\"/g, '"');
6800
+ const looksLikeLegacyPath = !rawValue.includes("\\\\") && (/[A-Za-z]:\\[A-Za-z0-9._ -]+(?:\\[A-Za-z0-9._ -]+)+/.test(rawValue) || /\\[A-Za-z0-9._ -]+\\[A-Za-z0-9._ -]+/.test(rawValue));
6801
+ if (looksLikeLegacyPath) {
6802
+ return legacyValue;
6803
+ }
6804
+ try {
6805
+ return JSON.parse(`"${rawValue}"`);
6806
+ } catch {
6807
+ return legacyValue;
6808
+ }
6809
+ }
6798
6810
  function parseFrontmatter3(raw) {
6799
6811
  const match = raw.match(/^---\n([\s\S]*?)\n---\n?([\s\S]*)$/);
6800
6812
  if (!match) return null;
@@ -6897,14 +6909,14 @@ function parseFrontmatter3(raw) {
6897
6909
  if (fmBlock.includes("links:")) {
6898
6910
  const links = [];
6899
6911
  const linkMatches = fmBlock.matchAll(
6900
- /- targetId: (\S+)\s+linkType: (\S+)\s+strength: ([\d.]+)(?:\s+reason: "([^"]*)")?/g
6912
+ /- targetId: (\S+)\s+linkType: (\S+)\s+strength: ([\d.]+)(?:\s+reason: "((?:\\.|[^"\\])*)")?/g
6901
6913
  );
6902
6914
  for (const match2 of linkMatches) {
6903
6915
  links.push({
6904
6916
  targetId: match2[1],
6905
6917
  linkType: match2[2],
6906
6918
  strength: parseFloat(match2[3]),
6907
- reason: match2[4] || void 0
6919
+ reason: match2[4] ? parseLinkReasonValue(match2[4]) : void 0
6908
6920
  });
6909
6921
  }
6910
6922
  if (links.length > 0) {