@mastra/memory 1.41.1 → 1.41.2-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.
@@ -3,7 +3,7 @@ name: mastra-memory
3
3
  description: Documentation for @mastra/memory. Use when working with @mastra/memory APIs, configuration, or implementation.
4
4
  metadata:
5
5
  package: "@mastra/memory"
6
- version: "1.41.1"
6
+ version: "1.41.2-alpha.1"
7
7
  ---
8
8
 
9
9
  ## When to use
@@ -1,243 +1,243 @@
1
1
  {
2
- "version": "1.41.1",
2
+ "version": "1.41.2-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-MUc-jGgr.js",
8
- "line": 32196
7
+ "implementation": "dist/src-DGBUSKXy.js",
8
+ "line": 32213
9
9
  },
10
10
  "Extractor": {
11
11
  "types": "dist/processors/observational-memory/extractor.d.ts",
12
- "implementation": "dist/src-MUc-jGgr.js",
12
+ "implementation": "dist/src-DGBUSKXy.js",
13
13
  "line": 23939
14
14
  },
15
15
  "ModelByInputTokens": {
16
16
  "types": "dist/processors/observational-memory/model-by-input-tokens.d.ts",
17
- "implementation": "dist/src-MUc-jGgr.js",
18
- "line": 31979
17
+ "implementation": "dist/src-DGBUSKXy.js",
18
+ "line": 31996
19
19
  },
20
20
  "OBSERVATIONAL_MEMORY_DEFAULTS": {
21
21
  "types": "dist/processors/observational-memory/constants.d.ts",
22
- "implementation": "dist/src-MUc-jGgr.js",
22
+ "implementation": "dist/src-DGBUSKXy.js",
23
23
  "line": 23675
24
24
  },
25
25
  "OBSERVATION_CONTEXT_INSTRUCTIONS": {
26
26
  "types": "dist/processors/observational-memory/constants.d.ts",
27
- "implementation": "dist/src-MUc-jGgr.js",
27
+ "implementation": "dist/src-DGBUSKXy.js",
28
28
  "line": 23736
29
29
  },
30
30
  "OBSERVATION_CONTEXT_PROMPT": {
31
31
  "types": "dist/processors/observational-memory/constants.d.ts",
32
- "implementation": "dist/src-MUc-jGgr.js",
32
+ "implementation": "dist/src-DGBUSKXy.js",
33
33
  "line": 23718
34
34
  },
35
35
  "OBSERVATION_CONTEXT_PROMPT_THREAD": {
36
36
  "types": "dist/processors/observational-memory/constants.d.ts",
37
- "implementation": "dist/src-MUc-jGgr.js",
37
+ "implementation": "dist/src-DGBUSKXy.js",
38
38
  "line": 23723
39
39
  },
40
40
  "OBSERVATION_CONTINUATION_HINT": {
41
41
  "types": "dist/processors/observational-memory/constants.d.ts",
42
- "implementation": "dist/src-MUc-jGgr.js",
42
+ "implementation": "dist/src-DGBUSKXy.js",
43
43
  "line": 23705
44
44
  },
45
45
  "OBSERVER_SYSTEM_PROMPT": {
46
46
  "types": "dist/processors/observational-memory/observer-agent.d.ts",
47
- "implementation": "dist/src-MUc-jGgr.js",
47
+ "implementation": "dist/src-DGBUSKXy.js",
48
48
  "line": 26300
49
49
  },
50
50
  "ObservationalMemory": {
51
51
  "types": "dist/processors/observational-memory/observational-memory.d.ts",
52
- "implementation": "dist/src-MUc-jGgr.js",
53
- "line": 37004
52
+ "implementation": "dist/src-DGBUSKXy.js",
53
+ "line": 37021
54
54
  },
55
55
  "ObservationalMemoryProcessor": {
56
56
  "types": "dist/processors/observational-memory/processor.d.ts",
57
- "implementation": "dist/src-MUc-jGgr.js",
58
- "line": 39739
57
+ "implementation": "dist/src-DGBUSKXy.js",
58
+ "line": 39756
59
59
  },
60
60
  "TokenCounter": {
61
61
  "types": "dist/processors/observational-memory/token-counter.d.ts",
62
- "implementation": "dist/src-MUc-jGgr.js",
63
- "line": 28804
62
+ "implementation": "dist/src-DGBUSKXy.js",
63
+ "line": 28818
64
64
  },
