@mastra/memory 0.11.0 → 0.11.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/.turbo/turbo-build.log +2 -2
- package/CHANGELOG.md +46 -0
- package/dist/_tsup-dts-rollup.d.cts +13 -5
- package/dist/_tsup-dts-rollup.d.ts +13 -5
- package/package.json +5 -5
- package/src/index.ts +5 -5
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
|
|
2
|
-
> @mastra/memory@0.11.
|
|
2
|
+
> @mastra/memory@0.11.1-alpha.0 build /home/runner/work/mastra/mastra/packages/memory
|
|
3
3
|
> pnpm run check && tsup --silent src/index.ts src/processors/index.ts --format esm,cjs --experimental-dts --clean --treeshake=smallest --splitting
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
> @mastra/memory@0.11.
|
|
6
|
+
> @mastra/memory@0.11.1-alpha.0 check /home/runner/work/mastra/mastra/packages/memory
|
|
7
7
|
> tsc --noEmit
|
|
8
8
|
|
|
9
9
|
Analysis will use the bundled TypeScript version 5.8.3
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,51 @@
|
|
|
1
1
|
# @mastra/memory
|
|
2
2
|
|
|
3
|
+
## 0.11.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 81a1b3b: Update peerdeps
|
|
8
|
+
- b7852ed: [MASTRA-4139] make private functions protected in memory
|
|
9
|
+
- Updated dependencies [9dda1ac]
|
|
10
|
+
- Updated dependencies [c984582]
|
|
11
|
+
- Updated dependencies [7e801dd]
|
|
12
|
+
- Updated dependencies [a606c75]
|
|
13
|
+
- Updated dependencies [7aa70a4]
|
|
14
|
+
- Updated dependencies [764f86a]
|
|
15
|
+
- Updated dependencies [1760a1c]
|
|
16
|
+
- Updated dependencies [038e5ae]
|
|
17
|
+
- Updated dependencies [7dda16a]
|
|
18
|
+
- Updated dependencies [5ebfcdd]
|
|
19
|
+
- Updated dependencies [b2d0c91]
|
|
20
|
+
- Updated dependencies [4e809ad]
|
|
21
|
+
- Updated dependencies [57929df]
|
|
22
|
+
- Updated dependencies [b7852ed]
|
|
23
|
+
- Updated dependencies [6320a61]
|
|
24
|
+
- @mastra/core@0.10.9
|
|
25
|
+
|
|
26
|
+
## 0.11.1-alpha.0
|
|
27
|
+
|
|
28
|
+
### Patch Changes
|
|
29
|
+
|
|
30
|
+
- 81a1b3b: Update peerdeps
|
|
31
|
+
- b7852ed: [MASTRA-4139] make private functions protected in memory
|
|
32
|
+
- Updated dependencies [9dda1ac]
|
|
33
|
+
- Updated dependencies [c984582]
|
|
34
|
+
- Updated dependencies [7e801dd]
|
|
35
|
+
- Updated dependencies [a606c75]
|
|
36
|
+
- Updated dependencies [7aa70a4]
|
|
37
|
+
- Updated dependencies [764f86a]
|
|
38
|
+
- Updated dependencies [1760a1c]
|
|
39
|
+
- Updated dependencies [038e5ae]
|
|
40
|
+
- Updated dependencies [7dda16a]
|
|
41
|
+
- Updated dependencies [5ebfcdd]
|
|
42
|
+
- Updated dependencies [b2d0c91]
|
|
43
|
+
- Updated dependencies [4e809ad]
|
|
44
|
+
- Updated dependencies [57929df]
|
|
45
|
+
- Updated dependencies [b7852ed]
|
|
46
|
+
- Updated dependencies [6320a61]
|
|
47
|
+
- @mastra/core@0.10.9-alpha.0
|
|
48
|
+
|
|
3
49
|
## 0.11.0
|
|
4
50
|
|
|
5
51
|
### Minor Changes
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { CoreMessage } from 'ai';
|
|
2
2
|
import type { CoreMessage as CoreMessage_2 } from '@mastra/core';
|
|
3
3
|
import type { CoreTool } from '@mastra/core';
|
|
4
|
+
import { embedMany } from 'ai';
|
|
4
5
|
import { MastraMemory } from '@mastra/core/memory';
|
|
5
6
|
import type { MastraMessageV1 } from '@mastra/core';
|
|
6
7
|
import type { MastraMessageV2 } from '@mastra/core/agent';
|
|
@@ -22,8 +23,8 @@ import type { WorkingMemoryTemplate } from '@mastra/core/memory';
|
|
|
22
23
|
*/
|
|
23
24
|
export declare class Memory extends MastraMemory {
|
|
24
25
|
constructor(config?: SharedMemoryConfig);
|
|
25
|
-
|
|
26
|
-
|
|
26
|
+
protected validateThreadIsOwnedByResource(threadId: string, resourceId: string): Promise<void>;
|
|
27
|
+
protected checkStorageFeatureSupport(config: MemoryConfig): void;
|
|
27
28
|
query({ threadId, resourceId, selectBy, threadConfig, }: StorageGetMessagesArg & {
|
|
28
29
|
threadConfig?: MemoryConfig;
|
|
29
30
|
}): Promise<{
|
|
@@ -62,11 +63,15 @@ export declare class Memory extends MastraMemory {
|
|
|
62
63
|
workingMemory: string;
|
|
63
64
|
memoryConfig?: MemoryConfig;
|
|
64
65
|
}): Promise<void>;
|
|
65
|
-
|
|
66
|
+
protected chunkText(text: string, tokenSize?: number): string[];
|
|
66
67
|
private hasher;
|
|
67
68
|
private embeddingCache;
|
|
68
69
|
private firstEmbed;
|
|
69
|
-
|
|
70
|
+
protected embedMessageContent(content: string): Promise<{
|
|
71
|
+
chunks: string[];
|
|
72
|
+
embeddings: Awaited<ReturnType<typeof embedMany>>["embeddings"];
|
|
73
|
+
dimension: number | undefined;
|
|
74
|
+
}>;
|
|
70
75
|
saveMessages(args: {
|
|
71
76
|
messages: (MastraMessageV1 | MastraMessageV2)[] | MastraMessageV1[] | MastraMessageV2[];
|
|
72
77
|
memoryConfig?: MemoryConfig | undefined;
|
|
@@ -92,7 +97,10 @@ export declare class Memory extends MastraMemory {
|
|
|
92
97
|
memoryConfig?: MemoryConfig;
|
|
93
98
|
}): Promise<string | null>;
|
|
94
99
|
defaultWorkingMemoryTemplate: string;
|
|
95
|
-
|
|
100
|
+
protected getWorkingMemoryToolInstruction({ template, data, }: {
|
|
101
|
+
template: WorkingMemoryTemplate;
|
|
102
|
+
data: string | null;
|
|
103
|
+
}): string;
|
|
96
104
|
getTools(config?: MemoryConfig): Record<string, CoreTool>;
|
|
97
105
|
/**
|
|
98
106
|
* Updates the metadata of a list of messages
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { CoreMessage } from 'ai';
|
|
2
2
|
import type { CoreMessage as CoreMessage_2 } from '@mastra/core';
|
|
3
3
|
import type { CoreTool } from '@mastra/core';
|
|
4
|
+
import { embedMany } from 'ai';
|
|
4
5
|
import { MastraMemory } from '@mastra/core/memory';
|
|
5
6
|
import type { MastraMessageV1 } from '@mastra/core';
|
|
6
7
|
import type { MastraMessageV2 } from '@mastra/core/agent';
|
|
@@ -22,8 +23,8 @@ import type { WorkingMemoryTemplate } from '@mastra/core/memory';
|
|
|
22
23
|
*/
|
|
23
24
|
export declare class Memory extends MastraMemory {
|
|
24
25
|
constructor(config?: SharedMemoryConfig);
|
|
25
|
-
|
|
26
|
-
|
|
26
|
+
protected validateThreadIsOwnedByResource(threadId: string, resourceId: string): Promise<void>;
|
|
27
|
+
protected checkStorageFeatureSupport(config: MemoryConfig): void;
|
|
27
28
|
query({ threadId, resourceId, selectBy, threadConfig, }: StorageGetMessagesArg & {
|
|
28
29
|
threadConfig?: MemoryConfig;
|
|
29
30
|
}): Promise<{
|
|
@@ -62,11 +63,15 @@ export declare class Memory extends MastraMemory {
|
|
|
62
63
|
workingMemory: string;
|
|
63
64
|
memoryConfig?: MemoryConfig;
|
|
64
65
|
}): Promise<void>;
|
|
65
|
-
|
|
66
|
+
protected chunkText(text: string, tokenSize?: number): string[];
|
|
66
67
|
private hasher;
|
|
67
68
|
private embeddingCache;
|
|
68
69
|
private firstEmbed;
|
|
69
|
-
|
|
70
|
+
protected embedMessageContent(content: string): Promise<{
|
|
71
|
+
chunks: string[];
|
|
72
|
+
embeddings: Awaited<ReturnType<typeof embedMany>>["embeddings"];
|
|
73
|
+
dimension: number | undefined;
|
|
74
|
+
}>;
|
|
70
75
|
saveMessages(args: {
|
|
71
76
|
messages: (MastraMessageV1 | MastraMessageV2)[] | MastraMessageV1[] | MastraMessageV2[];
|
|
72
77
|
memoryConfig?: MemoryConfig | undefined;
|
|
@@ -92,7 +97,10 @@ export declare class Memory extends MastraMemory {
|
|
|
92
97
|
memoryConfig?: MemoryConfig;
|
|
93
98
|
}): Promise<string | null>;
|
|
94
99
|
defaultWorkingMemoryTemplate: string;
|
|
95
|
-
|
|
100
|
+
protected getWorkingMemoryToolInstruction({ template, data, }: {
|
|
101
|
+
template: WorkingMemoryTemplate;
|
|
102
|
+
data: string | null;
|
|
103
|
+
}): string;
|
|
96
104
|
getTools(config?: MemoryConfig): Record<string, CoreTool>;
|
|
97
105
|
/**
|
|
98
106
|
* Updates the metadata of a list of messages
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mastra/memory",
|
|
3
|
-
"version": "0.11.
|
|
3
|
+
"version": "0.11.1",
|
|
4
4
|
"description": "",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -52,12 +52,12 @@
|
|
|
52
52
|
"tsup": "^8.5.0",
|
|
53
53
|
"typescript": "^5.8.3",
|
|
54
54
|
"typescript-eslint": "^8.34.0",
|
|
55
|
-
"vitest": "^3.2.
|
|
56
|
-
"@internal/lint": "0.0.
|
|
57
|
-
"@mastra/core": "0.10.
|
|
55
|
+
"vitest": "^3.2.4",
|
|
56
|
+
"@internal/lint": "0.0.16",
|
|
57
|
+
"@mastra/core": "0.10.9"
|
|
58
58
|
},
|
|
59
59
|
"peerDependencies": {
|
|
60
|
-
"@mastra/core": ">=0.10.
|
|
60
|
+
"@mastra/core": ">=0.10.9-0 <0.11.0-0"
|
|
61
61
|
},
|
|
62
62
|
"scripts": {
|
|
63
63
|
"check": "tsc --noEmit",
|
package/src/index.ts
CHANGED
|
@@ -40,7 +40,7 @@ export class Memory extends MastraMemory {
|
|
|
40
40
|
this.checkStorageFeatureSupport(mergedConfig);
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
-
|
|
43
|
+
protected async validateThreadIsOwnedByResource(threadId: string, resourceId: string) {
|
|
44
44
|
const thread = await this.storage.getThreadById({ threadId });
|
|
45
45
|
if (!thread) {
|
|
46
46
|
throw new Error(`No thread found with id ${threadId}`);
|
|
@@ -52,7 +52,7 @@ export class Memory extends MastraMemory {
|
|
|
52
52
|
}
|
|
53
53
|
}
|
|
54
54
|
|
|
55
|
-
|
|
55
|
+
protected checkStorageFeatureSupport(config: MemoryConfig) {
|
|
56
56
|
if (
|
|
57
57
|
typeof config.semanticRecall === `object` &&
|
|
58
58
|
config.semanticRecall.scope === `resource` &&
|
|
@@ -359,7 +359,7 @@ export class Memory extends MastraMemory {
|
|
|
359
359
|
}
|
|
360
360
|
}
|
|
361
361
|
|
|
362
|
-
|
|
362
|
+
protected chunkText(text: string, tokenSize = 4096) {
|
|
363
363
|
// Convert token size to character size with some buffer
|
|
364
364
|
const charSize = tokenSize * CHARS_PER_TOKEN;
|
|
365
365
|
const chunks: string[] = [];
|
|
@@ -401,7 +401,7 @@ export class Memory extends MastraMemory {
|
|
|
401
401
|
}
|
|
402
402
|
>();
|
|
403
403
|
private firstEmbed: Promise<any> | undefined;
|
|
404
|
-
|
|
404
|
+
protected async embedMessageContent(content: string) {
|
|
405
405
|
// use fast xxhash for lower memory usage. if we cache by content string we will store all messages in memory for the life of the process
|
|
406
406
|
const key = (await this.hasher).h32(content);
|
|
407
407
|
const cached = this.embeddingCache.get(key);
|
|
@@ -720,7 +720,7 @@ export class Memory extends MastraMemory {
|
|
|
720
720
|
- **Projects**:
|
|
721
721
|
`;
|
|
722
722
|
|
|
723
|
-
|
|
723
|
+
protected getWorkingMemoryToolInstruction({
|
|
724
724
|
template,
|
|
725
725
|
data,
|
|
726
726
|
}: {
|