@mastra/pg 1.8.6 → 1.9.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 +26 -0
- package/dist/docs/SKILL.md +1 -1
- package/dist/docs/assets/SOURCE_MAP.json +1 -1
- package/dist/index.cjs +61 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +61 -5
- package/dist/index.js.map +1 -1
- package/dist/storage/domains/memory/index.d.ts +3 -2
- package/dist/storage/domains/memory/index.d.ts.map +1 -1
- package/package.json +5 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,31 @@
|
|
|
1
1
|
# @mastra/pg
|
|
2
2
|
|
|
3
|
+
## 1.9.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- Implemented `updateObservationalMemoryConfig()` in Postgres, LibSQL, and MongoDB storage adapters. This enables per-record config overrides for observational memory thresholds, supporting the new `memory.updateObservationalMemoryConfig()` API in `@mastra/memory`. ([#15115](https://github.com/mastra-ai/mastra/pull/15115))
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- Fixed observational memory date-range queries to use ISO-string timestamp columns (`createdAtZ`) instead of the raw `createdAt` column, ensuring correct filtering when querying observations by date range. ([#15115](https://github.com/mastra-ai/mastra/pull/15115))
|
|
12
|
+
|
|
13
|
+
- Updated dependencies [[`f32b9e1`](https://github.com/mastra-ai/mastra/commit/f32b9e115a3c754d1c8cfa3f4256fba87b09cfb7), [`7d6f521`](https://github.com/mastra-ai/mastra/commit/7d6f52164d0cca099f0b07cb2bba334360f1c8ab), [`a50d220`](https://github.com/mastra-ai/mastra/commit/a50d220b01ecbc5644d489a3d446c3bd4ab30245), [`665477b`](https://github.com/mastra-ai/mastra/commit/665477bc104fd52cfef8e7610d7664781a70c220), [`4cc2755`](https://github.com/mastra-ai/mastra/commit/4cc2755a7194cb08720ff2ab4dffb4b4a5103dfd), [`ac7baf6`](https://github.com/mastra-ai/mastra/commit/ac7baf66ef1db15e03975ef4ebb02724f015a391), [`ed425d7`](https://github.com/mastra-ai/mastra/commit/ed425d78e7c66cbda8209fee910856f98c6c6b82), [`1371703`](https://github.com/mastra-ai/mastra/commit/1371703835080450ef3f9aea58059a95d0da2e5a), [`0df8321`](https://github.com/mastra-ai/mastra/commit/0df832196eeb2450ab77ce887e8553abdd44c5a6), [`98f8a8b`](https://github.com/mastra-ai/mastra/commit/98f8a8bdf5761b9982f3ad3acbe7f1cc3efa71f3), [`ba6f7e9`](https://github.com/mastra-ai/mastra/commit/ba6f7e9086d8281393f2acae60fda61de3bff1f9), [`7eb2596`](https://github.com/mastra-ai/mastra/commit/7eb25960d607e07468c9a10c5437abd2deaf1e9a), [`1805ddc`](https://github.com/mastra-ai/mastra/commit/1805ddc9c9b3b14b63749735a13c05a45af43a80), [`fff91cf`](https://github.com/mastra-ai/mastra/commit/fff91cf914de0e731578aacebffdeebef82f0440), [`61109b3`](https://github.com/mastra-ai/mastra/commit/61109b34feb0e38d54bee4b8ca83eb7345b1d557), [`33f1ead`](https://github.com/mastra-ai/mastra/commit/33f1eadfa19c86953f593478e5fa371093b33779)]:
|
|
14
|
+
- @mastra/core@1.23.0
|
|
15
|
+
|
|
16
|
+
## 1.9.0-alpha.0
|
|
17
|
+
|
|
18
|
+
### Minor Changes
|
|
19
|
+
|
|
20
|
+
- Implemented `updateObservationalMemoryConfig()` in Postgres, LibSQL, and MongoDB storage adapters. This enables per-record config overrides for observational memory thresholds, supporting the new `memory.updateObservationalMemoryConfig()` API in `@mastra/memory`. ([#15115](https://github.com/mastra-ai/mastra/pull/15115))
|
|
21
|
+
|
|
22
|
+
### Patch Changes
|
|
23
|
+
|
|
24
|
+
- Fixed observational memory date-range queries to use ISO-string timestamp columns (`createdAtZ`) instead of the raw `createdAt` column, ensuring correct filtering when querying observations by date range. ([#15115](https://github.com/mastra-ai/mastra/pull/15115))
|
|
25
|
+
|
|
26
|
+
- Updated dependencies [[`a50d220`](https://github.com/mastra-ai/mastra/commit/a50d220b01ecbc5644d489a3d446c3bd4ab30245)]:
|
|
27
|
+
- @mastra/core@1.23.0-alpha.9
|
|
28
|
+
|
|
3
29
|
## 1.8.6
|
|
4
30
|
|
|
5
31
|
### Patch Changes
|
package/dist/docs/SKILL.md
CHANGED
package/dist/index.cjs
CHANGED
|
@@ -8488,17 +8488,34 @@ var MemoryPG = class _MemoryPG extends storage.MemoryStorage {
|
|
|
8488
8488
|
);
|
|
8489
8489
|
}
|
|
8490
8490
|
}
|
|
8491
|
-
async getObservationalMemoryHistory(threadId, resourceId, limit = 10) {
|
|
8491
|
+
async getObservationalMemoryHistory(threadId, resourceId, limit = 10, options) {
|
|
8492
8492
|
try {
|
|
8493
8493
|
const lookupKey = this.getOMKey(threadId, resourceId);
|
|
8494
8494
|
const tableName = getTableName3({
|
|
8495
8495
|
indexName: OM_TABLE,
|
|
8496
8496
|
schemaName: getSchemaName3(this.#schema)
|
|
8497
8497
|
});
|
|
8498
|
-
const
|
|
8499
|
-
|
|
8500
|
-
|
|
8501
|
-
)
|
|
8498
|
+
const conditions = [`"lookupKey" = $1`];
|
|
8499
|
+
const params = [lookupKey];
|
|
8500
|
+
let paramIndex = 2;
|
|
8501
|
+
if (options?.from) {
|
|
8502
|
+
conditions.push(`"createdAtZ" >= $${paramIndex}`);
|
|
8503
|
+
params.push(options.from.toISOString());
|
|
8504
|
+
paramIndex++;
|
|
8505
|
+
}
|
|
8506
|
+
if (options?.to) {
|
|
8507
|
+
conditions.push(`"createdAtZ" <= $${paramIndex}`);
|
|
8508
|
+
params.push(options.to.toISOString());
|
|
8509
|
+
paramIndex++;
|
|
8510
|
+
}
|
|
8511
|
+
params.push(limit);
|
|
8512
|
+
let sql = `SELECT * FROM ${tableName} WHERE ${conditions.join(" AND ")} ORDER BY "generationCount" DESC LIMIT $${paramIndex}`;
|
|
8513
|
+
paramIndex++;
|
|
8514
|
+
if (options?.offset != null) {
|
|
8515
|
+
params.push(options.offset);
|
|
8516
|
+
sql += ` OFFSET $${paramIndex}`;
|
|
8517
|
+
}
|
|
8518
|
+
const result = await this.#db.client.manyOrNone(sql, params);
|
|
8502
8519
|
if (!result) return [];
|
|
8503
8520
|
return result.map((row) => this.parseOMRow(row));
|
|
8504
8521
|
} catch (error$1) {
|
|
@@ -9051,6 +9068,45 @@ var MemoryPG = class _MemoryPG extends storage.MemoryStorage {
|
|
|
9051
9068
|
);
|
|
9052
9069
|
}
|
|
9053
9070
|
}
|
|
9071
|
+
async updateObservationalMemoryConfig(input) {
|
|
9072
|
+
try {
|
|
9073
|
+
const tableName = getTableName3({
|
|
9074
|
+
indexName: OM_TABLE,
|
|
9075
|
+
schemaName: getSchemaName3(this.#schema)
|
|
9076
|
+
});
|
|
9077
|
+
const selectResult = await this.#db.client.query(`SELECT config FROM ${tableName} WHERE id = $1`, [input.id]);
|
|
9078
|
+
if (selectResult.rowCount === 0) {
|
|
9079
|
+
throw new error.MastraError({
|
|
9080
|
+
id: storage.createStorageErrorId("PG", "UPDATE_OM_CONFIG", "NOT_FOUND"),
|
|
9081
|
+
text: `Observational memory record not found: ${input.id}`,
|
|
9082
|
+
domain: error.ErrorDomain.STORAGE,
|
|
9083
|
+
category: error.ErrorCategory.THIRD_PARTY,
|
|
9084
|
+
details: { id: input.id }
|
|
9085
|
+
});
|
|
9086
|
+
}
|
|
9087
|
+
const row = selectResult.rows[0];
|
|
9088
|
+
const existing = row.config ? typeof row.config === "string" ? JSON.parse(row.config) : row.config : {};
|
|
9089
|
+
const merged = this.deepMergeConfig(existing, input.config);
|
|
9090
|
+
const nowStr = (/* @__PURE__ */ new Date()).toISOString();
|
|
9091
|
+
await this.#db.client.query(
|
|
9092
|
+
`UPDATE ${tableName} SET config = $1, "updatedAt" = $2, "updatedAtZ" = $3 WHERE id = $4`,
|
|
9093
|
+
[JSON.stringify(merged), nowStr, nowStr, input.id]
|
|
9094
|
+
);
|
|
9095
|
+
} catch (error$1) {
|
|
9096
|
+
if (error$1 instanceof error.MastraError) {
|
|
9097
|
+
throw error$1;
|
|
9098
|
+
}
|
|
9099
|
+
throw new error.MastraError(
|
|
9100
|
+
{
|
|
9101
|
+
id: storage.createStorageErrorId("PG", "UPDATE_OM_CONFIG", "FAILED"),
|
|
9102
|
+
domain: error.ErrorDomain.STORAGE,
|
|
9103
|
+
category: error.ErrorCategory.THIRD_PARTY,
|
|
9104
|
+
details: { id: input.id }
|
|
9105
|
+
},
|
|
9106
|
+
error$1
|
|
9107
|
+
);
|
|
9108
|
+
}
|
|
9109
|
+
}
|
|
9054
9110
|
// ============================================
|
|
9055
9111
|
// Async Buffering Methods
|
|
9056
9112
|
// ============================================
|