@mastra/memory 0.2.11-alpha.3 → 0.3.0-alpha.5
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/.turbo/turbo-build.log +9 -9
- package/CHANGELOG.md +18 -0
- package/dist/index.cjs +11 -11
- package/dist/index.js +11 -11
- package/package.json +2 -2
- package/src/index.ts +11 -11
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,29 +1,29 @@
|
|
|
1
1
|
|
|
2
|
-
> @mastra/memory@0.
|
|
2
|
+
> @mastra/memory@0.3.0-alpha.5 build /home/runner/work/mastra/mastra/packages/memory
|
|
3
3
|
> pnpm run check && tsup src/index.ts src/processors/index.ts --format esm,cjs --experimental-dts --clean --treeshake=smallest --splitting
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
> @mastra/memory@0.
|
|
6
|
+
> @mastra/memory@0.3.0-alpha.5 check /home/runner/work/mastra/mastra/packages/memory
|
|
7
7
|
> tsc --noEmit
|
|
8
8
|
|
|
9
9
|
[34mCLI[39m Building entry: src/index.ts, src/processors/index.ts
|
|
10
10
|
[34mCLI[39m Using tsconfig: tsconfig.json
|
|
11
11
|
[34mCLI[39m tsup v8.4.0
|
|
12
12
|
[34mTSC[39m Build start
|
|
13
|
-
[32mTSC[39m ⚡️ Build success in
|
|
13
|
+
[32mTSC[39m ⚡️ Build success in 12289ms
|
|
14
14
|
[34mDTS[39m Build start
|
|
15
15
|
[34mCLI[39m Target: es2022
|
|
16
16
|
Analysis will use the bundled TypeScript version 5.8.2
|
|
17
17
|
[36mWriting package typings: /home/runner/work/mastra/mastra/packages/memory/dist/_tsup-dts-rollup.d.ts[39m
|
|
18
18
|
Analysis will use the bundled TypeScript version 5.8.2
|
|
19
19
|
[36mWriting package typings: /home/runner/work/mastra/mastra/packages/memory/dist/_tsup-dts-rollup.d.cts[39m
|
|
20
|
-
[32mDTS[39m ⚡️ Build success in
|
|
20
|
+
[32mDTS[39m ⚡️ Build success in 12393ms
|
|
21
21
|
[34mCLI[39m Cleaning output folder
|
|
22
22
|
[34mESM[39m Build start
|
|
23
23
|
[34mCJS[39m Build start
|
|
24
|
-
[32mESM[39m [1mdist/index.js [22m[32m17.39 KB[39m
|
|
25
|
-
[32mESM[39m [1mdist/processors/index.js [22m[32m5.33 KB[39m
|
|
26
|
-
[32mESM[39m ⚡️ Build success in 951ms
|
|
27
|
-
[32mCJS[39m [1mdist/index.cjs [22m[32m17.58 KB[39m
|
|
28
24
|
[32mCJS[39m [1mdist/processors/index.cjs [22m[32m5.54 KB[39m
|
|
29
|
-
[32mCJS[39m
|
|
25
|
+
[32mCJS[39m [1mdist/index.cjs [22m[32m17.56 KB[39m
|
|
26
|
+
[32mCJS[39m ⚡️ Build success in 1170ms
|
|
27
|
+
[32mESM[39m [1mdist/index.js [22m[32m17.37 KB[39m
|
|
28
|
+
[32mESM[39m [1mdist/processors/index.js [22m[32m5.33 KB[39m
|
|
29
|
+
[32mESM[39m ⚡️ Build success in 1170ms
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
# @mastra/memory
|
|
2
2
|
|
|
3
|
+
## 0.3.0-alpha.5
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [7e92011]
|
|
8
|
+
- @mastra/core@0.9.0-alpha.4
|
|
9
|
+
|
|
10
|
+
## 0.3.0-alpha.4
|
|
11
|
+
|
|
12
|
+
### Minor Changes
|
|
13
|
+
|
|
14
|
+
- fe3ae4d: Remove \_\_ functions in storage and move to storage proxy to make sure init is called
|
|
15
|
+
|
|
16
|
+
### Patch Changes
|
|
17
|
+
|
|
18
|
+
- Updated dependencies [fe3ae4d]
|
|
19
|
+
- @mastra/core@0.9.0-alpha.3
|
|
20
|
+
|
|
3
21
|
## 0.2.11-alpha.3
|
|
4
22
|
|
|
5
23
|
### Patch Changes
|
package/dist/index.cjs
CHANGED
|
@@ -148,7 +148,7 @@ var Memory = class extends memory.MastraMemory {
|
|
|
148
148
|
})
|
|
149
149
|
);
|
|
150
150
|
}
|
|
151
|
-
const rawMessages = await this.storage.
|
|
151
|
+
const rawMessages = await this.storage.getMessages({
|
|
152
152
|
threadId,
|
|
153
153
|
selectBy: {
|
|
154
154
|
...selectBy,
|
|
@@ -199,10 +199,10 @@ var Memory = class extends memory.MastraMemory {
|
|
|
199
199
|
};
|
|
200
200
|
}
|
|
201
201
|
async getThreadById({ threadId }) {
|
|
202
|
-
return this.storage.
|
|
202
|
+
return this.storage.getThreadById({ threadId });
|
|
203
203
|
}
|
|
204
204
|
async getThreadsByResourceId({ resourceId }) {
|
|
205
|
-
return this.storage.
|
|
205
|
+
return this.storage.getThreadsByResourceId({ resourceId });
|
|
206
206
|
}
|
|
207
207
|
async saveThread({
|
|
208
208
|
thread,
|
|
@@ -210,7 +210,7 @@ var Memory = class extends memory.MastraMemory {
|
|
|
210
210
|
}) {
|
|
211
211
|
const config = this.getMergedThreadConfig(memoryConfig || {});
|
|
212
212
|
if (config.workingMemory?.enabled && !thread?.metadata?.workingMemory) {
|
|
213
|
-
return this.storage.
|
|
213
|
+
return this.storage.saveThread({
|
|
214
214
|
thread: core.deepMerge(thread, {
|
|
215
215
|
metadata: {
|
|
216
216
|
workingMemory: config.workingMemory.template || this.defaultWorkingMemoryTemplate
|
|
@@ -218,21 +218,21 @@ var Memory = class extends memory.MastraMemory {
|
|
|
218
218
|
})
|
|
219
219
|
});
|
|
220
220
|
}
|
|
221
|
-
return this.storage.
|
|
221
|
+
return this.storage.saveThread({ thread });
|
|
222
222
|
}
|
|
223
223
|
async updateThread({
|
|
224
224
|
id,
|
|
225
225
|
title,
|
|
226
226
|
metadata
|
|
227
227
|
}) {
|
|
228
|
-
return this.storage.
|
|
228
|
+
return this.storage.updateThread({
|
|
229
229
|
id,
|
|
230
230
|
title,
|
|
231
231
|
metadata
|
|
232
232
|
});
|
|
233
233
|
}
|
|
234
234
|
async deleteThread(threadId) {
|
|
235
|
-
await this.storage.
|
|
235
|
+
await this.storage.deleteThread({ threadId });
|
|
236
236
|
}
|
|
237
237
|
chunkText(text, tokenSize = 4096) {
|
|
238
238
|
const charSize = tokenSize * CHARS_PER_TOKEN;
|
|
@@ -291,7 +291,7 @@ var Memory = class extends memory.MastraMemory {
|
|
|
291
291
|
await this.saveWorkingMemory(messages);
|
|
292
292
|
this.mutateMessagesToHideWorkingMemory(messages);
|
|
293
293
|
const config = this.getMergedThreadConfig(memoryConfig);
|
|
294
|
-
const result = this.storage.
|
|
294
|
+
const result = this.storage.saveMessages({ messages });
|
|
295
295
|
if (this.vector && config.semanticRecall) {
|
|
296
296
|
let indexName;
|
|
297
297
|
await Promise.all(
|
|
@@ -349,7 +349,7 @@ var Memory = class extends memory.MastraMemory {
|
|
|
349
349
|
}
|
|
350
350
|
async getWorkingMemory({ threadId }) {
|
|
351
351
|
if (!this.threadConfig.workingMemory?.enabled) return null;
|
|
352
|
-
const thread = await this.storage.
|
|
352
|
+
const thread = await this.storage.getThreadById({ threadId });
|
|
353
353
|
if (!thread) return this.threadConfig?.workingMemory?.template || this.defaultWorkingMemoryTemplate;
|
|
354
354
|
const memory = thread.metadata?.workingMemory || this.threadConfig.workingMemory.template || this.defaultWorkingMemoryTemplate;
|
|
355
355
|
return memory.trim();
|
|
@@ -368,9 +368,9 @@ var Memory = class extends memory.MastraMemory {
|
|
|
368
368
|
if (!newMemory) {
|
|
369
369
|
return;
|
|
370
370
|
}
|
|
371
|
-
const thread = await this.storage.
|
|
371
|
+
const thread = await this.storage.getThreadById({ threadId });
|
|
372
372
|
if (!thread) return;
|
|
373
|
-
await this.storage.
|
|
373
|
+
await this.storage.updateThread({
|
|
374
374
|
id: thread.id,
|
|
375
375
|
title: thread.title || "",
|
|
376
376
|
metadata: core.deepMerge(thread.metadata || {}, {
|
package/dist/index.js
CHANGED
|
@@ -142,7 +142,7 @@ var Memory = class extends MastraMemory {
|
|
|
142
142
|
})
|
|
143
143
|
);
|
|
144
144
|
}
|
|
145
|
-
const rawMessages = await this.storage.
|
|
145
|
+
const rawMessages = await this.storage.getMessages({
|
|
146
146
|
threadId,
|
|
147
147
|
selectBy: {
|
|
148
148
|
...selectBy,
|
|
@@ -193,10 +193,10 @@ var Memory = class extends MastraMemory {
|
|
|
193
193
|
};
|
|
194
194
|
}
|
|
195
195
|
async getThreadById({ threadId }) {
|
|
196
|
-
return this.storage.
|
|
196
|
+
return this.storage.getThreadById({ threadId });
|
|
197
197
|
}
|
|
198
198
|
async getThreadsByResourceId({ resourceId }) {
|
|
199
|
-
return this.storage.
|
|
199
|
+
return this.storage.getThreadsByResourceId({ resourceId });
|
|
200
200
|
}
|
|
201
201
|
async saveThread({
|
|
202
202
|
thread,
|
|
@@ -204,7 +204,7 @@ var Memory = class extends MastraMemory {
|
|
|
204
204
|
}) {
|
|
205
205
|
const config = this.getMergedThreadConfig(memoryConfig || {});
|
|
206
206
|
if (config.workingMemory?.enabled && !thread?.metadata?.workingMemory) {
|
|
207
|
-
return this.storage.
|
|
207
|
+
return this.storage.saveThread({
|
|
208
208
|
thread: deepMerge(thread, {
|
|
209
209
|
metadata: {
|
|
210
210
|
workingMemory: config.workingMemory.template || this.defaultWorkingMemoryTemplate
|
|
@@ -212,21 +212,21 @@ var Memory = class extends MastraMemory {
|
|
|
212
212
|
})
|
|
213
213
|
});
|
|
214
214
|
}
|
|
215
|
-
return this.storage.
|
|
215
|
+
return this.storage.saveThread({ thread });
|
|
216
216
|
}
|
|
217
217
|
async updateThread({
|
|
218
218
|
id,
|
|
219
219
|
title,
|
|
220
220
|
metadata
|
|
221
221
|
}) {
|
|
222
|
-
return this.storage.
|
|
222
|
+
return this.storage.updateThread({
|
|
223
223
|
id,
|
|
224
224
|
title,
|
|
225
225
|
metadata
|
|
226
226
|
});
|
|
227
227
|
}
|
|
228
228
|
async deleteThread(threadId) {
|
|
229
|
-
await this.storage.
|
|
229
|
+
await this.storage.deleteThread({ threadId });
|
|
230
230
|
}
|
|
231
231
|
chunkText(text, tokenSize = 4096) {
|
|
232
232
|
const charSize = tokenSize * CHARS_PER_TOKEN;
|
|
@@ -285,7 +285,7 @@ var Memory = class extends MastraMemory {
|
|
|
285
285
|
await this.saveWorkingMemory(messages);
|
|
286
286
|
this.mutateMessagesToHideWorkingMemory(messages);
|
|
287
287
|
const config = this.getMergedThreadConfig(memoryConfig);
|
|
288
|
-
const result = this.storage.
|
|
288
|
+
const result = this.storage.saveMessages({ messages });
|
|
289
289
|
if (this.vector && config.semanticRecall) {
|
|
290
290
|
let indexName;
|
|
291
291
|
await Promise.all(
|
|
@@ -343,7 +343,7 @@ var Memory = class extends MastraMemory {
|
|
|
343
343
|
}
|
|
344
344
|
async getWorkingMemory({ threadId }) {
|
|
345
345
|
if (!this.threadConfig.workingMemory?.enabled) return null;
|
|
346
|
-
const thread = await this.storage.
|
|
346
|
+
const thread = await this.storage.getThreadById({ threadId });
|
|
347
347
|
if (!thread) return this.threadConfig?.workingMemory?.template || this.defaultWorkingMemoryTemplate;
|
|
348
348
|
const memory = thread.metadata?.workingMemory || this.threadConfig.workingMemory.template || this.defaultWorkingMemoryTemplate;
|
|
349
349
|
return memory.trim();
|
|
@@ -362,9 +362,9 @@ var Memory = class extends MastraMemory {
|
|
|
362
362
|
if (!newMemory) {
|
|
363
363
|
return;
|
|
364
364
|
}
|
|
365
|
-
const thread = await this.storage.
|
|
365
|
+
const thread = await this.storage.getThreadById({ threadId });
|
|
366
366
|
if (!thread) return;
|
|
367
|
-
await this.storage.
|
|
367
|
+
await this.storage.updateThread({
|
|
368
368
|
id: thread.id,
|
|
369
369
|
title: thread.title || "",
|
|
370
370
|
metadata: deepMerge(thread.metadata || {}, {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mastra/memory",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0-alpha.5",
|
|
4
4
|
"description": "",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
"redis": "^4.7.0",
|
|
42
42
|
"xxhash-wasm": "^1.1.0",
|
|
43
43
|
"zod": "^3.24.2",
|
|
44
|
-
"@mastra/core": "^0.
|
|
44
|
+
"@mastra/core": "^0.9.0-alpha.4"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
47
|
"@ai-sdk/openai": "^1.3.3",
|
package/src/index.ts
CHANGED
|
@@ -104,7 +104,7 @@ export class Memory extends MastraMemory {
|
|
|
104
104
|
}
|
|
105
105
|
|
|
106
106
|
// Get raw messages from storage
|
|
107
|
-
const rawMessages = await this.storage.
|
|
107
|
+
const rawMessages = await this.storage.getMessages({
|
|
108
108
|
threadId,
|
|
109
109
|
selectBy: {
|
|
110
110
|
...selectBy,
|
|
@@ -183,11 +183,11 @@ export class Memory extends MastraMemory {
|
|
|
183
183
|
}
|
|
184
184
|
|
|
185
185
|
async getThreadById({ threadId }: { threadId: string }): Promise<StorageThreadType | null> {
|
|
186
|
-
return this.storage.
|
|
186
|
+
return this.storage.getThreadById({ threadId });
|
|
187
187
|
}
|
|
188
188
|
|
|
189
189
|
async getThreadsByResourceId({ resourceId }: { resourceId: string }): Promise<StorageThreadType[]> {
|
|
190
|
-
return this.storage.
|
|
190
|
+
return this.storage.getThreadsByResourceId({ resourceId });
|
|
191
191
|
}
|
|
192
192
|
|
|
193
193
|
async saveThread({
|
|
@@ -201,7 +201,7 @@ export class Memory extends MastraMemory {
|
|
|
201
201
|
|
|
202
202
|
if (config.workingMemory?.enabled && !thread?.metadata?.workingMemory) {
|
|
203
203
|
// if working memory is enabled but the thread doesn't have it, we need to set it
|
|
204
|
-
return this.storage.
|
|
204
|
+
return this.storage.saveThread({
|
|
205
205
|
thread: deepMerge(thread, {
|
|
206
206
|
metadata: {
|
|
207
207
|
workingMemory: config.workingMemory.template || this.defaultWorkingMemoryTemplate,
|
|
@@ -210,7 +210,7 @@ export class Memory extends MastraMemory {
|
|
|
210
210
|
});
|
|
211
211
|
}
|
|
212
212
|
|
|
213
|
-
return this.storage.
|
|
213
|
+
return this.storage.saveThread({ thread });
|
|
214
214
|
}
|
|
215
215
|
|
|
216
216
|
async updateThread({
|
|
@@ -222,7 +222,7 @@ export class Memory extends MastraMemory {
|
|
|
222
222
|
title: string;
|
|
223
223
|
metadata: Record<string, unknown>;
|
|
224
224
|
}): Promise<StorageThreadType> {
|
|
225
|
-
return this.storage.
|
|
225
|
+
return this.storage.updateThread({
|
|
226
226
|
id,
|
|
227
227
|
title,
|
|
228
228
|
metadata,
|
|
@@ -230,7 +230,7 @@ export class Memory extends MastraMemory {
|
|
|
230
230
|
}
|
|
231
231
|
|
|
232
232
|
async deleteThread(threadId: string): Promise<void> {
|
|
233
|
-
await this.storage.
|
|
233
|
+
await this.storage.deleteThread({ threadId });
|
|
234
234
|
}
|
|
235
235
|
|
|
236
236
|
private chunkText(text: string, tokenSize = 4096) {
|
|
@@ -325,7 +325,7 @@ export class Memory extends MastraMemory {
|
|
|
325
325
|
|
|
326
326
|
const config = this.getMergedThreadConfig(memoryConfig);
|
|
327
327
|
|
|
328
|
-
const result = this.storage.
|
|
328
|
+
const result = this.storage.saveMessages({ messages });
|
|
329
329
|
|
|
330
330
|
if (this.vector && config.semanticRecall) {
|
|
331
331
|
let indexName: Promise<string>;
|
|
@@ -402,7 +402,7 @@ export class Memory extends MastraMemory {
|
|
|
402
402
|
if (!this.threadConfig.workingMemory?.enabled) return null;
|
|
403
403
|
|
|
404
404
|
// Get thread from storage
|
|
405
|
-
const thread = await this.storage.
|
|
405
|
+
const thread = await this.storage.getThreadById({ threadId });
|
|
406
406
|
if (!thread) return this.threadConfig?.workingMemory?.template || this.defaultWorkingMemoryTemplate;
|
|
407
407
|
|
|
408
408
|
// Return working memory from metadata
|
|
@@ -440,11 +440,11 @@ export class Memory extends MastraMemory {
|
|
|
440
440
|
return;
|
|
441
441
|
}
|
|
442
442
|
|
|
443
|
-
const thread = await this.storage.
|
|
443
|
+
const thread = await this.storage.getThreadById({ threadId });
|
|
444
444
|
if (!thread) return;
|
|
445
445
|
|
|
446
446
|
// Update thread metadata with new working memory
|
|
447
|
-
await this.storage.
|
|
447
|
+
await this.storage.updateThread({
|
|
448
448
|
id: thread.id,
|
|
449
449
|
title: thread.title || '',
|
|
450
450
|
metadata: deepMerge(thread.metadata || {}, {
|