@mastra/memory 1.10.1-alpha.0 → 1.10.1-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +92 -0
- package/dist/{chunk-K2NLYL2O.js → chunk-2QSOQQPM.js} +6817 -6615
- package/dist/chunk-2QSOQQPM.js.map +1 -0
- package/dist/chunk-D4J4XPGM.cjs +111 -0
- package/dist/chunk-D4J4XPGM.cjs.map +1 -0
- package/dist/chunk-LSJJAJAF.js +105 -0
- package/dist/chunk-LSJJAJAF.js.map +1 -0
- package/dist/{chunk-HSOEY7M2.cjs → chunk-NS47X3OB.cjs} +6807 -6608
- package/dist/chunk-NS47X3OB.cjs.map +1 -0
- package/dist/constants-BDOITAO3.js +3 -0
- package/dist/constants-BDOITAO3.js.map +1 -0
- package/dist/constants-HXOCZPB7.cjs +28 -0
- package/dist/constants-HXOCZPB7.cjs.map +1 -0
- package/dist/docs/SKILL.md +1 -1
- package/dist/docs/assets/SOURCE_MAP.json +67 -61
- package/dist/docs/references/docs-memory-observational-memory.md +7 -5
- package/dist/docs/references/reference-memory-observational-memory.md +2 -2
- package/dist/index.cjs +207 -78
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +52 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +200 -71
- package/dist/index.js.map +1 -1
- package/dist/{observational-memory-DJMF2UNC.cjs → observational-memory-I5UTOG63.cjs} +46 -41
- package/dist/{observational-memory-DJMF2UNC.cjs.map → observational-memory-I5UTOG63.cjs.map} +1 -1
- package/dist/observational-memory-WMCWT577.js +4 -0
- package/dist/{observational-memory-NMQ7URIP.js.map → observational-memory-WMCWT577.js.map} +1 -1
- package/dist/processors/index.cjs +44 -39
- package/dist/processors/index.js +2 -1
- package/dist/processors/observational-memory/buffering-coordinator.d.ts +61 -0
- package/dist/processors/observational-memory/buffering-coordinator.d.ts.map +1 -0
- package/dist/processors/observational-memory/constants.d.ts +62 -0
- package/dist/processors/observational-memory/constants.d.ts.map +1 -0
- package/dist/processors/observational-memory/debug.d.ts +3 -0
- package/dist/processors/observational-memory/debug.d.ts.map +1 -0
- package/dist/processors/observational-memory/index.d.ts +5 -2
- package/dist/processors/observational-memory/index.d.ts.map +1 -1
- package/dist/processors/observational-memory/message-utils.d.ts +69 -0
- package/dist/processors/observational-memory/message-utils.d.ts.map +1 -0
- package/dist/processors/observational-memory/observation-strategies/async-buffer.d.ts +33 -0
- package/dist/processors/observational-memory/observation-strategies/async-buffer.d.ts.map +1 -0
- package/dist/processors/observational-memory/observation-strategies/base.d.ts +102 -0
- package/dist/processors/observational-memory/observation-strategies/base.d.ts.map +1 -0
- package/dist/processors/observational-memory/observation-strategies/index.d.ts +7 -0
- package/dist/processors/observational-memory/observation-strategies/index.d.ts.map +1 -0
- package/dist/processors/observational-memory/observation-strategies/resource-scoped.d.ts +39 -0
- package/dist/processors/observational-memory/observation-strategies/resource-scoped.d.ts.map +1 -0
- package/dist/processors/observational-memory/observation-strategies/sync.d.ts +35 -0
- package/dist/processors/observational-memory/observation-strategies/sync.d.ts.map +1 -0
- package/dist/processors/observational-memory/observation-strategies/types.d.ts +55 -0
- package/dist/processors/observational-memory/observation-strategies/types.d.ts.map +1 -0
- package/dist/processors/observational-memory/observation-turn/index.d.ts +4 -0
- package/dist/processors/observational-memory/observation-turn/index.d.ts.map +1 -0
- package/dist/processors/observational-memory/observation-turn/step.d.ts +34 -0
- package/dist/processors/observational-memory/observation-turn/step.d.ts.map +1 -0
- package/dist/processors/observational-memory/observation-turn/turn.d.ts +84 -0
- package/dist/processors/observational-memory/observation-turn/turn.d.ts.map +1 -0
- package/dist/processors/observational-memory/observation-turn/types.d.ts +38 -0
- package/dist/processors/observational-memory/observation-turn/types.d.ts.map +1 -0
- package/dist/processors/observational-memory/observational-memory.d.ts +388 -553
- package/dist/processors/observational-memory/observational-memory.d.ts.map +1 -1
- package/dist/processors/observational-memory/observer-runner.d.ts +65 -0
- package/dist/processors/observational-memory/observer-runner.d.ts.map +1 -0
- package/dist/processors/observational-memory/processor.d.ts +70 -0
- package/dist/processors/observational-memory/processor.d.ts.map +1 -0
- package/dist/processors/observational-memory/reflector-runner.d.ts +95 -0
- package/dist/processors/observational-memory/reflector-runner.d.ts.map +1 -0
- package/dist/processors/observational-memory/types.d.ts +157 -0
- package/dist/processors/observational-memory/types.d.ts.map +1 -1
- package/package.json +3 -3
- package/dist/chunk-HSOEY7M2.cjs.map +0 -1
- package/dist/chunk-K2NLYL2O.js.map +0 -1
- package/dist/observational-memory-NMQ7URIP.js +0 -3
package/dist/index.d.ts
CHANGED
|
@@ -4,9 +4,9 @@ import { MastraMemory } from '@mastra/core/memory';
|
|
|
4
4
|
import type { MemoryConfigInternal, SharedMemoryConfig, StorageThreadType, WorkingMemoryTemplate, MessageDeleteInput, ObservationalMemoryOptions, MemoryConfig } from '@mastra/core/memory';
|
|
5
5
|
import type { InputProcessor, InputProcessorOrWorkflow, OutputProcessor, OutputProcessorOrWorkflow } from '@mastra/core/processors';
|
|
6
6
|
import type { RequestContext } from '@mastra/core/request-context';
|
|
7
|
-
import type { StorageListThreadsInput, StorageListThreadsOutput, StorageListMessagesInput, MemoryStorage, StorageCloneThreadInput, StorageCloneThreadOutput, ThreadCloneMetadata } from '@mastra/core/storage';
|
|
7
|
+
import type { StorageListThreadsInput, StorageListThreadsOutput, StorageListMessagesInput, MemoryStorage, StorageCloneThreadInput, StorageCloneThreadOutput, ThreadCloneMetadata, ObservationalMemoryRecord } from '@mastra/core/storage';
|
|
8
8
|
import type { ToolAction } from '@mastra/core/tools';
|
|
9
|
-
import type { ObservationalMemoryConfig } from './processors/observational-memory/index.js';
|
|
9
|
+
import type { ObservationalMemory, ObservationalMemoryConfig } from './processors/observational-memory/index.js';
|
|
10
10
|
import { deepMergeWorkingMemory } from './tools/working-memory.js';
|
|
11
11
|
export { ModelByInputTokens, type ModelByInputTokensConfig, } from './processors/observational-memory/model-by-input-tokens.js';
|
|
12
12
|
/**
|
|
@@ -32,6 +32,9 @@ export { extractWorkingMemoryTags, extractWorkingMemoryContent, removeWorkingMem
|
|
|
32
32
|
* and message injection.
|
|
33
33
|
*/
|
|
34
34
|
export declare class Memory extends MastraMemory {
|
|
35
|
+
private _omEngine;
|
|
36
|
+
/** The shared ObservationalMemory engine. Lazily created on first access. */
|
|
37
|
+
get omEngine(): Promise<ObservationalMemory | null>;
|
|
35
38
|
constructor(config?: MemoryConstructorConfig);
|
|
36
39
|
/**
|
|
37
40
|
* Gets the memory storage domain, throwing if not available.
|
|
@@ -172,6 +175,50 @@ export declare class Memory extends MastraMemory {
|
|
|
172
175
|
resourceId?: string;
|
|
173
176
|
memoryConfig?: MemoryConfigInternal;
|
|
174
177
|
}): Promise<string | null>;
|
|
178
|
+
/**
|
|
179
|
+
* Get everything needed for an LLM call in one shot.
|
|
180
|
+
*
|
|
181
|
+
* Assembles the system message (observations + working memory), loads
|
|
182
|
+
* unobserved messages from storage, and returns them ready to use.
|
|
183
|
+
*
|
|
184
|
+
* @example
|
|
185
|
+
* ```ts
|
|
186
|
+
* const ctx = await memory.getContext({ threadId });
|
|
187
|
+
* const result = await generateText({
|
|
188
|
+
* model: openai('gpt-4o'),
|
|
189
|
+
* system: ctx.systemMessage,
|
|
190
|
+
* messages: ctx.messages.map(toAiSdkMessage),
|
|
191
|
+
* });
|
|
192
|
+
* ```
|
|
193
|
+
*/
|
|
194
|
+
getContext(opts: {
|
|
195
|
+
threadId: string;
|
|
196
|
+
resourceId?: string;
|
|
197
|
+
memoryConfig?: MemoryConfigInternal;
|
|
198
|
+
}): Promise<{
|
|
199
|
+
/** Fully-formed system message (observations + instructions + working memory), or undefined if none. */
|
|
200
|
+
systemMessage: string | undefined;
|
|
201
|
+
/** Messages for the LLM — unobserved messages if OM is active, or recent messages from history. */
|
|
202
|
+
messages: MastraDBMessage[];
|
|
203
|
+
/** Whether observations exist for this thread. */
|
|
204
|
+
hasObservations: boolean;
|
|
205
|
+
/** The OM record, if OM is active. */
|
|
206
|
+
omRecord: ObservationalMemoryRecord | null;
|
|
207
|
+
/** The om-continuation reminder message, if OM has observations. Caller decides where to place it. */
|
|
208
|
+
continuationMessage: MastraDBMessage | undefined;
|
|
209
|
+
/** Formatted context blocks from other threads (resource scope only). */
|
|
210
|
+
otherThreadsContext: string | undefined;
|
|
211
|
+
}>;
|
|
212
|
+
/**
|
|
213
|
+
* Raw message upsert — persist messages to storage without embedding or working memory processing.
|
|
214
|
+
* Used by the processor to save sealed messages before firing a background buffer operation.
|
|
215
|
+
*/
|
|
216
|
+
persistMessages(messages: MastraDBMessage[]): Promise<void>;
|
|
217
|
+
/**
|
|
218
|
+
* One-time initialization of the shared ObservationalMemory engine.
|
|
219
|
+
* Called lazily by the `omEngine` getter on first access.
|
|
220
|
+
*/
|
|
221
|
+
private _initOMEngine;
|
|
175
222
|
defaultWorkingMemoryTemplate: string;
|
|
176
223
|
protected getWorkingMemoryToolInstruction({ template, data, }: {
|
|
177
224
|
template: WorkingMemoryTemplate;
|
|
@@ -381,9 +428,9 @@ export declare class Memory extends MastraMemory {
|
|
|
381
428
|
*/
|
|
382
429
|
getOutputProcessors(configuredProcessors?: OutputProcessorOrWorkflow[], context?: RequestContext): Promise<OutputProcessor[]>;
|
|
383
430
|
/**
|
|
384
|
-
* Creates an ObservationalMemory processor
|
|
385
|
-
*
|
|
386
|
-
*
|
|
431
|
+
* Creates an ObservationalMemory processor wrapping the shared engine.
|
|
432
|
+
* Returns null if OM is not configured, not supported, or already present
|
|
433
|
+
* in the user's configured processors.
|
|
387
434
|
*/
|
|
388
435
|
private createOMProcessor;
|
|
389
436
|
}
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAKhD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAG1D,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;;;;;;;;;;;;OAaG;IACI,OAAO,CAAC,MAAM,EAAE,iBAAiB,GAAG,IAAI,GAAG,OAAO;IAIzD;;;;;;;;;;;;;OAaG;IACU,eAAe,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,iBAAiB,GAAG,IAAI,CAAC;IAWjF;;;;;;;;;;;;OAYG;IACU,UAAU,CAAC,cAAc,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,iBAAiB,EAAE,CAAC;IAyBlG;;;;;;;;;;;OAWG;IACU,eAAe,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,iBAAiB,EAAE,CAAC;IAmB5E;;;;;;;OAOG;IACG,kBAAkB,CACtB,oBAAoB,GAAE,wBAAwB,EAAO,EACrD,OAAO,CAAC,EAAE,cAAc,GACvB,OAAO,CAAC,cAAc,EAAE,CAAC;IAY5B;;;;OAIG;IACG,mBAAmB,CACvB,oBAAoB,GAAE,yBAAyB,EAAO,EACtD,OAAO,CAAC,EAAE,cAAc,GACvB,OAAO,CAAC,eAAe,EAAE,CAAC;IAW7B;;;;OAIG;YACW,iBAAiB;CA6BhC;AAGD,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAGxF,YAAY,EAAE,uBAAuB,EAAE,wBAAwB,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAGnH,OAAO,EAAE,mBAAmB,EAAE,MAAM,mCAAmC,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { __commonJS, require_token_error, __toESM } from './chunk-SVPZMV27.js';
|
|
2
2
|
import { __commonJS as __commonJS$1, require_token_error as require_token_error$1, __toESM as __toESM$1 } from './chunk-RC6RZVYE.js';
|
|
3
|
-
import { truncateStringByTokens, resolveToolResultValue, formatToolResultForObserver } from './chunk-
|
|
4
|
-
export { ModelByInputTokens, getObservationsAsOf } from './chunk-
|
|
3
|
+
import { truncateStringByTokens, resolveToolResultValue, formatToolResultForObserver } from './chunk-2QSOQQPM.js';
|
|
4
|
+
export { ModelByInputTokens, getObservationsAsOf } from './chunk-2QSOQQPM.js';
|
|
5
5
|
import { ZodFirstPartyTypeKind } from 'zod/v3';
|
|
6
6
|
import { z } from 'zod';
|
|
7
7
|
import * as z4 from 'zod/v4';
|
|
@@ -16070,6 +16070,14 @@ var DEFAULT_MESSAGE_RANGE = { before: 1, after: 1 };
|
|
|
16070
16070
|
var DEFAULT_TOP_K = 4;
|
|
16071
16071
|
var VECTOR_DELETE_BATCH_SIZE = 100;
|
|
16072
16072
|
var Memory = class extends MastraMemory {
|
|
16073
|
+
_omEngine;
|
|
16074
|
+
/** The shared ObservationalMemory engine. Lazily created on first access. */
|
|
16075
|
+
get omEngine() {
|
|
16076
|
+
if (!this._omEngine) {
|
|
16077
|
+
this._omEngine = this._initOMEngine();
|
|
16078
|
+
}
|
|
16079
|
+
return this._omEngine;
|
|
16080
|
+
}
|
|
16073
16081
|
constructor(config = {}) {
|
|
16074
16082
|
super({ name: "Memory", ...config });
|
|
16075
16083
|
const mergedConfig = this.getMergedThreadConfig({
|
|
@@ -16710,6 +16718,179 @@ ${workingMemory}`;
|
|
|
16710
16718
|
data: workingMemoryData
|
|
16711
16719
|
});
|
|
16712
16720
|
}
|
|
16721
|
+
/**
|
|
16722
|
+
* Get everything needed for an LLM call in one shot.
|
|
16723
|
+
*
|
|
16724
|
+
* Assembles the system message (observations + working memory), loads
|
|
16725
|
+
* unobserved messages from storage, and returns them ready to use.
|
|
16726
|
+
*
|
|
16727
|
+
* @example
|
|
16728
|
+
* ```ts
|
|
16729
|
+
* const ctx = await memory.getContext({ threadId });
|
|
16730
|
+
* const result = await generateText({
|
|
16731
|
+
* model: openai('gpt-4o'),
|
|
16732
|
+
* system: ctx.systemMessage,
|
|
16733
|
+
* messages: ctx.messages.map(toAiSdkMessage),
|
|
16734
|
+
* });
|
|
16735
|
+
* ```
|
|
16736
|
+
*/
|
|
16737
|
+
async getContext(opts) {
|
|
16738
|
+
const { threadId, resourceId, memoryConfig } = opts;
|
|
16739
|
+
const config = this.getMergedThreadConfig(memoryConfig);
|
|
16740
|
+
const memoryStore = await this.getMemoryStore();
|
|
16741
|
+
const systemParts = [];
|
|
16742
|
+
let hasObservations = false;
|
|
16743
|
+
let omRecord = null;
|
|
16744
|
+
let continuationMessage;
|
|
16745
|
+
let otherThreadsContext;
|
|
16746
|
+
const omEngine = await this.omEngine;
|
|
16747
|
+
if (omEngine) {
|
|
16748
|
+
omRecord = await omEngine.getRecord(threadId, resourceId);
|
|
16749
|
+
if (omRecord?.activeObservations) {
|
|
16750
|
+
hasObservations = true;
|
|
16751
|
+
if (omEngine.scope === "resource" && resourceId) {
|
|
16752
|
+
otherThreadsContext = await omEngine.getOtherThreadsContext(resourceId, threadId);
|
|
16753
|
+
}
|
|
16754
|
+
const obsSystemMessage = await omEngine.buildContextSystemMessage({
|
|
16755
|
+
threadId,
|
|
16756
|
+
resourceId,
|
|
16757
|
+
record: omRecord,
|
|
16758
|
+
unobservedContextBlocks: otherThreadsContext
|
|
16759
|
+
});
|
|
16760
|
+
if (obsSystemMessage) {
|
|
16761
|
+
systemParts.push(obsSystemMessage);
|
|
16762
|
+
}
|
|
16763
|
+
const { OBSERVATION_CONTINUATION_HINT } = await import('./constants-BDOITAO3.js');
|
|
16764
|
+
continuationMessage = {
|
|
16765
|
+
id: "om-continuation",
|
|
16766
|
+
role: "user",
|
|
16767
|
+
createdAt: /* @__PURE__ */ new Date(0),
|
|
16768
|
+
content: {
|
|
16769
|
+
format: 2,
|
|
16770
|
+
parts: [
|
|
16771
|
+
{
|
|
16772
|
+
type: "text",
|
|
16773
|
+
text: `<system-reminder>${OBSERVATION_CONTINUATION_HINT}</system-reminder>`
|
|
16774
|
+
}
|
|
16775
|
+
]
|
|
16776
|
+
},
|
|
16777
|
+
threadId,
|
|
16778
|
+
resourceId
|
|
16779
|
+
};
|
|
16780
|
+
}
|
|
16781
|
+
}
|
|
16782
|
+
const workingMemoryMessage = await this.getSystemMessage({ threadId, resourceId, memoryConfig: config });
|
|
16783
|
+
if (workingMemoryMessage) {
|
|
16784
|
+
systemParts.push(workingMemoryMessage);
|
|
16785
|
+
}
|
|
16786
|
+
let messages;
|
|
16787
|
+
if (omEngine && omRecord) {
|
|
16788
|
+
const dateFilter = omRecord.lastObservedAt ? { dateRange: { start: new Date(new Date(omRecord.lastObservedAt).getTime() + 1) } } : void 0;
|
|
16789
|
+
if (omEngine.scope === "resource" && resourceId) {
|
|
16790
|
+
const result = await memoryStore.listMessagesByResourceId({
|
|
16791
|
+
resourceId,
|
|
16792
|
+
orderBy: { field: "createdAt", direction: "ASC" },
|
|
16793
|
+
perPage: false,
|
|
16794
|
+
filter: dateFilter
|
|
16795
|
+
});
|
|
16796
|
+
messages = result.messages;
|
|
16797
|
+
} else {
|
|
16798
|
+
const result = await memoryStore.listMessages({
|
|
16799
|
+
threadId,
|
|
16800
|
+
orderBy: { field: "createdAt", direction: "ASC" },
|
|
16801
|
+
perPage: false,
|
|
16802
|
+
filter: dateFilter
|
|
16803
|
+
});
|
|
16804
|
+
messages = result.messages;
|
|
16805
|
+
}
|
|
16806
|
+
} else {
|
|
16807
|
+
const lastMessages = config.lastMessages;
|
|
16808
|
+
if (lastMessages === false) {
|
|
16809
|
+
messages = [];
|
|
16810
|
+
} else {
|
|
16811
|
+
const result = await memoryStore.listMessages({
|
|
16812
|
+
threadId,
|
|
16813
|
+
resourceId,
|
|
16814
|
+
orderBy: { field: "createdAt", direction: "DESC" },
|
|
16815
|
+
perPage: typeof lastMessages === "number" ? lastMessages : void 0
|
|
16816
|
+
});
|
|
16817
|
+
messages = result.messages.reverse();
|
|
16818
|
+
}
|
|
16819
|
+
}
|
|
16820
|
+
return {
|
|
16821
|
+
systemMessage: systemParts.length > 0 ? systemParts.join("\n\n") : void 0,
|
|
16822
|
+
messages,
|
|
16823
|
+
hasObservations,
|
|
16824
|
+
omRecord,
|
|
16825
|
+
continuationMessage,
|
|
16826
|
+
otherThreadsContext
|
|
16827
|
+
};
|
|
16828
|
+
}
|
|
16829
|
+
/**
|
|
16830
|
+
* Raw message upsert — persist messages to storage without embedding or working memory processing.
|
|
16831
|
+
* Used by the processor to save sealed messages before firing a background buffer operation.
|
|
16832
|
+
*/
|
|
16833
|
+
async persistMessages(messages) {
|
|
16834
|
+
if (messages.length === 0) return;
|
|
16835
|
+
const memoryStore = await this.getMemoryStore();
|
|
16836
|
+
await memoryStore.saveMessages({ messages });
|
|
16837
|
+
}
|
|
16838
|
+
/**
|
|
16839
|
+
* One-time initialization of the shared ObservationalMemory engine.
|
|
16840
|
+
* Called lazily by the `omEngine` getter on first access.
|
|
16841
|
+
*/
|
|
16842
|
+
async _initOMEngine() {
|
|
16843
|
+
const omConfig = normalizeObservationalMemoryConfig(this.threadConfig.observationalMemory);
|
|
16844
|
+
if (!omConfig) return null;
|
|
16845
|
+
const memoryStore = await this.storage.getStore("memory");
|
|
16846
|
+
if (!memoryStore || !memoryStore.supportsObservationalMemory) return null;
|
|
16847
|
+
const coreSupportsOM = coreFeatures.has("observationalMemory");
|
|
16848
|
+
if (!coreSupportsOM) {
|
|
16849
|
+
throw new Error(
|
|
16850
|
+
"Observational memory is enabled but the installed version of @mastra/core does not support it. Please upgrade @mastra/core to a version that includes observational memory support."
|
|
16851
|
+
);
|
|
16852
|
+
}
|
|
16853
|
+
if (omConfig.observation?.bufferTokens !== false && !coreFeatures.has("asyncBuffering")) {
|
|
16854
|
+
throw new Error(
|
|
16855
|
+
"Observational memory async buffering is enabled by default but the installed version of @mastra/core does not support it. Either upgrade @mastra/core, @mastra/memory, and your storage adapter (@mastra/libsql, @mastra/pg, or @mastra/mongodb) to the latest version, or explicitly disable async buffering by setting `observation: { bufferTokens: false }` in your observationalMemory config."
|
|
16856
|
+
);
|
|
16857
|
+
}
|
|
16858
|
+
if (!coreFeatures.has("request-response-id-rotation")) {
|
|
16859
|
+
throw new Error(
|
|
16860
|
+
"Observational memory requires @mastra/core support for request-response-id-rotation. Please bump @mastra/core to a newer version."
|
|
16861
|
+
);
|
|
16862
|
+
}
|
|
16863
|
+
const { ObservationalMemory: OMClass } = await import('./observational-memory-WMCWT577.js');
|
|
16864
|
+
return new OMClass({
|
|
16865
|
+
storage: memoryStore,
|
|
16866
|
+
scope: omConfig.scope,
|
|
16867
|
+
retrieval: omConfig.retrieval,
|
|
16868
|
+
shareTokenBudget: omConfig.shareTokenBudget,
|
|
16869
|
+
model: omConfig.model,
|
|
16870
|
+
observation: omConfig.observation ? {
|
|
16871
|
+
model: omConfig.observation.model,
|
|
16872
|
+
messageTokens: omConfig.observation.messageTokens,
|
|
16873
|
+
modelSettings: omConfig.observation.modelSettings,
|
|
16874
|
+
maxTokensPerBatch: omConfig.observation.maxTokensPerBatch,
|
|
16875
|
+
providerOptions: omConfig.observation.providerOptions,
|
|
16876
|
+
bufferTokens: omConfig.observation.bufferTokens,
|
|
16877
|
+
bufferActivation: omConfig.observation.bufferActivation,
|
|
16878
|
+
blockAfter: omConfig.observation.blockAfter,
|
|
16879
|
+
previousObserverTokens: omConfig.observation.previousObserverTokens,
|
|
16880
|
+
instruction: omConfig.observation.instruction,
|
|
16881
|
+
threadTitle: omConfig.observation.threadTitle
|
|
16882
|
+
} : void 0,
|
|
16883
|
+
reflection: omConfig.reflection ? {
|
|
16884
|
+
model: omConfig.reflection.model,
|
|
16885
|
+
observationTokens: omConfig.reflection.observationTokens,
|
|
16886
|
+
modelSettings: omConfig.reflection.modelSettings,
|
|
16887
|
+
providerOptions: omConfig.reflection.providerOptions,
|
|
16888
|
+
bufferActivation: omConfig.reflection.bufferActivation,
|
|
16889
|
+
blockAfter: omConfig.reflection.blockAfter,
|
|
16890
|
+
instruction: omConfig.reflection.instruction
|
|
16891
|
+
} : void 0
|
|
16892
|
+
});
|
|
16893
|
+
}
|
|
16713
16894
|
defaultWorkingMemoryTemplate = `
|
|
16714
16895
|
# User Information
|
|
16715
16896
|
- **First Name**:
|
|
@@ -17371,81 +17552,29 @@ Notes:
|
|
|
17371
17552
|
return processors;
|
|
17372
17553
|
}
|
|
17373
17554
|
/**
|
|
17374
|
-
* Creates an ObservationalMemory processor
|
|
17375
|
-
*
|
|
17376
|
-
*
|
|
17555
|
+
* Creates an ObservationalMemory processor wrapping the shared engine.
|
|
17556
|
+
* Returns null if OM is not configured, not supported, or already present
|
|
17557
|
+
* in the user's configured processors.
|
|
17377
17558
|
*/
|
|
17378
17559
|
async createOMProcessor(configuredProcessors = [], context2) {
|
|
17379
17560
|
const hasObservationalMemory = configuredProcessors.some(
|
|
17380
17561
|
(p) => !("workflow" in p) && p.id === "observational-memory"
|
|
17381
17562
|
);
|
|
17382
|
-
|
|
17383
|
-
const
|
|
17384
|
-
const
|
|
17385
|
-
|
|
17386
|
-
|
|
17563
|
+
if (hasObservationalMemory) return null;
|
|
17564
|
+
const runtimeMemory = context2?.get("MastraMemory");
|
|
17565
|
+
const runtimeObservationalMemory = normalizeObservationalMemoryConfig(
|
|
17566
|
+
runtimeMemory?.memoryConfig?.observationalMemory
|
|
17567
|
+
);
|
|
17568
|
+
const threadConfig = runtimeObservationalMemory ? this.getMergedThreadConfig({
|
|
17569
|
+
...runtimeMemory?.memoryConfig,
|
|
17570
|
+
observationalMemory: runtimeObservationalMemory
|
|
17387
17571
|
}) : this.threadConfig;
|
|
17388
|
-
const
|
|
17389
|
-
if (!
|
|
17390
|
-
|
|
17391
|
-
|
|
17392
|
-
const
|
|
17393
|
-
|
|
17394
|
-
throw new Error(
|
|
17395
|
-
"Observational memory is enabled but the installed version of @mastra/core does not support it. Please upgrade @mastra/core to a version that includes observational memory support."
|
|
17396
|
-
);
|
|
17397
|
-
}
|
|
17398
|
-
const memoryStore = await this.storage.getStore("memory");
|
|
17399
|
-
if (!memoryStore) {
|
|
17400
|
-
throw new Error(
|
|
17401
|
-
"Using Mastra Memory observational memory requires a storage adapter but no attached adapter was detected."
|
|
17402
|
-
);
|
|
17403
|
-
}
|
|
17404
|
-
if (!memoryStore.supportsObservationalMemory) {
|
|
17405
|
-
throw new Error(
|
|
17406
|
-
`Observational memory is enabled but the storage adapter (${memoryStore.constructor.name}) does not support it. If you're using @mastra/libsql, @mastra/pg, or @mastra/mongodb, upgrade to the latest version. Otherwise, use one of those adapters or disable observational memory.`
|
|
17407
|
-
);
|
|
17408
|
-
}
|
|
17409
|
-
if (omConfig.observation?.bufferTokens !== false && !coreFeatures.has("asyncBuffering")) {
|
|
17410
|
-
throw new Error(
|
|
17411
|
-
"Observational memory async buffering is enabled by default but the installed version of @mastra/core does not support it. Either upgrade @mastra/core, @mastra/memory, and your storage adapter (@mastra/libsql, @mastra/pg, or @mastra/mongodb) to the latest version, or explicitly disable async buffering by setting `observation: { bufferTokens: false }` in your observationalMemory config."
|
|
17412
|
-
);
|
|
17413
|
-
}
|
|
17414
|
-
if (!coreFeatures.has("request-response-id-rotation")) {
|
|
17415
|
-
throw new Error(
|
|
17416
|
-
"Observational memory requires @mastra/core support for request-response-id-rotation. Please bump @mastra/core to a newer version."
|
|
17417
|
-
);
|
|
17418
|
-
}
|
|
17419
|
-
const { ObservationalMemory } = await import('./observational-memory-NMQ7URIP.js');
|
|
17420
|
-
return new ObservationalMemory({
|
|
17421
|
-
storage: memoryStore,
|
|
17422
|
-
scope: omConfig.scope,
|
|
17423
|
-
retrieval: omConfig.retrieval,
|
|
17424
|
-
shareTokenBudget: omConfig.shareTokenBudget,
|
|
17425
|
-
model: omConfig.model,
|
|
17426
|
-
observation: omConfig.observation ? {
|
|
17427
|
-
model: omConfig.observation.model,
|
|
17428
|
-
messageTokens: omConfig.observation.messageTokens,
|
|
17429
|
-
modelSettings: omConfig.observation.modelSettings,
|
|
17430
|
-
maxTokensPerBatch: omConfig.observation.maxTokensPerBatch,
|
|
17431
|
-
providerOptions: omConfig.observation.providerOptions,
|
|
17432
|
-
bufferTokens: omConfig.observation.bufferTokens,
|
|
17433
|
-
bufferActivation: omConfig.observation.bufferActivation,
|
|
17434
|
-
blockAfter: omConfig.observation.blockAfter,
|
|
17435
|
-
previousObserverTokens: omConfig.observation.previousObserverTokens,
|
|
17436
|
-
instruction: omConfig.observation.instruction,
|
|
17437
|
-
threadTitle: omConfig.observation.threadTitle
|
|
17438
|
-
} : void 0,
|
|
17439
|
-
reflection: omConfig.reflection ? {
|
|
17440
|
-
model: omConfig.reflection.model,
|
|
17441
|
-
observationTokens: omConfig.reflection.observationTokens,
|
|
17442
|
-
modelSettings: omConfig.reflection.modelSettings,
|
|
17443
|
-
providerOptions: omConfig.reflection.providerOptions,
|
|
17444
|
-
bufferActivation: omConfig.reflection.bufferActivation,
|
|
17445
|
-
blockAfter: omConfig.reflection.blockAfter,
|
|
17446
|
-
instruction: omConfig.reflection.instruction
|
|
17447
|
-
} : void 0
|
|
17448
|
-
});
|
|
17572
|
+
const effectiveConfig = normalizeObservationalMemoryConfig(threadConfig.observationalMemory);
|
|
17573
|
+
if (!effectiveConfig) return null;
|
|
17574
|
+
const engine = await this.omEngine;
|
|
17575
|
+
if (!engine) return null;
|
|
17576
|
+
const { ObservationalMemoryProcessor } = await import('./observational-memory-WMCWT577.js');
|
|
17577
|
+
return new ObservationalMemoryProcessor(engine, this);
|
|
17449
17578
|
}
|
|
17450
17579
|
};
|
|
17451
17580
|
|