@mastra/memory 1.9.1-alpha.1 → 1.10.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 +77 -0
- package/dist/{chunk-T5FHEWK6.js → chunk-7A3UGAXY.js} +338 -116
- package/dist/chunk-7A3UGAXY.js.map +1 -0
- package/dist/{chunk-CNOHXG5O.cjs → chunk-EVBFYGDL.cjs} +338 -115
- package/dist/chunk-EVBFYGDL.cjs.map +1 -0
- package/dist/docs/SKILL.md +1 -1
- package/dist/docs/assets/SOURCE_MAP.json +52 -47
- package/dist/docs/references/docs-memory-observational-memory.md +36 -0
- package/dist/docs/references/reference-memory-observational-memory.md +42 -3
- package/dist/index.cjs +17 -10
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +20 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -4
- package/dist/index.js.map +1 -1
- package/dist/{observational-memory-APEZUJUQ.cjs → observational-memory-COYJCVX3.cjs} +32 -28
- package/dist/{observational-memory-APEZUJUQ.cjs.map → observational-memory-COYJCVX3.cjs.map} +1 -1
- package/dist/observational-memory-K2U3QQIO.js +3 -0
- package/dist/{observational-memory-OZ7TG4DZ.js.map → observational-memory-K2U3QQIO.js.map} +1 -1
- package/dist/processors/index.cjs +30 -26
- package/dist/processors/index.js +1 -1
- package/dist/processors/observational-memory/index.d.ts +1 -0
- package/dist/processors/observational-memory/index.d.ts.map +1 -1
- package/dist/processors/observational-memory/model-by-input-tokens.d.ts +14 -0
- package/dist/processors/observational-memory/model-by-input-tokens.d.ts.map +1 -0
- package/dist/processors/observational-memory/observational-memory.d.ts +19 -5
- package/dist/processors/observational-memory/observational-memory.d.ts.map +1 -1
- package/dist/processors/observational-memory/types.d.ts +4 -2
- package/dist/processors/observational-memory/types.d.ts.map +1 -1
- package/package.json +8 -8
- package/dist/chunk-CNOHXG5O.cjs.map +0 -1
- package/dist/chunk-T5FHEWK6.js.map +0 -1
- package/dist/observational-memory-OZ7TG4DZ.js +0 -3
package/dist/docs/SKILL.md
CHANGED
|
@@ -1,126 +1,131 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "1.
|
|
2
|
+
"version": "1.10.0",
|
|
3
3
|
"package": "@mastra/memory",
|
|
4
4
|
"exports": {
|
|
5
|
+
"ModelByInputTokens": {
|
|
6
|
+
"types": "dist/processors/index.d.ts",
|
|
7
|
+
"implementation": "dist/chunk-7A3UGAXY.js",
|
|
8
|
+
"line": 343
|
|
9
|
+
},
|
|
5
10
|
"OBSERVATIONAL_MEMORY_DEFAULTS": {
|
|
6
11
|
"types": "dist/processors/index.d.ts",
|
|
7
|
-
"implementation": "dist/chunk-
|
|
12
|
+
"implementation": "dist/chunk-7A3UGAXY.js"
|
|
8
13
|
},
|
|
9
14
|
"OBSERVATION_CONTEXT_INSTRUCTIONS": {
|
|
10
15
|
"types": "dist/processors/index.d.ts",
|
|
11
|
-
"implementation": "dist/chunk-
|
|
16
|
+
"implementation": "dist/chunk-7A3UGAXY.js"
|
|
12
17
|
},
|
|
13
18
|
"OBSERVATION_CONTEXT_PROMPT": {
|
|
14
19
|
"types": "dist/processors/index.d.ts",
|
|
15
|
-
"implementation": "dist/chunk-
|
|
20
|
+
"implementation": "dist/chunk-7A3UGAXY.js"
|
|
16
21
|
},
|
|
17
22
|
"OBSERVATION_CONTINUATION_HINT": {
|
|
18
23
|
"types": "dist/processors/index.d.ts",
|
|
19
|
-
"implementation": "dist/chunk-
|
|
24
|
+
"implementation": "dist/chunk-7A3UGAXY.js"
|
|
20
25
|
},
|
|
21
26
|
"OBSERVER_SYSTEM_PROMPT": {
|
|
22
27
|
"types": "dist/processors/index.d.ts",
|
|
23
|
-
"implementation": "dist/chunk-
|
|
28
|
+
"implementation": "dist/chunk-7A3UGAXY.js"
|
|
24
29
|
},
|
|
25
30
|
"ObservationalMemory": {
|
|
26
31
|
"types": "dist/processors/index.d.ts",
|
|
27
|
-
"implementation": "dist/chunk-
|
|
28
|
-
"line":
|
|
32
|
+
"implementation": "dist/chunk-7A3UGAXY.js",
|
|
33
|
+
"line": 3505
|
|
29
34
|
},
|
|
30
35
|
"TokenCounter": {
|
|
31
36
|
"types": "dist/processors/index.d.ts",
|
|
32
|
-
"implementation": "dist/chunk-
|
|
33
|
-
"line":
|
|
37
|
+
"implementation": "dist/chunk-7A3UGAXY.js",
|
|
38
|
+
"line": 2936
|
|
34
39
|
},
|
|
35
40
|
"buildObserverPrompt": {
|
|
36
41
|
"types": "dist/processors/index.d.ts",
|
|
37
|
-
"implementation": "dist/chunk-
|
|
38
|
-
"line":
|
|
42
|
+
"implementation": "dist/chunk-7A3UGAXY.js",
|
|
43
|
+
"line": 1519
|
|
39
44
|
},
|
|
40
45
|
"buildObserverSystemPrompt": {
|
|
41
46
|
"types": "dist/processors/index.d.ts",
|
|
42
|
-
"implementation": "dist/chunk-
|
|
43
|
-
"line":
|
|
47
|
+
"implementation": "dist/chunk-7A3UGAXY.js",
|
|
48
|
+
"line": 986
|
|
44
49
|
},
|
|
45
50
|
"combineObservationGroupRanges": {
|
|
46
51
|
"types": "dist/processors/index.d.ts",
|
|
47
|
-
"implementation": "dist/chunk-
|
|
48
|
-
"line":
|
|
52
|
+
"implementation": "dist/chunk-7A3UGAXY.js",
|
|
53
|
+
"line": 432
|
|
49
54
|
},
|
|
50
55
|
"deriveObservationGroupProvenance": {
|
|
51
56
|
"types": "dist/processors/index.d.ts",
|
|
52
|
-
"implementation": "dist/chunk-
|
|
53
|
-
"line":
|
|
57
|
+
"implementation": "dist/chunk-7A3UGAXY.js",
|
|
58
|
+
"line": 459
|
|
54
59
|
},
|
|
55
60
|
"extractCurrentTask": {
|
|
56
61
|
"types": "dist/processors/index.d.ts",
|
|
57
|
-
"implementation": "dist/chunk-
|
|
58
|
-
"line":
|
|
62
|
+
"implementation": "dist/chunk-7A3UGAXY.js",
|
|
63
|
+
"line": 1633
|
|
59
64
|
},
|
|
60
65
|
"formatMessagesForObserver": {
|
|
61
66
|
"types": "dist/processors/index.d.ts",
|
|
62
|
-
"implementation": "dist/chunk-
|
|
63
|
-
"line":
|
|
67
|
+
"implementation": "dist/chunk-7A3UGAXY.js",
|
|
68
|
+
"line": 1252
|
|
64
69
|
},
|
|
65
70
|
"getObservationsAsOf": {
|
|
66
71
|
"types": "dist/processors/index.d.ts",
|
|
67
|
-
"implementation": "dist/chunk-
|
|
68
|
-
"line":
|
|
72
|
+
"implementation": "dist/chunk-7A3UGAXY.js",
|
|
73
|
+
"line": 7807
|
|
69
74
|
},
|
|
70
75
|
"hasCurrentTaskSection": {
|
|
71
76
|
"types": "dist/processors/index.d.ts",
|
|
72
|
-
"implementation": "dist/chunk-
|
|
73
|
-
"line":
|
|
77
|
+
"implementation": "dist/chunk-7A3UGAXY.js",
|
|
78
|
+
"line": 1621
|
|
74
79
|
},
|
|
75
80
|
"injectAnchorIds": {
|
|
76
81
|
"types": "dist/processors/index.d.ts",
|
|
77
|
-
"implementation": "dist/chunk-
|
|
78
|
-
"line":
|
|
82
|
+
"implementation": "dist/chunk-7A3UGAXY.js",
|
|
83
|
+
"line": 543
|
|
79
84
|
},
|
|
80
85
|
"optimizeObservationsForContext": {
|
|
81
86
|
"types": "dist/processors/index.d.ts",
|
|
82
|
-
"implementation": "dist/chunk-
|
|
83
|
-
"line":
|
|
87
|
+
"implementation": "dist/chunk-7A3UGAXY.js",
|
|
88
|
+
"line": 1644
|
|
84
89
|
},
|
|
85
90
|
"parseAnchorId": {
|
|
86
91
|
"types": "dist/processors/index.d.ts",
|
|
87
|
-
"implementation": "dist/chunk-
|
|
88
|
-
"line":
|
|
92
|
+
"implementation": "dist/chunk-7A3UGAXY.js",
|
|
93
|
+
"line": 516
|
|
89
94
|
},
|
|
90
95
|
"parseObservationGroups": {
|
|
91
96
|
"types": "dist/processors/index.d.ts",
|
|
92
|
-
"implementation": "dist/chunk-
|
|
93
|
-
"line":
|
|
97
|
+
"implementation": "dist/chunk-7A3UGAXY.js",
|
|
98
|
+
"line": 404
|
|
94
99
|
},
|
|
95
100
|
"parseObserverOutput": {
|
|
96
101
|
"types": "dist/processors/index.d.ts",
|
|
97
|
-
"implementation": "dist/chunk-
|
|
98
|
-
"line":
|
|
102
|
+
"implementation": "dist/chunk-7A3UGAXY.js",
|
|
103
|
+
"line": 1529
|
|
99
104
|
},
|
|
100
105
|
"reconcileObservationGroupsFromReflection": {
|
|
101
106
|
"types": "dist/processors/index.d.ts",
|
|
102
|
-
"implementation": "dist/chunk-
|
|
103
|
-
"line":
|
|
107
|
+
"implementation": "dist/chunk-7A3UGAXY.js",
|
|
108
|
+
"line": 486
|
|
104
109
|
},
|
|
105
110
|
"renderObservationGroupsForReflection": {
|
|
106
111
|
"types": "dist/processors/index.d.ts",
|
|
107
|
-
"implementation": "dist/chunk-
|
|
108
|
-
"line":
|
|
112
|
+
"implementation": "dist/chunk-7A3UGAXY.js",
|
|
113
|
+
"line": 439
|
|
109
114
|
},
|
|
110
115
|
"stripEphemeralAnchorIds": {
|
|
111
116
|
"types": "dist/processors/index.d.ts",
|
|
112
|
-
"implementation": "dist/chunk-
|
|
113
|
-
"line":
|
|
117
|
+
"implementation": "dist/chunk-7A3UGAXY.js",
|
|
118
|
+
"line": 573
|
|
114
119
|
},
|
|
115
120
|
"stripObservationGroups": {
|
|
116
121
|
"types": "dist/processors/index.d.ts",
|
|
117
|
-
"implementation": "dist/chunk-
|
|
118
|
-
"line":
|
|
122
|
+
"implementation": "dist/chunk-7A3UGAXY.js",
|
|
123
|
+
"line": 426
|
|
119
124
|
},
|
|
120
125
|
"wrapInObservationGroup": {
|
|
121
126
|
"types": "dist/processors/index.d.ts",
|
|
122
|
-
"implementation": "dist/chunk-
|
|
123
|
-
"line":
|
|
127
|
+
"implementation": "dist/chunk-7A3UGAXY.js",
|
|
128
|
+
"line": 397
|
|
124
129
|
},
|
|
125
130
|
"extractWorkingMemoryContent": {
|
|
126
131
|
"types": "dist/index.d.ts",
|
|
@@ -151,7 +156,7 @@
|
|
|
151
156
|
"processors": {
|
|
152
157
|
"index": "dist/processors/index.js",
|
|
153
158
|
"chunks": [
|
|
154
|
-
"chunk-
|
|
159
|
+
"chunk-7A3UGAXY.js"
|
|
155
160
|
]
|
|
156
161
|
}
|
|
157
162
|
}
|
|
@@ -137,6 +137,42 @@ const memory = new Memory({
|
|
|
137
137
|
|
|
138
138
|
See [model configuration](https://mastra.ai/reference/memory/observational-memory) for using different models per agent.
|
|
139
139
|
|
|
140
|
+
### Token-tiered model selection
|
|
141
|
+
|
|
142
|
+
You can use `ModelByInputTokens` to specify different Observer or Reflector models based on input token count. OM selects the matching model tier at runtime from the configured `upTo` thresholds.
|
|
143
|
+
|
|
144
|
+
```typescript
|
|
145
|
+
import { Memory, ModelByInputTokens } from '@mastra/memory'
|
|
146
|
+
|
|
147
|
+
const memory = new Memory({
|
|
148
|
+
options: {
|
|
149
|
+
observationalMemory: {
|
|
150
|
+
observation: {
|
|
151
|
+
model: new ModelByInputTokens({
|
|
152
|
+
upTo: {
|
|
153
|
+
10_000: 'google/gemini-2.5-flash', // Fast and cheap for small inputs
|
|
154
|
+
40_000: 'openai/gpt-4o', // Stronger for medium inputs
|
|
155
|
+
1_000_000: 'openai/gpt-4.5', // Most capable for very large inputs
|
|
156
|
+
},
|
|
157
|
+
}),
|
|
158
|
+
},
|
|
159
|
+
reflection: {
|
|
160
|
+
model: new ModelByInputTokens({
|
|
161
|
+
upTo: {
|
|
162
|
+
20_000: 'google/gemini-2.5-flash',
|
|
163
|
+
80_000: 'openai/gpt-4o',
|
|
164
|
+
},
|
|
165
|
+
}),
|
|
166
|
+
},
|
|
167
|
+
},
|
|
168
|
+
},
|
|
169
|
+
})
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
The `upTo` keys are inclusive upper bounds. OM computes the actual input token count for the Observer or Reflector call, resolves the matching tier directly, and uses that concrete model for the run.
|
|
173
|
+
|
|
174
|
+
If the input exceeds the largest configured threshold, an error is thrown — ensure your thresholds cover the full range of possible input sizes, or use a model with a sufficiently large context window at the highest tier.
|
|
175
|
+
|
|
140
176
|
## Scopes
|
|
141
177
|
|
|
142
178
|
### Thread scope (default)
|
|
@@ -32,7 +32,7 @@ OM performs thresholding with fast local token estimation. Text uses `tokenx`, a
|
|
|
32
32
|
|
|
33
33
|
**enabled** (`boolean`): Enable or disable Observational Memory. When omitted from a config object, defaults to \`true\`. Only \`enabled: false\` explicitly disables it. (Default: `true`)
|
|
34
34
|
|
|
35
|
-
**model** (`string | LanguageModel | DynamicModel | ModelWithRetries[]`): Model for both the Observer and Reflector agents. Sets the model for both at once. Cannot be used together with \`observation.model\` or \`reflection.model\` — an error will be thrown if both are set. When using \`observationalMemory: true\`, defaults to \`google/gemini-2.5-flash\`. When passing a config object, this or \`observation.model\`/\`reflection.model\` must be set. Use \`"default"\` to explicitly use the default model (\`google/gemini-2.5-flash\`). (Default: `'google/gemini-2.5-flash' (when using observationalMemory: true)`)
|
|
35
|
+
**model** (`string | LanguageModel | DynamicModel | ModelByInputTokens | ModelWithRetries[]`): Model for both the Observer and Reflector agents. Sets the model for both at once. Cannot be used together with \`observation.model\` or \`reflection.model\` — an error will be thrown if both are set. When using \`observationalMemory: true\`, defaults to \`google/gemini-2.5-flash\`. When passing a config object, this or \`observation.model\`/\`reflection.model\` must be set. Use \`"default"\` to explicitly use the default model (\`google/gemini-2.5-flash\`). (Default: `'google/gemini-2.5-flash' (when using observationalMemory: true)`)
|
|
36
36
|
|
|
37
37
|
**scope** (`'resource' | 'thread'`): Memory scope for observations. \`'thread'\` keeps observations per-thread. \`'resource'\` (experimental) shares observations across all threads for a resource, enabling cross-conversation memory. (Default: `'thread'`)
|
|
38
38
|
|
|
@@ -42,7 +42,7 @@ OM performs thresholding with fast local token estimation. Text uses `tokenx`, a
|
|
|
42
42
|
|
|
43
43
|
**observation** (`ObservationalMemoryObservationConfig`): Configuration for the observation step. Controls when the Observer agent runs and how it behaves.
|
|
44
44
|
|
|
45
|
-
**observation.model** (`string | LanguageModel | DynamicModel | ModelWithRetries[]`): Model for the Observer agent. Cannot be set if a top-level \`model\` is also provided. If neither this nor the top-level \`model\` is set, falls back to \`reflection.model\`.
|
|
45
|
+
**observation.model** (`string | LanguageModel | DynamicModel | ModelByInputTokens | ModelWithRetries[]`): Model for the Observer agent. Cannot be set if a top-level \`model\` is also provided. If neither this nor the top-level \`model\` is set, falls back to \`reflection.model\`.
|
|
46
46
|
|
|
47
47
|
**observation.instruction** (`string`): Custom instruction appended to the Observer's system prompt. Use this to customize what the Observer focuses on, such as domain-specific preferences or priorities.
|
|
48
48
|
|
|
@@ -68,7 +68,7 @@ OM performs thresholding with fast local token estimation. Text uses `tokenx`, a
|
|
|
68
68
|
|
|
69
69
|
**reflection** (`ObservationalMemoryReflectionConfig`): Configuration for the reflection step. Controls when the Reflector agent runs and how it behaves.
|
|
70
70
|
|
|
71
|
-
**reflection.model** (`string | LanguageModel | DynamicModel | ModelWithRetries[]`): Model for the Reflector agent. Cannot be set if a top-level \`model\` is also provided. If neither this nor the top-level \`model\` is set, falls back to \`observation.model\`.
|
|
71
|
+
**reflection.model** (`string | LanguageModel | DynamicModel | ModelByInputTokens | ModelWithRetries[]`): Model for the Reflector agent. Cannot be set if a top-level \`model\` is also provided. If neither this nor the top-level \`model\` is set, falls back to \`observation.model\`.
|
|
72
72
|
|
|
73
73
|
**reflection.instruction** (`string`): Custom instruction appended to the Reflector's system prompt. Use this to customize how the Reflector consolidates observations, such as prioritizing certain types of information.
|
|
74
74
|
|
|
@@ -612,6 +612,45 @@ When `retrieval: true` is set with `scope: 'thread'`, OM registers a `recall` to
|
|
|
612
612
|
|
|
613
613
|
**tokenOffset** (`number`): Approximate number of tokens that were trimmed when \`truncated\` is true.
|
|
614
614
|
|
|
615
|
+
### ModelByInputTokens
|
|
616
|
+
|
|
617
|
+
`ModelByInputTokens` selects a model based on the input token count. It chooses the model for the smallest threshold that covers the actual input size.
|
|
618
|
+
|
|
619
|
+
#### Constructor
|
|
620
|
+
|
|
621
|
+
```typescript
|
|
622
|
+
new ModelByInputTokens(config)
|
|
623
|
+
```
|
|
624
|
+
|
|
625
|
+
Where `config` is an object with `upTo` keys that map token thresholds (numbers) to model targets.
|
|
626
|
+
|
|
627
|
+
#### Example
|
|
628
|
+
|
|
629
|
+
```typescript
|
|
630
|
+
import { ModelByInputTokens } from '@mastra/memory'
|
|
631
|
+
|
|
632
|
+
const selector = new ModelByInputTokens({
|
|
633
|
+
upTo: {
|
|
634
|
+
10_000: 'google/gemini-2.5-flash', // Fast for small inputs
|
|
635
|
+
40_000: 'openai/gpt-4o', // Stronger for medium inputs
|
|
636
|
+
1_000_000: 'openai/gpt-4.5', // Most capable for large inputs
|
|
637
|
+
},
|
|
638
|
+
})
|
|
639
|
+
```
|
|
640
|
+
|
|
641
|
+
#### Behavior
|
|
642
|
+
|
|
643
|
+
- Thresholds are sorted internally, so the order in the config object does not matter.
|
|
644
|
+
- `inputTokens ≤ smallest threshold` → uses that threshold's model
|
|
645
|
+
- `inputTokens > largest threshold` → `resolve()` throws an error. If this happens during an OM Observer or Reflector run, OM aborts via TripWire, so callers receive an empty `text` result or streamed `tripwire` instead of a normal assistant response.
|
|
646
|
+
- OM computes the input token count for the Observer or Reflector call and resolves the matching model tier directly
|
|
647
|
+
|
|
648
|
+
#### Methods
|
|
649
|
+
|
|
650
|
+
**resolve** (`(inputTokens: number) => MastraModelConfig`): Returns the model for the given input token count. Throws if inputTokens exceeds the largest configured threshold. When this happens during an OM run, callers receive a TripWire/empty-text outcome instead of a normal assistant response.
|
|
651
|
+
|
|
652
|
+
**getThresholds** (`() => number[]`): Returns the configured thresholds in ascending order. Useful for introspection.
|
|
653
|
+
|
|
615
654
|
### Related
|
|
616
655
|
|
|
617
656
|
- [Observational Memory](https://mastra.ai/docs/memory/observational-memory)
|
package/dist/index.cjs
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
var chunkCK4U3AYR_cjs = require('./chunk-CK4U3AYR.cjs');
|
|
4
4
|
var chunkIDRQZVB4_cjs = require('./chunk-IDRQZVB4.cjs');
|
|
5
|
-
var
|
|
5
|
+
var chunkEVBFYGDL_cjs = require('./chunk-EVBFYGDL.cjs');
|
|
6
6
|
var v3 = require('zod/v3');
|
|
7
7
|
var zod = require('zod');
|
|
8
8
|
var z4 = require('zod/v4');
|
|
@@ -15503,7 +15503,7 @@ function formatTimestamp(date) {
|
|
|
15503
15503
|
}
|
|
15504
15504
|
function truncateByTokens(text4, maxTokens, hint) {
|
|
15505
15505
|
if (tokenx.estimateTokenCount(text4) <= maxTokens) return { text: text4, wasTruncated: false };
|
|
15506
|
-
const truncated =
|
|
15506
|
+
const truncated = chunkEVBFYGDL_cjs.truncateStringByTokens(text4, maxTokens);
|
|
15507
15507
|
const suffix = hint ? ` [${hint} for more]` : "";
|
|
15508
15508
|
return { text: truncated + suffix, wasTruncated: true };
|
|
15509
15509
|
}
|
|
@@ -15536,11 +15536,11 @@ function formatMessageParts(msg, detail) {
|
|
|
15536
15536
|
} else if (partType === "tool-invocation") {
|
|
15537
15537
|
const inv = part.toolInvocation;
|
|
15538
15538
|
if (inv.state === "result") {
|
|
15539
|
-
const { value: resultValue } =
|
|
15539
|
+
const { value: resultValue } = chunkEVBFYGDL_cjs.resolveToolResultValue(
|
|
15540
15540
|
part,
|
|
15541
15541
|
inv.result
|
|
15542
15542
|
);
|
|
15543
|
-
const resultStr =
|
|
15543
|
+
const resultStr = chunkEVBFYGDL_cjs.formatToolResultForObserver(resultValue, { maxTokens: HIGH_DETAIL_TOOL_RESULT_TOKENS });
|
|
15544
15544
|
const fullText = `[Tool Result: ${inv.toolName}]
|
|
15545
15545
|
${resultStr}`;
|
|
15546
15546
|
parts.push(makePart(msg, i, "tool-result", fullText, detail));
|
|
@@ -15603,7 +15603,7 @@ function renderFormattedParts(parts, timestamps, options) {
|
|
|
15603
15603
|
const text4 = buildRenderedText(parts, timestamps);
|
|
15604
15604
|
let totalTokens = tokenx.estimateTokenCount(text4);
|
|
15605
15605
|
if (totalTokens > options.maxTokens) {
|
|
15606
|
-
const truncated =
|
|
15606
|
+
const truncated = chunkEVBFYGDL_cjs.truncateStringByTokens(text4, options.maxTokens);
|
|
15607
15607
|
return { text: truncated, truncated: true, tokenOffset: totalTokens - options.maxTokens };
|
|
15608
15608
|
}
|
|
15609
15609
|
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));
|
|
@@ -15636,7 +15636,7 @@ function renderFormattedParts(parts, timestamps, options) {
|
|
|
15636
15636
|
if (expandedTokens <= options.maxTokens) {
|
|
15637
15637
|
return { text: expanded, truncated: false, tokenOffset: 0 };
|
|
15638
15638
|
}
|
|
15639
|
-
const hardTruncated =
|
|
15639
|
+
const hardTruncated = chunkEVBFYGDL_cjs.truncateStringByTokens(expanded, options.maxTokens);
|
|
15640
15640
|
return { text: hardTruncated, truncated: true, tokenOffset: expandedTokens - options.maxTokens };
|
|
15641
15641
|
}
|
|
15642
15642
|
async function recallPart({
|
|
@@ -15671,7 +15671,7 @@ async function recallPart({
|
|
|
15671
15671
|
`Part index ${partIndex} not found in message ${cursor}. Available indices: ${allParts.map((p) => p.partIndex).join(", ")}`
|
|
15672
15672
|
);
|
|
15673
15673
|
}
|
|
15674
|
-
const truncatedText =
|
|
15674
|
+
const truncatedText = chunkEVBFYGDL_cjs.truncateStringByTokens(target.text, maxTokens);
|
|
15675
15675
|
const wasTruncated = truncatedText !== target.text;
|
|
15676
15676
|
return {
|
|
15677
15677
|
text: truncatedText,
|
|
@@ -17403,7 +17403,10 @@ Notes:
|
|
|
17403
17403
|
);
|
|
17404
17404
|
const memoryContext = context2?.get("MastraMemory");
|
|
17405
17405
|
const runtimeMemoryConfig = memoryContext?.memoryConfig;
|
|
17406
|
-
const effectiveConfig = runtimeMemoryConfig ? this.getMergedThreadConfig(
|
|
17406
|
+
const effectiveConfig = runtimeMemoryConfig ? this.getMergedThreadConfig({
|
|
17407
|
+
...runtimeMemoryConfig,
|
|
17408
|
+
observationalMemory: runtimeMemoryConfig.observationalMemory
|
|
17409
|
+
}) : this.threadConfig;
|
|
17407
17410
|
const omConfig = normalizeObservationalMemoryConfig(effectiveConfig.observationalMemory);
|
|
17408
17411
|
if (!omConfig || hasObservationalMemory) {
|
|
17409
17412
|
return null;
|
|
@@ -17435,7 +17438,7 @@ Notes:
|
|
|
17435
17438
|
"Observational memory requires @mastra/core support for request-response-id-rotation. Please bump @mastra/core to a newer version."
|
|
17436
17439
|
);
|
|
17437
17440
|
}
|
|
17438
|
-
const { ObservationalMemory } = await import('./observational-memory-
|
|
17441
|
+
const { ObservationalMemory } = await import('./observational-memory-COYJCVX3.cjs');
|
|
17439
17442
|
return new ObservationalMemory({
|
|
17440
17443
|
storage: memoryStore,
|
|
17441
17444
|
scope: omConfig.scope,
|
|
@@ -17468,9 +17471,13 @@ Notes:
|
|
|
17468
17471
|
}
|
|
17469
17472
|
};
|
|
17470
17473
|
|
|
17474
|
+
Object.defineProperty(exports, "ModelByInputTokens", {
|
|
17475
|
+
enumerable: true,
|
|
17476
|
+
get: function () { return chunkEVBFYGDL_cjs.ModelByInputTokens; }
|
|
17477
|
+
});
|
|
17471
17478
|
Object.defineProperty(exports, "getObservationsAsOf", {
|
|
17472
17479
|
enumerable: true,
|
|
17473
|
-
get: function () { return
|
|
17480
|
+
get: function () { return chunkEVBFYGDL_cjs.getObservationsAsOf; }
|
|
17474
17481
|
});
|
|
17475
17482
|
Object.defineProperty(exports, "extractWorkingMemoryContent", {
|
|
17476
17483
|
enumerable: true,
|