@mastra/pg 1.7.1-alpha.0 → 1.7.2-alpha.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 +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 +17 -1
- package/dist/docs/references/reference-memory-memory-class.md +12 -14
- package/dist/docs/references/reference-processors-message-history-processor.md +7 -9
- package/dist/docs/references/reference-processors-semantic-recall-processor.md +14 -16
- package/dist/docs/references/reference-processors-working-memory-processor.md +14 -18
- package/dist/docs/references/reference-storage-composite.md +9 -9
- package/dist/docs/references/reference-storage-dynamodb.md +9 -9
- package/dist/docs/references/reference-storage-postgresql.md +25 -25
- package/dist/docs/references/reference-tools-vector-query-tool.md +34 -22
- package/dist/docs/references/reference-vectors-pg.md +60 -44
- package/dist/index.cjs +4 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -1
- package/dist/storage/domains/experiments/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.7.2-alpha.0
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- - Fixed experiment pending count showing negative values when experiments are triggered from the Studio ([#13831](https://github.com/mastra-ai/mastra/pull/13831))
|
|
8
|
+
- Fixed scorer prompt metadata (analysis context, generated prompts) being lost when saving experiment scores
|
|
9
|
+
- Updated dependencies [[`41e48c1`](https://github.com/mastra-ai/mastra/commit/41e48c198eee846478e60c02ec432c19d322a517), [`82469d3`](https://github.com/mastra-ai/mastra/commit/82469d3135d5a49dd8dc8feec0ff398b4e0225a0), [`33e2fd5`](https://github.com/mastra-ai/mastra/commit/33e2fd5088f83666df17401e2da68c943dbc0448), [`7ef6e2c`](https://github.com/mastra-ai/mastra/commit/7ef6e2c61be5a42e26f55d15b5902866fc76634f), [`b12d2a5`](https://github.com/mastra-ai/mastra/commit/b12d2a59a48be0477cabae66eb6cf0fc94a7d40d), [`fa37d39`](https://github.com/mastra-ai/mastra/commit/fa37d39910421feaf8847716292e3d65dd4f30c2), [`b12d2a5`](https://github.com/mastra-ai/mastra/commit/b12d2a59a48be0477cabae66eb6cf0fc94a7d40d), [`71c38bf`](https://github.com/mastra-ai/mastra/commit/71c38bf905905148ecd0e75c07c1f9825d299b76), [`f993c38`](https://github.com/mastra-ai/mastra/commit/f993c3848c97479b813231be872443bedeced6ab), [`f51849a`](https://github.com/mastra-ai/mastra/commit/f51849a568935122b5100b7ee69704e6d680cf7b), [`9bf3a0d`](https://github.com/mastra-ai/mastra/commit/9bf3a0dac602787925f1762f1f0387d7b4a59620), [`cafa045`](https://github.com/mastra-ai/mastra/commit/cafa0453c9de141ad50c09a13894622dffdd9978), [`1fd9ddb`](https://github.com/mastra-ai/mastra/commit/1fd9ddbb3fe83b281b12bd2e27e426ae86288266), [`6135ef4`](https://github.com/mastra-ai/mastra/commit/6135ef4f5288652bf45f616ec590607e4c95f443), [`d9d228c`](https://github.com/mastra-ai/mastra/commit/d9d228c0c6ae82ae6ce3b540a3a56b2b1c2b8d98), [`5576507`](https://github.com/mastra-ai/mastra/commit/55765071e360fb97e443aa0a91ccf7e1cd8d92aa), [`79d69c9`](https://github.com/mastra-ai/mastra/commit/79d69c9d5f842ff1c31352fb6026f04c1f6190f3), [`94f44b8`](https://github.com/mastra-ai/mastra/commit/94f44b827ce57b179e50f4916a84c0fa6e7f3b8c), [`13187db`](https://github.com/mastra-ai/mastra/commit/13187dbac880174232dedc5a501ff6c5d0fe59bc), [`2ae5311`](https://github.com/mastra-ai/mastra/commit/2ae531185fff66a80fa165c0999e3d801900e89d), [`6135ef4`](https://github.com/mastra-ai/mastra/commit/6135ef4f5288652bf45f616ec590607e4c95f443)]:
|
|
10
|
+
- @mastra/core@1.10.0-alpha.0
|
|
11
|
+
|
|
12
|
+
## 1.7.1
|
|
13
|
+
|
|
14
|
+
### Patch Changes
|
|
15
|
+
|
|
16
|
+
- Added atomic `updateWorkflowResults` and `updateWorkflowState` to safely merge concurrent step results into workflow snapshots. ([#12575](https://github.com/mastra-ai/mastra/pull/12575))
|
|
17
|
+
|
|
18
|
+
- Added `insertObservationalMemoryRecord()` to PostgreSQL, LibSQL, MongoDB, and Upstash adapters for OM cloning support. ([#13569](https://github.com/mastra-ai/mastra/pull/13569))
|
|
19
|
+
|
|
20
|
+
- Eliminate pg client deprecation warnings on startup by running index metadata queries sequentially ([#13659](https://github.com/mastra-ai/mastra/pull/13659))
|
|
21
|
+
|
|
22
|
+
- Updated dependencies [[`504fc8b`](https://github.com/mastra-ai/mastra/commit/504fc8b9d0ddab717577ad3bf9c95ea4bd5377bd), [`f9c150b`](https://github.com/mastra-ai/mastra/commit/f9c150b7595ad05ad9cc9a11098e2944361e8c22), [`88de7e8`](https://github.com/mastra-ai/mastra/commit/88de7e8dfe4b7e1951a9e441bb33136e705ce24e), [`edee4b3`](https://github.com/mastra-ai/mastra/commit/edee4b37dff0af515fc7cc0e8d71ee39e6a762f0), [`3790c75`](https://github.com/mastra-ai/mastra/commit/3790c7578cc6a47d854eb12d89e6b1912867fe29), [`e7a235b`](https://github.com/mastra-ai/mastra/commit/e7a235be6472e0c870ed6c791ddb17c492dc188b), [`d51d298`](https://github.com/mastra-ai/mastra/commit/d51d298953967aab1f58ec965b644d109214f085), [`6dbeeb9`](https://github.com/mastra-ai/mastra/commit/6dbeeb94a8b1eebb727300d1a98961f882180794), [`d5f0d8d`](https://github.com/mastra-ai/mastra/commit/d5f0d8d6a03e515ddaa9b5da19b7e44b8357b07b), [`09c3b18`](https://github.com/mastra-ai/mastra/commit/09c3b1802ff14e243a8a8baea327440bc8cc2e32), [`b896379`](https://github.com/mastra-ai/mastra/commit/b8963791c6afa79484645fcec596a201f936b9a2), [`85c84eb`](https://github.com/mastra-ai/mastra/commit/85c84ebb78aebfcba9d209c8e152b16d7a00cb71), [`a89272a`](https://github.com/mastra-ai/mastra/commit/a89272a5d71939b9fcd284e6a6dc1dd091a6bdcf), [`ee9c8df`](https://github.com/mastra-ai/mastra/commit/ee9c8df644f19d055af5f496bf4942705f5a47b7), [`77b4a25`](https://github.com/mastra-ai/mastra/commit/77b4a254e51907f8ff3a3ba95596a18e93ae4b35), [`276246e`](https://github.com/mastra-ai/mastra/commit/276246e0b9066a1ea48bbc70df84dbe528daaf99), [`08ecfdb`](https://github.com/mastra-ai/mastra/commit/08ecfdbdad6fb8285deef86a034bdf4a6047cfca), [`d5f628c`](https://github.com/mastra-ai/mastra/commit/d5f628ca86c6f6f3ff1035d52f635df32dd81cab), [`524c0f3`](https://github.com/mastra-ai/mastra/commit/524c0f3c434c3d9d18f66338dcef383d6161b59c), [`c18a0e9`](https://github.com/mastra-ai/mastra/commit/c18a0e9cef1e4ca004b2963d35e4cfc031971eac), [`4bd21ea`](https://github.com/mastra-ai/mastra/commit/4bd21ea43d44d0a0427414fc047577f9f0aa3bec), [`115a7a4`](https://github.com/mastra-ai/mastra/commit/115a7a47db5e9896fec12ae6507501adb9ec89bf), [`22a48ae`](https://github.com/mastra-ai/mastra/commit/22a48ae2513eb54d8d79dad361fddbca97a155e8), [`3c6ef79`](https://github.com/mastra-ai/mastra/commit/3c6ef798481e00d6d22563be2de98818fd4dd5e0), [`9311c17`](https://github.com/mastra-ai/mastra/commit/9311c17d7a0640d9c4da2e71b814dc67c57c6369), [`7edf78f`](https://github.com/mastra-ai/mastra/commit/7edf78f80422c43e84585f08ba11df0d4d0b73c5), [`1c4221c`](https://github.com/mastra-ai/mastra/commit/1c4221cf6032ec98d0e094d4ee11da3e48490d96), [`d25b9ea`](https://github.com/mastra-ai/mastra/commit/d25b9eabd400167255a97b690ffbc4ee4097ded5), [`fe1ce5c`](https://github.com/mastra-ai/mastra/commit/fe1ce5c9211c03d561606fda95cbfe7df1d9a9b5), [`b03c0e0`](https://github.com/mastra-ai/mastra/commit/b03c0e0389a799523929a458b0509c9e4244d562), [`0a8366b`](https://github.com/mastra-ai/mastra/commit/0a8366b0a692fcdde56c4d526e4cf03c502ae4ac), [`85664e9`](https://github.com/mastra-ai/mastra/commit/85664e9fd857320fbc245e301f764f45f66f32a3), [`bc79650`](https://github.com/mastra-ai/mastra/commit/bc796500c6e0334faa158a96077e3fb332274869), [`9257d01`](https://github.com/mastra-ai/mastra/commit/9257d01d1366d81f84c582fe02b5e200cf9621f4), [`3a3a59e`](https://github.com/mastra-ai/mastra/commit/3a3a59e8ffaa6a985fe3d9a126a3f5ade11a6724), [`3108d4e`](https://github.com/mastra-ai/mastra/commit/3108d4e649c9fddbf03253a6feeb388a5fa9fa5a), [`0c33b2c`](https://github.com/mastra-ai/mastra/commit/0c33b2c9db537f815e1c59e2c898ffce2e395a79), [`191e5bd`](https://github.com/mastra-ai/mastra/commit/191e5bd29b82f5bda35243945790da7bc7b695c2), [`f77cd94`](https://github.com/mastra-ai/mastra/commit/f77cd94c44eabed490384e7d19232a865e13214c), [`e8135c7`](https://github.com/mastra-ai/mastra/commit/e8135c7e300dac5040670eec7eab896ac6092e30), [`daca48f`](https://github.com/mastra-ai/mastra/commit/daca48f0fb17b7ae0b62a2ac40cf0e491b2fd0b7), [`257d14f`](https://github.com/mastra-ai/mastra/commit/257d14faca5931f2e4186fc165b6f0b1f915deee), [`352f25d`](https://github.com/mastra-ai/mastra/commit/352f25da316b24cdd5b410fd8dddf6a8b763da2a), [`93477d0`](https://github.com/mastra-ai/mastra/commit/93477d0769b8a13ea5ed73d508d967fb23eaeed9), [`31c78b3`](https://github.com/mastra-ai/mastra/commit/31c78b3eb28f58a8017f1dcc795c33214d87feac), [`0bc0720`](https://github.com/mastra-ai/mastra/commit/0bc07201095791858087cc56f353fcd65e87ab54), [`36516ac`](https://github.com/mastra-ai/mastra/commit/36516aca1021cbeb42e74751b46a2614101f37c8), [`e947652`](https://github.com/mastra-ai/mastra/commit/e9476527fdecb4449e54570e80dfaf8466901254), [`3c6ef79`](https://github.com/mastra-ai/mastra/commit/3c6ef798481e00d6d22563be2de98818fd4dd5e0), [`9257d01`](https://github.com/mastra-ai/mastra/commit/9257d01d1366d81f84c582fe02b5e200cf9621f4), [`ec248f6`](https://github.com/mastra-ai/mastra/commit/ec248f6b56e8a037c066c49b2178e2507471d988)]:
|
|
23
|
+
- @mastra/core@1.9.0
|
|
24
|
+
|
|
3
25
|
## 1.7.1-alpha.0
|
|
4
26
|
|
|
5
27
|
### Patch Changes
|
package/dist/docs/SKILL.md
CHANGED
|
@@ -147,8 +147,24 @@ Supported embedding models:
|
|
|
147
147
|
|
|
148
148
|
- **OpenAI**: `text-embedding-3-small`, `text-embedding-3-large`, `text-embedding-ada-002`
|
|
149
149
|
- **Google**: `gemini-embedding-001`
|
|
150
|
+
- **OpenRouter**: Access embedding models from various providers
|
|
150
151
|
|
|
151
|
-
|
|
152
|
+
```ts
|
|
153
|
+
import { Agent } from '@mastra/core/agent'
|
|
154
|
+
import { Memory } from '@mastra/memory'
|
|
155
|
+
import { ModelRouterEmbeddingModel } from '@mastra/core/llm'
|
|
156
|
+
|
|
157
|
+
const agent = new Agent({
|
|
158
|
+
memory: new Memory({
|
|
159
|
+
embedder: new ModelRouterEmbeddingModel({
|
|
160
|
+
providerId: 'openrouter',
|
|
161
|
+
modelId: 'openai/text-embedding-3-small',
|
|
162
|
+
}),
|
|
163
|
+
}),
|
|
164
|
+
})
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
The model router automatically handles API key detection from environment variables (`OPENAI_API_KEY`, `GOOGLE_GENERATIVE_AI_API_KEY`, `OPENROUTER_API_KEY`).
|
|
152
168
|
|
|
153
169
|
### Using AI SDK Packages
|
|
154
170
|
|
|
@@ -22,35 +22,33 @@ export const agent = new Agent({
|
|
|
22
22
|
})
|
|
23
23
|
```
|
|
24
24
|
|
|
25
|
-
> To enable `workingMemory` on an agent, you’ll need a storage provider configured on your main Mastra instance. See [Mastra class](https://mastra.ai/reference/core/mastra-class) for more information.
|
|
25
|
+
> **Note:** To enable `workingMemory` on an agent, you’ll need a storage provider configured on your main Mastra instance. See [Mastra class](https://mastra.ai/reference/core/mastra-class) for more information.
|
|
26
26
|
|
|
27
27
|
## Constructor parameters
|
|
28
28
|
|
|
29
|
-
**storage
|
|
29
|
+
**storage** (`MastraCompositeStore`): Storage implementation for persisting memory data. Defaults to \`new DefaultStorage({ config: { url: "file:memory.db" } })\` if not provided.
|
|
30
30
|
|
|
31
|
-
**vector
|
|
31
|
+
**vector** (`MastraVector | false`): Vector store for semantic search capabilities. Set to \`false\` to disable vector operations.
|
|
32
32
|
|
|
33
|
-
**embedder
|
|
33
|
+
**embedder** (`EmbeddingModel<string> | EmbeddingModelV2<string>`): Embedder instance for vector embeddings. Required when semantic recall is enabled.
|
|
34
34
|
|
|
35
|
-
**options
|
|
35
|
+
**options** (`MemoryConfig`): Memory configuration options.
|
|
36
36
|
|
|
37
|
-
|
|
37
|
+
**options.lastMessages** (`number | false`): Number of most recent messages to include in context. Set to \`false\` to disable loading conversation history into context. Use \`Number.MAX\_SAFE\_INTEGER\` to retrieve all messages with no limit. To prevent saving new messages, use the \`readOnly\` option instead.
|
|
38
38
|
|
|
39
|
-
**
|
|
39
|
+
**options.readOnly** (`boolean`): When true, prevents memory from saving new messages and provides working memory as read-only context (without the updateWorkingMemory tool). Useful for read-only operations like previews, internal routing agents, or sub agents that should reference but not modify memory.
|
|
40
40
|
|
|
41
|
-
**
|
|
41
|
+
**options.semanticRecall** (`boolean | { topK: number; messageRange: number | { before: number; after: number }; scope?: 'thread' | 'resource' }`): Enable semantic search in message history. Can be a boolean or an object with configuration options. When enabled, requires both vector store and embedder to be configured. Default topK is 4, default messageRange is {before: 1, after: 1}.
|
|
42
42
|
|
|
43
|
-
**
|
|
43
|
+
**options.workingMemory** (`WorkingMemory`): Configuration for working memory feature. Can be \`{ enabled: boolean; template?: string; schema?: ZodObject\<any> | JSONSchema7; scope?: 'thread' | 'resource' }\` or \`{ enabled: boolean }\` to disable.
|
|
44
44
|
|
|
45
|
-
**
|
|
45
|
+
**options.observationalMemory** (`boolean | ObservationalMemoryOptions`): Enable Observational Memory for long-context agentic memory. Set to \`true\` for defaults, or pass a config object to customize token budgets, models, and scope. See \[Observational Memory reference]\(/reference/memory/observational-memory) for configuration details.
|
|
46
46
|
|
|
47
|
-
**
|
|
48
|
-
|
|
49
|
-
**generateTitle?:** (`boolean | { model: DynamicArgument<MastraLanguageModel>; instructions?: DynamicArgument<string> }`): Controls automatic thread title generation from the user's first message. Can be a boolean or an object with custom model and instructions. (Default: `false`)
|
|
47
|
+
**options.generateTitle** (`boolean | { model: DynamicArgument<MastraLanguageModel>; instructions?: DynamicArgument<string> }`): Controls automatic thread title generation from the user's first message. Can be a boolean or an object with custom model and instructions.
|
|
50
48
|
|
|
51
49
|
## Returns
|
|
52
50
|
|
|
53
|
-
**memory
|
|
51
|
+
**memory** (`Memory`): A new Memory instance with the specified configuration.
|
|
54
52
|
|
|
55
53
|
## Extended usage example
|
|
56
54
|
|
|
@@ -15,23 +15,21 @@ const processor = new MessageHistory({
|
|
|
15
15
|
|
|
16
16
|
## Constructor parameters
|
|
17
17
|
|
|
18
|
-
**options
|
|
18
|
+
**options** (`MessageHistoryOptions`): Configuration options for the message history processor
|
|
19
19
|
|
|
20
|
-
|
|
20
|
+
**options.storage** (`MemoryStorage`): Storage instance for retrieving and persisting messages
|
|
21
21
|
|
|
22
|
-
**
|
|
23
|
-
|
|
24
|
-
**lastMessages?:** (`number`): Maximum number of historical messages to retrieve. If not specified, retrieves all messages
|
|
22
|
+
**options.lastMessages** (`number`): Maximum number of historical messages to retrieve. If not specified, retrieves all messages
|
|
25
23
|
|
|
26
24
|
## Returns
|
|
27
25
|
|
|
28
|
-
**id
|
|
26
|
+
**id** (`string`): Processor identifier set to 'message-history'
|
|
29
27
|
|
|
30
|
-
**name
|
|
28
|
+
**name** (`string`): Processor display name set to 'MessageHistory'
|
|
31
29
|
|
|
32
|
-
**processInput
|
|
30
|
+
**processInput** (`(args: { messages: MastraDBMessage[]; messageList: MessageList; abort: (reason?: string) => never; tracingContext?: TracingContext; requestContext?: RequestContext }) => Promise<MessageList | MastraDBMessage[]>`): Fetches historical messages from storage and adds them to the message list
|
|
33
31
|
|
|
34
|
-
**processOutputResult
|
|
32
|
+
**processOutputResult** (`(args: { messages: MastraDBMessage[]; messageList: MessageList; abort: (reason?: string) => never; tracingContext?: TracingContext; requestContext?: RequestContext }) => Promise<MessageList>`): Persists new messages (user input and assistant response) to storage, excluding system messages
|
|
35
33
|
|
|
36
34
|
## Extended usage example
|
|
37
35
|
|
|
@@ -20,37 +20,35 @@ const processor = new SemanticRecall({
|
|
|
20
20
|
|
|
21
21
|
## Constructor parameters
|
|
22
22
|
|
|
23
|
-
**options
|
|
23
|
+
**options** (`SemanticRecallOptions`): Configuration options for the semantic recall processor
|
|
24
24
|
|
|
25
|
-
|
|
25
|
+
**options.storage** (`MemoryStorage`): Storage instance for retrieving messages
|
|
26
26
|
|
|
27
|
-
**
|
|
27
|
+
**options.vector** (`MastraVector`): Vector store for semantic search
|
|
28
28
|
|
|
29
|
-
**
|
|
29
|
+
**options.embedder** (`MastraEmbeddingModel<string>`): Embedder for generating query embeddings
|
|
30
30
|
|
|
31
|
-
**
|
|
31
|
+
**options.topK** (`number`): Number of most similar messages to retrieve
|
|
32
32
|
|
|
33
|
-
**
|
|
33
|
+
**options.messageRange** (`number | { before: number; after: number }`): Number of context messages to include before/after each match. Can be a single number (same for both) or an object with separate values
|
|
34
34
|
|
|
35
|
-
**
|
|
35
|
+
**options.scope** (`'thread' | 'resource'`): Scope of semantic search. 'thread' searches within the current thread only. 'resource' searches across all threads for the resource
|
|
36
36
|
|
|
37
|
-
**
|
|
37
|
+
**options.threshold** (`number`): Minimum similarity score threshold (0-1). Messages below this threshold are filtered out
|
|
38
38
|
|
|
39
|
-
**
|
|
39
|
+
**options.indexName** (`string`): Index name for the vector store. If not provided, auto-generated based on embedder model
|
|
40
40
|
|
|
41
|
-
**
|
|
42
|
-
|
|
43
|
-
**logger?:** (`IMastraLogger`): Optional logger instance for structured logging
|
|
41
|
+
**options.logger** (`IMastraLogger`): Optional logger instance for structured logging
|
|
44
42
|
|
|
45
43
|
## Returns
|
|
46
44
|
|
|
47
|
-
**id
|
|
45
|
+
**id** (`string`): Processor identifier set to 'semantic-recall'
|
|
48
46
|
|
|
49
|
-
**name
|
|
47
|
+
**name** (`string`): Processor display name set to 'SemanticRecall'
|
|
50
48
|
|
|
51
|
-
**processInput
|
|
49
|
+
**processInput** (`(args: { messages: MastraDBMessage[]; messageList: MessageList; abort: (reason?: string) => never; tracingContext?: TracingContext; requestContext?: RequestContext }) => Promise<MessageList | MastraDBMessage[]>`): Performs semantic search on historical messages and adds relevant context to the message list
|
|
52
50
|
|
|
53
|
-
**processOutputResult
|
|
51
|
+
**processOutputResult** (`(args: { messages: MastraDBMessage[]; messageList?: MessageList; abort: (reason?: string) => never; tracingContext?: TracingContext; requestContext?: RequestContext }) => Promise<MessageList | MastraDBMessage[]>`): Creates embeddings for new messages to enable future semantic search
|
|
54
52
|
|
|
55
53
|
## Extended usage example
|
|
56
54
|
|
|
@@ -23,39 +23,35 @@ const processor = new WorkingMemory({
|
|
|
23
23
|
|
|
24
24
|
## Constructor parameters
|
|
25
25
|
|
|
26
|
-
**options
|
|
26
|
+
**options** (`Options`): Configuration options for the working memory processor
|
|
27
27
|
|
|
28
|
-
|
|
28
|
+
**options.storage** (`MemoryStorage`): Storage instance for retrieving working memory data
|
|
29
29
|
|
|
30
|
-
**
|
|
30
|
+
**options.template** (`WorkingMemoryTemplate`): Template defining the format and structure of working memory
|
|
31
31
|
|
|
32
|
-
**template
|
|
32
|
+
**options.template.format** (`'markdown' | 'json'`): Format of the working memory content
|
|
33
33
|
|
|
34
|
-
**
|
|
34
|
+
**options.template.content** (`string`): Template content defining the structure of working memory data
|
|
35
35
|
|
|
36
|
-
**
|
|
36
|
+
**options.scope** (`'thread' | 'resource'`): Scope of working memory. 'thread' scopes to current thread, 'resource' shares across all threads for the resource
|
|
37
37
|
|
|
38
|
-
**
|
|
38
|
+
**options.useVNext** (`boolean`): Use the next-generation instruction format with improved guidelines
|
|
39
39
|
|
|
40
|
-
**
|
|
40
|
+
**options.readOnly** (`boolean`): When true, working memory is provided as read-only context. The data is injected into the conversation but without the updateWorkingMemory tool or update instructions. Useful for agents that should reference working memory without modifying it.
|
|
41
41
|
|
|
42
|
-
**
|
|
42
|
+
**options.templateProvider** (`{ getWorkingMemoryTemplate(args: { memoryConfig?: MemoryConfig }): Promise<WorkingMemoryTemplate | null> }`): Dynamic template provider for runtime template resolution
|
|
43
43
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
**format:** (`'markdown' | 'json'`): Format of the working memory content
|
|
47
|
-
|
|
48
|
-
**content:** (`string`): Template content defining the structure of working memory data
|
|
44
|
+
**options.logger** (`IMastraLogger`): Optional logger instance for structured logging
|
|
49
45
|
|
|
50
46
|
## Returns
|
|
51
47
|
|
|
52
|
-
**id
|
|
48
|
+
**id** (`string`): Processor identifier set to 'working-memory'
|
|
53
49
|
|
|
54
|
-
**name
|
|
50
|
+
**name** (`string`): Processor display name set to 'WorkingMemory'
|
|
55
51
|
|
|
56
|
-
**defaultWorkingMemoryTemplate
|
|
52
|
+
**defaultWorkingMemoryTemplate** (`string`): The default markdown template used when no custom template is provided
|
|
57
53
|
|
|
58
|
-
**processInput
|
|
54
|
+
**processInput** (`(args: { messages: MastraDBMessage[]; messageList: MessageList; abort: (reason?: string) => never; requestContext?: RequestContext }) => Promise<MessageList | MastraDBMessage[]>`): Retrieves working memory and adds it as a system message to the message list
|
|
59
55
|
|
|
60
56
|
## Extended usage example
|
|
61
57
|
|
|
@@ -120,23 +120,23 @@ export const mastra = new Mastra({
|
|
|
120
120
|
|
|
121
121
|
## Options
|
|
122
122
|
|
|
123
|
-
**id
|
|
123
|
+
**id** (`string`): Unique identifier for this storage instance.
|
|
124
124
|
|
|
125
|
-
**default
|
|
125
|
+
**default** (`MastraCompositeStore`): Default storage adapter. Domains not explicitly specified in \`domains\` will use this storage's domains as fallbacks.
|
|
126
126
|
|
|
127
|
-
**domains
|
|
127
|
+
**domains** (`object`): Individual domain overrides. Each domain can come from a different storage adapter. These take precedence over the default storage.
|
|
128
128
|
|
|
129
|
-
**domains.memory
|
|
129
|
+
**domains.memory** (`MemoryStorage`): Storage for threads, messages, and resources.
|
|
130
130
|
|
|
131
|
-
**domains.workflows
|
|
131
|
+
**domains.workflows** (`WorkflowsStorage`): Storage for workflow snapshots.
|
|
132
132
|
|
|
133
|
-
**domains.scores
|
|
133
|
+
**domains.scores** (`ScoresStorage`): Storage for evaluation scores.
|
|
134
134
|
|
|
135
|
-
**domains.observability
|
|
135
|
+
**domains.observability** (`ObservabilityStorage`): Storage for traces and spans.
|
|
136
136
|
|
|
137
|
-
**domains.agents
|
|
137
|
+
**domains.agents** (`AgentsStorage`): Storage for stored agent configurations.
|
|
138
138
|
|
|
139
|
-
**disableInit
|
|
139
|
+
**disableInit** (`boolean`): When true, automatic initialization is disabled. You must call init() explicitly.
|
|
140
140
|
|
|
141
141
|
## Initialization
|
|
142
142
|
|
|
@@ -108,17 +108,17 @@ For local development, you can use [DynamoDB Local](https://docs.aws.amazon.com/
|
|
|
108
108
|
|
|
109
109
|
## Parameters
|
|
110
110
|
|
|
111
|
-
**id
|
|
111
|
+
**id** (`string`): Unique identifier for this storage instance.
|
|
112
112
|
|
|
113
|
-
**config.tableName
|
|
113
|
+
**config.tableName** (`string`): The name of your DynamoDB table.
|
|
114
114
|
|
|
115
|
-
**config.region
|
|
115
|
+
**config.region** (`string`): AWS region. Defaults to 'us-east-1'. For local development, can be set to 'localhost' or similar.
|
|
116
116
|
|
|
117
|
-
**config.endpoint
|
|
117
|
+
**config.endpoint** (`string`): Custom endpoint for DynamoDB (e.g., 'http\://localhost:8000' for local development).
|
|
118
118
|
|
|
119
|
-
**config.credentials
|
|
119
|
+
**config.credentials** (`object`): AWS credentials object with \`accessKeyId\` and \`secretAccessKey\`. If not provided, the AWS SDK will attempt to source credentials from environment variables, IAM roles (e.g., for EC2/Lambda), or the shared AWS credentials file.
|
|
120
120
|
|
|
121
|
-
**config.ttl
|
|
121
|
+
**config.ttl** (`object`): TTL (Time To Live) configuration for automatic data expiration. Configure per entity type: thread, message, trace, eval, workflow\_snapshot, resource, score. Each entity config includes: enabled (boolean), attributeName (string, default: 'ttl'), defaultTtlSeconds (number).
|
|
122
122
|
|
|
123
123
|
## TTL (Time To Live) Configuration
|
|
124
124
|
|
|
@@ -188,11 +188,11 @@ TTL can be configured for these entity types:
|
|
|
188
188
|
|
|
189
189
|
Each entity type accepts the following configuration:
|
|
190
190
|
|
|
191
|
-
**enabled
|
|
191
|
+
**enabled** (`boolean`): Whether TTL is enabled for this entity type.
|
|
192
192
|
|
|
193
|
-
**attributeName
|
|
193
|
+
**attributeName** (`string`): The DynamoDB attribute name to use for TTL. Must match the TTL attribute configured on your DynamoDB table. Defaults to 'ttl'.
|
|
194
194
|
|
|
195
|
-
**defaultTtlSeconds
|
|
195
|
+
**defaultTtlSeconds** (`number`): Default TTL in seconds from item creation time. Items will be automatically deleted by DynamoDB after this duration.
|
|
196
196
|
|
|
197
197
|
### Enabling TTL on Your DynamoDB Table
|
|
198
198
|
|
|
@@ -41,35 +41,35 @@ const storage = new PostgresStore({
|
|
|
41
41
|
|
|
42
42
|
## Parameters
|
|
43
43
|
|
|
44
|
-
**id
|
|
44
|
+
**id** (`string`): Unique identifier for this storage instance.
|
|
45
45
|
|
|
46
|
-
**connectionString
|
|
46
|
+
**connectionString** (`string`): PostgreSQL connection string (e.g., postgresql://user:pass\@host:5432/dbname). Required unless using \`pool\` or individual host-based parameters (\`host\`, \`port\`, \`database\`, \`user\`, \`password\`).
|
|
47
47
|
|
|
48
|
-
**host
|
|
48
|
+
**host** (`string`): Database server hostname or IP address. Used with other host-based parameters as an alternative to connectionString.
|
|
49
49
|
|
|
50
|
-
**port
|
|
50
|
+
**port** (`number`): Database server port number. Defaults to 5432 if not specified.
|
|
51
51
|
|
|
52
|
-
**database
|
|
52
|
+
**database** (`string`): Name of the database to connect to.
|
|
53
53
|
|
|
54
|
-
**user
|
|
54
|
+
**user** (`string`): Database user for authentication.
|
|
55
55
|
|
|
56
|
-
**password
|
|
56
|
+
**password** (`string`): Password for the database user.
|
|
57
57
|
|
|
58
|
-
**pool
|
|
58
|
+
**pool** (`pg.Pool`): Pre-configured pg.Pool instance. Use this to reuse an existing connection pool. When provided, Mastra will not create its own pool and will not close it when \`store.close()\` is called.
|
|
59
59
|
|
|
60
|
-
**schemaName
|
|
60
|
+
**schemaName** (`string`): The name of the schema you want the storage to use. Defaults to 'public'.
|
|
61
61
|
|
|
62
|
-
**ssl
|
|
62
|
+
**ssl** (`boolean | ConnectionOptions`): SSL configuration for the connection; set to true to use default SSL or provide a ConnectionOptions object for custom SSL settings.
|
|
63
63
|
|
|
64
|
-
**max
|
|
64
|
+
**max** (`number`): Maximum number of connections in the pool. Defaults to 20.
|
|
65
65
|
|
|
66
|
-
**idleTimeoutMillis
|
|
66
|
+
**idleTimeoutMillis** (`number`): How long a connection can sit idle before being closed. Defaults to 30000 (30 seconds).
|
|
67
67
|
|
|
68
|
-
**disableInit
|
|
68
|
+
**disableInit** (`boolean`): When true, automatic table creation/migrations are disabled. Useful for CI/CD pipelines where migrations are run separately.
|
|
69
69
|
|
|
70
|
-
**skipDefaultIndexes
|
|
70
|
+
**skipDefaultIndexes** (`boolean`): When true, default indexes will not be created during initialization.
|
|
71
71
|
|
|
72
|
-
**indexes
|
|
72
|
+
**indexes** (`CreateIndexOptions[]`): Custom indexes to create during initialization.
|
|
73
73
|
|
|
74
74
|
## Constructor Examples
|
|
75
75
|
|
|
@@ -448,25 +448,25 @@ For advanced index types, you can specify additional options:
|
|
|
448
448
|
|
|
449
449
|
### Index Options
|
|
450
450
|
|
|
451
|
-
**name
|
|
451
|
+
**name** (`string`): Unique name for the index
|
|
452
452
|
|
|
453
|
-
**table
|
|
453
|
+
**table** (`string`): Table name (e.g., 'mastra\_threads')
|
|
454
454
|
|
|
455
|
-
**columns
|
|
455
|
+
**columns** (`string[]`): Array of column names with optional sort order (e.g., \['id', 'createdAt DESC'])
|
|
456
456
|
|
|
457
|
-
**unique
|
|
457
|
+
**unique** (`boolean`): Creates a unique constraint index
|
|
458
458
|
|
|
459
|
-
**concurrent
|
|
459
|
+
**concurrent** (`boolean`): Creates index without locking table (default: true)
|
|
460
460
|
|
|
461
|
-
**where
|
|
461
|
+
**where** (`string`): Partial index condition (PostgreSQL specific)
|
|
462
462
|
|
|
463
|
-
**method
|
|
463
|
+
**method** (`'btree' | 'hash' | 'gin' | 'gist' | 'spgist' | 'brin'`): Index method (default: 'btree')
|
|
464
464
|
|
|
465
|
-
**opclass
|
|
465
|
+
**opclass** (`string`): Operator class for GIN/GIST indexes
|
|
466
466
|
|
|
467
|
-
**storage
|
|
467
|
+
**storage** (`Record<string, any>`): Storage parameters (e.g., { fillfactor: 90 })
|
|
468
468
|
|
|
469
|
-
**tablespace
|
|
469
|
+
**tablespace** (`string`): Tablespace name for index placement
|
|
470
470
|
|
|
471
471
|
### Schema-Specific Indexes
|
|
472
472
|
|
|
@@ -19,53 +19,65 @@ const queryTool = createVectorQueryTool({
|
|
|
19
19
|
|
|
20
20
|
> **Note:** **Parameter Requirements:** Most fields can be set at creation as defaults. Some fields can be overridden at runtime via the request context or input. If a required field is missing from both creation and runtime, an error will be thrown. Note that `model`, `id`, and `description` can only be set at creation time.
|
|
21
21
|
|
|
22
|
-
**id
|
|
22
|
+
**id** (`string`): Custom ID for the tool. By default: 'VectorQuery {vectorStoreName} {indexName} Tool'. (Set at creation only.)
|
|
23
23
|
|
|
24
|
-
**description
|
|
24
|
+
**description** (`string`): Custom description for the tool. By default: 'Access the knowledge base to find information needed to answer user questions' (Set at creation only.)
|
|
25
25
|
|
|
26
|
-
**model
|
|
26
|
+
**model** (`EmbeddingModel`): Embedding model to use for vector search. (Set at creation only.)
|
|
27
27
|
|
|
28
|
-
**vectorStoreName
|
|
28
|
+
**vectorStoreName** (`string`): Name of the vector store to query. (Can be set at creation or overridden at runtime.)
|
|
29
29
|
|
|
30
|
-
**indexName
|
|
30
|
+
**indexName** (`string`): Name of the index within the vector store. (Can be set at creation or overridden at runtime.)
|
|
31
31
|
|
|
32
|
-
**enableFilter
|
|
32
|
+
**enableFilter** (`boolean`): Enable filtering of results based on metadata. (Set at creation only, but will be automatically enabled if a filter is provided in the request context.) (Default: `false`)
|
|
33
33
|
|
|
34
|
-
**includeVectors
|
|
34
|
+
**includeVectors** (`boolean`): Include the embedding vectors in the results. (Can be set at creation or overridden at runtime.) (Default: `false`)
|
|
35
35
|
|
|
36
|
-
**includeSources
|
|
36
|
+
**includeSources** (`boolean`): Include the full retrieval objects in the results. (Can be set at creation or overridden at runtime.) (Default: `true`)
|
|
37
37
|
|
|
38
|
-
**reranker
|
|
38
|
+
**reranker** (`RerankConfig`): Options for reranking results. (Can be set at creation or overridden at runtime.)
|
|
39
39
|
|
|
40
|
-
**
|
|
40
|
+
**reranker.model** (`MastraLanguageModel`): Language model to use for reranking
|
|
41
41
|
|
|
42
|
-
**
|
|
42
|
+
**reranker.options** (`RerankerOptions`): Options for the reranking process
|
|
43
43
|
|
|
44
|
-
**
|
|
44
|
+
**reranker.options.weights** (`WeightConfig`): Weights for scoring components (semantic: 0.4, vector: 0.4, position: 0.2)
|
|
45
45
|
|
|
46
|
-
|
|
46
|
+
**reranker.options.topK** (`number`): Number of top results to return
|
|
47
47
|
|
|
48
|
-
|
|
48
|
+
**databaseConfig** (`DatabaseConfig`): Database-specific configuration options for optimizing queries. (Can be set at creation or overridden at runtime.)
|
|
49
49
|
|
|
50
|
-
**pinecone
|
|
50
|
+
**databaseConfig.pinecone** (`PineconeConfig`): Configuration specific to Pinecone vector store
|
|
51
51
|
|
|
52
|
-
**
|
|
52
|
+
**databaseConfig.pinecone.namespace** (`string`): Pinecone namespace for organizing vectors
|
|
53
53
|
|
|
54
|
-
**
|
|
54
|
+
**databaseConfig.pinecone.sparseVector** (`{ indices: number[]; values: number[]; }`): Sparse vector for hybrid search
|
|
55
55
|
|
|
56
|
-
|
|
56
|
+
**databaseConfig.pgvector** (`PgVectorConfig`): Configuration specific to PostgreSQL with pgvector extension
|
|
57
57
|
|
|
58
|
-
**
|
|
58
|
+
**databaseConfig.pgvector.minScore** (`number`): Minimum similarity score threshold for results
|
|
59
59
|
|
|
60
|
-
**
|
|
60
|
+
**databaseConfig.pgvector.ef** (`number`): HNSW search parameter - controls accuracy vs speed tradeoff
|
|
61
|
+
|
|
62
|
+
**databaseConfig.pgvector.probes** (`number`): IVFFlat probe parameter - number of cells to visit during search
|
|
63
|
+
|
|
64
|
+
**databaseConfig.chroma** (`ChromaConfig`): Configuration specific to Chroma vector store
|
|
65
|
+
|
|
66
|
+
**databaseConfig.chroma.where** (`Record<string, any>`): Metadata filtering conditions
|
|
67
|
+
|
|
68
|
+
**databaseConfig.chroma.whereDocument** (`Record<string, any>`): Document content filtering conditions
|
|
69
|
+
|
|
70
|
+
**providerOptions** (`Record<string, Record<string, any>>`): Provider-specific options for the embedding model (e.g., outputDimensionality). \*\*Important\*\*: Only works with AI SDK EmbeddingModelV2 models. For V1 models, configure options when creating the model itself.
|
|
71
|
+
|
|
72
|
+
**vectorStore** (`MastraVector | VectorStoreResolver`): Direct vector store instance or a resolver function for dynamic selection. Use a function for multi-tenant applications where the vector store is selected based on request context. When provided, \`vectorStoreName\` becomes optional.
|
|
61
73
|
|
|
62
74
|
## Returns
|
|
63
75
|
|
|
64
76
|
The tool returns an object with:
|
|
65
77
|
|
|
66
|
-
**relevantContext
|
|
78
|
+
**relevantContext** (`string`): Combined text from the most relevant document chunks
|
|
67
79
|
|
|
68
|
-
**sources
|
|
80
|
+
**sources** (`QueryResult[]`): Array of full retrieval result objects. Each object contains all information needed to reference the original document, chunk, and similarity score.
|
|
69
81
|
|
|
70
82
|
### QueryResult object structure
|
|
71
83
|
|