@joshuaswarren/openclaw-engram 8.3.61 → 8.3.62

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
@@ -418,6 +418,9 @@ function parseConfig(raw) {
418
418
  causalGraphEnabled: cfg.causalGraphEnabled !== false,
419
419
  maxGraphTraversalSteps: typeof cfg.maxGraphTraversalSteps === "number" ? Math.max(0, cfg.maxGraphTraversalSteps) : 3,
420
420
  graphActivationDecay: typeof cfg.graphActivationDecay === "number" ? Math.min(1, Math.max(0, cfg.graphActivationDecay)) : 0.7,
421
+ graphExpansionActivationWeight: typeof cfg.graphExpansionActivationWeight === "number" ? Math.min(1, Math.max(0, cfg.graphExpansionActivationWeight)) : 0.65,
422
+ graphExpansionBlendMin: typeof cfg.graphExpansionBlendMin === "number" ? Math.min(1, Math.max(0, cfg.graphExpansionBlendMin)) : 0.05,
423
+ graphExpansionBlendMax: typeof cfg.graphExpansionBlendMax === "number" ? Math.min(1, Math.max(0, cfg.graphExpansionBlendMax)) : 0.95,
421
424
  maxEntityGraphEdgesPerMemory: typeof cfg.maxEntityGraphEdgesPerMemory === "number" ? Math.max(0, cfg.maxEntityGraphEdgesPerMemory) : 10,
422
425
  // v8.2: Temporal Memory Tree
423
426
  temporalMemoryTreeEnabled: cfg.temporalMemoryTreeEnabled === true,
@@ -12534,10 +12537,20 @@ function graphPathRelativeToStorage(storageDir, candidatePath) {
12534
12537
  if (rel.startsWith("..")) return null;
12535
12538
  return rel.split(path25.sep).join("/");
12536
12539
  }
12537
- function graphActivationScoreToRecallScore(score) {
12540
+ function normalizeGraphActivationScore(score) {
12538
12541
  const bounded = Number.isFinite(score) && score > 0 ? score : 0;
12539
- const normalized = bounded / (1 + bounded);
12540
- return Math.max(0.05, Math.min(0.95, normalized));
12542
+ return bounded / (1 + bounded);
12543
+ }
12544
+ function blendGraphExpandedRecallScore(options) {
12545
+ const graphNorm = normalizeGraphActivationScore(options.graphActivationScore);
12546
+ const seedScore = Number.isFinite(options.seedRecallScore) ? Math.min(1, Math.max(0, options.seedRecallScore)) : 0;
12547
+ const weight = Math.min(1, Math.max(0, options.activationWeight));
12548
+ const rawMin = Math.min(1, Math.max(0, options.blendMin));
12549
+ const rawMax = Math.min(1, Math.max(0, options.blendMax));
12550
+ const minBound = Math.min(rawMin, rawMax);
12551
+ const maxBound = Math.max(rawMin, rawMax);
12552
+ const blended = graphNorm * weight + seedScore * (1 - weight);
12553
+ return Math.max(minBound, Math.min(maxBound, blended));
12541
12554
  }
12542
12555
  function mergeArtifactRecallCandidates(candidatesByNamespace, limit) {
12543
12556
  const cappedLimit = Math.max(0, limit);
@@ -13430,8 +13443,10 @@ ${r.snippet.trim()}
13430
13443
  const expandedResults = [];
13431
13444
  for (const [namespace, nsResults] of byNamespace.entries()) {
13432
13445
  const storage = await this.storageRouter.storageFor(namespace);
13433
- const seedRelativePaths = nsResults.slice(0, perNamespaceSeedCap).map((result) => graphPathRelativeToStorage(storage.dir, result.path)).filter((value) => typeof value === "string" && value.length > 0);
13446
+ const seedCandidates = nsResults.slice(0, perNamespaceSeedCap);
13447
+ const seedRelativePaths = seedCandidates.map((result) => graphPathRelativeToStorage(storage.dir, result.path)).filter((value) => typeof value === "string" && value.length > 0);
13434
13448
  if (seedRelativePaths.length === 0) continue;
13449
+ const seedRecallScore = seedCandidates.reduce((max, item) => Math.max(max, item.score), 0);
13435
13450
  seedPaths.push(...seedRelativePaths.map((rel) => path25.join(storage.dir, rel)));
13436
13451
  const seedSet = new Set(seedRelativePaths);
13437
13452
  const expanded = await this.graphIndexFor(storage).spreadingActivation(
@@ -13447,7 +13462,13 @@ ${r.snippet.trim()}
13447
13462
  if (isArtifactMemoryPath(memory.path)) continue;
13448
13463
  if (memory.frontmatter.status && memory.frontmatter.status !== "active") continue;
13449
13464
  const snippet = memory.content.slice(0, 400);
13450
- const score = graphActivationScoreToRecallScore(candidate.score);
13465
+ const score = blendGraphExpandedRecallScore({
13466
+ graphActivationScore: candidate.score,
13467
+ seedRecallScore,
13468
+ activationWeight: this.config.graphExpansionActivationWeight,
13469
+ blendMin: this.config.graphExpansionBlendMin,
13470
+ blendMax: this.config.graphExpansionBlendMax
13471
+ });
13451
13472
  expandedResults.push({
13452
13473
  docid: memory.frontmatter.id,
13453
13474
  path: memory.path,