65
65
  "WorkingMemoryExtractor": {
66
66
  "types": "dist/processors/observational-memory/working-memory-extractor.d.ts",
67
- "implementation": "dist/src-MUc-jGgr.js",
68
- "line": 29820
67
+ "implementation": "dist/src-DGBUSKXy.js",
68
+ "line": 29837
69
69
  },
70
70
  "buildObserverPrompt": {
71
71
  "types": "dist/processors/observational-memory/observer-agent.d.ts",
72
- "implementation": "dist/src-MUc-jGgr.js",
73
- "line": 26983
72
+ "implementation": "dist/src-DGBUSKXy.js",
73
+ "line": 26984
74
74
  },
75
75
  "buildObserverSystemPrompt": {
76
76
  "types": "dist/processors/observational-memory/observer-agent.d.ts",
77
- "implementation": "dist/src-MUc-jGgr.js",
77
+ "implementation": "dist/src-DGBUSKXy.js",
78
78
  "line": 26194
79
79
  },
80
80
  "combineObservationGroupRanges": {
81
81
  "types": "dist/processors/observational-memory/observation-groups.d.ts",
82
- "implementation": "dist/src-MUc-jGgr.js",
83
- "line": 30299
82
+ "implementation": "dist/src-DGBUSKXy.js",
83
+ "line": 30316
84
84
  },
85
85
  "deriveObservationGroupProvenance": {
86
86
  "types": "dist/processors/observational-memory/observation-groups.d.ts",
87
- "implementation": "dist/src-MUc-jGgr.js",
88
- "line": 30343
87
+ "implementation": "dist/src-DGBUSKXy.js",
88
+ "line": 30360
89
89
  },
90
90
  "extractCurrentTask": {
91
91
  "types": "dist/processors/observational-memory/observer-agent.d.ts",
92
- "implementation": "dist/src-MUc-jGgr.js",
93
- "line": 27296
92
+ "implementation": "dist/src-DGBUSKXy.js",
93
+ "line": 27297
94
94
  },
95
95
  "formatMessagesForObserver": {
96
96
  "types": "dist/processors/observational-memory/observer-agent.d.ts",
97
- "implementation": "dist/src-MUc-jGgr.js",
97
+ "implementation": "dist/src-DGBUSKXy.js",
98
98
  "line": 26735
99
99
  },
100
100
  "getObservationContextPrompt": {
101
101
  "types": "dist/processors/observational-memory/constants.d.ts",
102
- "implementation": "dist/src-MUc-jGgr.js",
102
+ "implementation": "dist/src-DGBUSKXy.js",
103
103
  "line": 23729
104
104
  },
105
105
  "getObservationsAsOf": {
106
106
  "types": "dist/processors/observational-memory/observation-utils.d.ts",
107
- "implementation": "dist/src-MUc-jGgr.js",
108
- "line": 40046
107
+ "implementation": "dist/src-DGBUSKXy.js",
108
+ "line": 40063
109
109
  },
110
110
  "hasCurrentTaskSection": {
111
111
  "types": "dist/processors/observational-memory/observer-agent.d.ts",
112
- "implementation": "dist/src-MUc-jGgr.js",
113
- "line": 27284
112
+ "implementation": "dist/src-DGBUSKXy.js",
113
+ "line": 27285
114
114
  },
115
115
  "injectAnchorIds": {
116
116
  "types": "dist/processors/observational-memory/anchor-ids.d.ts",
117
- "implementation": "dist/src-MUc-jGgr.js",
117
+ "implementation": "dist/src-DGBUSKXy.js",
118
118
  "line": 24916
119
119
  },
120
120
  "optimizeObservationsForContext": {
121
121
  "types": "dist/processors/observational-memory/observer-agent.d.ts",
122
- "implementation": "dist/src-MUc-jGgr.js",
123
- "line": 27317
122
+ "implementation": "dist/src-DGBUSKXy.js",
123
+ "line": 27318
124
124
  },
125
125
  "parseAnchorId": {
126
126
  "types": "dist/processors/observational-memory/anchor-ids.d.ts",
127
- "implementation": "dist/src-MUc-jGgr.js",
127
+ "implementation": "dist/src-DGBUSKXy.js",
128
128
  "line": 24900
129
129
  },
130
130
  "parseObservationGroups": {
131
131
  "types": "dist/processors/observational-memory/observation-groups.d.ts",
132
- "implementation": "dist/src-MUc-jGgr.js",
133
- "line": 30254
132
+ "implementation": "dist/src-DGBUSKXy.js",
133
+ "line": 30271
134
134
  },
