@mastra/memory 1.41.3-alpha.2 → 1.41.3-alpha.4

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.3-alpha.2"
6
+ version: "1.41.3-alpha.4"
7
7
  ---
8
8
 
9
9
  ## When to use
@@ -1,243 +1,243 @@
1
1
  {
2
- "version": "1.41.3-alpha.2",
2
+ "version": "1.41.3-alpha.4",
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-CRmfe-8x.js",
8
- "line": 32808
7
+ "implementation": "dist/src-TRQ73bGO.js",
8
+ "line": 32819
9
9
  },
10
10
  "Extractor": {
11
11
  "types": "dist/processors/observational-memory/extractor.d.ts",
12
- "implementation": "dist/src-CRmfe-8x.js",
12
+ "implementation": "dist/src-TRQ73bGO.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-CRmfe-8x.js",
18
- "line": 32591
17
+ "implementation": "dist/src-TRQ73bGO.js",
18
+ "line": 32602
19
19
  },
20
20
  "OBSERVATIONAL_MEMORY_DEFAULTS": {
21
21
  "types": "dist/processors/observational-memory/constants.d.ts",
22
- "implementation": "dist/src-CRmfe-8x.js",
22
+ "implementation": "dist/src-TRQ73bGO.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-CRmfe-8x.js",
27
+ "implementation": "dist/src-TRQ73bGO.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-CRmfe-8x.js",
32
+ "implementation": "dist/src-TRQ73bGO.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-CRmfe-8x.js",
37
+ "implementation": "dist/src-TRQ73bGO.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-CRmfe-8x.js",
42
+ "implementation": "dist/src-TRQ73bGO.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-CRmfe-8x.js",
48
- "line": 26793
47
+ "implementation": "dist/src-TRQ73bGO.js",
48
+ "line": 26804
49
49
  },
50
50
  "ObservationalMemory": {
51
51
  "types": "dist/processors/observational-memory/observational-memory.d.ts",
52
- "implementation": "dist/src-CRmfe-8x.js",
53
- "line": 37616
52
+ "implementation": "dist/src-TRQ73bGO.js",
53
+ "line": 37893
54
54
  },
55
55
  "ObservationalMemoryProcessor": {
56
56
  "types": "dist/processors/observational-memory/processor.d.ts",
57
- "implementation": "dist/src-CRmfe-8x.js",
58
- "line": 40364
57
+ "implementation": "dist/src-TRQ73bGO.js",
58
+ "line": 40641
59
59
  },
60
60
  "TokenCounter": {
61
61
  "types": "dist/processors/observational-memory/token-counter.d.ts",
62
- "implementation": "dist/src-CRmfe-8x.js",
63
- "line": 29310
62
+ "implementation": "dist/src-TRQ73bGO.js",
63
+ "line": 29321
64
64
  },
65
65
  "WorkingMemoryExtractor": {
66
66
  "types": "dist/processors/observational-memory/working-memory-extractor.d.ts",
67
- "implementation": "dist/src-CRmfe-8x.js",
68
- "line": 30329
67
+ "implementation": "dist/src-TRQ73bGO.js",
68
+ "line": 30340
69
69
  },
70
70
  "buildObserverPrompt": {
71
71
  "types": "dist/processors/observational-memory/observer-agent.d.ts",
72
- "implementation": "dist/src-CRmfe-8x.js",
73
- "line": 27477
72
+ "implementation": "dist/src-TRQ73bGO.js",
73
+ "line": 27488
74
74
  },
75
75
  "buildObserverSystemPrompt": {
76
76
  "types": "dist/processors/observational-memory/observer-agent.d.ts",
77
- "implementation": "dist/src-CRmfe-8x.js",
78
- "line": 26687
77
+ "implementation": "dist/src-TRQ73bGO.js",
78
+ "line": 26698
79
79
  },
80
80
  "combineObservationGroupRanges": {
81
81
  "types": "dist/processors/observational-memory/observation-groups.d.ts",
82
- "implementation": "dist/src-CRmfe-8x.js",
83
- "line": 30911
82
+ "implementation": "dist/src-TRQ73bGO.js",
83
+ "line": 30922
84
84
  },
