@mastra/pg 1.8.1 → 1.8.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 +22 -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 +1 -1
- 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,27 @@
|
|
|
1
1
|
# @mastra/pg
|
|
2
2
|
|
|
3
|
+
## 1.8.2
|
|
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 [[`cb611a1`](https://github.com/mastra-ai/mastra/commit/cb611a1e89a4f4cf74c97b57e0c27bb56f2eceb5), [`da93115`](https://github.com/mastra-ai/mastra/commit/da931155c1a9bc63d455d3d86b4ec984db5991fe), [`62d1d3c`](https://github.com/mastra-ai/mastra/commit/62d1d3cc08fe8182e7080237fd975de862ec8c91), [`9e1a3ed`](https://github.com/mastra-ai/mastra/commit/9e1a3ed07cfafb5e8e19a796ce0bee817002d7c0), [`8681ecb`](https://github.com/mastra-ai/mastra/commit/8681ecb86184d5907267000e4576cc442a9a83fc), [`28d0249`](https://github.com/mastra-ai/mastra/commit/28d0249295782277040ad1e0d243e695b7ab1ce4), [`681ee1c`](https://github.com/mastra-ai/mastra/commit/681ee1c811359efd1b8bebc4bce35b9bb7b14bec), [`bb0f09d`](https://github.com/mastra-ai/mastra/commit/bb0f09dbac58401b36069f483acf5673202db5b5), [`a579f7a`](https://github.com/mastra-ai/mastra/commit/a579f7a31e582674862b5679bc79af7ccf7429b8), [`5f7e9d0`](https://github.com/mastra-ai/mastra/commit/5f7e9d0db664020e1f3d97d7d18c6b0b9d4843d0), [`d7f14c3`](https://github.com/mastra-ai/mastra/commit/d7f14c3285cd253ecdd5f58139b7b6cbdf3678b5), [`0efe12a`](https://github.com/mastra-ai/mastra/commit/0efe12a5f008a939a1aac71699486ba40138054e)]:
|
|
12
|
+
- @mastra/core@1.15.0
|
|
13
|
+
|
|
14
|
+
## 1.8.2-alpha.0
|
|
15
|
+
|
|
16
|
+
### Patch Changes
|
|
17
|
+
|
|
18
|
+
- Fixed PostgreSQL transaction query execution in `@mastra/pg`. ([#14483](https://github.com/mastra-ai/mastra/pull/14483))
|
|
19
|
+
|
|
20
|
+
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.
|
|
21
|
+
|
|
22
|
+
- Updated dependencies [[`d7f14c3`](https://github.com/mastra-ai/mastra/commit/d7f14c3285cd253ecdd5f58139b7b6cbdf3678b5)]:
|
|
23
|
+
- @mastra/core@1.15.0-alpha.3
|
|
24
|
+
|
|
3
25
|
## 1.8.1
|
|
4
26
|
|
|
5
27
|
### 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
|
|
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) {
|