@mastra/pg 1.12.1 → 1.13.0-alpha.1
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 +91 -0
- package/dist/docs/SKILL.md +1 -1
- package/dist/docs/assets/SOURCE_MAP.json +1 -1
- package/dist/docs/references/docs-memory-working-memory.md +2 -2
- package/dist/docs/references/reference-storage-composite.md +34 -2
- package/dist/docs/references/reference-storage-postgresql.md +1 -1
- package/dist/index.cjs +3837 -147
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +3836 -149
- package/dist/index.js.map +1 -1
- package/dist/{storage → shared}/pool-config.d.ts +10 -2
- package/dist/shared/pool-config.d.ts.map +1 -0
- package/dist/storage/domains/agents/index.d.ts.map +1 -1
- package/dist/storage/domains/background-tasks/index.d.ts.map +1 -1
- package/dist/storage/domains/blobs/index.d.ts +1 -0
- package/dist/storage/domains/blobs/index.d.ts.map +1 -1
- package/dist/storage/domains/mcp-clients/index.d.ts +2 -0
- package/dist/storage/domains/mcp-clients/index.d.ts.map +1 -1
- package/dist/storage/domains/mcp-servers/index.d.ts +2 -0
- package/dist/storage/domains/mcp-servers/index.d.ts.map +1 -1
- package/dist/storage/domains/observability/v-next/ddl.d.ts +55 -0
- package/dist/storage/domains/observability/v-next/ddl.d.ts.map +1 -0
- package/dist/storage/domains/observability/v-next/discovery.d.ts +52 -0
- package/dist/storage/domains/observability/v-next/discovery.d.ts.map +1 -0
- package/dist/storage/domains/observability/v-next/feedback.d.ts +17 -0
- package/dist/storage/domains/observability/v-next/feedback.d.ts.map +1 -0
- package/dist/storage/domains/observability/v-next/filters.d.ts +29 -0
- package/dist/storage/domains/observability/v-next/filters.d.ts.map +1 -0
- package/dist/storage/domains/observability/v-next/helpers.d.ts +33 -0
- package/dist/storage/domains/observability/v-next/helpers.d.ts.map +1 -0
- package/dist/storage/domains/observability/v-next/index.d.ts +104 -0
- package/dist/storage/domains/observability/v-next/index.d.ts.map +1 -0
- package/dist/storage/domains/observability/v-next/listing.d.ts +53 -0
- package/dist/storage/domains/observability/v-next/listing.d.ts.map +1 -0
- package/dist/storage/domains/observability/v-next/logs.d.ts +8 -0
- package/dist/storage/domains/observability/v-next/logs.d.ts.map +1 -0
- package/dist/storage/domains/observability/v-next/metrics.d.ts +19 -0
- package/dist/storage/domains/observability/v-next/metrics.d.ts.map +1 -0
- package/dist/storage/domains/observability/v-next/olap.d.ts +93 -0
- package/dist/storage/domains/observability/v-next/olap.d.ts.map +1 -0
- package/dist/storage/domains/observability/v-next/partitioning.d.ts +76 -0
- package/dist/storage/domains/observability/v-next/partitioning.d.ts.map +1 -0
- package/dist/storage/domains/observability/v-next/pg-errors.d.ts +25 -0
- package/dist/storage/domains/observability/v-next/pg-errors.d.ts.map +1 -0
- package/dist/storage/domains/observability/v-next/polling.d.ts +28 -0
- package/dist/storage/domains/observability/v-next/polling.d.ts.map +1 -0
- package/dist/storage/domains/observability/v-next/scores.d.ts +17 -0
- package/dist/storage/domains/observability/v-next/scores.d.ts.map +1 -0
- package/dist/storage/domains/observability/v-next/signal-schema.d.ts +776 -0
- package/dist/storage/domains/observability/v-next/signal-schema.d.ts.map +1 -0
- package/dist/storage/domains/observability/v-next/sql.d.ts +31 -0
- package/dist/storage/domains/observability/v-next/sql.d.ts.map +1 -0
- package/dist/storage/domains/observability/v-next/traces.d.ts +16 -0
- package/dist/storage/domains/observability/v-next/traces.d.ts.map +1 -0
- package/dist/storage/domains/observability/v-next/tracing.d.ts +19 -0
- package/dist/storage/domains/observability/v-next/tracing.d.ts.map +1 -0
- package/dist/storage/domains/skills/index.d.ts +2 -0
- package/dist/storage/domains/skills/index.d.ts.map +1 -1
- package/dist/storage/domains/tool-provider-connections/index.d.ts +20 -0
- package/dist/storage/domains/tool-provider-connections/index.d.ts.map +1 -0
- package/dist/storage/domains/workflows/index.d.ts.map +1 -1
- package/dist/storage/domains/workspaces/index.d.ts +2 -0
- package/dist/storage/domains/workspaces/index.d.ts.map +1 -1
- package/dist/storage/index.d.ts +89 -1
- package/dist/storage/index.d.ts.map +1 -1
- package/dist/vector/index.d.ts.map +1 -1
- package/package.json +9 -7
- package/dist/storage/pool-config.d.ts.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,96 @@
|
|
|
1
1
|
# @mastra/pg
|
|
2
2
|
|
|
3
|
+
## 1.13.0-alpha.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- dependencies updates: ([#17148](https://github.com/mastra-ai/mastra/pull/17148))
|
|
8
|
+
- Updated dependency [`pg@^8.21.0` ↗︎](https://www.npmjs.com/package/pg/v/8.21.0) (from `^8.20.0`, in `dependencies`)
|
|
9
|
+
|
|
10
|
+
- Fixed `PgVector` ignoring an explicit `ssl` option when the connection string also contained an `sslmode=` (or `ssl=`) query parameter. `node-postgres` re-parses the connection string and overwrote the explicit `ssl` object, causing `UNABLE_TO_GET_ISSUER_CERT_LOCALLY` / "self-signed certificate" errors against self-signed or internal CAs even when verification was meant to be skipped. ([#17650](https://github.com/mastra-ai/mastra/pull/17650))
|
|
11
|
+
|
|
12
|
+
`PgVector` now honors an explicit `ssl` option over the connection string, matching the existing `PostgresStore` behavior. Connection-string-only SSL (`?sslmode=require` with no explicit `ssl`) keeps working as before.
|
|
13
|
+
|
|
14
|
+
```ts
|
|
15
|
+
import { PgVector } from '@mastra/pg';
|
|
16
|
+
|
|
17
|
+
// This now connects instead of throwing UNABLE_TO_GET_ISSUER_CERT_LOCALLY
|
|
18
|
+
const vector = new PgVector({
|
|
19
|
+
id: 'my-vector',
|
|
20
|
+
connectionString: 'postgresql://user:pass@host:5432/db?sslmode=require',
|
|
21
|
+
ssl: { rejectUnauthorized: false },
|
|
22
|
+
});
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
- Make atomic db updates better ([#16796](https://github.com/mastra-ai/mastra/pull/16796))
|
|
26
|
+
|
|
27
|
+
- Updated dependencies [[`575f815`](https://github.com/mastra-ai/mastra/commit/575f815c5c3567b71c0b83cbb7fa98c8253a9d9c), [`306909a`](https://github.com/mastra-ai/mastra/commit/306909a693de77d709b38706e2673c9547d24a28), [`5191af8`](https://github.com/mastra-ai/mastra/commit/5191af80c799eea25357c545fc05d91b3883531d), [`43bd3d4`](https://github.com/mastra-ai/mastra/commit/43bd3d421987463fdf35386a45199c49499ed069), [`e6fa79e`](https://github.com/mastra-ai/mastra/commit/e6fa79ec72a2ddffdd25e85270398951e9d552a4), [`904bcdf`](https://github.com/mastra-ai/mastra/commit/904bcdf7b8004aa7be823f9f70ca63580e47e470), [`7f5ee1d`](https://github.com/mastra-ai/mastra/commit/7f5ee1dca46daee8d2817f2ebe49e6335da81956), [`1e9aab5`](https://github.com/mastra-ai/mastra/commit/1e9aab50ff11e6e88fde4d7cbf512c44a9fe8d61), [`bf8eb6d`](https://github.com/mastra-ai/mastra/commit/bf8eb6d0ec213a403eb9265a594ad283c44ab3dc), [`493a328`](https://github.com/mastra-ai/mastra/commit/493a328f4346a1deeb9f1e2e44c8f2a3a4d7591b), [`029a414`](https://github.com/mastra-ai/mastra/commit/029a4141719793bd3e898a39eb5a0466a55f5f3a), [`b147b29`](https://github.com/mastra-ai/mastra/commit/b147b2907f0cd1aa812efe6d6e3f58d22e66fc88), [`d371ac1`](https://github.com/mastra-ai/mastra/commit/d371ac1d9820afaaf7cfdbc380a475946a994d8f), [`cf182b7`](https://github.com/mastra-ai/mastra/commit/cf182b7fb495767946d9840ef29f19cfa906f31f), [`a049c2a`](https://github.com/mastra-ai/mastra/commit/a049c2a9dfb41d0ee2e7a28874a88cd64fd5669f), [`b147b29`](https://github.com/mastra-ai/mastra/commit/b147b2907f0cd1aa812efe6d6e3f58d22e66fc88), [`2a96528`](https://github.com/mastra-ai/mastra/commit/2a9652848dfa3c5a2426f952e9d93554c26fd90f), [`2656d9c`](https://github.com/mastra-ai/mastra/commit/2656d9c2976d4f3354253bfbbbf9b88a1b2bbf34), [`63e3fe1`](https://github.com/mastra-ai/mastra/commit/63e3fe13cc1ea96f91d7c68aea92f400faf9e4da), [`1d4ce8d`](https://github.com/mastra-ai/mastra/commit/1d4ce8daaa54511f325c1b609d31b8e54009d677), [`8c68372`](https://github.com/mastra-ai/mastra/commit/8c68372e85fe0b066ec12c58bd29ffb93e54c552)]:
|
|
28
|
+
- @mastra/core@1.42.0-alpha.4
|
|
29
|
+
|
|
30
|
+
## 1.13.0-alpha.0
|
|
31
|
+
|
|
32
|
+
### Minor Changes
|
|
33
|
+
|
|
34
|
+
- Add the v-next observability storage domain for `@mastra/pg`, an insert-only, ([#16760](https://github.com/mastra-ai/mastra/pull/16760))
|
|
35
|
+
partitioned Postgres adapter for low-volume observability (~100 calls/sec,
|
|
36
|
+
up to roughly 1,500 calls/sec sustained on a single primary).
|
|
37
|
+
|
|
38
|
+
The new `PostgresStoreVNext` composes a primary `PostgresStore` (memory,
|
|
39
|
+
workflows, scores, agents, etc.) with an `ObservabilityStoragePostgresVNext`
|
|
40
|
+
for spans, logs, metrics, scores, and feedback. All observability writes go
|
|
41
|
+
through a single multi-row `INSERT ... ON CONFLICT DO NOTHING` path. Storage
|
|
42
|
+
is partitioned per day with three modes auto-detected at `init()` time:
|
|
43
|
+
TimescaleDB hypertables, pg_partman (4.x or 5.x), or native Postgres range
|
|
44
|
+
partitions. Root-span lookups are served by partial indexes, and OLAP queries
|
|
45
|
+
(aggregates, breakdowns, time-series, percentiles) prune partitions by
|
|
46
|
+
`timestamp`. A small discovery cache table powers stale-while-revalidate
|
|
47
|
+
lookups for entity names/types/labels.
|
|
48
|
+
|
|
49
|
+
The `observability` connection is **required** — callers always make an
|
|
50
|
+
explicit decision about where observability data lives. For production,
|
|
51
|
+
point it at a dedicated Postgres instance to keep OLAP scans from
|
|
52
|
+
contending with your primary OLTP workload. Reusing the primary
|
|
53
|
+
connection works for local development and logs a runtime warning on every
|
|
54
|
+
construction.
|
|
55
|
+
|
|
56
|
+
```typescript
|
|
57
|
+
import { Mastra } from '@mastra/core';
|
|
58
|
+
import { PostgresStoreVNext } from '@mastra/pg';
|
|
59
|
+
|
|
60
|
+
export const mastra = new Mastra({
|
|
61
|
+
storage: new PostgresStoreVNext({
|
|
62
|
+
id: 'app',
|
|
63
|
+
connectionString: process.env.DATABASE_URL!,
|
|
64
|
+
observability: {
|
|
65
|
+
connectionString: process.env.OBSERVABILITY_DATABASE_URL!,
|
|
66
|
+
},
|
|
67
|
+
}),
|
|
68
|
+
});
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
Delta polling uses Postgres transaction IDs and a safe transaction horizon so
|
|
72
|
+
concurrent writers cannot cause late-committing rows to be skipped. The
|
|
73
|
+
`observability-delta-polling` feature flag is opt-in.
|
|
74
|
+
|
|
75
|
+
`ensureNativePartitions()` swallows the `42P07 relation already exists`
|
|
76
|
+
error around `CREATE TABLE IF NOT EXISTS … PARTITION OF`, matching the
|
|
77
|
+
existing guard used for base-table and index DDL. This makes concurrent
|
|
78
|
+
`init()` from two processes (serverless cold-start, blue/green overlap, two
|
|
79
|
+
stores sharing a schema) idempotent instead of letting the loser surface an
|
|
80
|
+
unhandled duplicate-relation error.
|
|
81
|
+
|
|
82
|
+
### Patch Changes
|
|
83
|
+
|
|
84
|
+
- Added full Agent Builder storage support to the PostgreSQL adapter, bringing it to parity with libSQL. ([#17596](https://github.com/mastra-ai/mastra/pull/17596))
|
|
85
|
+
|
|
86
|
+
Previously, projects using PostgreSQL could not store tool provider connections or agent tool providers, and several Agent Builder tables were missing from the exported schema.
|
|
87
|
+
- Added storage for tool provider connections, so connections can be created, read, listed by author, and deleted on PostgreSQL.
|
|
88
|
+
- Agent versions now persist their tool providers on PostgreSQL across save and load.
|
|
89
|
+
- Fixed schema export so all Agent Builder tables are included.
|
|
90
|
+
|
|
91
|
+
- Updated dependencies [[`d468acb`](https://github.com/mastra-ai/mastra/commit/d468acb07aec1bb19a2cb0ada8042b05b46746b2), [`e9be4e7`](https://github.com/mastra-ai/mastra/commit/e9be4e747ec3d8b65548bff92f9377db06105376), [`d53cfc2`](https://github.com/mastra-ai/mastra/commit/d53cfc2c7f8d78343a4aa84ec4e129ba25f3325e), [`65799d4`](https://github.com/mastra-ai/mastra/commit/65799d4d549e5ebb9c848fbe3f51ac090f64becf), [`c268c89`](https://github.com/mastra-ai/mastra/commit/c268c89f4c63a93ee474d3cffdf3ea60bf00d4f2), [`d468acb`](https://github.com/mastra-ai/mastra/commit/d468acb07aec1bb19a2cb0ada8042b05b46746b2), [`0c72f03`](https://github.com/mastra-ai/mastra/commit/0c72f032abb13254df5a7856d64be2f207b8006d), [`3b45ea9`](https://github.com/mastra-ai/mastra/commit/3b45ea95015557a6cb9d70dc5252af54ab1b78ac), [`f084be1`](https://github.com/mastra-ai/mastra/commit/f084be1fcbe33ad7480913e44d6130c421c0976f)]:
|
|
92
|
+
- @mastra/core@1.42.0-alpha.0
|
|
93
|
+
|
|
3
94
|
## 1.12.1
|
|
4
95
|
|
|
5
96
|
### Patch Changes
|
package/dist/docs/SKILL.md
CHANGED
|
@@ -413,12 +413,12 @@ const memory = new Memory({
|
|
|
413
413
|
What changes:
|
|
414
414
|
|
|
415
415
|
- **Storage is identical.** The same resource/thread `workingMemory` field is read and written.
|
|
416
|
-
- **The tool is the same shape, exposed under a new name.** Writes still flow through the same underlying tool; on this path it
|
|
416
|
+
- **The tool is the same shape, exposed under a new name.** Writes still flow through the same underlying tool; on this path it's registered as `setWorkingMemory` (instead of `updateWorkingMemory`). The rename keeps legacy strip filters from removing tool-call parts so they persist as a normal audit trail and the next model step picks the new value up automatically.
|
|
417
417
|
- **Delivery only.** Instead of folding into the system prompt, `Memory` auto-attaches a `WorkingMemoryStateProcessor` that emits the current working memory as a `state` signal with `stateId: 'working-memory'`.
|
|
418
418
|
|
|
419
419
|
You inherit the standard state-signal benefits: thread-scoped tracking metadata, `cacheKey` dedup so identical snapshots are only emitted once, and `contextWindow.hasSnapshot` re-injection when an older snapshot rolls out of the window.
|
|
420
420
|
|
|
421
|
-
The default (`useStateSignals: false`) keeps the existing system-message behavior unchanged. `useStateSignals`
|
|
421
|
+
The default (`useStateSignals: false`) keeps the existing system-message behavior unchanged. `useStateSignals` isn't supported with template working memory `version: 'vnext'`.
|
|
422
422
|
|
|
423
423
|
## Examples
|
|
424
424
|
|
|
@@ -240,6 +240,38 @@ const storage = new MastraCompositeStore({
|
|
|
240
240
|
})
|
|
241
241
|
```
|
|
242
242
|
|
|
243
|
-
> **Note:** `ObservabilityStorageClickhouseVNext` is the current observability domain implementation. The legacy `ObservabilityStorageClickhouse` class is also exported and remains supported for projects that
|
|
243
|
+
> **Note:** `ObservabilityStorageClickhouseVNext` is the current observability domain implementation. The legacy `ObservabilityStorageClickhouse` class is also exported and remains supported for projects that haven't migrated. See the [ClickHouse storage reference](https://mastra.ai/reference/storage/clickhouse) for details.
|
|
244
244
|
|
|
245
|
-
|
|
245
|
+
### Replicated ClickHouse for multi-replica clusters
|
|
246
|
+
|
|
247
|
+
For self-managed ClickHouse clusters with multiple replicas, set `replication` so Mastra emits `ReplicatedMergeTree` engines and applies `ON CLUSTER` to its DDL:
|
|
248
|
+
|
|
249
|
+
```typescript
|
|
250
|
+
import { MastraCompositeStore } from '@mastra/core/storage'
|
|
251
|
+
import { MemoryPG, WorkflowsPG, ScoresPG } from '@mastra/pg'
|
|
252
|
+
import { ObservabilityStorageClickhouseVNext } from '@mastra/clickhouse'
|
|
253
|
+
|
|
254
|
+
const storage = new MastraCompositeStore({
|
|
255
|
+
id: 'composite',
|
|
256
|
+
domains: {
|
|
257
|
+
memory: new MemoryPG({ connectionString: process.env.DATABASE_URL }),
|
|
258
|
+
workflows: new WorkflowsPG({ connectionString: process.env.DATABASE_URL }),
|
|
259
|
+
scores: new ScoresPG({ connectionString: process.env.DATABASE_URL }),
|
|
260
|
+
observability: new ObservabilityStorageClickhouseVNext({
|
|
261
|
+
url: process.env.CLICKHOUSE_URL,
|
|
262
|
+
username: process.env.CLICKHOUSE_USERNAME,
|
|
263
|
+
password: process.env.CLICKHOUSE_PASSWORD,
|
|
264
|
+
replication: {
|
|
265
|
+
cluster: 'production_cluster',
|
|
266
|
+
// Optional (defaults shown):
|
|
267
|
+
// zookeeperPath: '/clickhouse/tables/{shard}/{database}/{table}',
|
|
268
|
+
// replicaName: '{replica}',
|
|
269
|
+
},
|
|
270
|
+
}),
|
|
271
|
+
},
|
|
272
|
+
})
|
|
273
|
+
```
|
|
274
|
+
|
|
275
|
+
Do not set `replication` on ClickHouse Cloud. Cloud rewrites `MergeTree` to `SharedMergeTree` server-side. See the [ClickHouse storage reference](https://mastra.ai/reference/storage/clickhouse) for the full config shape and operator notes.
|
|
276
|
+
|
|
277
|
+
> **Info:** This approach is also required when using storage providers that don't support observability (like Convex, DynamoDB, or Cloudflare). See the [MastraStorageExporter documentation](https://mastra.ai/docs/observability/integrations/exporters/mastra-storage) for the full list of supported providers.
|
|
@@ -140,7 +140,7 @@ The storage implementation handles schema creation and updates automatically. It
|
|
|
140
140
|
|
|
141
141
|
PostgreSQL supports observability and can handle low trace volumes. Throughput capacity depends on deployment factors such as hardware, schema design, indexing, and retention policies, and should be validated for your specific environment. For high-volume production environments, consider:
|
|
142
142
|
|
|
143
|
-
- Using the `insert-only` [tracing strategy](https://mastra.ai/docs/observability/
|
|
143
|
+
- Using the `insert-only` [tracing strategy](https://mastra.ai/docs/observability/integrations/exporters/mastra-storage) to reduce database write operations
|
|
144
144
|
- Setting up table partitioning for efficient data retention
|
|
145
145
|
- Migrating observability to [ClickHouse via composite storage](https://mastra.ai/reference/storage/composite) if you need to scale further
|
|
146
146
|
|