@mastra/memory 1.20.2 → 1.20.3-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 +9 -0
- package/dist/{chunk-PTCSCRB6.cjs → chunk-4TZ5SRFX.cjs} +9 -2
- package/dist/chunk-4TZ5SRFX.cjs.map +1 -0
- package/dist/{chunk-SXFOZU7K.js → chunk-YJJXL5KY.js} +9 -2
- package/dist/chunk-YJJXL5KY.js.map +1 -0
- package/dist/docs/SKILL.md +1 -1
- package/dist/docs/assets/SOURCE_MAP.json +26 -26
- package/dist/docs/references/docs-agents-agent-approval.md +2 -2
- package/dist/docs/references/docs-agents-background-tasks.md +1 -1
- package/dist/docs/references/docs-agents-supervisor-agents.md +40 -2
- package/dist/docs/references/docs-evals-evals-with-memory.md +8 -8
- package/dist/docs/references/docs-memory-observational-memory.md +1 -1
- package/dist/docs/references/docs-memory-working-memory.md +2 -2
- package/dist/docs/references/reference-storage-dsql.md +7 -7
- package/dist/docs/references/reference-storage-libsql.md +1 -1
- package/dist/docs/references/reference-storage-postgresql.md +1 -1
- package/dist/docs/references/reference-storage-redis.md +3 -3
- package/dist/index.cjs +14 -14
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +5 -5
- package/dist/index.js.map +1 -1
- package/dist/{observational-memory-SZF7GKTS.cjs → observational-memory-6SHFQDPT.cjs} +26 -26
- package/dist/{observational-memory-SZF7GKTS.cjs.map → observational-memory-6SHFQDPT.cjs.map} +1 -1
- package/dist/{observational-memory-G52HNRHE.js → observational-memory-NIGWGBLT.js} +3 -3
- package/dist/{observational-memory-G52HNRHE.js.map → observational-memory-NIGWGBLT.js.map} +1 -1
- package/dist/processors/index.cjs +24 -24
- package/dist/processors/index.js +1 -1
- package/dist/processors/observational-memory/processor.d.ts.map +1 -1
- package/package.json +9 -8
- package/dist/chunk-PTCSCRB6.cjs.map +0 -1
- package/dist/chunk-SXFOZU7K.js.map +0 -1
package/dist/docs/SKILL.md
CHANGED
|
@@ -1,119 +1,119 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "1.20.
|
|
2
|
+
"version": "1.20.3-alpha.0",
|
|
3
3
|
"package": "@mastra/memory",
|
|
4
4
|
"exports": {
|
|
5
5
|
"ModelByInputTokens": {
|
|
6
6
|
"types": "dist/processors/index.d.ts",
|
|
7
|
-
"implementation": "dist/chunk-
|
|
7
|
+
"implementation": "dist/chunk-YJJXL5KY.js",
|
|
8
8
|
"line": 787
|
|
9
9
|
},
|
|
10
10
|
"OBSERVER_SYSTEM_PROMPT": {
|
|
11
11
|
"types": "dist/processors/index.d.ts",
|
|
12
|
-
"implementation": "dist/chunk-
|
|
12
|
+
"implementation": "dist/chunk-YJJXL5KY.js"
|
|
13
13
|
},
|
|
14
14
|
"ObservationalMemory": {
|
|
15
15
|
"types": "dist/processors/index.d.ts",
|
|
16
|
-
"implementation": "dist/chunk-
|
|
16
|
+
"implementation": "dist/chunk-YJJXL5KY.js",
|
|
17
17
|
"line": 7175
|
|
18
18
|
},
|
|
19
19
|
"ObservationalMemoryProcessor": {
|
|
20
20
|
"types": "dist/processors/index.d.ts",
|
|
21
|
-
"implementation": "dist/chunk-
|
|
21
|
+
"implementation": "dist/chunk-YJJXL5KY.js",
|
|
22
22
|
"line": 9747
|
|
23
23
|
},
|
|
24
24
|
"TokenCounter": {
|
|
25
25
|
"types": "dist/processors/index.d.ts",
|
|
26
|
-
"implementation": "dist/chunk-
|
|
26
|
+
"implementation": "dist/chunk-YJJXL5KY.js",
|
|
27
27
|
"line": 6506
|
|
28
28
|
},
|
|
29
29
|
"buildObserverPrompt": {
|
|
30
30
|
"types": "dist/processors/index.d.ts",
|
|
31
|
-
"implementation": "dist/chunk-
|
|
31
|
+
"implementation": "dist/chunk-YJJXL5KY.js",
|
|
32
32
|
"line": 3774
|
|
33
33
|
},
|
|
34
34
|
"buildObserverSystemPrompt": {
|
|
35
35
|
"types": "dist/processors/index.d.ts",
|
|
36
|
-
"implementation": "dist/chunk-
|
|
36
|
+
"implementation": "dist/chunk-YJJXL5KY.js",
|
|
37
37
|
"line": 3045
|
|
38
38
|
},
|
|
39
39
|
"combineObservationGroupRanges": {
|
|
40
40
|
"types": "dist/processors/index.d.ts",
|
|
41
|
-
"implementation": "dist/chunk-
|
|
41
|
+
"implementation": "dist/chunk-YJJXL5KY.js",
|
|
42
42
|
"line": 879
|
|
43
43
|
},
|
|
44
44
|
"deriveObservationGroupProvenance": {
|
|
45
45
|
"types": "dist/processors/index.d.ts",
|
|
46
|
-
"implementation": "dist/chunk-
|
|
46
|
+
"implementation": "dist/chunk-YJJXL5KY.js",
|
|
47
47
|
"line": 913
|
|
48
48
|
},
|
|
49
49
|
"extractCurrentTask": {
|
|
50
50
|
"types": "dist/processors/index.d.ts",
|
|
51
|
-
"implementation": "dist/chunk-
|
|
51
|
+
"implementation": "dist/chunk-YJJXL5KY.js",
|
|
52
52
|
"line": 3888
|
|
53
53
|
},
|
|
54
54
|
"formatMessagesForObserver": {
|
|
55
55
|
"types": "dist/processors/index.d.ts",
|
|
56
|
-
"implementation": "dist/chunk-
|
|
56
|
+
"implementation": "dist/chunk-YJJXL5KY.js",
|
|
57
57
|
"line": 3500
|
|
58
58
|
},
|
|
59
59
|
"getObservationsAsOf": {
|
|
60
60
|
"types": "dist/processors/index.d.ts",
|
|
61
|
-
"implementation": "dist/chunk-
|
|
62
|
-
"line":
|
|
61
|
+
"implementation": "dist/chunk-YJJXL5KY.js",
|
|
62
|
+
"line": 9967
|
|
63
63
|
},
|
|
64
64
|
"hasCurrentTaskSection": {
|
|
65
65
|
"types": "dist/processors/index.d.ts",
|
|
66
|
-
"implementation": "dist/chunk-
|
|
66
|
+
"implementation": "dist/chunk-YJJXL5KY.js",
|
|
67
67
|
"line": 3876
|
|
68
68
|
},
|
|
69
69
|
"injectAnchorIds": {
|
|
70
70
|
"types": "dist/processors/index.d.ts",
|
|
71
|
-
"implementation": "dist/chunk-
|
|
71
|
+
"implementation": "dist/chunk-YJJXL5KY.js",
|
|
72
72
|
"line": 2593
|
|
73
73
|
},
|
|
74
74
|
"optimizeObservationsForContext": {
|
|
75
75
|
"types": "dist/processors/index.d.ts",
|
|
76
|
-
"implementation": "dist/chunk-
|
|
76
|
+
"implementation": "dist/chunk-YJJXL5KY.js",
|
|
77
77
|
"line": 3899
|
|
78
78
|
},
|
|
79
79
|
"parseAnchorId": {
|
|
80
80
|
"types": "dist/processors/index.d.ts",
|
|
81
|
-
"implementation": "dist/chunk-
|
|
81
|
+
"implementation": "dist/chunk-YJJXL5KY.js",
|
|
82
82
|
"line": 2566
|
|
83
83
|
},
|
|
84
84
|
"parseObservationGroups": {
|
|
85
85
|
"types": "dist/processors/index.d.ts",
|
|
86
|
-
"implementation": "dist/chunk-
|
|
86
|
+
"implementation": "dist/chunk-YJJXL5KY.js",
|
|
87
87
|
"line": 848
|
|
88
88
|
},
|
|
89
89
|
"parseObserverOutput": {
|
|
90
90
|
"types": "dist/processors/index.d.ts",
|
|
91
|
-
"implementation": "dist/chunk-
|
|
91
|
+
"implementation": "dist/chunk-YJJXL5KY.js",
|
|
92
92
|
"line": 3784
|
|
93
93
|
},
|
|
94
94
|
"reconcileObservationGroupsFromReflection": {
|
|
95
95
|
"types": "dist/processors/index.d.ts",
|
|
96
|
-
"implementation": "dist/chunk-
|
|
96
|
+
"implementation": "dist/chunk-YJJXL5KY.js",
|
|
97
97
|
"line": 937
|
|
98
98
|
},
|
|
99
99
|
"renderObservationGroupsForReflection": {
|
|
100
100
|
"types": "dist/processors/index.d.ts",
|
|
101
|
-
"implementation": "dist/chunk-
|
|
101
|
+
"implementation": "dist/chunk-YJJXL5KY.js",
|
|
102
102
|
"line": 893
|
|
103
103
|
},
|
|
104
104
|
"stripEphemeralAnchorIds": {
|
|
105
105
|
"types": "dist/processors/index.d.ts",
|
|
106
|
-
"implementation": "dist/chunk-
|
|
106
|
+
"implementation": "dist/chunk-YJJXL5KY.js",
|
|
107
107
|
"line": 2623
|
|
108
108
|
},
|
|
109
109
|
"stripObservationGroups": {
|
|
110
110
|
"types": "dist/processors/index.d.ts",
|
|
111
|
-
"implementation": "dist/chunk-
|
|
111
|
+
"implementation": "dist/chunk-YJJXL5KY.js",
|
|
112
112
|
"line": 870
|
|
113
113
|
},
|
|
114
114
|
"wrapInObservationGroup": {
|
|
115
115
|
"types": "dist/processors/index.d.ts",
|
|
116
|
-
"implementation": "dist/chunk-
|
|
116
|
+
"implementation": "dist/chunk-YJJXL5KY.js",
|
|
117
117
|
"line": 841
|
|
118
118
|
},
|
|
119
119
|
"OBSERVATIONAL_MEMORY_DEFAULTS": {
|
|
@@ -162,7 +162,7 @@
|
|
|
162
162
|
"processors": {
|
|
163
163
|
"index": "dist/processors/index.js",
|
|
164
164
|
"chunks": [
|
|
165
|
-
"chunk-
|
|
165
|
+
"chunk-YJJXL5KY.js",
|
|
166
166
|
"chunk-LSJJAJAF.js"
|
|
167
167
|
]
|
|
168
168
|
}
|
|
@@ -96,7 +96,7 @@ const stream = await agent.stream('Clean up old records', {
|
|
|
96
96
|
})
|
|
97
97
|
```
|
|
98
98
|
|
|
99
|
-
A tool's own `requireApproval` setting still takes precedence: if a tool defines its own approval rule, that rule decides for that tool and the function above
|
|
99
|
+
A tool's own `requireApproval` setting still takes precedence: if a tool defines its own approval rule, that rule decides for that tool and the function above doesn't override it. If the function throws, the call requires approval (fail-safe).
|
|
100
100
|
|
|
101
101
|
> **Note:** Function-based `requireToolApproval` is only available on regular `stream()` / `generate()` calls. Durable agents and stored agents persist their options, and a function can't be serialized, so they accept only a boolean. If you pass a function in those contexts it falls back to requiring approval for every tool call.
|
|
102
102
|
|
|
@@ -106,7 +106,7 @@ A tool can also pause _during_ its `execute` function by calling `suspend()`. Th
|
|
|
106
106
|
|
|
107
107
|
The stream emits a `tool-call-suspended` chunk with a custom payload defined by the tool's `suspendSchema`. You resume by calling `resumeStream()` with data matching the tool's `resumeSchema`.
|
|
108
108
|
|
|
109
|
-
> **Note:** `suspend()`
|
|
109
|
+
> **Note:** `suspend()` doesn't throw — return immediately after calling it (e.g. `return await suspend({ ... })`). Code after `await suspend(...)` still runs before the tool pauses.
|
|
110
110
|
|
|
111
111
|
## Tool approval with `generate()`
|
|
112
112
|
|
|
@@ -104,7 +104,7 @@ When a tool is registered on an agent that has background tasks enabled, the mod
|
|
|
104
104
|
}
|
|
105
105
|
```
|
|
106
106
|
|
|
107
|
-
The `_background` override is a _modifier_ on tools the developer has already opted in at the tool or agent layer — it
|
|
107
|
+
The `_background` override is a _modifier_ on tools the developer has already opted in at the tool or agent layer — it's not a standalone opt-in. If a tool hasn't been opted in, `_background.enabled: true` from the model is ignored and the tool runs in the foreground. This keeps deterministic, foreground-only tools (calculators, lookups, schema validators) from being silently dispatched as tasks.
|
|
108
108
|
|
|
109
109
|
### Resolution order
|
|
110
110
|
|
|
@@ -169,7 +169,7 @@ The callback receives `messages` (the full conversation history), `primitiveId`
|
|
|
169
169
|
|
|
170
170
|
## Subagent result context
|
|
171
171
|
|
|
172
|
-
When a subagent completes, the supervisor model receives the subagent's text response in later iterations. Nested tool calls and subagent metadata, such as thread and resource IDs,
|
|
172
|
+
When a subagent completes, the supervisor model receives the subagent's text response in later iterations. Nested tool calls and subagent metadata, such as thread and resource IDs, aren't added to the supervisor model context.
|
|
173
173
|
|
|
174
174
|
Application code and UI integrations can still inspect the raw delegation result, including `subAgentToolResults`, from the tool result payload. This keeps debugging and display data available without sending nested tool arguments or outputs back into the supervisor's next model call.
|
|
175
175
|
|
|
@@ -263,7 +263,7 @@ for await (const chunk of stream.fullStream) {
|
|
|
263
263
|
|
|
264
264
|
## Task completion scoring
|
|
265
265
|
|
|
266
|
-
Task completion scorers
|
|
266
|
+
Agents don't always produce a complete, correct output on the first try. Task completion scorers can help with that by validating whether the task is complete after each iteration. If validation fails, the supervisor continues iterating. Feedback from failed scorers is included in the conversation context so subagents can see what was missing.
|
|
267
267
|
|
|
268
268
|
```typescript
|
|
269
269
|
import { createScorer } from '@mastra/core/evals'
|
|
@@ -290,6 +290,44 @@ const stream = await supervisor.stream('Research AI in education', {
|
|
|
290
290
|
})
|
|
291
291
|
```
|
|
292
292
|
|
|
293
|
+
### Rubric scorer
|
|
294
|
+
|
|
295
|
+
The built-in rubric scorer lets you define what "correct" looks like as a checklist and have the agent self-evaluate and iterate until every criterion is satisfied or `maxSteps` is reached.
|
|
296
|
+
|
|
297
|
+
It works as an **LLM-as-judge** scorer: a separate grader model reviews the agent's output against the rubric after each iteration. If every required criterion passes, the loop ends. If anything falls short, per-criterion feedback is injected back into the conversation and the agent tries again.
|
|
298
|
+
|
|
299
|
+
This is most effective for tasks with clear, verifiable success criteria. You can use it like so:
|
|
300
|
+
|
|
301
|
+
```typescript
|
|
302
|
+
import { Agent } from '@mastra/core/agent'
|
|
303
|
+
import { createRubricScorer } from '@mastra/evals/scorers/prebuilt'
|
|
304
|
+
|
|
305
|
+
const supervisor = new Agent({
|
|
306
|
+
id: 'supervisor',
|
|
307
|
+
instructions: 'You coordinate research and writing using specialized agents.',
|
|
308
|
+
model: 'openai/gpt-5.5',
|
|
309
|
+
agents: { researchAgent, writingAgent },
|
|
310
|
+
})
|
|
311
|
+
|
|
312
|
+
const rubricScorer = createRubricScorer({
|
|
313
|
+
model: 'openai/gpt-5-mini',
|
|
314
|
+
criteria: [
|
|
315
|
+
{ description: 'The response includes an analysis section' },
|
|
316
|
+
{ description: 'The response includes concrete recommendations' },
|
|
317
|
+
],
|
|
318
|
+
})
|
|
319
|
+
|
|
320
|
+
const stream = await supervisor.stream('Research AI in education', {
|
|
321
|
+
maxSteps: 10,
|
|
322
|
+
isTaskComplete: {
|
|
323
|
+
scorers: [rubricScorer],
|
|
324
|
+
strategy: 'all',
|
|
325
|
+
},
|
|
326
|
+
})
|
|
327
|
+
```
|
|
328
|
+
|
|
329
|
+
For full API details, see the [rubric scorer reference](https://mastra.ai/reference/evals/rubric).
|
|
330
|
+
|
|
293
331
|
## Writing effective instructions
|
|
294
332
|
|
|
295
333
|
Clear instructions are essential for effective delegation. Your supervisor's `instructions` should specify available resources, when to use each one, how to coordinate them, and success criteria.
|
|
@@ -10,13 +10,13 @@ This page covers the three working patterns for running Mastra evals against mem
|
|
|
10
10
|
|
|
11
11
|
## When to use which approach
|
|
12
12
|
|
|
13
|
-
| Goal
|
|
14
|
-
|
|
|
15
|
-
| One shared conversation across every item
|
|
16
|
-
| One independent thread per item,
|
|
17
|
-
| Per-item threads driven by a stored `Dataset`
|
|
13
|
+
| Goal | Approach |
|
|
14
|
+
| ------------------------------------------------ | ----------------------------------------------------------------------------------------- |
|
|
15
|
+
| One shared conversation across every item | [`runEvals` with global `targetOptions.memory`](#shared-thread-with-runevals) |
|
|
16
|
+
| One independent thread per item, focused CI loop | [`runEvals` per item](#per-item-threads-with-runevals) |
|
|
17
|
+
| Per-item threads driven by a stored `Dataset` | [`dataset.startExperiment` with an inline task](#dataset-experiments-with-an-inline-task) |
|
|
18
18
|
|
|
19
|
-
Pre-seeding `RequestContext` with `MastraMemory`
|
|
19
|
+
Pre-seeding `RequestContext` with `MastraMemory` **isn't** a supported way to drive memory into an agent. Thread resolution reads `args.memory.thread` — `RequestContext.MastraMemory` is populated by `prepare-memory-step` after the agent has already resolved its thread.
|
|
20
20
|
|
|
21
21
|
## Shared thread with `runEvals`
|
|
22
22
|
|
|
@@ -43,7 +43,7 @@ const result = await runEvals({
|
|
|
43
43
|
})
|
|
44
44
|
```
|
|
45
45
|
|
|
46
|
-
`targetOptions` is **global per call**.
|
|
46
|
+
`targetOptions` is **global per call**. No per-item override on `RunEvalsDataItem` is available today.
|
|
47
47
|
|
|
48
48
|
## Per-item threads with `runEvals`
|
|
49
49
|
|
|
@@ -86,7 +86,7 @@ const average = scores.reduce((a, b) => a + b, 0) / scores.length
|
|
|
86
86
|
|
|
87
87
|
## Dataset experiments with an inline task
|
|
88
88
|
|
|
89
|
-
`dataset.startExperiment({ target: agent })`
|
|
89
|
+
`dataset.startExperiment({ target: agent })` **doesn't** forward a `memory` option to the agent — only `requestContext`. To run a stored dataset against a memory-enabled agent, use an inline `task` function and stash `{ threadId, resourceId }` in each item's `metadata`. The scorer pipeline still runs as normal.
|
|
90
90
|
|
|
91
91
|
```typescript
|
|
92
92
|
import { randomUUID } from 'node:crypto'
|
|
@@ -134,7 +134,7 @@ const memory = new Memory({
|
|
|
134
134
|
})
|
|
135
135
|
```
|
|
136
136
|
|
|
137
|
-
`bufferOnIdle` is off by default. It
|
|
137
|
+
`bufferOnIdle` is off by default. It's separate from `bufferTokens`: `bufferTokens` controls step-time async buffering, while `bufferOnIdle` controls end-of-turn buffering for idle turns.
|
|
138
138
|
|
|
139
139
|
See [the API reference](https://mastra.ai/reference/memory/observational-memory) for the full configuration shape.
|
|
140
140
|
|
|
@@ -413,12 +413,12 @@ const memory = new Memory({
|
|
|
413
413
|
What changes:
|
|
414
414
|
|
|
415
415
|
- **Storage is identical.** The same resource/thread `workingMemory` field is read and written.
|
|
416
|
-
- **The tool is the same shape, exposed under a new name.** Writes still flow through the same underlying tool; on this path it
|
|
416
|
+
- **The tool is the same shape, exposed under a new name.** Writes still flow through the same underlying tool; on this path it's registered as `setWorkingMemory` (instead of `updateWorkingMemory`). The rename keeps legacy strip filters from removing tool-call parts so they persist as a normal audit trail and the next model step picks the new value up automatically.
|
|
417
417
|
- **Delivery only.** Instead of folding into the system prompt, `Memory` auto-attaches a `WorkingMemoryStateProcessor` that emits the current working memory as a `state` signal with `stateId: 'working-memory'`.
|
|
418
418
|
|
|
419
419
|
You inherit the standard state-signal benefits: thread-scoped tracking metadata, `cacheKey` dedup so identical snapshots are only emitted once, and `contextWindow.hasSnapshot` re-injection when an older snapshot rolls out of the window.
|
|
420
420
|
|
|
421
|
-
The default (`useStateSignals: false`) keeps the existing system-message behavior unchanged. `useStateSignals`
|
|
421
|
+
The default (`useStateSignals: false`) keeps the existing system-message behavior unchanged. `useStateSignals` isn't supported with template working memory `version: 'vnext'`.
|
|
422
422
|
|
|
423
423
|
## Examples
|
|
424
424
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
The Aurora DSQL storage implementation provides storage using Amazon Aurora DSQL with IAM authentication.
|
|
4
4
|
|
|
5
|
-
Aurora DSQL
|
|
5
|
+
Aurora DSQL doesn't support PostgreSQL extensions (`CREATE EXTENSION`), including `pgvector`. For vector storage, use a separate vector store such as `@mastra/s3vectors`.
|
|
6
6
|
|
|
7
7
|
## Installation
|
|
8
8
|
|
|
@@ -170,7 +170,7 @@ const memoryStore = await storage.getStore('memory')
|
|
|
170
170
|
const thread = await memoryStore?.getThreadById({ threadId: '...' })
|
|
171
171
|
```
|
|
172
172
|
|
|
173
|
-
> **Warning:** If `init()`
|
|
173
|
+
> **Warning:** If `init()` isn't called, tables won't be created and storage operations will fail silently or throw errors.
|
|
174
174
|
|
|
175
175
|
### Direct Database and Pool Access
|
|
176
176
|
|
|
@@ -193,7 +193,7 @@ This approach is intended for advanced scenarios where low-level access is requi
|
|
|
193
193
|
|
|
194
194
|
#### IAM-only authentication
|
|
195
195
|
|
|
196
|
-
Connections are authenticated with IAM.
|
|
196
|
+
Connections are authenticated with IAM. No database passwords are required. `@mastra/dsql` uses `@aws/aurora-dsql-node-postgres-connector` to generate short-lived auth tokens. You can provide a custom credentials provider via `customCredentialsProvider`.
|
|
197
197
|
|
|
198
198
|
#### Single database, schema-based isolation
|
|
199
199
|
|
|
@@ -201,7 +201,7 @@ Each cluster exposes a single database named `postgres`. Logical separation is d
|
|
|
201
201
|
|
|
202
202
|
#### No PostgreSQL extensions
|
|
203
203
|
|
|
204
|
-
`CREATE EXTENSION`
|
|
204
|
+
`CREATE EXTENSION` isn't supported. This includes `pgvector`, `PostGIS`, and others. For vector storage, use a separate store such as `@mastra/s3vectors` alongside `DSQLStore`.
|
|
205
205
|
|
|
206
206
|
#### JSON stored as text
|
|
207
207
|
|
|
@@ -209,7 +209,7 @@ JSON/JSONB are available as query types but not as column types. `@mastra/dsql`
|
|
|
209
209
|
|
|
210
210
|
#### Schema and DDL constraints
|
|
211
211
|
|
|
212
|
-
Some PostgreSQL features
|
|
212
|
+
Some PostgreSQL features aren't available:
|
|
213
213
|
|
|
214
214
|
- Foreign key constraints
|
|
215
215
|
- `TRUNCATE`
|
|
@@ -219,7 +219,7 @@ Indexes are created asynchronously using `CREATE INDEX ASYNC`. The store's `init
|
|
|
219
219
|
|
|
220
220
|
#### Transactions and optimistic concurrency
|
|
221
221
|
|
|
222
|
-
Aurora DSQL uses optimistic concurrency control (OCC) and may return retriable OCC errors under contention.
|
|
222
|
+
Aurora DSQL uses optimistic concurrency control (OCC) and may return retriable OCC errors under contention. Limits exist on transaction duration and size. Large bulk operations should be split into smaller batches at the application level.
|
|
223
223
|
|
|
224
224
|
#### Connection lifetime
|
|
225
225
|
|
|
@@ -332,7 +332,7 @@ await storage.createIndex({
|
|
|
332
332
|
})
|
|
333
333
|
```
|
|
334
334
|
|
|
335
|
-
Aurora DSQL
|
|
335
|
+
Aurora DSQL doesn't allow `ASC`/`DESC` in `CREATE INDEX ASYNC`. If you include them, they will be automatically stripped.
|
|
336
336
|
|
|
337
337
|
### Index Options
|
|
338
338
|
|
|
@@ -136,6 +136,6 @@ const thread = await memoryStore?.getThreadById({ threadId: '...' })
|
|
|
136
136
|
|
|
137
137
|
## Observability
|
|
138
138
|
|
|
139
|
-
libSQL supports observability and is ideal for local development. Use the `realtime` [tracing strategy](https://mastra.ai/docs/observability/
|
|
139
|
+
libSQL supports observability and is ideal for local development. Use the `realtime` [tracing strategy](https://mastra.ai/docs/observability/integrations/exporters/mastra-storage) for immediate visibility while debugging.
|
|
140
140
|
|
|
141
141
|
For production environments with higher trace volumes, consider using [PostgreSQL](https://mastra.ai/reference/storage/postgresql) or [ClickHouse via composite storage](https://mastra.ai/reference/storage/composite).
|
|
@@ -140,7 +140,7 @@ The storage implementation handles schema creation and updates automatically. It
|
|
|
140
140
|
|
|
141
141
|
PostgreSQL supports observability and can handle low trace volumes. Throughput capacity depends on deployment factors such as hardware, schema design, indexing, and retention policies, and should be validated for your specific environment. For high-volume production environments, consider:
|
|
142
142
|
|
|
143
|
-
- Using the `insert-only` [tracing strategy](https://mastra.ai/docs/observability/
|
|
143
|
+
- Using the `insert-only` [tracing strategy](https://mastra.ai/docs/observability/integrations/exporters/mastra-storage) to reduce database write operations
|
|
144
144
|
- Setting up table partitioning for efficient data retention
|
|
145
145
|
- Migrating observability to [ClickHouse via composite storage](https://mastra.ai/reference/storage/composite) if you need to scale further
|
|
146
146
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Redis Storage
|
|
2
2
|
|
|
3
|
-
The Redis storage implementation provides a high-performance storage solution using direct Redis connections via [node-redis](https://github.com/redis/node-redis) (the official Redis client for Node.js). It supports standalone Redis, and through custom client configuration, Redis Sentinel and Cluster deployments.
|
|
3
|
+
The Redis storage implementation provides a high-performance storage solution using direct Redis connections via [`node-redis`](https://github.com/redis/node-redis) (the official Redis client for Node.js). It supports standalone Redis, and through custom client configuration, Redis Sentinel and Cluster deployments.
|
|
4
4
|
|
|
5
5
|
## Installation
|
|
6
6
|
|
|
@@ -41,7 +41,7 @@ await storage.init()
|
|
|
41
41
|
|
|
42
42
|
### Using Pre-configured Client
|
|
43
43
|
|
|
44
|
-
For advanced configurations like Sentinel or Cluster, you can pass a pre-configured
|
|
44
|
+
For advanced configurations like Sentinel or Cluster, you can pass a pre-configured Redis client:
|
|
45
45
|
|
|
46
46
|
```typescript
|
|
47
47
|
import { RedisStore } from '@mastra/redis'
|
|
@@ -142,7 +142,7 @@ const storage = new RedisStore({
|
|
|
142
142
|
|
|
143
143
|
### Accessing the Underlying Client
|
|
144
144
|
|
|
145
|
-
You can access the underlying
|
|
145
|
+
You can access the underlying Redis client for custom operations:
|
|
146
146
|
|
|
147
147
|
```typescript
|
|
148
148
|
const storage = new RedisStore({
|
package/dist/index.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunk4TZ5SRFX_cjs = require('./chunk-4TZ5SRFX.cjs');
|
|
4
4
|
var chunk43FJOLKM_cjs = require('./chunk-43FJOLKM.cjs');
|
|
5
5
|
var chunkQ7SFCCGT_cjs = require('./chunk-Q7SFCCGT.cjs');
|
|
6
6
|
var agent = require('@mastra/core/agent');
|
|
@@ -22918,7 +22918,7 @@ var ZodFirstPartyTypeKind3;
|
|
|
22918
22918
|
ZodFirstPartyTypeKind4["ZodReadonly"] = "ZodReadonly";
|
|
22919
22919
|
})(ZodFirstPartyTypeKind3 || (ZodFirstPartyTypeKind3 = {}));
|
|
22920
22920
|
|
|
22921
|
-
// ../_vendored/ai_v5/dist/chunk-
|
|
22921
|
+
// ../_vendored/ai_v5/dist/chunk-LPCSE373.js
|
|
22922
22922
|
var marker17 = "vercel.ai.error";
|
|
22923
22923
|
var symbol18 = Symbol.for(marker17);
|
|
22924
22924
|
var _a19;
|
|
@@ -46034,7 +46034,7 @@ function formatTimestamp(date9) {
|
|
|
46034
46034
|
}
|
|
46035
46035
|
function truncateByTokens(text4, maxTokens, hint) {
|
|
46036
46036
|
if (tokenx.estimateTokenCount(text4) <= maxTokens) return { text: text4, wasTruncated: false };
|
|
46037
|
-
const truncated =
|
|
46037
|
+
const truncated = chunk4TZ5SRFX_cjs.truncateStringByTokens(text4, maxTokens);
|
|
46038
46038
|
const suffix = hint ? ` [${hint} for more]` : "";
|
|
46039
46039
|
return { text: truncated + suffix, wasTruncated: true };
|
|
46040
46040
|
}
|
|
@@ -46086,11 +46086,11 @@ ${JSON.stringify(inv.args, null, 2)}`;
|
|
|
46086
46086
|
});
|
|
46087
46087
|
}
|
|
46088
46088
|
if (inv.state === "result") {
|
|
46089
|
-
const { value: resultValue } =
|
|
46089
|
+
const { value: resultValue } = chunk4TZ5SRFX_cjs.resolveToolResultValue(
|
|
46090
46090
|
part,
|
|
46091
46091
|
inv.result
|
|
46092
46092
|
);
|
|
46093
|
-
const resultStr =
|
|
46093
|
+
const resultStr = chunk4TZ5SRFX_cjs.formatToolResultForObserver(resultValue, { maxTokens: HIGH_DETAIL_TOOL_RESULT_TOKENS });
|
|
46094
46094
|
const fullText = `[Tool Result: ${inv.toolName}]
|
|
46095
46095
|
${resultStr}`;
|
|
46096
46096
|
parts.push(makePart(msg, i, "tool-result", fullText, detail, inv.toolName));
|
|
@@ -46117,7 +46117,7 @@ ${typeof rawArgs === "string" ? rawArgs : JSON.stringify(rawArgs, null, 2)}`;
|
|
|
46117
46117
|
const toolName = part.toolName;
|
|
46118
46118
|
if (toolName) {
|
|
46119
46119
|
const rawResult = part.output ?? part.result;
|
|
46120
|
-
const resultStr =
|
|
46120
|
+
const resultStr = chunk4TZ5SRFX_cjs.formatToolResultForObserver(rawResult, { maxTokens: HIGH_DETAIL_TOOL_RESULT_TOKENS });
|
|
46121
46121
|
const fullText = `[Tool Result: ${toolName}]
|
|
46122
46122
|
${resultStr}`;
|
|
46123
46123
|
parts.push(makePart(msg, i, "tool-result", fullText, detail, toolName));
|
|
@@ -46196,7 +46196,7 @@ function renderFormattedParts(parts, timestamps, options) {
|
|
|
46196
46196
|
const text4 = buildRenderedText(parts, timestamps);
|
|
46197
46197
|
let totalTokens = tokenx.estimateTokenCount(text4);
|
|
46198
46198
|
if (totalTokens > options.maxTokens) {
|
|
46199
|
-
const truncated =
|
|
46199
|
+
const truncated = chunk4TZ5SRFX_cjs.truncateStringByTokens(text4, options.maxTokens);
|
|
46200
46200
|
return { text: truncated, truncated: true, tokenOffset: totalTokens - options.maxTokens };
|
|
46201
46201
|
}
|
|
46202
46202
|
const truncatedIndices = parts.map((p, i) => ({ part: p, index: i })).filter(({ part }) => part.text !== part.fullText).sort((a, b) => expandPriority(a.part) - expandPriority(b.part));
|
|
@@ -46229,7 +46229,7 @@ function renderFormattedParts(parts, timestamps, options) {
|
|
|
46229
46229
|
if (expandedTokens <= options.maxTokens) {
|
|
46230
46230
|
return { text: expanded, truncated: false, tokenOffset: 0 };
|
|
46231
46231
|
}
|
|
46232
|
-
const hardTruncated =
|
|
46232
|
+
const hardTruncated = chunk4TZ5SRFX_cjs.truncateStringByTokens(expanded, options.maxTokens);
|
|
46233
46233
|
return { text: hardTruncated, truncated: true, tokenOffset: expandedTokens - options.maxTokens };
|
|
46234
46234
|
}
|
|
46235
46235
|
async function recallPart({
|
|
@@ -46280,7 +46280,7 @@ async function recallPart({
|
|
|
46280
46280
|
|
|
46281
46281
|
`;
|
|
46282
46282
|
const fallbackText = `${fallbackNote}${firstNextPart.text}`;
|
|
46283
|
-
const truncatedText2 =
|
|
46283
|
+
const truncatedText2 = chunk4TZ5SRFX_cjs.truncateStringByTokens(fallbackText, maxTokens);
|
|
46284
46284
|
const wasTruncated2 = truncatedText2 !== fallbackText;
|
|
46285
46285
|
return {
|
|
46286
46286
|
text: truncatedText2,
|
|
@@ -46295,7 +46295,7 @@ async function recallPart({
|
|
|
46295
46295
|
}
|
|
46296
46296
|
throw new Error(`Part index ${partIndex} not found in message ${cursor}. Available indices: ${availableIndices}`);
|
|
46297
46297
|
}
|
|
46298
|
-
const truncatedText =
|
|
46298
|
+
const truncatedText = chunk4TZ5SRFX_cjs.truncateStringByTokens(target.text, maxTokens);
|
|
46299
46299
|
const wasTruncated = truncatedText !== target.text;
|
|
46300
46300
|
return {
|
|
46301
46301
|
text: truncatedText,
|
|
@@ -48116,7 +48116,7 @@ ${workingMemory}`;
|
|
|
48116
48116
|
"Observational memory requires @mastra/core support for request-response-id-rotation. Please bump @mastra/core to a newer version."
|
|
48117
48117
|
);
|
|
48118
48118
|
}
|
|
48119
|
-
const { ObservationalMemory: OMClass } = await import('./observational-memory-
|
|
48119
|
+
const { ObservationalMemory: OMClass } = await import('./observational-memory-6SHFQDPT.cjs');
|
|
48120
48120
|
const onIndexObservations = this.hasRetrievalSearch(omConfig.retrieval) ? async (observation) => {
|
|
48121
48121
|
await this.indexObservation(observation);
|
|
48122
48122
|
} : void 0;
|
|
@@ -49068,7 +49068,7 @@ Notes:
|
|
|
49068
49068
|
if (!effectiveConfig) return null;
|
|
49069
49069
|
const engine = await this.omEngine;
|
|
49070
49070
|
if (!engine) return null;
|
|
49071
|
-
const { ObservationalMemoryProcessor } = await import('./observational-memory-
|
|
49071
|
+
const { ObservationalMemoryProcessor } = await import('./observational-memory-6SHFQDPT.cjs');
|
|
49072
49072
|
return new ObservationalMemoryProcessor(engine, this, {
|
|
49073
49073
|
temporalMarkers: effectiveConfig.temporalMarkers
|
|
49074
49074
|
});
|
|
@@ -49095,11 +49095,11 @@ Notes:
|
|
|
49095
49095
|
|
|
49096
49096
|
Object.defineProperty(exports, "ModelByInputTokens", {
|
|
49097
49097
|
enumerable: true,
|
|
49098
|
-
get: function () { return
|
|
49098
|
+
get: function () { return chunk4TZ5SRFX_cjs.ModelByInputTokens; }
|
|
49099
49099
|
});
|
|
49100
49100
|
Object.defineProperty(exports, "getObservationsAsOf", {
|
|
49101
49101
|
enumerable: true,
|
|
49102
|
-
get: function () { return
|
|
49102
|
+
get: function () { return chunk4TZ5SRFX_cjs.getObservationsAsOf; }
|
|
49103
49103
|
});
|
|
49104
49104
|
Object.defineProperty(exports, "WORKING_MEMORY_STATE_ID", {
|
|
49105
49105
|
enumerable: true,
|