@joshuaswarren/openclaw-engram 8.0.1 → 8.0.2
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 +107 -7
- package/dist/index.js.map +1 -1
- package/openclaw.plugin.json +5 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -366,7 +366,9 @@ function parseConfig(raw) {
|
|
|
366
366
|
traceWeaverEnabled: cfg.traceWeaverEnabled === true,
|
|
367
367
|
traceWeaverLookbackDays: typeof cfg.traceWeaverLookbackDays === "number" ? cfg.traceWeaverLookbackDays : 7,
|
|
368
368
|
traceWeaverOverlapThreshold: typeof cfg.traceWeaverOverlapThreshold === "number" ? cfg.traceWeaverOverlapThreshold : 0.4,
|
|
369
|
-
boxRecallDays: typeof cfg.boxRecallDays === "number" ? cfg.boxRecallDays : 3
|
|
369
|
+
boxRecallDays: typeof cfg.boxRecallDays === "number" ? cfg.boxRecallDays : 3,
|
|
370
|
+
// v8.0 Phase 2B: Episode/Note dual store (HiMem)
|
|
371
|
+
episodeNoteModeEnabled: cfg.episodeNoteModeEnabled === true
|
|
370
372
|
};
|
|
371
373
|
}
|
|
372
374
|
|
|
@@ -4141,6 +4143,7 @@ function serializeFrontmatter(fm) {
|
|
|
4141
4143
|
if (fm.artifactType) lines.push(`artifactType: ${fm.artifactType}`);
|
|
4142
4144
|
if (fm.sourceMemoryId) lines.push(`sourceMemoryId: ${fm.sourceMemoryId}`);
|
|
4143
4145
|
if (fm.sourceTurnId) lines.push(`sourceTurnId: ${fm.sourceTurnId}`);
|
|
4146
|
+
if (fm.memoryKind) lines.push(`memoryKind: ${fm.memoryKind}`);
|
|
4144
4147
|
lines.push("---");
|
|
4145
4148
|
return lines.join("\n");
|
|
4146
4149
|
}
|
|
@@ -4229,7 +4232,9 @@ function parseFrontmatter(raw) {
|
|
|
4229
4232
|
intentEntityTypes: intentEntityTypes && intentEntityTypes.length > 0 ? intentEntityTypes : void 0,
|
|
4230
4233
|
artifactType: fm.artifactType || void 0,
|
|
4231
4234
|
sourceMemoryId: fm.sourceMemoryId || void 0,
|
|
4232
|
-
sourceTurnId: fm.sourceTurnId || void 0
|
|
4235
|
+
sourceTurnId: fm.sourceTurnId || void 0,
|
|
4236
|
+
// v8.0 Phase 2B: HiMem episode/note classification
|
|
4237
|
+
memoryKind: fm.memoryKind || void 0
|
|
4233
4238
|
},
|
|
4234
4239
|
content
|
|
4235
4240
|
};
|
|
@@ -4585,7 +4590,8 @@ var StorageManager = class _StorageManager {
|
|
|
4585
4590
|
intentEntityTypes: options.intentEntityTypes,
|
|
4586
4591
|
artifactType: options.artifactType,
|
|
4587
4592
|
sourceMemoryId: options.sourceMemoryId,
|
|
4588
|
-
sourceTurnId: options.sourceTurnId
|
|
4593
|
+
sourceTurnId: options.sourceTurnId,
|
|
4594
|
+
memoryKind: options.memoryKind
|
|
4589
4595
|
};
|
|
4590
4596
|
const sanitized = sanitizeMemoryContent(content);
|
|
4591
4597
|
if (!sanitized.clean) {
|
|
@@ -5588,7 +5594,8 @@ ${memory.content}
|
|
|
5588
5594
|
chunkTotal,
|
|
5589
5595
|
intentGoal: options.intentGoal,
|
|
5590
5596
|
intentActionType: options.intentActionType,
|
|
5591
|
-
intentEntityTypes: options.intentEntityTypes
|
|
5597
|
+
intentEntityTypes: options.intentEntityTypes,
|
|
5598
|
+
memoryKind: options.memoryKind
|
|
5592
5599
|
};
|
|
5593
5600
|
const sanitized = sanitizeMemoryContent(content);
|
|
5594
5601
|
if (!sanitized.clean) {
|
|
@@ -8283,6 +8290,94 @@ var BoxBuilder = class {
|
|
|
8283
8290
|
}
|
|
8284
8291
|
};
|
|
8285
8292
|
|
|
8293
|
+
// src/himem.ts
|
|
8294
|
+
var NOTE_SIGNALS = [
|
|
8295
|
+
/\bprefer(?:red|s|ring)?\b/i,
|
|
8296
|
+
/\bwant(?:ed|s|ing)?\b/i,
|
|
8297
|
+
/\bneed(?:ed|s|ing)?\b/i,
|
|
8298
|
+
/\balways\b/i,
|
|
8299
|
+
/\bnever\b/i,
|
|
8300
|
+
/\bmust\b/i,
|
|
8301
|
+
/\bshould\b/i,
|
|
8302
|
+
/\bgoals?\b/i,
|
|
8303
|
+
/\bdecid(?:ed|es|e|ing)\b/i,
|
|
8304
|
+
/\bpolic(?:y|ies)\b/i,
|
|
8305
|
+
/\brequir(?:ed|es?|ements?|ing)\b/i,
|
|
8306
|
+
/\bconstraints?\b/i,
|
|
8307
|
+
/\bstandards?\b/i,
|
|
8308
|
+
/\bconventions?\b/i
|
|
8309
|
+
];
|
|
8310
|
+
var TEMPORAL_SIGNALS = [
|
|
8311
|
+
/\byesterday\b/i,
|
|
8312
|
+
/\btoday\b/i,
|
|
8313
|
+
/\blast\s+(?:week|month|year|Monday|Tuesday|Wednesday|Thursday|Friday|Saturday|Sunday)\b/i,
|
|
8314
|
+
/\bon\s+(?:Monday|Tuesday|Wednesday|Thursday|Friday|Saturday|Sunday)\b/i,
|
|
8315
|
+
/\b(?:recently|earlier|this morning|this afternoon)\b/i
|
|
8316
|
+
];
|
|
8317
|
+
var VERB_EPISODE_SIGNALS = [
|
|
8318
|
+
/\bdeployed\b/i,
|
|
8319
|
+
/\bpushed\b/i,
|
|
8320
|
+
/\bfixed\b/i,
|
|
8321
|
+
/\bmerged\b/i,
|
|
8322
|
+
/\breported\b/i,
|
|
8323
|
+
/\bmentioned\b/i,
|
|
8324
|
+
/\bsaid\b/i,
|
|
8325
|
+
/\bhappened\b/i,
|
|
8326
|
+
/\bfailed\b/i,
|
|
8327
|
+
/\bcompleted\b/i,
|
|
8328
|
+
/\bshipped\b/i
|
|
8329
|
+
];
|
|
8330
|
+
var NOTE_CATEGORIES = /* @__PURE__ */ new Set([
|
|
8331
|
+
"preference",
|
|
8332
|
+
"constraint",
|
|
8333
|
+
"goal",
|
|
8334
|
+
"habit",
|
|
8335
|
+
"policy",
|
|
8336
|
+
"standard",
|
|
8337
|
+
"belief",
|
|
8338
|
+
"decision",
|
|
8339
|
+
"principle",
|
|
8340
|
+
// durable operating rules emitted by extraction
|
|
8341
|
+
"commitment",
|
|
8342
|
+
// deadlines/promises — stable obligations
|
|
8343
|
+
"relationship",
|
|
8344
|
+
// durable facts about people/entities
|
|
8345
|
+
"skill",
|
|
8346
|
+
// capabilities — stable knowledge
|
|
8347
|
+
"correction",
|
|
8348
|
+
// user corrections — durable override of prior belief
|
|
8349
|
+
"entity"
|
|
8350
|
+
// stable facts about people, projects, tools, etc.
|
|
8351
|
+
]);
|
|
8352
|
+
var EPISODE_CATEGORIES = /* @__PURE__ */ new Set(["event", "action", "observation", "issue", "bug", "incident", "moment"]);
|
|
8353
|
+
var NOTE_TAGS = /* @__PURE__ */ new Set(["preference", "constraint", "goal", "habit", "policy", "belief"]);
|
|
8354
|
+
var EPISODE_TAGS = /* @__PURE__ */ new Set(["bug", "fix", "deploy", "incident", "release", "merge", "event"]);
|
|
8355
|
+
function classifyMemoryKind(content, tags, category) {
|
|
8356
|
+
const lowerContent = content.toLowerCase();
|
|
8357
|
+
const lowerCategory = category.toLowerCase();
|
|
8358
|
+
for (const re of TEMPORAL_SIGNALS) {
|
|
8359
|
+
if (re.test(lowerContent)) return "episode";
|
|
8360
|
+
}
|
|
8361
|
+
if (NOTE_CATEGORIES.has(lowerCategory)) return "note";
|
|
8362
|
+
if (EPISODE_CATEGORIES.has(lowerCategory)) return "episode";
|
|
8363
|
+
let tagMatchesNote = false;
|
|
8364
|
+
let tagMatchesEpisode = false;
|
|
8365
|
+
for (const tag of tags) {
|
|
8366
|
+
const lowerTag = tag.toLowerCase();
|
|
8367
|
+
if (NOTE_TAGS.has(lowerTag)) tagMatchesNote = true;
|
|
8368
|
+
if (EPISODE_TAGS.has(lowerTag)) tagMatchesEpisode = true;
|
|
8369
|
+
}
|
|
8370
|
+
if (tagMatchesNote) return "note";
|
|
8371
|
+
if (tagMatchesEpisode) return "episode";
|
|
8372
|
+
for (const re of VERB_EPISODE_SIGNALS) {
|
|
8373
|
+
if (re.test(lowerContent)) return "episode";
|
|
8374
|
+
}
|
|
8375
|
+
for (const re of NOTE_SIGNALS) {
|
|
8376
|
+
if (re.test(lowerContent)) return "note";
|
|
8377
|
+
}
|
|
8378
|
+
return "episode";
|
|
8379
|
+
}
|
|
8380
|
+
|
|
8286
8381
|
// src/conversation-index/chunker.ts
|
|
8287
8382
|
function chunkTranscriptEntries(sessionKey, entries, opts) {
|
|
8288
8383
|
const maxChars = Math.max(500, opts.maxChars);
|
|
@@ -10099,6 +10194,7 @@ _Context: ${topQuestion.context}_`);
|
|
|
10099
10194
|
if (this.config.chunkingEnabled) {
|
|
10100
10195
|
const chunkResult = chunkContent(fact.content, chunkingConfig);
|
|
10101
10196
|
if (chunkResult.chunked && chunkResult.chunks.length > 1) {
|
|
10197
|
+
const memoryKind2 = this.config.episodeNoteModeEnabled ? classifyMemoryKind(fact.content, fact.tags ?? [], fact.category) : void 0;
|
|
10102
10198
|
const parentId = await storage.writeMemory(fact.category, fact.content, {
|
|
10103
10199
|
confidence: fact.confidence,
|
|
10104
10200
|
tags: [...fact.tags, "chunked"],
|
|
@@ -10107,7 +10203,8 @@ _Context: ${topQuestion.context}_`);
|
|
|
10107
10203
|
importance,
|
|
10108
10204
|
intentGoal: inferredIntent?.goal,
|
|
10109
10205
|
intentActionType: inferredIntent?.actionType,
|
|
10110
|
-
intentEntityTypes: inferredIntent?.entityTypes
|
|
10206
|
+
intentEntityTypes: inferredIntent?.entityTypes,
|
|
10207
|
+
memoryKind: memoryKind2
|
|
10111
10208
|
});
|
|
10112
10209
|
for (const chunk of chunkResult.chunks) {
|
|
10113
10210
|
const chunkImportance = scoreImportance(chunk.content, fact.category, fact.tags);
|
|
@@ -10125,7 +10222,8 @@ _Context: ${topQuestion.context}_`);
|
|
|
10125
10222
|
importance: chunkImportance,
|
|
10126
10223
|
intentGoal: inferredIntent?.goal,
|
|
10127
10224
|
intentActionType: inferredIntent?.actionType,
|
|
10128
|
-
intentEntityTypes: inferredIntent?.entityTypes
|
|
10225
|
+
intentEntityTypes: inferredIntent?.entityTypes,
|
|
10226
|
+
memoryKind: memoryKind2
|
|
10129
10227
|
}
|
|
10130
10228
|
);
|
|
10131
10229
|
}
|
|
@@ -10172,6 +10270,7 @@ _Context: ${topQuestion.context}_`);
|
|
|
10172
10270
|
links.push(...suggestedLinks);
|
|
10173
10271
|
}
|
|
10174
10272
|
}
|
|
10273
|
+
const memoryKind = this.config.episodeNoteModeEnabled ? classifyMemoryKind(fact.content, fact.tags ?? [], fact.category) : void 0;
|
|
10175
10274
|
const memoryId = await storage.writeMemory(fact.category, fact.content, {
|
|
10176
10275
|
confidence: fact.confidence,
|
|
10177
10276
|
tags: fact.tags,
|
|
@@ -10182,7 +10281,8 @@ _Context: ${topQuestion.context}_`);
|
|
|
10182
10281
|
links: links.length > 0 ? links : void 0,
|
|
10183
10282
|
intentGoal: inferredIntent?.goal,
|
|
10184
10283
|
intentActionType: inferredIntent?.actionType,
|
|
10185
|
-
intentEntityTypes: inferredIntent?.entityTypes
|
|
10284
|
+
intentEntityTypes: inferredIntent?.entityTypes,
|
|
10285
|
+
memoryKind
|
|
10186
10286
|
});
|
|
10187
10287
|
persistedIds.push(memoryId);
|
|
10188
10288
|
await this.indexPersistedMemory(storage, memoryId);
|