@mastra/upstash 1.2.1 → 1.2.2
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 +76 -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 +4 -0
- package/dist/docs/references/docs-rag-retrieval.md +2 -0
- package/dist/docs/references/docs-rag-vector-databases.md +2 -0
- package/dist/docs/references/reference-storage-upstash.md +2 -0
- package/dist/docs/references/reference-vectors-upstash.md +2 -0
- package/dist/index.cjs +28 -9
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +28 -9
- package/dist/index.js.map +1 -1
- package/dist/storage/domains/scores/index.d.ts +9 -5
- package/dist/storage/domains/scores/index.d.ts.map +1 -1
- package/package.json +6 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,81 @@
|
|
|
1
1
|
# @mastra/upstash
|
|
2
2
|
|
|
3
|
+
## 1.2.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 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))
|
|
8
|
+
- `scoreTrace()` accepts top-level `batchId`, `datasetId`, and `datasetItemId` when persisting a score for a stored trace.
|
|
9
|
+
- `ScoreRowData` and score save payloads now include nullable `batchId`, `datasetId`, and `datasetItemId`.
|
|
10
|
+
- Built-in stores with explicit score schema or attribute mappings now persist these provenance fields on saved scores.
|
|
11
|
+
- D1, DSQL, MSSQL, and Upstash score stores now apply additive provenance migrations or deterministic score ordering for persisted score reads.
|
|
12
|
+
|
|
13
|
+
```ts
|
|
14
|
+
await scoreTrace({
|
|
15
|
+
storage,
|
|
16
|
+
scorer,
|
|
17
|
+
target: { traceId },
|
|
18
|
+
batchId: 'baseline-batch-1',
|
|
19
|
+
datasetId,
|
|
20
|
+
datasetItemId,
|
|
21
|
+
});
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
- 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))
|
|
25
|
+
|
|
26
|
+
```ts
|
|
27
|
+
await storage.saveScore({ ...score, organizationId: 'org-a', projectId: 'proj-1' });
|
|
28
|
+
|
|
29
|
+
const result = await storage.listScoresByScorerId({
|
|
30
|
+
scorerId,
|
|
31
|
+
filters: { organizationId: 'org-a', projectId: 'proj-1' },
|
|
32
|
+
});
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
`projectId` identifies the project scope, separate from `resourceId` which continues to mean the agent memory resource.
|
|
36
|
+
|
|
37
|
+
- 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)]:
|
|
38
|
+
- @mastra/core@1.49.0
|
|
39
|
+
- @mastra/redis@1.2.2
|
|
40
|
+
|
|
41
|
+
## 1.2.2-alpha.0
|
|
42
|
+
|
|
43
|
+
### Patch Changes
|
|
44
|
+
|
|
45
|
+
- 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))
|
|
46
|
+
- `scoreTrace()` accepts top-level `batchId`, `datasetId`, and `datasetItemId` when persisting a score for a stored trace.
|
|
47
|
+
- `ScoreRowData` and score save payloads now include nullable `batchId`, `datasetId`, and `datasetItemId`.
|
|
48
|
+
- Built-in stores with explicit score schema or attribute mappings now persist these provenance fields on saved scores.
|
|
49
|
+
- D1, DSQL, MSSQL, and Upstash score stores now apply additive provenance migrations or deterministic score ordering for persisted score reads.
|
|
50
|
+
|
|
51
|
+
```ts
|
|
52
|
+
await scoreTrace({
|
|
53
|
+
storage,
|
|
54
|
+
scorer,
|
|
55
|
+
target: { traceId },
|
|
56
|
+
batchId: 'baseline-batch-1',
|
|
57
|
+
datasetId,
|
|
58
|
+
datasetItemId,
|
|
59
|
+
});
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
- 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))
|
|
63
|
+
|
|
64
|
+
```ts
|
|
65
|
+
await storage.saveScore({ ...score, organizationId: 'org-a', projectId: 'proj-1' });
|
|
66
|
+
|
|
67
|
+
const result = await storage.listScoresByScorerId({
|
|
68
|
+
scorerId,
|
|
69
|
+
filters: { organizationId: 'org-a', projectId: 'proj-1' },
|
|
70
|
+
});
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
`projectId` identifies the project scope, separate from `resourceId` which continues to mean the agent memory resource.
|
|
74
|
+
|
|
75
|
+
- Updated dependencies [[`9250acd`](https://github.com/mastra-ai/mastra/commit/9250acd1357f0f1f33d0dcca16f9655084c58eca), [`215f9b0`](https://github.com/mastra-ai/mastra/commit/215f9b0f3f3f6fc165edad360582dd4d3d7ea748), [`c64c2a8`](https://github.com/mastra-ai/mastra/commit/c64c2a8503a50252f9ca6b8e8c54cadee31b92a2), [`06e2680`](https://github.com/mastra-ai/mastra/commit/06e26806b51d2cbd858afdc66daa2b86ff3ba64a), [`1240f05`](https://github.com/mastra-ai/mastra/commit/1240f051c8e5371f1c014448bf37b1a1b9a05e47), [`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), [`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)]:
|
|
76
|
+
- @mastra/core@1.49.0-alpha.5
|
|
77
|
+
- @mastra/redis@1.2.2-alpha.0
|
|
78
|
+
|
|
3
79
|
## 1.2.1
|
|
4
80
|
|
|
5
81
|
### Patch Changes
|
package/dist/docs/SKILL.md
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
> Discover all available pages from the documentation index: https://mastra.ai/llms.txt
|
|
2
|
+
|
|
1
3
|
# Working Memory
|
|
2
4
|
|
|
3
5
|
While [message history](https://mastra.ai/docs/memory/message-history) and [semantic recall](https://mastra.ai/docs/memory/semantic-recall) help agents remember conversations, working memory allows them to maintain persistent information about users across interactions.
|
|
@@ -6,6 +8,8 @@ Think of it as the agent's active thoughts or scratchpad – the key information
|
|
|
6
8
|
|
|
7
9
|
This is useful for maintaining ongoing state that's always relevant and should always be available to the agent.
|
|
8
10
|
|
|
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
|
+
|
|
9
13
|
Working memory can persist at two different scopes:
|
|
10
14
|
|
|
11
15
|
- **Resource-scoped** (default): Memory persists across all conversation threads for the same user
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
> Discover all available pages from the documentation index: https://mastra.ai/llms.txt
|
|
2
|
+
|
|
1
3
|
# Storing embeddings in a vector database
|
|
2
4
|
|
|
3
5
|
After generating embeddings, you need to store them in a database that supports vector similarity search. Mastra provides a consistent interface for storing and querying embeddings across various vector databases.
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
> Discover all available pages from the documentation index: https://mastra.ai/llms.txt
|
|
2
|
+
|
|
1
3
|
# Upstash vector store
|
|
2
4
|
|
|
3
5
|
The UpstashVector class provides vector search using [Upstash Vector](https://upstash.com/vector), a serverless vector database service that provides vector similarity search with metadata filtering capabilities and hybrid search support.
|
package/dist/index.cjs
CHANGED
|
@@ -1456,6 +1456,16 @@ var StoreMemoryUpstash = class extends storage.MemoryStorage {
|
|
|
1456
1456
|
function transformScoreRow(row) {
|
|
1457
1457
|
return storage.transformScoreRow(row);
|
|
1458
1458
|
}
|
|
1459
|
+
function matchesTenancy(row, filters) {
|
|
1460
|
+
if (filters?.organizationId !== void 0 && row.organizationId !== filters.organizationId) return false;
|
|
1461
|
+
if (filters?.projectId !== void 0 && row.projectId !== filters.projectId) return false;
|
|
1462
|
+
return true;
|
|
1463
|
+
}
|
|
1464
|
+
function compareScoresByCreatedAtDesc(a, b) {
|
|
1465
|
+
const createdAtDiff = new Date(b.createdAt).getTime() - new Date(a.createdAt).getTime();
|
|
1466
|
+
if (createdAtDiff !== 0) return createdAtDiff;
|
|
1467
|
+
return String(b.id ?? "").localeCompare(String(a.id ?? ""));
|
|
1468
|
+
}
|
|
1459
1469
|
var ScoresUpstash = class extends storage.ScoresStorage {
|
|
1460
1470
|
client;
|
|
1461
1471
|
#db;
|
|
@@ -1495,7 +1505,8 @@ var ScoresUpstash = class extends storage.ScoresStorage {
|
|
|
1495
1505
|
entityId,
|
|
1496
1506
|
entityType,
|
|
1497
1507
|
source,
|
|
1498
|
-
pagination = { page: 0, perPage: 20 }
|
|
1508
|
+
pagination = { page: 0, perPage: 20 },
|
|
1509
|
+
filters
|
|
1499
1510
|
}) {
|
|
1500
1511
|
const pattern = `${storage.TABLE_SCORERS}:*`;
|
|
1501
1512
|
const keys = await this.#db.scanKeys(pattern);
|
|
@@ -1525,13 +1536,14 @@ var ScoresUpstash = class extends storage.ScoresStorage {
|
|
|
1525
1536
|
if (entityId && row.entityId !== entityId) return false;
|
|
1526
1537
|
if (entityType && row.entityType !== entityType) return false;
|
|
1527
1538
|
if (source && row.source !== source) return false;
|
|
1539
|
+
if (!matchesTenancy(row, filters)) return false;
|
|
1528
1540
|
return true;
|
|
1529
1541
|
});
|
|
1530
1542
|
const perPage = storage.normalizePerPage(perPageInput, 100);
|
|
1531
1543
|
const { offset: start, perPage: perPageForResponse } = storage.calculatePagination(page, perPageInput, perPage);
|
|
1532
1544
|
const end = perPageInput === false ? filtered.length : start + perPage;
|
|
1533
1545
|
const total = filtered.length;
|
|
1534
|
-
const paged = filtered.slice(start, end);
|
|
1546
|
+
const paged = [...filtered].sort(compareScoresByCreatedAtDesc).slice(start, end);
|
|
1535
1547
|
const scores = paged.map((row) => transformScoreRow(row));
|
|
1536
1548
|
return {
|
|
1537
1549
|
scores,
|
|
@@ -1592,7 +1604,8 @@ var ScoresUpstash = class extends storage.ScoresStorage {
|
|
|
1592
1604
|
}
|
|
1593
1605
|
async listScoresByRunId({
|
|
1594
1606
|
runId,
|
|
1595
|
-
pagination = { page: 0, perPage: 20 }
|
|
1607
|
+
pagination = { page: 0, perPage: 20 },
|
|
1608
|
+
filters
|
|
1596
1609
|
}) {
|
|
1597
1610
|
const pattern = `${storage.TABLE_SCORERS}:*`;
|
|
1598
1611
|
const keys = await this.#db.scanKeys(pattern);
|
|
@@ -1616,12 +1629,14 @@ var ScoresUpstash = class extends storage.ScoresStorage {
|
|
|
1616
1629
|
}
|
|
1617
1630
|
}
|
|
1618
1631
|
return raw;
|
|
1619
|
-
}).filter(
|
|
1632
|
+
}).filter(
|
|
1633
|
+
(row) => !!row && typeof row === "object" && row.runId === runId && matchesTenancy(row, filters)
|
|
1634
|
+
);
|
|
1620
1635
|
const total = filtered.length;
|
|
1621
1636
|
const perPage = storage.normalizePerPage(perPageInput, 100);
|
|
1622
1637
|
const { offset: start, perPage: perPageForResponse } = storage.calculatePagination(page, perPageInput, perPage);
|
|
1623
1638
|
const end = perPageInput === false ? filtered.length : start + perPage;
|
|
1624
|
-
const paged = filtered.slice(start, end);
|
|
1639
|
+
const paged = [...filtered].sort(compareScoresByCreatedAtDesc).slice(start, end);
|
|
1625
1640
|
const scores = paged.map((row) => transformScoreRow(row));
|
|
1626
1641
|
return {
|
|
1627
1642
|
scores,
|
|
@@ -1636,7 +1651,8 @@ var ScoresUpstash = class extends storage.ScoresStorage {
|
|
|
1636
1651
|
async listScoresByEntityId({
|
|
1637
1652
|
entityId,
|
|
1638
1653
|
entityType,
|
|
1639
|
-
pagination = { page: 0, perPage: 20 }
|
|
1654
|
+
pagination = { page: 0, perPage: 20 },
|
|
1655
|
+
filters
|
|
1640
1656
|
}) {
|
|
1641
1657
|
const pattern = `${storage.TABLE_SCORERS}:*`;
|
|
1642
1658
|
const keys = await this.#db.scanKeys(pattern);
|
|
@@ -1664,13 +1680,14 @@ var ScoresUpstash = class extends storage.ScoresStorage {
|
|
|
1664
1680
|
if (!row || typeof row !== "object") return false;
|
|
1665
1681
|
if (row.entityId !== entityId) return false;
|
|
1666
1682
|
if (entityType && row.entityType !== entityType) return false;
|
|
1683
|
+
if (!matchesTenancy(row, filters)) return false;
|
|
1667
1684
|
return true;
|
|
1668
1685
|
});
|
|
1669
1686
|
const total = filtered.length;
|
|
1670
1687
|
const perPage = storage.normalizePerPage(perPageInput, 100);
|
|
1671
1688
|
const { offset: start, perPage: perPageForResponse } = storage.calculatePagination(page, perPageInput, perPage);
|
|
1672
1689
|
const end = perPageInput === false ? filtered.length : start + perPage;
|
|
1673
|
-
const paged = filtered.slice(start, end);
|
|
1690
|
+
const paged = [...filtered].sort(compareScoresByCreatedAtDesc).slice(start, end);
|
|
1674
1691
|
const scores = paged.map((row) => transformScoreRow(row));
|
|
1675
1692
|
return {
|
|
1676
1693
|
scores,
|
|
@@ -1685,7 +1702,8 @@ var ScoresUpstash = class extends storage.ScoresStorage {
|
|
|
1685
1702
|
async listScoresBySpan({
|
|
1686
1703
|
traceId,
|
|
1687
1704
|
spanId,
|
|
1688
|
-
pagination = { page: 0, perPage: 20 }
|
|
1705
|
+
pagination = { page: 0, perPage: 20 },
|
|
1706
|
+
filters
|
|
1689
1707
|
}) {
|
|
1690
1708
|
const pattern = `${storage.TABLE_SCORERS}:*`;
|
|
1691
1709
|
const keys = await this.#db.scanKeys(pattern);
|
|
@@ -1713,13 +1731,14 @@ var ScoresUpstash = class extends storage.ScoresStorage {
|
|
|
1713
1731
|
if (!row || typeof row !== "object") return false;
|
|
1714
1732
|
if (row.traceId !== traceId) return false;
|
|
1715
1733
|
if (row.spanId !== spanId) return false;
|
|
1734
|
+
if (!matchesTenancy(row, filters)) return false;
|
|
1716
1735
|
return true;
|
|
1717
1736
|
});
|
|
1718
1737
|
const total = filtered.length;
|
|
1719
1738
|
const perPage = storage.normalizePerPage(perPageInput, 100);
|
|
1720
1739
|
const { offset: start, perPage: perPageForResponse } = storage.calculatePagination(page, perPageInput, perPage);
|
|
1721
1740
|
const end = perPageInput === false ? filtered.length : start + perPage;
|
|
1722
|
-
const paged = filtered.slice(start, end);
|
|
1741
|
+
const paged = [...filtered].sort(compareScoresByCreatedAtDesc).slice(start, end);
|
|
1723
1742
|
const scores = paged.map((row) => transformScoreRow(row));
|
|
1724
1743
|
return {
|
|
1725
1744
|
scores,
|