85
85
  "deriveObservationGroupProvenance": {
86
86
  "types": "dist/processors/observational-memory/observation-groups.d.ts",
87
- "implementation": "dist/src-CRmfe-8x.js",
88
- "line": 30955
87
+ "implementation": "dist/src-TRQ73bGO.js",
88
+ "line": 30966
89
89
  },
90
90
  "extractCurrentTask": {
91
91
  "types": "dist/processors/observational-memory/observer-agent.d.ts",
92
- "implementation": "dist/src-CRmfe-8x.js",
93
- "line": 27790
92
+ "implementation": "dist/src-TRQ73bGO.js",
93
+ "line": 27801
94
94
  },
95
95
  "formatMessagesForObserver": {
96
96
  "types": "dist/processors/observational-memory/observer-agent.d.ts",
97
- "implementation": "dist/src-CRmfe-8x.js",
98
- "line": 27228
97
+ "implementation": "dist/src-TRQ73bGO.js",
98
+ "line": 27239
99
99
  },
100
100
  "getObservationContextPrompt": {
101
101
  "types": "dist/processors/observational-memory/constants.d.ts",
102
- "implementation": "dist/src-CRmfe-8x.js",
102
+ "implementation": "dist/src-TRQ73bGO.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-CRmfe-8x.js",
108
- "line": 40704
107
+ "implementation": "dist/src-TRQ73bGO.js",
108
+ "line": 40981
109
109
  },
110
110
  "hasCurrentTaskSection": {
111
111
  "types": "dist/processors/observational-memory/observer-agent.d.ts",
112
- "implementation": "dist/src-CRmfe-8x.js",
113
- "line": 27778
112
+ "implementation": "dist/src-TRQ73bGO.js",
113
+ "line": 27789
114
114
  },
115
115
  "injectAnchorIds": {
116
116
  "types": "dist/processors/observational-memory/anchor-ids.d.ts",
117
- "implementation": "dist/src-CRmfe-8x.js",
118
- "line": 25409
117
+ "implementation": "dist/src-TRQ73bGO.js",
118
+ "line": 25420
119
119
  },
120
120
  "optimizeObservationsForContext": {
121
121
  "types": "dist/processors/observational-memory/observer-agent.d.ts",
122
- "implementation": "dist/src-CRmfe-8x.js",
123
- "line": 27811
122
+ "implementation": "dist/src-TRQ73bGO.js",
123
+ "line": 27822
124
124
  },
125
125
  "parseAnchorId": {
126
126
  "types": "dist/processors/observational-memory/anchor-ids.d.ts",
127
- "implementation": "dist/src-CRmfe-8x.js",
128
- "line": 25393
127
+ "implementation": "dist/src-TRQ73bGO.js",
128
+ "line": 25404
129
129
  },
130
130
  "parseObservationGroups": {
131
131
  "types": "dist/processors/observational-memory/observation-groups.d.ts",
132
- "implementation": "dist/src-CRmfe-8x.js",
133
- "line": 30866
132
+ "implementation": "dist/src-TRQ73bGO.js",
133
+ "line": 30877
134
134
  },
135
135
  "parseObserverOutput": {
136
136
  "types": "dist/processors/observational-memory/observer-agent.d.ts",
137
- "implementation": "dist/src-CRmfe-8x.js",
138
- "line": 27488
137
+ "implementation": "dist/src-TRQ73bGO.js",
138
+ "line": 27499
139
139
  },
140
140
  "reconcileObservationGroupsFromReflection": {
141
141
  "types": "dist/processors/observational-memory/observation-groups.d.ts",
142
- "implementation": "dist/src-CRmfe-8x.js",
143
- "line": 30974
142
+ "implementation": "dist/src-TRQ73bGO.js",
143
+ "line": 30985
144
144
  },
145
145
  "renderObservationGroupsForReflection": {
146
146
  "types": "dist/processors/observational-memory/observation-groups.d.ts",
147
- "implementation": "dist/src-CRmfe-8x.js",
148
- "line": 30940
147
+ "implementation": "dist/src-TRQ73bGO.js",
148
+ "line": 30951
149
149
  },
