@mastra/pg 1.8.1-alpha.0 → 1.8.2-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 +20 -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 +1 -1
- package/dist/docs/references/docs-memory-storage.md +4 -4
- package/dist/docs/references/docs-memory-working-memory.md +2 -2
- package/dist/index.cjs +11 -13
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +11 -13
- package/dist/index.js.map +1 -1
- package/dist/storage/domains/memory/index.d.ts.map +1 -1
- package/package.json +5 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,25 @@
|
|
|
1
1
|
# @mastra/pg
|
|
2
2
|
|
|
3
|
+
## 1.8.2-alpha.0
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Fixed PostgreSQL transaction query execution in `@mastra/pg`. ([#14483](https://github.com/mastra-ai/mastra/pull/14483))
|
|
8
|
+
|
|
9
|
+
Message save/delete operations now run transaction queries one at a time on the same client. This removes the pg deprecation warning in 8.19+ and prevents failures in pg 9.0.
|
|
10
|
+
|
|
11
|
+
- Updated dependencies [[`d7f14c3`](https://github.com/mastra-ai/mastra/commit/d7f14c3285cd253ecdd5f58139b7b6cbdf3678b5)]:
|
|
12
|
+
- @mastra/core@1.15.0-alpha.3
|
|
13
|
+
|
|
14
|
+
## 1.8.1
|
|
15
|
+
|
|
16
|
+
### Patch Changes
|
|
17
|
+
|
|
18
|
+
- Added dated message boundary delimiters when activating buffered observations for improved cache stability. ([#14367](https://github.com/mastra-ai/mastra/pull/14367))
|
|
19
|
+
|
|
20
|
+
- Updated dependencies [[`51970b3`](https://github.com/mastra-ai/mastra/commit/51970b3828494d59a8dd4df143b194d37d31e3f5), [`4444280`](https://github.com/mastra-ai/mastra/commit/444428094253e916ec077e66284e685fde67021e), [`085e371`](https://github.com/mastra-ai/mastra/commit/085e3718a7d0fe9a210fe7dd1c867b9bdfe8d16b), [`b77aa19`](https://github.com/mastra-ai/mastra/commit/b77aa1981361c021f2c881bee8f0c703687f00da), [`dbb879a`](https://github.com/mastra-ai/mastra/commit/dbb879af0b809c668e9b3a9d8bac97d806caa267), [`8b4ce84`](https://github.com/mastra-ai/mastra/commit/8b4ce84aed0808b9805cc4fd7147c1f8a2ef7a36), [`8d4cfe6`](https://github.com/mastra-ai/mastra/commit/8d4cfe6b9a7157d3876206227ec9f04cde6dbc4a), [`dd6ca1c`](https://github.com/mastra-ai/mastra/commit/dd6ca1cdea3b8b6182f4cf61df41070ba0cc0deb), [`ce26fe2`](https://github.com/mastra-ai/mastra/commit/ce26fe2166dd90254f8bee5776e55977143e97de), [`68a019d`](https://github.com/mastra-ai/mastra/commit/68a019d30d22251ddd628a2947d60215c03c350a), [`4cb4edf`](https://github.com/mastra-ai/mastra/commit/4cb4edf3c909d197ec356c1790d13270514ffef6), [`8de3555`](https://github.com/mastra-ai/mastra/commit/8de355572c6fd838f863a3e7e6fe24d0947b774f), [`b26307f`](https://github.com/mastra-ai/mastra/commit/b26307f050df39629511b0e831b8fc26973ce8b1), [`68a019d`](https://github.com/mastra-ai/mastra/commit/68a019d30d22251ddd628a2947d60215c03c350a)]:
|
|
21
|
+
- @mastra/core@1.14.0
|
|
22
|
+
|
|
3
23
|
## 1.8.1-alpha.0
|
|
4
24
|
|
|
5
25
|
### Patch Changes
|
package/dist/docs/SKILL.md
CHANGED
|
@@ -16,7 +16,7 @@ When it's enabled, new messages are used to query a vector DB for semantically s
|
|
|
16
16
|
|
|
17
17
|
After getting a response from the LLM, all new messages (user, assistant, and tool calls/results) are inserted into the vector DB to be recalled in later interactions.
|
|
18
18
|
|
|
19
|
-
##
|
|
19
|
+
## Quickstart
|
|
20
20
|
|
|
21
21
|
Semantic recall is enabled by default, so if you give your agent memory it will be included:
|
|
22
22
|
|
|
@@ -100,7 +100,7 @@ This is useful when different types of data have different performance or operat
|
|
|
100
100
|
|
|
101
101
|
### Agent-level storage
|
|
102
102
|
|
|
103
|
-
Agent-level storage overrides storage configured at the instance level. Add storage to a specific agent when you need data
|
|
103
|
+
Agent-level storage overrides storage configured at the instance level. Add storage to a specific agent when you need to keep data separate or use different providers per agent.
|
|
104
104
|
|
|
105
105
|
```typescript
|
|
106
106
|
import { Agent } from '@mastra/core/agent'
|
|
@@ -118,14 +118,14 @@ export const agent = new Agent({
|
|
|
118
118
|
})
|
|
119
119
|
```
|
|
120
120
|
|
|
121
|
-
> **Warning:** [Mastra Cloud Store](https://mastra.ai/docs/mastra-cloud/deployment) doesn't
|
|
121
|
+
> **Warning:** Agent-level storage isn't supported when using [Mastra Cloud Store](https://mastra.ai/docs/mastra-cloud/deployment). If you use Mastra Cloud Store, configure storage on the Mastra instance instead. This limitation doesn't apply if you bring your own database.
|
|
122
122
|
|
|
123
123
|
## Threads and resources
|
|
124
124
|
|
|
125
125
|
Mastra organizes conversations using two identifiers:
|
|
126
126
|
|
|
127
|
-
- **Thread
|
|
128
|
-
- **Resource
|
|
127
|
+
- **Thread**: A conversation session containing a sequence of messages.
|
|
128
|
+
- **Resource**: The entity that owns the thread, such as a user, organization, project, or any other domain entity in your application.
|
|
129
129
|
|
|
130
130
|
Both identifiers are required for agents to store information:
|
|
131
131
|
|
|
@@ -13,7 +13,7 @@ Working memory can persist at two different scopes:
|
|
|
13
13
|
|
|
14
14
|
**Important:** Switching between scopes means the agent won't see memory from the other scope - thread-scoped memory is completely separate from resource-scoped memory.
|
|
15
15
|
|
|
16
|
-
##
|
|
16
|
+
## Quickstart
|
|
17
17
|
|
|
18
18
|
Here's a minimal example of setting up an agent with working memory:
|
|
19
19
|
|
|
@@ -268,7 +268,7 @@ Schema-based working memory uses **merge semantics**, meaning the agent only nee
|
|
|
268
268
|
## Choosing between template and schema
|
|
269
269
|
|
|
270
270
|
- Use a **template** (Markdown) if you want the agent to maintain memory as a free-form text block, such as a user profile or scratchpad. Templates use **replace semantics** — the agent must provide the complete memory content on each update.
|
|
271
|
-
- Use a **schema** if you need structured, type-safe data that can be validated and programmatically accessed as JSON. Schemas use **merge semantics** — the agent only provides fields to update, and existing fields are preserved.
|
|
271
|
+
- Use a **schema** if you need structured, type-safe data that can be validated and programmatically accessed as JSON. The `workingMemory.schema` field accepts any `PublicSchema`-compatible schema (including Zod v3, Zod v4, JSON Schema, or already-standard schemas). Schemas use **merge semantics** — the agent only provides fields to update, and existing fields are preserved.
|
|
272
272
|
- Only one mode can be active at a time: setting both `template` and `schema` isn't supported.
|
|
273
273
|
|
|
274
274
|
## Example: Multi-step retention
|
package/dist/index.cjs
CHANGED
|
@@ -7844,7 +7844,7 @@ var MemoryPG = class _MemoryPG extends storage.MemoryStorage {
|
|
|
7844
7844
|
try {
|
|
7845
7845
|
const tableName = getTableName3({ indexName: storage.TABLE_MESSAGES, schemaName: getSchemaName3(this.#schema) });
|
|
7846
7846
|
await this.#db.client.tx(async (t) => {
|
|
7847
|
-
const
|
|
7847
|
+
for (const message of messages) {
|
|
7848
7848
|
if (!message.threadId) {
|
|
7849
7849
|
throw new Error(
|
|
7850
7850
|
`Expected to find a threadId for message, but couldn't find one. An unexpected error has occurred.`
|
|
@@ -7855,7 +7855,7 @@ var MemoryPG = class _MemoryPG extends storage.MemoryStorage {
|
|
|
7855
7855
|
`Expected to find a resourceId for message, but couldn't find one. An unexpected error has occurred.`
|
|
7856
7856
|
);
|
|
7857
7857
|
}
|
|
7858
|
-
|
|
7858
|
+
await t.none(
|
|
7859
7859
|
`INSERT INTO ${tableName} (id, thread_id, content, "createdAt", "createdAtZ", role, type, "resourceId")
|
|
7860
7860
|
VALUES ($1, $2, $3, $4, $5, $6, $7, $8)
|
|
7861
7861
|
ON CONFLICT (id) DO UPDATE SET
|
|
@@ -7875,19 +7875,17 @@ var MemoryPG = class _MemoryPG extends storage.MemoryStorage {
|
|
|
7875
7875
|
message.resourceId
|
|
7876
7876
|
]
|
|
7877
7877
|
);
|
|
7878
|
-
}
|
|
7878
|
+
}
|
|
7879
7879
|
const threadTableName = getTableName3({ indexName: storage.TABLE_THREADS, schemaName: getSchemaName3(this.#schema) });
|
|
7880
7880
|
const nowStr = (/* @__PURE__ */ new Date()).toISOString();
|
|
7881
|
-
|
|
7881
|
+
await t.none(
|
|
7882
7882
|
`UPDATE ${threadTableName}
|
|
7883
|
-
|
|
7884
|
-
|
|
7885
|
-
|
|
7886
|
-
|
|
7887
|
-
`,
|
|
7883
|
+
SET
|
|
7884
|
+
"updatedAt" = $1,
|
|
7885
|
+
"updatedAtZ" = $2
|
|
7886
|
+
WHERE id = $3`,
|
|
7888
7887
|
[nowStr, nowStr, threadId]
|
|
7889
7888
|
);
|
|
7890
|
-
await Promise.all([...messageInserts, threadUpdate]);
|
|
7891
7889
|
});
|
|
7892
7890
|
const messagesWithParsedContent = messages.map((message) => {
|
|
7893
7891
|
if (typeof message.content === "string") {
|
|
@@ -8024,10 +8022,10 @@ var MemoryPG = class _MemoryPG extends storage.MemoryStorage {
|
|
|
8024
8022
|
const threadIds = messages?.map((msg) => msg.thread_id).filter(Boolean) || [];
|
|
8025
8023
|
await t.none(`DELETE FROM ${messageTableName} WHERE id IN (${placeholders})`, messageIds);
|
|
8026
8024
|
if (threadIds.length > 0) {
|
|
8027
|
-
|
|
8028
|
-
|
|
8025
|
+
await t.none(
|
|
8026
|
+
`UPDATE ${threadTableName} SET "updatedAt" = NOW(), "updatedAtZ" = NOW() WHERE id IN (${inPlaceholders(threadIds.length)})`,
|
|
8027
|
+
threadIds
|
|
8029
8028
|
);
|
|
8030
|
-
await Promise.all(updatePromises);
|
|
8031
8029
|
}
|
|
8032
8030
|
});
|
|
8033
8031
|
} catch (error$1) {
|