@mastra/memory 0.2.6-alpha.3 → 0.2.6-alpha.4
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 +11 -11
- package/CHANGELOG.md +7 -0
- package/dist/_tsup-dts-rollup.d.cts +1 -1
- package/dist/_tsup-dts-rollup.d.ts +1 -1
- package/dist/index.cjs +4 -1
- package/dist/index.js +4 -1
- package/package.json +1 -1
- package/src/index.ts +10 -2
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,27 +1,27 @@
|
|
|
1
1
|
|
|
2
|
-
> @mastra/memory@0.2.6-alpha.
|
|
2
|
+
> @mastra/memory@0.2.6-alpha.4 build /home/runner/work/mastra/mastra/packages/memory
|
|
3
3
|
> pnpm run check && tsup src/index.ts --format esm,cjs --experimental-dts --clean --treeshake=smallest --splitting
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
> @mastra/memory@0.2.6-alpha.
|
|
6
|
+
> @mastra/memory@0.2.6-alpha.4 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.4.0
|
|
12
12
|
[34mTSC[39m Build start
|
|
13
|
-
[32mTSC[39m ⚡️ Build success in
|
|
13
|
+
[32mTSC[39m ⚡️ Build success in 13659ms
|
|
14
14
|
[34mDTS[39m Build start
|
|
15
15
|
[34mCLI[39m Target: es2022
|
|
16
|
-
[34mCLI[39m Cleaning output folder
|
|
17
|
-
[34mESM[39m Build start
|
|
18
|
-
[34mCJS[39m Build start
|
|
19
16
|
Analysis will use the bundled TypeScript version 5.8.2
|
|
20
17
|
[36mWriting package typings: /home/runner/work/mastra/mastra/packages/memory/dist/_tsup-dts-rollup.d.ts[39m
|
|
21
18
|
Analysis will use the bundled TypeScript version 5.8.2
|
|
22
19
|
[36mWriting package typings: /home/runner/work/mastra/mastra/packages/memory/dist/_tsup-dts-rollup.d.cts[39m
|
|
23
|
-
[32mDTS[39m ⚡️ Build success in
|
|
24
|
-
[
|
|
25
|
-
[
|
|
26
|
-
[
|
|
27
|
-
[32mESM[39m
|
|
20
|
+
[32mDTS[39m ⚡️ Build success in 5635ms
|
|
21
|
+
[34mCLI[39m Cleaning output folder
|
|
22
|
+
[34mESM[39m Build start
|
|
23
|
+
[34mCJS[39m Build start
|
|
24
|
+
[32mESM[39m [1mdist/index.js [22m[32m13.53 KB[39m
|
|
25
|
+
[32mESM[39m ⚡️ Build success in 315ms
|
|
26
|
+
[32mCJS[39m [1mdist/index.cjs [22m[32m13.56 KB[39m
|
|
27
|
+
[32mCJS[39m ⚡️ Build success in 316ms
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# @mastra/memory
|
|
2
2
|
|
|
3
|
+
## 0.2.6-alpha.4
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 394dfad: Removed working memory tool calls from thread history after the working memory has been updated. This is to prevent updates from polluting the context history and confusing agents. They should only see the most recent copy of working memory.
|
|
8
|
+
Also made memory.getWorkingMemory() public since it's useful for testing, debugging, and building UIs.
|
|
9
|
+
|
|
3
10
|
## 0.2.6-alpha.3
|
|
4
11
|
|
|
5
12
|
### Patch Changes
|
|
@@ -52,7 +52,7 @@ export declare class Memory extends MastraMemory {
|
|
|
52
52
|
}): Promise<MessageType[]>;
|
|
53
53
|
protected mutateMessagesToHideWorkingMemory(messages: MessageType[]): void;
|
|
54
54
|
protected parseWorkingMemory(text: string): string | null;
|
|
55
|
-
|
|
55
|
+
getWorkingMemory({ threadId }: {
|
|
56
56
|
threadId: string;
|
|
57
57
|
}): Promise<string | null>;
|
|
58
58
|
private saveWorkingMemory;
|
|
@@ -52,7 +52,7 @@ export declare class Memory extends MastraMemory {
|
|
|
52
52
|
}): Promise<MessageType[]>;
|
|
53
53
|
protected mutateMessagesToHideWorkingMemory(messages: MessageType[]): void;
|
|
54
54
|
protected parseWorkingMemory(text: string): string | null;
|
|
55
|
-
|
|
55
|
+
getWorkingMemory({ threadId }: {
|
|
56
56
|
threadId: string;
|
|
57
57
|
}): Promise<string | null>;
|
|
58
58
|
private saveWorkingMemory;
|
package/dist/index.cjs
CHANGED
|
@@ -223,7 +223,7 @@ var Memory = class extends memory.MastraMemory {
|
|
|
223
223
|
}
|
|
224
224
|
mutateMessagesToHideWorkingMemory(messages) {
|
|
225
225
|
const workingMemoryRegex = /<working_memory>([^]*?)<\/working_memory>/g;
|
|
226
|
-
for (const message of messages) {
|
|
226
|
+
for (const [index, message] of messages.entries()) {
|
|
227
227
|
if (typeof message?.content === `string`) {
|
|
228
228
|
message.content = message.content.replace(workingMemoryRegex, ``).trim();
|
|
229
229
|
} else if (Array.isArray(message?.content)) {
|
|
@@ -231,6 +231,9 @@ var Memory = class extends memory.MastraMemory {
|
|
|
231
231
|
if (content.type === `text`) {
|
|
232
232
|
content.text = content.text.replace(workingMemoryRegex, ``).trim();
|
|
233
233
|
}
|
|
234
|
+
if ((content.type === `tool-call` || content.type === `tool-result`) && content.toolName === `updateWorkingMemory`) {
|
|
235
|
+
delete messages[index];
|
|
236
|
+
}
|
|
234
237
|
}
|
|
235
238
|
}
|
|
236
239
|
}
|
package/dist/index.js
CHANGED
|
@@ -221,7 +221,7 @@ var Memory = class extends MastraMemory {
|
|
|
221
221
|
}
|
|
222
222
|
mutateMessagesToHideWorkingMemory(messages) {
|
|
223
223
|
const workingMemoryRegex = /<working_memory>([^]*?)<\/working_memory>/g;
|
|
224
|
-
for (const message of messages) {
|
|
224
|
+
for (const [index, message] of messages.entries()) {
|
|
225
225
|
if (typeof message?.content === `string`) {
|
|
226
226
|
message.content = message.content.replace(workingMemoryRegex, ``).trim();
|
|
227
227
|
} else if (Array.isArray(message?.content)) {
|
|
@@ -229,6 +229,9 @@ var Memory = class extends MastraMemory {
|
|
|
229
229
|
if (content.type === `text`) {
|
|
230
230
|
content.text = content.text.replace(workingMemoryRegex, ``).trim();
|
|
231
231
|
}
|
|
232
|
+
if ((content.type === `tool-call` || content.type === `tool-result`) && content.toolName === `updateWorkingMemory`) {
|
|
233
|
+
delete messages[index];
|
|
234
|
+
}
|
|
232
235
|
}
|
|
233
236
|
}
|
|
234
237
|
}
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -281,7 +281,8 @@ export class Memory extends MastraMemory {
|
|
|
281
281
|
|
|
282
282
|
protected mutateMessagesToHideWorkingMemory(messages: MessageType[]) {
|
|
283
283
|
const workingMemoryRegex = /<working_memory>([^]*?)<\/working_memory>/g;
|
|
284
|
-
|
|
284
|
+
|
|
285
|
+
for (const [index, message] of messages.entries()) {
|
|
285
286
|
if (typeof message?.content === `string`) {
|
|
286
287
|
message.content = message.content.replace(workingMemoryRegex, ``).trim();
|
|
287
288
|
} else if (Array.isArray(message?.content)) {
|
|
@@ -289,6 +290,13 @@ export class Memory extends MastraMemory {
|
|
|
289
290
|
if (content.type === `text`) {
|
|
290
291
|
content.text = content.text.replace(workingMemoryRegex, ``).trim();
|
|
291
292
|
}
|
|
293
|
+
|
|
294
|
+
if (
|
|
295
|
+
(content.type === `tool-call` || content.type === `tool-result`) &&
|
|
296
|
+
content.toolName === `updateWorkingMemory`
|
|
297
|
+
) {
|
|
298
|
+
delete messages[index];
|
|
299
|
+
}
|
|
292
300
|
}
|
|
293
301
|
}
|
|
294
302
|
}
|
|
@@ -308,7 +316,7 @@ export class Memory extends MastraMemory {
|
|
|
308
316
|
return null;
|
|
309
317
|
}
|
|
310
318
|
|
|
311
|
-
|
|
319
|
+
public async getWorkingMemory({ threadId }: { threadId: string }): Promise<string | null> {
|
|
312
320
|
if (!this.threadConfig.workingMemory?.enabled) return null;
|
|
313
321
|
|
|
314
322
|
// Get thread from storage
|