150
150
  "resolveAutoModelId": {
151
151
  "types": "dist/processors/observational-memory/auto-model.d.ts",
152
- "implementation": "dist/src-CRmfe-8x.js",
153
- "line": 32828
152
+ "implementation": "dist/src-TRQ73bGO.js",
153
+ "line": 32839
154
154
  },
155
155
  "stripEphemeralAnchorIds": {
156
156
  "types": "dist/processors/observational-memory/anchor-ids.d.ts",
157
- "implementation": "dist/src-CRmfe-8x.js",
158
- "line": 25432
157
+ "implementation": "dist/src-TRQ73bGO.js",
158
+ "line": 25443
159
159
  },
160
160
  "stripObservationGroups": {
161
161
  "types": "dist/processors/observational-memory/observation-groups.d.ts",
162
- "implementation": "dist/src-CRmfe-8x.js",
163
- "line": 30883
162
+ "implementation": "dist/src-TRQ73bGO.js",
163
+ "line": 30894
164
164
  },
165
165
  "summarizeConversation": {
166
166
  "types": "dist/processors/observational-memory/summarize.d.ts",
167
- "implementation": "dist/src-CRmfe-8x.js",
168
- "line": 29941
167
+ "implementation": "dist/src-TRQ73bGO.js",
168
+ "line": 29952
169
169
  },
170
170
  "wrapInObservationGroup": {
171
171
  "types": "dist/processors/observational-memory/observation-groups.d.ts",
172
- "implementation": "dist/src-CRmfe-8x.js",
173
- "line": 30837
172
+ "implementation": "dist/src-TRQ73bGO.js",
173
+ "line": 30848
174
174
  },
175
175
  "KnowledgeSemanticIndexCoordinator": {
176
176
  "types": "dist/removed-subconscious.d.ts",
177
- "implementation": "dist/src-CRmfe-8x.js",
178
- "line": 30435
177
+ "implementation": "dist/src-TRQ73bGO.js",
178
+ "line": 30446
179
179
  },
180
180
  "Memory": {
181
181
  "types": "dist/index.d.ts",
182
- "implementation": "dist/src-CRmfe-8x.js",
183
- "line": 40935
182
+ "implementation": "dist/src-TRQ73bGO.js",
183
+ "line": 41212
184
184
  },
185
185
  "SUMMARIZE_THREAD_DEFAULTS": {
186
186
  "types": "dist/processors/observational-memory/summarize.d.ts",
187
- "implementation": "dist/src-CRmfe-8x.js",
188
- "line": 29897
187
+ "implementation": "dist/src-TRQ73bGO.js",
188
+ "line": 29908
189
189
  },
190
190
  "StaleKnowledgeSemanticIndexError": {
191
191
  "types": "dist/removed-subconscious.d.ts",
192
- "implementation": "dist/src-CRmfe-8x.js",
193
- "line": 30441
192
+ "implementation": "dist/src-TRQ73bGO.js",
193
+ "line": 30452
194
194
  },
195
195
  "Subconscious": {
196
196
  "types": "dist/removed-subconscious.d.ts",
197
- "implementation": "dist/src-CRmfe-8x.js",
198
- "line": 30429
197
+ "implementation": "dist/src-TRQ73bGO.js",
198
+ "line": 30440
199
199
  },
200
200
  "WORKING_MEMORY_STATE_ID": {
201
201
  "types": "dist/processors/working-memory-state/processor.d.ts",
202
- "implementation": "dist/src-CRmfe-8x.js",
203
- "line": 32637
202
+ "implementation": "dist/src-TRQ73bGO.js",
203
+ "line": 32648
204
204
  },
205
205
  "WORKING_MEMORY_STATE_PROCESSOR_ID": {
206
206
  "types": "dist/processors/working-memory-state/processor.d.ts",
207
- "implementation": "dist/src-CRmfe-8x.js",
208
- "line": 32638
207
+ "implementation": "dist/src-TRQ73bGO.js",
208
+ "line": 32649
209
209
  },
210
210
  "WorkingMemoryStateProcessor": {
211
211
  "types": "dist/processors/working-memory-state/processor.d.ts",
212
- "implementation": "dist/src-CRmfe-8x.js",
213
- "line": 32639
212
+ "implementation": "dist/src-TRQ73bGO.js",
213
+ "line": 32650
214
214
  },
