@mastra/memory 1.0.0-beta.7 → 1.0.0-beta.8
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/CHANGELOG.md +40 -0
- package/dist/index.cjs +0 -19
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +0 -19
- package/dist/index.js.map +1 -1
- package/package.json +5 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,45 @@
|
|
|
1
1
|
# @mastra/memory
|
|
2
2
|
|
|
3
|
+
## 1.0.0-beta.8
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Add storage composition to MastraStorage ([#11401](https://github.com/mastra-ai/mastra/pull/11401))
|
|
8
|
+
|
|
9
|
+
`MastraStorage` can now compose storage domains from different adapters. Use it when you need different databases for different purposes - for example, PostgreSQL for memory and workflows, but a different database for observability.
|
|
10
|
+
|
|
11
|
+
```typescript
|
|
12
|
+
import { MastraStorage } from '@mastra/core/storage';
|
|
13
|
+
import { MemoryPG, WorkflowsPG, ScoresPG } from '@mastra/pg';
|
|
14
|
+
import { MemoryLibSQL } from '@mastra/libsql';
|
|
15
|
+
|
|
16
|
+
// Compose domains from different stores
|
|
17
|
+
const storage = new MastraStorage({
|
|
18
|
+
id: 'composite',
|
|
19
|
+
domains: {
|
|
20
|
+
memory: new MemoryLibSQL({ url: 'file:./local.db' }),
|
|
21
|
+
workflows: new WorkflowsPG({ connectionString: process.env.DATABASE_URL }),
|
|
22
|
+
scores: new ScoresPG({ connectionString: process.env.DATABASE_URL }),
|
|
23
|
+
},
|
|
24
|
+
});
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
**Breaking changes:**
|
|
28
|
+
- `storage.supports` property no longer exists
|
|
29
|
+
- `StorageSupports` type is no longer exported from `@mastra/core/storage`
|
|
30
|
+
|
|
31
|
+
All stores now support the same features. For domain availability, use `getStore()`:
|
|
32
|
+
|
|
33
|
+
```typescript
|
|
34
|
+
const store = await storage.getStore('memory');
|
|
35
|
+
if (store) {
|
|
36
|
+
// domain is available
|
|
37
|
+
}
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
- Updated dependencies [[`3d93a15`](https://github.com/mastra-ai/mastra/commit/3d93a15796b158c617461c8b98bede476ebb43e2), [`efe406a`](https://github.com/mastra-ai/mastra/commit/efe406a1353c24993280ebc2ed61dd9f65b84b26), [`119e5c6`](https://github.com/mastra-ai/mastra/commit/119e5c65008f3e5cfca954eefc2eb85e3bf40da4), [`74e504a`](https://github.com/mastra-ai/mastra/commit/74e504a3b584eafd2f198001c6a113bbec589fd3), [`e33fdbd`](https://github.com/mastra-ai/mastra/commit/e33fdbd07b33920d81e823122331b0c0bee0bb59), [`929f69c`](https://github.com/mastra-ai/mastra/commit/929f69c3436fa20dd0f0e2f7ebe8270bd82a1529), [`8a73529`](https://github.com/mastra-ai/mastra/commit/8a73529ca01187f604b1f3019d0a725ac63ae55f)]:
|
|
41
|
+
- @mastra/core@1.0.0-beta.16
|
|
42
|
+
|
|
3
43
|
## 1.0.0-beta.7
|
|
4
44
|
|
|
5
45
|
### Patch Changes
|
package/dist/index.cjs
CHANGED
|
@@ -14633,20 +14633,6 @@ var Memory = class extends memory.MastraMemory {
|
|
|
14633
14633
|
);
|
|
14634
14634
|
}
|
|
14635
14635
|
}
|
|
14636
|
-
checkStorageFeatureSupport(config) {
|
|
14637
|
-
const resourceScope = typeof config.semanticRecall === "object" && config.semanticRecall.scope !== "thread" || // resource scope is now default
|
|
14638
|
-
config.semanticRecall === true;
|
|
14639
|
-
if (resourceScope && !this.storage.supports.selectByIncludeResourceScope) {
|
|
14640
|
-
throw new Error(
|
|
14641
|
-
`Memory error: Attached storage adapter "${this.storage.name || "unknown"}" doesn't support semanticRecall: { scope: "resource" } yet and currently only supports per-thread semantic recall.`
|
|
14642
|
-
);
|
|
14643
|
-
}
|
|
14644
|
-
if (config.workingMemory?.enabled && config.workingMemory.scope === `resource` && !this.storage.supports.resourceWorkingMemory) {
|
|
14645
|
-
throw new Error(
|
|
14646
|
-
`Memory error: Attached storage adapter "${this.storage.name || "unknown"}" doesn't support workingMemory: { scope: "resource" } yet and currently only supports per-thread working memory. Supported adapters: LibSQL, PostgreSQL, Upstash.`
|
|
14647
|
-
);
|
|
14648
|
-
}
|
|
14649
|
-
}
|
|
14650
14636
|
async recall(args) {
|
|
14651
14637
|
const { threadId, resourceId, perPage: perPageArg, page, orderBy, threadConfig, vectorSearchString, filter: filter3 } = args;
|
|
14652
14638
|
const config = this.getMergedThreadConfig(threadConfig || {});
|
|
@@ -14664,7 +14650,6 @@ var Memory = class extends memory.MastraMemory {
|
|
|
14664
14650
|
workingMemoryEnabled: config.workingMemory?.enabled,
|
|
14665
14651
|
semanticRecallEnabled: Boolean(config.semanticRecall)
|
|
14666
14652
|
});
|
|
14667
|
-
this.checkStorageFeatureSupport(config);
|
|
14668
14653
|
const defaultRange = DEFAULT_MESSAGE_RANGE;
|
|
14669
14654
|
const defaultTopK = DEFAULT_TOP_K;
|
|
14670
14655
|
const vectorConfig = typeof config?.semanticRecall === `boolean` ? {
|
|
@@ -14742,7 +14727,6 @@ var Memory = class extends memory.MastraMemory {
|
|
|
14742
14727
|
}) {
|
|
14743
14728
|
const config = this.getMergedThreadConfig(memoryConfig || {});
|
|
14744
14729
|
if (config.workingMemory?.enabled) {
|
|
14745
|
-
this.checkStorageFeatureSupport(config);
|
|
14746
14730
|
const scope = config.workingMemory.scope || "resource";
|
|
14747
14731
|
if (scope === "resource" && resourceId) {
|
|
14748
14732
|
const memoryStore = await this.getMemoryStore();
|
|
@@ -14803,7 +14787,6 @@ var Memory = class extends memory.MastraMemory {
|
|
|
14803
14787
|
if (!config.workingMemory?.enabled) {
|
|
14804
14788
|
throw new Error("Working memory is not enabled for this memory instance");
|
|
14805
14789
|
}
|
|
14806
|
-
this.checkStorageFeatureSupport(config);
|
|
14807
14790
|
const scope = config.workingMemory.scope || "resource";
|
|
14808
14791
|
if (scope === "resource" && !resourceId) {
|
|
14809
14792
|
throw new Error(
|
|
@@ -14846,7 +14829,6 @@ var Memory = class extends memory.MastraMemory {
|
|
|
14846
14829
|
if (!config.workingMemory?.enabled) {
|
|
14847
14830
|
throw new Error("Working memory is not enabled for this memory instance");
|
|
14848
14831
|
}
|
|
14849
|
-
this.checkStorageFeatureSupport(config);
|
|
14850
14832
|
const mutexKey = memoryConfig?.workingMemory?.scope === `resource` ? `resource-${resourceId}` : `thread-${threadId}`;
|
|
14851
14833
|
const mutex = this.updateWorkingMemoryMutexes.has(mutexKey) ? this.updateWorkingMemoryMutexes.get(mutexKey) : new asyncMutex.Mutex();
|
|
14852
14834
|
this.updateWorkingMemoryMutexes.set(mutexKey, mutex);
|
|
@@ -15088,7 +15070,6 @@ ${workingMemory}`;
|
|
|
15088
15070
|
if (!config.workingMemory?.enabled) {
|
|
15089
15071
|
return null;
|
|
15090
15072
|
}
|
|
15091
|
-
this.checkStorageFeatureSupport(config);
|
|
15092
15073
|
const scope = config.workingMemory.scope || "resource";
|
|
15093
15074
|
let workingMemoryData = null;
|
|
15094
15075
|
if (scope === "resource" && !resourceId) {
|