135
135
  "parseObserverOutput": {
136
136
  "types": "dist/processors/observational-memory/observer-agent.d.ts",
137
- "implementation": "dist/src-MUc-jGgr.js",
138
- "line": 26994
137
+ "implementation": "dist/src-DGBUSKXy.js",
138
+ "line": 26995
139
139
  },
140
140
  "reconcileObservationGroupsFromReflection": {
141
141
  "types": "dist/processors/observational-memory/observation-groups.d.ts",
142
- "implementation": "dist/src-MUc-jGgr.js",
143
- "line": 30362
142
+ "implementation": "dist/src-DGBUSKXy.js",
143
+ "line": 30379
144
144
  },
145
145
  "renderObservationGroupsForReflection": {
146
146
  "types": "dist/processors/observational-memory/observation-groups.d.ts",
147
- "implementation": "dist/src-MUc-jGgr.js",
148
- "line": 30328
147
+ "implementation": "dist/src-DGBUSKXy.js",
148
+ "line": 30345
149
149
  },
150
150
  "resolveAutoModelId": {
151
151
  "types": "dist/processors/observational-memory/auto-model.d.ts",
152
- "implementation": "dist/src-MUc-jGgr.js",
153
- "line": 32216
152
+ "implementation": "dist/src-DGBUSKXy.js",
153
+ "line": 32233
154
154
  },
155
155
  "stripEphemeralAnchorIds": {
156
156
  "types": "dist/processors/observational-memory/anchor-ids.d.ts",
157
- "implementation": "dist/src-MUc-jGgr.js",
157
+ "implementation": "dist/src-DGBUSKXy.js",
158
158
  "line": 24939
159
159
  },
160
160
  "stripObservationGroups": {
161
161
  "types": "dist/processors/observational-memory/observation-groups.d.ts",
162
- "implementation": "dist/src-MUc-jGgr.js",
163
- "line": 30271
162
+ "implementation": "dist/src-DGBUSKXy.js",
163
+ "line": 30288
164
164
  },
165
165
  "summarizeConversation": {
166
166
  "types": "dist/processors/observational-memory/summarize.d.ts",
167
- "implementation": "dist/src-MUc-jGgr.js",
168
- "line": 29435
167
+ "implementation": "dist/src-DGBUSKXy.js",
168
+ "line": 29449
169
169
  },
170
170
  "wrapInObservationGroup": {
171
171
  "types": "dist/processors/observational-memory/observation-groups.d.ts",
172
- "implementation": "dist/src-MUc-jGgr.js",
173
- "line": 30225
172
+ "implementation": "dist/src-DGBUSKXy.js",
173
+ "line": 30242
174
174
  },
175
175
  "KnowledgeSemanticIndexCoordinator": {
176
176
  "types": "dist/removed-subconscious.d.ts",
177
- "implementation": "dist/src-MUc-jGgr.js",
178
- "line": 29867
177
+ "implementation": "dist/src-DGBUSKXy.js",
178
+ "line": 29884
179
179
  },
180
180
  "Memory": {
181
181
  "types": "dist/index.d.ts",
182
- "implementation": "dist/src-MUc-jGgr.js",
183
- "line": 40257
182
+ "implementation": "dist/src-DGBUSKXy.js",
183
+ "line": 40274
184
184
  },
185
185
  "SUMMARIZE_THREAD_DEFAULTS": {
186
186
  "types": "dist/processors/observational-memory/summarize.d.ts",
187
- "implementation": "dist/src-MUc-jGgr.js",
188
- "line": 29391
187
+ "implementation": "dist/src-DGBUSKXy.js",
188
+ "line": 29405
189
189
  },
190
190
  "StaleKnowledgeSemanticIndexError": {
191
191
  "types": "dist/removed-subconscious.d.ts",
192
- "implementation": "dist/src-MUc-jGgr.js",
193
- "line": 29873
192
+ "implementation": "dist/src-DGBUSKXy.js",
193
+ "line": 29890
194
194
  },
195
195
  "Subconscious": {
196
196
  "types": "dist/removed-subconscious.d.ts",
197
- "implementation": "dist/src-MUc-jGgr.js",
198
- "line": 29861
197
+ "implementation": "dist/src-DGBUSKXy.js",
198
+ "line": 29878
199
199
  },
200
200
  "WORKING_MEMORY_STATE_ID": {
201
201
  "types": "dist/processors/working-memory-state/processor.d.ts",
202
- "implementation": "dist/src-MUc-jGgr.js",
203
- "line": 32025
202
+ "implementation": "dist/src-DGBUSKXy.js",
203
+ "line": 32042
204
204
  },