215
215
  "deepMergeWorkingMemory": {
216
216
  "types": "dist/tools/working-memory.d.ts",
217
- "implementation": "dist/src-CRmfe-8x.js",
218
- "line": 30020
217
+ "implementation": "dist/src-TRQ73bGO.js",
218
+ "line": 30031
219
219
  },
220
220
  "extractWorkingMemoryContent": {
221
221
  "types": "dist/index.d.ts",
222
- "implementation": "dist/src-CRmfe-8x.js",
223
- "line": 40769
222
+ "implementation": "dist/src-TRQ73bGO.js",
223
+ "line": 41046
224
224
  },
225
225
  "extractWorkingMemoryTags": {
226
226
  "types": "dist/index.d.ts",
227
- "implementation": "dist/src-CRmfe-8x.js",
228
- "line": 40737
227
+ "implementation": "dist/src-TRQ73bGO.js",
228
+ "line": 41014
229
229
  },
230
230
  "removeWorkingMemoryTags": {
231
231
  "types": "dist/index.d.ts",
232
- "implementation": "dist/src-CRmfe-8x.js",
233
- "line": 40750
232
+ "implementation": "dist/src-TRQ73bGO.js",
233
+ "line": 41027
234
234
  }
235
235
  },
236
236
  "modules": {
237
237
  "processors": {
238
238
  "index": "dist/processors/index.js",
239
239
  "chunks": [
240
- "src-CRmfe-8x.js"
240
+ "src-TRQ73bGO.js"
241
241
  ]
242
242
  }
243
243
  }
@@ -156,6 +156,6 @@ const thread = await memoryStore?.getThreadById({ threadId: '...' })
156
156
 
157
157
  ## Observability
158
158
 
