@mastra/server 1.18.0-alpha.5 → 1.18.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 +39 -0
- package/dist/{chunk-SDKSW2BQ.js → chunk-FTGC7KXM.js} +6 -6
- package/dist/{chunk-SDKSW2BQ.js.map → chunk-FTGC7KXM.js.map} +1 -1
- package/dist/{chunk-GDWCOWNR.cjs → chunk-MS7GNCN3.cjs} +19 -19
- package/dist/{chunk-GDWCOWNR.cjs.map → chunk-MS7GNCN3.cjs.map} +1 -1
- package/dist/{chunk-HUAXEKGI.cjs → chunk-POOOTRUM.cjs} +29 -22
- package/dist/chunk-POOOTRUM.cjs.map +1 -0
- package/dist/{chunk-YUTITKH2.js → chunk-U5XW3WOS.js} +29 -22
- package/dist/chunk-U5XW3WOS.js.map +1 -0
- package/dist/docs/SKILL.md +1 -1
- package/dist/docs/assets/SOURCE_MAP.json +1 -1
- package/dist/{observational-memory-SN7GKMHZ-WOK4TGDH.cjs → observational-memory-SASGM6OW-2G3RBRTW.cjs} +26 -26
- package/dist/{observational-memory-SN7GKMHZ-WOK4TGDH.cjs.map → observational-memory-SASGM6OW-2G3RBRTW.cjs.map} +1 -1
- package/dist/{observational-memory-SN7GKMHZ-IWVBFBS6.js → observational-memory-SASGM6OW-3S6D4TAF.js} +3 -3
- package/dist/{observational-memory-SN7GKMHZ-IWVBFBS6.js.map → observational-memory-SASGM6OW-3S6D4TAF.js.map} +1 -1
- package/dist/server/handlers/agent-builder.cjs +16 -16
- package/dist/server/handlers/agent-builder.js +1 -1
- package/dist/server/handlers.cjs +2 -2
- package/dist/server/handlers.js +1 -1
- package/dist/server/server-adapter/index.cjs +16 -16
- package/dist/server/server-adapter/index.js +1 -1
- package/package.json +8 -8
- package/dist/chunk-HUAXEKGI.cjs.map +0 -1
- package/dist/chunk-YUTITKH2.js.map +0 -1
|
@@ -1730,10 +1730,10 @@ function stripReflectionGroupMetadata(body) {
|
|
|
1730
1730
|
function generateAnchorId() {
|
|
1731
1731
|
return randomBytes(8).toString("hex");
|
|
1732
1732
|
}
|
|
1733
|
-
function wrapInObservationGroup(observations, range, id = generateAnchorId(),
|
|
1733
|
+
function wrapInObservationGroup(observations, range, id = generateAnchorId(), _sourceGroupIds, kind) {
|
|
1734
1734
|
const content = observations.trim();
|
|
1735
|
-
const
|
|
1736
|
-
return `<observation-group id="${id}" range="${range}"${
|
|
1735
|
+
const kindAttr = kind ? ` kind="${kind}"` : "";
|
|
1736
|
+
return `<observation-group id="${id}" range="${range}"${kindAttr}>
|
|
1737
1737
|
${content}
|
|
1738
1738
|
</observation-group>`;
|
|
1739
1739
|
}
|
|
@@ -1753,8 +1753,8 @@ function parseObservationGroups(observations) {
|
|
|
1753
1753
|
groups.push({
|
|
1754
1754
|
id,
|
|
1755
1755
|
range,
|
|
1756
|
-
|
|
1757
|
-
|
|
1756
|
+
kind: attributes.kind,
|
|
1757
|
+
content: match[2].trim()
|
|
1758
1758
|
});
|
|
1759
1759
|
}
|
|
1760
1760
|
return groups;
|
|
@@ -1765,12 +1765,22 @@ function stripObservationGroups(observations) {
|
|
|
1765
1765
|
}
|
|
1766
1766
|
return observations.replace(OBSERVATION_GROUP_PATTERN, (_match, _attributes, content) => content.trim()).replace(/\n{3,}/g, "\n\n").trim();
|
|
1767
1767
|
}
|
|
1768
|
+
function getRangeSegments(range) {
|
|
1769
|
+
return range.split(",").map((segment) => segment.trim()).filter(Boolean);
|
|
1770
|
+
}
|
|
1768
1771
|
function combineObservationGroupRanges(groups) {
|
|
1769
|
-
|
|
1770
|
-
|
|
1771
|
-
|
|
1772
|
-
|
|
1773
|
-
|
|
1772
|
+
const segments = groups.flatMap((group) => getRangeSegments(group.range));
|
|
1773
|
+
if (segments.length === 0) {
|
|
1774
|
+
return "";
|
|
1775
|
+
}
|
|
1776
|
+
const firstSegment = segments[0];
|
|
1777
|
+
const lastSegment = segments[segments.length - 1];
|
|
1778
|
+
const firstStart = firstSegment?.split(":")[0]?.trim();
|
|
1779
|
+
const lastEnd = lastSegment?.split(":").at(-1)?.trim();
|
|
1780
|
+
if (firstStart && lastEnd) {
|
|
1781
|
+
return `${firstStart}:${lastEnd}`;
|
|
1782
|
+
}
|
|
1783
|
+
return Array.from(new Set(segments)).join(",");
|
|
1774
1784
|
}
|
|
1775
1785
|
function renderObservationGroupsForReflection(observations) {
|
|
1776
1786
|
const groups = parseObservationGroups(observations);
|
|
@@ -1807,15 +1817,12 @@ function deriveObservationGroupProvenance(content, groups) {
|
|
|
1807
1817
|
});
|
|
1808
1818
|
const fallbackGroup = groups[Math.min(index, groups.length - 1)];
|
|
1809
1819
|
const resolvedGroups = matchingGroups.length > 0 ? matchingGroups : fallbackGroup ? [fallbackGroup] : [];
|
|
1810
|
-
const sourceGroupIds = Array.from(
|
|
1811
|
-
new Set(resolvedGroups.flatMap((group) => [group.id, ...group.sourceGroupIds ?? []]))
|
|
1812
|
-
);
|
|
1813
1820
|
const canonicalGroupId = getCanonicalGroupId(section.heading, index);
|
|
1814
1821
|
return {
|
|
1815
1822
|
id: canonicalGroupId,
|
|
1816
1823
|
range: combineObservationGroupRanges(resolvedGroups),
|
|
1817
|
-
|
|
1818
|
-
|
|
1824
|
+
kind: "reflection",
|
|
1825
|
+
content: section.body
|
|
1819
1826
|
};
|
|
1820
1827
|
});
|
|
1821
1828
|
}
|
|
@@ -1830,13 +1837,14 @@ function reconcileObservationGroupsFromReflection(content, sourceObservations) {
|
|
|
1830
1837
|
}
|
|
1831
1838
|
const derivedGroups = deriveObservationGroupProvenance(normalizedContent, sourceGroups);
|
|
1832
1839
|
if (derivedGroups.length > 0) {
|
|
1833
|
-
return derivedGroups.map((group) => wrapInObservationGroup(group.content, group.range, group.id, group.
|
|
1840
|
+
return derivedGroups.map((group) => wrapInObservationGroup(group.content, group.range, group.id, void 0, group.kind)).join("\n\n");
|
|
1834
1841
|
}
|
|
1835
1842
|
return wrapInObservationGroup(
|
|
1836
1843
|
normalizedContent,
|
|
1837
1844
|
combineObservationGroupRanges(sourceGroups),
|
|
1838
1845
|
generateAnchorId(),
|
|
1839
|
-
|
|
1846
|
+
void 0,
|
|
1847
|
+
"reflection"
|
|
1840
1848
|
);
|
|
1841
1849
|
}
|
|
1842
1850
|
function getMaxThreshold(threshold) {
|
|
@@ -4816,11 +4824,10 @@ Aim for a 2/10 detail level. Fewer, more generic observations are better than ma
|
|
|
4816
4824
|
};
|
|
4817
4825
|
function buildReflectorPrompt(observations, manualPrompt, compressionLevel, skipContinuationHints) {
|
|
4818
4826
|
const level = typeof compressionLevel === "number" ? compressionLevel : compressionLevel ? 1 : 0;
|
|
4819
|
-
const reflectionView =
|
|
4820
|
-
const anchoredObservations = injectAnchorIds(reflectionView);
|
|
4827
|
+
const reflectionView = stripObservationGroups(observations);
|
|
4821
4828
|
let prompt = `## OBSERVATIONS TO REFLECT ON
|
|
4822
4829
|
|
|
4823
|
-
${
|
|
4830
|
+
${reflectionView}
|
|
4824
4831
|
|
|
4825
4832
|
---
|
|
4826
4833
|
|
|
@@ -9405,5 +9412,5 @@ function getObservationsAsOf(activeObservations, asOf) {
|
|
|
9405
9412
|
}
|
|
9406
9413
|
|
|
9407
9414
|
export { ModelByInputTokens, OBSERVER_SYSTEM_PROMPT, ObservationalMemory, ObservationalMemoryProcessor, TokenCounter, buildObserverPrompt, buildObserverSystemPrompt, combineObservationGroupRanges, deriveObservationGroupProvenance, e, estimateTokenCount, extractCurrentTask, formatMessagesForObserver, formatToolResultForObserver, getObservationsAsOf, hasCurrentTaskSection, injectAnchorIds, optimizeObservationsForContext, parseAnchorId, parseObservationGroups, parseObserverOutput, reconcileObservationGroupsFromReflection, renderObservationGroupsForReflection, resolveToolResultValue, stripEphemeralAnchorIds, stripObservationGroups, truncateStringByTokens, wrapInObservationGroup };
|
|
9408
|
-
//# sourceMappingURL=chunk-
|
|
9409
|
-
//# sourceMappingURL=chunk-
|
|
9415
|
+
//# sourceMappingURL=chunk-U5XW3WOS.js.map
|
|
9416
|
+
//# sourceMappingURL=chunk-U5XW3WOS.js.map
|