@mastra/memory 1.24.0 → 1.25.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 +43 -0
- package/dist/docs/SKILL.md +6 -6
- package/dist/docs/assets/SOURCE_MAP.json +1 -1
- package/dist/docs/references/docs-agents-agent-approval.md +85 -11
- package/dist/docs/references/docs-agents-networks.md +2 -2
- package/dist/docs/references/docs-agents-supervisor-agents.md +19 -13
- package/dist/docs/references/docs-evals-evals-with-memory.md +4 -4
- package/dist/docs/references/docs-long-running-agents-background-tasks.md +10 -10
- package/dist/docs/references/docs-long-running-agents-goals.md +15 -11
- package/dist/docs/references/docs-memory-memory-processors.md +10 -10
- package/dist/docs/references/docs-memory-message-history.md +11 -5
- package/dist/docs/references/docs-memory-multi-user-threads.md +6 -6
- package/dist/docs/references/docs-memory-observational-memory.md +57 -38
- package/dist/docs/references/docs-memory-overview.md +24 -10
- package/dist/docs/references/docs-memory-semantic-recall.md +3 -3
- package/dist/docs/references/docs-memory-working-memory.md +8 -8
- package/dist/docs/references/docs-storage-overview.md +2 -2
- package/dist/docs/references/reference-memory-clone-utilities.md +1 -1
- package/dist/docs/references/reference-memory-cloneThread.md +3 -3
- package/dist/docs/references/reference-memory-listThreads.md +1 -1
- package/dist/docs/references/reference-memory-memory-class.md +4 -4
- package/dist/docs/references/reference-memory-observational-memory.md +88 -38
- package/dist/docs/references/reference-memory-summarizeConversation.md +3 -3
- package/dist/docs/references/reference-memory-summarizeThread.md +3 -3
- package/dist/docs/references/reference-processors-token-limiter-processor.md +4 -4
- package/dist/docs/references/reference-storage-dsql.md +3 -3
- package/dist/docs/references/reference-storage-dynamodb.md +7 -7
- package/dist/docs/references/reference-storage-mongodb.md +2 -2
- package/dist/docs/references/reference-storage-postgresql.md +2 -2
- package/dist/docs/references/reference-storage-redis.md +1 -1
- package/dist/docs/references/reference-storage-upstash.md +1 -1
- package/dist/docs/references/reference-vectors-libsql.md +2 -2
- package/dist/docs/references/reference-vectors-mongodb.md +16 -16
- package/dist/docs/references/reference-vectors-pg.md +5 -5
- package/dist/docs/references/reference-vectors-upstash.md +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/processors/index.cjs +1 -1
- package/dist/processors/index.js +1 -1
- package/dist/processors/observational-memory/index.d.ts +1 -1
- package/dist/processors/observational-memory/index.d.ts.map +1 -1
- package/dist/processors/observational-memory/internal-request-context.d.ts +7 -0
- package/dist/processors/observational-memory/internal-request-context.d.ts.map +1 -1
- package/dist/processors/observational-memory/observation-strategies/types.d.ts +6 -0
- package/dist/processors/observational-memory/observation-strategies/types.d.ts.map +1 -1
- package/dist/processors/observational-memory/observation-turn/step.d.ts.map +1 -1
- package/dist/processors/observational-memory/observational-memory.d.ts +30 -1
- package/dist/processors/observational-memory/observational-memory.d.ts.map +1 -1
- package/dist/processors/observational-memory/processor.d.ts.map +1 -1
- package/dist/processors/observational-memory/reflector-runner.d.ts.map +1 -1
- package/dist/processors/observational-memory/types.d.ts +50 -6
- package/dist/processors/observational-memory/types.d.ts.map +1 -1
- package/dist/{src-VD6qMn-H.cjs → src-C3u7zaSu.cjs} +182 -32
- package/dist/{src-VD6qMn-H.cjs.map → src-C3u7zaSu.cjs.map} +1 -1
- package/dist/{src-Ci_GvBVm.js → src-DoNjfXNm.js} +182 -32
- package/dist/{src-Ci_GvBVm.js.map → src-DoNjfXNm.js.map} +1 -1
- package/package.json +7 -7
|
@@ -183,7 +183,7 @@ storage.db // Database client for executing queries
|
|
|
183
183
|
storage.pool // Underlying pg.Pool instance
|
|
184
184
|
```
|
|
185
185
|
|
|
186
|
-
|
|
186
|
+
It supports direct queries and custom transaction management. When using these fields:
|
|
187
187
|
|
|
188
188
|
- You are responsible for proper connection and transaction handling.
|
|
189
189
|
- Closing the store (`storage.close()`) will destroy the connection pool if it was created by the store.
|
|
@@ -199,7 +199,7 @@ Connections are authenticated with IAM. No database passwords are required. `@ma
|
|
|
199
199
|
|
|
200
200
|
#### Single database, schema-based isolation
|
|
201
201
|
|
|
202
|
-
Each cluster exposes a single database
|
|
202
|
+
Each cluster exposes a single database `postgres`. Logical separation is done via schemas. The `schemaName` option controls where Mastra tables are created.
|
|
203
203
|
|
|
204
204
|
#### No PostgreSQL extensions
|
|
205
205
|
|
|
@@ -243,7 +243,7 @@ export const dsqlAgent = new Agent({
|
|
|
243
243
|
name: 'DSQL Agent',
|
|
244
244
|
instructions:
|
|
245
245
|
'You are an AI agent with the ability to automatically recall memories from previous interactions.',
|
|
246
|
-
model: 'openai/gpt-5.
|
|
246
|
+
model: 'openai/gpt-5.6-sol',
|
|
247
247
|
memory: new Memory({
|
|
248
248
|
storage: new DSQLStore({
|
|
249
249
|
id: 'dsql-agent-storage',
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
# DynamoDB storage
|
|
4
4
|
|
|
5
|
-
The DynamoDB storage implementation provides a
|
|
5
|
+
The DynamoDB storage implementation provides a high-capacity and performant NoSQL database solution for Mastra, using a single-table design pattern with [ElectroDB](https://electrodb.dev/).
|
|
6
6
|
|
|
7
7
|
> **Observability Not Supported:** DynamoDB storage **doesn't support the observability domain**. Traces from the `MastraStorageExporter` can't be persisted to DynamoDB, and [Studio's](https://mastra.ai/docs/studio/overview) observability features won't work with DynamoDB as your only storage provider. To enable observability, use [composite storage](https://mastra.ai/reference/storage/composite) to route observability data to a supported provider like ClickHouse.
|
|
8
8
|
|
|
@@ -124,7 +124,7 @@ For local development, you can use [DynamoDB Local](https://docs.aws.amazon.com/
|
|
|
124
124
|
|
|
125
125
|
## TTL (time to live) configuration
|
|
126
126
|
|
|
127
|
-
DynamoDB TTL allows you to automatically delete items after a specified
|
|
127
|
+
DynamoDB TTL allows you to automatically delete items after a specified duration for these use cases:
|
|
128
128
|
|
|
129
129
|
- **Cost optimization**: Automatically remove old data to reduce storage costs
|
|
130
130
|
- **Data lifecycle management**: Implement retention policies for compliance
|
|
@@ -259,19 +259,19 @@ Before diving into the architectural details, keep these key points in mind when
|
|
|
259
259
|
|
|
260
260
|
## Architectural approach
|
|
261
261
|
|
|
262
|
-
This storage adapter utilizes a **single-table design pattern**
|
|
262
|
+
This storage adapter utilizes a **single-table design pattern** with [ElectroDB](https://electrodb.dev/), a common and recommended approach for DynamoDB. This differs architecturally from relational database adapters (like `@mastra/pg` or `@mastra/libsql`) that typically use multiple tables, each dedicated to a specific entity (threads, messages, etc.).
|
|
263
263
|
|
|
264
264
|
Key aspects of this approach:
|
|
265
265
|
|
|
266
|
-
- **DynamoDB Native:** The single-table design is optimized for DynamoDB's key-value and query capabilities, often leading to better performance and
|
|
266
|
+
- **DynamoDB Native:** The single-table design is optimized for DynamoDB's key-value and query capabilities, often leading to better performance and capacity compared to mimicking relational models.
|
|
267
267
|
- **External Table Management:** Unlike some adapters that might offer helper functions to create tables via code, this adapter **expects the DynamoDB table and its associated Global Secondary Indexes (GSIs) to be provisioned externally** before use. Please refer to [TABLE\_SETUP.md](https://github.com/mastra-ai/mastra/blob/main/stores/dynamodb/TABLE_SETUP.md) for detailed instructions using tools like AWS CloudFormation or CDK. The adapter focuses solely on interacting with the pre-existing table structure.
|
|
268
268
|
- **Consistency via Interface:** While the underlying storage model differs, this adapter adheres to the same `MastraStorage` interface as other adapters, ensuring it can be used interchangeably within the Mastra `Memory` component.
|
|
269
269
|
|
|
270
270
|
### Mastra Data in the Single Table
|
|
271
271
|
|
|
272
|
-
Within the single DynamoDB table, different Mastra data entities (such as Threads, Messages, Traces, Evals, and Workflows) are managed and distinguished using ElectroDB. ElectroDB defines specific models for each entity type, which include unique key structures and attributes.
|
|
272
|
+
Within the single DynamoDB table, different Mastra data entities (such as Threads, Messages, Traces, Evals, and Workflows) are managed and distinguished using ElectroDB. ElectroDB defines specific models for each entity type, which include unique key structures and attributes. It allows the adapter to store and retrieve diverse data types efficiently within the same table.
|
|
273
273
|
|
|
274
|
-
For example, a `Thread` item might have a primary key like `THREAD#<threadId>`, while a `Message` item belonging to that thread might use `THREAD#<threadId>` as a partition key and `MESSAGE#<messageId>` as a sort key. The Global Secondary Indexes (GSIs), detailed in `TABLE_SETUP.md`, are strategically designed to support common access patterns across these different entities, such as fetching all messages for a thread or querying traces associated with a
|
|
274
|
+
For example, a `Thread` item might have a primary key like `THREAD#<threadId>`, while a `Message` item belonging to that thread might use `THREAD#<threadId>` as a partition key and `MESSAGE#<messageId>` as a sort key. The Global Secondary Indexes (GSIs), detailed in `TABLE_SETUP.md`, are strategically designed to support common access patterns across these different entities, such as fetching all messages for a thread or querying traces associated with a workflow.
|
|
275
275
|
|
|
276
276
|
### Advantages of Single-Table Design
|
|
277
277
|
|
|
@@ -279,6 +279,6 @@ This implementation uses a single-table design pattern with ElectroDB, which off
|
|
|
279
279
|
|
|
280
280
|
1. **Lower cost (potentially):** Fewer tables can simplify Read/Write Capacity Unit (RCU/WCU) provisioning and management, especially with on-demand capacity.
|
|
281
281
|
2. **Better performance:** Related data can be co-located or accessed efficiently through GSIs, enabling fast lookups for common access patterns.
|
|
282
|
-
3. **Simplified administration:** Fewer distinct tables to monitor
|
|
282
|
+
3. **Simplified administration:** Fewer distinct tables to monitor and back up, with less to manage.
|
|
283
283
|
4. **Reduced complexity in access patterns:** ElectroDB helps manage the complexity of item types and access patterns on a single table.
|
|
284
284
|
5. **Transaction support:** DynamoDB transactions can be used across different "entity" types stored within the same table if needed.
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
# MongoDB storage
|
|
4
4
|
|
|
5
|
-
The MongoDB storage implementation provides a
|
|
5
|
+
The MongoDB storage implementation provides a high-capacity storage solution using MongoDB databases with support for both document storage and vector operations.
|
|
6
6
|
|
|
7
7
|
## Installation
|
|
8
8
|
|
|
@@ -210,7 +210,7 @@ export const mongodbAgent = new Agent({
|
|
|
210
210
|
name: 'mongodb-agent',
|
|
211
211
|
instructions:
|
|
212
212
|
'You are an AI agent with the ability to automatically recall memories from previous interactions.',
|
|
213
|
-
model: 'openai/gpt-5.
|
|
213
|
+
model: 'openai/gpt-5.6-sol',
|
|
214
214
|
memory: new Memory({
|
|
215
215
|
storage: new MongoDBStore({
|
|
216
216
|
id: 'mongodb-storage',
|
|
@@ -317,7 +317,7 @@ export const mastra = new Mastra({
|
|
|
317
317
|
})
|
|
318
318
|
```
|
|
319
319
|
|
|
320
|
-
|
|
320
|
+
The pattern ensures only one `PostgresStore` instance is created regardless of how many times the module is reloaded during development. The same pattern can be applied to other storage providers like `LibSQLStore`.
|
|
321
321
|
|
|
322
322
|
> **Tip:** This singleton pattern is only necessary during local development with HMR. In production builds, modules are only loaded once.
|
|
323
323
|
|
|
@@ -337,7 +337,7 @@ export const pgAgent = new Agent({
|
|
|
337
337
|
name: 'PG Agent',
|
|
338
338
|
instructions:
|
|
339
339
|
'You are an AI agent with the ability to automatically recall memories from previous interactions.',
|
|
340
|
-
model: 'openai/gpt-5.
|
|
340
|
+
model: 'openai/gpt-5.6-sol',
|
|
341
341
|
memory: new Memory({
|
|
342
342
|
storage: new PostgresStore({
|
|
343
343
|
id: 'pg-agent-storage',
|
|
@@ -183,7 +183,7 @@ export const redisAgent = new Agent({
|
|
|
183
183
|
name: 'Redis Agent',
|
|
184
184
|
instructions:
|
|
185
185
|
'You are an AI agent with the ability to automatically recall memories from previous interactions.',
|
|
186
|
-
model: 'openai/gpt-5.
|
|
186
|
+
model: 'openai/gpt-5.6-sol',
|
|
187
187
|
memory: new Memory({
|
|
188
188
|
storage: new RedisStore({
|
|
189
189
|
id: 'redis-agent-storage',
|
|
@@ -105,7 +105,7 @@ export const upstashAgent = new Agent({
|
|
|
105
105
|
name: 'Upstash Agent',
|
|
106
106
|
instructions:
|
|
107
107
|
'You are an AI agent with the ability to automatically recall memories from previous interactions.',
|
|
108
|
-
model: 'openai/gpt-5.
|
|
108
|
+
model: 'openai/gpt-5.6-sol',
|
|
109
109
|
memory: new Memory({
|
|
110
110
|
storage: new UpstashStore({
|
|
111
111
|
id: 'upstash-agent-storage',
|
|
@@ -85,7 +85,7 @@ const results = await store.query({
|
|
|
85
85
|
|
|
86
86
|
### `createIndex()`
|
|
87
87
|
|
|
88
|
-
Creates a new vector collection. The index name must start with a letter or underscore and can only contain letters, numbers, and
|
|
88
|
+
Creates a new vector collection. The index name must start with a letter or underscore and can only contain letters, numbers, and underscore characters. The dimension must be a positive integer.
|
|
89
89
|
|
|
90
90
|
**indexName** (`string`): Name of the index to create
|
|
91
91
|
|
|
@@ -279,7 +279,7 @@ export const libsqlAgent = new Agent({
|
|
|
279
279
|
name: 'libSQL Agent',
|
|
280
280
|
instructions:
|
|
281
281
|
'You are an AI agent with the ability to automatically recall memories from previous interactions.',
|
|
282
|
-
model: 'openai/gpt-5.
|
|
282
|
+
model: 'openai/gpt-5.6-sol',
|
|
283
283
|
memory: new Memory({
|
|
284
284
|
storage: new LibSQLStore({
|
|
285
285
|
id: 'libsql-agent-storage',
|
|
@@ -109,7 +109,7 @@ Waits for an index to become ready after creation. Useful when you need to ensur
|
|
|
109
109
|
|
|
110
110
|
### `upsert()`
|
|
111
111
|
|
|
112
|
-
Adds or updates vectors and their metadata in the collection. On a bring-your-own index this requires `allowWrites: true` at `createIndex()` time
|
|
112
|
+
Adds or updates vectors and their metadata in the collection. On a bring-your-own index, this requires `allowWrites: true` at `createIndex()` time because BYO collections are read-only by default.
|
|
113
113
|
|
|
114
114
|
**indexName** (`string`): Name of the collection to insert into
|
|
115
115
|
|
|
@@ -148,12 +148,12 @@ Provisions an Atlas Search (BM25/full-text) index on the collection backing an i
|
|
|
148
148
|
**Managed vs. bring-your-own collections:**
|
|
149
149
|
|
|
150
150
|
- For a **managed** index (created without `collectionName`), `createIndex()` already provisions a _dynamic_ full-text index named `${collectionName}_search_index` (covering all string fields). `createSearchIndex()` is therefore only needed when you want a **field-restricted** mapping or a **custom index name**.
|
|
151
|
-
- For a **bring-your-own** index (created with `collectionName`), `createIndex()`
|
|
151
|
+
- For a **bring-your-own** index (created with `collectionName`), `createIndex()` doesn't auto-create any full-text index. Enabling `textQuery()`/`hybridQuery()` on a caller-owned operational collection is opt-in. Call `createSearchIndex()` explicitly to provision the (billable) text index. Until you do, `textQuery()`/`hybridQuery()` throw a clear error rather than querying a non-existent index.
|
|
152
152
|
|
|
153
153
|
Naming:
|
|
154
154
|
|
|
155
|
-
- When `fields` is provided **without** an explicit `searchIndexName`, the field-mapped index is created under a **distinct** default name (`${collectionName}_${indexName}_search_fields_index`, unique per logical index) so it
|
|
156
|
-
- When `searchIndexName` is provided, that exact name is used and persisted. `textQuery()`/`hybridQuery()` resolve the persisted name automatically
|
|
155
|
+
- When `fields` is provided **without** an explicit `searchIndexName`, the field-mapped index is created under a **distinct** default name (`${collectionName}_${indexName}_search_fields_index`, unique per logical index) so it doesn't collide with a managed collection's auto-created dynamic index and get silently ignored. This distinct index is persisted as the text-search index, so `textQuery()`/`hybridQuery()` use the restricted mapping automatically.
|
|
156
|
+
- When `searchIndexName` is provided, that exact name is used and persisted. `textQuery()`/`hybridQuery()` resolve the persisted name automatically. You can also override the name per call via their `searchIndexName` / `textSearchIndexName` parameters.
|
|
157
157
|
|
|
158
158
|
**indexName** (`string`): Name of the Mastra index whose collection will have the search index
|
|
159
159
|
|
|
@@ -170,7 +170,7 @@ await store.createSearchIndex({
|
|
|
170
170
|
})
|
|
171
171
|
```
|
|
172
172
|
|
|
173
|
-
|
|
173
|
+
The field-mapped index name includes the logical `indexName`, so two logical indexes on the same collection get distinct text indexes. Recreating the _same_ logical index with different `fields` still requires dropping the existing index first (`IndexAlreadyExists`).
|
|
174
174
|
|
|
175
175
|
### `waitForSearchIndexReady()`
|
|
176
176
|
|
|
@@ -193,7 +193,7 @@ await store.waitForSearchIndexReady({ indexName: 'precedents' })
|
|
|
193
193
|
|
|
194
194
|
Runs a full-text (BM25) search against an Atlas Search index. By default it targets the text-search index recorded for this index (set by `createSearchIndex()`, or the dynamic `${collectionName}_search_index` auto-created by `createIndex()`). Pass `searchIndexName` to target a specific index for this call.
|
|
195
195
|
|
|
196
|
-
|
|
196
|
+
Metadata filters here (like `hybridQuery()`) are applied via a `$match` stage. For the vector branch of `hybridQuery()`, filters on fields not declared via `filterFields` at index creation are transparently materialised as candidate `_id`s (the same fallback `query()` uses), so undeclared-field filters don't error.
|
|
197
197
|
|
|
198
198
|
**indexName** (`string`): Name of the Mastra index to search
|
|
199
199
|
|
|
@@ -220,7 +220,7 @@ const results = await store.textQuery({
|
|
|
220
220
|
|
|
221
221
|
### `hybridQuery()`
|
|
222
222
|
|
|
223
|
-
Runs a hybrid search that fuses vector similarity and full-text results using MongoDB's server-side `$rankFusion
|
|
223
|
+
Runs a hybrid search that fuses vector similarity and full-text results using MongoDB's server-side `$rankFusion`. It requires MongoDB >= 8.0 and is generally available from 8.1. On 8.0.x, it may need a MongoDB support case to enable, and it runs where enabled, such as Atlas 8.0.x. A full-text search index must exist: it's auto-created for managed indexes, but for a bring-your-own collection you must call `createSearchIndex()` first (opt-in).
|
|
224
224
|
|
|
225
225
|
**indexName** (`string`): Name of the Mastra index to search
|
|
226
226
|
|
|
@@ -253,7 +253,7 @@ const results = await store.hybridQuery({
|
|
|
253
253
|
})
|
|
254
254
|
```
|
|
255
255
|
|
|
256
|
-
|
|
256
|
+
`hybridQuery()` requires MongoDB >= 8.0 for the `$rankFusion` stage. The stage is generally available from 8.1. On 8.0.x, it may need a MongoDB support case to enable and runs where enabled, such as Atlas 8.0.x. If you're running an older version, or `$rankFusion` isn't enabled on your 8.0.x deployment, use `query()` and `textQuery()` separately and merge the results client-side.
|
|
257
257
|
|
|
258
258
|
### `describeIndex()`
|
|
259
259
|
|
|
@@ -276,15 +276,15 @@ interface IndexStats {
|
|
|
276
276
|
Deletes a vector index. Behavior depends on how the index was created:
|
|
277
277
|
|
|
278
278
|
- **Managed index** (created without `collectionName`): drops the entire collection and all its data.
|
|
279
|
-
- **Bring-your-own index** (created with `collectionName`): drops the Atlas vectorSearch index
|
|
279
|
+
- **Bring-your-own index** (created with `collectionName`): drops the Atlas vectorSearch index and, if one was provisioned via `createSearchIndex()`, the companion full-text search index. The caller's operational collection and its documents are preserved. This store never drops a collection it didn't create.
|
|
280
280
|
|
|
281
|
-
The BYO classification is recorded durably when the index is created, so it
|
|
281
|
+
The BYO classification is recorded durably when the index is created, so it's applied correctly even by a different process (e.g. an index created by a setup job and later deleted by a long-lived service). Always pass the **logical index name** (the `indexName` used at `createIndex`), not the physical collection name.
|
|
282
282
|
|
|
283
283
|
**indexName** (`string`): Logical name of the index to delete
|
|
284
284
|
|
|
285
285
|
### `listIndexes()`
|
|
286
286
|
|
|
287
|
-
Lists the **logical** Mastra index names (the `indexName` values passed to `createIndex`), not physical collection names. For a bring-your-own index whose data lives in an operational collection, the logical index name is returned
|
|
287
|
+
Lists the **logical** Mastra index names (the `indexName` values passed to `createIndex`), not physical collection names. For a bring-your-own index whose data lives in an operational collection, the logical index name is returned instead of the physical collection name. The value can be passed straight back into `deleteIndex()` / `describeIndex()`. Managed indexes created before durable metadata was introduced are still discovered via their `${name}_vector_index` search index. The internal registry collection is never listed.
|
|
288
288
|
|
|
289
289
|
Returns: `Promise<string[]>`
|
|
290
290
|
|
|
@@ -408,12 +408,12 @@ await store.createSearchIndex({ indexName: 'precedents', fields: ['note'] })
|
|
|
408
408
|
|
|
409
409
|
- The collection must already exist and contain documents with an `embedding` field (or the custom `embeddingFieldPath` you configured)
|
|
410
410
|
- The collection is never created or dropped when using `collectionName`
|
|
411
|
-
- **A BYO index is read-only by default.** `upsert()`, `updateVector()`, `deleteVector()`, and `deleteVectors()` throw a clear error rather than mutating caller-owned operational documents. To let the store write embeddings into (or delete documents from) your collection, opt in explicitly with `createIndex({ ..., allowWrites: true })`. The policy is persisted and survives restarts
|
|
411
|
+
- **A BYO index is read-only by default.** `upsert()`, `updateVector()`, `deleteVector()`, and `deleteVectors()` throw a clear error rather than mutating caller-owned operational documents. To let the store write embeddings into (or delete documents from) your collection, opt in explicitly with `createIndex({ ..., allowWrites: true })`. The policy is persisted and survives restarts. Entries written by older versions without the flag are treated as read-only (fail closed).
|
|
412
412
|
- Use `metadataMode: 'document'` when querying to retrieve the full source document as `metadata`
|
|
413
413
|
- In `'document'` mode the embedding is omitted from `metadata` by default; pass `includeVector: true` to retain it (and also expose it as a top-level `vector`)
|
|
414
414
|
- **Filtering in `'document'` mode operates on root document fields**, not a nested `metadata.` subdocument. `filter: { lane: 'fraud' }` matches the top-level `lane` field of your operational documents (in the default `'field'` mode, bare fields are rewritten to `metadata.<field>` for managed collections). Both the pushdown and `$match` fallback paths honor this.
|
|
415
415
|
- **Native `ObjectId` `_id`s are supported.** Operational collections commonly key on `ObjectId`; query results coerce `_id` to a string (the `QueryResult.id` contract), and `deleteVector()`/`updateVector()`/`deleteVectors()` accept that string and match the underlying `ObjectId` document. Managed collections (string `_id`s) are unaffected.
|
|
416
|
-
- Full-text and hybrid search on a BYO collection are **opt-in**: no full-text index is auto-created, so call `createSearchIndex()` before `textQuery()`/`hybridQuery()`. The full-text index builds asynchronously
|
|
416
|
+
- Full-text and hybrid search on a BYO collection are **opt-in**: no full-text index is auto-created, so call `createSearchIndex()` before `textQuery()`/`hybridQuery()`. The full-text index builds asynchronously. Call `waitForSearchIndexReady()` (or pass `waitUntilReady: true`) before an immediate text/hybrid query.
|
|
417
417
|
- `deleteIndex()` on a BYO index drops the vector index (and the text index if one was created) but **preserves** the collection and its documents
|
|
418
418
|
|
|
419
419
|
## Best practices
|
|
@@ -470,7 +470,7 @@ export const mongodbAgent = new Agent({
|
|
|
470
470
|
name: 'mongodb-agent',
|
|
471
471
|
instructions:
|
|
472
472
|
'You are an AI agent with the ability to automatically recall memories from previous interactions.',
|
|
473
|
-
model: 'openai/gpt-5.
|
|
473
|
+
model: 'openai/gpt-5.6-sol',
|
|
474
474
|
memory: new Memory({
|
|
475
475
|
storage: new MongoDBStore({
|
|
476
476
|
id: 'mongodb-storage',
|
|
@@ -535,7 +535,7 @@ export const mongodbVoyageAgent = new Agent({
|
|
|
535
535
|
id: 'mongodb-voyage-agent',
|
|
536
536
|
name: 'MongoDB VoyageAI Agent',
|
|
537
537
|
instructions: 'You are an AI agent with semantic recall powered by VoyageAI and MongoDB.',
|
|
538
|
-
model: 'openai/gpt-5.
|
|
538
|
+
model: 'openai/gpt-5.6-sol',
|
|
539
539
|
memory: new Memory({
|
|
540
540
|
storage: new MongoDBStore({
|
|
541
541
|
id: 'mongodb-storage',
|
|
@@ -559,7 +559,7 @@ export const mongodbVoyageAgent = new Agent({
|
|
|
559
559
|
})
|
|
560
560
|
```
|
|
561
561
|
|
|
562
|
-
For
|
|
562
|
+
For detailed VoyageAI embedding examples including specialized models, multimodal embeddings, and retrieval optimization, see the [VoyageAI embeddings documentation](https://mastra.ai/models/embeddings).
|
|
563
563
|
|
|
564
564
|
## Related
|
|
565
565
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
# PG vector store
|
|
4
4
|
|
|
5
|
-
The PgVector class provides vector search using [PostgreSQL](https://www.postgresql.org/) with [pgvector](https://github.com/pgvector/pgvector) extension. It provides
|
|
5
|
+
The PgVector class provides vector search using [PostgreSQL](https://www.postgresql.org/) with [pgvector](https://github.com/pgvector/pgvector) extension. It provides reliable vector similarity search capabilities within your existing PostgreSQL database.
|
|
6
6
|
|
|
7
7
|
## Constructor options
|
|
8
8
|
|
|
@@ -110,13 +110,13 @@ const vectorStore = new PgVector({
|
|
|
110
110
|
|
|
111
111
|
#### Memory Requirements
|
|
112
112
|
|
|
113
|
-
HNSW indexes require
|
|
113
|
+
HNSW indexes require substantial shared memory during construction. For 100K vectors:
|
|
114
114
|
|
|
115
115
|
- Small dimensions (64d): \~60MB with default settings
|
|
116
116
|
- Medium dimensions (256d): \~180MB with default settings
|
|
117
117
|
- Large dimensions (384d+): \~250MB+ with default settings
|
|
118
118
|
|
|
119
|
-
Higher M values or efConstruction values will increase memory requirements
|
|
119
|
+
Higher M values or efConstruction values will increase memory requirements substantially. Adjust your system's shared memory limits if needed.
|
|
120
120
|
|
|
121
121
|
### `upsert()`
|
|
122
122
|
|
|
@@ -340,7 +340,7 @@ The system automatically detects configuration changes and only rebuilds indexes
|
|
|
340
340
|
- Regularly evaluate your index configuration to ensure optimal performance.
|
|
341
341
|
- Adjust parameters like `lists` and `m` based on dataset size and query requirements.
|
|
342
342
|
- **Monitor index performance** using `describeIndex()` to track usage
|
|
343
|
-
- Rebuild indexes periodically to maintain efficiency, especially after
|
|
343
|
+
- Rebuild indexes periodically to maintain efficiency, especially after substantial data changes
|
|
344
344
|
|
|
345
345
|
## Direct pool access
|
|
346
346
|
|
|
@@ -403,7 +403,7 @@ export const pgAgent = new Agent({
|
|
|
403
403
|
name: 'PG Agent',
|
|
404
404
|
instructions:
|
|
405
405
|
'You are an AI agent with the ability to automatically recall memories from previous interactions.',
|
|
406
|
-
model: 'openai/gpt-5.
|
|
406
|
+
model: 'openai/gpt-5.6-sol',
|
|
407
407
|
memory: new Memory({
|
|
408
408
|
storage: new PostgresStore({
|
|
409
409
|
id: 'pg-agent-storage',
|
|
@@ -267,7 +267,7 @@ export const upstashAgent = new Agent({
|
|
|
267
267
|
name: 'Upstash Agent',
|
|
268
268
|
instructions:
|
|
269
269
|
'You are an AI agent with the ability to automatically recall memories from previous interactions.',
|
|
270
|
-
model: 'openai/gpt-5.
|
|
270
|
+
model: 'openai/gpt-5.6-sol',
|
|
271
271
|
memory: new Memory({
|
|
272
272
|
storage: new UpstashStore({
|
|
273
273
|
id: 'upstash-agent-storage',
|
package/dist/index.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_src = require("./src-
|
|
2
|
+
const require_src = require("./src-C3u7zaSu.cjs");
|
|
3
3
|
let _mastra_core_processors = require("@mastra/core/processors");
|
|
4
4
|
exports.Extractor = require_src.Extractor;
|
|
5
5
|
exports.Memory = require_src.Memory;
|
package/dist/index.d.ts
CHANGED
|
@@ -28,6 +28,7 @@ type MemoryObservationalMemoryOptions = Omit<ObservationalMemoryOptions, 'model'
|
|
|
28
28
|
activateAfterIdle?: ObservationalMemoryConfig['activateAfterIdle'];
|
|
29
29
|
activateOnProviderChange?: ObservationalMemoryConfig['activateOnProviderChange'];
|
|
30
30
|
temporalMarkers?: boolean;
|
|
31
|
+
hooks?: ObservationalMemoryConfig['hooks'];
|
|
31
32
|
};
|
|
32
33
|
type MemoryOptions = Omit<MemoryConfigInternal, 'observationalMemory'> & {
|
|
33
34
|
observationalMemory?: boolean | MemoryObservationalMemoryOptions;
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAKhD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAG1D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,KAAK,EACV,oBAAoB,EACpB,kBAAkB,EAClB,iBAAiB,EACjB,qBAAqB,EACrB,kBAAkB,EAClB,0BAA0B,EAC1B,YAAY,EACb,MAAM,qBAAqB,CAAC;AAE7B,OAAO,KAAK,EAAE,oBAAoB,EAA6B,MAAM,4BAA4B,CAAC;AAClG,OAAO,KAAK,EACV,cAAc,EACd,wBAAwB,EACxB,eAAe,EACf,yBAAyB,EAC1B,MAAM,yBAAyB,CAAC;AACjC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AACnE,OAAO,KAAK,EACV,uBAAuB,EACvB,wBAAwB,EACxB,wBAAwB,EACxB,oCAAoC,EACpC,yBAAyB,EACzB,aAAa,EACb,uBAAuB,EACvB,wBAAwB,EACxB,mBAAmB,EACnB,yBAAyB,EAE1B,MAAM,sBAAsB,CAAC;AAC9B,OA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IACG,mBAAmB,CACvB,oBAAoB,GAAE,yBAAyB,EAAO,EACtD,OAAO,CAAC,EAAE,cAAc,GACvB,OAAO,CAAC,eAAe,EAAE,CAAC;IAW7B;;;;OAIG;YACW,iBAAiB;IAqC/B;;;;OAIG;YACW,iCAAiC;CAwBhD;AAGD,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAGxF,YAAY,EAAE,uBAAuB,EAAE,wBAAwB,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAGnH,OAAO,EAAE,mBAAmB,EAAE,MAAM,mCAAmC,CAAC;AAGxE,OAAO,EACL,2BAA2B,EAC3B,uBAAuB,EACvB,iCAAiC,GAClC,MAAM,mCAAmC,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { C as WorkingMemoryExtractor, R as Extractor, S as deepMergeWorkingMemory, T as summarizeConversation, a as extractWorkingMemoryContent, c as WORKING_MEMORY_STATE_ID, d as getObservationsAsOf, i as WorkingMemory, l as WORKING_MEMORY_STATE_PROCESSOR_ID, n as MessageHistory, o as extractWorkingMemoryTags, r as SemanticRecall, s as removeWorkingMemoryTags, t as Memory, u as WorkingMemoryStateProcessor, w as SUMMARIZE_THREAD_DEFAULTS, x as ModelByInputTokens } from "./src-
|
|
1
|
+
import { C as WorkingMemoryExtractor, R as Extractor, S as deepMergeWorkingMemory, T as summarizeConversation, a as extractWorkingMemoryContent, c as WORKING_MEMORY_STATE_ID, d as getObservationsAsOf, i as WorkingMemory, l as WORKING_MEMORY_STATE_PROCESSOR_ID, n as MessageHistory, o as extractWorkingMemoryTags, r as SemanticRecall, s as removeWorkingMemoryTags, t as Memory, u as WorkingMemoryStateProcessor, w as SUMMARIZE_THREAD_DEFAULTS, x as ModelByInputTokens } from "./src-DoNjfXNm.js";
|
|
2
2
|
export { Extractor, Memory, MessageHistory, ModelByInputTokens, SUMMARIZE_THREAD_DEFAULTS, SemanticRecall, WORKING_MEMORY_STATE_ID, WORKING_MEMORY_STATE_PROCESSOR_ID, WorkingMemory, WorkingMemoryExtractor, WorkingMemoryStateProcessor, deepMergeWorkingMemory, extractWorkingMemoryContent, extractWorkingMemoryTags, getObservationsAsOf, removeWorkingMemoryTags, summarizeConversation };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_src = require("../src-
|
|
2
|
+
const require_src = require("../src-C3u7zaSu.cjs");
|
|
3
3
|
exports.Extractor = require_src.Extractor;
|
|
4
4
|
exports.ModelByInputTokens = require_src.ModelByInputTokens;
|
|
5
5
|
exports.OBSERVATIONAL_MEMORY_DEFAULTS = require_src.OBSERVATIONAL_MEMORY_DEFAULTS;
|
package/dist/processors/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { A as extractCurrentTask, B as OBSERVATION_CONTEXT_INSTRUCTIONS, C as WorkingMemoryExtractor, D as OBSERVER_SYSTEM_PROMPT, E as TokenCounter, F as injectAnchorIds, H as OBSERVATION_CONTINUATION_HINT, I as parseAnchorId, L as stripEphemeralAnchorIds, M as hasCurrentTaskSection, N as optimizeObservationsForContext, O as buildObserverPrompt, P as parseObserverOutput, R as Extractor, T as summarizeConversation, V as OBSERVATION_CONTEXT_PROMPT, _ as reconcileObservationGroupsFromReflection, b as wrapInObservationGroup, d as getObservationsAsOf, f as ObservationalMemoryProcessor, g as parseObservationGroups, h as deriveObservationGroupProvenance, j as formatMessagesForObserver, k as buildObserverSystemPrompt, m as combineObservationGroupRanges, p as ObservationalMemory, v as renderObservationGroupsForReflection, x as ModelByInputTokens, y as stripObservationGroups, z as OBSERVATIONAL_MEMORY_DEFAULTS } from "../src-
|
|
1
|
+
import { A as extractCurrentTask, B as OBSERVATION_CONTEXT_INSTRUCTIONS, C as WorkingMemoryExtractor, D as OBSERVER_SYSTEM_PROMPT, E as TokenCounter, F as injectAnchorIds, H as OBSERVATION_CONTINUATION_HINT, I as parseAnchorId, L as stripEphemeralAnchorIds, M as hasCurrentTaskSection, N as optimizeObservationsForContext, O as buildObserverPrompt, P as parseObserverOutput, R as Extractor, T as summarizeConversation, V as OBSERVATION_CONTEXT_PROMPT, _ as reconcileObservationGroupsFromReflection, b as wrapInObservationGroup, d as getObservationsAsOf, f as ObservationalMemoryProcessor, g as parseObservationGroups, h as deriveObservationGroupProvenance, j as formatMessagesForObserver, k as buildObserverSystemPrompt, m as combineObservationGroupRanges, p as ObservationalMemory, v as renderObservationGroupsForReflection, x as ModelByInputTokens, y as stripObservationGroups, z as OBSERVATIONAL_MEMORY_DEFAULTS } from "../src-DoNjfXNm.js";
|
|
2
2
|
export { Extractor, ModelByInputTokens, OBSERVATIONAL_MEMORY_DEFAULTS, OBSERVATION_CONTEXT_INSTRUCTIONS, OBSERVATION_CONTEXT_PROMPT, OBSERVATION_CONTINUATION_HINT, OBSERVER_SYSTEM_PROMPT, ObservationalMemory, ObservationalMemoryProcessor, TokenCounter, WorkingMemoryExtractor, buildObserverPrompt, buildObserverSystemPrompt, combineObservationGroupRanges, deriveObservationGroupProvenance, extractCurrentTask, formatMessagesForObserver, getObservationsAsOf, hasCurrentTaskSection, injectAnchorIds, optimizeObservationsForContext, parseAnchorId, parseObservationGroups, parseObserverOutput, reconcileObservationGroupsFromReflection, renderObservationGroupsForReflection, stripEphemeralAnchorIds, stripObservationGroups, summarizeConversation, wrapInObservationGroup };
|
|
@@ -21,7 +21,7 @@ export type { ExtractorConfig, ExtractorOnExtractedContext, ExtractorRuntimeCont
|
|
|
21
21
|
export { WorkingMemoryExtractor } from './working-memory-extractor.js';
|
|
22
22
|
export { summarizeConversation } from './summarize.js';
|
|
23
23
|
export type { SummarizeConversationOptions, SummarizeConversationResult, SummarizeModel } from './summarize.js';
|
|
24
|
-
export type { ObservationalMemoryConfig, ObservationDebugEvent, ObserveHooks, ObserveHookUsage, ObservationConfig, ReflectionConfig, ObserverResult, ReflectorResult, ObservationMarkerConfig, DataOmObservationStartPart, DataOmObservationEndPart, DataOmObservationFailedPart, DataOmStatusPart, DataOmThreadUpdatePart, DataOmObservationPart, DataOmBufferingStartPart, DataOmBufferingEndPart, DataOmBufferingFailedPart, DataOmBufferingPart, DataOmActivationPart, DataOmPart, } from './types.js';
|
|
24
|
+
export type { ObservationalMemoryConfig, ObservationDebugEvent, ObserveHooks, ObserveHookContext, ObserveHookUsage, ObserveTrigger, ObservationConfig, ReflectionConfig, ObserverResult, ReflectorResult, ObservationMarkerConfig, DataOmObservationStartPart, DataOmObservationEndPart, DataOmObservationFailedPart, DataOmStatusPart, DataOmThreadUpdatePart, DataOmObservationPart, DataOmBufferingStartPart, DataOmBufferingEndPart, DataOmBufferingFailedPart, DataOmBufferingPart, DataOmActivationPart, DataOmPart, } from './types.js';
|
|
25
25
|
export { OBSERVER_SYSTEM_PROMPT, buildObserverSystemPrompt, buildObserverPrompt, parseObserverOutput, optimizeObservationsForContext, formatMessagesForObserver, hasCurrentTaskSection, extractCurrentTask, type ObserverResult as ObserverAgentResult, } from './observer-agent.js';
|
|
26
26
|
export type { ObservationalMemoryRecord, ObservationalMemoryScope, ObservationalMemoryOriginType, CreateObservationalMemoryInput, UpdateActiveObservationsInput, UpdateBufferedObservationsInput, CreateReflectionGenerationInput, } from '@mastra/core/storage';
|
|
27
27
|
export { TokenCounter } from './token-counter.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/processors/observational-memory/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAGH,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAG7D,OAAO,EACL,6BAA6B,EAC7B,6BAA6B,EAC7B,0BAA0B,EAC1B,gCAAgC,GACjC,MAAM,aAAa,CAAC;AAGrB,OAAO,EAAE,4BAA4B,EAAE,MAAM,aAAa,CAAC;AAC3D,YAAY,EAAE,qBAAqB,EAAE,MAAM,aAA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AAM,cAAc,CAAC;AACvF,OAAO,EACL,sBAAsB,EACtB,sBAAsB,EACtB,sBAAsB,EACtB,oCAAoC,EACpC,wCAAwC,EACxC,gCAAgC,EAChC,6BAA6B,EAC7B,KAAK,gBAAgB,GACtB,MAAM,sBAAsB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/processors/observational-memory/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAGH,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAG7D,OAAO,EACL,6BAA6B,EAC7B,6BAA6B,EAC7B,0BAA0B,EAC1B,gCAAgC,GACjC,MAAM,aAAa,CAAC;AAGrB,OAAO,EAAE,4BAA4B,EAAE,MAAM,aAAa,CAAC;AAC3D,YAAY,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AAGzD,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAG1D,OAAO,EAAE,kBAAkB,EAAE,KAAK,wBAAwB,EAAE,MAAM,yBAAyB,CAAC;AAC5F,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,YAAY,EACV,eAAe,EACf,2BAA2B,EAC3B,uBAAuB,EACvB,eAAe,GAChB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAC;AAGpE,OAAO,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AACpD,YAAY,EAAE,4BAA4B,EAAE,2BAA2B,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAE7G,YAAY,EACV,yBAAyB,EACzB,qBAAqB,EACrB,YAAY,EACZ,kBAAkB,EAClB,gBAAgB,EAChB,cAAc,EACd,iBAAiB,EACjB,gBAAgB,EAChB,cAAc,EACd,eAAe,EAEf,uBAAuB,EAEvB,0BAA0B,EAC1B,wBAAwB,EACxB,2BAA2B,EAC3B,gBAAgB,EAChB,sBAAsB,EACtB,qBAAqB,EAErB,wBAAwB,EACxB,sBAAsB,EACtB,yBAAyB,EACzB,mBAAmB,EAEnB,oBAAoB,EACpB,UAAU,GACX,MAAM,SAAS,CAAC;AAGjB,OAAO,EACL,sBAAsB,EACtB,yBAAyB,EACzB,mBAAmB,EACnB,mBAAmB,EACnB,8BAA8B,EAC9B,yBAAyB,EACzB,qBAAqB,EACrB,kBAAkB,EAClB,KAAK,cAAc,IAAI,mBAAmB,GAC3C,MAAM,kBAAkB,CAAC;AAG1B,YAAY,EACV,yBAAyB,EACzB,wBAAwB,EACxB,6BAA6B,EAC7B,8BAA8B,EAC9B,6BAA6B,EAC7B,+BAA+B,EAC/B,+BAA+B,GAChC,MAAM,sBAAsB,CAAC;AAG9B,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,eAAe,EAAE,uBAAuB,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AACvF,OAAO,EACL,sBAAsB,EACtB,sBAAsB,EACtB,sBAAsB,EACtB,oCAAoC,EACpC,wCAAwC,EACxC,gCAAgC,EAChC,6BAA6B,EAC7B,KAAK,gBAAgB,GACtB,MAAM,sBAAsB,CAAC"}
|
|
@@ -5,6 +5,13 @@ import { RequestContext } from '@mastra/core/request-context';
|
|
|
5
5
|
* auth, versions, routing hints, and resource id, but they must not present as
|
|
6
6
|
* another run on the parent thread or core's cross-agent thread wait can block
|
|
7
7
|
* on the parent run that is waiting for OM to complete.
|
|
8
|
+
*
|
|
9
|
+
* A fresh RequestContext clone is always returned so that memory-scoped writes
|
|
10
|
+
* made by the internal agent run (e.g. the `MastraMemory` entry that agent.generate
|
|
11
|
+
* sets from the observer's temporary `structured-observer` memory) cannot leak back
|
|
12
|
+
* into the parent's RequestContext. Without this isolation the parent's OM turn later
|
|
13
|
+
* reads the temporary observer's resourceId and injects a continuation message that
|
|
14
|
+
* fails MessageList's resourceId validation.
|
|
8
15
|
*/
|
|
9
16
|
export declare function withOmInternalThreadId(requestContext: RequestContext | undefined, omAgentId: string): RequestContext | undefined;
|
|
10
17
|
//# sourceMappingURL=internal-request-context.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"internal-request-context.d.ts","sourceRoot":"","sources":["../../../src/processors/observational-memory/internal-request-context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAwB,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAEpF
|
|
1
|
+
{"version":3,"file":"internal-request-context.d.ts","sourceRoot":"","sources":["../../../src/processors/observational-memory/internal-request-context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAwB,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAEpF;;;;;;;;;;;;;GAaG;AACH,wBAAgB,sBAAsB,CACpC,cAAc,EAAE,cAAc,GAAG,SAAS,EAC1C,SAAS,EAAE,MAAM,GAChB,cAAc,GAAG,SAAS,CAW5B"}
|
|
@@ -53,6 +53,12 @@ export interface ObservationRunResult {
|
|
|
53
53
|
totalTokens?: number;
|
|
54
54
|
};
|
|
55
55
|
providerMetadata?: ProviderMetadata;
|
|
56
|
+
/**
|
|
57
|
+
* The failure that ended the cycle, for strategies that swallow errors
|
|
58
|
+
* instead of rethrowing (async buffering). Lets callers report the failure
|
|
59
|
+
* (e.g. to ObserveHooks) even though the fire-and-forget path never throws.
|
|
60
|
+
*/
|
|
61
|
+
error?: Error;
|
|
56
62
|
}
|
|
57
63
|
/** Processed observation ready for persistence. */
|
|
58
64
|
export interface ProcessedObservation {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/processors/observational-memory/observation-strategies/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAC1D,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AACvE,OAAO,KAAK,EAAE,gBAAgB,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AACvF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kBAAkB,CAAC,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAC5D,UAAU,CAAC,EAAE,SAAS,SAAS,CAAC,GAAG,CAAC,EAAE,CAAC;IACvC,KAAK,CAAC,EAAE;QAAE,WAAW,CAAC,EAAE,MAAM,CAAC;QAAC,YAAY,CAAC,EAAE,MAAM,CAAC;QAAC,WAAW,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IAC9E,gBAAgB,CAAC,EAAE,gBAAgB,CAAC;CACrC;AAED,sDAAsD;AACtD,MAAM,WAAW,oBAAoB;IACnC,QAAQ,EAAE,OAAO,CAAC;IAClB,KAAK,CAAC,EAAE;QAAE,WAAW,CAAC,EAAE,MAAM,CAAC;QAAC,YAAY,CAAC,EAAE,MAAM,CAAC;QAAC,WAAW,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IAC9E,gBAAgB,CAAC,EAAE,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/processors/observational-memory/observation-strategies/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAC1D,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AACvE,OAAO,KAAK,EAAE,gBAAgB,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AACvF,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AACnE,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,sBAAsB,CAAC;AACtE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAE5D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,KAAK,EAAE,uBAAuB,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAEtE,4DAA4D;AA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;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,eAAe,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC1C,kBAAkB,CAAC,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAC5D,UAAU,CAAC,EAAE,SAAS,SAAS,CAAC,GAAG,CAAC,EAAE,CAAC;CACxC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"step.d.ts","sourceRoot":"","sources":["../../../../src/processors/observational-memory/observation-turn/step.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,QAAQ,CAAC;AAC9C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAE3C;;;;;;GAMG;AACH,qBAAa,eAAe;IAKxB,OAAO,CAAC,QAAQ,CAAC,IAAI;IACrB,QAAQ,CAAC,UAAU,EAAE,MAAM;IAL7B,OAAO,CAAC,SAAS,CAAS;IAC1B,OAAO,CAAC,QAAQ,CAAC,CAAc;gBAGZ,IAAI,EAAE,eAAe,EAC7B,UAAU,EAAE,MAAM;IAG7B,2CAA2C;IAC3C,IAAI,QAAQ,YAEX;IAED;;;;;;;;OAQG;IACH,MAAM;;;;IAIN,2EAA2E;IAC3E,IAAI,OAAO,IAAI,WAAW,CAGzB;IAED;;;;;;OAMG;IACG,OAAO,IAAI,OAAO,CAAC,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"step.d.ts","sourceRoot":"","sources":["../../../../src/processors/observational-memory/observation-turn/step.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,QAAQ,CAAC;AAC9C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAE3C;;;;;;GAMG;AACH,qBAAa,eAAe;IAKxB,OAAO,CAAC,QAAQ,CAAC,IAAI;IACrB,QAAQ,CAAC,UAAU,EAAE,MAAM;IAL7B,OAAO,CAAC,SAAS,CAAS;IAC1B,OAAO,CAAC,QAAQ,CAAC,CAAc;gBAGZ,IAAI,EAAE,eAAe,EAC7B,UAAU,EAAE,MAAM;IAG7B,2CAA2C;IAC3C,IAAI,QAAQ,YAEX;IAED;;;;;;;;OAQG;IACH,MAAM;;;;IAIN,2EAA2E;IAC3E,IAAI,OAAO,IAAI,WAAW,CAGzB;IAED;;;;;;OAMG;IACG,OAAO,IAAI,OAAO,CAAC,WAAW,CAAC;IAgQrC;;;OAGG;YACW,uBAAuB;CA4GtC"}
|
|
@@ -35,7 +35,7 @@ import { ObserverRunner } from './observer-runner.js';
|
|
|
35
35
|
import type { CompressionLevel } from './reflector-agent.js';
|
|
36
36
|
import { ReflectorRunner } from './reflector-runner.js';
|
|
37
37
|
import { TokenCounter } from './token-counter.js';
|
|
38
|
-
import type { ObservationDebugEvent, ObservationalMemoryConfig, ObserveHookUsage, ObserveHooks, ResolvedObservationConfig, ResolvedReflectionConfig, ThresholdRange, ObservationModelContext } from './types.js';
|
|
38
|
+
import type { ObservationDebugEvent, ObservationalMemoryConfig, ObserveHookContext, ObserveHookUsage, ObserveHooks, ObserveTrigger, ResolvedObservationConfig, ResolvedReflectionConfig, ThresholdRange, ObservationModelContext } from './types.js';
|
|
39
39
|
/**
|
|
40
40
|
* ObservationalMemory - A three-agent memory system for long conversations.
|
|
41
41
|
*
|
|
@@ -92,6 +92,8 @@ export declare class ObservationalMemory {
|
|
|
92
92
|
resourceId: string;
|
|
93
93
|
observedAt?: Date;
|
|
94
94
|
}) => Promise<void>;
|
|
95
|
+
/** Config-level lifecycle hooks fired for every observation/reflection cycle. */
|
|
96
|
+
readonly hooks?: ObserveHooks;
|
|
95
97
|
/** Observer agent runner — handles LLM calls for extracting observations. */
|
|
96
98
|
readonly observer: ObserverRunner;
|
|
97
99
|
/** Reflector agent runner — handles LLM calls for compressing observations. */
|
|
@@ -752,6 +754,31 @@ export declare class ObservationalMemory {
|
|
|
752
754
|
record: ObservationalMemoryRecord;
|
|
753
755
|
activatedMessageIds?: string[];
|
|
754
756
|
}>;
|
|
757
|
+
/**
|
|
758
|
+
* Compose the config-level hooks with optional per-call hooks into a single
|
|
759
|
+
* `ObserveHooks` object, binding call context onto the config-level
|
|
760
|
+
* callbacks. Config-level hooks are guarded so a throwing consumer hook can
|
|
761
|
+
* never fail an observation/reflection cycle; per-call hooks keep their
|
|
762
|
+
* existing payloads and propagation semantics. Returns undefined when
|
|
763
|
+
* neither is configured, so call sites stay zero-cost.
|
|
764
|
+
*
|
|
765
|
+
* Used internally by every pipeline path (manual observe/reflect,
|
|
766
|
+
* turn-engine sync observation, async buffering); public only so the
|
|
767
|
+
* observation turn engine can thread config-level reflection hooks into
|
|
768
|
+
* reflector calls.
|
|
769
|
+
*
|
|
770
|
+
* @internal
|
|
771
|
+
*/
|
|
772
|
+
composeHooks(callHooks: ObserveHooks | undefined, context: ObserveHookContext): ObserveHooks | undefined;
|
|
773
|
+
/**
|
|
774
|
+
* Run one buffered observation cycle, firing config-level hooks around it.
|
|
775
|
+
* Shared by both async-buffer lanes — buffer() and
|
|
776
|
+
* runAsyncBufferedObservation() — whose fire-and-forget callers never see
|
|
777
|
+
* the strategy result. The async-buffer strategy swallows failures
|
|
778
|
+
* (rethrowOnFailure=false) and surfaces them on the result instead, so the
|
|
779
|
+
* end hook reports `error` for failed cycles even though nothing throws.
|
|
780
|
+
*/
|
|
781
|
+
private runBufferedObservationCycle;
|
|
755
782
|
/**
|
|
756
783
|
* Manually trigger observation.
|
|
757
784
|
*
|
|
@@ -767,6 +794,8 @@ export declare class ObservationalMemory {
|
|
|
767
794
|
resourceId?: string;
|
|
768
795
|
messages?: MastraDBMessage[];
|
|
769
796
|
hooks?: ObserveHooks;
|
|
797
|
+
/** Which pipeline path initiated this cycle; defaults to 'manual'. */
|
|
798
|
+
trigger?: ObserveTrigger;
|
|
770
799
|
agent?: ProcessorContext['agent'];
|
|
771
800
|
requestContext?: RequestContext;
|
|
772
801
|
writer?: ProcessorStreamWriter;
|