159
- 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.
159
+ libSQL supports observability and is ideal for local development. By default, the exporter uses the `batch-with-updates` [tracing strategy](https://mastra.ai/docs/observability/integrations/exporters/mastra-storage), which shows in-progress traces while you debug.
160
160
 
161
161
  For production environments with higher trace volumes, consider using [PostgreSQL](https://mastra.ai/integrations/databases/postgresql) or [ClickHouse via composite storage](https://mastra.ai/reference/storage/composite).
package/dist/index.cjs CHANGED
@@ -1,5 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_src = require("./src-BC-wnTHt.cjs");
2
+ const require_src = require("./src-CKIbQdMJ.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-CRmfe-8x.js";
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-TRQ73bGO.js";
@@ -1,5 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_src = require("../src-BC-wnTHt.cjs");
2
+ const require_src = require("../src-CKIbQdMJ.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 { 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-CRmfe-8x.js";
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-TRQ73bGO.js";
@@ -0,0 +1,7 @@
1
+ import type { MemoryStorage, ObservationalMemoryRecord } from '@mastra/core/storage';
2
+ import type { Extractor } from './extractor.js';
3
+ /** Keep prepared values outside active OM metadata, durable across Memory instances. */
4
+ export declare function stageBufferedReflectionValues(storage: MemoryStorage, record: ObservationalMemoryRecord, values: Record<string, unknown> | undefined): Promise<void>;
5
+ /** Called under the OM commit lock, only after this exact buffer was activated. */
6
+ export declare function publishBufferedReflectionValues(storage: MemoryStorage, extractors: readonly Extractor<any>[], record: ObservationalMemoryRecord): Promise<void>;
7
+ //# sourceMappingURL=buffered-reflection-values.d.ts.map
@@ -1,5 +1,12 @@
1
1
  import type { ObservationalMemoryRecord } from '@mastra/core/storage';
2
2
  import type { ResolvedObservationConfig, ResolvedReflectionConfig } from './types.js';
3
+ /** The buffered-reflection op that owns a reflection boundary and cycle. */
4
+ export interface ReflectionBufferOwner {
5
+ /** The generation the op buffers for. */
6
+ recordId: string;
7
+ /** Another writer retired `recordId` while the op was still running. */
8
+ retired: boolean;
9
+ }
3
10
  /**
4
11
  * Manages the static buffering state machine for async observation and reflection.
5
12
  *
@@ -52,6 +59,37 @@ export declare class BufferingCoordinator {
52
59
  * Key format: "refl:{lockKey}"
53
60
  */
54
61
  static reflectionBufferCycleIds: Map<string, string>;
62
+ /**
63
+ * The buffered-reflection op that set the reflection boundary and cycle, and the generation
64
+ * it buffers for. Key format: "refl:{lockKey}"
65
+ */
66
+ static reflectionBufferOwners: Map<string, ReflectionBufferOwner>;
67
+ /** Set the reflection boundary for a new buffered-reflection op on generation `recordId`. */
68
+ static startReflectionBuffer(bufferKey: string, tokens: number, recordId: string): ReflectionBufferOwner;
69
+ /** Drop this process's reflection boundary, cycle, and owner. */
70
+ static clearReflectionBuffer(bufferKey: string): void;
71
+ /**
72
+ * Another writer retired generation `recordId`, so a buffer this process prepared for it can
73
+ * never activate. Its boundary and cycle are dropped now, or, while the op that set them is
74
+ * still running (it may be awaiting its `onReflectionEnd` hook), when that op finishes. State
75
+ * owned by a newer generation is kept.
76
+ */
77
+ static retireReflectionBuffer(bufferKey: string, recordId: string): void;
78
+ /**
79
+ * Reconcile this process's reflection buffer state against an observed head record.
80
+ * Whenever `head.id` differs from `owner.recordId`, confirm against a fresh storage read started
81
+ * after `owner` existed (never trusting `generationCount`, which resets to 0 after `clear()`):
82
+ * only retire/clear when storage's live head is no longer `owner.recordId`.
83
+ */
84
+ static reconcileReflectionBufferHead(bufferKey: string, headId: string, readLiveHead: () => Promise<ObservationalMemoryRecord | null>): Promise<void>;
85
+ /**
86
+ * Take the buffered-reflection cycle id for generation `recordId` and release its
87
+ * coordinator state after its buffer activates. State owned by another generation
88
+ * is left untouched.
89
+ */
90
+ static consumeReflectionBuffer(bufferKey: string, recordId: string): string | undefined;
91
+ /** Called when the op that started as `owner` finishes; completes a deferred retirement. */
92
+ static finishReflectionBuffer(bufferKey: string, owner: ReflectionBufferOwner): void;
55
93
  constructor(opts: {
56
94
  observationConfig: ResolvedObservationConfig;
57
95
  reflectionConfig: ResolvedReflectionConfig;
@@ -32,7 +32,11 @@ export declare function applyExtractorHooks(opts: {
32
32
  failures?: ExtractionFailure[];
33
33
  previousValues?: Record<string, unknown>;
34
34
  rawObservations?: string;
35
- recentMessages?: string;
35
+ /**
36
+ * Rendered recent conversation for hooks. Pass a function to defer rendering: it only runs
37
+ * (once) when a non-internal `onExtracted` hook is about to receive it.
38
+ */
39
+ recentMessages?: string | (() => string);
36
40
  threadId: string;
37
41
  resourceId?: string;
38
42
  mainAgent?: ProcessorContext['agent'];
@@ -134,6 +134,20 @@ export declare class ReflectorRunner {
134
134
  * Does NOT create a new generation or update activeObservations.
135
135
  */
136
136
  private doAsyncBufferedReflection;
137
+ /**
138
+ * Decide what a buffered-reflection swap did. Built-in adapters only swap the buffer and line
139
+ * count in the snapshot, return the stored record (no new generation) when another writer
140
+ * extended them after the head check, and mark a generation they created after that check with
141
+ * `bufferedReflectionVerified`. Adapters without that check build the new generation from
142
+ * whatever is stored. Either way the swap must also produce what the snapshot's buffer and line
143
+ * count give from the text the swap retired (retired records are never written again, so that
144
+ * text is exactly what the swap read).
145
+ *
146
+ * Staged values are published only with the adapter's proof. Without it an extension that
147
+ * repeats the unreflected tail produces the same text as the snapshot's buffer, so the values
148
+ * fail closed: the activation still applies, but the staged values stay unpublished.
149
+ */
150
+ private classifyBufferedReflectionSwap;
137
151
  /**
138
152
  * Try to activate buffered reflection when threshold is reached.
139
153
  * Returns a discriminated result so the caller can distinguish between