205
205
  "WORKING_MEMORY_STATE_PROCESSOR_ID": {
206
206
  "types": "dist/processors/working-memory-state/processor.d.ts",
207
- "implementation": "dist/src-MUc-jGgr.js",
208
- "line": 32026
207
+ "implementation": "dist/src-DGBUSKXy.js",
208
+ "line": 32043
209
209
  },
210
210
  "WorkingMemoryStateProcessor": {
211
211
  "types": "dist/processors/working-memory-state/processor.d.ts",
212
- "implementation": "dist/src-MUc-jGgr.js",
213
- "line": 32027
212
+ "implementation": "dist/src-DGBUSKXy.js",
213
+ "line": 32044
214
214
  },
215
215
  "deepMergeWorkingMemory": {
216
216
  "types": "dist/tools/working-memory.d.ts",
217
- "implementation": "dist/src-MUc-jGgr.js",
218
- "line": 29514
217
+ "implementation": "dist/src-DGBUSKXy.js",
218
+ "line": 29528
219
219
  },
220
220
  "extractWorkingMemoryContent": {
221
221
  "types": "dist/index.d.ts",
222
- "implementation": "dist/src-MUc-jGgr.js",
223
- "line": 40111
222
+ "implementation": "dist/src-DGBUSKXy.js",
223
+ "line": 40128
224
224
  },
225
225
  "extractWorkingMemoryTags": {
226
226
  "types": "dist/index.d.ts",
227
- "implementation": "dist/src-MUc-jGgr.js",
228
- "line": 40079
227
+ "implementation": "dist/src-DGBUSKXy.js",
228
+ "line": 40096
229
229
  },
230
230
  "removeWorkingMemoryTags": {
231
231
  "types": "dist/index.d.ts",
232
- "implementation": "dist/src-MUc-jGgr.js",
233
- "line": 40092
232
+ "implementation": "dist/src-DGBUSKXy.js",
233
+ "line": 40109
234
234
  }
235
235
  },
236
236
  "modules": {
237
237
  "processors": {
238
238
  "index": "dist/processors/index.js",
239
239
  "chunks": [
240
- "src-MUc-jGgr.js"
240
+ "src-DGBUSKXy.js"
241
241
  ]
242
242
  }
243
243
  }
