@mastra/memory 1.35.0 → 1.36.0-alpha.0
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 +1 -1
- package/dist/docs/references/docs-memory-observational-memory.md +25 -1
- package/dist/docs/references/reference-memory-observational-memory.md +3 -3
- package/dist/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/dist/processors/index.cjs +1 -1
- package/dist/processors/index.js +1 -1
- package/dist/processors/observational-memory/activation-ttl.d.ts +4 -2
- package/dist/processors/observational-memory/activation-ttl.d.ts.map +1 -1
- package/dist/processors/observational-memory/observational-memory.d.ts.map +1 -1
- package/dist/processors/observational-memory/processor.d.ts.map +1 -1
- package/dist/processors/observational-memory/reflector-runner.d.ts.map +1 -1
- package/dist/processors/observational-memory/types.d.ts +23 -4
- package/dist/processors/observational-memory/types.d.ts.map +1 -1
- package/dist/{src-CPCWMt3d.js → src-BV9eXuMM.js} +49 -8
- package/dist/{src-CPCWMt3d.js.map → src-BV9eXuMM.js.map} +1 -1
- package/dist/{src-BlhP1hpS.cjs → src-DhCg-LqR.cjs} +49 -8
- package/dist/{src-BlhP1hpS.cjs.map → src-DhCg-LqR.cjs.map} +1 -1
- package/package.json +2 -2
|
@@ -26045,8 +26045,23 @@ function getOpenAIPromptCacheRetention(providerOptions) {
|
|
|
26045
26045
|
const openaiOptions = providerOptions?.openai;
|
|
26046
26046
|
return typeof openaiOptions?.promptCacheRetention === "string" ? openaiOptions.promptCacheRetention.toLowerCase() : void 0;
|
|
26047
26047
|
}
|
|
26048
|
+
function isActivationTTLMap(activateAfterIdle) {
|
|
26049
|
+
return typeof activateAfterIdle === "object" && activateAfterIdle !== null;
|
|
26050
|
+
}
|
|
26051
|
+
/** The configured TTL for marker payloads. Per-provider maps are omitted; markers only carry scalar values. */
|
|
26052
|
+
function getMarkerActivationTTL(activateAfterIdle) {
|
|
26053
|
+
return isActivationTTLMap(activateAfterIdle) ? void 0 : activateAfterIdle;
|
|
26054
|
+
}
|
|
26055
|
+
/** A map entry applies when its key equals the model's provider before the first `.`, lowercased. */
|
|
26056
|
+
function resolveActivationTTLMapEntry(activateAfterIdle, modelContext) {
|
|
26057
|
+
const providerKey = normalize(modelContext?.provider).split(".")[0];
|
|
26058
|
+
if (providerKey && Object.hasOwn(activateAfterIdle.providers, providerKey)) return activateAfterIdle.providers[providerKey];
|
|
26059
|
+
return activateAfterIdle.default;
|
|
26060
|
+
}
|
|
26048
26061
|
function resolveActivationTTL(activateAfterIdle, modelContext) {
|
|
26049
|
-
|
|
26062
|
+
const ttl = isActivationTTLMap(activateAfterIdle) ? resolveActivationTTLMapEntry(activateAfterIdle, modelContext) : activateAfterIdle;
|
|
26063
|
+
if (ttl === void 0 || ttl === false) return;
|
|
26064
|
+
if (ttl !== "auto") return ttl;
|
|
26050
26065
|
return resolveAutoActivationTTL(modelContext);
|
|
26051
26066
|
}
|
|
26052
26067
|
function resolveAutoActivationTTL(modelContext) {
|
|
@@ -28856,7 +28871,7 @@ var ReflectorRunner = class {
|
|
|
28856
28871
|
messageTokens: getMaxThreshold(this.observationConfig.messageTokens),
|
|
28857
28872
|
observationTokens: getMaxThreshold(record ? this.getEffectiveReflectionTokens(record) : this.reflectionConfig.observationTokens),
|
|
28858
28873
|
scope: this.scope,
|
|
28859
|
-
activateAfterIdle: this.reflectionConfig.activateAfterIdle
|
|
28874
|
+
activateAfterIdle: getMarkerActivationTTL(this.reflectionConfig.activateAfterIdle)
|
|
28860
28875
|
};
|
|
28861
28876
|
}
|
|
28862
28877
|
/**
|
|
@@ -29287,7 +29302,7 @@ var ReflectorRunner = class {
|
|
|
29287
29302
|
currentModel: activationMetadata?.currentModel,
|
|
29288
29303
|
config: {
|
|
29289
29304
|
...this.getObservationMarkerConfig(freshRecord),
|
|
29290
|
-
activateAfterIdle: activationMetadata?.activateAfterIdle ?? this.reflectionConfig.activateAfterIdle
|
|
29305
|
+
activateAfterIdle: activationMetadata?.activateAfterIdle ?? getMarkerActivationTTL(this.reflectionConfig.activateAfterIdle)
|
|
29291
29306
|
}
|
|
29292
29307
|
});
|
|
29293
29308
|
writer.custom({
|
|
@@ -29976,6 +29991,32 @@ function parseActivationTTL(value, fieldPath) {
|
|
|
29976
29991
|
if (!Number.isFinite(amount) || amount < 0) throw new Error(`${fieldPath} must be a non-negative number of milliseconds or a duration string like "5m".`);
|
|
29977
29992
|
return amount * (unit === "ms" || unit === "msec" || unit === "msecs" || unit === "millisecond" || unit === "milliseconds" ? 1 : unit === "s" || unit === "sec" || unit === "secs" || unit === "second" || unit === "seconds" ? 1e3 : unit === "m" || unit === "min" || unit === "mins" || unit === "minute" || unit === "minutes" ? 6e4 : 36e5);
|
|
29978
29993
|
}
|
|
29994
|
+
/**
|
|
29995
|
+
* Parse an `activateAfterIdle` config value: a scalar TTL, or a per-provider map
|
|
29996
|
+
* like `{ default: 'auto', anthropic: '1h' }`.
|
|
29997
|
+
*/
|
|
29998
|
+
function parseActivationTTLConfig(value, fieldPath) {
|
|
29999
|
+
if (typeof value !== "object") return parseActivationTTL(value, fieldPath);
|
|
30000
|
+
if (value === null || Array.isArray(value)) throw new Error(`${fieldPath} must be a TTL value or an object of per-provider TTLs, e.g. { default: 'auto', anthropic: '1h' }.`);
|
|
30001
|
+
const entries = Object.entries(value).filter(([, entryValue]) => entryValue !== void 0);
|
|
30002
|
+
if (entries.length === 0) throw new Error(`${fieldPath} must set at least one provider or "default" when using per-provider TTLs, e.g. { default: 'auto', anthropic: '1h' }.`);
|
|
30003
|
+
const parsed = { providers: Object.create(null) };
|
|
30004
|
+
const seenKeys = /* @__PURE__ */ new Set();
|
|
30005
|
+
for (const [rawKey, entryValue] of entries) {
|
|
30006
|
+
const key = rawKey.trim().toLowerCase();
|
|
30007
|
+
const entryPath = `${fieldPath}.${rawKey}`;
|
|
30008
|
+
if (!key) throw new Error(`${fieldPath} contains an empty provider key.`);
|
|
30009
|
+
if (key.includes(".") || key.includes("/")) throw new Error(`${entryPath} is not a valid provider key. Use the provider name before the first ".", e.g. "anthropic" instead of "anthropic.messages".`);
|
|
30010
|
+
if (seenKeys.has(key)) throw new Error(`${entryPath} duplicates another key in ${fieldPath}. Provider keys are case-insensitive.`);
|
|
30011
|
+
seenKeys.add(key);
|
|
30012
|
+
if (entryValue !== false && typeof entryValue !== "number" && typeof entryValue !== "string") throw new Error(`${entryPath} must be a non-negative number of milliseconds, a duration string like "5m" or "1hr", "auto", or false.`);
|
|
30013
|
+
const ttl = entryValue === false ? false : parseActivationTTL(entryValue, entryPath);
|
|
30014
|
+
if (key === "default") {
|
|
30015
|
+
if (ttl !== false) parsed.default = ttl;
|
|
30016
|
+
} else parsed.providers[key] = ttl;
|
|
30017
|
+
}
|
|
30018
|
+
return parsed;
|
|
30019
|
+
}
|
|
29979
30020
|
let hasWarnedResourceScopeDeprecation = false;
|
|
29980
30021
|
/**
|
|
29981
30022
|
* ObservationalMemory - A three-agent memory system for long conversations.
|
|
@@ -30190,7 +30231,7 @@ var ObservationalMemory = class ObservationalMemory {
|
|
|
30190
30231
|
bufferTokens: asyncBufferingDisabled ? void 0 : resolveBufferTokens(config.observation?.bufferTokens ?? OBSERVATIONAL_MEMORY_DEFAULTS.observation.bufferTokens, config.observation?.messageTokens ?? OBSERVATIONAL_MEMORY_DEFAULTS.observation.messageTokens),
|
|
30191
30232
|
bufferOnIdle: config.observation?.bufferOnIdle ?? false,
|
|
30192
30233
|
bufferActivation: asyncBufferingDisabled ? void 0 : config.observation?.bufferActivation ?? OBSERVATIONAL_MEMORY_DEFAULTS.observation.bufferActivation,
|
|
30193
|
-
activateAfterIdle:
|
|
30234
|
+
activateAfterIdle: parseActivationTTLConfig(observationActivateAfterIdle, observationActivateAfterIdlePath),
|
|
30194
30235
|
activateOnProviderChange: config.observation?.activateOnProviderChange ?? config.activateOnProviderChange ?? false,
|
|
30195
30236
|
blockAfter: asyncBufferingDisabled ? void 0 : resolveBlockAfter(config.observation?.blockAfter ?? (config.observation?.bufferTokens ?? OBSERVATIONAL_MEMORY_DEFAULTS.observation.bufferTokens ? 1.2 : void 0), config.observation?.messageTokens ?? OBSERVATIONAL_MEMORY_DEFAULTS.observation.messageTokens),
|
|
30196
30237
|
previousObserverTokens: config.observation?.previousObserverTokens ?? 2e3,
|
|
@@ -30215,7 +30256,7 @@ var ObservationalMemory = class ObservationalMemory {
|
|
|
30215
30256
|
},
|
|
30216
30257
|
providerOptions: config.reflection?.providerOptions ?? OBSERVATIONAL_MEMORY_DEFAULTS.reflection.providerOptions,
|
|
30217
30258
|
bufferActivation: asyncBufferingDisabled ? void 0 : config?.reflection?.bufferActivation ?? OBSERVATIONAL_MEMORY_DEFAULTS.reflection.bufferActivation,
|
|
30218
|
-
activateAfterIdle:
|
|
30259
|
+
activateAfterIdle: parseActivationTTLConfig(config.reflection?.activateAfterIdle, "reflection.activateAfterIdle"),
|
|
30219
30260
|
activateOnProviderChange: config.reflection?.activateOnProviderChange ?? false,
|
|
30220
30261
|
blockAfter: asyncBufferingDisabled ? void 0 : resolveBlockAfter(config.reflection?.blockAfter ?? (config.reflection?.bufferActivation ?? OBSERVATIONAL_MEMORY_DEFAULTS.reflection.bufferActivation ? 1.2 : void 0), config.reflection?.observationTokens ?? OBSERVATIONAL_MEMORY_DEFAULTS.reflection.observationTokens),
|
|
30221
30262
|
instruction: config.reflection?.instruction,
|
|
@@ -30541,7 +30582,7 @@ var ObservationalMemory = class ObservationalMemory {
|
|
|
30541
30582
|
messageTokens: getMaxThreshold(this.observationConfig.messageTokens),
|
|
30542
30583
|
observationTokens: getMaxThreshold(this.reflectionConfig.observationTokens),
|
|
30543
30584
|
scope: this.scope,
|
|
30544
|
-
activateAfterIdle: this.observationConfig.activateAfterIdle
|
|
30585
|
+
activateAfterIdle: getMarkerActivationTTL(this.observationConfig.activateAfterIdle)
|
|
30545
30586
|
};
|
|
30546
30587
|
}
|
|
30547
30588
|
/**
|
|
@@ -31942,7 +31983,7 @@ ${formattedMessages}
|
|
|
31942
31983
|
currentModel,
|
|
31943
31984
|
config: {
|
|
31944
31985
|
...this.getObservationMarkerConfig(),
|
|
31945
|
-
activateAfterIdle: activationActivateAfterIdle ?? this.observationConfig.activateAfterIdle
|
|
31986
|
+
activateAfterIdle: activationActivateAfterIdle ?? getMarkerActivationTTL(this.observationConfig.activateAfterIdle)
|
|
31946
31987
|
}
|
|
31947
31988
|
});
|
|
31948
31989
|
opts.writer.custom({
|
|
@@ -35457,4 +35498,4 @@ Object.defineProperty(exports, "wrapInObservationGroup", {
|
|
|
35457
35498
|
}
|
|
35458
35499
|
});
|
|
35459
35500
|
|
|
35460
|
-
//# sourceMappingURL=src-
|
|
35501
|
+
//# sourceMappingURL=src-DhCg-LqR.cjs.map
|