@mastra/memory 1.42.0-alpha.2 → 1.42.0-alpha.3
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 +84 -84
- package/dist/docs/references/reference-memory-observational-memory.md +4 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +2 -0
- 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/constants.d.ts +1 -1
- package/dist/processors/observational-memory/date-utils.d.ts +4 -0
- package/dist/processors/observational-memory/observational-memory.d.ts +1 -0
- package/dist/processors/observational-memory/types.d.ts +5 -0
- package/dist/{src-Bv05c6Nj.js → src-CHDmfrJu.js} +47 -23
- package/dist/{src-D2dL-xVG.cjs → src-DiUUpFI9.cjs} +47 -23
- package/package.json +2 -2
package/dist/docs/SKILL.md
CHANGED
|
@@ -1,243 +1,243 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "1.42.0-alpha.
|
|
2
|
+
"version": "1.42.0-alpha.3",
|
|
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-
|
|
8
|
-
"line":
|
|
7
|
+
"implementation": "dist/src-CHDmfrJu.js",
|
|
8
|
+
"line": 32963
|
|
9
9
|
},
|
|
10
10
|
"Extractor": {
|
|
11
11
|
"types": "dist/processors/observational-memory/extractor.d.ts",
|
|
12
|
-
"implementation": "dist/src-
|
|
12
|
+
"implementation": "dist/src-CHDmfrJu.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-
|
|
18
|
-
"line":
|
|
17
|
+
"implementation": "dist/src-CHDmfrJu.js",
|
|
18
|
+
"line": 32746
|
|
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-CHDmfrJu.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-CHDmfrJu.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-CHDmfrJu.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-CHDmfrJu.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-CHDmfrJu.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-
|
|
48
|
-
"line":
|
|
47
|
+
"implementation": "dist/src-CHDmfrJu.js",
|
|
48
|
+
"line": 26898
|
|
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-CHDmfrJu.js",
|
|
53
|
+
"line": 38081
|
|
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-CHDmfrJu.js",
|
|
58
|
+
"line": 40920
|
|
59
59
|
},
|
|
60
60
|
"TokenCounter": {
|
|
61
61
|
"types": "dist/processors/observational-memory/token-counter.d.ts",
|
|
62
|
-
"implementation": "dist/src-
|
|
63
|
-
"line":
|
|
62
|
+
"implementation": "dist/src-CHDmfrJu.js",
|
|
63
|
+
"line": 29428
|
|
64
64
|
},
|
|
65
65
|
"WorkingMemoryExtractor": {
|
|
66
66
|
"types": "dist/processors/observational-memory/working-memory-extractor.d.ts",
|
|
67
|
-
"implementation": "dist/src-
|
|
68
|
-
"line":
|
|
67
|
+
"implementation": "dist/src-CHDmfrJu.js",
|
|
68
|
+
"line": 30484
|
|
69
69
|
},
|
|
70
70
|
"buildObserverPrompt": {
|
|
71
71
|
"types": "dist/processors/observational-memory/observer-agent.d.ts",
|
|
72
|
-
"implementation": "dist/src-
|
|
73
|
-
"line":
|
|
72
|
+
"implementation": "dist/src-CHDmfrJu.js",
|
|
73
|
+
"line": 27580
|
|
74
74
|
},
|
|
75
75
|
"buildObserverSystemPrompt": {
|
|
76
76
|
"types": "dist/processors/observational-memory/observer-agent.d.ts",
|
|
77
|
-
"implementation": "dist/src-
|
|
78
|
-
"line":
|
|
77
|
+
"implementation": "dist/src-CHDmfrJu.js",
|
|
78
|
+
"line": 26792
|
|
79
79
|
},
|
|
80
80
|
"combineObservationGroupRanges": {
|
|
81
81
|
"types": "dist/processors/observational-memory/observation-groups.d.ts",
|
|
82
|
-
"implementation": "dist/src-
|
|
83
|
-
"line":
|
|
82
|
+
"implementation": "dist/src-CHDmfrJu.js",
|
|
83
|
+
"line": 31066
|
|
84
84
|
},
|
|
85
85
|
"deriveObservationGroupProvenance": {
|
|
86
86
|
"types": "dist/processors/observational-memory/observation-groups.d.ts",
|
|
87
|
-
"implementation": "dist/src-
|
|
88
|
-
"line":
|
|
87
|
+
"implementation": "dist/src-CHDmfrJu.js",
|
|
88
|
+
"line": 31110
|
|
89
89
|
},
|
|
90
90
|
"extractCurrentTask": {
|
|
91
91
|
"types": "dist/processors/observational-memory/observer-agent.d.ts",
|
|
92
|
-
"implementation": "dist/src-
|
|
93
|
-
"line":
|
|
92
|
+
"implementation": "dist/src-CHDmfrJu.js",
|
|
93
|
+
"line": 27893
|
|
94
94
|
},
|
|
95
95
|
"formatMessagesForObserver": {
|
|
96
96
|
"types": "dist/processors/observational-memory/observer-agent.d.ts",
|
|
97
|
-
"implementation": "dist/src-
|
|
98
|
-
"line":
|
|
97
|
+
"implementation": "dist/src-CHDmfrJu.js",
|
|
98
|
+
"line": 27331
|
|
99
99
|
},
|
|
100
100
|
"getObservationContextPrompt": {
|
|
101
101
|
"types": "dist/processors/observational-memory/constants.d.ts",
|
|
102
|
-
"implementation": "dist/src-
|
|
102
|
+
"implementation": "dist/src-CHDmfrJu.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-CHDmfrJu.js",
|
|
108
|
+
"line": 41266
|
|
109
109
|
},
|
|
110
110
|
"hasCurrentTaskSection": {
|
|
111
111
|
"types": "dist/processors/observational-memory/observer-agent.d.ts",
|
|
112
|
-
"implementation": "dist/src-
|
|
113
|
-
"line":
|
|
112
|
+
"implementation": "dist/src-CHDmfrJu.js",
|
|
113
|
+
"line": 27881
|
|
114
114
|
},
|
|
115
115
|
"injectAnchorIds": {
|
|
116
116
|
"types": "dist/processors/observational-memory/anchor-ids.d.ts",
|
|
117
|
-
"implementation": "dist/src-
|
|
117
|
+
"implementation": "dist/src-CHDmfrJu.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-
|
|
123
|
-
"line":
|
|
122
|
+
"implementation": "dist/src-CHDmfrJu.js",
|
|
123
|
+
"line": 27914
|
|
124
124
|
},
|
|
125
125
|
"parseAnchorId": {
|
|
126
126
|
"types": "dist/processors/observational-memory/anchor-ids.d.ts",
|
|
127
|
-
"implementation": "dist/src-
|
|
127
|
+
"implementation": "dist/src-CHDmfrJu.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-
|
|
133
|
-
"line":
|
|
132
|
+
"implementation": "dist/src-CHDmfrJu.js",
|
|
133
|
+
"line": 31021
|
|
134
134
|
},
|
|
135
135
|
"parseObserverOutput": {
|
|
136
136
|
"types": "dist/processors/observational-memory/observer-agent.d.ts",
|
|
137
|
-
"implementation": "dist/src-
|
|
138
|
-
"line":
|
|
137
|
+
"implementation": "dist/src-CHDmfrJu.js",
|
|
138
|
+
"line": 27591
|
|
139
139
|
},
|
|
140
140
|
"reconcileObservationGroupsFromReflection": {
|
|
141
141
|
"types": "dist/processors/observational-memory/observation-groups.d.ts",
|
|
142
|
-
"implementation": "dist/src-
|
|
143
|
-
"line":
|
|
142
|
+
"implementation": "dist/src-CHDmfrJu.js",
|
|
143
|
+
"line": 31129
|
|
144
144
|
},
|
|
145
145
|
"renderObservationGroupsForReflection": {
|
|
146
146
|
"types": "dist/processors/observational-memory/observation-groups.d.ts",
|
|
147
|
-
"implementation": "dist/src-
|
|
148
|
-
"line":
|
|
147
|
+
"implementation": "dist/src-CHDmfrJu.js",
|
|
148
|
+
"line": 31095
|
|
149
149
|
},
|
|
150
150
|
"resolveAutoModelId": {
|
|
151
151
|
"types": "dist/processors/observational-memory/auto-model.d.ts",
|
|
152
|
-
"implementation": "dist/src-
|
|
153
|
-
"line":
|
|
152
|
+
"implementation": "dist/src-CHDmfrJu.js",
|
|
153
|
+
"line": 32983
|
|
154
154
|
},
|
|
155
155
|
"stripEphemeralAnchorIds": {
|
|
156
156
|
"types": "dist/processors/observational-memory/anchor-ids.d.ts",
|
|
157
|
-
"implementation": "dist/src-
|
|
157
|
+
"implementation": "dist/src-CHDmfrJu.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-
|
|
163
|
-
"line":
|
|
162
|
+
"implementation": "dist/src-CHDmfrJu.js",
|
|
163
|
+
"line": 31038
|
|
164
164
|
},
|
|
165
165
|
"summarizeConversation": {
|
|
166
166
|
"types": "dist/processors/observational-memory/summarize.d.ts",
|
|
167
|
-
"implementation": "dist/src-
|
|
168
|
-
"line":
|
|
167
|
+
"implementation": "dist/src-CHDmfrJu.js",
|
|
168
|
+
"line": 30096
|
|
169
169
|
},
|
|
170
170
|
"wrapInObservationGroup": {
|
|
171
171
|
"types": "dist/processors/observational-memory/observation-groups.d.ts",
|
|
172
|
-
"implementation": "dist/src-
|
|
173
|
-
"line":
|
|
172
|
+
"implementation": "dist/src-CHDmfrJu.js",
|
|
173
|
+
"line": 30992
|
|
174
174
|
},
|
|
175
175
|
"KnowledgeSemanticIndexCoordinator": {
|
|
176
176
|
"types": "dist/removed-subconscious.d.ts",
|
|
177
|
-
"implementation": "dist/src-
|
|
178
|
-
"line":
|
|
177
|
+
"implementation": "dist/src-CHDmfrJu.js",
|
|
178
|
+
"line": 30590
|
|
179
179
|
},
|
|
180
180
|
"Memory": {
|
|
181
181
|
"types": "dist/index.d.ts",
|
|
182
|
-
"implementation": "dist/src-
|
|
183
|
-
"line":
|
|
182
|
+
"implementation": "dist/src-CHDmfrJu.js",
|
|
183
|
+
"line": 41518
|
|
184
184
|
},
|
|
185
185
|
"SUMMARIZE_THREAD_DEFAULTS": {
|
|
186
186
|
"types": "dist/processors/observational-memory/summarize.d.ts",
|
|
187
|
-
"implementation": "dist/src-
|
|
188
|
-
"line":
|
|
187
|
+
"implementation": "dist/src-CHDmfrJu.js",
|
|
188
|
+
"line": 30052
|
|
189
189
|
},
|
|
190
190
|
"StaleKnowledgeSemanticIndexError": {
|
|
191
191
|
"types": "dist/removed-subconscious.d.ts",
|
|
192
|
-
"implementation": "dist/src-
|
|
193
|
-
"line":
|
|
192
|
+
"implementation": "dist/src-CHDmfrJu.js",
|
|
193
|
+
"line": 30596
|
|
194
194
|
},
|
|
195
195
|
"Subconscious": {
|
|
196
196
|
"types": "dist/removed-subconscious.d.ts",
|
|
197
|
-
"implementation": "dist/src-
|
|
198
|
-
"line":
|
|
197
|
+
"implementation": "dist/src-CHDmfrJu.js",
|
|
198
|
+
"line": 30584
|
|
199
199
|
},
|
|
200
200
|
"WORKING_MEMORY_STATE_ID": {
|
|
201
201
|
"types": "dist/processors/working-memory-state/processor.d.ts",
|
|
202
|
-
"implementation": "dist/src-
|
|
203
|
-
"line":
|
|
202
|
+
"implementation": "dist/src-CHDmfrJu.js",
|
|
203
|
+
"line": 32792
|
|
204
204
|
},
|
|
205
205
|
"WORKING_MEMORY_STATE_PROCESSOR_ID": {
|
|
206
206
|
"types": "dist/processors/working-memory-state/processor.d.ts",
|
|
207
|
-
"implementation": "dist/src-
|
|
208
|
-
"line":
|
|
207
|
+
"implementation": "dist/src-CHDmfrJu.js",
|
|
208
|
+
"line": 32793
|
|
209
209
|
},
|
|
210
210
|
"WorkingMemoryStateProcessor": {
|
|
211
211
|
"types": "dist/processors/working-memory-state/processor.d.ts",
|
|
212
|
-
"implementation": "dist/src-
|
|
213
|
-
"line":
|
|
212
|
+
"implementation": "dist/src-CHDmfrJu.js",
|
|
213
|
+
"line": 32794
|
|
214
214
|
},
|
|
215
215
|
"deepMergeWorkingMemory": {
|
|
216
216
|
"types": "dist/tools/working-memory.d.ts",
|
|
217
|
-
"implementation": "dist/src-
|
|
218
|
-
"line":
|
|
217
|
+
"implementation": "dist/src-CHDmfrJu.js",
|
|
218
|
+
"line": 30175
|
|
219
219
|
},
|
|
220
220
|
"extractWorkingMemoryContent": {
|
|
221
221
|
"types": "dist/index.d.ts",
|
|
222
|
-
"implementation": "dist/src-
|
|
223
|
-
"line":
|
|
222
|
+
"implementation": "dist/src-CHDmfrJu.js",
|
|
223
|
+
"line": 41331
|
|
224
224
|
},
|
|
225
225
|
"extractWorkingMemoryTags": {
|
|
226
226
|
"types": "dist/index.d.ts",
|
|
227
|
-
"implementation": "dist/src-
|
|
228
|
-
"line":
|
|
227
|
+
"implementation": "dist/src-CHDmfrJu.js",
|
|
228
|
+
"line": 41299
|
|
229
229
|
},
|
|
230
230
|
"removeWorkingMemoryTags": {
|
|
231
231
|
"types": "dist/index.d.ts",
|
|
232
|
-
"implementation": "dist/src-
|
|
233
|
-
"line":
|
|
232
|
+
"implementation": "dist/src-CHDmfrJu.js",
|
|
233
|
+
"line": 41312
|
|
234
234
|
}
|
|
235
235
|
},
|
|
236
236
|
"modules": {
|
|
237
237
|
"processors": {
|
|
238
238
|
"index": "dist/processors/index.js",
|
|
239
239
|
"chunks": [
|
|
240
|
-
"src-
|
|
240
|
+
"src-CHDmfrJu.js"
|
|
241
241
|
]
|
|
242
242
|
}
|
|
243
243
|
}
|
|
@@ -35,8 +35,12 @@ Observer input is multimodal-aware. OM keeps text placeholders like `[Image #1:
|
|
|
35
35
|
|
|
36
36
|
OM performs thresholding with fast local token estimation. Text uses `tokenx`, and image-like inputs use provider-aware heuristics plus deterministic fallbacks when metadata is incomplete.
|
|
37
37
|
|
|
38
|
+
By default, live date hints follow the observation block rather than changing its absolute-date prefix. The complete hint suffix is limited to 8,000 characters and 64 date cues, including its tags, current-day explanation, and any omission notice. Set `observationalMemory: { liveDateHints: false }` to omit the suffix. Unchanged observations then produce the same OM context across days. Other context sections or messages can still change.
|
|
39
|
+
|
|
38
40
|
**enabled** (`boolean`): Enable or disable Observational Memory. When omitted from a config object, defaults to true. Only enabled: false explicitly disables it. (Default: `true`)
|
|
39
41
|
|
|
42
|
+
**liveDateHints** (`boolean`): Append current-day and relative-date cues after the observations, using their recorded time zone. Set to false to keep date hints out of the Actor context. Absolute dates and static date gaps remain unchanged. (Default: `true`)
|
|
43
|
+
|
|
40
44
|
**model** (`'auto' | string | LanguageModel | DynamicModel | ModelByInputTokens | ModelWithRetries[]`): Model for both the Observer and Reflector agents. Cannot be used together with observation.model or reflection.model. When all model fields are omitted, each role defaults to "auto". Automatic selection prefers google/gemini-2.5-flash when GOOGLE_GENERATIVE_AI_API_KEY is configured, then a low-cost model for the active provider, then the active main model. Use "default" for the legacy fixed default. (Default: `'auto'`)
|
|
41
45
|
|
|
42
46
|
**autoModels** (`Record<string, string>`): Overrides the model automatic selection picks for a provider, keyed by provider ID. For example, { openai: "\_\_GATEWAY_OPENAI_MODEL_LUNA\_\_" }. Providers not listed use the built-in pick.
|
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-DiUUpFI9.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.d.ts
CHANGED
|
@@ -29,6 +29,8 @@ export type { SummarizeConversationOptions, SummarizeConversationResult, Summari
|
|
|
29
29
|
* Inlined here to avoid importing runtime exports that don't exist on older @mastra/core versions.
|
|
30
30
|
*/
|
|
31
31
|
type MemoryObservationalMemoryOptions = Omit<ObservationalMemoryOptions, 'model' | 'observation' | 'reflection'> & {
|
|
32
|
+
/** Append live relative-date cues after observations. Defaults to true. */
|
|
33
|
+
liveDateHints?: ObservationalMemoryConfig['liveDateHints'];
|
|
32
34
|
model?: ObservationalMemoryConfig['model'];
|
|
33
35
|
observation?: ObservationalMemoryConfig['observation'];
|
|
34
36
|
reflection?: ObservationalMemoryConfig['reflection'];
|
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-CHDmfrJu.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-DiUUpFI9.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-CHDmfrJu.js";
|
|
@@ -66,7 +66,7 @@ export declare function getObservationContextPrompt(scope?: 'thread' | 'resource
|
|
|
66
66
|
* Instructions that tell the model how to interpret and use observations.
|
|
67
67
|
* Placed with the observations preamble, before the `<observations>` blocks.
|
|
68
68
|
*/
|
|
69
|
-
export declare const OBSERVATION_CONTEXT_INSTRUCTIONS = "IMPORTANT: When responding, reference specific details from these observations. Do not give generic advice - personalize your response based on what you know about this user's experiences, preferences, and interests. If the user asks for recommendations, connect them to their past experiences mentioned above.\n\nKNOWLEDGE UPDATES: When asked about current state (e.g., \"where do I currently...\", \"what is my current...\"), always prefer the MOST RECENT information. Observations include dates - if you see conflicting information, the newer observation supersedes the older one. Look for phrases like \"will start\", \"is switching\", \"changed to\", \"moved to\" as indicators that previous information has been updated.\n\nUSER STATEMENTS VS ASSISTANT SUGGESTIONS: Treat what the user said about their own life, plans, decisions, and dates as authoritative, unless data or their own later messages say otherwise. Treat what the assistant said, such as proposed schedules, example dates, and recommendations, as suggestions rather than facts about what happened, unless the user adopted or confirmed them. What the assistant did, such as editing a file, running a command, or calling a tool, is a record of what happened.\n\nPLANNED ACTIONS: If the user stated they planned to do something (e.g., \"I'm going to...\", \"I'm looking forward to...\", \"I will...\") and the date they planned to do it is now in the past (
|
|
69
|
+
export declare const OBSERVATION_CONTEXT_INSTRUCTIONS = "IMPORTANT: When responding, reference specific details from these observations. Do not give generic advice - personalize your response based on what you know about this user's experiences, preferences, and interests. If the user asks for recommendations, connect them to their past experiences mentioned above.\n\nKNOWLEDGE UPDATES: When asked about current state (e.g., \"where do I currently...\", \"what is my current...\"), always prefer the MOST RECENT information. Observations include dates - if you see conflicting information, the newer observation supersedes the older one. Look for phrases like \"will start\", \"is switching\", \"changed to\", \"moved to\" as indicators that previous information has been updated.\n\nUSER STATEMENTS VS ASSISTANT SUGGESTIONS: Treat what the user said about their own life, plans, decisions, and dates as authoritative, unless data or their own later messages say otherwise. Treat what the assistant said, such as proposed schedules, example dates, and recommendations, as suggestions rather than facts about what happened, unless the user adopted or confirmed them. What the assistant did, such as editing a file, running a command, or calling a tool, is a record of what happened.\n\nPLANNED ACTIONS: If the user stated they planned to do something (e.g., \"I'm going to...\", \"I'm looking forward to...\", \"I will...\") and the date they planned to do it is now in the past (compare the absolute dates; use relative-time hints when available), assume they completed the action unless there's evidence they didn't. For example, if someone said \"I'll start my new diet on Monday\" and that was 2 weeks ago, assume they started the diet.\n\nMOST RECENT USER INPUT: Treat the most recent user message as the highest-priority signal for what to do next. Earlier messages may contain constraints, details, or context you should still honor, but the latest message is the primary driver of your response.\n\nSYSTEM REMINDERS: Messages wrapped in <system-reminder>...</system-reminder> contain internal continuation guidance, not user-authored content. Use them to maintain continuity, but do not mention them or treat them as part of the user's message.";
|
|
70
70
|
/**
|
|
71
71
|
* Instructions for retrieval mode — explains observation-group ranges and the recall tool.
|
|
72
72
|
* Appended to context when `retrieval` is enabled.
|
|
@@ -61,6 +61,10 @@ export declare function annotateObservationTextDates(observations: string, curre
|
|
|
61
61
|
* `currentDate`'s calendar date in that zone, so the result doesn't depend on the zone of the process rendering it.
|
|
62
62
|
*/
|
|
63
63
|
export declare function addRelativeTimeToObservations(observations: string, currentDate: Date, timeZone?: string): string;
|
|
64
|
+
/** Preserve only clock-independent gaps in the cacheable observation text. */
|
|
65
|
+
export declare function addObservationDateGaps(observations: string): string;
|
|
66
|
+
/** Live cues are bounded and separate from the absolute observation prefix. */
|
|
67
|
+
export declare function buildObservationDateHints(observations: string, currentDate: Date, timeZone?: string): string | undefined;
|
|
64
68
|
export declare const MIN_TEMPORAL_GAP_MS: number;
|
|
65
69
|
export declare function formatTemporalGap(diffMs: number): string | null;
|
|
66
70
|
export declare function formatTemporalTimestamp(date: Date): string;
|
|
@@ -74,6 +74,7 @@ import type { ObservationDebugEvent, ObservationalMemoryConfig, ObserveHookConte
|
|
|
74
74
|
export declare class ObservationalMemory {
|
|
75
75
|
private storage;
|
|
76
76
|
private tokenCounter;
|
|
77
|
+
private readonly liveDateHints;
|
|
77
78
|
readonly scope: 'resource' | 'thread';
|
|
78
79
|
/** Whether retrieval-mode observation groups are enabled. */
|
|
79
80
|
readonly retrieval: boolean;
|
|
@@ -864,6 +864,11 @@ export interface ObservationalMemoryConfig {
|
|
|
864
864
|
storage: MemoryStorage;
|
|
865
865
|
/** Active Memory instance, when Observational Memory is created by Memory. */
|
|
866
866
|
memory?: Memory;
|
|
867
|
+
/**
|
|
868
|
+
* Append live relative-date cues after observations. Set false to omit the cues.
|
|
869
|
+
* @default true
|
|
870
|
+
*/
|
|
871
|
+
liveDateHints?: boolean;
|
|
867
872
|
/**
|
|
868
873
|
* Enable retrieval-mode observation group metadata.
|
|
869
874
|
* When true, observation groups are treated as durable pointers to raw
|
|
@@ -24232,7 +24232,7 @@ KNOWLEDGE UPDATES: When asked about current state (e.g., "where do I currently..
|
|
|
24232
24232
|
|
|
24233
24233
|
USER STATEMENTS VS ASSISTANT SUGGESTIONS: Treat what the user said about their own life, plans, decisions, and dates as authoritative, unless data or their own later messages say otherwise. Treat what the assistant said, such as proposed schedules, example dates, and recommendations, as suggestions rather than facts about what happened, unless the user adopted or confirmed them. What the assistant did, such as editing a file, running a command, or calling a tool, is a record of what happened.
|
|
24234
24234
|
|
|
24235
|
-
PLANNED ACTIONS: If the user stated they planned to do something (e.g., "I'm going to...", "I'm looking forward to...", "I will...") and the date they planned to do it is now in the past (
|
|
24235
|
+
PLANNED ACTIONS: If the user stated they planned to do something (e.g., "I'm going to...", "I'm looking forward to...", "I will...") and the date they planned to do it is now in the past (compare the absolute dates; use relative-time hints when available), assume they completed the action unless there's evidence they didn't. For example, if someone said "I'll start my new diet on Monday" and that was 2 weeks ago, assume they started the diet.
|
|
24236
24236
|
|
|
24237
24237
|
MOST RECENT USER INPUT: Treat the most recent user message as the highest-priority signal for what to do next. Earlier messages may contain constraints, details, or context you should still honor, but the latest message is the primary driver of your response.
|
|
24238
24238
|
|
|
@@ -25718,15 +25718,8 @@ function isFutureIntentObservation(line) {
|
|
|
25718
25718
|
/\babout\s+to\b/i
|
|
25719
25719
|
].some((pattern) => pattern.test(line));
|
|
25720
25720
|
}
|
|
25721
|
-
|
|
25722
|
-
*
|
|
25723
|
-
* Matches patterns like "(estimated May 27-28, 2023)" or "(meaning May 30, 2023 at 3:00 PM)"
|
|
25724
|
-
* and expands them to "(meaning May 30, 2023 - 3 weeks ago)". Notes without a year are left alone.
|
|
25725
|
-
*/
|
|
25726
|
-
function expandInlineEstimatedDates(observations, currentDate, timeZone) {
|
|
25727
|
-
const inlineDateRegex = /\((estimated|meaning)\s([^()]*)\)/gi;
|
|
25728
|
-
const today = calendarDayIn(currentDate, timeZone);
|
|
25729
|
-
return observations.replace(inlineDateRegex, (match, prefix, noteText, offset) => {
|
|
25721
|
+
function expandInlineEstimatedDatesForDay(observations, today) {
|
|
25722
|
+
return observations.replace(/\((estimated|meaning)\s([^()]*)\)/gi, (match, prefix, noteText, offset) => {
|
|
25730
25723
|
const dateContent = noteText.trimStart();
|
|
25731
25724
|
const span = findDateSpan(dateContent);
|
|
25732
25725
|
if (!span) return match;
|
|
@@ -25737,14 +25730,8 @@ function expandInlineEstimatedDates(observations, currentDate, timeZone) {
|
|
|
25737
25730
|
return `(${prefix} ${dateContent} - ${relative})`;
|
|
25738
25731
|
});
|
|
25739
25732
|
}
|
|
25740
|
-
|
|
25741
|
-
* Annotates dates written into observation text, e.g. "exam on January 10, 2024" becomes
|
|
25742
|
-
* "exam on January 10, 2024 (5 months ago)". Only dates that state their year are annotated;
|
|
25743
|
-
* "Date:" headers and "(meaning/estimated …)" notes are handled separately and skipped here.
|
|
25744
|
-
*/
|
|
25745
|
-
function annotateObservationTextDates(observations, currentDate, timeZone) {
|
|
25733
|
+
function annotateObservationTextDatesForDay(observations, today) {
|
|
25746
25734
|
const regex = new RegExp(String.raw`^Date:.*$|\((?:[Ee]stimated|[Mm]eaning)\b[^()]*\)|${FREE_TEXT_DATE.source}`, "gm");
|
|
25747
|
-
const today = calendarDayIn(currentDate, timeZone);
|
|
25748
25735
|
return observations.replace(regex, (match, offset) => {
|
|
25749
25736
|
if (match.startsWith("Date:") || match.startsWith("(")) return match;
|
|
25750
25737
|
const span = parseDateSpan(match);
|
|
@@ -25762,8 +25749,16 @@ function annotateObservationTextDates(observations, currentDate, timeZone) {
|
|
|
25762
25749
|
* `currentDate`'s calendar date in that zone, so the result doesn't depend on the zone of the process rendering it.
|
|
25763
25750
|
*/
|
|
25764
25751
|
function addRelativeTimeToObservations(observations, currentDate, timeZone) {
|
|
25765
|
-
|
|
25766
|
-
|
|
25752
|
+
return addRelativeTimeForDay(observations, calendarDayIn(currentDate, timeZone));
|
|
25753
|
+
}
|
|
25754
|
+
function addRelativeTimeForDay(observations, today) {
|
|
25755
|
+
return formatObservationDateHeaders(annotateObservationTextDatesForDay(expandInlineEstimatedDatesForDay(observations, today), today), today);
|
|
25756
|
+
}
|
|
25757
|
+
/** Preserve only clock-independent gaps in the cacheable observation text. */
|
|
25758
|
+
function addObservationDateGaps(observations) {
|
|
25759
|
+
return formatObservationDateHeaders(observations);
|
|
25760
|
+
}
|
|
25761
|
+
function formatObservationDateHeaders(withInlineDates, today) {
|
|
25767
25762
|
const dateHeaderRegex = /^(Date:[ \t]*)(.*)$/gm;
|
|
25768
25763
|
const dates = [];
|
|
25769
25764
|
let regexMatch;
|
|
@@ -25789,12 +25784,35 @@ function addRelativeTimeToObservations(observations, currentDate, timeZone) {
|
|
|
25789
25784
|
const gap = formatGapBetweenDates(prev.span.end, curr.span.start);
|
|
25790
25785
|
if (gap) result += `\n${gap}\n\n`;
|
|
25791
25786
|
}
|
|
25792
|
-
result += `${curr.prefix}${curr.dateStr} (${relativeSpan(curr.span, today)})`;
|
|
25787
|
+
result += today === void 0 ? curr.match : `${curr.prefix}${curr.dateStr} (${relativeSpan(curr.span, today)})`;
|
|
25793
25788
|
lastIndex = curr.index + curr.match.length;
|
|
25794
25789
|
}
|
|
25795
25790
|
result += withInlineDates.slice(lastIndex);
|
|
25796
25791
|
return result;
|
|
25797
25792
|
}
|
|
25793
|
+
/** Live cues are bounded and separate from the absolute observation prefix. */
|
|
25794
|
+
function buildObservationDateHints(observations, currentDate, timeZone) {
|
|
25795
|
+
const today = calendarDayIn(currentDate, timeZone);
|
|
25796
|
+
const opening = `<observation-date-hints>\nToday is ${(/* @__PURE__ */ new Date(today * DAY_MS)).toISOString().slice(0, 10)} in the observation time zone (${resolveTimeZone(timeZone) ?? "process local"}). These live annotations refer to the absolute observations above; they are not additional observations.`;
|
|
25797
|
+
const closing = "\n</observation-date-hints>";
|
|
25798
|
+
const omission = "\nAdditional date cues omitted. Interpret remaining absolute dates against today; past planned actions likely already happened.";
|
|
25799
|
+
const lines = [];
|
|
25800
|
+
let remaining = 8e3 - opening.length - 26 - 126;
|
|
25801
|
+
let omitted = false;
|
|
25802
|
+
for (const line of observations.split("\n")) {
|
|
25803
|
+
if (!/\d{4}/.test(line)) continue;
|
|
25804
|
+
const annotated = addRelativeTimeForDay(line, today);
|
|
25805
|
+
if (annotated === line) continue;
|
|
25806
|
+
if (lines.length >= 64 || annotated.length + 1 > remaining) {
|
|
25807
|
+
omitted = true;
|
|
25808
|
+
break;
|
|
25809
|
+
}
|
|
25810
|
+
lines.push(annotated);
|
|
25811
|
+
remaining -= annotated.length + 1;
|
|
25812
|
+
}
|
|
25813
|
+
if (!lines.length && !omitted) return void 0;
|
|
25814
|
+
return `${opening}${lines.map((line) => `\n${line}`).join("")}${omitted ? omission : ""}${closing}`;
|
|
25815
|
+
}
|
|
25798
25816
|
function formatTemporalGap(diffMs) {
|
|
25799
25817
|
if (diffMs < 6e5) return null;
|
|
25800
25818
|
const minute = 6e4;
|
|
@@ -38063,6 +38081,7 @@ let hasWarnedResourceScopeDeprecation = false;
|
|
|
38063
38081
|
var ObservationalMemory = class ObservationalMemory {
|
|
38064
38082
|
storage;
|
|
38065
38083
|
tokenCounter;
|
|
38084
|
+
liveDateHints;
|
|
38066
38085
|
scope;
|
|
38067
38086
|
/** Whether retrieval-mode observation groups are enabled. */
|
|
38068
38087
|
retrieval;
|
|
@@ -38195,6 +38214,7 @@ var ObservationalMemory = class ObservationalMemory {
|
|
|
38195
38214
|
if (config.model && config.reflection?.model) throw new Error("Cannot set both `model` and `reflection.model`. Use `model` to set both agents, or set each individually.");
|
|
38196
38215
|
this.shouldObscureThreadIds = config.obscureThreadIds || false;
|
|
38197
38216
|
this.storage = config.storage;
|
|
38217
|
+
this.liveDateHints = config.liveDateHints ?? true;
|
|
38198
38218
|
this.scope = config.scope ?? "thread";
|
|
38199
38219
|
this.retrieval = Boolean(config.retrieval);
|
|
38200
38220
|
this.retrievalScope = typeof config.retrieval === "object" ? config.retrieval.scope ?? "resource" : "resource";
|
|
@@ -38983,11 +39003,14 @@ var ObservationalMemory = class ObservationalMemory {
|
|
|
38983
39003
|
* the message for the current thread.
|
|
38984
39004
|
*/
|
|
38985
39005
|
formatObservationsForContext(observations, currentTask, suggestedResponse, extractedValues, unobservedContextBlocks, currentDate, retrieval = false, timeZone) {
|
|
38986
|
-
|
|
38987
|
-
|
|
39006
|
+
const optimized = retrieval ? renderObservationGroupsForReflection(observations, { includeReflectionKind: true }) ?? optimizeObservationsForContext(observations) : optimizeObservationsForContext(observations);
|
|
39007
|
+
const dateHints = this.liveDateHints && currentDate ? buildObservationDateHints(optimized, currentDate, timeZone) : void 0;
|
|
39008
|
+
const stableObservations = currentDate ? addObservationDateGaps(optimized) : optimized;
|
|
38988
39009
|
const messages = [`${getObservationContextPrompt(this.scope)}\n\n${OBSERVATION_CONTEXT_INSTRUCTIONS}${retrieval ? `\n\n${getRetrievalInstructions(this.retrievalScope, this.retrievalInstructions, this.retrievalSearch, this.storage.supportsObservationalMemoryHistorySearch === true)}` : ""}`];
|
|
38989
39010
|
if (unobservedContextBlocks) messages.push(`The following content is from OTHER conversations different from the current conversation, they're here for reference, but they're not necessarily your focus:\nSTART_OTHER_CONVERSATIONS_BLOCK\n${unobservedContextBlocks}\nEND_OTHER_CONVERSATIONS_BLOCK`);
|
|
38990
|
-
|
|
39011
|
+
const observationChunks = this.splitObservationContextChunks(stableObservations);
|
|
39012
|
+
for (const chunk of observationChunks) messages.push(`<observations>\n${chunk}\n</observations>`);
|
|
39013
|
+
if (observationChunks.length > 0 && dateHints) messages.push(dateHints);
|
|
38991
39014
|
if (currentTask) messages.push(`<current-task>\n${currentTask}\n</current-task>`);
|
|
38992
39015
|
if (suggestedResponse) messages.push(`<suggested-response>\n${suggestedResponse}\n</suggested-response>`);
|
|
38993
39016
|
messages.push(...buildExtractedValueContextSections([...this.observationConfig.extractors, ...this.reflectionConfig.extractors], extractedValues));
|
|
@@ -42632,6 +42655,7 @@ ${workingMemory}`;
|
|
|
42632
42655
|
return new OMClass({
|
|
42633
42656
|
storage: memoryStore,
|
|
42634
42657
|
memory: this,
|
|
42658
|
+
liveDateHints: omConfig.liveDateHints,
|
|
42635
42659
|
scope: omConfig.scope,
|
|
42636
42660
|
retrieval: omConfig.retrieval,
|
|
42637
42661
|
activateAfterIdle: omConfig.activateAfterIdle,
|
|
@@ -24254,7 +24254,7 @@ KNOWLEDGE UPDATES: When asked about current state (e.g., "where do I currently..
|
|
|
24254
24254
|
|
|
24255
24255
|
USER STATEMENTS VS ASSISTANT SUGGESTIONS: Treat what the user said about their own life, plans, decisions, and dates as authoritative, unless data or their own later messages say otherwise. Treat what the assistant said, such as proposed schedules, example dates, and recommendations, as suggestions rather than facts about what happened, unless the user adopted or confirmed them. What the assistant did, such as editing a file, running a command, or calling a tool, is a record of what happened.
|
|
24256
24256
|
|
|
24257
|
-
PLANNED ACTIONS: If the user stated they planned to do something (e.g., "I'm going to...", "I'm looking forward to...", "I will...") and the date they planned to do it is now in the past (
|
|
24257
|
+
PLANNED ACTIONS: If the user stated they planned to do something (e.g., "I'm going to...", "I'm looking forward to...", "I will...") and the date they planned to do it is now in the past (compare the absolute dates; use relative-time hints when available), assume they completed the action unless there's evidence they didn't. For example, if someone said "I'll start my new diet on Monday" and that was 2 weeks ago, assume they started the diet.
|
|
24258
24258
|
|
|
24259
24259
|
MOST RECENT USER INPUT: Treat the most recent user message as the highest-priority signal for what to do next. Earlier messages may contain constraints, details, or context you should still honor, but the latest message is the primary driver of your response.
|
|
24260
24260
|
|
|
@@ -25740,15 +25740,8 @@ function isFutureIntentObservation(line) {
|
|
|
25740
25740
|
/\babout\s+to\b/i
|
|
25741
25741
|
].some((pattern) => pattern.test(line));
|
|
25742
25742
|
}
|
|
25743
|
-
|
|
25744
|
-
*
|
|
25745
|
-
* Matches patterns like "(estimated May 27-28, 2023)" or "(meaning May 30, 2023 at 3:00 PM)"
|
|
25746
|
-
* and expands them to "(meaning May 30, 2023 - 3 weeks ago)". Notes without a year are left alone.
|
|
25747
|
-
*/
|
|
25748
|
-
function expandInlineEstimatedDates(observations, currentDate, timeZone) {
|
|
25749
|
-
const inlineDateRegex = /\((estimated|meaning)\s([^()]*)\)/gi;
|
|
25750
|
-
const today = calendarDayIn(currentDate, timeZone);
|
|
25751
|
-
return observations.replace(inlineDateRegex, (match, prefix, noteText, offset) => {
|
|
25743
|
+
function expandInlineEstimatedDatesForDay(observations, today) {
|
|
25744
|
+
return observations.replace(/\((estimated|meaning)\s([^()]*)\)/gi, (match, prefix, noteText, offset) => {
|
|
25752
25745
|
const dateContent = noteText.trimStart();
|
|
25753
25746
|
const span = findDateSpan(dateContent);
|
|
25754
25747
|
if (!span) return match;
|
|
@@ -25759,14 +25752,8 @@ function expandInlineEstimatedDates(observations, currentDate, timeZone) {
|
|
|
25759
25752
|
return `(${prefix} ${dateContent} - ${relative})`;
|
|
25760
25753
|
});
|
|
25761
25754
|
}
|
|
25762
|
-
|
|
25763
|
-
* Annotates dates written into observation text, e.g. "exam on January 10, 2024" becomes
|
|
25764
|
-
* "exam on January 10, 2024 (5 months ago)". Only dates that state their year are annotated;
|
|
25765
|
-
* "Date:" headers and "(meaning/estimated …)" notes are handled separately and skipped here.
|
|
25766
|
-
*/
|
|
25767
|
-
function annotateObservationTextDates(observations, currentDate, timeZone) {
|
|
25755
|
+
function annotateObservationTextDatesForDay(observations, today) {
|
|
25768
25756
|
const regex = new RegExp(String.raw`^Date:.*$|\((?:[Ee]stimated|[Mm]eaning)\b[^()]*\)|${FREE_TEXT_DATE.source}`, "gm");
|
|
25769
|
-
const today = calendarDayIn(currentDate, timeZone);
|
|
25770
25757
|
return observations.replace(regex, (match, offset) => {
|
|
25771
25758
|
if (match.startsWith("Date:") || match.startsWith("(")) return match;
|
|
25772
25759
|
const span = parseDateSpan(match);
|
|
@@ -25784,8 +25771,16 @@ function annotateObservationTextDates(observations, currentDate, timeZone) {
|
|
|
25784
25771
|
* `currentDate`'s calendar date in that zone, so the result doesn't depend on the zone of the process rendering it.
|
|
25785
25772
|
*/
|
|
25786
25773
|
function addRelativeTimeToObservations(observations, currentDate, timeZone) {
|
|
25787
|
-
|
|
25788
|
-
|
|
25774
|
+
return addRelativeTimeForDay(observations, calendarDayIn(currentDate, timeZone));
|
|
25775
|
+
}
|
|
25776
|
+
function addRelativeTimeForDay(observations, today) {
|
|
25777
|
+
return formatObservationDateHeaders(annotateObservationTextDatesForDay(expandInlineEstimatedDatesForDay(observations, today), today), today);
|
|
25778
|
+
}
|
|
25779
|
+
/** Preserve only clock-independent gaps in the cacheable observation text. */
|
|
25780
|
+
function addObservationDateGaps(observations) {
|
|
25781
|
+
return formatObservationDateHeaders(observations);
|
|
25782
|
+
}
|
|
25783
|
+
function formatObservationDateHeaders(withInlineDates, today) {
|
|
25789
25784
|
const dateHeaderRegex = /^(Date:[ \t]*)(.*)$/gm;
|
|
25790
25785
|
const dates = [];
|
|
25791
25786
|
let regexMatch;
|
|
@@ -25811,12 +25806,35 @@ function addRelativeTimeToObservations(observations, currentDate, timeZone) {
|
|
|
25811
25806
|
const gap = formatGapBetweenDates(prev.span.end, curr.span.start);
|
|
25812
25807
|
if (gap) result += `\n${gap}\n\n`;
|
|
25813
25808
|
}
|
|
25814
|
-
result += `${curr.prefix}${curr.dateStr} (${relativeSpan(curr.span, today)})`;
|
|
25809
|
+
result += today === void 0 ? curr.match : `${curr.prefix}${curr.dateStr} (${relativeSpan(curr.span, today)})`;
|
|
25815
25810
|
lastIndex = curr.index + curr.match.length;
|
|
25816
25811
|
}
|
|
25817
25812
|
result += withInlineDates.slice(lastIndex);
|
|
25818
25813
|
return result;
|
|
25819
25814
|
}
|
|
25815
|
+
/** Live cues are bounded and separate from the absolute observation prefix. */
|
|
25816
|
+
function buildObservationDateHints(observations, currentDate, timeZone) {
|
|
25817
|
+
const today = calendarDayIn(currentDate, timeZone);
|
|
25818
|
+
const opening = `<observation-date-hints>\nToday is ${(/* @__PURE__ */ new Date(today * DAY_MS)).toISOString().slice(0, 10)} in the observation time zone (${resolveTimeZone(timeZone) ?? "process local"}). These live annotations refer to the absolute observations above; they are not additional observations.`;
|
|
25819
|
+
const closing = "\n</observation-date-hints>";
|
|
25820
|
+
const omission = "\nAdditional date cues omitted. Interpret remaining absolute dates against today; past planned actions likely already happened.";
|
|
25821
|
+
const lines = [];
|
|
25822
|
+
let remaining = 8e3 - opening.length - 26 - 126;
|
|
25823
|
+
let omitted = false;
|
|
25824
|
+
for (const line of observations.split("\n")) {
|
|
25825
|
+
if (!/\d{4}/.test(line)) continue;
|
|
25826
|
+
const annotated = addRelativeTimeForDay(line, today);
|
|
25827
|
+
if (annotated === line) continue;
|
|
25828
|
+
if (lines.length >= 64 || annotated.length + 1 > remaining) {
|
|
25829
|
+
omitted = true;
|
|
25830
|
+
break;
|
|
25831
|
+
}
|
|
25832
|
+
lines.push(annotated);
|
|
25833
|
+
remaining -= annotated.length + 1;
|
|
25834
|
+
}
|
|
25835
|
+
if (!lines.length && !omitted) return void 0;
|
|
25836
|
+
return `${opening}${lines.map((line) => `\n${line}`).join("")}${omitted ? omission : ""}${closing}`;
|
|
25837
|
+
}
|
|
25820
25838
|
function formatTemporalGap(diffMs) {
|
|
25821
25839
|
if (diffMs < 6e5) return null;
|
|
25822
25840
|
const minute = 6e4;
|
|
@@ -38085,6 +38103,7 @@ let hasWarnedResourceScopeDeprecation = false;
|
|
|
38085
38103
|
var ObservationalMemory = class ObservationalMemory {
|
|
38086
38104
|
storage;
|
|
38087
38105
|
tokenCounter;
|
|
38106
|
+
liveDateHints;
|
|
38088
38107
|
scope;
|
|
38089
38108
|
/** Whether retrieval-mode observation groups are enabled. */
|
|
38090
38109
|
retrieval;
|
|
@@ -38217,6 +38236,7 @@ var ObservationalMemory = class ObservationalMemory {
|
|
|
38217
38236
|
if (config.model && config.reflection?.model) throw new Error("Cannot set both `model` and `reflection.model`. Use `model` to set both agents, or set each individually.");
|
|
38218
38237
|
this.shouldObscureThreadIds = config.obscureThreadIds || false;
|
|
38219
38238
|
this.storage = config.storage;
|
|
38239
|
+
this.liveDateHints = config.liveDateHints ?? true;
|
|
38220
38240
|
this.scope = config.scope ?? "thread";
|
|
38221
38241
|
this.retrieval = Boolean(config.retrieval);
|
|
38222
38242
|
this.retrievalScope = typeof config.retrieval === "object" ? config.retrieval.scope ?? "resource" : "resource";
|
|
@@ -39005,11 +39025,14 @@ var ObservationalMemory = class ObservationalMemory {
|
|
|
39005
39025
|
* the message for the current thread.
|
|
39006
39026
|
*/
|
|
39007
39027
|
formatObservationsForContext(observations, currentTask, suggestedResponse, extractedValues, unobservedContextBlocks, currentDate, retrieval = false, timeZone) {
|
|
39008
|
-
|
|
39009
|
-
|
|
39028
|
+
const optimized = retrieval ? renderObservationGroupsForReflection(observations, { includeReflectionKind: true }) ?? optimizeObservationsForContext(observations) : optimizeObservationsForContext(observations);
|
|
39029
|
+
const dateHints = this.liveDateHints && currentDate ? buildObservationDateHints(optimized, currentDate, timeZone) : void 0;
|
|
39030
|
+
const stableObservations = currentDate ? addObservationDateGaps(optimized) : optimized;
|
|
39010
39031
|
const messages = [`${getObservationContextPrompt(this.scope)}\n\n${OBSERVATION_CONTEXT_INSTRUCTIONS}${retrieval ? `\n\n${getRetrievalInstructions(this.retrievalScope, this.retrievalInstructions, this.retrievalSearch, this.storage.supportsObservationalMemoryHistorySearch === true)}` : ""}`];
|
|
39011
39032
|
if (unobservedContextBlocks) messages.push(`The following content is from OTHER conversations different from the current conversation, they're here for reference, but they're not necessarily your focus:\nSTART_OTHER_CONVERSATIONS_BLOCK\n${unobservedContextBlocks}\nEND_OTHER_CONVERSATIONS_BLOCK`);
|
|
39012
|
-
|
|
39033
|
+
const observationChunks = this.splitObservationContextChunks(stableObservations);
|
|
39034
|
+
for (const chunk of observationChunks) messages.push(`<observations>\n${chunk}\n</observations>`);
|
|
39035
|
+
if (observationChunks.length > 0 && dateHints) messages.push(dateHints);
|
|
39013
39036
|
if (currentTask) messages.push(`<current-task>\n${currentTask}\n</current-task>`);
|
|
39014
39037
|
if (suggestedResponse) messages.push(`<suggested-response>\n${suggestedResponse}\n</suggested-response>`);
|
|
39015
39038
|
messages.push(...buildExtractedValueContextSections([...this.observationConfig.extractors, ...this.reflectionConfig.extractors], extractedValues));
|
|
@@ -42654,6 +42677,7 @@ ${workingMemory}`;
|
|
|
42654
42677
|
return new OMClass({
|
|
42655
42678
|
storage: memoryStore,
|
|
42656
42679
|
memory: this,
|
|
42680
|
+
liveDateHints: omConfig.liveDateHints,
|
|
42657
42681
|
scope: omConfig.scope,
|
|
42658
42682
|
retrieval: omConfig.retrieval,
|
|
42659
42683
|
activateAfterIdle: omConfig.activateAfterIdle,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mastra/memory",
|
|
3
|
-
"version": "1.42.0-alpha.
|
|
3
|
+
"version": "1.42.0-alpha.3",
|
|
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.12"
|
|
77
77
|
},
|
|
78
78
|
"peerDependencies": {
|
|
79
79
|
"@mastra/core": ">=1.85.1-0 <2.0.0-0"
|