@mastra/memory 0.2.0-alpha.3 → 0.2.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 +8 -8
- package/CHANGELOG.md +29 -0
- package/dist/_tsup-dts-rollup.d.cts +4 -3
- package/dist/_tsup-dts-rollup.d.ts +4 -3
- package/dist/index.cjs +11 -4
- package/dist/index.js +11 -4
- package/package.json +2 -2
- package/src/index.ts +15 -6
- package/src/tools/working-memory.ts +1 -2
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,27 +1,27 @@
|
|
|
1
1
|
|
|
2
|
-
> @mastra/memory@0.2.0-alpha.
|
|
2
|
+
> @mastra/memory@0.2.0-alpha.5 build /home/runner/work/mastra/mastra/packages/memory
|
|
3
3
|
> pnpm run check && tsup src/index.ts --format esm,cjs --experimental-dts --clean --treeshake
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
> @mastra/memory@0.2.0-alpha.
|
|
6
|
+
> @mastra/memory@0.2.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
|
|
10
10
|
[34mCLI[39m Using tsconfig: tsconfig.json
|
|
11
11
|
[34mCLI[39m tsup v8.3.6
|
|
12
12
|
[34mTSC[39m Build start
|
|
13
|
-
[32mTSC[39m ⚡️ Build success in
|
|
13
|
+
[32mTSC[39m ⚡️ Build success in 8106ms
|
|
14
14
|
[34mDTS[39m Build start
|
|
15
15
|
[34mCLI[39m Target: es2022
|
|
16
16
|
Analysis will use the bundled TypeScript version 5.7.3
|
|
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.7.3
|
|
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 9546ms
|
|
21
21
|
[34mCLI[39m Cleaning output folder
|
|
22
22
|
[34mESM[39m Build start
|
|
23
23
|
[34mCJS[39m Build start
|
|
24
|
-
[32mCJS[39m [1mdist/index.cjs [22m[32m12.
|
|
25
|
-
[32mCJS[39m ⚡️ Build success in
|
|
26
|
-
[32mESM[39m [1mdist/index.js [22m[32m12.
|
|
27
|
-
[32mESM[39m ⚡️ Build success in
|
|
24
|
+
[32mCJS[39m [1mdist/index.cjs [22m[32m12.21 KB[39m
|
|
25
|
+
[32mCJS[39m ⚡️ Build success in 505ms
|
|
26
|
+
[32mESM[39m [1mdist/index.js [22m[32m12.18 KB[39m
|
|
27
|
+
[32mESM[39m ⚡️ Build success in 505ms
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,34 @@
|
|
|
1
1
|
# @mastra/memory
|
|
2
2
|
|
|
3
|
+
## 0.2.0-alpha.5
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- c151ae6: Fixed an issue where models that don't support structured output would error when generating a thread title. Added an option to disable thread title llm generation `new Memory({ threads: { generateTitle: false }})`
|
|
8
|
+
- Updated dependencies [22643eb]
|
|
9
|
+
- Updated dependencies [6feb23f]
|
|
10
|
+
- Updated dependencies [f2d6727]
|
|
11
|
+
- Updated dependencies [301e4ee]
|
|
12
|
+
- Updated dependencies [dfbe4e9]
|
|
13
|
+
- Updated dependencies [9e81f35]
|
|
14
|
+
- Updated dependencies [caefaa2]
|
|
15
|
+
- Updated dependencies [c151ae6]
|
|
16
|
+
- Updated dependencies [52e0418]
|
|
17
|
+
- Updated dependencies [03236ec]
|
|
18
|
+
- Updated dependencies [3764e71]
|
|
19
|
+
- Updated dependencies [df982db]
|
|
20
|
+
- Updated dependencies [0461849]
|
|
21
|
+
- Updated dependencies [2259379]
|
|
22
|
+
- Updated dependencies [358f069]
|
|
23
|
+
- @mastra/core@0.5.0-alpha.5
|
|
24
|
+
|
|
25
|
+
## 0.2.0-alpha.4
|
|
26
|
+
|
|
27
|
+
### Patch Changes
|
|
28
|
+
|
|
29
|
+
- Updated dependencies [d79aedf]
|
|
30
|
+
- @mastra/core@0.5.0-alpha.4
|
|
31
|
+
|
|
3
32
|
## 0.2.0-alpha.3
|
|
4
33
|
|
|
5
34
|
### Patch Changes
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
+
import type { AiMessageType } from '@mastra/core';
|
|
1
2
|
import type { CoreMessage } from '@mastra/core';
|
|
2
3
|
import type { CoreTool } from '@mastra/core';
|
|
3
4
|
import { MastraMemory } from '@mastra/core/memory';
|
|
4
5
|
import type { MemoryConfig } from '@mastra/core/memory';
|
|
5
|
-
import type { Message } from 'ai';
|
|
6
6
|
import type { MessageType } from '@mastra/core/memory';
|
|
7
7
|
import type { SharedMemoryConfig } from '@mastra/core/memory';
|
|
8
8
|
import type { StorageGetMessagesArg } from '@mastra/core/storage';
|
|
@@ -16,15 +16,16 @@ export declare class Memory extends MastraMemory {
|
|
|
16
16
|
constructor(config?: SharedMemoryConfig);
|
|
17
17
|
query({ threadId, selectBy, threadConfig, }: StorageGetMessagesArg): Promise<{
|
|
18
18
|
messages: CoreMessage[];
|
|
19
|
-
uiMessages:
|
|
19
|
+
uiMessages: AiMessageType[];
|
|
20
20
|
}>;
|
|
21
21
|
rememberMessages({ threadId, vectorMessageSearch, config, }: {
|
|
22
22
|
threadId: string;
|
|
23
23
|
vectorMessageSearch?: string;
|
|
24
24
|
config?: MemoryConfig;
|
|
25
25
|
}): Promise<{
|
|
26
|
+
threadId: string;
|
|
26
27
|
messages: CoreMessage[];
|
|
27
|
-
uiMessages:
|
|
28
|
+
uiMessages: AiMessageType[];
|
|
28
29
|
}>;
|
|
29
30
|
getThreadById({ threadId }: {
|
|
30
31
|
threadId: string;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
+
import type { AiMessageType } from '@mastra/core';
|
|
1
2
|
import type { CoreMessage } from '@mastra/core';
|
|
2
3
|
import type { CoreTool } from '@mastra/core';
|
|
3
4
|
import { MastraMemory } from '@mastra/core/memory';
|
|
4
5
|
import type { MemoryConfig } from '@mastra/core/memory';
|
|
5
|
-
import type { Message } from 'ai';
|
|
6
6
|
import type { MessageType } from '@mastra/core/memory';
|
|
7
7
|
import type { SharedMemoryConfig } from '@mastra/core/memory';
|
|
8
8
|
import type { StorageGetMessagesArg } from '@mastra/core/storage';
|
|
@@ -16,15 +16,16 @@ export declare class Memory extends MastraMemory {
|
|
|
16
16
|
constructor(config?: SharedMemoryConfig);
|
|
17
17
|
query({ threadId, selectBy, threadConfig, }: StorageGetMessagesArg): Promise<{
|
|
18
18
|
messages: CoreMessage[];
|
|
19
|
-
uiMessages:
|
|
19
|
+
uiMessages: AiMessageType[];
|
|
20
20
|
}>;
|
|
21
21
|
rememberMessages({ threadId, vectorMessageSearch, config, }: {
|
|
22
22
|
threadId: string;
|
|
23
23
|
vectorMessageSearch?: string;
|
|
24
24
|
config?: MemoryConfig;
|
|
25
25
|
}): Promise<{
|
|
26
|
+
threadId: string;
|
|
26
27
|
messages: CoreMessage[];
|
|
27
|
-
uiMessages:
|
|
28
|
+
uiMessages: AiMessageType[];
|
|
28
29
|
}>;
|
|
29
30
|
getThreadById({ threadId }: {
|
|
30
31
|
threadId: string;
|
package/dist/index.cjs
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
var core = require('@mastra/core');
|
|
4
4
|
var memory = require('@mastra/core/memory');
|
|
5
|
-
var zod = require('zod');
|
|
6
5
|
var ai = require('ai');
|
|
6
|
+
var zod = require('zod');
|
|
7
7
|
|
|
8
8
|
// src/index.ts
|
|
9
9
|
var updateWorkingMemoryTool = {
|
|
@@ -11,7 +11,7 @@ var updateWorkingMemoryTool = {
|
|
|
11
11
|
parameters: zod.z.object({
|
|
12
12
|
memory: zod.z.string().describe("The XML-formatted working memory content to store")
|
|
13
13
|
}),
|
|
14
|
-
execute: async (params
|
|
14
|
+
execute: async (params) => {
|
|
15
15
|
const { context, threadId, memory } = params;
|
|
16
16
|
if (!threadId || !memory) {
|
|
17
17
|
throw new Error("Thread ID and Memory instance are required for working memory updates");
|
|
@@ -32,6 +32,8 @@ var updateWorkingMemoryTool = {
|
|
|
32
32
|
return { success: true };
|
|
33
33
|
}
|
|
34
34
|
};
|
|
35
|
+
|
|
36
|
+
// src/index.ts
|
|
35
37
|
var Memory = class extends memory.MastraMemory {
|
|
36
38
|
constructor(config = {}) {
|
|
37
39
|
super({ name: "Memory", ...config });
|
|
@@ -104,7 +106,8 @@ var Memory = class extends memory.MastraMemory {
|
|
|
104
106
|
if (!threadConfig.lastMessages && !threadConfig.semanticRecall) {
|
|
105
107
|
return {
|
|
106
108
|
messages: [],
|
|
107
|
-
uiMessages: []
|
|
109
|
+
uiMessages: [],
|
|
110
|
+
threadId
|
|
108
111
|
};
|
|
109
112
|
}
|
|
110
113
|
const messages = await this.query({
|
|
@@ -116,7 +119,11 @@ var Memory = class extends memory.MastraMemory {
|
|
|
116
119
|
threadConfig: config
|
|
117
120
|
});
|
|
118
121
|
this.logger.debug(`Remembered message history includes ${messages.messages.length} messages.`);
|
|
119
|
-
return
|
|
122
|
+
return {
|
|
123
|
+
threadId,
|
|
124
|
+
messages: messages.messages,
|
|
125
|
+
uiMessages: messages.uiMessages
|
|
126
|
+
};
|
|
120
127
|
}
|
|
121
128
|
async getThreadById({ threadId }) {
|
|
122
129
|
return this.storage.__getThreadById({ threadId });
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { deepMerge } from '@mastra/core';
|
|
2
2
|
import { MastraMemory } from '@mastra/core/memory';
|
|
3
|
-
import { z } from 'zod';
|
|
4
3
|
import { embed } from 'ai';
|
|
4
|
+
import { z } from 'zod';
|
|
5
5
|
|
|
6
6
|
// src/index.ts
|
|
7
7
|
var updateWorkingMemoryTool = {
|
|
@@ -9,7 +9,7 @@ var updateWorkingMemoryTool = {
|
|
|
9
9
|
parameters: z.object({
|
|
10
10
|
memory: z.string().describe("The XML-formatted working memory content to store")
|
|
11
11
|
}),
|
|
12
|
-
execute: async (params
|
|
12
|
+
execute: async (params) => {
|
|
13
13
|
const { context, threadId, memory } = params;
|
|
14
14
|
if (!threadId || !memory) {
|
|
15
15
|
throw new Error("Thread ID and Memory instance are required for working memory updates");
|
|
@@ -30,6 +30,8 @@ var updateWorkingMemoryTool = {
|
|
|
30
30
|
return { success: true };
|
|
31
31
|
}
|
|
32
32
|
};
|
|
33
|
+
|
|
34
|
+
// src/index.ts
|
|
33
35
|
var Memory = class extends MastraMemory {
|
|
34
36
|
constructor(config = {}) {
|
|
35
37
|
super({ name: "Memory", ...config });
|
|
@@ -102,7 +104,8 @@ var Memory = class extends MastraMemory {
|
|
|
102
104
|
if (!threadConfig.lastMessages && !threadConfig.semanticRecall) {
|
|
103
105
|
return {
|
|
104
106
|
messages: [],
|
|
105
|
-
uiMessages: []
|
|
107
|
+
uiMessages: [],
|
|
108
|
+
threadId
|
|
106
109
|
};
|
|
107
110
|
}
|
|
108
111
|
const messages = await this.query({
|
|
@@ -114,7 +117,11 @@ var Memory = class extends MastraMemory {
|
|
|
114
117
|
threadConfig: config
|
|
115
118
|
});
|
|
116
119
|
this.logger.debug(`Remembered message history includes ${messages.messages.length} messages.`);
|
|
117
|
-
return
|
|
120
|
+
return {
|
|
121
|
+
threadId,
|
|
122
|
+
messages: messages.messages,
|
|
123
|
+
uiMessages: messages.uiMessages
|
|
124
|
+
};
|
|
118
125
|
}
|
|
119
126
|
async getThreadById({ threadId }) {
|
|
120
127
|
return this.storage.__getThreadById({ threadId });
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mastra/memory",
|
|
3
|
-
"version": "0.2.0-alpha.
|
|
3
|
+
"version": "0.2.0-alpha.5",
|
|
4
4
|
"description": "",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
"postgres": "^3.4.5",
|
|
50
50
|
"redis": "^4.7.0",
|
|
51
51
|
"zod": "^3.24.1",
|
|
52
|
-
"@mastra/core": "^0.5.0-alpha.
|
|
52
|
+
"@mastra/core": "^0.5.0-alpha.5"
|
|
53
53
|
},
|
|
54
54
|
"devDependencies": {
|
|
55
55
|
"@microsoft/api-extractor": "^7.49.2",
|
package/src/index.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { deepMerge } from '@mastra/core';
|
|
2
|
-
import type { CoreMessage, CoreTool } from '@mastra/core';
|
|
2
|
+
import type { AiMessageType, CoreMessage, CoreTool } from '@mastra/core';
|
|
3
3
|
import { MastraMemory } from '@mastra/core/memory';
|
|
4
4
|
import type { MessageType, MemoryConfig, SharedMemoryConfig, StorageThreadType } from '@mastra/core/memory';
|
|
5
5
|
import type { StorageGetMessagesArg } from '@mastra/core/storage';
|
|
6
|
-
import { updateWorkingMemoryTool } from './tools/working-memory';
|
|
7
6
|
import { embed } from 'ai';
|
|
8
7
|
import type { Message as AiMessage } from 'ai';
|
|
8
|
+
import { updateWorkingMemoryTool } from './tools/working-memory';
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
11
|
* Concrete implementation of MastraMemory that adds support for thread configuration
|
|
@@ -28,7 +28,7 @@ export class Memory extends MastraMemory {
|
|
|
28
28
|
threadId,
|
|
29
29
|
selectBy,
|
|
30
30
|
threadConfig,
|
|
31
|
-
}: StorageGetMessagesArg): Promise<{ messages: CoreMessage[]; uiMessages:
|
|
31
|
+
}: StorageGetMessagesArg): Promise<{ messages: CoreMessage[]; uiMessages: AiMessageType[] }> {
|
|
32
32
|
let vectorResults:
|
|
33
33
|
| null
|
|
34
34
|
| {
|
|
@@ -114,14 +114,19 @@ export class Memory extends MastraMemory {
|
|
|
114
114
|
threadId: string;
|
|
115
115
|
vectorMessageSearch?: string;
|
|
116
116
|
config?: MemoryConfig;
|
|
117
|
-
}) {
|
|
117
|
+
}): Promise<{
|
|
118
|
+
threadId: string;
|
|
119
|
+
messages: CoreMessage[];
|
|
120
|
+
uiMessages: AiMessageType[];
|
|
121
|
+
}> {
|
|
118
122
|
const threadConfig = this.getMergedThreadConfig(config || {});
|
|
119
123
|
|
|
120
124
|
if (!threadConfig.lastMessages && !threadConfig.semanticRecall) {
|
|
121
125
|
return {
|
|
122
126
|
messages: [],
|
|
123
127
|
uiMessages: [],
|
|
124
|
-
|
|
128
|
+
threadId,
|
|
129
|
+
};
|
|
125
130
|
}
|
|
126
131
|
|
|
127
132
|
const messages = await this.query({
|
|
@@ -134,7 +139,11 @@ export class Memory extends MastraMemory {
|
|
|
134
139
|
});
|
|
135
140
|
|
|
136
141
|
this.logger.debug(`Remembered message history includes ${messages.messages.length} messages.`);
|
|
137
|
-
return
|
|
142
|
+
return {
|
|
143
|
+
threadId,
|
|
144
|
+
messages: messages.messages,
|
|
145
|
+
uiMessages: messages.uiMessages,
|
|
146
|
+
};
|
|
138
147
|
}
|
|
139
148
|
|
|
140
149
|
async getThreadById({ threadId }: { threadId: string }): Promise<StorageThreadType | null> {
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import type { CoreTool } from '@mastra/core';
|
|
2
|
-
import type { ToolExecutionOptions } from 'ai';
|
|
3
2
|
import { z } from 'zod';
|
|
4
3
|
|
|
5
4
|
export const updateWorkingMemoryTool: CoreTool = {
|
|
@@ -7,7 +6,7 @@ export const updateWorkingMemoryTool: CoreTool = {
|
|
|
7
6
|
parameters: z.object({
|
|
8
7
|
memory: z.string().describe('The XML-formatted working memory content to store'),
|
|
9
8
|
}),
|
|
10
|
-
execute: async (params: any
|
|
9
|
+
execute: async (params: any) => {
|
|
11
10
|
const { context, threadId, memory } = params;
|
|
12
11
|
if (!threadId || !memory) {
|
|
13
12
|
throw new Error('Thread ID and Memory instance are required for working memory updates');
|