@joshuaswarren/openclaw-engram 8.3.56 → 8.3.57

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
@@ -5168,6 +5168,9 @@ var StorageManager = class _StorageManager {
5168
5168
  get compressionGuidelinesPath() {
5169
5169
  return path4.join(this.stateDir, "compression-guidelines.md");
5170
5170
  }
5171
+ get compressionGuidelineStatePath() {
5172
+ return path4.join(this.stateDir, "compression-guideline-state.json");
5173
+ }
5171
5174
  /**
5172
5175
  * Load user-defined entity aliases from config/aliases.json in the memory store.
5173
5176
  * File format: { "variant": "canonical", "variant2": "canonical", ... }
@@ -5807,6 +5810,40 @@ ${memory.content}
5807
5810
  return null;
5808
5811
  }
5809
5812
  }
5813
+ async writeCompressionGuidelineOptimizerState(state) {
5814
+ await this.ensureDirectories();
5815
+ await writeFile2(this.compressionGuidelineStatePath, `${JSON.stringify(state, null, 2)}
5816
+ `, "utf-8");
5817
+ }
5818
+ async readCompressionGuidelineOptimizerState() {
5819
+ const isFiniteNonNegativeInteger = (value) => typeof value === "number" && Number.isFinite(value) && Number.isInteger(value) && value >= 0;
5820
+ try {
5821
+ const raw = await readFile2(this.compressionGuidelineStatePath, "utf-8");
5822
+ const parsed = JSON.parse(raw);
5823
+ const sourceWindow = parsed?.sourceWindow;
5824
+ const eventCounts = parsed?.eventCounts;
5825
+ if (!isFiniteNonNegativeInteger(parsed?.version) || typeof parsed?.updatedAt !== "string" || parsed.updatedAt.length === 0 || !sourceWindow || typeof sourceWindow.from !== "string" || sourceWindow.from.length === 0 || typeof sourceWindow.to !== "string" || sourceWindow.to.length === 0 || !eventCounts || !isFiniteNonNegativeInteger(eventCounts.total) || !isFiniteNonNegativeInteger(eventCounts.applied) || !isFiniteNonNegativeInteger(eventCounts.skipped) || !isFiniteNonNegativeInteger(eventCounts.failed) || !isFiniteNonNegativeInteger(parsed?.guidelineVersion)) {
5826
+ return null;
5827
+ }
5828
+ return {
5829
+ version: parsed.version,
5830
+ updatedAt: parsed.updatedAt,
5831
+ sourceWindow: {
5832
+ from: sourceWindow.from,
5833
+ to: sourceWindow.to
5834
+ },
5835
+ eventCounts: {
5836
+ total: eventCounts.total,
5837
+ applied: eventCounts.applied,
5838
+ skipped: eventCounts.skipped,
5839
+ failed: eventCounts.failed
5840
+ },
5841
+ guidelineVersion: parsed.guidelineVersion
5842
+ };
5843
+ } catch {
5844
+ return null;
5845
+ }
5846
+ }
5810
5847
  async writeIdentityAnchor(content) {
5811
5848
  await this.ensureDirectories();
5812
5849
  await writeFile2(this.identityAnchorPath, content, "utf-8");