@mastra/pg 1.20.0-alpha.2 → 1.20.0-alpha.3
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 +19 -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 +2 -1
- package/dist/docs/references/docs-memory-working-memory.md +1 -0
- package/dist/docs/references/docs-storage-overview.md +1 -0
- package/dist/docs/references/guides-rag-overview.md +1 -1
- package/dist/docs/references/guides-rag-retrieval.md +17 -0
- package/dist/docs/references/guides-rag-vector-databases.md +41 -0
- package/dist/docs/references/reference-rag-metadata-filters.md +13 -4
- package/dist/index.cjs +4 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +4 -4
- package/dist/index.js.map +1 -1
- package/dist/storage/domains/memory/index.d.ts +2 -2
- package/dist/storage/domains/memory/index.d.ts.map +1 -1
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,24 @@
|
|
|
1
1
|
# @mastra/pg
|
|
2
2
|
|
|
3
|
+
## 1.20.0-alpha.3
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Fixed generated thread titles being clobbered during a turn ([#21041](https://github.com/mastra-ai/mastra/pull/21041))
|
|
8
|
+
|
|
9
|
+
`updateThread` required both `title` and `metadata`, so callers that only needed to
|
|
10
|
+
change metadata (message persistence, working memory, observational memory, channel
|
|
11
|
+
subscriptions) had to read the thread and pass its title back. When title generation
|
|
12
|
+
finished between that read and the write, the freshly generated title was overwritten
|
|
13
|
+
with the stale one.
|
|
14
|
+
|
|
15
|
+
`title` and `metadata` are now independently optional: omitting one leaves that column
|
|
16
|
+
untouched. Callers that only change metadata no longer send a title, and message
|
|
17
|
+
persistence no longer rewrites a thread row it just read.
|
|
18
|
+
|
|
19
|
+
- Updated dependencies [[`1c75e32`](https://github.com/mastra-ai/mastra/commit/1c75e32f7fc0b9fb6f548b4407feaec8a1440212), [`c47165c`](https://github.com/mastra-ai/mastra/commit/c47165c983c87594c6952f1fd2fa51a90205034c), [`e08e789`](https://github.com/mastra-ai/mastra/commit/e08e789c1bf4cd2fe46363f7a4728536ceccc9bd), [`35cc901`](https://github.com/mastra-ai/mastra/commit/35cc90102cf834a84827acaf9eee0b6d6d1e2a3b), [`a8b4cf0`](https://github.com/mastra-ai/mastra/commit/a8b4cf02823cffebc4751a53337dfacf097c1ae1), [`f33264f`](https://github.com/mastra-ai/mastra/commit/f33264f517ae603279afd5c4251e2b40f6dd3618), [`689f2c4`](https://github.com/mastra-ai/mastra/commit/689f2c4b6c0835fe455702b01d21daa8abcd9331), [`eeae63e`](https://github.com/mastra-ai/mastra/commit/eeae63e7fbe8e1f237adc69bca6e2ac13c5ca907), [`4c186a0`](https://github.com/mastra-ai/mastra/commit/4c186a017275f45e6ed4c09de0f89550e2d09e8c), [`b0fa077`](https://github.com/mastra-ai/mastra/commit/b0fa077bcbc9b08551846fe372a0d3d15b71ed72)]:
|
|
20
|
+
- @mastra/core@1.58.0-alpha.8
|
|
21
|
+
|
|
3
22
|
## 1.20.0-alpha.2
|
|
4
23
|
|
|
5
24
|
### Patch Changes
|
package/dist/docs/SKILL.md
CHANGED
|
@@ -148,6 +148,7 @@ Each vector store page below includes installation instructions, configuration p
|
|
|
148
148
|
- [libSQL](https://mastra.ai/reference/vectors/libsql)
|
|
149
149
|
- [MongoDB](https://mastra.ai/reference/vectors/mongodb)
|
|
150
150
|
- [OpenSearch](https://mastra.ai/reference/vectors/opensearch)
|
|
151
|
+
- [OracleDB](https://mastra.ai/reference/vectors/oracledb)
|
|
151
152
|
- [Pinecone](https://mastra.ai/reference/vectors/pinecone)
|
|
152
153
|
- [PostgreSQL](https://mastra.ai/reference/vectors/pg)
|
|
153
154
|
- [Qdrant](https://mastra.ai/reference/vectors/qdrant)
|
|
@@ -180,7 +181,7 @@ const agent = new Agent({
|
|
|
180
181
|
})
|
|
181
182
|
```
|
|
182
183
|
|
|
183
|
-
> **Note:** `scope: 'resource'` is supported by the LibSQL, PostgreSQL, MongoDB, and Upstash storage adapters.
|
|
184
|
+
> **Note:** `scope: 'resource'` is supported by the LibSQL, OracleDB, PostgreSQL, MongoDB, and Upstash storage adapters.
|
|
184
185
|
|
|
185
186
|
### Metadata filtering
|
|
186
187
|
|
|
@@ -129,6 +129,7 @@ Resource-scoped working memory requires specific storage adapters that support t
|
|
|
129
129
|
|
|
130
130
|
- **libSQL** (`@mastra/libsql`)
|
|
131
131
|
- **PostgreSQL** (`@mastra/pg`)
|
|
132
|
+
- **OracleDB** (`@mastra/oracledb`)
|
|
132
133
|
- **Upstash** (`@mastra/upstash`)
|
|
133
134
|
- **MongoDB** (`@mastra/mongodb`)
|
|
134
135
|
|
|
@@ -193,6 +193,7 @@ Each provider page includes installation instructions, configuration parameters,
|
|
|
193
193
|
- [libSQL](https://mastra.ai/reference/storage/libsql)
|
|
194
194
|
- [PostgreSQL](https://mastra.ai/reference/storage/postgresql)
|
|
195
195
|
- [MongoDB](https://mastra.ai/reference/storage/mongodb)
|
|
196
|
+
- [OracleDB](https://mastra.ai/reference/storage/oracledb)
|
|
196
197
|
- [Upstash](https://mastra.ai/reference/storage/upstash)
|
|
197
198
|
- [Redis](https://mastra.ai/reference/storage/redis)
|
|
198
199
|
- [Cloudflare D1](https://mastra.ai/reference/storage/cloudflare-d1)
|
|
@@ -67,7 +67,7 @@ The basic building block of RAG is document processing. Documents can be chunked
|
|
|
67
67
|
|
|
68
68
|
## Vector storage
|
|
69
69
|
|
|
70
|
-
Mastra supports multiple vector stores for embedding persistence and similarity search, including pgvector, Pinecone, Qdrant, and MongoDB. See the [vector database doc](https://mastra.ai/guides/rag/vector-databases).
|
|
70
|
+
Mastra supports multiple vector stores for embedding persistence and similarity search, including pgvector, OracleDB, Pinecone, Qdrant, and MongoDB. See the [vector database doc](https://mastra.ai/guides/rag/vector-databases).
|
|
71
71
|
|
|
72
72
|
## More resources
|
|
73
73
|
|
|
@@ -436,6 +436,23 @@ export const ragAgent = new Agent({
|
|
|
436
436
|
})
|
|
437
437
|
```
|
|
438
438
|
|
|
439
|
+
**OracleDB**:
|
|
440
|
+
|
|
441
|
+
```ts
|
|
442
|
+
import { ORACLEDB_PROMPT } from '@mastra/oracledb'
|
|
443
|
+
|
|
444
|
+
export const ragAgent = new Agent({
|
|
445
|
+
id: 'rag-agent',
|
|
446
|
+
name: 'RAG Agent',
|
|
447
|
+
model: 'openai/gpt-5.6-sol',
|
|
448
|
+
instructions: `
|
|
449
|
+
Process queries using the provided context. Structure responses to be concise and relevant.
|
|
450
|
+
${ORACLEDB_PROMPT}
|
|
451
|
+
`,
|
|
452
|
+
tools: { vectorQueryTool },
|
|
453
|
+
})
|
|
454
|
+
```
|
|
455
|
+
|
|
439
456
|
**S3Vectors**:
|
|
440
457
|
|
|
441
458
|
```ts
|
|
@@ -78,6 +78,35 @@ await store.upsert({
|
|
|
78
78
|
|
|
79
79
|
PostgreSQL with the pgvector extension is a good solution for teams already using PostgreSQL who want to minimize infrastructure complexity. For detailed setup instructions and best practices, see the [official pgvector repository](https://github.com/pgvector/pgvector).
|
|
80
80
|
|
|
81
|
+
**OracleDB**:
|
|
82
|
+
|
|
83
|
+
```ts
|
|
84
|
+
import { OracleVector } from '@mastra/oracledb'
|
|
85
|
+
|
|
86
|
+
const store = new OracleVector({
|
|
87
|
+
id: 'oracle-vector',
|
|
88
|
+
user: process.env.ORACLE_DATABASE_USER,
|
|
89
|
+
password: process.env.ORACLE_DATABASE_PASSWORD,
|
|
90
|
+
connectString: process.env.ORACLE_DATABASE_CONNECT_STRING,
|
|
91
|
+
})
|
|
92
|
+
|
|
93
|
+
await store.createIndex({
|
|
94
|
+
indexName: 'myCollection',
|
|
95
|
+
dimension: 1536,
|
|
96
|
+
indexConfig: { type: 'none' },
|
|
97
|
+
})
|
|
98
|
+
|
|
99
|
+
await store.upsert({
|
|
100
|
+
indexName: 'myCollection',
|
|
101
|
+
vectors: embeddings,
|
|
102
|
+
metadata: chunks.map(chunk => ({ text: chunk.text })),
|
|
103
|
+
})
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
### Using Oracle Database Vector Search
|
|
107
|
+
|
|
108
|
+
OracleDB stores embeddings in native `VECTOR` columns and metadata in Oracle JSON. Exact search is the default; HNSW and IVF indexes can be configured for tuned deployments.
|
|
109
|
+
|
|
81
110
|
**Pinecone**:
|
|
82
111
|
|
|
83
112
|
```ts
|
|
@@ -410,6 +439,18 @@ Index names must:
|
|
|
410
439
|
- Example: `my_index_123` is valid
|
|
411
440
|
- Example: `my-index` is not valid (contains hyphen)
|
|
412
441
|
|
|
442
|
+
**OracleDB**:
|
|
443
|
+
|
|
444
|
+
Index names are logical Mastra names. OracleDB maps each logical index to a physical Oracle table internally.
|
|
445
|
+
|
|
446
|
+
Logical index names must:
|
|
447
|
+
|
|
448
|
+
- Be non-empty
|
|
449
|
+
- Be 512 characters or fewer
|
|
450
|
+
- Be stable for the lifetime of the vector index
|
|
451
|
+
- Example: `my_collection_123` is valid
|
|
452
|
+
- Example: `customer-support/docs:v1` is valid and is mapped to a safe Oracle table name
|
|
453
|
+
|
|
413
454
|
**Pinecone**:
|
|
414
455
|
|
|
415
456
|
Index names must:
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
# Metadata filters
|
|
4
4
|
|
|
5
|
-
Mastra provides a unified metadata filtering syntax across all vector stores, based on MongoDB/Sift query syntax. Each vector store translates these filters into
|
|
5
|
+
Mastra provides a unified metadata filtering syntax across all vector stores, based on MongoDB/Sift query syntax. Each vector store translates these filters into its native query format. For example, PgVector uses PostgreSQL JSONB predicates, while OracleDB stores metadata as Oracle JSON and compiles filters to `JSON_VALUE`, `JSON_EXISTS`, `REGEXP_LIKE`, and `LIKE` predicates with bound values.
|
|
6
6
|
|
|
7
7
|
## Basic example
|
|
8
8
|
|
|
@@ -34,11 +34,11 @@ const results = await store.query({
|
|
|
34
34
|
|
|
35
35
|
### Array Operators
|
|
36
36
|
|
|
37
|
-
`$in`Matches any value in array{ category: { $in: \["A", "B"] } }Supported by: All except Couchbase`$nin`Matches none of the values{ status: { $nin: \["deleted", "archived"] } }Supported by: All except Couchbase`$all`Matches arrays containing all elements{ tags: { $all: \["urgent", "high"] } }Supported by: Astra, Pinecone, Upstash, MongoDB`$elemMatch`Matches array elements meeting criteria{ scores: { $elemMatch: { $gt: 80 } } }Supported by: libSQL, PgVector, MongoDB
|
|
37
|
+
`$in`Matches any value in array{ category: { $in: \["A", "B"] } }Supported by: All except Couchbase`$nin`Matches none of the values{ status: { $nin: \["deleted", "archived"] } }Supported by: All except Couchbase`$all`Matches arrays containing all elements{ tags: { $all: \["urgent", "high"] } }Supported by: Astra, Pinecone, Upstash, MongoDB, OracleDB`$elemMatch`Matches array elements meeting criteria{ scores: { $elemMatch: { $gt: 80 } } }Supported by: libSQL, PgVector, MongoDB, OracleDB
|
|
38
38
|
|
|
39
39
|
### Logical Operators
|
|
40
40
|
|
|
41
|
-
`$and`Logical AND{ $and: \[{ price: { $gt: 100 } }, { stock: { $gt: 0 } }] }Supported by: All except Vectorize, Couchbase`$or`Logical OR{ $or: \[{ status: "active" }, { priority: "high" }] }Supported by: All except Vectorize, Couchbase`$not`Logical NOT{ price: { $not: { $lt: 100 } } }Supported by: Astra, Qdrant, Upstash, PgVector, libSQL, MongoDB`$nor`Logical NOR{ $nor: \[{ status: "deleted" }, { archived: true }] }Supported by: Qdrant, Upstash, PgVector, libSQL, MongoDB
|
|
41
|
+
`$and`Logical AND{ $and: \[{ price: { $gt: 100 } }, { stock: { $gt: 0 } }] }Supported by: All except Vectorize, Couchbase`$or`Logical OR{ $or: \[{ status: "active" }, { priority: "high" }] }Supported by: All except Vectorize, Couchbase`$not`Logical NOT{ price: { $not: { $lt: 100 } } }Supported by: Astra, Qdrant, Upstash, PgVector, libSQL, MongoDB, OracleDB`$nor`Logical NOR{ $nor: \[{ status: "deleted" }, { archived: true }] }Supported by: Qdrant, Upstash, PgVector, libSQL, MongoDB, OracleDB
|
|
42
42
|
|
|
43
43
|
### Element Operators
|
|
44
44
|
|
|
@@ -46,7 +46,7 @@ const results = await store.query({
|
|
|
46
46
|
|
|
47
47
|
### Custom Operators
|
|
48
48
|
|
|
49
|
-
`$contains`Text contains substring{ description: { $contains: "sale" } }Supported by: Upstash, libSQL, PgVector`$regex`Regular expression match{ name: { $regex: "^test" } }Supported by: Qdrant, PgVector, Upstash, MongoDB`$size`Array length check{ tags: { $size:
|
|
49
|
+
`$contains`Text contains substring{ description: { $contains: "sale" } }Supported by: Upstash, libSQL, PgVector, OracleDB`$regex`Regular expression match{ name: { $regex: "^test" } }Supported by: Qdrant, PgVector, Upstash, MongoDB, OracleDB`$size`Array length check{ tags: { $size: 3 } }Supported by: Astra, libSQL, PgVector, MongoDB, OracleDB`$geo`Geospatial query{ location: { $geo: { type: "radius", ... } } }Supported by: Qdrant`$datetime`Datetime range query{ created: { $datetime: { range: { gt: "2024-01-01" } } } }Supported by: Qdrant`$hasId`Vector ID existence check{ $hasId: \["id1", "id2"] }Supported by: Qdrant`$hasVector`Vector existence check{ $hasVector: true }Supported by: Qdrant
|
|
50
50
|
|
|
51
51
|
## Common rules and restrictions
|
|
52
52
|
|
|
@@ -124,6 +124,14 @@ const results = await store.query({
|
|
|
124
124
|
- Empty arrays in conditions are handled gracefully
|
|
125
125
|
- Metadata is stored in a JSONB column for efficient querying
|
|
126
126
|
|
|
127
|
+
### OracleDB
|
|
128
|
+
|
|
129
|
+
- Metadata is stored as Oracle JSON alongside each `VECTOR` row
|
|
130
|
+
- Scalar comparisons use `JSON_VALUE`, while array, existence, and element-match checks use `JSON_EXISTS`
|
|
131
|
+
- `$regex` uses Oracle `REGEXP_LIKE`; string `$contains` uses case-insensitive `LIKE`
|
|
132
|
+
- Nested fields are supported with dot notation and are converted to quoted Oracle JSON paths
|
|
133
|
+
- User-provided metadata values are bound as parameters instead of interpolated into SQL
|
|
134
|
+
|
|
127
135
|
### PgVector
|
|
128
136
|
|
|
129
137
|
- Full support for PostgreSQL's native JSON querying capabilities
|
|
@@ -211,6 +219,7 @@ const results = await store.query({
|
|
|
211
219
|
- [Cloudflare Vectorize](https://mastra.ai/reference/vectors/vectorize)
|
|
212
220
|
- [libSQL](https://mastra.ai/reference/vectors/libsql)
|
|
213
221
|
- [MongoDB](https://mastra.ai/reference/vectors/mongodb)
|
|
222
|
+
- [OracleDB](https://mastra.ai/reference/vectors/oracledb)
|
|
214
223
|
- [PgStore](https://mastra.ai/reference/vectors/pg)
|
|
215
224
|
- [Pinecone](https://mastra.ai/reference/vectors/pinecone)
|
|
216
225
|
- [Qdrant](https://mastra.ai/reference/vectors/qdrant)
|
package/dist/index.cjs
CHANGED
|
@@ -9200,7 +9200,7 @@ var MemoryPG = class MemoryPG extends _mastra_core_storage.MemoryStorage {
|
|
|
9200
9200
|
text: `Thread ${id} not found`,
|
|
9201
9201
|
details: {
|
|
9202
9202
|
threadId: id,
|
|
9203
|
-
title
|
|
9203
|
+
title: title ?? null
|
|
9204
9204
|
}
|
|
9205
9205
|
});
|
|
9206
9206
|
const mergedMetadata = {
|
|
@@ -9211,14 +9211,14 @@ var MemoryPG = class MemoryPG extends _mastra_core_storage.MemoryStorage {
|
|
|
9211
9211
|
const nowStr = toUtcISOString(/* @__PURE__ */ new Date());
|
|
9212
9212
|
const thread = await this.#db.client.one(`UPDATE ${threadTableName}
|
|
9213
9213
|
SET
|
|
9214
|
-
title = $1,
|
|
9214
|
+
title = COALESCE($1, title),
|
|
9215
9215
|
metadata = $2,
|
|
9216
9216
|
"updatedAt" = $3,
|
|
9217
9217
|
"updatedAtZ" = $4
|
|
9218
9218
|
WHERE id = $5
|
|
9219
9219
|
RETURNING *
|
|
9220
9220
|
`, [
|
|
9221
|
-
title,
|
|
9221
|
+
title ?? null,
|
|
9222
9222
|
mergedMetadata,
|
|
9223
9223
|
nowStr,
|
|
9224
9224
|
nowStr,
|
|
@@ -9239,7 +9239,7 @@ var MemoryPG = class MemoryPG extends _mastra_core_storage.MemoryStorage {
|
|
|
9239
9239
|
category: _mastra_core_error.ErrorCategory.THIRD_PARTY,
|
|
9240
9240
|
details: {
|
|
9241
9241
|
threadId: id,
|
|
9242
|
-
title
|
|
9242
|
+
title: title ?? null
|
|
9243
9243
|
}
|
|
9244
9244
|
}, error);
|
|
9245
9245
|
}
|