@joshuaswarren/openclaw-engram 9.0.9 → 9.0.10

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
@@ -12536,6 +12536,9 @@ function serializeBoxFrontmatter(fm) {
12536
12536
  ];
12537
12537
  if (fm.sessionKey) lines.push(`sessionKey: ${fm.sessionKey}`);
12538
12538
  if (fm.traceId) lines.push(`traceId: ${fm.traceId}`);
12539
+ if (fm.goal) lines.push(`goal: ${fm.goal.replace(/[\r\n]+/g, " ")}`);
12540
+ if (fm.toolsUsed?.length) lines.push(`toolsUsed: [${fm.toolsUsed.map((t) => `"${t}"`).join(", ")}]`);
12541
+ if (fm.outcome) lines.push(`outcome: ${fm.outcome}`);
12539
12542
  lines.push("---");
12540
12543
  return lines.join("\n");
12541
12544
  }
@@ -12555,6 +12558,7 @@ function parseBoxFrontmatter(raw) {
12555
12558
  if (!m) return [];
12556
12559
  return m[1].split(",").map((s) => s.trim().replace(/^"|"$/g, "")).filter(Boolean);
12557
12560
  };
12561
+ const outcome = fm.outcome;
12558
12562
  return {
12559
12563
  id: fm.id ?? "",
12560
12564
  memoryKind: "box",
@@ -12564,7 +12568,10 @@ function parseBoxFrontmatter(raw) {
12564
12568
  sessionKey: fm.sessionKey,
12565
12569
  topics: parseArray(fm.topics),
12566
12570
  memoryIds: parseArray(fm.memoryIds),
12567
- traceId: fm.traceId
12571
+ traceId: fm.traceId,
12572
+ goal: fm.goal || void 0,
12573
+ toolsUsed: fm.toolsUsed ? parseArray(fm.toolsUsed) : void 0,
12574
+ outcome: outcome && ["success", "failure", "partial", "unknown"].includes(outcome) ? outcome : void 0
12568
12575
  };
12569
12576
  }
12570
12577
  var BoxBuilder = class {
@@ -12650,6 +12657,10 @@ var BoxBuilder = class {
12650
12657
  const topicSet = /* @__PURE__ */ new Set([...this.openBox.topics, ...newTopics]);
12651
12658
  this.openBox.topics = [...topicSet];
12652
12659
  this.openBox.memoryIds.push(...event.memoryIds);
12660
+ if (event.toolsUsed?.length) {
12661
+ const toolSet = /* @__PURE__ */ new Set([...this.openBox.toolsUsed ?? [], ...event.toolsUsed]);
12662
+ this.openBox.toolsUsed = [...toolSet];
12663
+ }
12653
12664
  await this.sealCurrent("max_memories");
12654
12665
  } else if (topicShifted) {
12655
12666
  await this.sealCurrent("topic_shift");
@@ -12664,6 +12675,10 @@ var BoxBuilder = class {
12664
12675
  const topicSet = /* @__PURE__ */ new Set([...this.openBox.topics, ...newTopics]);
12665
12676
  this.openBox.topics = [...topicSet];
12666
12677
  this.openBox.lastActivityAt = now.toISOString();
12678
+ if (event.toolsUsed?.length) {
12679
+ const toolSet = /* @__PURE__ */ new Set([...this.openBox.toolsUsed ?? [], ...event.toolsUsed]);
12680
+ this.openBox.toolsUsed = [...toolSet];
12681
+ }
12667
12682
  await this.saveOpenBox();
12668
12683
  }
12669
12684
  } else {
@@ -12681,7 +12696,9 @@ var BoxBuilder = class {
12681
12696
  createdAt: ts,
12682
12697
  lastActivityAt: ts,
12683
12698
  topics: event.topics.filter(Boolean),
12684
- memoryIds: [...event.memoryIds]
12699
+ memoryIds: [...event.memoryIds],
12700
+ goal: event.goal,
12701
+ toolsUsed: event.toolsUsed?.length ? [...event.toolsUsed] : void 0
12685
12702
  };
12686
12703
  }
12687
12704
  /**
@@ -12713,7 +12730,10 @@ var BoxBuilder = class {
12713
12730
  sealReason: reason,
12714
12731
  topics: box.topics,
12715
12732
  memoryIds: box.memoryIds,
12716
- traceId
12733
+ traceId,
12734
+ goal: box.goal,
12735
+ toolsUsed: box.toolsUsed?.length ? box.toolsUsed : void 0,
12736
+ outcome: "unknown"
12717
12737
  };
12718
12738
  const content = `${serializeBoxFrontmatter(fm)}
12719
12739
 
@@ -18387,10 +18407,13 @@ _Context: ${topQuestion.context}_`
18387
18407
  await clearBuffer();
18388
18408
  if (this.config.memoryBoxesEnabled && persistedIds.length > 0) {
18389
18409
  const extractionTopics = deriveTopicsFromExtraction(result);
18410
+ const firstUserTurn = turns.find((t) => t.role === "user");
18411
+ const boxGoal = firstUserTurn?.content?.slice(0, 100)?.trim() || void 0;
18390
18412
  await this.boxBuilderFor(storage).onExtraction({
18391
18413
  topics: extractionTopics,
18392
18414
  memoryIds: persistedIds,
18393
- timestamp: (/* @__PURE__ */ new Date()).toISOString()
18415
+ timestamp: (/* @__PURE__ */ new Date()).toISOString(),
18416
+ goal: boxGoal
18394
18417
  }).catch((err) => log.warn("[boxes] onExtraction failed (non-fatal)", err));
18395
18418
  }
18396
18419
  if (this.config.threadingEnabled && threadIdForExtraction && persistedIds.length > 0) {