@mastra/memory 1.12.1 → 1.13.0-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 +20 -0
- package/dist/{chunk-HLGFIN4J.cjs → chunk-O3KNDDJV.cjs} +27 -6
- package/dist/chunk-O3KNDDJV.cjs.map +1 -0
- package/dist/{chunk-DDQHE4NV.js → chunk-ZVRY34YB.js} +27 -6
- package/dist/chunk-ZVRY34YB.js.map +1 -0
- package/dist/docs/SKILL.md +1 -1
- package/dist/docs/assets/SOURCE_MAP.json +27 -27
- package/dist/index.cjs +12 -12
- package/dist/index.js +4 -4
- package/dist/{observational-memory-34W4S4I5.cjs → observational-memory-HBQCXPBU.cjs} +26 -26
- package/dist/{observational-memory-34W4S4I5.cjs.map → observational-memory-HBQCXPBU.cjs.map} +1 -1
- package/dist/{observational-memory-B25SASRW.js → observational-memory-WOEVNCG4.js} +3 -3
- package/dist/{observational-memory-B25SASRW.js.map → observational-memory-WOEVNCG4.js.map} +1 -1
- package/dist/processors/index.cjs +24 -24
- package/dist/processors/index.js +1 -1
- package/dist/processors/observational-memory/observational-memory.d.ts +16 -1
- package/dist/processors/observational-memory/observational-memory.d.ts.map +1 -1
- package/package.json +3 -3
- package/dist/chunk-DDQHE4NV.js.map +0 -1
- package/dist/chunk-HLGFIN4J.cjs.map +0 -1
|
@@ -6708,7 +6708,7 @@ ${suggestedResponse}
|
|
|
6708
6708
|
* In resource scope mode, loads messages for the entire resource (all threads).
|
|
6709
6709
|
* In thread scope mode, loads messages for just the current thread.
|
|
6710
6710
|
*/
|
|
6711
|
-
async
|
|
6711
|
+
async loadMessagesFromStorage(threadId, resourceId, lastObservedAt) {
|
|
6712
6712
|
const startDate = lastObservedAt ? new Date(lastObservedAt.getTime() + 1) : void 0;
|
|
6713
6713
|
let result;
|
|
6714
6714
|
if (this.scope === "resource" && resourceId) {
|
|
@@ -7396,7 +7396,7 @@ ${grouped}` : grouped;
|
|
|
7396
7396
|
if (opts.messages) {
|
|
7397
7397
|
unobservedMessages = this.getUnobservedMessages(opts.messages, record);
|
|
7398
7398
|
} else {
|
|
7399
|
-
const rawMessages = await this.
|
|
7399
|
+
const rawMessages = await this.loadMessagesFromStorage(
|
|
7400
7400
|
threadId,
|
|
7401
7401
|
resourceId,
|
|
7402
7402
|
record.lastObservedAt ? new Date(record.lastObservedAt) : void 0
|
|
@@ -7509,6 +7509,27 @@ ${grouped}` : grouped;
|
|
|
7509
7509
|
const record = await this.getOrCreateRecord(threadId, resourceId);
|
|
7510
7510
|
return this.getUnobservedMessages(messages, record);
|
|
7511
7511
|
}
|
|
7512
|
+
/**
|
|
7513
|
+
* Load unobserved messages from storage for a thread/resource.
|
|
7514
|
+
*
|
|
7515
|
+
* Fetches the OM record, queries storage for messages after the
|
|
7516
|
+
* lastObservedAt cursor, then applies part-level filtering so
|
|
7517
|
+
* partially-observed messages only include their unobserved parts.
|
|
7518
|
+
*
|
|
7519
|
+
* Use this when you need to load stored conversation history that
|
|
7520
|
+
* hasn't been observed yet (e.g. in a stateless gateway proxy that
|
|
7521
|
+
* only receives the latest message from the HTTP request).
|
|
7522
|
+
*/
|
|
7523
|
+
async loadUnobservedMessages(opts) {
|
|
7524
|
+
const { threadId, resourceId } = opts;
|
|
7525
|
+
const record = await this.getOrCreateRecord(threadId, resourceId);
|
|
7526
|
+
const rawMessages = await this.loadMessagesFromStorage(
|
|
7527
|
+
threadId,
|
|
7528
|
+
resourceId,
|
|
7529
|
+
record.lastObservedAt ? new Date(record.lastObservedAt) : void 0
|
|
7530
|
+
);
|
|
7531
|
+
return this.getUnobservedMessages(rawMessages, record);
|
|
7532
|
+
}
|
|
7512
7533
|
/**
|
|
7513
7534
|
* Create a buffered observation chunk without merging into active observations.
|
|
7514
7535
|
*
|
|
@@ -7570,7 +7591,7 @@ ${grouped}` : grouped;
|
|
|
7570
7591
|
if (opts.messages) {
|
|
7571
7592
|
candidateMessages = this.getUnobservedMessages(opts.messages, record, { excludeBuffered: true });
|
|
7572
7593
|
} else {
|
|
7573
|
-
const rawMessages = await this.
|
|
7594
|
+
const rawMessages = await this.loadMessagesFromStorage(
|
|
7574
7595
|
threadId,
|
|
7575
7596
|
resourceId,
|
|
7576
7597
|
record.lastObservedAt ? new Date(record.lastObservedAt) : void 0
|
|
@@ -7812,7 +7833,7 @@ ${grouped}` : grouped;
|
|
|
7812
7833
|
await this.withLock(lockKey, async () => {
|
|
7813
7834
|
const freshRecord = await this.getOrCreateRecord(threadId, resourceId);
|
|
7814
7835
|
generationBefore = freshRecord.generationCount;
|
|
7815
|
-
const unobservedMessages = messages ? this.getUnobservedMessages(messages, freshRecord) : await this.
|
|
7836
|
+
const unobservedMessages = messages ? this.getUnobservedMessages(messages, freshRecord) : await this.loadMessagesFromStorage(
|
|
7816
7837
|
threadId,
|
|
7817
7838
|
resourceId,
|
|
7818
7839
|
freshRecord.lastObservedAt ? new Date(freshRecord.lastObservedAt) : void 0
|
|
@@ -8443,5 +8464,5 @@ function getObservationsAsOf(activeObservations, asOf) {
|
|
|
8443
8464
|
}
|
|
8444
8465
|
|
|
8445
8466
|
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 };
|
|
8446
|
-
//# sourceMappingURL=chunk-
|
|
8447
|
-
//# sourceMappingURL=chunk-
|
|
8467
|
+
//# sourceMappingURL=chunk-ZVRY34YB.js.map
|
|
8468
|
+
//# sourceMappingURL=chunk-ZVRY34YB.js.map
|