@@ -577,6 +577,20 @@ The same discovery is available over HTTP as `GET /agents/:agentId/suspended-run
577
577
 
578
578
  > **Note:** Suspended runs only survive restarts when your Mastra instance is configured with a persistent [storage provider](https://mastra.ai/docs/storage). The default in-memory store loses snapshots when the process exits.
579
579
 
580
+ ### Recovering a decision after a crash
581
+
582
+ When `approveToolCall()`, `declineToolCall()`, or `resumeStream()` runs, the run is claimed in storage together with the decision or resume data and the targeted `toolCallId`. If the process handling the resume stops before the run finishes, call `recoverResume()` from any process to finish the run with that stored decision:
583
+
584
+ ```typescript
585
+ const stream = await agent.recoverResume({ runId })
586
+
587
+ for await (const chunk of stream.textStream) process.stdout.write(chunk)
588
+ ```
589
+
590
+ `recoverResume()` takes over a claim once it's abandoned: claimed but not started for 60 seconds, or, on storage with run fencing, started and its lease not renewed for 60 seconds. Before that, it rejects with `AGENT_RESUME_ALREADY_CLAIMED`. For a run that no resume has claimed, it rejects with `AGENT_RESUME_NOTHING_TO_RECOVER`.
591
+
592
+ > **Warning:** The resumed tool call runs again. A claim counts as abandoned by its age, so a process that stalled for 60 seconds may still be running the tool when the recovery runs it. Make tools with side effects safe to repeat, for example with an idempotency key.
593
+
580
594
  ## Tool approval: Supervisor agents
581
595
 
582
596
  A [supervisor agent](https://mastra.ai/docs/subagents) coordinates multiple subagents using `.stream()` or `.generate()`. When a subagent calls a tool that requires approval, the request propagates up through the delegation chain and surfaces at the supervisor level:
@@ -123,6 +123,8 @@ The `_background` override only _modifies_ tools the developer has already opted
123
123
 
124
124
  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.
125
125
 
126
+ A timeout of `0` means no timeout. Set `timeoutMs: 0` on a tool or agent tool entry, or `defaultTimeoutMs: 0` on the manager, for tasks that should run until they finish or are cancelled.
127
+
126
128
  If the agent has `backgroundTasks.disabled: true`, every tool call runs synchronously regardless of the layers above.
127
129
 
128
130
  ## Background tasks related stream chunks
@@ -191,7 +193,7 @@ export const mastra = new Mastra({
191
193
 
192
194
  When a deferred task finishes and no `untilIdle` stream is open for its thread, Mastra sends the agent a `notification` signal with the tag `background-task`. The signal names the tool call and task, and tells the agent the result is now on the tool call. It doesn't copy the result into the prompt. This covers a `stream()` call without `untilIdle`, a client that disconnected, and a task resumed after it [suspended](#suspending-and-resuming).
193
195
 
194
- - If the thread is idle, the signal wakes the agent, which runs a turn on the thread to report the outcome. The woken run uses the request context of the run that dispatched the task, so a model, instructions, or memory resolved from that context resolve the same way.
196
+ - If the thread is idle, the signal wakes the agent, which runs a turn on the thread to report the outcome. The woken run uses the request context of the run that dispatched the task, so a model, instructions, or memory resolved from that context resolve the same way. This also holds when the agent that claimed the thread runs on another server: the context is sent along with the signal, minus the auth token, the signed-in user, and any values that can't be sent as JSON or are too large to serialize. That server's run keeps its own auth token and user.
195
197
  - If a run is already active on the thread, including the run that dispatched the task, the signal is delivered to that run's next model request. If that run ends without making another request, the signal runs as its own turn.
196
198
  - If another agent's run holds the thread, for example while it waits for a tool approval, the signal waits and wakes the agent once that run ends.
197
199
  - If an `untilIdle` stream is open for the thread, no signal is sent, because that stream runs its own follow-up turn.
package/dist/index.cjs CHANGED
@@ -1,5 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_src = require("./src-DiQcqLOH.cjs");
2
+ const require_src = require("./src-D49WAwNu.cjs");
3
3
  let _mastra_core_processors = require("@mastra/core/processors");
4
4
  exports.AUTO_MODEL_BY_PROVIDER = require_src.AUTO_MODEL_BY_PROVIDER;
5
5
  exports.Extractor = require_src.Extractor;
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- export { d as AUTO_MODEL_BY_PROVIDER, U as Extractor, w as KnowledgeSemanticIndexCoordinator, t as Memory, n as MessageHistory, g as ModelByInputTokens, k as SUMMARIZE_THREAD_DEFAULTS, r as SemanticRecall, T as StaleKnowledgeSemanticIndexError, E as Subconscious, p as WORKING_MEMORY_STATE_ID, m as WORKING_MEMORY_STATE_PROCESSOR_ID, i as WorkingMemory, D as WorkingMemoryExtractor, h as WorkingMemoryStateProcessor, O as deepMergeWorkingMemory, a as extractWorkingMemoryContent, o as extractWorkingMemoryTags, c as getObservationsAsOf, s as removeWorkingMemoryTags, f as resolveAutoModelId, A as summarizeConversation } from "./src-MUc-jGgr.js";
1
+ export { d as AUTO_MODEL_BY_PROVIDER, U as Extractor, w as KnowledgeSemanticIndexCoordinator, t as Memory, n as MessageHistory, g as ModelByInputTokens, k as SUMMARIZE_THREAD_DEFAULTS, r as SemanticRecall, T as StaleKnowledgeSemanticIndexError, E as Subconscious, p as WORKING_MEMORY_STATE_ID, m as WORKING_MEMORY_STATE_PROCESSOR_ID, i as WorkingMemory, D as WorkingMemoryExtractor, h as WorkingMemoryStateProcessor, O as deepMergeWorkingMemory, a as extractWorkingMemoryContent, o as extractWorkingMemoryTags, c as getObservationsAsOf, s as removeWorkingMemoryTags, f as resolveAutoModelId, A as summarizeConversation } from "./src-DGBUSKXy.js";
@@ -1,5 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_src = require("../src-DiQcqLOH.cjs");
2
+ const require_src = require("../src-D49WAwNu.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;
@@ -1 +1 @@
1
- export { d as AUTO_MODEL_BY_PROVIDER, U as Extractor, g as ModelByInputTokens, W as OBSERVATIONAL_MEMORY_DEFAULTS, G as OBSERVATION_CONTEXT_INSTRUCTIONS, K as OBSERVATION_CONTEXT_PROMPT, q as OBSERVATION_CONTEXT_PROMPT_THREAD, J as OBSERVATION_CONTINUATION_HINT, M as OBSERVER_SYSTEM_PROMPT, u as ObservationalMemory, l as ObservationalMemoryProcessor, j as TokenCounter, D as WorkingMemoryExtractor, N as buildObserverPrompt, P as buildObserverSystemPrompt, _ as combineObservationGroupRanges, v as deriveObservationGroupProvenance, F as extractCurrentTask, I as formatMessagesForObserver, Y as getObservationContextPrompt, c as getObservationsAsOf, L as hasCurrentTaskSection, B as injectAnchorIds, R as optimizeObservationsForContext, V as parseAnchorId, y as parseObservationGroups, z as parseObserverOutput, b as reconcileObservationGroupsFromReflection, x as renderObservationGroupsForReflection, f as resolveAutoModelId, H as stripEphemeralAnchorIds, S as stripObservationGroups, A as summarizeConversation, C as wrapInObservationGroup } from "../src-MUc-jGgr.js";
1
+ export { d as AUTO_MODEL_BY_PROVIDER, U as Extractor, g as ModelByInputTokens, W as OBSERVATIONAL_MEMORY_DEFAULTS, G as OBSERVATION_CONTEXT_INSTRUCTIONS, K as OBSERVATION_CONTEXT_PROMPT, q as OBSERVATION_CONTEXT_PROMPT_THREAD, J as OBSERVATION_CONTINUATION_HINT, M as OBSERVER_SYSTEM_PROMPT, u as ObservationalMemory, l as ObservationalMemoryProcessor, j as TokenCounter, D as WorkingMemoryExtractor, N as buildObserverPrompt, P as buildObserverSystemPrompt, _ as combineObservationGroupRanges, v as deriveObservationGroupProvenance, F as extractCurrentTask, I as formatMessagesForObserver, Y as getObservationContextPrompt, c as getObservationsAsOf, L as hasCurrentTaskSection, B as injectAnchorIds, R as optimizeObservationsForContext, V as parseAnchorId, y as parseObservationGroups, z as parseObserverOutput, b as reconcileObservationGroupsFromReflection, x as renderObservationGroupsForReflection, f as resolveAutoModelId, H as stripEphemeralAnchorIds, S as stripObservationGroups, A as summarizeConversation, C as wrapInObservationGroup } from "../src-DGBUSKXy.js";
@@ -1 +1 @@
1
- {"version":3,"file":"observer-agent.d.ts","sourceRoot":"","sources":["../../../src/processors/observational-memory/observer-agent.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAE1D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAKpD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAgB7C;;;;;;;;;;GAUG;AACH,MAAM,MAAM,wBAAwB,GAAG,OAAO,GAAG,MAAM,EAAE,CAAC;AAE1D,KAAK,qBAAqB,GAAG;IAC3B,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,gBAAgB,CAAC,EAAE,wBAAwB,CAAC;IAC5C,kHAAkH;IAClH,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,gCAAgC,2ucAuPoE,CAAC;AAElH;;;GAGG;AAEH;;GAEG;AACH,eAAO,MAAM,2BAA2B,QAA8B,CAAC;AAEvE;;;;;;;;;GASG;AACH,wBAAgB,yBAAyB,CAAC,UAAU,CAAC,EAAE,SAAS,SAAS,CAAC,GAAG,CAAC,EAAE,GAAG,MAAM,CA4CxF;AAED;;;GAGG;AACH,eAAO,MAAM,mBAAmB,6sDAgByD,CAAC;AAE1F;;;;;;;GAOG;AACH,wBAAgB,yBAAyB,CACvC,WAAW,GAAE,OAAe,EAC5B,WAAW,CAAC,EAAE,MAAM,EACpB,kBAAkB,GAAE,OAAe,EACnC,UAAU,CAAC,EAAE,SAAS,SAAS,CAAC,GAAG,CAAC,EAAE,GACrC,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;AA8DD;;GAEG;AACH,wBAAgB,wBAAwB,CAAC,YAAY,EAAE,MAAM,GAAG,MAAM,CAWrE;AAsBD;;;;;;GAMG;AACH,wBAAgB,sBAAsB,CAAC,YAAY,EAAE,MAAM,GAAG,MAAM,CA2CnE;AAuID,wBAAgB,0BAA0B,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAIhE;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,MAAM,EAAE,YAAY,SAAM,GAAG,MAAM,CA2BjF;AAED;;;GAGG;AACH,wBAAgB,qBAAqB,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAenE;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,YAAY,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAUtE;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,8BAA8B,CAAC,YAAY,EAAE,MAAM,GAAG,MAAM,CAsB3E"}
1
+ {"version":3,"file":"observer-agent.d.ts","sourceRoot":"","sources":["../../../src/processors/observational-memory/observer-agent.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAE1D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAKpD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAgB7C;;;;;;;;;;GAUG;AACH,MAAM,MAAM,wBAAwB,GAAG,OAAO,GAAG,MAAM,EAAE,CAAC;AAE1D,KAAK,qBAAqB,GAAG;IAC3B,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,gBAAgB,CAAC,EAAE,wBAAwB,CAAC;IAC5C,kHAAkH;IAClH,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,gCAAgC,2ucAuPoE,CAAC;AAElH;;;GAGG;AAEH;;GA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AAE,OAAO,CAAC,CAAC;CAChD,GACA,MAAM,CAGR;AAWD,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,MAAM,EAAE,UAAU,GAAE,SAAS,SAAS,CAAC,GAAG,CAAC,EAAO,GAAG,cAAc,CA4B9G;AAED;;GAEG;AACH,UAAU,mBAAmB;IAC3B,YAAY,EAAE,MAAM,CAAC;IACrB,WAAW,EAAE,MAAM,CAAC;IACpB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,WAAW,EAAE,MAAM,CAAC;CACrB;AAED;;;GAGG;AACH,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,MAAM,GAAG,mBAAmB,CAyD1E;AA8DD;;GAEG;AACH,wBAAgB,wBAAwB,CAAC,YAAY,EAAE,MAAM,GAAG,MAAM,CAWrE;AAsBD;;;;;;GAMG;AACH,wBAAgB,sBAAsB,CAAC,YAAY,EAAE,MAAM,GAAG,MAAM,CA2CnE;AAuID,wBAAgB,0BAA0B,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAIhE;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,MAAM,EAAE,YAAY,SAAM,GAAG,MAAM,CA2BjF;AAED;;;GAGG;AACH,wBAAgB,qBAAqB,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAenE;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,YAAY,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAUtE;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,8BAA8B,CAAC,YAAY,EAAE,MAAM,GAAG,MAAM,CAsB3E"}
@@ -1 +1 @@
1
- {"version":3,"file":"token-counter.d.ts","sourceRoot":"","sources":["../../../src/processors/observational-memory/token-counter.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAkB1D,MAAM,MAAM,wBAAwB,GAAG;IACrC,QAAQ,CAAC,EAAE,MAAM,CAA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,kBAAkB,CAAO;IAEjD,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,uBAAuB,CAAM;IAErD,YAAY,OAAO,CAAC,EAAE,mBAAmB,EAGxC;IAED,mBAAmB,CAAC,CAAC,EAAE,KAAK,EAAE,MAAM,GAAG,wBAAwB,GAAG,SAAS,EAAE,EAAE,EAAE,MAAM,CAAC,GAAG,CAAC,CAI3F;IAED,OAAO,CAAC,eAAe;IAIvB;;OAEG;IACH,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAGhC;IAED,OAAO,CAAC,yBAAyB;IAkBjC,OAAO,CAAC,8BAA8B;IAiBtC,OAAO,CAAC,4BAA4B;IAkBpC,OAAO,CAAC,iCAAiC;IAOzC,OAAO,CAAC,gCAAgC;IA4IxC,OAAO,CAAC,wBAAwB;IAsEhC,OAAO,CAAC,mBAAmB;IAI3B,OAAO,CAAC,2BAA2B;IAInC,OAAO,CAAC,uBAAuB;IAkC/B,OAAO,CAAC,iCAAiC;YAiC3B,oCAAoC;YAyBpC,wBAAwB;IAyFtC;;;;;OAKG;IACH,OAAO,CAAC,sBAAsB;IAuB9B,OAAO,CAAC,sBAAsB;IAwI9B;;;;;;;OAOG;IACH,YAAY,CAAC,OAAO,EAAE,eAAe,GAAG,MAAM,CA+B7C;IAEK,iBAAiB,CAAC,OAAO,EAAE,eAAe,GAAG,OAAO,CAAC,MAAM,CAAC,CA+BjE;IAED;;OAEG;IACH,aAAa,CAAC,QAAQ,EAAE,eAAe,EAAE,GAAG,MAAM,CAQjD;IAEK,kBAAkB,CAAC,QAAQ,EAAE,eAAe,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC,CAKrE;IAED;;OAEG;IACH,iBAAiB,CAAC,YAAY,EAAE,MAAM,GAAG,MAAM,CAE9C;CACF"}
@@ -26803,6 +26803,7 @@ function buildObserverHistoryMessage(messages, options) {
26803
26803
  }
26804
26804
  /** Truncate a string to maxLen characters, appending a note if truncated. */
26805
26805
  function maybeTruncate(str, maxLen) {
26806
+ if (typeof str !== "string") return "";
26806
26807
  if (!maxLen || str.length <= maxLen) return str;
26807
26808
  const truncated = safeSlice(str, maxLen);
26808
26809
  return `${truncated}\n... [truncated ${str.length - truncated.length} characters]`;
@@ -28099,6 +28100,19 @@ function buildEstimateKey(kind, text) {
28099
28100
  function resolveEstimatorId() {
28100
28101
  return "tokenx";
28101
28102
  }
28103
+ const ATTACHMENT_CONTENT_PART_TYPES = /* @__PURE__ */ new Set([
28104
+ "image",
28105
+ "image-data",
28106
+ "media",
28107
+ "audio",
28108
+ "file-data"
28109
+ ]);
28110
+ /** Mirrors the parts countMultimodalToolResultContent counts as attachments. */
28111
+ function isAttachmentContentPart(item) {
28112
+ if (!item || typeof item !== "object") return false;
28113
+ const contentPart = item;
28114
+ return ATTACHMENT_CONTENT_PART_TYPES.has(contentPart.type) && typeof contentPart.data === "string";
28115
+ }
28102
28116
  function isTokenEstimateEntry(value) {
28103
28117
  if (!value || typeof value !== "object") return false;
28104
28118
  const entry = value;
@@ -28891,12 +28905,12 @@ var TokenCounter = class TokenCounter {
28891
28905
  }
28892
28906
  countMultimodalToolResultContent(part, toolResult) {
28893
28907
  if (!toolResult || typeof toolResult !== "object") return;
28908
+ const output = toolResult;
28909
+ const content = output.type === "content" && Array.isArray(output.value) ? output.value : output.content;
28910
+ if (!Array.isArray(content) || !content.some(isAttachmentContentPart)) return;
28894
28911
  const resultKey = buildEstimateKey("tool-result-multimodal-content-source", JSON.stringify(toolResult));
28895
28912
  const cached = this.multimodalToolResultCounts.get(part);
28896
28913
  if (cached?.resultKey === resultKey) return cached.tokens;
28897
- const output = toolResult;
28898
- const content = output.type === "content" && Array.isArray(output.value) ? output.value : output.content;
28899
- if (!Array.isArray(content)) return;
28900
28914
  let hasAttachment = false;
28901
28915
  let tokens = 0;
28902
28916
  const cacheParts = [];
@@ -29745,7 +29759,10 @@ const __experimental_updateWorkingMemoryToolVNext = (config) => {
29745
29759
  }
29746
29760
  const workingMemory = workingMemoryInput.newMemory || "";
29747
29761
  if (!workingMemoryInput.updateReason) workingMemoryInput.updateReason = `append-new-memory`;
29748
- if (workingMemoryInput.searchString && config.workingMemory?.scope === `resource` && workingMemoryInput.updateReason === `replace-irrelevant-memory`) workingMemoryInput.searchString = void 0;
29762
+ if (workingMemoryInput.searchString && scope === "resource" && workingMemoryInput.updateReason === `replace-irrelevant-memory`) return {
29763
+ success: false,
29764
+ reason: `working memory is shared across all conversations for this resource, so it can't be replaced just because it isn't relevant to this conversation. Use clarify-existing-memory to correct it, or append-new-memory to add to it.`
29765
+ };
29749
29766
  if (workingMemoryInput.updateReason === `append-new-memory` && workingMemoryInput.searchString) workingMemoryInput.searchString = void 0;
29750
29767
  if (workingMemoryInput.updateReason !== `append-new-memory` && !workingMemoryInput.searchString) return {
29751
29768
  success: false,
@@ -42794,4 +42811,4 @@ Object.defineProperty(exports, "wrapInObservationGroup", {
42794
42811
  }
42795
42812
  });
42796
42813
 
42797
- //# sourceMappingURL=src-DiQcqLOH.cjs.map
42814
+ //# sourceMappingURL=src-D49WAwNu.cjs.map