@mastra/memory 1.41.4-alpha.0 → 1.41.4-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/docs/SKILL.md +1 -1
- package/dist/docs/assets/SOURCE_MAP.json +55 -55
- package/dist/docs/references/docs-harness-background-tasks.md +38 -0
- package/dist/index.cjs +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/observation-turn/turn.d.ts +2 -1
- package/dist/{src-fOZd9ewi.cjs → src-Cr_776no.cjs} +33 -12
- package/dist/{src-BLtNRhqm.js → src-SlK5VIXE.js} +33 -12
- package/package.json +2 -2
package/dist/docs/SKILL.md
CHANGED
|
@@ -1,243 +1,243 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "1.41.4-alpha.
|
|
2
|
+
"version": "1.41.4-alpha.1",
|
|
3
3
|
"package": "@mastra/memory",
|
|
4
4
|
"exports": {
|
|
5
5
|
"AUTO_MODEL_BY_PROVIDER": {
|
|
6
6
|
"types": "dist/processors/observational-memory/auto-model.d.ts",
|
|
7
|
-
"implementation": "dist/src-
|
|
7
|
+
"implementation": "dist/src-SlK5VIXE.js",
|
|
8
8
|
"line": 32945
|
|
9
9
|
},
|
|
10
10
|
"Extractor": {
|
|
11
11
|
"types": "dist/processors/observational-memory/extractor.d.ts",
|
|
12
|
-
"implementation": "dist/src-
|
|
12
|
+
"implementation": "dist/src-SlK5VIXE.js",
|
|
13
13
|
"line": 24432
|
|
14
14
|
},
|
|
15
15
|
"ModelByInputTokens": {
|
|
16
16
|
"types": "dist/processors/observational-memory/model-by-input-tokens.d.ts",
|
|
17
|
-
"implementation": "dist/src-
|
|
17
|
+
"implementation": "dist/src-SlK5VIXE.js",
|
|
18
18
|
"line": 32728
|
|
19
19
|
},
|
|
20
20
|
"OBSERVATIONAL_MEMORY_DEFAULTS": {
|
|
21
21
|
"types": "dist/processors/observational-memory/constants.d.ts",
|
|
22
|
-
"implementation": "dist/src-
|
|
22
|
+
"implementation": "dist/src-SlK5VIXE.js",
|
|
23
23
|
"line": 24168
|
|
24
24
|
},
|
|
25
25
|
"OBSERVATION_CONTEXT_INSTRUCTIONS": {
|
|
26
26
|
"types": "dist/processors/observational-memory/constants.d.ts",
|
|
27
|
-
"implementation": "dist/src-
|
|
27
|
+
"implementation": "dist/src-SlK5VIXE.js",
|
|
28
28
|
"line": 24229
|
|
29
29
|
},
|
|
30
30
|
"OBSERVATION_CONTEXT_PROMPT": {
|
|
31
31
|
"types": "dist/processors/observational-memory/constants.d.ts",
|
|
32
|
-
"implementation": "dist/src-
|
|
32
|
+
"implementation": "dist/src-SlK5VIXE.js",
|
|
33
33
|
"line": 24211
|
|
34
34
|
},
|
|
35
35
|
"OBSERVATION_CONTEXT_PROMPT_THREAD": {
|
|
36
36
|
"types": "dist/processors/observational-memory/constants.d.ts",
|
|
37
|
-
"implementation": "dist/src-
|
|
37
|
+
"implementation": "dist/src-SlK5VIXE.js",
|
|
38
38
|
"line": 24216
|
|
39
39
|
},
|
|
40
40
|
"OBSERVATION_CONTINUATION_HINT": {
|
|
41
41
|
"types": "dist/processors/observational-memory/constants.d.ts",
|
|
42
|
-
"implementation": "dist/src-
|
|
42
|
+
"implementation": "dist/src-SlK5VIXE.js",
|
|
43
43
|
"line": 24198
|
|
44
44
|
},
|
|
45
45
|
"OBSERVER_SYSTEM_PROMPT": {
|
|
46
46
|
"types": "dist/processors/observational-memory/observer-agent.d.ts",
|
|
47
|
-
"implementation": "dist/src-
|
|
47
|
+
"implementation": "dist/src-SlK5VIXE.js",
|
|
48
48
|
"line": 26880
|
|
49
49
|
},
|
|
50
50
|
"ObservationalMemory": {
|
|
51
51
|
"types": "dist/processors/observational-memory/observational-memory.d.ts",
|
|
52
|
-
"implementation": "dist/src-
|
|
53
|
-
"line":
|
|
52
|
+
"implementation": "dist/src-SlK5VIXE.js",
|
|
53
|
+
"line": 38063
|
|
54
54
|
},
|
|
55
55
|
"ObservationalMemoryProcessor": {
|
|
56
56
|
"types": "dist/processors/observational-memory/processor.d.ts",
|
|
57
|
-
"implementation": "dist/src-
|
|
58
|
-
"line":
|
|
57
|
+
"implementation": "dist/src-SlK5VIXE.js",
|
|
58
|
+
"line": 40898
|
|
59
59
|
},
|
|
60
60
|
"TokenCounter": {
|
|
61
61
|
"types": "dist/processors/observational-memory/token-counter.d.ts",
|
|
62
|
-
"implementation": "dist/src-
|
|
62
|
+
"implementation": "dist/src-SlK5VIXE.js",
|
|
63
63
|
"line": 29410
|
|
64
64
|
},
|
|
65
65
|
"WorkingMemoryExtractor": {
|
|
66
66
|
"types": "dist/processors/observational-memory/working-memory-extractor.d.ts",
|
|
67
|
-
"implementation": "dist/src-
|
|
67
|
+
"implementation": "dist/src-SlK5VIXE.js",
|
|
68
68
|
"line": 30466
|
|
69
69
|
},
|
|
70
70
|
"buildObserverPrompt": {
|
|
71
71
|
"types": "dist/processors/observational-memory/observer-agent.d.ts",
|
|
72
|
-
"implementation": "dist/src-
|
|
72
|
+
"implementation": "dist/src-SlK5VIXE.js",
|
|
73
73
|
"line": 27562
|
|
74
74
|
},
|
|
75
75
|
"buildObserverSystemPrompt": {
|
|
76
76
|
"types": "dist/processors/observational-memory/observer-agent.d.ts",
|
|
77
|
-
"implementation": "dist/src-
|
|
77
|
+
"implementation": "dist/src-SlK5VIXE.js",
|
|
78
78
|
"line": 26774
|
|
79
79
|
},
|
|
80
80
|
"combineObservationGroupRanges": {
|
|
81
81
|
"types": "dist/processors/observational-memory/observation-groups.d.ts",
|
|
82
|
-
"implementation": "dist/src-
|
|
82
|
+
"implementation": "dist/src-SlK5VIXE.js",
|
|
83
83
|
"line": 31048
|
|
84
84
|
},
|
|
85
85
|
"deriveObservationGroupProvenance": {
|
|
86
86
|
"types": "dist/processors/observational-memory/observation-groups.d.ts",
|
|
87
|
-
"implementation": "dist/src-
|
|
87
|
+
"implementation": "dist/src-SlK5VIXE.js",
|
|
88
88
|
"line": 31092
|
|
89
89
|
},
|
|
90
90
|
"extractCurrentTask": {
|
|
91
91
|
"types": "dist/processors/observational-memory/observer-agent.d.ts",
|
|
92
|
-
"implementation": "dist/src-
|
|
92
|
+
"implementation": "dist/src-SlK5VIXE.js",
|
|
93
93
|
"line": 27875
|
|
94
94
|
},
|
|
95
95
|
"formatMessagesForObserver": {
|
|
96
96
|
"types": "dist/processors/observational-memory/observer-agent.d.ts",
|
|
97
|
-
"implementation": "dist/src-
|
|
97
|
+
"implementation": "dist/src-SlK5VIXE.js",
|
|
98
98
|
"line": 27313
|
|
99
99
|
},
|
|
100
100
|
"getObservationContextPrompt": {
|
|
101
101
|
"types": "dist/processors/observational-memory/constants.d.ts",
|
|
102
|
-
"implementation": "dist/src-
|
|
102
|
+
"implementation": "dist/src-SlK5VIXE.js",
|
|
103
103
|
"line": 24222
|
|
104
104
|
},
|
|
105
105
|
"getObservationsAsOf": {
|
|
106
106
|
"types": "dist/processors/observational-memory/observation-utils.d.ts",
|
|
107
|
-
"implementation": "dist/src-
|
|
108
|
-
"line":
|
|
107
|
+
"implementation": "dist/src-SlK5VIXE.js",
|
|
108
|
+
"line": 41244
|
|
109
109
|
},
|
|
110
110
|
"hasCurrentTaskSection": {
|
|
111
111
|
"types": "dist/processors/observational-memory/observer-agent.d.ts",
|
|
112
|
-
"implementation": "dist/src-
|
|
112
|
+
"implementation": "dist/src-SlK5VIXE.js",
|
|
113
113
|
"line": 27863
|
|
114
114
|
},
|
|
115
115
|
"injectAnchorIds": {
|
|
116
116
|
"types": "dist/processors/observational-memory/anchor-ids.d.ts",
|
|
117
|
-
"implementation": "dist/src-
|
|
117
|
+
"implementation": "dist/src-SlK5VIXE.js",
|
|
118
118
|
"line": 25432
|
|
119
119
|
},
|
|
120
120
|
"optimizeObservationsForContext": {
|
|
121
121
|
"types": "dist/processors/observational-memory/observer-agent.d.ts",
|
|
122
|
-
"implementation": "dist/src-
|
|
122
|
+
"implementation": "dist/src-SlK5VIXE.js",
|
|
123
123
|
"line": 27896
|
|
124
124
|
},
|
|
125
125
|
"parseAnchorId": {
|
|
126
126
|
"types": "dist/processors/observational-memory/anchor-ids.d.ts",
|
|
127
|
-
"implementation": "dist/src-
|
|
127
|
+
"implementation": "dist/src-SlK5VIXE.js",
|
|
128
128
|
"line": 25416
|
|
129
129
|
},
|
|
130
130
|
"parseObservationGroups": {
|
|
131
131
|
"types": "dist/processors/observational-memory/observation-groups.d.ts",
|
|
132
|
-
"implementation": "dist/src-
|
|
132
|
+
"implementation": "dist/src-SlK5VIXE.js",
|
|
133
133
|
"line": 31003
|
|
134
134
|
},
|
|
135
135
|
"parseObserverOutput": {
|
|
136
136
|
"types": "dist/processors/observational-memory/observer-agent.d.ts",
|
|
137
|
-
"implementation": "dist/src-
|
|
137
|
+
"implementation": "dist/src-SlK5VIXE.js",
|
|
138
138
|
"line": 27573
|
|
139
139
|
},
|
|
140
140
|
"reconcileObservationGroupsFromReflection": {
|
|
141
141
|
"types": "dist/processors/observational-memory/observation-groups.d.ts",
|
|
142
|
-
"implementation": "dist/src-
|
|
142
|
+
"implementation": "dist/src-SlK5VIXE.js",
|
|
143
143
|
"line": 31111
|
|
144
144
|
},
|
|
145
145
|
"renderObservationGroupsForReflection": {
|
|
146
146
|
"types": "dist/processors/observational-memory/observation-groups.d.ts",
|
|
147
|
-
"implementation": "dist/src-
|
|
147
|
+
"implementation": "dist/src-SlK5VIXE.js",
|
|
148
148
|
"line": 31077
|
|
149
149
|
},
|
|
150
150
|
"resolveAutoModelId": {
|
|
151
151
|
"types": "dist/processors/observational-memory/auto-model.d.ts",
|
|
152
|
-
"implementation": "dist/src-
|
|
152
|
+
"implementation": "dist/src-SlK5VIXE.js",
|
|
153
153
|
"line": 32965
|
|
154
154
|
},
|
|
155
155
|
"stripEphemeralAnchorIds": {
|
|
156
156
|
"types": "dist/processors/observational-memory/anchor-ids.d.ts",
|
|
157
|
-
"implementation": "dist/src-
|
|
157
|
+
"implementation": "dist/src-SlK5VIXE.js",
|
|
158
158
|
"line": 25455
|
|
159
159
|
},
|
|
160
160
|
"stripObservationGroups": {
|
|
161
161
|
"types": "dist/processors/observational-memory/observation-groups.d.ts",
|
|
162
|
-
"implementation": "dist/src-
|
|
162
|
+
"implementation": "dist/src-SlK5VIXE.js",
|
|
163
163
|
"line": 31020
|
|
164
164
|
},
|
|
165
165
|
"summarizeConversation": {
|
|
166
166
|
"types": "dist/processors/observational-memory/summarize.d.ts",
|
|
167
|
-
"implementation": "dist/src-
|
|
167
|
+
"implementation": "dist/src-SlK5VIXE.js",
|
|
168
168
|
"line": 30078
|
|
169
169
|
},
|
|
170
170
|
"wrapInObservationGroup": {
|
|
171
171
|
"types": "dist/processors/observational-memory/observation-groups.d.ts",
|
|
172
|
-
"implementation": "dist/src-
|
|
172
|
+
"implementation": "dist/src-SlK5VIXE.js",
|
|
173
173
|
"line": 30974
|
|
174
174
|
},
|
|
175
175
|
"KnowledgeSemanticIndexCoordinator": {
|
|
176
176
|
"types": "dist/removed-subconscious.d.ts",
|
|
177
|
-
"implementation": "dist/src-
|
|
177
|
+
"implementation": "dist/src-SlK5VIXE.js",
|
|
178
178
|
"line": 30572
|
|
179
179
|
},
|
|
180
180
|
"Memory": {
|
|
181
181
|
"types": "dist/index.d.ts",
|
|
182
|
-
"implementation": "dist/src-
|
|
183
|
-
"line":
|
|
182
|
+
"implementation": "dist/src-SlK5VIXE.js",
|
|
183
|
+
"line": 41496
|
|
184
184
|
},
|
|
185
185
|
"SUMMARIZE_THREAD_DEFAULTS": {
|
|
186
186
|
"types": "dist/processors/observational-memory/summarize.d.ts",
|
|
187
|
-
"implementation": "dist/src-
|
|
187
|
+
"implementation": "dist/src-SlK5VIXE.js",
|
|
188
188
|
"line": 30034
|
|
189
189
|
},
|
|
190
190
|
"StaleKnowledgeSemanticIndexError": {
|
|
191
191
|
"types": "dist/removed-subconscious.d.ts",
|
|
192
|
-
"implementation": "dist/src-
|
|
192
|
+
"implementation": "dist/src-SlK5VIXE.js",
|
|
193
193
|
"line": 30578
|
|
194
194
|
},
|
|
195
195
|
"Subconscious": {
|
|
196
196
|
"types": "dist/removed-subconscious.d.ts",
|
|
197
|
-
"implementation": "dist/src-
|
|
197
|
+
"implementation": "dist/src-SlK5VIXE.js",
|
|
198
198
|
"line": 30566
|
|
199
199
|
},
|
|
200
200
|
"WORKING_MEMORY_STATE_ID": {
|
|
201
201
|
"types": "dist/processors/working-memory-state/processor.d.ts",
|
|
202
|
-
"implementation": "dist/src-
|
|
202
|
+
"implementation": "dist/src-SlK5VIXE.js",
|
|
203
203
|
"line": 32774
|
|
204
204
|
},
|
|
205
205
|
"WORKING_MEMORY_STATE_PROCESSOR_ID": {
|
|
206
206
|
"types": "dist/processors/working-memory-state/processor.d.ts",
|
|
207
|
-
"implementation": "dist/src-
|
|
207
|
+
"implementation": "dist/src-SlK5VIXE.js",
|
|
208
208
|
"line": 32775
|
|
209
209
|
},
|
|
210
210
|
"WorkingMemoryStateProcessor": {
|
|
211
211
|
"types": "dist/processors/working-memory-state/processor.d.ts",
|
|
212
|
-
"implementation": "dist/src-
|
|
212
|
+
"implementation": "dist/src-SlK5VIXE.js",
|
|
213
213
|
"line": 32776
|
|
214
214
|
},
|
|
215
215
|
"deepMergeWorkingMemory": {
|
|
216
216
|
"types": "dist/tools/working-memory.d.ts",
|
|
217
|
-
"implementation": "dist/src-
|
|
217
|
+
"implementation": "dist/src-SlK5VIXE.js",
|
|
218
218
|
"line": 30157
|
|
219
219
|
},
|
|
220
220
|
"extractWorkingMemoryContent": {
|
|
221
221
|
"types": "dist/index.d.ts",
|
|
222
|
-
"implementation": "dist/src-
|
|
223
|
-
"line":
|
|
222
|
+
"implementation": "dist/src-SlK5VIXE.js",
|
|
223
|
+
"line": 41309
|
|
224
224
|
},
|
|
225
225
|
"extractWorkingMemoryTags": {
|
|
226
226
|
"types": "dist/index.d.ts",
|
|
227
|
-
"implementation": "dist/src-
|
|
228
|
-
"line":
|
|
227
|
+
"implementation": "dist/src-SlK5VIXE.js",
|
|
228
|
+
"line": 41277
|
|
229
229
|
},
|
|
230
230
|
"removeWorkingMemoryTags": {
|
|
231
231
|
"types": "dist/index.d.ts",
|
|
232
|
-
"implementation": "dist/src-
|
|
233
|
-
"line":
|
|
232
|
+
"implementation": "dist/src-SlK5VIXE.js",
|
|
233
|
+
"line": 41290
|
|
234
234
|
}
|
|
235
235
|
},
|
|
236
236
|
"modules": {
|
|
237
237
|
"processors": {
|
|
238
238
|
"index": "dist/processors/index.js",
|
|
239
239
|
"chunks": [
|
|
240
|
-
"src-
|
|
240
|
+
"src-SlK5VIXE.js"
|
|
241
241
|
]
|
|
242
242
|
}
|
|
243
243
|
}
|
|
@@ -98,6 +98,25 @@ export const researcher = new Agent({
|
|
|
98
98
|
|
|
99
99
|
Set `tools: 'all'` to opt in every tool the agent has.
|
|
100
100
|
|
|
101
|
+
### Agent-wide defaults
|
|
102
|
+
|
|
103
|
+
Agent-wide `defaultDisposition` and `modelOverrides` sit next to `tools` and apply to every tool the agent has opted in, so you don't have to repeat them per tool:
|
|
104
|
+
|
|
105
|
+
```typescript
|
|
106
|
+
export const researcher = new Agent({
|
|
107
|
+
// ...
|
|
108
|
+
backgroundTasks: {
|
|
109
|
+
tools: 'all',
|
|
110
|
+
defaultDisposition: 'foreground',
|
|
111
|
+
modelOverrides: false,
|
|
112
|
+
},
|
|
113
|
+
})
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
Both act as defaults. For each tool the agent has opted in, `defaultDisposition` resolves as the tool entry's own value, then the agent-wide value, then the tool's own `background` config, then `deferred`. `modelOverrides` resolves the same way but defaults to `true`. `enabled` is never inherited, so agent-wide fields can't opt a tool in on their own.
|
|
117
|
+
|
|
118
|
+
Agent-wide values apply to named entries too, so a plain `tools: { research: true }` inherits them. An entry can still opt out per tool with its own `defaultDisposition` or `modelOverrides`. `defaultDisposition` accepts `'foreground'` or `'deferred'`, so `awaited` remains a per-call `_background` choice.
|
|
119
|
+
|
|
101
120
|
### LLM per-call override
|
|
102
121
|
|
|
103
122
|
When a tool is registered on an agent that has background tasks enabled, the model can include a `_background` field in the tool arguments to override the resolved configuration for that specific call. The model only includes what it wants to override, all fields in `_background` are optional. The override is stripped from the arguments before the tool runs.
|
|
@@ -119,6 +138,25 @@ For compatibility, `_background.enabled: true` selects `deferred`, and `_backgro
|
|
|
119
138
|
|
|
120
139
|
The `_background` override only _modifies_ tools the developer has already opted in at the tool or agent layer. If a tool hasn't been opted in, a model-selected background disposition 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.
|
|
121
140
|
|
|
141
|
+
### Disable the per-call override
|
|
142
|
+
|
|
143
|
+
The `_background` object adds five optional parameters to each eligible tool's input schema: the object itself plus `enabled`, `disposition`, `timeoutMs`, and `maxRetries`. Some providers cap optional parameters per request. Anthropic rejects strict tool schemas with more than 24 optional parameters in total, so five strict background tools exceed the limit before counting their own optional fields.
|
|
144
|
+
|
|
145
|
+
Set `modelOverrides: false` when a tool should always use its configured disposition. Mastra then leaves `_background` out of the tool's schema and the system prompt, and ignores any `_background` value the model sends:
|
|
146
|
+
|
|
147
|
+
```typescript
|
|
148
|
+
const researchTool = createTool({
|
|
149
|
+
id: 'research',
|
|
150
|
+
description: 'Research a topic in depth',
|
|
151
|
+
strict: true,
|
|
152
|
+
inputSchema: z.object({ topic: z.string() }),
|
|
153
|
+
background: { enabled: true, modelOverrides: false },
|
|
154
|
+
execute: async ({ topic }) => runResearch(topic),
|
|
155
|
+
})
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
You can also set `modelOverrides: false` on an agent's per-tool entry, for example `backgroundTasks: { tools: { research: { enabled: true, modelOverrides: false } } }`. The agent entry takes precedence over the tool definition. Tools with `modelOverrides: false` and `defaultDisposition: 'foreground'` always run in the foreground.
|
|
159
|
+
|
|
122
160
|
### Resolution order
|
|
123
161
|
|
|
124
162
|
When a tool call is dispatched, agent-level and tool-level settings determine eligibility and fallback values. For an eligible tool, the LLM `_background` fields override the corresponding values for that call. Manager defaults fill timeout and retry values that remain unset. An `_background` field can't enable a tool that's not eligible.
|
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-Cr_776no.cjs");
|
|
3
3
|
let _mastra_core_processors = require("@mastra/core/processors");
|
|
4
4
|
let _mastra_core_memory = require("@mastra/core/memory");
|
|
5
5
|
exports.AUTO_MODEL_BY_PROVIDER = require_src.AUTO_MODEL_BY_PROVIDER;
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { m as AUTO_MODEL_BY_PROVIDER, K as Extractor, D as KnowledgeSemanticIndexCoordinator, t as Memory, n as MessageHistory, y as ModelByInputTokens, M as SUMMARIZE_THREAD_DEFAULTS, r as SemanticRecall, O as StaleKnowledgeSemanticIndexError, k as Subconscious, g as WORKING_MEMORY_STATE_ID, _ as WORKING_MEMORY_STATE_PROCESSOR_ID, i as WorkingMemory, A as WorkingMemoryExtractor, v as WorkingMemoryStateProcessor, a as asUserTurn, j as deepMergeWorkingMemory, o as escapeTurnMarkup, s as extractWorkingMemoryContent, c as extractWorkingMemoryTags, d as getObservationsAsOf, l as removeWorkingMemoryTags, h as resolveAutoModelId, u as sealTurnMarkup, N as summarizeConversation } from "./src-
|
|
1
|
+
export { m as AUTO_MODEL_BY_PROVIDER, K as Extractor, D as KnowledgeSemanticIndexCoordinator, t as Memory, n as MessageHistory, y as ModelByInputTokens, M as SUMMARIZE_THREAD_DEFAULTS, r as SemanticRecall, O as StaleKnowledgeSemanticIndexError, k as Subconscious, g as WORKING_MEMORY_STATE_ID, _ as WORKING_MEMORY_STATE_PROCESSOR_ID, i as WorkingMemory, A as WorkingMemoryExtractor, v as WorkingMemoryStateProcessor, a as asUserTurn, j as deepMergeWorkingMemory, o as escapeTurnMarkup, s as extractWorkingMemoryContent, c as extractWorkingMemoryTags, d as getObservationsAsOf, l as removeWorkingMemoryTags, h as resolveAutoModelId, u as sealTurnMarkup, N as summarizeConversation } from "./src-SlK5VIXE.js";
|
|
@@ -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-Cr_776no.cjs");
|
|
3
3
|
exports.AUTO_MODEL_BY_PROVIDER = require_src.AUTO_MODEL_BY_PROVIDER;
|
|
4
4
|
exports.Extractor = require_src.Extractor;
|
|
5
5
|
exports.ModelByInputTokens = require_src.ModelByInputTokens;
|
package/dist/processors/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { m as AUTO_MODEL_BY_PROVIDER, K as Extractor, y as ModelByInputTokens, q as OBSERVATIONAL_MEMORY_DEFAULTS, J as OBSERVATION_CONTEXT_INSTRUCTIONS, Y as OBSERVATION_CONTEXT_PROMPT, X as OBSERVATION_CONTEXT_PROMPT_THREAD, Z as OBSERVATION_CONTINUATION_HINT, F as OBSERVER_SYSTEM_PROMPT, p as ObservationalMemory, f as ObservationalMemoryProcessor, P as TokenCounter, A as WorkingMemoryExtractor, I as buildObserverPrompt, L as buildObserverSystemPrompt, b as combineObservationGroupRanges, x as deriveObservationGroupProvenance, R as extractCurrentTask, z as formatMessagesForObserver, Q as getObservationContextPrompt, d as getObservationsAsOf, B as hasCurrentTaskSection, U as injectAnchorIds, V as optimizeObservationsForContext, W as parseAnchorId, S as parseObservationGroups, H as parseObserverOutput, C as reconcileObservationGroupsFromReflection, w as renderObservationGroupsForReflection, h as resolveAutoModelId, G as stripEphemeralAnchorIds, T as stripObservationGroups, N as summarizeConversation, E as wrapInObservationGroup } from "../src-
|
|
1
|
+
export { m as AUTO_MODEL_BY_PROVIDER, K as Extractor, y as ModelByInputTokens, q as OBSERVATIONAL_MEMORY_DEFAULTS, J as OBSERVATION_CONTEXT_INSTRUCTIONS, Y as OBSERVATION_CONTEXT_PROMPT, X as OBSERVATION_CONTEXT_PROMPT_THREAD, Z as OBSERVATION_CONTINUATION_HINT, F as OBSERVER_SYSTEM_PROMPT, p as ObservationalMemory, f as ObservationalMemoryProcessor, P as TokenCounter, A as WorkingMemoryExtractor, I as buildObserverPrompt, L as buildObserverSystemPrompt, b as combineObservationGroupRanges, x as deriveObservationGroupProvenance, R as extractCurrentTask, z as formatMessagesForObserver, Q as getObservationContextPrompt, d as getObservationsAsOf, B as hasCurrentTaskSection, U as injectAnchorIds, V as optimizeObservationsForContext, W as parseAnchorId, S as parseObservationGroups, H as parseObserverOutput, C as reconcileObservationGroupsFromReflection, w as renderObservationGroupsForReflection, h as resolveAutoModelId, G as stripEphemeralAnchorIds, T as stripObservationGroups, N as summarizeConversation, E as wrapInObservationGroup } from "../src-SlK5VIXE.js";
|
|
@@ -67,7 +67,8 @@ export declare class ObservationTurn {
|
|
|
67
67
|
responseMessageId?: string;
|
|
68
68
|
/** Processor-provided hooks for turn/step lifecycle integration. */
|
|
69
69
|
readonly hooks: ObservationTurnHooks;
|
|
70
|
-
|
|
70
|
+
/** The current call's abort signal. A durable resume continues the turn under a new call, so the processor updates it before each step. */
|
|
71
|
+
abortSignal?: AbortSignal;
|
|
71
72
|
constructor(opts: {
|
|
72
73
|
abortSignal?: AbortSignal;
|
|
73
74
|
om: ObservationalMemory;
|
|
@@ -36035,6 +36035,7 @@ var ObservationTurn = class {
|
|
|
36035
36035
|
responseMessageId;
|
|
36036
36036
|
/** Processor-provided hooks for turn/step lifecycle integration. */
|
|
36037
36037
|
hooks;
|
|
36038
|
+
/** The current call's abort signal. A durable resume continues the turn under a new call, so the processor updates it before each step. */
|
|
36038
36039
|
abortSignal;
|
|
36039
36040
|
constructor(opts) {
|
|
36040
36041
|
this.abortSignal = opts.abortSignal;
|
|
@@ -39437,6 +39438,16 @@ ${formattedMessages}
|
|
|
39437
39438
|
let skipped = 0;
|
|
39438
39439
|
let backoffTriggered = false;
|
|
39439
39440
|
const retentionCounter = typeof retentionFloor === "number" ? new TokenCounter() : null;
|
|
39441
|
+
const tokensById = /* @__PURE__ */ new Map();
|
|
39442
|
+
let remainingTokens = 0;
|
|
39443
|
+
let remainingIds = 0;
|
|
39444
|
+
if (retentionCounter) {
|
|
39445
|
+
const countable = messages.filter((m) => m?.id && m.id !== "om-continuation");
|
|
39446
|
+
remainingTokens = retentionCounter.countMessages(countable);
|
|
39447
|
+
for (const m of countable) tokensById.set(m.id, (tokensById.get(m.id) ?? 0) + retentionCounter.countMessage(m));
|
|
39448
|
+
remainingIds = tokensById.size;
|
|
39449
|
+
}
|
|
39450
|
+
const remainingCount = (tokens, ids) => ids === 0 ? 0 : tokens;
|
|
39440
39451
|
for (const msg of messages) {
|
|
39441
39452
|
if (!msg?.id || msg.id === "om-continuation" || !observedSet.has(msg.id)) continue;
|
|
39442
39453
|
if (preserveSet?.has(msg.id)) {
|
|
@@ -39446,31 +39457,40 @@ ${formattedMessages}
|
|
|
39446
39457
|
const unobservedParts = getUnobservedParts(msg);
|
|
39447
39458
|
const totalParts = msg.content?.parts?.length ?? 0;
|
|
39448
39459
|
if (unobservedParts.length > 0 && unobservedParts.length < totalParts) {
|
|
39460
|
+
const tokensBefore = retentionCounter ? retentionCounter.countMessage(msg) : 0;
|
|
39449
39461
|
msg.content.parts = unobservedParts;
|
|
39462
|
+
if (retentionCounter) {
|
|
39463
|
+
const delta = retentionCounter.countMessage(msg) - tokensBefore;
|
|
39464
|
+
tokensById.set(msg.id, (tokensById.get(msg.id) ?? 0) + delta);
|
|
39465
|
+
if (!idsToRemove.has(msg.id)) remainingTokens += delta;
|
|
39466
|
+
}
|
|
39450
39467
|
continue;
|
|
39451
39468
|
}
|
|
39469
|
+
const alreadyRemoved = idsToRemove.has(msg.id);
|
|
39470
|
+
const msgTokens = tokensById.get(msg.id) ?? 0;
|
|
39452
39471
|
if (retentionCounter && typeof retentionFloor === "number") {
|
|
39453
|
-
const
|
|
39454
|
-
if (
|
|
39472
|
+
const idsIfRemoved = alreadyRemoved ? remainingIds : remainingIds - 1;
|
|
39473
|
+
if (remainingCount(alreadyRemoved ? remainingTokens : remainingTokens - msgTokens, idsIfRemoved) < retentionFloor) {
|
|
39455
39474
|
skipped += 1;
|
|
39456
39475
|
backoffTriggered = true;
|
|
39457
39476
|
break;
|
|
39458
39477
|
}
|
|
39459
39478
|
}
|
|
39479
|
+
if (!alreadyRemoved) {
|
|
39480
|
+
remainingTokens -= msgTokens;
|
|
39481
|
+
remainingIds -= 1;
|
|
39482
|
+
}
|
|
39460
39483
|
idsToRemove.add(msg.id);
|
|
39461
39484
|
removalOrder.push(msg.id);
|
|
39462
39485
|
}
|
|
39463
|
-
if (retentionCounter && typeof retentionFloor === "number" && idsToRemove.size > 0) {
|
|
39464
|
-
|
|
39465
|
-
|
|
39466
|
-
|
|
39467
|
-
|
|
39468
|
-
idsToRemove.delete(restoreId);
|
|
39469
|
-
skipped += 1;
|
|
39470
|
-
backoffTriggered = true;
|
|
39471
|
-
remainingMessages = messages.filter((m) => m?.id && m.id !== "om-continuation" && !idsToRemove.has(m.id));
|
|
39472
|
-
remainingTokens = retentionCounter.countMessages(remainingMessages);
|
|
39486
|
+
if (retentionCounter && typeof retentionFloor === "number" && idsToRemove.size > 0) while (remainingCount(remainingTokens, remainingIds) < retentionFloor && removalOrder.length > 0) {
|
|
39487
|
+
const restoreId = removalOrder.pop();
|
|
39488
|
+
if (idsToRemove.delete(restoreId)) {
|
|
39489
|
+
remainingTokens += tokensById.get(restoreId) ?? 0;
|
|
39490
|
+
remainingIds += 1;
|
|
39473
39491
|
}
|
|
39492
|
+
skipped += 1;
|
|
39493
|
+
backoffTriggered = true;
|
|
39474
39494
|
}
|
|
39475
39495
|
omDebug(`[OM:cleanupActivation] matched=${idsToRemove.size}, skipped=${skipped}, backoffTriggered=${backoffTriggered}`);
|
|
39476
39496
|
return [...idsToRemove];
|
|
@@ -41082,6 +41102,7 @@ var ObservationalMemoryProcessor = class {
|
|
|
41082
41102
|
const observabilityContext = getOmObservabilityContext(args);
|
|
41083
41103
|
state.__omObservabilityContext = observabilityContext;
|
|
41084
41104
|
this.turn.observabilityContext = observabilityContext;
|
|
41105
|
+
this.turn.abortSignal = abortSignal;
|
|
41085
41106
|
this.turn.actorModelContext = actorModelContext;
|
|
41086
41107
|
this.turn.responseMessageId = responseMessageId;
|
|
41087
41108
|
{
|
|
@@ -36013,6 +36013,7 @@ var ObservationTurn = class {
|
|
|
36013
36013
|
responseMessageId;
|
|
36014
36014
|
/** Processor-provided hooks for turn/step lifecycle integration. */
|
|
36015
36015
|
hooks;
|
|
36016
|
+
/** The current call's abort signal. A durable resume continues the turn under a new call, so the processor updates it before each step. */
|
|
36016
36017
|
abortSignal;
|
|
36017
36018
|
constructor(opts) {
|
|
36018
36019
|
this.abortSignal = opts.abortSignal;
|
|
@@ -39415,6 +39416,16 @@ ${formattedMessages}
|
|
|
39415
39416
|
let skipped = 0;
|
|
39416
39417
|
let backoffTriggered = false;
|
|
39417
39418
|
const retentionCounter = typeof retentionFloor === "number" ? new TokenCounter() : null;
|
|
39419
|
+
const tokensById = /* @__PURE__ */ new Map();
|
|
39420
|
+
let remainingTokens = 0;
|
|
39421
|
+
let remainingIds = 0;
|
|
39422
|
+
if (retentionCounter) {
|
|
39423
|
+
const countable = messages.filter((m) => m?.id && m.id !== "om-continuation");
|
|
39424
|
+
remainingTokens = retentionCounter.countMessages(countable);
|
|
39425
|
+
for (const m of countable) tokensById.set(m.id, (tokensById.get(m.id) ?? 0) + retentionCounter.countMessage(m));
|
|
39426
|
+
remainingIds = tokensById.size;
|
|
39427
|
+
}
|
|
39428
|
+
const remainingCount = (tokens, ids) => ids === 0 ? 0 : tokens;
|
|
39418
39429
|
for (const msg of messages) {
|
|
39419
39430
|
if (!msg?.id || msg.id === "om-continuation" || !observedSet.has(msg.id)) continue;
|
|
39420
39431
|
if (preserveSet?.has(msg.id)) {
|
|
@@ -39424,31 +39435,40 @@ ${formattedMessages}
|
|
|
39424
39435
|
const unobservedParts = getUnobservedParts(msg);
|
|
39425
39436
|
const totalParts = msg.content?.parts?.length ?? 0;
|
|
39426
39437
|
if (unobservedParts.length > 0 && unobservedParts.length < totalParts) {
|
|
39438
|
+
const tokensBefore = retentionCounter ? retentionCounter.countMessage(msg) : 0;
|
|
39427
39439
|
msg.content.parts = unobservedParts;
|
|
39440
|
+
if (retentionCounter) {
|
|
39441
|
+
const delta = retentionCounter.countMessage(msg) - tokensBefore;
|
|
39442
|
+
tokensById.set(msg.id, (tokensById.get(msg.id) ?? 0) + delta);
|
|
39443
|
+
if (!idsToRemove.has(msg.id)) remainingTokens += delta;
|
|
39444
|
+
}
|
|
39428
39445
|
continue;
|
|
39429
39446
|
}
|
|
39447
|
+
const alreadyRemoved = idsToRemove.has(msg.id);
|
|
39448
|
+
const msgTokens = tokensById.get(msg.id) ?? 0;
|
|
39430
39449
|
if (retentionCounter && typeof retentionFloor === "number") {
|
|
39431
|
-
const
|
|
39432
|
-
if (
|
|
39450
|
+
const idsIfRemoved = alreadyRemoved ? remainingIds : remainingIds - 1;
|
|
39451
|
+
if (remainingCount(alreadyRemoved ? remainingTokens : remainingTokens - msgTokens, idsIfRemoved) < retentionFloor) {
|
|
39433
39452
|
skipped += 1;
|
|
39434
39453
|
backoffTriggered = true;
|
|
39435
39454
|
break;
|
|
39436
39455
|
}
|
|
39437
39456
|
}
|
|
39457
|
+
if (!alreadyRemoved) {
|
|
39458
|
+
remainingTokens -= msgTokens;
|
|
39459
|
+
remainingIds -= 1;
|
|
39460
|
+
}
|
|
39438
39461
|
idsToRemove.add(msg.id);
|
|
39439
39462
|
removalOrder.push(msg.id);
|
|
39440
39463
|
}
|
|
39441
|
-
if (retentionCounter && typeof retentionFloor === "number" && idsToRemove.size > 0) {
|
|
39442
|
-
|
|
39443
|
-
|
|
39444
|
-
|
|
39445
|
-
|
|
39446
|
-
idsToRemove.delete(restoreId);
|
|
39447
|
-
skipped += 1;
|
|
39448
|
-
backoffTriggered = true;
|
|
39449
|
-
remainingMessages = messages.filter((m) => m?.id && m.id !== "om-continuation" && !idsToRemove.has(m.id));
|
|
39450
|
-
remainingTokens = retentionCounter.countMessages(remainingMessages);
|
|
39464
|
+
if (retentionCounter && typeof retentionFloor === "number" && idsToRemove.size > 0) while (remainingCount(remainingTokens, remainingIds) < retentionFloor && removalOrder.length > 0) {
|
|
39465
|
+
const restoreId = removalOrder.pop();
|
|
39466
|
+
if (idsToRemove.delete(restoreId)) {
|
|
39467
|
+
remainingTokens += tokensById.get(restoreId) ?? 0;
|
|
39468
|
+
remainingIds += 1;
|
|
39451
39469
|
}
|
|
39470
|
+
skipped += 1;
|
|
39471
|
+
backoffTriggered = true;
|
|
39452
39472
|
}
|
|
39453
39473
|
omDebug(`[OM:cleanupActivation] matched=${idsToRemove.size}, skipped=${skipped}, backoffTriggered=${backoffTriggered}`);
|
|
39454
39474
|
return [...idsToRemove];
|
|
@@ -41060,6 +41080,7 @@ var ObservationalMemoryProcessor = class {
|
|
|
41060
41080
|
const observabilityContext = getOmObservabilityContext(args);
|
|
41061
41081
|
state.__omObservabilityContext = observabilityContext;
|
|
41062
41082
|
this.turn.observabilityContext = observabilityContext;
|
|
41083
|
+
this.turn.abortSignal = abortSignal;
|
|
41063
41084
|
this.turn.actorModelContext = actorModelContext;
|
|
41064
41085
|
this.turn.responseMessageId = responseMessageId;
|
|
41065
41086
|
{
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mastra/memory",
|
|
3
|
-
"version": "1.41.4-alpha.
|
|
3
|
+
"version": "1.41.4-alpha.1",
|
|
4
4
|
"description": "",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -73,7 +73,7 @@
|
|
|
73
73
|
"@internal/ai-v7": "0.0.99",
|
|
74
74
|
"@internal/lint": "0.0.152",
|
|
75
75
|
"@internal/types-builder": "0.0.127",
|
|
76
|
-
"@mastra/core": "1.87.0-alpha.
|
|
76
|
+
"@mastra/core": "1.87.0-alpha.8"
|
|
77
77
|
},
|
|
78
78
|
"peerDependencies": {
|
|
79
79
|
"@mastra/core": ">=1.85.1-0 <2.0.0-0"
|