@joshuaswarren/openclaw-engram 8.3.60 → 8.3.61
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 +29 -0
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -12414,6 +12414,14 @@ function deriveTopicsFromExtraction(result) {
|
|
|
12414
12414
|
}
|
|
12415
12415
|
return [...topics].slice(0, 16);
|
|
12416
12416
|
}
|
|
12417
|
+
function formatCompressionGuidelinesForRecall(raw, maxLines = 5) {
|
|
12418
|
+
if (typeof raw !== "string" || raw.trim().length === 0) return null;
|
|
12419
|
+
const sectionMatch = raw.match(/## Suggested Guidelines\s*\n([\s\S]*?)(?:\n##\s+|\s*$)/i);
|
|
12420
|
+
if (!sectionMatch) return null;
|
|
12421
|
+
const lines = sectionMatch[1].split("\n").map((line) => line.trim()).filter((line) => line.startsWith("- ")).slice(0, Math.max(1, Math.floor(maxLines)));
|
|
12422
|
+
if (lines.length === 0) return null;
|
|
12423
|
+
return lines.join("\n");
|
|
12424
|
+
}
|
|
12417
12425
|
function filterRecallCandidates(candidates, options) {
|
|
12418
12426
|
const scopedByNamespace = options.namespacesEnabled ? candidates.filter((r) => options.recallNamespaces.includes(options.resolveNamespace(r.path))) : candidates;
|
|
12419
12427
|
return scopedByNamespace.filter((r) => !isArtifactMemoryPath(r.path)).slice(0, Math.max(0, options.limit));
|
|
@@ -13988,6 +13996,10 @@ ${tmtNode.summary}`);
|
|
|
13988
13996
|
);
|
|
13989
13997
|
}
|
|
13990
13998
|
}
|
|
13999
|
+
const compressionGuidelineSection = await this.buildCompressionGuidelineRecallSection();
|
|
14000
|
+
if (compressionGuidelineSection) {
|
|
14001
|
+
sections.push(compressionGuidelineSection);
|
|
14002
|
+
}
|
|
13991
14003
|
const transcriptT0 = Date.now();
|
|
13992
14004
|
log.debug(`recall: transcriptEnabled=${this.config.transcriptEnabled}, sessionKey=${sessionKey}`);
|
|
13993
14005
|
if (this.config.transcriptEnabled) {
|
|
@@ -15248,6 +15260,23 @@ ${texts.map((t, i) => `[${i + 1}] ${t}`).join("\n\n")}`;
|
|
|
15248
15260
|
log.warn(`compression guideline learning failed (ignored): ${err}`);
|
|
15249
15261
|
}
|
|
15250
15262
|
}
|
|
15263
|
+
async buildCompressionGuidelineRecallSection() {
|
|
15264
|
+
if (!this.config.contextCompressionActionsEnabled) return null;
|
|
15265
|
+
if (!this.config.compressionGuidelineLearningEnabled) return null;
|
|
15266
|
+
const state = await this.storage.readCompressionGuidelineOptimizerState().catch(() => null);
|
|
15267
|
+
if (!state || state.guidelineVersion <= 0) return null;
|
|
15268
|
+
const raw = await this.storage.readCompressionGuidelines().catch(() => null);
|
|
15269
|
+
const summary = raw ? formatCompressionGuidelinesForRecall(raw, 5) : null;
|
|
15270
|
+
if (!summary) return null;
|
|
15271
|
+
return [
|
|
15272
|
+
"## Active Compression Guidelines",
|
|
15273
|
+
"",
|
|
15274
|
+
`Guideline version: ${state.guidelineVersion}`,
|
|
15275
|
+
`Updated: ${state.updatedAt}`,
|
|
15276
|
+
"",
|
|
15277
|
+
summary
|
|
15278
|
+
].join("\n");
|
|
15279
|
+
}
|
|
15251
15280
|
parseCompressionSemanticRefinement(raw) {
|
|
15252
15281
|
if (typeof raw !== "string" || raw.trim().length === 0) return null;
|
|
15253
15282
|
const trimmed = raw.trim();
|