@mastra/memory 0.2.9 → 0.2.10-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/.turbo/turbo-build.log +8 -8
- package/CHANGELOG.md +18 -0
- package/{LICENSE → LICENSE.md} +3 -1
- package/dist/index.cjs +13 -0
- package/dist/index.js +13 -0
- package/package.json +4 -4
- package/src/index.ts +15 -5
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,29 +1,29 @@
|
|
|
1
1
|
|
|
2
|
-
> @mastra/memory@0.2.
|
|
2
|
+
> @mastra/memory@0.2.10-alpha.1 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.2.
|
|
6
|
+
> @mastra/memory@0.2.10-alpha.1 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 8934ms
|
|
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 12151ms
|
|
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[32m15.
|
|
24
|
+
[32mCJS[39m [1mdist/index.cjs [22m[32m15.71 KB[39m
|
|
25
25
|
[32mCJS[39m [1mdist/processors/index.cjs [22m[32m5.54 KB[39m
|
|
26
|
-
[32mCJS[39m ⚡️ Build success in
|
|
27
|
-
[32mESM[39m [1mdist/index.js [22m[32m14.82 KB[39m
|
|
26
|
+
[32mCJS[39m ⚡️ Build success in 593ms
|
|
28
27
|
[32mESM[39m [1mdist/processors/index.js [22m[32m5.33 KB[39m
|
|
29
|
-
[32mESM[39m
|
|
28
|
+
[32mESM[39m [1mdist/index.js [22m[32m15.44 KB[39m
|
|
29
|
+
[32mESM[39m ⚡️ Build success in 596ms
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
# @mastra/memory
|
|
2
2
|
|
|
3
|
+
## 0.2.10-alpha.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 37bb612: Add Elastic-2.0 licensing for packages
|
|
8
|
+
- Updated dependencies [32e7b71]
|
|
9
|
+
- Updated dependencies [37bb612]
|
|
10
|
+
- @mastra/core@0.8.3-alpha.1
|
|
11
|
+
|
|
12
|
+
## 0.2.10-alpha.0
|
|
13
|
+
|
|
14
|
+
### Patch Changes
|
|
15
|
+
|
|
16
|
+
- f6f7345: Added missing createdAt field to UI messages in memory
|
|
17
|
+
- 359b089: Allowed explicitly disabling vector/embedder in Memory by passing vector: false or options.semanticRecall: false
|
|
18
|
+
- Updated dependencies [359b089]
|
|
19
|
+
- @mastra/core@0.8.3-alpha.0
|
|
20
|
+
|
|
3
21
|
## 0.2.9
|
|
4
22
|
|
|
5
23
|
### Patch Changes
|
package/{LICENSE → LICENSE.md}
RENAMED
package/dist/index.cjs
CHANGED
|
@@ -91,6 +91,11 @@ var Memory = class extends memory.MastraMemory {
|
|
|
91
91
|
const { indexName } = await this.createEmbeddingIndex(dimension);
|
|
92
92
|
await Promise.all(
|
|
93
93
|
embeddings.map(async (embedding) => {
|
|
94
|
+
if (typeof this.vector === `undefined`) {
|
|
95
|
+
throw new Error(
|
|
96
|
+
`Tried to query vector index ${indexName} but this Memory instance doesn't have an attached vector db.`
|
|
97
|
+
);
|
|
98
|
+
}
|
|
94
99
|
vectorResults.push(
|
|
95
100
|
...await this.vector.query({
|
|
96
101
|
indexName,
|
|
@@ -213,6 +218,9 @@ var Memory = class extends memory.MastraMemory {
|
|
|
213
218
|
const cached = this.embeddingCache.get(key);
|
|
214
219
|
if (cached) return cached;
|
|
215
220
|
const chunks = this.chunkText(content);
|
|
221
|
+
if (typeof this.embedder === `undefined`) {
|
|
222
|
+
throw new Error(`Tried to embed message content but this Memory instance doesn't have an attached embedder.`);
|
|
223
|
+
}
|
|
216
224
|
const isFastEmbed = this.embedder.provider === `fastembed`;
|
|
217
225
|
if (isFastEmbed && this.firstEmbed instanceof Promise) {
|
|
218
226
|
await this.firstEmbed;
|
|
@@ -249,6 +257,11 @@ var Memory = class extends memory.MastraMemory {
|
|
|
249
257
|
if (typeof indexName === `undefined`) {
|
|
250
258
|
indexName = this.createEmbeddingIndex(dimension).then((result2) => result2.indexName);
|
|
251
259
|
}
|
|
260
|
+
if (typeof this.vector === `undefined`) {
|
|
261
|
+
throw new Error(
|
|
262
|
+
`Tried to upsert embeddings to index ${indexName} but this Memory instance doesn't have an attached vector db.`
|
|
263
|
+
);
|
|
264
|
+
}
|
|
252
265
|
await this.vector.upsert({
|
|
253
266
|
indexName: await indexName,
|
|
254
267
|
vectors: embeddings,
|
package/dist/index.js
CHANGED
|
@@ -84,6 +84,11 @@ var Memory = class extends MastraMemory {
|
|
|
84
84
|
const { indexName } = await this.createEmbeddingIndex(dimension);
|
|
85
85
|
await Promise.all(
|
|
86
86
|
embeddings.map(async (embedding) => {
|
|
87
|
+
if (typeof this.vector === `undefined`) {
|
|
88
|
+
throw new Error(
|
|
89
|
+
`Tried to query vector index ${indexName} but this Memory instance doesn't have an attached vector db.`
|
|
90
|
+
);
|
|
91
|
+
}
|
|
87
92
|
vectorResults.push(
|
|
88
93
|
...await this.vector.query({
|
|
89
94
|
indexName,
|
|
@@ -206,6 +211,9 @@ var Memory = class extends MastraMemory {
|
|
|
206
211
|
const cached = this.embeddingCache.get(key);
|
|
207
212
|
if (cached) return cached;
|
|
208
213
|
const chunks = this.chunkText(content);
|
|
214
|
+
if (typeof this.embedder === `undefined`) {
|
|
215
|
+
throw new Error(`Tried to embed message content but this Memory instance doesn't have an attached embedder.`);
|
|
216
|
+
}
|
|
209
217
|
const isFastEmbed = this.embedder.provider === `fastembed`;
|
|
210
218
|
if (isFastEmbed && this.firstEmbed instanceof Promise) {
|
|
211
219
|
await this.firstEmbed;
|
|
@@ -242,6 +250,11 @@ var Memory = class extends MastraMemory {
|
|
|
242
250
|
if (typeof indexName === `undefined`) {
|
|
243
251
|
indexName = this.createEmbeddingIndex(dimension).then((result2) => result2.indexName);
|
|
244
252
|
}
|
|
253
|
+
if (typeof this.vector === `undefined`) {
|
|
254
|
+
throw new Error(
|
|
255
|
+
`Tried to upsert embeddings to index ${indexName} but this Memory instance doesn't have an attached vector db.`
|
|
256
|
+
);
|
|
257
|
+
}
|
|
245
258
|
await this.vector.upsert({
|
|
246
259
|
indexName: await indexName,
|
|
247
260
|
vectors: embeddings,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mastra/memory",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.10-alpha.1",
|
|
4
4
|
"description": "",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
},
|
|
31
31
|
"keywords": [],
|
|
32
32
|
"author": "",
|
|
33
|
-
"license": "
|
|
33
|
+
"license": "Elastic-2.0",
|
|
34
34
|
"dependencies": {
|
|
35
35
|
"@upstash/redis": "^1.34.5",
|
|
36
36
|
"ai": "^4.2.2",
|
|
@@ -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.8.
|
|
44
|
+
"@mastra/core": "^0.8.3-alpha.1"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
47
|
"@ai-sdk/openai": "^1.3.3",
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
"typescript": "^5.8.2",
|
|
54
54
|
"typescript-eslint": "^8.26.1",
|
|
55
55
|
"vitest": "^3.0.9",
|
|
56
|
-
"@internal/lint": "0.0.
|
|
56
|
+
"@internal/lint": "0.0.2-alpha.0"
|
|
57
57
|
},
|
|
58
58
|
"scripts": {
|
|
59
59
|
"check": "tsc --noEmit",
|
package/src/index.ts
CHANGED
|
@@ -82,6 +82,12 @@ export class Memory extends MastraMemory {
|
|
|
82
82
|
|
|
83
83
|
await Promise.all(
|
|
84
84
|
embeddings.map(async embedding => {
|
|
85
|
+
if (typeof this.vector === `undefined`) {
|
|
86
|
+
throw new Error(
|
|
87
|
+
`Tried to query vector index ${indexName} but this Memory instance doesn't have an attached vector db.`,
|
|
88
|
+
);
|
|
89
|
+
}
|
|
90
|
+
|
|
85
91
|
vectorResults.push(
|
|
86
92
|
...(await this.vector.query({
|
|
87
93
|
indexName,
|
|
@@ -219,11 +225,6 @@ export class Memory extends MastraMemory {
|
|
|
219
225
|
|
|
220
226
|
async deleteThread(threadId: string): Promise<void> {
|
|
221
227
|
await this.storage.__deleteThread({ threadId });
|
|
222
|
-
|
|
223
|
-
// TODO: Also clean up vector storage if it exists
|
|
224
|
-
// if (this.vector) {
|
|
225
|
-
// await this.vector.deleteThread(threadId); ?? filter by thread attributes and delete all returned messages?
|
|
226
|
-
// }
|
|
227
228
|
}
|
|
228
229
|
|
|
229
230
|
private chunkText(text: string, size = 4096) {
|
|
@@ -268,6 +269,9 @@ export class Memory extends MastraMemory {
|
|
|
268
269
|
if (cached) return cached;
|
|
269
270
|
const chunks = this.chunkText(content);
|
|
270
271
|
|
|
272
|
+
if (typeof this.embedder === `undefined`) {
|
|
273
|
+
throw new Error(`Tried to embed message content but this Memory instance doesn't have an attached embedder.`);
|
|
274
|
+
}
|
|
271
275
|
// for fastembed multiple initial calls to embed will fail if the model hasn't been downloaded yet.
|
|
272
276
|
const isFastEmbed = this.embedder.provider === `fastembed`;
|
|
273
277
|
if (isFastEmbed && this.firstEmbed instanceof Promise) {
|
|
@@ -322,6 +326,12 @@ export class Memory extends MastraMemory {
|
|
|
322
326
|
indexName = this.createEmbeddingIndex(dimension).then(result => result.indexName);
|
|
323
327
|
}
|
|
324
328
|
|
|
329
|
+
if (typeof this.vector === `undefined`) {
|
|
330
|
+
throw new Error(
|
|
331
|
+
`Tried to upsert embeddings to index ${indexName} but this Memory instance doesn't have an attached vector db.`,
|
|
332
|
+
);
|
|
333
|
+
}
|
|
334
|
+
|
|
325
335
|
await this.vector.upsert({
|
|
326
336
|
indexName: await indexName,
|
|
327
337
|
vectors: embeddings,
|