@mastra/pg 1.8.4-alpha.3 → 1.8.5-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 +29 -0
- package/dist/docs/SKILL.md +1 -1
- package/dist/docs/assets/SOURCE_MAP.json +1 -1
- package/dist/docs/references/docs-memory-semantic-recall.md +28 -19
- package/dist/docs/references/docs-memory-storage.md +4 -4
- package/dist/docs/references/reference-storage-dynamodb.md +1 -1
- package/dist/index.cjs +10 -10
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +10 -10
- package/dist/index.js.map +1 -1
- package/package.json +5 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,34 @@
|
|
|
1
1
|
# @mastra/pg
|
|
2
2
|
|
|
3
|
+
## 1.8.5-alpha.0
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Fixed thread and message timestamp handling to use timezone-aware columns (TIMESTAMPTZ) for sorting and date range filtering. Previously, ORDER BY and date range queries used TIMESTAMP columns which could produce incorrect ordering when the PostgreSQL server timezone differs from UTC. Also fixed timestamp values passed to UPDATE queries to use Date objects instead of ISO strings, preventing timezone information from being stripped when stored in TIMESTAMP columns. ([#14297](https://github.com/mastra-ai/mastra/pull/14297))
|
|
8
|
+
|
|
9
|
+
- Updated dependencies [[`9140989`](https://github.com/mastra-ai/mastra/commit/91409890e83f4f1d9c1b39223f1af91a6a53b549), [`d7c98cf`](https://github.com/mastra-ai/mastra/commit/d7c98cfc9d75baba9ecbf1a8835b5183d0a0aec8), [`acf5fbc`](https://github.com/mastra-ai/mastra/commit/acf5fbcb890dc7ca7167bec386ce5874dfadb997), [`24ca2ae`](https://github.com/mastra-ai/mastra/commit/24ca2ae57538ec189fabb9daee6175ad27035853), [`0762516`](https://github.com/mastra-ai/mastra/commit/07625167e029a8268ea7aaf0402416e6d8832874), [`2de3d36`](https://github.com/mastra-ai/mastra/commit/2de3d36932b7f73ad26bc403f7da26cfe89e903e), [`d3736cb`](https://github.com/mastra-ai/mastra/commit/d3736cb9ce074d2b8e8b00218a01f790fe81a1b4), [`c627366`](https://github.com/mastra-ai/mastra/commit/c6273666f9ef4c8c617c68b7d07fe878a322f85c)]:
|
|
10
|
+
- @mastra/core@1.18.1-alpha.1
|
|
11
|
+
|
|
12
|
+
## 1.8.4
|
|
13
|
+
|
|
14
|
+
### Patch Changes
|
|
15
|
+
|
|
16
|
+
- The internal architecture of observational memory has been refactored. The public API and behavior remain unchanged. ([#14453](https://github.com/mastra-ai/mastra/pull/14453))
|
|
17
|
+
|
|
18
|
+
- Add `getReviewSummary()` to experiments storage for aggregating review status counts ([#14649](https://github.com/mastra-ai/mastra/pull/14649))
|
|
19
|
+
|
|
20
|
+
Query experiment results grouped by experiment ID, returning counts of `needs-review`, `reviewed`, and `complete` items in a single query instead of fetching all results client-side.
|
|
21
|
+
|
|
22
|
+
```ts
|
|
23
|
+
const summary = await storage.experiments.getReviewSummary();
|
|
24
|
+
// [{ experimentId: 'exp-1', needsReview: 3, reviewed: 5, complete: 2, total: 10 }, ...]
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
- Added `scorerIds` persistence for datasets. The `scorerIds` field is now stored and retrieved correctly when creating or updating datasets. ([#14783](https://github.com/mastra-ai/mastra/pull/14783))
|
|
28
|
+
|
|
29
|
+
- Updated dependencies [[`dc514a8`](https://github.com/mastra-ai/mastra/commit/dc514a83dba5f719172dddfd2c7b858e4943d067), [`e333b77`](https://github.com/mastra-ai/mastra/commit/e333b77e2d76ba57ccec1818e08cebc1993469ff), [`dc9fc19`](https://github.com/mastra-ai/mastra/commit/dc9fc19da4437f6b508cc355f346a8856746a76b), [`60a224d`](https://github.com/mastra-ai/mastra/commit/60a224dd497240e83698cfa5bfd02e3d1d854844), [`fbf22a7`](https://github.com/mastra-ai/mastra/commit/fbf22a7ad86bcb50dcf30459f0d075e51ddeb468), [`f16d92c`](https://github.com/mastra-ai/mastra/commit/f16d92c677a119a135cebcf7e2b9f51ada7a9df4), [`949b7bf`](https://github.com/mastra-ai/mastra/commit/949b7bfd4e40f2b2cba7fef5eb3f108a02cfe938), [`404fea1`](https://github.com/mastra-ai/mastra/commit/404fea13042181f0b0c73a101392ac87c79ceae2), [`ebf5047`](https://github.com/mastra-ai/mastra/commit/ebf5047e825c38a1a356f10b214c1d4260dfcd8d), [`12c647c`](https://github.com/mastra-ai/mastra/commit/12c647cf3a26826eb72d40b42e3c8356ceae16ed), [`d084b66`](https://github.com/mastra-ai/mastra/commit/d084b6692396057e83c086b954c1857d20b58a14), [`79c699a`](https://github.com/mastra-ai/mastra/commit/79c699acf3cd8a77e11c55530431f48eb48456e9), [`62757b6`](https://github.com/mastra-ai/mastra/commit/62757b6db6e8bb86569d23ad0b514178f57053f8), [`675f15b`](https://github.com/mastra-ai/mastra/commit/675f15b7eaeea649158d228ea635be40480c584d), [`b174c63`](https://github.com/mastra-ai/mastra/commit/b174c63a093108d4e53b9bc89a078d9f66202b3f), [`819f03c`](https://github.com/mastra-ai/mastra/commit/819f03c25823373b32476413bd76be28a5d8705a), [`04160ee`](https://github.com/mastra-ai/mastra/commit/04160eedf3130003cf842ad08428c8ff69af4cc1), [`2c27503`](https://github.com/mastra-ai/mastra/commit/2c275032510d131d2cde47f99953abf0fe02c081), [`424a1df`](https://github.com/mastra-ai/mastra/commit/424a1df7bee59abb5c83717a54807fdd674a6224), [`3d70b0b`](https://github.com/mastra-ai/mastra/commit/3d70b0b3524d817173ad870768f259c06d61bd23), [`eef7cb2`](https://github.com/mastra-ai/mastra/commit/eef7cb2abe7ef15951e2fdf792a5095c6c643333), [`260fe12`](https://github.com/mastra-ai/mastra/commit/260fe1295fe7354e39d6def2775e0797a7a277f0), [`12c88a6`](https://github.com/mastra-ai/mastra/commit/12c88a6e32bf982c2fe0c6af62e65a3414519a75), [`43595bf`](https://github.com/mastra-ai/mastra/commit/43595bf7b8df1a6edce7a23b445b5124d2a0b473), [`78670e9`](https://github.com/mastra-ai/mastra/commit/78670e97e76d7422cf7025faf371b2aeafed860d), [`e8a5b0b`](https://github.com/mastra-ai/mastra/commit/e8a5b0b9bc94d12dee4150095512ca27a288d778), [`3b45a13`](https://github.com/mastra-ai/mastra/commit/3b45a138d09d040779c0aba1edbbfc1b57442d23), [`d400e7c`](https://github.com/mastra-ai/mastra/commit/d400e7c8b8d7afa6ba2c71769eace4048e3cef8e), [`f58d1a7`](https://github.com/mastra-ai/mastra/commit/f58d1a7a457588a996c3ecb53201a68f3d28c432), [`a49a929`](https://github.com/mastra-ai/mastra/commit/a49a92904968b4fc67e01effee8c7c8d0464ba85), [`8127d96`](https://github.com/mastra-ai/mastra/commit/8127d96280492e335d49b244501088dfdd59a8f1)]:
|
|
30
|
+
- @mastra/core@1.18.0
|
|
31
|
+
|
|
3
32
|
## 1.8.4-alpha.3
|
|
4
33
|
|
|
5
34
|
### Patch Changes
|
package/dist/docs/SKILL.md
CHANGED
|
@@ -18,18 +18,33 @@ After getting a response from the LLM, all new messages (user, assistant, and to
|
|
|
18
18
|
|
|
19
19
|
## Quickstart
|
|
20
20
|
|
|
21
|
-
Semantic recall is
|
|
21
|
+
Semantic recall is disabled by default. To enable it, set `semanticRecall: true` in `options` and provide a `vector` store and `embedder`:
|
|
22
22
|
|
|
23
23
|
```typescript
|
|
24
24
|
import { Agent } from '@mastra/core/agent'
|
|
25
25
|
import { Memory } from '@mastra/memory'
|
|
26
|
+
import { LibSQLStore, LibSQLVector } from '@mastra/libsql'
|
|
27
|
+
import { ModelRouterEmbeddingModel } from '@mastra/core/llm'
|
|
26
28
|
|
|
27
29
|
const agent = new Agent({
|
|
28
30
|
id: 'support-agent',
|
|
29
31
|
name: 'SupportAgent',
|
|
30
32
|
instructions: 'You are a helpful support agent.',
|
|
31
33
|
model: 'openai/gpt-5.4',
|
|
32
|
-
memory: new Memory(
|
|
34
|
+
memory: new Memory({
|
|
35
|
+
storage: new LibSQLStore({
|
|
36
|
+
id: 'agent-storage',
|
|
37
|
+
url: 'file:./local.db',
|
|
38
|
+
}),
|
|
39
|
+
vector: new LibSQLVector({
|
|
40
|
+
id: 'agent-vector',
|
|
41
|
+
url: 'file:./local.db',
|
|
42
|
+
}),
|
|
43
|
+
embedder: new ModelRouterEmbeddingModel('openai/text-embedding-3-small'),
|
|
44
|
+
options: {
|
|
45
|
+
semanticRecall: true,
|
|
46
|
+
},
|
|
47
|
+
}),
|
|
33
48
|
})
|
|
34
49
|
```
|
|
35
50
|
|
|
@@ -77,6 +92,9 @@ const agent = new Agent({
|
|
|
77
92
|
id: 'agent-vector',
|
|
78
93
|
url: 'file:./local.db',
|
|
79
94
|
}),
|
|
95
|
+
options: {
|
|
96
|
+
semanticRecall: true,
|
|
97
|
+
},
|
|
80
98
|
}),
|
|
81
99
|
})
|
|
82
100
|
```
|
|
@@ -139,6 +157,9 @@ import { ModelRouterEmbeddingModel } from '@mastra/core/llm'
|
|
|
139
157
|
const agent = new Agent({
|
|
140
158
|
memory: new Memory({
|
|
141
159
|
embedder: new ModelRouterEmbeddingModel('openai/text-embedding-3-small'),
|
|
160
|
+
options: {
|
|
161
|
+
semanticRecall: true,
|
|
162
|
+
},
|
|
142
163
|
}),
|
|
143
164
|
})
|
|
144
165
|
```
|
|
@@ -262,26 +283,14 @@ const agent = new Agent({
|
|
|
262
283
|
|
|
263
284
|
For detailed information about index configuration options and performance tuning, see the [PgVector configuration guide](https://mastra.ai/reference/vectors/pg).
|
|
264
285
|
|
|
265
|
-
##
|
|
286
|
+
## Disable semantic recall
|
|
266
287
|
|
|
267
|
-
Semantic recall
|
|
268
|
-
|
|
269
|
-
Semantic recall is enabled by default but can be disabled when not needed:
|
|
270
|
-
|
|
271
|
-
```typescript
|
|
272
|
-
const agent = new Agent({
|
|
273
|
-
memory: new Memory({
|
|
274
|
-
options: {
|
|
275
|
-
semanticRecall: false,
|
|
276
|
-
},
|
|
277
|
-
}),
|
|
278
|
-
})
|
|
279
|
-
```
|
|
288
|
+
Semantic recall is disabled by default (`semanticRecall: false`). Each call adds latency because new messages are converted into embeddings and used to query a vector database before the LLM receives them.
|
|
280
289
|
|
|
281
|
-
|
|
290
|
+
Keep semantic recall disabled when:
|
|
282
291
|
|
|
283
|
-
-
|
|
284
|
-
-
|
|
292
|
+
- Message history provides sufficient context for the current conversation.
|
|
293
|
+
- You're building performance-sensitive applications, like realtime two-way audio, where embedding and vector query latency is noticeable.
|
|
285
294
|
|
|
286
295
|
## Viewing recalled messages
|
|
287
296
|
|
|
@@ -14,7 +14,7 @@ export const mastra = new Mastra({
|
|
|
14
14
|
})
|
|
15
15
|
```
|
|
16
16
|
|
|
17
|
-
> **Sharing the database with
|
|
17
|
+
> **Sharing the database with Studio:** When running `mastra dev` alongside your application (e.g., Next.js), use an absolute path to ensure both processes access the same database:
|
|
18
18
|
>
|
|
19
19
|
> ```typescript
|
|
20
20
|
> url: 'file:/absolute/path/to/your/project/mastra.db'
|
|
@@ -129,7 +129,7 @@ Mastra organizes conversations using two identifiers:
|
|
|
129
129
|
|
|
130
130
|
Both identifiers are required for agents to store information:
|
|
131
131
|
|
|
132
|
-
|
|
132
|
+
**.generate()**:
|
|
133
133
|
|
|
134
134
|
```typescript
|
|
135
135
|
const response = await agent.generate('hello', {
|
|
@@ -140,7 +140,7 @@ const response = await agent.generate('hello', {
|
|
|
140
140
|
})
|
|
141
141
|
```
|
|
142
142
|
|
|
143
|
-
|
|
143
|
+
**.stream()**:
|
|
144
144
|
|
|
145
145
|
```typescript
|
|
146
146
|
const stream = await agent.stream('hello', {
|
|
@@ -151,7 +151,7 @@ const stream = await agent.stream('hello', {
|
|
|
151
151
|
})
|
|
152
152
|
```
|
|
153
153
|
|
|
154
|
-
> **Note:** [Studio](https://mastra.ai/docs/
|
|
154
|
+
> **Note:** [Studio](https://mastra.ai/docs/studio/overview) automatically generates a thread and resource ID for you. When calling `stream()` or `generate()` yourself, remember to provide these identifiers explicitly.
|
|
155
155
|
|
|
156
156
|
### Thread title generation
|
|
157
157
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
The DynamoDB storage implementation provides a scalable and performant NoSQL database solution for Mastra, leveraging a single-table design pattern with [ElectroDB](https://electrodb.dev/).
|
|
4
4
|
|
|
5
|
-
> **Observability Not Supported:** DynamoDB storage **doesn't support the observability domain**. Traces from the `DefaultExporter` can't be persisted to DynamoDB, and
|
|
5
|
+
> **Observability Not Supported:** DynamoDB storage **doesn't support the observability domain**. Traces from the `DefaultExporter` can't be persisted to DynamoDB, and [Studio's](https://mastra.ai/docs/studio/overview) observability features won't work with DynamoDB as your only storage provider. To enable observability, use [composite storage](https://mastra.ai/reference/storage/composite) to route observability data to a supported provider like ClickHouse or PostgreSQL.
|
|
6
6
|
|
|
7
7
|
> **Item Size Limit:** DynamoDB enforces a **400 KB maximum item size**. This limit can be exceeded when storing messages with base64-encoded attachments such as images. See [Handling large attachments](https://mastra.ai/docs/memory/storage) for workarounds including uploading attachments to external storage.
|
|
8
8
|
|
package/dist/index.cjs
CHANGED
|
@@ -7355,7 +7355,7 @@ var MemoryPG = class _MemoryPG extends storage.MemoryStorage {
|
|
|
7355
7355
|
};
|
|
7356
7356
|
}
|
|
7357
7357
|
const limitValue = perPageInput === false ? total : perPage;
|
|
7358
|
-
const dataQuery = `SELECT id, "resourceId", title, metadata, "createdAt", "createdAtZ", "updatedAt", "updatedAtZ" ${baseQuery} ORDER BY "${field}" ${direction} LIMIT $${paramIndex} OFFSET $${paramIndex + 1}`;
|
|
7358
|
+
const dataQuery = `SELECT id, "resourceId", title, metadata, "createdAt", "createdAtZ", "updatedAt", "updatedAtZ" ${baseQuery} ORDER BY COALESCE("${field}Z", "${field}") ${direction} LIMIT $${paramIndex} OFFSET $${paramIndex + 1}`;
|
|
7359
7359
|
const rows = await this.#db.client.manyOrNone(
|
|
7360
7360
|
dataQuery,
|
|
7361
7361
|
[...queryParams, limitValue, offset]
|
|
@@ -7473,7 +7473,7 @@ var MemoryPG = class _MemoryPG extends storage.MemoryStorage {
|
|
|
7473
7473
|
...metadata
|
|
7474
7474
|
};
|
|
7475
7475
|
try {
|
|
7476
|
-
const now =
|
|
7476
|
+
const now = /* @__PURE__ */ new Date();
|
|
7477
7477
|
const thread = await this.#db.client.one(
|
|
7478
7478
|
`UPDATE ${threadTableName}
|
|
7479
7479
|
SET
|
|
@@ -7719,7 +7719,7 @@ var MemoryPG = class _MemoryPG extends storage.MemoryStorage {
|
|
|
7719
7719
|
const { offset, perPage: perPageForResponse } = storage.calculatePagination(page, perPageInput, perPage);
|
|
7720
7720
|
try {
|
|
7721
7721
|
const { field, direction } = this.parseOrderBy(orderBy, "ASC");
|
|
7722
|
-
const orderByStatement = `ORDER BY "${field}" ${direction}`;
|
|
7722
|
+
const orderByStatement = `ORDER BY COALESCE("${field}Z", "${field}") ${direction}`;
|
|
7723
7723
|
const selectStatement = `SELECT id, content, role, type, "createdAt", "createdAtZ", thread_id AS "threadId", "resourceId"`;
|
|
7724
7724
|
const tableName = getTableName3({ indexName: storage.TABLE_MESSAGES, schemaName: getSchemaName3(this.#schema) });
|
|
7725
7725
|
const conditions = [`thread_id IN (${inPlaceholders(threadIds.length)})`];
|
|
@@ -7858,7 +7858,7 @@ var MemoryPG = class _MemoryPG extends storage.MemoryStorage {
|
|
|
7858
7858
|
const { offset, perPage: perPageForResponse } = storage.calculatePagination(page, perPageInput, perPage);
|
|
7859
7859
|
try {
|
|
7860
7860
|
const { field, direction } = this.parseOrderBy(orderBy, "ASC");
|
|
7861
|
-
const orderByStatement = `ORDER BY "${field}" ${direction}`;
|
|
7861
|
+
const orderByStatement = `ORDER BY COALESCE("${field}Z", "${field}") ${direction}`;
|
|
7862
7862
|
const selectStatement = `SELECT id, content, role, type, "createdAt", "createdAtZ", thread_id AS "threadId", "resourceId"`;
|
|
7863
7863
|
const tableName = getTableName3({ indexName: storage.TABLE_MESSAGES, schemaName: getSchemaName3(this.#schema) });
|
|
7864
7864
|
const conditions = [];
|
|
@@ -7868,12 +7868,12 @@ var MemoryPG = class _MemoryPG extends storage.MemoryStorage {
|
|
|
7868
7868
|
queryParams.push(resourceId);
|
|
7869
7869
|
if (filter?.dateRange?.start) {
|
|
7870
7870
|
const startOp = filter.dateRange.startExclusive ? ">" : ">=";
|
|
7871
|
-
conditions.push(`"createdAt" ${startOp} $${paramIndex++}`);
|
|
7871
|
+
conditions.push(`COALESCE("createdAtZ", "createdAt") ${startOp} $${paramIndex++}`);
|
|
7872
7872
|
queryParams.push(filter.dateRange.start);
|
|
7873
7873
|
}
|
|
7874
7874
|
if (filter?.dateRange?.end) {
|
|
7875
7875
|
const endOp = filter.dateRange.endExclusive ? "<" : "<=";
|
|
7876
|
-
conditions.push(`"createdAt" ${endOp} $${paramIndex++}`);
|
|
7876
|
+
conditions.push(`COALESCE("createdAtZ", "createdAt") ${endOp} $${paramIndex++}`);
|
|
7877
7877
|
queryParams.push(filter.dateRange.end);
|
|
7878
7878
|
}
|
|
7879
7879
|
const whereClause = conditions.length > 0 ? `WHERE ${conditions.join(" AND ")}` : "";
|
|
@@ -8013,8 +8013,8 @@ var MemoryPG = class _MemoryPG extends storage.MemoryStorage {
|
|
|
8013
8013
|
message.id,
|
|
8014
8014
|
message.threadId,
|
|
8015
8015
|
typeof message.content === "string" ? message.content : JSON.stringify(message.content),
|
|
8016
|
-
message.createdAt ||
|
|
8017
|
-
message.createdAt ||
|
|
8016
|
+
message.createdAt || /* @__PURE__ */ new Date(),
|
|
8017
|
+
message.createdAt || /* @__PURE__ */ new Date(),
|
|
8018
8018
|
message.role,
|
|
8019
8019
|
message.type || "v2",
|
|
8020
8020
|
message.resourceId
|
|
@@ -8022,14 +8022,14 @@ var MemoryPG = class _MemoryPG extends storage.MemoryStorage {
|
|
|
8022
8022
|
);
|
|
8023
8023
|
}
|
|
8024
8024
|
const threadTableName = getTableName3({ indexName: storage.TABLE_THREADS, schemaName: getSchemaName3(this.#schema) });
|
|
8025
|
-
const
|
|
8025
|
+
const now = /* @__PURE__ */ new Date();
|
|
8026
8026
|
await t.none(
|
|
8027
8027
|
`UPDATE ${threadTableName}
|
|
8028
8028
|
SET
|
|
8029
8029
|
"updatedAt" = $1,
|
|
8030
8030
|
"updatedAtZ" = $2
|
|
8031
8031
|
WHERE id = $3`,
|
|
8032
|
-
[
|
|
8032
|
+
[now, now, threadId]
|
|
8033
8033
|
);
|
|
8034
8034
|
});
|
|
8035
8035
|
const messagesWithParsedContent = messages.map((message) => {
|