@mastra/upstash 1.2.2-alpha.0 → 1.3.0-alpha.0
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 +64 -0
- package/dist/docs/SKILL.md +1 -1
- package/dist/docs/assets/SOURCE_MAP.json +1 -1
- package/dist/docs/references/docs-memory-working-memory.md +5 -5
- package/dist/docs/references/docs-rag-vector-databases.md +7 -2
- package/dist/index.cjs +8 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +9 -4
- package/dist/index.js.map +1 -1
- package/dist/storage/domains/memory/index.d.ts.map +1 -1
- package/package.json +14 -13
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,69 @@
|
|
|
1
1
|
# @mastra/upstash
|
|
2
2
|
|
|
3
|
+
## 1.3.0-alpha.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- Added exact metadata filtering to message history queries across Memory APIs and supported storage providers. ([#19991](https://github.com/mastra-ai/mastra/pull/19991))
|
|
8
|
+
|
|
9
|
+
```ts
|
|
10
|
+
const messages = await memory.recall({
|
|
11
|
+
threadId: 'thread-1',
|
|
12
|
+
filter: {
|
|
13
|
+
metadata: {
|
|
14
|
+
status: 'done',
|
|
15
|
+
priority: 'high',
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
});
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
Multiple fields use AND semantics. Supported values are strings, finite numbers, booleans, and `null`.
|
|
22
|
+
|
|
23
|
+
### Patch Changes
|
|
24
|
+
|
|
25
|
+
- Updated dependencies [[`0dca9d0`](https://github.com/mastra-ai/mastra/commit/0dca9d0b1356024a53b72ea6f040db528b126caa)]:
|
|
26
|
+
- @mastra/core@1.54.0-alpha.0
|
|
27
|
+
- @mastra/redis@1.3.0-alpha.0
|
|
28
|
+
|
|
29
|
+
## 1.2.2
|
|
30
|
+
|
|
31
|
+
### Patch Changes
|
|
32
|
+
|
|
33
|
+
- Add optional `batchId`, `datasetId`, and `datasetItemId` fields to persisted scores so saved baseline scores can be grouped as one scoring pass and joined back to the dataset items they came from. ([#18331](https://github.com/mastra-ai/mastra/pull/18331))
|
|
34
|
+
- `scoreTrace()` accepts top-level `batchId`, `datasetId`, and `datasetItemId` when persisting a score for a stored trace.
|
|
35
|
+
- `ScoreRowData` and score save payloads now include nullable `batchId`, `datasetId`, and `datasetItemId`.
|
|
36
|
+
- Built-in stores with explicit score schema or attribute mappings now persist these provenance fields on saved scores.
|
|
37
|
+
- D1, DSQL, MSSQL, and Upstash score stores now apply additive provenance migrations or deterministic score ordering for persisted score reads.
|
|
38
|
+
|
|
39
|
+
```ts
|
|
40
|
+
await scoreTrace({
|
|
41
|
+
storage,
|
|
42
|
+
scorer,
|
|
43
|
+
target: { traceId },
|
|
44
|
+
batchId: 'baseline-batch-1',
|
|
45
|
+
datasetId,
|
|
46
|
+
datasetItemId,
|
|
47
|
+
});
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
- Added optional `organizationId` and `projectId` fields to scores for multi-tenant isolation. Scores can now be saved with tenancy metadata and the `listScoresBy*` methods accept a `filters` option to scope results by organization and project. ([#18331](https://github.com/mastra-ai/mastra/pull/18331))
|
|
51
|
+
|
|
52
|
+
```ts
|
|
53
|
+
await storage.saveScore({ ...score, organizationId: 'org-a', projectId: 'proj-1' });
|
|
54
|
+
|
|
55
|
+
const result = await storage.listScoresByScorerId({
|
|
56
|
+
scorerId,
|
|
57
|
+
filters: { organizationId: 'org-a', projectId: 'proj-1' },
|
|
58
|
+
});
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
`projectId` identifies the project scope, separate from `resourceId` which continues to mean the agent memory resource.
|
|
62
|
+
|
|
63
|
+
- Updated dependencies [[`700619b`](https://github.com/mastra-ai/mastra/commit/700619b61d572e592cbaaf758121d168844ca4d2), [`0f69865`](https://github.com/mastra-ai/mastra/commit/0f69865aced225d98eac812e22699dc445ee18cb), [`9250acd`](https://github.com/mastra-ai/mastra/commit/9250acd1357f0f1f33d0dcca16f9655084c58eca), [`0c3d4bc`](https://github.com/mastra-ai/mastra/commit/0c3d4bcae13ea3699d379403e6f350d5cf4efe9f), [`cc440a3`](https://github.com/mastra-ai/mastra/commit/cc440a39400d8ce06655462b26c1666a1b3d4320), [`6a61846`](https://github.com/mastra-ai/mastra/commit/6a61846eeda29fb714549b70f1bee2bf6b141c44), [`215f9b0`](https://github.com/mastra-ai/mastra/commit/215f9b0f3f3f6fc165edad360582dd4d3d7ea748), [`17369b2`](https://github.com/mastra-ai/mastra/commit/17369b25250561e9ed994ae509be1d15bfb33bcb), [`c64c2a8`](https://github.com/mastra-ai/mastra/commit/c64c2a8503a50252f9ca6b8e8c54cadee31b92a2), [`bcae929`](https://github.com/mastra-ai/mastra/commit/bcae929945cbf265bd9f327cc715ecafa072b5b9), [`ea6327b`](https://github.com/mastra-ai/mastra/commit/ea6327ba2d63ca647804bc97b347e03a58617162), [`3439fa8`](https://github.com/mastra-ai/mastra/commit/3439fa836ecfcaa257b40c20b30ac2a8be22e9ea), [`85107f2`](https://github.com/mastra-ai/mastra/commit/85107f2758b527147fccbedff962961927c2d3b8), [`b33822e`](https://github.com/mastra-ai/mastra/commit/b33822e8d470884954b02f7b0745407ee4ef74b1), [`06e2680`](https://github.com/mastra-ai/mastra/commit/06e26806b51d2cbd858afdc66daa2b86ff3ba64a), [`06ff9e0`](https://github.com/mastra-ai/mastra/commit/06ff9e0befd1d642ab87ff749285ee4091205c7e), [`d5c11e3`](https://github.com/mastra-ai/mastra/commit/d5c11e3ba5045969caa7272a7bd1fd141c93ab6c), [`7f5e1ff`](https://github.com/mastra-ai/mastra/commit/7f5e1ff695a92f672bb3976363925d1e9136b54a), [`ff80671`](https://github.com/mastra-ai/mastra/commit/ff8067185e208b27198b4e5b71803013175c3643), [`b8375c1`](https://github.com/mastra-ai/mastra/commit/b8375c1f8fe905df8ae2ae9a893bb365f17aec4e), [`dab1257`](https://github.com/mastra-ai/mastra/commit/dab1257b64e4ed576dc5038bb7a3f7072338bc9f), [`1240f05`](https://github.com/mastra-ai/mastra/commit/1240f051c8e5371f1c014448bf37b1a1b9a05e47), [`705ff39`](https://github.com/mastra-ai/mastra/commit/705ff3969e57214ff2fdaf3815d751dd558886ed), [`e6fbd5b`](https://github.com/mastra-ai/mastra/commit/e6fbd5bfdc28e92c0c0433f29aa1bc152d3430f6), [`215f9b0`](https://github.com/mastra-ai/mastra/commit/215f9b0f3f3f6fc165edad360582dd4d3d7ea748), [`24c10d3`](https://github.com/mastra-ai/mastra/commit/24c10d333e6649ac06075903aeeee13a933db3b3), [`24c10d3`](https://github.com/mastra-ai/mastra/commit/24c10d333e6649ac06075903aeeee13a933db3b3), [`24c10d3`](https://github.com/mastra-ai/mastra/commit/24c10d333e6649ac06075903aeeee13a933db3b3), [`6f2026c`](https://github.com/mastra-ai/mastra/commit/6f2026cdf114ff1e21e49133ca774ec7d5085059), [`24c10d3`](https://github.com/mastra-ai/mastra/commit/24c10d333e6649ac06075903aeeee13a933db3b3), [`215f9b0`](https://github.com/mastra-ai/mastra/commit/215f9b0f3f3f6fc165edad360582dd4d3d7ea748), [`215f9b0`](https://github.com/mastra-ai/mastra/commit/215f9b0f3f3f6fc165edad360582dd4d3d7ea748), [`003f35d`](https://github.com/mastra-ai/mastra/commit/003f35d19e07b23b4bacc591c8bc0c59b42124ae), [`f890eda`](https://github.com/mastra-ai/mastra/commit/f890eda2c8a2ae83d9b30bc6d85842f93b6c266b), [`1340fb7`](https://github.com/mastra-ai/mastra/commit/1340fb76262a3ca062130aa71859f07257a0a5a4)]:
|
|
64
|
+
- @mastra/core@1.49.0
|
|
65
|
+
- @mastra/redis@1.2.2
|
|
66
|
+
|
|
3
67
|
## 1.2.2-alpha.0
|
|
4
68
|
|
|
5
69
|
### Patch Changes
|
package/dist/docs/SKILL.md
CHANGED
|
@@ -3,7 +3,7 @@ name: mastra-upstash
|
|
|
3
3
|
description: Documentation for @mastra/upstash. Use when working with @mastra/upstash APIs, configuration, or implementation.
|
|
4
4
|
metadata:
|
|
5
5
|
package: "@mastra/upstash"
|
|
6
|
-
version: "1.
|
|
6
|
+
version: "1.3.0-alpha.0"
|
|
7
7
|
---
|
|
8
8
|
|
|
9
9
|
## When to use
|
|
@@ -10,6 +10,8 @@ This is useful for maintaining ongoing state that's always relevant and should a
|
|
|
10
10
|
|
|
11
11
|
If you use [Observational Memory](https://mastra.ai/docs/memory/observational-memory), `observationalMemory.observation.manageWorkingMemory` lets OM update working memory for the agent.
|
|
12
12
|
|
|
13
|
+
> **📹 Watch:** Watch [Mastra working memory](https://www.youtube.com/watch?v=UMy_JHLf1n8\&pp=ygUVbWFzdHJhIHdvcmtpbmcgbWVtb3J5) to see how agents keep persistent user context available across interactions.
|
|
14
|
+
|
|
13
15
|
Working memory can persist at two different scopes:
|
|
14
16
|
|
|
15
17
|
- **Resource-scoped** (default): Memory persists across all conversation threads for the same user
|
|
@@ -43,9 +45,7 @@ const agent = new Agent({
|
|
|
43
45
|
|
|
44
46
|
## How it works
|
|
45
47
|
|
|
46
|
-
Working memory is a block of Markdown text that the agent is able to update over time to store continuously relevant information
|
|
47
|
-
|
|
48
|
-
[YouTube video player](https://www.youtube-nocookie.com/embed/UMy_JHLf1n8)
|
|
48
|
+
Working memory is a block of Markdown text that the agent is able to update over time to store continuously relevant information.
|
|
49
49
|
|
|
50
50
|
## Memory persistence scopes
|
|
51
51
|
|
|
@@ -399,11 +399,11 @@ const response = await agent.generate('What do you know about me?', {
|
|
|
399
399
|
|
|
400
400
|
## Opt in to state signals (experimental)
|
|
401
401
|
|
|
402
|
-
By default, working memory reaches the model as part of the system message. You can opt into delivering it as a [state signal](https://mastra.ai/docs/agents/signals) instead by setting `useStateSignals: true`:
|
|
402
|
+
By default, working memory reaches the model as part of the system message. You can opt into delivering it as a [state signal](https://mastra.ai/docs/long-running-agents/signals) instead by setting `useStateSignals: true`:
|
|
403
403
|
|
|
404
404
|
```typescript
|
|
405
405
|
const memory = new Memory({
|
|
406
|
-
storage: new LibSQLStore({ url: 'file:./mastra.db' }),
|
|
406
|
+
storage: new LibSQLStore({ id: 'mastra-storage', url: 'file:./mastra.db' }),
|
|
407
407
|
options: {
|
|
408
408
|
workingMemory: {
|
|
409
409
|
enabled: true,
|
|
@@ -14,7 +14,7 @@ import { MongoDBVector } from '@mastra/mongodb'
|
|
|
14
14
|
const store = new MongoDBVector({
|
|
15
15
|
id: 'mongodb-vector',
|
|
16
16
|
uri: process.env.MONGODB_URI,
|
|
17
|
-
dbName: process.env.
|
|
17
|
+
dbName: process.env.MONGODB_DB_NAME,
|
|
18
18
|
})
|
|
19
19
|
await store.createIndex({
|
|
20
20
|
indexName: 'myCollection',
|
|
@@ -27,10 +27,14 @@ await store.upsert({
|
|
|
27
27
|
})
|
|
28
28
|
```
|
|
29
29
|
|
|
30
|
-
### Using MongoDB Atlas Vector
|
|
30
|
+
### Using MongoDB Atlas Vector Search
|
|
31
31
|
|
|
32
32
|
For detailed setup instructions and best practices, see the [official MongoDB Atlas Vector Search documentation](https://www.mongodb.com/docs/atlas/atlas-vector-search/vector-search-overview/?utm_campaign=devrel\&utm_source=third-party-content\&utm_medium=cta\&utm_content=mastra-docs).
|
|
33
33
|
|
|
34
|
+
### Using VoyageAI with MongoDB
|
|
35
|
+
|
|
36
|
+
MongoDB works seamlessly with VoyageAI's embedding models, which are optimized for retrieval tasks. For complete examples and specialized models, see the [VoyageAI embeddings documentation](https://mastra.ai/models/embeddings) and [MongoDB vector reference](https://mastra.ai/reference/vectors/mongodb).
|
|
37
|
+
|
|
34
38
|
**PgVector**:
|
|
35
39
|
|
|
36
40
|
```ts
|
|
@@ -359,6 +363,7 @@ The dimension size must match the output dimension of your chosen embedding mode
|
|
|
359
363
|
|
|
360
364
|
- `OpenAI text-embedding-3-small`: 1536 dimensions (or custom, e.g., 256)
|
|
361
365
|
- `Cohere embed-multilingual-v3`: 1024 dimensions
|
|
366
|
+
- `VoyageAI voyage-3.5`: 1024 dimensions (or custom: 256, 512, 1024, 2048)
|
|
362
367
|
- `Google gemini-embedding-001`: 768 dimensions (or custom)
|
|
363
368
|
|
|
364
369
|
> **Warning:** Index dimensions can't be changed after creation. To use a different model, delete and recreate the index with the new dimension size.
|
package/dist/index.cjs
CHANGED
|
@@ -868,6 +868,7 @@ var StoreMemoryUpstash = class extends storage.MemoryStorage {
|
|
|
868
868
|
}
|
|
869
869
|
const perPage = storage.normalizePerPage(perPageInput, 40);
|
|
870
870
|
const { offset, perPage: perPageForResponse } = storage.calculatePagination(page, perPageInput, perPage);
|
|
871
|
+
const metadataFilter = storage.validateStorageMetadataFilter(filter?.metadata);
|
|
871
872
|
try {
|
|
872
873
|
if (page < 0) {
|
|
873
874
|
throw new error.MastraError(
|
|
@@ -928,6 +929,9 @@ var StoreMemoryUpstash = class extends storage.MemoryStorage {
|
|
|
928
929
|
(msg) => new Date(msg.createdAt),
|
|
929
930
|
filter?.dateRange
|
|
930
931
|
);
|
|
932
|
+
messagesData = messagesData.filter(
|
|
933
|
+
(message) => storage.storageMessageMatchesMetadataFilter(message.content, metadataFilter)
|
|
934
|
+
);
|
|
931
935
|
messagesData = this._sortMessages(messagesData, field, direction);
|
|
932
936
|
const total = messagesData.length;
|
|
933
937
|
const start = offset;
|
|
@@ -950,9 +954,10 @@ var StoreMemoryUpstash = class extends storage.MemoryStorage {
|
|
|
950
954
|
const list = new agent.MessageList().add(allMessages, "memory");
|
|
951
955
|
let finalMessages = list.get.all.db();
|
|
952
956
|
finalMessages = this._sortMessages(finalMessages, field, direction);
|
|
953
|
-
const returnedThreadMessageIds = new Set(
|
|
954
|
-
|
|
955
|
-
|
|
957
|
+
const returnedThreadMessageIds = new Set(
|
|
958
|
+
finalMessages.filter((message) => message.threadId === threadId).map((message) => message.id)
|
|
959
|
+
);
|
|
960
|
+
const hasMore = perPageInput !== false && (metadataFilter || returnedThreadMessageIds.size < total) && offset + paginatedMessages.length < total;
|
|
956
961
|
return {
|
|
957
962
|
messages: finalMessages,
|
|
958
963
|
total,
|