@mastra/memory 1.41.1-alpha.2 → 1.41.1-alpha.4
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/docs/SKILL.md +1 -1
- package/dist/docs/assets/SOURCE_MAP.json +67 -67
- package/dist/docs/references/docs-memory-semantic-recall.md +2 -0
- package/dist/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/dist/processors/index.cjs +1 -1
- package/dist/processors/index.js +1 -1
- package/dist/processors/observational-memory/observation-groups.d.ts +8 -0
- package/dist/processors/observational-memory/observation-groups.d.ts.map +1 -1
- package/dist/processors/observational-memory/reflector-runner.d.ts.map +1 -1
- package/dist/{src-DrWCcSnW.cjs → src-DvkS93hU.cjs} +27 -2
- package/dist/{src-DrWCcSnW.cjs.map → src-DvkS93hU.cjs.map} +1 -1
- package/dist/{src-wMl-5Ms8.js → src-KIKQ7ztT.js} +27 -2
- package/dist/{src-wMl-5Ms8.js.map → src-KIKQ7ztT.js.map} +1 -1
- package/package.json +4 -4
|
@@ -30226,6 +30226,31 @@ function wrapInObservationGroup(observations, range, id = generateAnchorId(), _s
|
|
|
30226
30226
|
const content = observations.trim();
|
|
30227
30227
|
return `<observation-group id="${id}" range="${range}"${kind ? ` kind="${kind}"` : ""}>\n${content}\n</observation-group>`;
|
|
30228
30228
|
}
|
|
30229
|
+
function isObservationGroupOpeningLine(line) {
|
|
30230
|
+
const trimmed = line.trimStart();
|
|
30231
|
+
return trimmed.startsWith(OBSERVATION_GROUP_OPEN) && /\s/.test(trimmed[18] ?? "");
|
|
30232
|
+
}
|
|
30233
|
+
/**
|
|
30234
|
+
* Moves a cut of `cut` leading lines so it never splits an observation group. A cut inside a group
|
|
30235
|
+
* moves back to just before the group's opening tag (and the blank lines that separate it from the
|
|
30236
|
+
* previous group). When nothing precedes that group, the cut moves forward to just after its closing
|
|
30237
|
+
* tag instead, so the whole group is cut. A cut outside every group, and observations without group
|
|
30238
|
+
* tags, are returned unchanged.
|
|
30239
|
+
*/
|
|
30240
|
+
function alignLineCutToObservationGroups(lines, cut) {
|
|
30241
|
+
let openingLine = -1;
|
|
30242
|
+
for (let i = 0; i < cut; i++) {
|
|
30243
|
+
const line = lines[i];
|
|
30244
|
+
if (isObservationGroupOpeningLine(line)) openingLine = i;
|
|
30245
|
+
else if (line.trim() === OBSERVATION_GROUP_CLOSE) openingLine = -1;
|
|
30246
|
+
}
|
|
30247
|
+
if (openingLine === -1) return cut;
|
|
30248
|
+
let before = openingLine;
|
|
30249
|
+
while (before > 0 && lines[before - 1].trim() === "") before--;
|
|
30250
|
+
if (before > 0) return before;
|
|
30251
|
+
for (let i = cut; i < lines.length; i++) if (lines[i].trim() === OBSERVATION_GROUP_CLOSE) return i + 1;
|
|
30252
|
+
return cut;
|
|
30253
|
+
}
|
|
30229
30254
|
function parseObservationGroups(observations) {
|
|
30230
30255
|
if (!observations) return [];
|
|
30231
30256
|
const groups = [];
|
|
@@ -36049,7 +36074,7 @@ var ReflectorRunner = class {
|
|
|
36049
36074
|
const totalLines = allLines.length;
|
|
36050
36075
|
const avgTokensPerLine = totalLines > 0 ? observationTokens / totalLines : 0;
|
|
36051
36076
|
const activationPointTokens = reflectThreshold * bufferActivation;
|
|
36052
|
-
const linesToReflect = avgTokensPerLine > 0 ? Math.min(Math.floor(activationPointTokens / avgTokensPerLine), totalLines) : totalLines;
|
|
36077
|
+
const linesToReflect = alignLineCutToObservationGroups(allLines, avgTokensPerLine > 0 ? Math.min(Math.floor(activationPointTokens / avgTokensPerLine), totalLines) : totalLines);
|
|
36053
36078
|
const hookContext = {
|
|
36054
36079
|
threadId: currentRecord.threadId ?? void 0,
|
|
36055
36080
|
resourceId: currentRecord.resourceId ?? void 0,
|
|
@@ -42473,4 +42498,4 @@ Notes:
|
|
|
42473
42498
|
};
|
|
42474
42499
|
export { summarizeConversation as A, injectAnchorIds as B, wrapInObservationGroup as C, WorkingMemoryExtractor as D, Subconscious as E, extractCurrentTask as F, OBSERVATION_CONTEXT_INSTRUCTIONS as G, stripEphemeralAnchorIds as H, formatMessagesForObserver as I, OBSERVATION_CONTINUATION_HINT as J, OBSERVATION_CONTEXT_PROMPT as K, hasCurrentTaskSection as L, OBSERVER_SYSTEM_PROMPT as M, buildObserverPrompt as N, deepMergeWorkingMemory as O, buildObserverSystemPrompt as P, optimizeObservationsForContext as R, stripObservationGroups as S, StaleKnowledgeSemanticIndexError as T, Extractor as U, parseAnchorId as V, OBSERVATIONAL_MEMORY_DEFAULTS as W, getObservationContextPrompt as Y, combineObservationGroupRanges as _, extractWorkingMemoryContent as a, reconcileObservationGroupsFromReflection as b, getObservationsAsOf as c, AUTO_MODEL_BY_PROVIDER as d, resolveAutoModelId as f, ModelByInputTokens as g, WorkingMemoryStateProcessor as h, WorkingMemory as i, TokenCounter as j, SUMMARIZE_THREAD_DEFAULTS as k, ObservationalMemoryProcessor as l, WORKING_MEMORY_STATE_PROCESSOR_ID as m, MessageHistory$1 as n, extractWorkingMemoryTags as o, WORKING_MEMORY_STATE_ID as p, OBSERVATION_CONTEXT_PROMPT_THREAD as q, SemanticRecall as r, removeWorkingMemoryTags as s, Memory as t, ObservationalMemory as u, deriveObservationGroupProvenance as v, KnowledgeSemanticIndexCoordinator as w, renderObservationGroupsForReflection as x, parseObservationGroups as y, parseObserverOutput as z };
|
|
42475
42500
|
|
|
42476
|
-
//# sourceMappingURL=src-
|
|
42501
|
+
//# sourceMappingURL=src-KIKQ7ztT.js.map
|