@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.
@@ -1,29 +1,29 @@
1
1
 
2
- > @mastra/memory@0.2.9-alpha.0 build /home/runner/work/mastra/mastra/packages/memory
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.9-alpha.0 check /home/runner/work/mastra/mastra/packages/memory
6
+ > @mastra/memory@0.2.10-alpha.1 check /home/runner/work/mastra/mastra/packages/memory
7
7
  > tsc --noEmit
8
8
 
9
9
  CLI Building entry: src/index.ts, src/processors/index.ts
10
10
  CLI Using tsconfig: tsconfig.json
11
11
  CLI tsup v8.4.0
12
12
  TSC Build start
13
- TSC ⚡️ Build success in 8412ms
13
+ TSC ⚡️ Build success in 8934ms
14
14
  DTS Build start
15
15
  CLI Target: es2022
16
16
  Analysis will use the bundled TypeScript version 5.8.2
17
17
  Writing package typings: /home/runner/work/mastra/mastra/packages/memory/dist/_tsup-dts-rollup.d.ts
18
18
  Analysis will use the bundled TypeScript version 5.8.2
19
19
  Writing package typings: /home/runner/work/mastra/mastra/packages/memory/dist/_tsup-dts-rollup.d.cts
20
- DTS ⚡️ Build success in 11032ms
20
+ DTS ⚡️ Build success in 12151ms
21
21
  CLI Cleaning output folder
22
22
  ESM Build start
23
23
  CJS Build start
24
- CJS dist/index.cjs 15.09 KB
24
+ CJS dist/index.cjs 15.71 KB
25
25
  CJS dist/processors/index.cjs 5.54 KB
26
- CJS ⚡️ Build success in 898ms
27
- ESM dist/index.js 14.82 KB
26
+ CJS ⚡️ Build success in 593ms
28
27
  ESM dist/processors/index.js 5.33 KB
29
- ESM ⚡️ Build success in 899ms
28
+ ESM dist/index.js 15.44 KB
29
+ ESM ⚡️ 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
@@ -1,4 +1,6 @@
1
- Elastic License 2.0 (ELv2)
1
+ # Elastic License 2.0 (ELv2)
2
+
3
+ Copyright (c) 2025 Mastra AI, Inc.
2
4
 
3
5
  **Acceptance**
4
6
  By using the software, you agree to all of the terms and conditions below.
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.9",
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": "ISC",
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.2"
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.1"
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,