@mastra/memory 1.11.0 → 1.11.1-alpha.0
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/CHANGELOG.md +9 -0
- package/dist/{chunk-D4D6ZFBQ.js → chunk-2NZR2XHO.js} +29 -22
- package/dist/chunk-2NZR2XHO.js.map +1 -0
- package/dist/{chunk-VINRPDYQ.cjs → chunk-W2RTLXNQ.cjs} +29 -22
- package/dist/chunk-W2RTLXNQ.cjs.map +1 -0
- package/dist/docs/SKILL.md +1 -1
- package/dist/docs/assets/SOURCE_MAP.json +43 -43
- package/dist/index.cjs +11 -11
- package/dist/index.js +4 -4
- package/dist/{observational-memory-FATH657E.cjs → observational-memory-JCPPBSVG.cjs} +26 -26
- package/dist/{observational-memory-FATH657E.cjs.map → observational-memory-JCPPBSVG.cjs.map} +1 -1
- package/dist/{observational-memory-SN7GKMHZ.js → observational-memory-SASGM6OW.js} +3 -3
- package/dist/{observational-memory-SN7GKMHZ.js.map → observational-memory-SASGM6OW.js.map} +1 -1
- package/dist/processors/index.cjs +24 -24
- package/dist/processors/index.js +1 -1
- package/dist/processors/observational-memory/observation-groups.d.ts +2 -2
- package/dist/processors/observational-memory/observation-groups.d.ts.map +1 -1
- package/dist/processors/observational-memory/reflector-agent.d.ts.map +1 -1
- package/package.json +5 -5
- package/dist/chunk-D4D6ZFBQ.js.map +0 -1
- package/dist/chunk-VINRPDYQ.cjs.map +0 -1
|
@@ -724,10 +724,10 @@ function stripReflectionGroupMetadata(body) {
|
|
|
724
724
|
function generateAnchorId() {
|
|
725
725
|
return crypto$1.randomBytes(8).toString("hex");
|
|
726
726
|
}
|
|
727
|
-
function wrapInObservationGroup(observations, range, id = generateAnchorId(),
|
|
727
|
+
function wrapInObservationGroup(observations, range, id = generateAnchorId(), _sourceGroupIds, kind) {
|
|
728
728
|
const content = observations.trim();
|
|
729
|
-
const
|
|
730
|
-
return `<observation-group id="${id}" range="${range}"${
|
|
729
|
+
const kindAttr = kind ? ` kind="${kind}"` : "";
|
|
730
|
+
return `<observation-group id="${id}" range="${range}"${kindAttr}>
|
|
731
731
|
${content}
|
|
732
732
|
</observation-group>`;
|
|
733
733
|
}
|
|
@@ -747,8 +747,8 @@ function parseObservationGroups(observations) {
|
|
|
747
747
|
groups.push({
|
|
748
748
|
id,
|
|
749
749
|
range,
|
|
750
|
-
|
|
751
|
-
|
|
750
|
+
kind: attributes.kind,
|
|
751
|
+
content: match[2].trim()
|
|
752
752
|
});
|
|
753
753
|
}
|
|
754
754
|
return groups;
|
|
@@ -759,12 +759,22 @@ function stripObservationGroups(observations) {
|
|
|
759
759
|
}
|
|
760
760
|
return observations.replace(OBSERVATION_GROUP_PATTERN, (_match, _attributes, content) => content.trim()).replace(/\n{3,}/g, "\n\n").trim();
|
|
761
761
|
}
|
|
762
|
+
function getRangeSegments(range) {
|
|
763
|
+
return range.split(",").map((segment) => segment.trim()).filter(Boolean);
|
|
764
|
+
}
|
|
762
765
|
function combineObservationGroupRanges(groups) {
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
766
|
+
const segments = groups.flatMap((group) => getRangeSegments(group.range));
|
|
767
|
+
if (segments.length === 0) {
|
|
768
|
+
return "";
|
|
769
|
+
}
|
|
770
|
+
const firstSegment = segments[0];
|
|
771
|
+
const lastSegment = segments[segments.length - 1];
|
|
772
|
+
const firstStart = firstSegment?.split(":")[0]?.trim();
|
|
773
|
+
const lastEnd = lastSegment?.split(":").at(-1)?.trim();
|
|
774
|
+
if (firstStart && lastEnd) {
|
|
775
|
+
return `${firstStart}:${lastEnd}`;
|
|
776
|
+
}
|
|
777
|
+
return Array.from(new Set(segments)).join(",");
|
|
768
778
|
}
|
|
769
779
|
function renderObservationGroupsForReflection(observations) {
|
|
770
780
|
const groups = parseObservationGroups(observations);
|
|
@@ -801,15 +811,12 @@ function deriveObservationGroupProvenance(content, groups) {
|
|
|
801
811
|
});
|
|
802
812
|
const fallbackGroup = groups[Math.min(index, groups.length - 1)];
|
|
803
813
|
const resolvedGroups = matchingGroups.length > 0 ? matchingGroups : fallbackGroup ? [fallbackGroup] : [];
|
|
804
|
-
const sourceGroupIds = Array.from(
|
|
805
|
-
new Set(resolvedGroups.flatMap((group) => [group.id, ...group.sourceGroupIds ?? []]))
|
|
806
|
-
);
|
|
807
814
|
const canonicalGroupId = getCanonicalGroupId(section.heading, index);
|
|
808
815
|
return {
|
|
809
816
|
id: canonicalGroupId,
|
|
810
817
|
range: combineObservationGroupRanges(resolvedGroups),
|
|
811
|
-
|
|
812
|
-
|
|
818
|
+
kind: "reflection",
|
|
819
|
+
content: section.body
|
|
813
820
|
};
|
|
814
821
|
});
|
|
815
822
|
}
|
|
@@ -824,13 +831,14 @@ function reconcileObservationGroupsFromReflection(content, sourceObservations) {
|
|
|
824
831
|
}
|
|
825
832
|
const derivedGroups = deriveObservationGroupProvenance(normalizedContent, sourceGroups);
|
|
826
833
|
if (derivedGroups.length > 0) {
|
|
827
|
-
return derivedGroups.map((group) => wrapInObservationGroup(group.content, group.range, group.id, group.
|
|
834
|
+
return derivedGroups.map((group) => wrapInObservationGroup(group.content, group.range, group.id, void 0, group.kind)).join("\n\n");
|
|
828
835
|
}
|
|
829
836
|
return wrapInObservationGroup(
|
|
830
837
|
normalizedContent,
|
|
831
838
|
combineObservationGroupRanges(sourceGroups),
|
|
832
839
|
generateAnchorId(),
|
|
833
|
-
|
|
840
|
+
void 0,
|
|
841
|
+
"reflection"
|
|
834
842
|
);
|
|
835
843
|
}
|
|
836
844
|
|
|
@@ -3828,11 +3836,10 @@ Aim for a 2/10 detail level. Fewer, more generic observations are better than ma
|
|
|
3828
3836
|
};
|
|
3829
3837
|
function buildReflectorPrompt(observations, manualPrompt, compressionLevel, skipContinuationHints) {
|
|
3830
3838
|
const level = typeof compressionLevel === "number" ? compressionLevel : compressionLevel ? 1 : 0;
|
|
3831
|
-
const reflectionView =
|
|
3832
|
-
const anchoredObservations = injectAnchorIds(reflectionView);
|
|
3839
|
+
const reflectionView = stripObservationGroups(observations);
|
|
3833
3840
|
let prompt = `## OBSERVATIONS TO REFLECT ON
|
|
3834
3841
|
|
|
3835
|
-
${
|
|
3842
|
+
${reflectionView}
|
|
3836
3843
|
|
|
3837
3844
|
---
|
|
3838
3845
|
|
|
@@ -8450,5 +8457,5 @@ exports.stripEphemeralAnchorIds = stripEphemeralAnchorIds;
|
|
|
8450
8457
|
exports.stripObservationGroups = stripObservationGroups;
|
|
8451
8458
|
exports.truncateStringByTokens = truncateStringByTokens;
|
|
8452
8459
|
exports.wrapInObservationGroup = wrapInObservationGroup;
|
|
8453
|
-
//# sourceMappingURL=chunk-
|
|
8454
|
-
//# sourceMappingURL=chunk-
|
|
8460
|
+
//# sourceMappingURL=chunk-W2RTLXNQ.cjs.map
|
|
8461
|
+
//# sourceMappingURL=chunk-W2RTLXNQ.cjs.map
|