@mastra/memory 1.19.0 → 1.20.0-alpha.1
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 +26 -0
- package/dist/{chunk-NZXH5WER.js → chunk-G72RLVRT.js} +70 -40
- package/dist/chunk-G72RLVRT.js.map +1 -0
- package/dist/{chunk-5IJQOXJM.cjs → chunk-PNKMNTE6.cjs} +69 -39
- package/dist/chunk-PNKMNTE6.cjs.map +1 -0
- package/dist/docs/SKILL.md +1 -1
- package/dist/docs/assets/SOURCE_MAP.json +47 -47
- package/dist/docs/references/docs-memory-multi-user-threads.md +1 -1
- package/dist/docs/references/docs-memory-observational-memory.md +2 -2
- package/dist/docs/references/docs-memory-storage.md +1 -1
- package/dist/docs/references/reference-memory-observational-memory.md +1 -1
- package/dist/docs/references/reference-storage-dsql.md +1 -1
- package/dist/docs/references/reference-storage-redis.md +1 -1
- package/dist/index.cjs +15 -14
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -5
- package/dist/index.js.map +1 -1
- package/dist/{observational-memory-V2APY3TO.cjs → observational-memory-25PDEXBJ.cjs} +26 -26
- package/dist/{observational-memory-V2APY3TO.cjs.map → observational-memory-25PDEXBJ.cjs.map} +1 -1
- package/dist/{observational-memory-KFKHBTCB.js → observational-memory-FBSRD6QN.js} +3 -3
- package/dist/{observational-memory-KFKHBTCB.js.map → observational-memory-FBSRD6QN.js.map} +1 -1
- package/dist/processors/index.cjs +24 -24
- package/dist/processors/index.js +1 -1
- package/dist/processors/observational-memory/message-utils.d.ts +1 -0
- package/dist/processors/observational-memory/message-utils.d.ts.map +1 -1
- package/dist/processors/observational-memory/observation-strategies/async-buffer.d.ts.map +1 -1
- package/dist/processors/observational-memory/observation-strategies/sync.d.ts.map +1 -1
- package/dist/processors/observational-memory/observation-turn/step.d.ts.map +1 -1
- package/dist/processors/observational-memory/observer-runner.d.ts +11 -0
- package/dist/processors/observational-memory/observer-runner.d.ts.map +1 -1
- package/dist/processors/observational-memory/processor.d.ts.map +1 -1
- package/dist/processors/observational-memory/temporal-markers.d.ts +1 -1
- package/dist/processors/observational-memory/temporal-markers.d.ts.map +1 -1
- package/dist/processors/observational-memory/types.d.ts +7 -3
- package/dist/processors/observational-memory/types.d.ts.map +1 -1
- package/package.json +3 -3
- package/dist/chunk-5IJQOXJM.cjs.map +0 -1
- package/dist/chunk-NZXH5WER.js.map +0 -1
package/dist/docs/SKILL.md
CHANGED
|
@@ -1,120 +1,120 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "1.
|
|
2
|
+
"version": "1.20.0-alpha.1",
|
|
3
3
|
"package": "@mastra/memory",
|
|
4
4
|
"exports": {
|
|
5
5
|
"ModelByInputTokens": {
|
|
6
6
|
"types": "dist/processors/index.d.ts",
|
|
7
|
-
"implementation": "dist/chunk-
|
|
8
|
-
"line":
|
|
7
|
+
"implementation": "dist/chunk-G72RLVRT.js",
|
|
8
|
+
"line": 787
|
|
9
9
|
},
|
|
10
10
|
"OBSERVER_SYSTEM_PROMPT": {
|
|
11
11
|
"types": "dist/processors/index.d.ts",
|
|
12
|
-
"implementation": "dist/chunk-
|
|
12
|
+
"implementation": "dist/chunk-G72RLVRT.js"
|
|
13
13
|
},
|
|
14
14
|
"ObservationalMemory": {
|
|
15
15
|
"types": "dist/processors/index.d.ts",
|
|
16
|
-
"implementation": "dist/chunk-
|
|
17
|
-
"line":
|
|
16
|
+
"implementation": "dist/chunk-G72RLVRT.js",
|
|
17
|
+
"line": 7051
|
|
18
18
|
},
|
|
19
19
|
"ObservationalMemoryProcessor": {
|
|
20
20
|
"types": "dist/processors/index.d.ts",
|
|
21
|
-
"implementation": "dist/chunk-
|
|
22
|
-
"line":
|
|
21
|
+
"implementation": "dist/chunk-G72RLVRT.js",
|
|
22
|
+
"line": 9619
|
|
23
23
|
},
|
|
24
24
|
"TokenCounter": {
|
|
25
25
|
"types": "dist/processors/index.d.ts",
|
|
26
|
-
"implementation": "dist/chunk-
|
|
27
|
-
"line":
|
|
26
|
+
"implementation": "dist/chunk-G72RLVRT.js",
|
|
27
|
+
"line": 6497
|
|
28
28
|
},
|
|
29
29
|
"buildObserverPrompt": {
|
|
30
30
|
"types": "dist/processors/index.d.ts",
|
|
31
|
-
"implementation": "dist/chunk-
|
|
32
|
-
"line":
|
|
31
|
+
"implementation": "dist/chunk-G72RLVRT.js",
|
|
32
|
+
"line": 3765
|
|
33
33
|
},
|
|
34
34
|
"buildObserverSystemPrompt": {
|
|
35
35
|
"types": "dist/processors/index.d.ts",
|
|
36
|
-
"implementation": "dist/chunk-
|
|
37
|
-
"line":
|
|
36
|
+
"implementation": "dist/chunk-G72RLVRT.js",
|
|
37
|
+
"line": 3036
|
|
38
38
|
},
|
|
39
39
|
"combineObservationGroupRanges": {
|
|
40
40
|
"types": "dist/processors/index.d.ts",
|
|
41
|
-
"implementation": "dist/chunk-
|
|
42
|
-
"line":
|
|
41
|
+
"implementation": "dist/chunk-G72RLVRT.js",
|
|
42
|
+
"line": 879
|
|
43
43
|
},
|
|
44
44
|
"deriveObservationGroupProvenance": {
|
|
45
45
|
"types": "dist/processors/index.d.ts",
|
|
46
|
-
"implementation": "dist/chunk-
|
|
47
|
-
"line":
|
|
46
|
+
"implementation": "dist/chunk-G72RLVRT.js",
|
|
47
|
+
"line": 913
|
|
48
48
|
},
|
|
49
49
|
"extractCurrentTask": {
|
|
50
50
|
"types": "dist/processors/index.d.ts",
|
|
51
|
-
"implementation": "dist/chunk-
|
|
52
|
-
"line":
|
|
51
|
+
"implementation": "dist/chunk-G72RLVRT.js",
|
|
52
|
+
"line": 3879
|
|
53
53
|
},
|
|
54
54
|
"formatMessagesForObserver": {
|
|
55
55
|
"types": "dist/processors/index.d.ts",
|
|
56
|
-
"implementation": "dist/chunk-
|
|
57
|
-
"line":
|
|
56
|
+
"implementation": "dist/chunk-G72RLVRT.js",
|
|
57
|
+
"line": 3491
|
|
58
58
|
},
|
|
59
59
|
"getObservationsAsOf": {
|
|
60
60
|
"types": "dist/processors/index.d.ts",
|
|
61
|
-
"implementation": "dist/chunk-
|
|
62
|
-
"line":
|
|
61
|
+
"implementation": "dist/chunk-G72RLVRT.js",
|
|
62
|
+
"line": 9831
|
|
63
63
|
},
|
|
64
64
|
"hasCurrentTaskSection": {
|
|
65
65
|
"types": "dist/processors/index.d.ts",
|
|
66
|
-
"implementation": "dist/chunk-
|
|
67
|
-
"line":
|
|
66
|
+
"implementation": "dist/chunk-G72RLVRT.js",
|
|
67
|
+
"line": 3867
|
|
68
68
|
},
|
|
69
69
|
"injectAnchorIds": {
|
|
70
70
|
"types": "dist/processors/index.d.ts",
|
|
71
|
-
"implementation": "dist/chunk-
|
|
72
|
-
"line":
|
|
71
|
+
"implementation": "dist/chunk-G72RLVRT.js",
|
|
72
|
+
"line": 2584
|
|
73
73
|
},
|
|
74
74
|
"optimizeObservationsForContext": {
|
|
75
75
|
"types": "dist/processors/index.d.ts",
|
|
76
|
-
"implementation": "dist/chunk-
|
|
77
|
-
"line":
|
|
76
|
+
"implementation": "dist/chunk-G72RLVRT.js",
|
|
77
|
+
"line": 3890
|
|
78
78
|
},
|
|
79
79
|
"parseAnchorId": {
|
|
80
80
|
"types": "dist/processors/index.d.ts",
|
|
81
|
-
"implementation": "dist/chunk-
|
|
82
|
-
"line":
|
|
81
|
+
"implementation": "dist/chunk-G72RLVRT.js",
|
|
82
|
+
"line": 2557
|
|
83
83
|
},
|
|
84
84
|
"parseObservationGroups": {
|
|
85
85
|
"types": "dist/processors/index.d.ts",
|
|
86
|
-
"implementation": "dist/chunk-
|
|
87
|
-
"line":
|
|
86
|
+
"implementation": "dist/chunk-G72RLVRT.js",
|
|
87
|
+
"line": 848
|
|
88
88
|
},
|
|
89
89
|
"parseObserverOutput": {
|
|
90
90
|
"types": "dist/processors/index.d.ts",
|
|
91
|
-
"implementation": "dist/chunk-
|
|
92
|
-
"line":
|
|
91
|
+
"implementation": "dist/chunk-G72RLVRT.js",
|
|
92
|
+
"line": 3775
|
|
93
93
|
},
|
|
94
94
|
"reconcileObservationGroupsFromReflection": {
|
|
95
95
|
"types": "dist/processors/index.d.ts",
|
|
96
|
-
"implementation": "dist/chunk-
|
|
97
|
-
"line":
|
|
96
|
+
"implementation": "dist/chunk-G72RLVRT.js",
|
|
97
|
+
"line": 937
|
|
98
98
|
},
|
|
99
99
|
"renderObservationGroupsForReflection": {
|
|
100
100
|
"types": "dist/processors/index.d.ts",
|
|
101
|
-
"implementation": "dist/chunk-
|
|
102
|
-
"line":
|
|
101
|
+
"implementation": "dist/chunk-G72RLVRT.js",
|
|
102
|
+
"line": 893
|
|
103
103
|
},
|
|
104
104
|
"stripEphemeralAnchorIds": {
|
|
105
105
|
"types": "dist/processors/index.d.ts",
|
|
106
|
-
"implementation": "dist/chunk-
|
|
107
|
-
"line":
|
|
106
|
+
"implementation": "dist/chunk-G72RLVRT.js",
|
|
107
|
+
"line": 2614
|
|
108
108
|
},
|
|
109
109
|
"stripObservationGroups": {
|
|
110
110
|
"types": "dist/processors/index.d.ts",
|
|
111
|
-
"implementation": "dist/chunk-
|
|
112
|
-
"line":
|
|
111
|
+
"implementation": "dist/chunk-G72RLVRT.js",
|
|
112
|
+
"line": 870
|
|
113
113
|
},
|
|
114
114
|
"wrapInObservationGroup": {
|
|
115
115
|
"types": "dist/processors/index.d.ts",
|
|
116
|
-
"implementation": "dist/chunk-
|
|
117
|
-
"line":
|
|
116
|
+
"implementation": "dist/chunk-G72RLVRT.js",
|
|
117
|
+
"line": 841
|
|
118
118
|
},
|
|
119
119
|
"OBSERVATIONAL_MEMORY_DEFAULTS": {
|
|
120
120
|
"types": "dist/processors/index.d.ts",
|
|
@@ -149,7 +149,7 @@
|
|
|
149
149
|
"processors": {
|
|
150
150
|
"index": "dist/processors/index.js",
|
|
151
151
|
"chunks": [
|
|
152
|
-
"chunk-
|
|
152
|
+
"chunk-G72RLVRT.js",
|
|
153
153
|
"chunk-LSJJAJAF.js"
|
|
154
154
|
]
|
|
155
155
|
}
|
|
@@ -65,7 +65,7 @@ const memory = new Memory({
|
|
|
65
65
|
export const collabAgent = new Agent({
|
|
66
66
|
id: 'collab',
|
|
67
67
|
name: 'CollabAgent',
|
|
68
|
-
model: '
|
|
68
|
+
model: '__OPENAI_MODEL_MINI__',
|
|
69
69
|
memory,
|
|
70
70
|
instructions: `
|
|
71
71
|
You are a collaborative document assistant. Multiple users talk to you in the SAME thread.
|
|
@@ -316,7 +316,7 @@ const memory = new Memory({
|
|
|
316
316
|
// Faster, cheaper models for smaller inputs; stronger models for larger contexts
|
|
317
317
|
5_000: 'openrouter/mistralai/ministral-8b-2512',
|
|
318
318
|
20_000: 'openrouter/mistralai/mistral-small-2603',
|
|
319
|
-
40_000: 'openai/gpt-5
|
|
319
|
+
40_000: 'openai/gpt-5-mini',
|
|
320
320
|
1_000_000: 'google/gemini-3.1-flash-lite-preview',
|
|
321
321
|
},
|
|
322
322
|
}),
|
|
@@ -324,7 +324,7 @@ const memory = new Memory({
|
|
|
324
324
|
reflection: {
|
|
325
325
|
model: new ModelByInputTokens({
|
|
326
326
|
upTo: {
|
|
327
|
-
20_000: 'openai/gpt-5
|
|
327
|
+
20_000: 'openai/gpt-5-mini',
|
|
328
328
|
100_000: 'google/gemini-2.5-flash',
|
|
329
329
|
},
|
|
330
330
|
}),
|
|
@@ -674,7 +674,7 @@ import { ModelByInputTokens } from '@mastra/memory'
|
|
|
674
674
|
const selector = new ModelByInputTokens({
|
|
675
675
|
upTo: {
|
|
676
676
|
10_000: 'google/gemini-2.5-flash', // Fast for small inputs
|
|
677
|
-
40_000: 'openai/gpt-5
|
|
677
|
+
40_000: 'openai/gpt-5-mini', // Stronger for medium inputs
|
|
678
678
|
1_000_000: 'openai/gpt-5.4', // Most capable for large inputs
|
|
679
679
|
},
|
|
680
680
|
})
|
|
@@ -241,7 +241,7 @@ export const dsqlAgent = new Agent({
|
|
|
241
241
|
name: 'DSQL Agent',
|
|
242
242
|
instructions:
|
|
243
243
|
'You are an AI agent with the ability to automatically recall memories from previous interactions.',
|
|
244
|
-
model: 'openai/gpt-5.
|
|
244
|
+
model: 'openai/gpt-5.4',
|
|
245
245
|
memory: new Memory({
|
|
246
246
|
storage: new DSQLStore({
|
|
247
247
|
id: 'dsql-agent-storage',
|
|
@@ -181,7 +181,7 @@ export const redisAgent = new Agent({
|
|
|
181
181
|
name: 'Redis Agent',
|
|
182
182
|
instructions:
|
|
183
183
|
'You are an AI agent with the ability to automatically recall memories from previous interactions.',
|
|
184
|
-
model: 'openai/gpt-
|
|
184
|
+
model: 'openai/gpt-5.4',
|
|
185
185
|
memory: new Memory({
|
|
186
186
|
storage: new RedisStore({
|
|
187
187
|
id: 'redis-agent-storage',
|
package/dist/index.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkPNKMNTE6_cjs = require('./chunk-PNKMNTE6.cjs');
|
|
4
4
|
var v3 = require('zod/v3');
|
|
5
5
|
var zod = require('zod');
|
|
6
6
|
var z4 = require('zod/v4');
|
|
@@ -16056,7 +16056,7 @@ function formatTimestamp(date) {
|
|
|
16056
16056
|
}
|
|
16057
16057
|
function truncateByTokens(text4, maxTokens, hint) {
|
|
16058
16058
|
if (tokenx.estimateTokenCount(text4) <= maxTokens) return { text: text4, wasTruncated: false };
|
|
16059
|
-
const truncated =
|
|
16059
|
+
const truncated = chunkPNKMNTE6_cjs.truncateStringByTokens(text4, maxTokens);
|
|
16060
16060
|
const suffix = hint ? ` [${hint} for more]` : "";
|
|
16061
16061
|
return { text: truncated + suffix, wasTruncated: true };
|
|
16062
16062
|
}
|
|
@@ -16108,11 +16108,11 @@ ${JSON.stringify(inv.args, null, 2)}`;
|
|
|
16108
16108
|
});
|
|
16109
16109
|
}
|
|
16110
16110
|
if (inv.state === "result") {
|
|
16111
|
-
const { value: resultValue } =
|
|
16111
|
+
const { value: resultValue } = chunkPNKMNTE6_cjs.resolveToolResultValue(
|
|
16112
16112
|
part,
|
|
16113
16113
|
inv.result
|
|
16114
16114
|
);
|
|
16115
|
-
const resultStr =
|
|
16115
|
+
const resultStr = chunkPNKMNTE6_cjs.formatToolResultForObserver(resultValue, { maxTokens: HIGH_DETAIL_TOOL_RESULT_TOKENS });
|
|
16116
16116
|
const fullText = `[Tool Result: ${inv.toolName}]
|
|
16117
16117
|
${resultStr}`;
|
|
16118
16118
|
parts.push(makePart(msg, i, "tool-result", fullText, detail, inv.toolName));
|
|
@@ -16139,7 +16139,7 @@ ${typeof rawArgs === "string" ? rawArgs : JSON.stringify(rawArgs, null, 2)}`;
|
|
|
16139
16139
|
const toolName = part.toolName;
|
|
16140
16140
|
if (toolName) {
|
|
16141
16141
|
const rawResult = part.output ?? part.result;
|
|
16142
|
-
const resultStr =
|
|
16142
|
+
const resultStr = chunkPNKMNTE6_cjs.formatToolResultForObserver(rawResult, { maxTokens: HIGH_DETAIL_TOOL_RESULT_TOKENS });
|
|
16143
16143
|
const fullText = `[Tool Result: ${toolName}]
|
|
16144
16144
|
${resultStr}`;
|
|
16145
16145
|
parts.push(makePart(msg, i, "tool-result", fullText, detail, toolName));
|
|
@@ -16218,7 +16218,7 @@ function renderFormattedParts(parts, timestamps, options) {
|
|
|
16218
16218
|
const text4 = buildRenderedText(parts, timestamps);
|
|
16219
16219
|
let totalTokens = tokenx.estimateTokenCount(text4);
|
|
16220
16220
|
if (totalTokens > options.maxTokens) {
|
|
16221
|
-
const truncated =
|
|
16221
|
+
const truncated = chunkPNKMNTE6_cjs.truncateStringByTokens(text4, options.maxTokens);
|
|
16222
16222
|
return { text: truncated, truncated: true, tokenOffset: totalTokens - options.maxTokens };
|
|
16223
16223
|
}
|
|
16224
16224
|
const truncatedIndices = parts.map((p, i) => ({ part: p, index: i })).filter(({ part }) => part.text !== part.fullText).sort((a, b) => expandPriority(a.part) - expandPriority(b.part));
|
|
@@ -16251,7 +16251,7 @@ function renderFormattedParts(parts, timestamps, options) {
|
|
|
16251
16251
|
if (expandedTokens <= options.maxTokens) {
|
|
16252
16252
|
return { text: expanded, truncated: false, tokenOffset: 0 };
|
|
16253
16253
|
}
|
|
16254
|
-
const hardTruncated =
|
|
16254
|
+
const hardTruncated = chunkPNKMNTE6_cjs.truncateStringByTokens(expanded, options.maxTokens);
|
|
16255
16255
|
return { text: hardTruncated, truncated: true, tokenOffset: expandedTokens - options.maxTokens };
|
|
16256
16256
|
}
|
|
16257
16257
|
async function recallPart({
|
|
@@ -16302,7 +16302,7 @@ async function recallPart({
|
|
|
16302
16302
|
|
|
16303
16303
|
`;
|
|
16304
16304
|
const fallbackText = `${fallbackNote}${firstNextPart.text}`;
|
|
16305
|
-
const truncatedText2 =
|
|
16305
|
+
const truncatedText2 = chunkPNKMNTE6_cjs.truncateStringByTokens(fallbackText, maxTokens);
|
|
16306
16306
|
const wasTruncated2 = truncatedText2 !== fallbackText;
|
|
16307
16307
|
return {
|
|
16308
16308
|
text: truncatedText2,
|
|
@@ -16317,7 +16317,7 @@ async function recallPart({
|
|
|
16317
16317
|
}
|
|
16318
16318
|
throw new Error(`Part index ${partIndex} not found in message ${cursor}. Available indices: ${availableIndices}`);
|
|
16319
16319
|
}
|
|
16320
|
-
const truncatedText =
|
|
16320
|
+
const truncatedText = chunkPNKMNTE6_cjs.truncateStringByTokens(target.text, maxTokens);
|
|
16321
16321
|
const wasTruncated = truncatedText !== target.text;
|
|
16322
16322
|
return {
|
|
16323
16323
|
text: truncatedText,
|
|
@@ -18079,7 +18079,7 @@ ${workingMemory}`;
|
|
|
18079
18079
|
"Observational memory requires @mastra/core support for request-response-id-rotation. Please bump @mastra/core to a newer version."
|
|
18080
18080
|
);
|
|
18081
18081
|
}
|
|
18082
|
-
const { ObservationalMemory: OMClass } = await import('./observational-memory-
|
|
18082
|
+
const { ObservationalMemory: OMClass } = await import('./observational-memory-25PDEXBJ.cjs');
|
|
18083
18083
|
const onIndexObservations = this.hasRetrievalSearch(omConfig.retrieval) ? async (observation) => {
|
|
18084
18084
|
await this.indexObservation(observation);
|
|
18085
18085
|
} : void 0;
|
|
@@ -18104,7 +18104,8 @@ ${workingMemory}`;
|
|
|
18104
18104
|
blockAfter: omConfig.observation.blockAfter,
|
|
18105
18105
|
previousObserverTokens: omConfig.observation.previousObserverTokens,
|
|
18106
18106
|
instruction: omConfig.observation.instruction,
|
|
18107
|
-
threadTitle: omConfig.observation.threadTitle
|
|
18107
|
+
threadTitle: omConfig.observation.threadTitle,
|
|
18108
|
+
observeAttachments: omConfig.observation.observeAttachments
|
|
18108
18109
|
} : void 0,
|
|
18109
18110
|
reflection: omConfig.reflection ? {
|
|
18110
18111
|
model: omConfig.reflection.model,
|
|
@@ -19005,7 +19006,7 @@ Notes:
|
|
|
19005
19006
|
if (!effectiveConfig) return null;
|
|
19006
19007
|
const engine = await this.omEngine;
|
|
19007
19008
|
if (!engine) return null;
|
|
19008
|
-
const { ObservationalMemoryProcessor } = await import('./observational-memory-
|
|
19009
|
+
const { ObservationalMemoryProcessor } = await import('./observational-memory-25PDEXBJ.cjs');
|
|
19009
19010
|
return new ObservationalMemoryProcessor(engine, this, {
|
|
19010
19011
|
temporalMarkers: effectiveConfig.temporalMarkers
|
|
19011
19012
|
});
|
|
@@ -19014,11 +19015,11 @@ Notes:
|
|
|
19014
19015
|
|
|
19015
19016
|
Object.defineProperty(exports, "ModelByInputTokens", {
|
|
19016
19017
|
enumerable: true,
|
|
19017
|
-
get: function () { return
|
|
19018
|
+
get: function () { return chunkPNKMNTE6_cjs.ModelByInputTokens; }
|
|
19018
19019
|
});
|
|
19019
19020
|
Object.defineProperty(exports, "getObservationsAsOf", {
|
|
19020
19021
|
enumerable: true,
|
|
19021
|
-
get: function () { return
|
|
19022
|
+
get: function () { return chunkPNKMNTE6_cjs.getObservationsAsOf; }
|
|
19022
19023
|
});
|
|
19023
19024
|
Object.defineProperty(exports, "MessageHistory", {
|
|
19024
19025
|
enumerable: true,
|