@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
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
# @mastra/memory
|
|
2
2
|
|
|
3
|
+
## 1.11.1-alpha.0
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Fixed reflected observation groups so their metadata stays compact and marks reflection-derived content. ([#14791](https://github.com/mastra-ai/mastra/pull/14791))
|
|
8
|
+
|
|
9
|
+
- Updated dependencies [[`180aaaf`](https://github.com/mastra-ai/mastra/commit/180aaaf4d0903d33a49bc72de2d40ca69a5bc599)]:
|
|
10
|
+
- @mastra/core@1.18.1-alpha.0
|
|
11
|
+
|
|
3
12
|
## 1.11.0
|
|
4
13
|
|
|
5
14
|
### Minor Changes
|
|
@@ -717,10 +717,10 @@ function stripReflectionGroupMetadata(body) {
|
|
|
717
717
|
function generateAnchorId() {
|
|
718
718
|
return randomBytes(8).toString("hex");
|
|
719
719
|
}
|
|
720
|
-
function wrapInObservationGroup(observations, range, id = generateAnchorId(),
|
|
720
|
+
function wrapInObservationGroup(observations, range, id = generateAnchorId(), _sourceGroupIds, kind) {
|
|
721
721
|
const content = observations.trim();
|
|
722
|
-
const
|
|
723
|
-
return `<observation-group id="${id}" range="${range}"${
|
|
722
|
+
const kindAttr = kind ? ` kind="${kind}"` : "";
|
|
723
|
+
return `<observation-group id="${id}" range="${range}"${kindAttr}>
|
|
724
724
|
${content}
|
|
725
725
|
</observation-group>`;
|
|
726
726
|
}
|
|
@@ -740,8 +740,8 @@ function parseObservationGroups(observations) {
|
|
|
740
740
|
groups.push({
|
|
741
741
|
id,
|
|
742
742
|
range,
|
|
743
|
-
|
|
744
|
-
|
|
743
|
+
kind: attributes.kind,
|
|
744
|
+
content: match[2].trim()
|
|
745
745
|
});
|
|
746
746
|
}
|
|
747
747
|
return groups;
|
|
@@ -752,12 +752,22 @@ function stripObservationGroups(observations) {
|
|
|
752
752
|
}
|
|
753
753
|
return observations.replace(OBSERVATION_GROUP_PATTERN, (_match, _attributes, content) => content.trim()).replace(/\n{3,}/g, "\n\n").trim();
|
|
754
754
|
}
|
|
755
|
+
function getRangeSegments(range) {
|
|
756
|
+
return range.split(",").map((segment) => segment.trim()).filter(Boolean);
|
|
757
|
+
}
|
|
755
758
|
function combineObservationGroupRanges(groups) {
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
759
|
+
const segments = groups.flatMap((group) => getRangeSegments(group.range));
|
|
760
|
+
if (segments.length === 0) {
|
|
761
|
+
return "";
|
|
762
|
+
}
|
|
763
|
+
const firstSegment = segments[0];
|
|
764
|
+
const lastSegment = segments[segments.length - 1];
|
|
765
|
+
const firstStart = firstSegment?.split(":")[0]?.trim();
|
|
766
|
+
const lastEnd = lastSegment?.split(":").at(-1)?.trim();
|
|
767
|
+
if (firstStart && lastEnd) {
|
|
768
|
+
return `${firstStart}:${lastEnd}`;
|
|
769
|
+
}
|
|
770
|
+
return Array.from(new Set(segments)).join(",");
|
|
761
771
|
}
|
|
762
772
|
function renderObservationGroupsForReflection(observations) {
|
|
763
773
|
const groups = parseObservationGroups(observations);
|
|
@@ -794,15 +804,12 @@ function deriveObservationGroupProvenance(content, groups) {
|
|
|
794
804
|
});
|
|
795
805
|
const fallbackGroup = groups[Math.min(index, groups.length - 1)];
|
|
796
806
|
const resolvedGroups = matchingGroups.length > 0 ? matchingGroups : fallbackGroup ? [fallbackGroup] : [];
|
|
797
|
-
const sourceGroupIds = Array.from(
|
|
798
|
-
new Set(resolvedGroups.flatMap((group) => [group.id, ...group.sourceGroupIds ?? []]))
|
|
799
|
-
);
|
|
800
807
|
const canonicalGroupId = getCanonicalGroupId(section.heading, index);
|
|
801
808
|
return {
|
|
802
809
|
id: canonicalGroupId,
|
|
803
810
|
range: combineObservationGroupRanges(resolvedGroups),
|
|
804
|
-
|
|
805
|
-
|
|
811
|
+
kind: "reflection",
|
|
812
|
+
content: section.body
|
|
806
813
|
};
|
|
807
814
|
});
|
|
808
815
|
}
|
|
@@ -817,13 +824,14 @@ function reconcileObservationGroupsFromReflection(content, sourceObservations) {
|
|
|
817
824
|
}
|
|
818
825
|
const derivedGroups = deriveObservationGroupProvenance(normalizedContent, sourceGroups);
|
|
819
826
|
if (derivedGroups.length > 0) {
|
|
820
|
-
return derivedGroups.map((group) => wrapInObservationGroup(group.content, group.range, group.id, group.
|
|
827
|
+
return derivedGroups.map((group) => wrapInObservationGroup(group.content, group.range, group.id, void 0, group.kind)).join("\n\n");
|
|
821
828
|
}
|
|
822
829
|
return wrapInObservationGroup(
|
|
823
830
|
normalizedContent,
|
|
824
831
|
combineObservationGroupRanges(sourceGroups),
|
|
825
832
|
generateAnchorId(),
|
|
826
|
-
|
|
833
|
+
void 0,
|
|
834
|
+
"reflection"
|
|
827
835
|
);
|
|
828
836
|
}
|
|
829
837
|
|
|
@@ -3821,11 +3829,10 @@ Aim for a 2/10 detail level. Fewer, more generic observations are better than ma
|
|
|
3821
3829
|
};
|
|
3822
3830
|
function buildReflectorPrompt(observations, manualPrompt, compressionLevel, skipContinuationHints) {
|
|
3823
3831
|
const level = typeof compressionLevel === "number" ? compressionLevel : compressionLevel ? 1 : 0;
|
|
3824
|
-
const reflectionView =
|
|
3825
|
-
const anchoredObservations = injectAnchorIds(reflectionView);
|
|
3832
|
+
const reflectionView = stripObservationGroups(observations);
|
|
3826
3833
|
let prompt = `## OBSERVATIONS TO REFLECT ON
|
|
3827
3834
|
|
|
3828
|
-
${
|
|
3835
|
+
${reflectionView}
|
|
3829
3836
|
|
|
3830
3837
|
---
|
|
3831
3838
|
|
|
@@ -8418,5 +8425,5 @@ function getObservationsAsOf(activeObservations, asOf) {
|
|
|
8418
8425
|
}
|
|
8419
8426
|
|
|
8420
8427
|
export { ModelByInputTokens, OBSERVER_SYSTEM_PROMPT, ObservationalMemory, ObservationalMemoryProcessor, TokenCounter, buildObserverPrompt, buildObserverSystemPrompt, combineObservationGroupRanges, deriveObservationGroupProvenance, extractCurrentTask, formatMessagesForObserver, formatToolResultForObserver, getObservationsAsOf, hasCurrentTaskSection, injectAnchorIds, optimizeObservationsForContext, parseAnchorId, parseObservationGroups, parseObserverOutput, reconcileObservationGroupsFromReflection, renderObservationGroupsForReflection, resolveToolResultValue, stripEphemeralAnchorIds, stripObservationGroups, truncateStringByTokens, wrapInObservationGroup };
|
|
8421
|
-
//# sourceMappingURL=chunk-
|
|
8422
|
-
//# sourceMappingURL=chunk-
|
|
8428
|
+
//# sourceMappingURL=chunk-2NZR2XHO.js.map
|
|
8429
|
+
//# sourceMappingURL=chunk-2NZR2XHO.js.map
|