@mastra/pg 1.22.2 → 1.22.3-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/dist/docs/SKILL.md +21 -21
- package/dist/docs/assets/SOURCE_MAP.json +1 -1
- package/dist/docs/references/docs-deployment-workers.md +2 -2
- package/dist/docs/references/docs-memory-semantic-recall.md +0 -2
- package/dist/docs/references/docs-memory-working-memory.md +1 -1
- package/dist/docs/references/reference-processors-working-memory-processor.md +1 -1
- package/dist/docs/references/reference-rag-vector-databases.md +33 -33
- package/dist/docs/references/reference-storage-composite.md +1 -1
- package/dist/docs/references/reference-storage-retention.md +4 -4
- package/dist/index.cjs +9 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +9 -0
- package/dist/index.js.map +1 -1
- package/dist/shared/config.d.ts.map +1 -1
- package/dist/storage/client.d.ts.map +1 -1
- package/dist/storage/db/index.d.ts.map +1 -1
- 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.map +1 -1
- package/dist/storage/domains/channels/index.d.ts.map +1 -1
- package/dist/storage/domains/datasets/index.d.ts.map +1 -1
- package/dist/storage/domains/experiments/index.d.ts.map +1 -1
- package/dist/storage/domains/favorites/index.d.ts.map +1 -1
- package/dist/storage/domains/knowledge/index.d.ts.map +1 -1
- package/dist/storage/domains/mcp-clients/index.d.ts.map +1 -1
- package/dist/storage/domains/mcp-servers/index.d.ts.map +1 -1
- package/dist/storage/domains/memory/index.d.ts.map +1 -1
- package/dist/storage/domains/memory/test-utils.d.ts +1 -1
- package/dist/storage/domains/memory/test-utils.d.ts.map +1 -1
- package/dist/storage/domains/notifications/index.d.ts.map +1 -1
- package/dist/storage/domains/observability/index.d.ts.map +1 -1
- package/dist/storage/domains/observability/v-next/index.d.ts.map +1 -1
- package/dist/storage/domains/observability/v-next/signal-schema.d.ts +400 -400
- package/dist/storage/domains/observability/v-next/signal-schema.d.ts.map +1 -1
- package/dist/storage/domains/prompt-blocks/index.d.ts.map +1 -1
- package/dist/storage/domains/schedules/index.d.ts.map +1 -1
- package/dist/storage/domains/scorer-definitions/index.d.ts.map +1 -1
- package/dist/storage/domains/scores/index.d.ts.map +1 -1
- package/dist/storage/domains/skills/index.d.ts.map +1 -1
- package/dist/storage/domains/thread-state/index.d.ts.map +1 -1
- package/dist/storage/domains/tool-provider-connections/index.d.ts.map +1 -1
- package/dist/storage/domains/workflow-definitions/index.d.ts.map +1 -1
- package/dist/storage/domains/workflows/index.d.ts.map +1 -1
- package/dist/storage/domains/workspaces/index.d.ts.map +1 -1
- package/dist/storage/factory-storage.d.ts.map +1 -1
- package/dist/storage/index.d.ts.map +1 -1
- package/dist/storage/performance-indexes/performance-test.d.ts.map +1 -1
- package/dist/vector/filter.d.ts.map +1 -1
- package/dist/vector/index.d.ts.map +1 -1
- package/dist/vector/performance.helpers.d.ts.map +1 -1
- package/package.json +5 -6
- package/CHANGELOG.md +0 -9004
package/dist/docs/SKILL.md
CHANGED
|
@@ -3,7 +3,7 @@ name: mastra-pg
|
|
|
3
3
|
description: Documentation for @mastra/pg. Use when working with @mastra/pg APIs, configuration, or implementation.
|
|
4
4
|
metadata:
|
|
5
5
|
package: "@mastra/pg"
|
|
6
|
-
version: "1.22.
|
|
6
|
+
version: "1.22.3-alpha.1"
|
|
7
7
|
---
|
|
8
8
|
|
|
9
9
|
## When to use
|
|
@@ -16,32 +16,32 @@ Read the individual reference documents for detailed explanations and code examp
|
|
|
16
16
|
|
|
17
17
|
### Docs
|
|
18
18
|
|
|
19
|
-
- [Workers](references/docs-deployment-workers.md) -
|
|
20
|
-
- [Semantic recall](references/docs-memory-semantic-recall.md) -
|
|
21
|
-
- [Working memory](references/docs-memory-working-memory.md) -
|
|
22
|
-
- [Storage](references/docs-storage.md) - Configure storage
|
|
19
|
+
- [Workers](references/docs-deployment-workers.md) - Run Mastra workflow orchestration, schedules, and long-running background tasks in dedicated workers to keep API processes responsive under load.
|
|
20
|
+
- [Semantic recall](references/docs-memory-semantic-recall.md) - Retrieve relevant messages from past Mastra conversations with semantic recall, vector search, embeddings, metadata filters, and configurable storage.
|
|
21
|
+
- [Working memory](references/docs-memory-working-memory.md) - Persist user profiles, preferences, and application data with Mastra working memory using resource- or thread-scoped templates and storage adapters.
|
|
22
|
+
- [Storage](references/docs-storage.md) - Configure Mastra storage to persist memory, workflow state, observability data, evals, schedules, and long-running agent state across restarts.
|
|
23
23
|
|
|
24
24
|
### Integrations
|
|
25
25
|
|
|
26
|
-
- [DynamoDB](references/integrations-databases-dynamodb.md) -
|
|
27
|
-
- [Neon Postgres](references/integrations-databases-neon.md) -
|
|
28
|
-
- [PostgreSQL](references/integrations-databases-postgresql.md) -
|
|
26
|
+
- [DynamoDB](references/integrations-databases-dynamodb.md) - Persist Mastra data in Amazon DynamoDB with a single-table ElectroDB design, configurable indexes, TTL support, credentials, and table initialization.
|
|
27
|
+
- [Neon Postgres](references/integrations-databases-neon.md) - Connect Mastra to Neon Postgres with PostgresStore, pooled production connections, schema initialization, vector search, and Neon agent skills.
|
|
28
|
+
- [PostgreSQL](references/integrations-databases-postgresql.md) - Persist Mastra application data in PostgreSQL with PostgresStore, configure connections and pools, initialize schemas, and enable observability.
|
|
29
29
|
|
|
30
30
|
### Reference
|
|
31
31
|
|
|
32
|
-
- [Reference: Memory class](references/reference-memory-memory-class.md) -
|
|
33
|
-
- [Reference: MessageHistory](references/reference-processors-message-history-processor.md) -
|
|
34
|
-
- [Reference: SemanticRecall](references/reference-processors-semantic-recall-processor.md) -
|
|
35
|
-
- [Reference: WorkingMemory](references/reference-processors-working-memory-processor.md) -
|
|
36
|
-
- [Chunking and embedding documents](references/reference-rag-chunking-and-embedding.md) -
|
|
37
|
-
- [Reference: Metadata filters](references/reference-rag-metadata-filters.md) -
|
|
38
|
-
- [RAG (Retrieval-Augmented Generation) in Mastra](references/reference-rag-overview.md) -
|
|
39
|
-
- [Retrieval, semantic search, reranking](references/reference-rag-retrieval.md) -
|
|
40
|
-
- [Storing embeddings in a vector database](references/reference-rag-vector-databases.md) -
|
|
41
|
-
- [Reference: Composite storage](references/reference-storage-composite.md) -
|
|
42
|
-
- [Reference: Storage retention (prune)](references/reference-storage-retention.md) -
|
|
43
|
-
- [Reference: createVectorQueryTool()](references/reference-tools-vector-query-tool.md) -
|
|
44
|
-
- [Reference: PG vector store](references/reference-vectors-pg.md) -
|
|
32
|
+
- [Reference: Memory class](references/reference-memory-memory-class.md) - The Memory class provides a reliable system for managing conversation history and thread-based message storage in Mastra.
|
|
33
|
+
- [Reference: MessageHistory](references/reference-processors-message-history-processor.md) - The MessageHistory is a hybrid processor that handles both retrieval and persistence of message history.
|
|
34
|
+
- [Reference: SemanticRecall](references/reference-processors-semantic-recall-processor.md) - The SemanticRecall is a hybrid processor that enables semantic search over conversation history using vector embeddings.
|
|
35
|
+
- [Reference: WorkingMemory](references/reference-processors-working-memory-processor.md) - The WorkingMemory is an input processor that injects working memory data as a system message.
|
|
36
|
+
- [Chunking and embedding documents](references/reference-rag-chunking-and-embedding.md) - Chunk documents with MDocument, generate embeddings through the AI SDK, and prepare text and metadata for vector storage and RAG retrieval.
|
|
37
|
+
- [Reference: Metadata filters](references/reference-rag-metadata-filters.md) - Mastra provides a unified metadata filtering syntax across all vector stores, based on MongoDB/Sift query syntax.
|
|
38
|
+
- [RAG (Retrieval-Augmented Generation) in Mastra](references/reference-rag-overview.md) - RAG in Mastra helps you enhance LLM outputs by incorporating relevant context from your own data sources, improving accuracy and grounding responses in real information.
|
|
39
|
+
- [Retrieval, semantic search, reranking](references/reference-rag-retrieval.md) - After storing embeddings, you need to retrieve relevant chunks to answer user queries.
|
|
40
|
+
- [Storing embeddings in a vector database](references/reference-rag-vector-databases.md) - After generating embeddings, you need to store them in a database that supports vector similarity search.
|
|
41
|
+
- [Reference: Composite storage](references/reference-storage-composite.md) - MastraCompositeStore can compose storage domains from different providers. Use it when you need different databases for different purposes.
|
|
42
|
+
- [Reference: Storage retention (prune)](references/reference-storage-retention.md) - prune() deletes rows. It caps growth and is safe to run against large tables (batched, bounded, resumable, cancellable).
|
|
43
|
+
- [Reference: createVectorQueryTool()](references/reference-tools-vector-query-tool.md) - The createVectorQueryTool() function creates a tool for semantic search over vector stores.
|
|
44
|
+
- [Reference: PG vector store](references/reference-vectors-pg.md) - The PgVector class provides vector search using PostgreSQL with pgvector extension. It provides reliable vector similarity search capabilities within your existing PostgreSQL database.
|
|
45
45
|
|
|
46
46
|
|
|
47
47
|
Read [assets/SOURCE_MAP.json](assets/SOURCE_MAP.json) for source code references.
|
|
@@ -27,7 +27,7 @@ Mastra has three built-in worker types. Each handles a specific kind of backgrou
|
|
|
27
27
|
|
|
28
28
|
### Orchestration worker
|
|
29
29
|
|
|
30
|
-
|
|
30
|
+
This worker subscribes to workflow events on the [PubSub](https://mastra.ai/docs/server/pubsub) bus and executes workflow steps. It handles each `workflow.start` and lifecycle event together with every step transition.
|
|
31
31
|
|
|
32
32
|
In a split deployment, the orchestration worker pulls events from a distributed PubSub backend and delegates step execution back to the API over HTTP. In-process, it runs steps directly.
|
|
33
33
|
|
|
@@ -377,7 +377,7 @@ If the API crashes while a step is executing, that work can be lost and the work
|
|
|
377
377
|
|
|
378
378
|
- **No dead-letter queue**: Failed events are nacked and retried, but there's no DLQ for events that fail after all retries.
|
|
379
379
|
- **Scheduler is single-instance**: Running multiple scheduler processes causes duplicate schedule fires.
|
|
380
|
-
- **Runs stuck in "running" after API crash**:
|
|
380
|
+
- **Runs stuck in "running" after API crash**: A crash during workflow-step execution leaves the run in `running` status without an automatic retry. For [durable agents](https://mastra.ai/docs/harness/durable-agents), configure `recovery.durableAgents: 'auto'` so a server restart automatically re-drives orphaned runs. See [Crash recovery](https://mastra.ai/docs/harness/durable-agents) for details.
|
|
381
381
|
|
|
382
382
|
## Related
|
|
383
383
|
|
|
@@ -14,8 +14,6 @@ Semantic recall is RAG-based search that helps agents maintain context across lo
|
|
|
14
14
|
|
|
15
15
|
It uses vector embeddings of messages for similarity search and integrates with vector stores, plus has configurable context windows around retrieved messages.
|
|
16
16
|
|
|
17
|
-

|
|
18
|
-
|
|
19
17
|
When it's enabled, new messages are used to query a vector DB for semantically similar messages.
|
|
20
18
|
|
|
21
19
|
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.
|
|
@@ -275,7 +275,7 @@ Schema-based working memory uses **merge semantics**, meaning the agent only nee
|
|
|
275
275
|
## Choosing between template and schema
|
|
276
276
|
|
|
277
277
|
- 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.
|
|
278
|
-
- Use a **schema**
|
|
278
|
+
- Use a **schema** for structured, type-safe JSON data that supports validation and programmatic access. The `workingMemory.schema` field accepts any `PublicSchema`-compatible schema, such as Zod v3 or v4. JSON Schema and already-standard schemas are also supported. **Merge semantics** preserve existing fields when the agent provides only the fields to update.
|
|
279
279
|
- Only one mode can be active at a time: setting both `template` and `schema` isn't supported.
|
|
280
280
|
|
|
281
281
|
## Example: Multi-step retention
|
|
@@ -130,7 +130,7 @@ const processor = new WorkingMemory({
|
|
|
130
130
|
|
|
131
131
|
4. Generates system instructions based on mode:
|
|
132
132
|
|
|
133
|
-
- **Normal mode**: Includes guidelines for storing
|
|
133
|
+
- **Normal mode**: Includes guidelines for storing and updating information, along with the template structure and current data
|
|
134
134
|
- **Read-only mode** (`readOnly: true`): Includes only the current data as context without update instructions
|
|
135
135
|
|
|
136
136
|
5. Adds the instruction as a system message with `source: 'memory'` tag
|
|
@@ -35,11 +35,11 @@ MongoDB Vector Search is a good solution for teams who want to consolidate vecto
|
|
|
35
35
|
|
|
36
36
|
### Using VoyageAI with MongoDB
|
|
37
37
|
|
|
38
|
-
MongoDB works
|
|
38
|
+
MongoDB works directly with VoyageAI's embedding models, which are optimized for retrieval tasks. For complete examples and specialized models, see the [VoyageAI embeddings documentation](https://mastra.ai/models/embeddings) and [MongoDB vector reference](https://mastra.ai/reference/vectors/mongodb).
|
|
39
39
|
|
|
40
40
|
### Hybrid Search (Vector + Full-Text)
|
|
41
41
|
|
|
42
|
-
MongoDB supports hybrid search that
|
|
42
|
+
MongoDB supports hybrid search that combines vector similarity with BM25 full-text search through server-side `$rankFusion`. It requires MongoDB 8.0 or later, is generally available from 8.1, and is enabled on MongoDB Atlas 8.0.x. Use it to combine semantic retrieval with keyword-based results:
|
|
43
43
|
|
|
44
44
|
```ts
|
|
45
45
|
await store.createSearchIndex({ indexName: 'myCollection', fields: ['text'] })
|
|
@@ -107,7 +107,7 @@ await store.upsert({
|
|
|
107
107
|
|
|
108
108
|
### Using Oracle Database Vector Search
|
|
109
109
|
|
|
110
|
-
OracleDB stores embeddings in native `VECTOR` columns and metadata in Oracle JSON. Exact search is the default
|
|
110
|
+
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.
|
|
111
111
|
|
|
112
112
|
**Pinecone**:
|
|
113
113
|
|
|
@@ -239,8 +239,8 @@ const store = new UpstashVector({
|
|
|
239
239
|
token: process.env.UPSTASH_TOKEN,
|
|
240
240
|
})
|
|
241
241
|
|
|
242
|
-
//
|
|
243
|
-
// when you upsert if that namespace
|
|
242
|
+
// Upstash creates indexes (known as namespaces) automatically, so no store.createIndex call is needed here
|
|
243
|
+
// when you upsert if that namespace doesn't exist yet.
|
|
244
244
|
await store.upsert({
|
|
245
245
|
indexName: 'myCollection', // the namespace name in Upstash
|
|
246
246
|
vectors: embeddings,
|
|
@@ -426,20 +426,20 @@ Collection and index names must:
|
|
|
426
426
|
|
|
427
427
|
- Start with a letter or underscore
|
|
428
428
|
- Be up to 120 bytes long
|
|
429
|
-
- Contain only letters, numbers,
|
|
430
|
-
-
|
|
429
|
+
- Contain only letters, numbers, underscore characters, or dots
|
|
430
|
+
- Can't contain `$` or the null character
|
|
431
431
|
- Example: `my_collection.123` is valid
|
|
432
|
-
- Example: `my-index`
|
|
433
|
-
- Example: `My$Collection`
|
|
432
|
+
- Example: `my-index` isn't valid (contains hyphen)
|
|
433
|
+
- Example: `My$Collection` isn't valid (contains `$`)
|
|
434
434
|
|
|
435
435
|
**PgVector**:
|
|
436
436
|
|
|
437
437
|
Index names must:
|
|
438
438
|
|
|
439
439
|
- Start with a letter or underscore
|
|
440
|
-
- Contain only letters, numbers, and
|
|
440
|
+
- Contain only letters, numbers, and underscore characters
|
|
441
441
|
- Example: `my_index_123` is valid
|
|
442
|
-
- Example: `my-index`
|
|
442
|
+
- Example: `my-index` isn't valid (contains hyphen)
|
|
443
443
|
|
|
444
444
|
**OracleDB**:
|
|
445
445
|
|
|
@@ -466,7 +466,7 @@ Index names must:
|
|
|
466
466
|
- Have a combined length (with project ID) under 52 characters
|
|
467
467
|
|
|
468
468
|
- Example: `my-index-123` is valid
|
|
469
|
-
- Example: `my.index`
|
|
469
|
+
- Example: `my.index` isn't valid (contains dot)
|
|
470
470
|
|
|
471
471
|
**Qdrant**:
|
|
472
472
|
|
|
@@ -482,7 +482,7 @@ Collection names must:
|
|
|
482
482
|
|
|
483
483
|
- Example: `my_collection_123` is valid
|
|
484
484
|
|
|
485
|
-
- Example: `my/collection`
|
|
485
|
+
- Example: `my/collection` isn't valid (contains slash)
|
|
486
486
|
|
|
487
487
|
**Chroma**:
|
|
488
488
|
|
|
@@ -490,11 +490,11 @@ Collection names must:
|
|
|
490
490
|
|
|
491
491
|
- Be 3-63 characters long
|
|
492
492
|
- Start and end with a letter or number
|
|
493
|
-
- Contain only letters, numbers,
|
|
493
|
+
- Contain only letters, numbers, underscore characters, or hyphens
|
|
494
494
|
- Not contain consecutive periods (..)
|
|
495
495
|
- Not be a valid IPv4 address
|
|
496
496
|
- Example: `my-collection-123` is valid
|
|
497
|
-
- Example: `my..collection`
|
|
497
|
+
- Example: `my..collection` isn't valid (consecutive periods)
|
|
498
498
|
|
|
499
499
|
**Astra**:
|
|
500
500
|
|
|
@@ -502,18 +502,18 @@ Collection names must:
|
|
|
502
502
|
|
|
503
503
|
- Not be empty
|
|
504
504
|
- Be 48 characters or less
|
|
505
|
-
- Contain only letters, numbers, and
|
|
505
|
+
- Contain only letters, numbers, and `_` characters
|
|
506
506
|
- Example: `my_collection_123` is valid
|
|
507
|
-
- Example: `my-collection`
|
|
507
|
+
- Example: `my-collection` isn't valid (contains hyphen)
|
|
508
508
|
|
|
509
509
|
**libSQL**:
|
|
510
510
|
|
|
511
511
|
Index names must:
|
|
512
512
|
|
|
513
513
|
- Start with a letter or underscore
|
|
514
|
-
- Contain only letters, numbers, and
|
|
514
|
+
- Contain only letters, numbers, and `_` characters
|
|
515
515
|
- Example: `my_index_123` is valid
|
|
516
|
-
- Example: `my-index`
|
|
516
|
+
- Example: `my-index` isn't valid (contains hyphen)
|
|
517
517
|
|
|
518
518
|
**Upstash**:
|
|
519
519
|
|
|
@@ -532,7 +532,7 @@ Namespace names must:
|
|
|
532
532
|
|
|
533
533
|
- Example: `MyNamespace123` is valid
|
|
534
534
|
|
|
535
|
-
- Example: `_namespace`
|
|
535
|
+
- Example: `_namespace` isn't valid (starts with underscore)
|
|
536
536
|
|
|
537
537
|
**Cloudflare**:
|
|
538
538
|
|
|
@@ -543,19 +543,19 @@ Index names must:
|
|
|
543
543
|
- Contain only lowercase ASCII letters, numbers, and dashes
|
|
544
544
|
- Use dashes instead of spaces
|
|
545
545
|
- Example: `my-index-123` is valid
|
|
546
|
-
- Example: `My_Index`
|
|
546
|
+
- Example: `My_Index` isn't valid (uppercase and underscore)
|
|
547
547
|
|
|
548
548
|
**OpenSearch**:
|
|
549
549
|
|
|
550
550
|
Index names must:
|
|
551
551
|
|
|
552
552
|
- Use only lowercase letters
|
|
553
|
-
- Not begin with
|
|
553
|
+
- Not begin with underscore characters or hyphens
|
|
554
554
|
- Not contain spaces, commas
|
|
555
555
|
- Not contain special characters (e.g. `:`, `"`, `*`, `+`, `/`, `\`, `|`, `?`, `#`, `>`, `<`)
|
|
556
556
|
- Example: `my-index-123` is valid
|
|
557
|
-
- Example: `My_Index`
|
|
558
|
-
- Example: `_myindex`
|
|
557
|
+
- Example: `My_Index` isn't valid (contains uppercase letters)
|
|
558
|
+
- Example: `_myindex` isn't valid (begins with underscore)
|
|
559
559
|
|
|
560
560
|
**Elasticsearch**:
|
|
561
561
|
|
|
@@ -563,29 +563,29 @@ Index names must:
|
|
|
563
563
|
|
|
564
564
|
- Use only lowercase letters
|
|
565
565
|
- Not exceed 255 bytes (counting multi-byte characters)
|
|
566
|
-
- Not begin with
|
|
566
|
+
- Not begin with underscore characters, hyphens, or plus signs
|
|
567
567
|
- Not contain spaces, commas
|
|
568
568
|
- Not contain special characters (e.g. `:`, `"`, `*`, `+`, `/`, `\`, `|`, `?`, `#`, `>`, `<`)
|
|
569
569
|
- Not be "." or ".."
|
|
570
570
|
- Not start with "." (deprecated except for system/hidden indices)
|
|
571
571
|
- Example: `my-index-123` is valid
|
|
572
|
-
- Example: `My_Index`
|
|
573
|
-
- Example: `_myindex`
|
|
574
|
-
- Example: `.myindex`
|
|
572
|
+
- Example: `My_Index` isn't valid (contains uppercase letters)
|
|
573
|
+
- Example: `_myindex` isn't valid (begins with underscore)
|
|
574
|
+
- Example: `.myindex` isn't valid (begins with dot, deprecated)
|
|
575
575
|
|
|
576
576
|
**S3 Vectors**:
|
|
577
577
|
|
|
578
578
|
Index names must:
|
|
579
579
|
|
|
580
580
|
- Be unique within the same vector bucket
|
|
581
|
-
- Be 3
|
|
581
|
+
- Be between 3 and 63 characters long
|
|
582
582
|
- Use only lowercase letters (`a–z`), numbers (`0–9`), hyphens (`-`), and dots (`.`)
|
|
583
583
|
- Begin and end with a letter or number
|
|
584
584
|
- Example: `my-index.123` is valid
|
|
585
|
-
- Example: `my_index`
|
|
586
|
-
- Example: `-myindex`
|
|
587
|
-
- Example: `myindex-`
|
|
588
|
-
- Example: `MyIndex`
|
|
585
|
+
- Example: `my_index` isn't valid (contains underscore)
|
|
586
|
+
- Example: `-myindex` isn't valid (begins with hyphen)
|
|
587
|
+
- Example: `myindex-` isn't valid (ends with hyphen)
|
|
588
|
+
- Example: `MyIndex` isn't valid (contains uppercase letters)
|
|
589
589
|
|
|
590
590
|
### Upserting Embeddings
|
|
591
591
|
|
|
@@ -255,7 +255,7 @@ const thread = await memoryStore?.getThreadById({ threadId: '...' })
|
|
|
255
255
|
|
|
256
256
|
## Closing connections
|
|
257
257
|
|
|
258
|
-
`close()` releases
|
|
258
|
+
`close()` releases connections for the stores used by a composite, including the `default` and `editor` stores and any domain with its own client. Each store closes once even if it backs several domains. When the composite is passed to the Mastra class, `shutdown()` calls `close()`:
|
|
259
259
|
|
|
260
260
|
```typescript
|
|
261
261
|
import { MastraCompositeStore } from '@mastra/core/storage'
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
# Storage retention
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
Because storage grows without bound by default, Mastra provides an opt-in, age-based retention system. Declare per-table `maxAge` policies in the `retention` config, then call `storage.prune()` to delete rows older than their configured age. Unconfigured data is kept forever, so behavior doesn't change until you opt in.
|
|
8
8
|
|
|
9
9
|
`prune()` deletes rows. It caps growth and is safe to run against large tables (batched, bounded, resumable, cancellable). It never reclaims disk: on SQLite/libSQL the freed pages are reused by future writes so the file stops growing, but handing disk back to the OS (for example a `VACUUM`) is left to the underlying database and the operator to manage.
|
|
10
10
|
|
|
@@ -37,7 +37,7 @@ const storage = new LibSQLStore({
|
|
|
37
37
|
const results = await storage.prune()
|
|
38
38
|
```
|
|
39
39
|
|
|
40
|
-
`retention` is fully typed.
|
|
40
|
+
`retention` is fully typed. Domain keys must exist, and their table keys must be declared retention-eligible. Store configs type-check objects passed directly. When building an object separately, use `satisfies RetentionConfig` so unknown domains or tables produce compile errors:
|
|
41
41
|
|
|
42
42
|
```typescript
|
|
43
43
|
import type { RetentionConfig } from '@mastra/core/storage'
|
|
@@ -67,7 +67,7 @@ Set the `retention` field on the store config.
|
|
|
67
67
|
|
|
68
68
|
### Retention-eligible tables
|
|
69
69
|
|
|
70
|
-
Each domain
|
|
70
|
+
Each domain specifies its age-prunable tables and the timestamp column that anchors comparison, chosen so `maxAge` matches the meaning of the data. Append-only logs use creation time, live state uses last activity, and jobs or runs use completion time so in-flight work isn't pruned.
|
|
71
71
|
|
|
72
72
|
| Domain | Table key | Anchor column | `maxAge` measures |
|
|
73
73
|
| ----------------- | ------------------ | ---------------- | ---------------------------------------------------------------- |
|
|
@@ -158,7 +158,7 @@ interface PruneResult {
|
|
|
158
158
|
|
|
159
159
|
## Running prune on a schedule
|
|
160
160
|
|
|
161
|
-
`prune()` has no built-in scheduler
|
|
161
|
+
`prune()` has no built-in scheduler, so you decide when it runs. A bounded call may leave eligible rows, indicated by any result with `done: false`. Call it again on the next tick. Short invocations let a large backlog drain over several runs.
|
|
162
162
|
|
|
163
163
|
```typescript
|
|
164
164
|
// Runs on your own cron (node-cron, a workflow schedule, an external job, etc.).
|
package/dist/index.cjs
CHANGED
|
@@ -20751,6 +20751,8 @@ function rowToDefinition(row) {
|
|
|
20751
20751
|
if (stateSchema !== void 0 && stateSchema !== null) def.stateSchema = stateSchema;
|
|
20752
20752
|
const requestContextSchema = parseJsonResilient(row.requestContextSchema);
|
|
20753
20753
|
if (requestContextSchema !== void 0 && requestContextSchema !== null) def.requestContextSchema = requestContextSchema;
|
|
20754
|
+
const schedule = parseJsonResilient(row.schedule);
|
|
20755
|
+
if (schedule !== void 0 && schedule !== null) def.schedule = schedule;
|
|
20754
20756
|
if (row.authorId != null) def.authorId = String(row.authorId);
|
|
20755
20757
|
return def;
|
|
20756
20758
|
}
|
|
@@ -20808,6 +20810,11 @@ var WorkflowDefinitionsPG = class WorkflowDefinitionsPG extends _mastra_core_sto
|
|
|
20808
20810
|
tableName: _mastra_core_storage.TABLE_WORKFLOW_DEFINITIONS,
|
|
20809
20811
|
schema: _mastra_core_storage.TABLE_SCHEMAS[_mastra_core_storage.TABLE_WORKFLOW_DEFINITIONS]
|
|
20810
20812
|
});
|
|
20813
|
+
await this.#db.alterTable({
|
|
20814
|
+
tableName: _mastra_core_storage.TABLE_WORKFLOW_DEFINITIONS,
|
|
20815
|
+
schema: _mastra_core_storage.TABLE_SCHEMAS[_mastra_core_storage.TABLE_WORKFLOW_DEFINITIONS],
|
|
20816
|
+
ifNotExists: ["schedule"]
|
|
20817
|
+
});
|
|
20811
20818
|
await this.createDefaultIndexes();
|
|
20812
20819
|
await this.createCustomIndexes();
|
|
20813
20820
|
}
|
|
@@ -20829,6 +20836,7 @@ var WorkflowDefinitionsPG = class WorkflowDefinitionsPG extends _mastra_core_sto
|
|
|
20829
20836
|
stateSchema: input.stateSchema ?? null,
|
|
20830
20837
|
requestContextSchema: input.requestContextSchema ?? null,
|
|
20831
20838
|
graph: input.graph,
|
|
20839
|
+
schedule: "schedule" in input ? input.schedule ?? null : null,
|
|
20832
20840
|
status: "active",
|
|
20833
20841
|
source: "storage",
|
|
20834
20842
|
authorId: "authorId" in input ? input.authorId ?? null : null,
|
|
@@ -20859,6 +20867,7 @@ var WorkflowDefinitionsPG = class WorkflowDefinitionsPG extends _mastra_core_sto
|
|
|
20859
20867
|
if ("stateSchema" in input && input.stateSchema !== void 0) data.stateSchema = input.stateSchema;
|
|
20860
20868
|
if ("requestContextSchema" in input && input.requestContextSchema !== void 0) data.requestContextSchema = input.requestContextSchema;
|
|
20861
20869
|
if ("graph" in input && input.graph !== void 0) data.graph = input.graph;
|
|
20870
|
+
if ("schedule" in input && input.schedule !== void 0) data.schedule = input.schedule;
|
|
20862
20871
|
if ("status" in input && input.status !== void 0) data.status = input.status;
|
|
20863
20872
|
if ("authorId" in input && input.authorId !== void 0) data.authorId = input.authorId;
|
|
20864
20873
|
await this.#db.update({
|