@mastra/memory 1.20.3-alpha.0 → 1.20.5
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 +33 -0
- package/dist/{chunk-4TZ5SRFX.cjs → chunk-2ZNDDQ6X.cjs} +31 -12
- package/dist/chunk-2ZNDDQ6X.cjs.map +1 -0
- package/dist/{chunk-YJJXL5KY.js → chunk-3I6H2ABM.js} +31 -12
- package/dist/chunk-3I6H2ABM.js.map +1 -0
- package/dist/docs/SKILL.md +2 -1
- package/dist/docs/assets/SOURCE_MAP.json +47 -47
- package/dist/docs/references/docs-agents-goals.md +110 -0
- package/dist/index.cjs +23 -19
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +14 -10
- package/dist/index.js.map +1 -1
- package/dist/{observational-memory-6SHFQDPT.cjs → observational-memory-XZTKSWPR.cjs} +26 -26
- package/dist/{observational-memory-6SHFQDPT.cjs.map → observational-memory-XZTKSWPR.cjs.map} +1 -1
- package/dist/{observational-memory-NIGWGBLT.js → observational-memory-Y5T2OR2Y.js} +3 -3
- package/dist/{observational-memory-NIGWGBLT.js.map → observational-memory-Y5T2OR2Y.js.map} +1 -1
- package/dist/processors/index.cjs +24 -24
- package/dist/processors/index.js +1 -1
- package/dist/processors/observational-memory/internal-request-context.d.ts +10 -0
- package/dist/processors/observational-memory/internal-request-context.d.ts.map +1 -0
- package/dist/processors/observational-memory/model-context.d.ts +0 -8
- package/dist/processors/observational-memory/model-context.d.ts.map +1 -1
- package/dist/processors/observational-memory/observation-strategies/async-buffer.d.ts.map +1 -1
- package/dist/processors/observational-memory/observation-strategies/sync.d.ts.map +1 -1
- package/dist/processors/observational-memory/observer-runner.d.ts.map +1 -1
- package/dist/processors/observational-memory/reflector-runner.d.ts.map +1 -1
- package/package.json +13 -13
- package/dist/chunk-4TZ5SRFX.cjs.map +0 -1
- package/dist/chunk-YJJXL5KY.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,38 @@
|
|
|
1
1
|
# @mastra/memory
|
|
2
2
|
|
|
3
|
+
## 1.20.4
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Republished clean patch versions after compromised npm releases were published outside of the trusted release workflow. ([#18049](https://github.com/mastra-ai/mastra/pull/18049))
|
|
8
|
+
|
|
9
|
+
These packages must be released as clean versions higher than the compromised versions currently present on npm so semver ranges resolve to trusted tarballs.
|
|
10
|
+
|
|
11
|
+
- Prevent Observational Memory observer and reflector runs from blocking on their parent agent run by deriving an internal thread id for OM agent streams instead of reusing the parent thread id. ([#17829](https://github.com/mastra-ai/mastra/pull/17829))
|
|
12
|
+
|
|
13
|
+
- Avoid observational memory provider-change activation when the same model is attributed through provider subnamespaces such as `openai` and `openai.responses`. ([#17988](https://github.com/mastra-ai/mastra/pull/17988))
|
|
14
|
+
|
|
15
|
+
- Fixed the semantic recall embedding cache so it no longer grows without bound and can no longer return another message's embeddings. ([#17924](https://github.com/mastra-ai/mastra/pull/17924))
|
|
16
|
+
|
|
17
|
+
The in-process cache that stores embeddings for recall now uses an LRU with a fixed capacity, so a long-running `Memory` instance stops accumulating every message and query it has ever embedded (each entry holds chunk text plus vectors) for the lifetime of the process. Cache keys also moved from a 32-bit hash to a 64-bit hash, removing a collision that could make one message silently receive a different message's cached embeddings — corrupting what gets indexed and recalled.
|
|
18
|
+
|
|
19
|
+
No API changes; semantic recall results for correctly cached content are unchanged.
|
|
20
|
+
|
|
21
|
+
- Pin `image-size` to `1.2.1` to remediate CVE-2025-71330 (GHSA-w3rx-r6r6-pgpr). `image-size@2.x` has an unpatched DoS where a crafted ICNS image causes an infinite loop blocking the Node event loop, and no fixed 2.x release is available. `1.2.1` predates the vulnerable code paths and is API-compatible. Fixes #17975. ([#18017](https://github.com/mastra-ai/mastra/pull/18017))
|
|
22
|
+
|
|
23
|
+
- Updated dependencies [[`de66bb0`](https://github.com/mastra-ai/mastra/commit/de66bb040570444c702ce4d8e1e228a5de2949cb), [`67bf8e2`](https://github.com/mastra-ai/mastra/commit/67bf8e206dfe583954d96015cf0d09f7ac50e45f), [`8216d05`](https://github.com/mastra-ai/mastra/commit/8216d0528d866eb9a07f5d4c87ea3bb1e1139b45), [`d18b23c`](https://github.com/mastra-ai/mastra/commit/d18b23c5e29dfc381e73e3c51fcf6c779afd1823), [`5eb94eb`](https://github.com/mastra-ai/mastra/commit/5eb94ebcf66d4e28c9e26d5821ac93379bab20a0), [`1fa3e12`](https://github.com/mastra-ai/mastra/commit/1fa3e123582b63cfe49de4ee52dc6a065e8d956a), [`f9ee2ac`](https://github.com/mastra-ai/mastra/commit/f9ee2ac661af584e61bc063ac208c9035cd752ef), [`c853d53`](https://github.com/mastra-ai/mastra/commit/c853d535d2df84ab89db1adb4c28900c54c9a2d2), [`d8df1f8`](https://github.com/mastra-ai/mastra/commit/d8df1f8e947e1966c9d4e54713df56d0d0d65226), [`9192ddb`](https://github.com/mastra-ai/mastra/commit/9192ddbced8949113b30de444cbe763f075b59f5), [`ae96523`](https://github.com/mastra-ai/mastra/commit/ae965231f562d9766b0c90c49a69fc68acaa031c), [`17d5a92`](https://github.com/mastra-ai/mastra/commit/17d5a9211aa293b4d4418de3de70dc0394d58101), [`5573693`](https://github.com/mastra-ai/mastra/commit/5573693b589822250e20dfe6cf66e9ff3bc96da8), [`ec4da8a`](https://github.com/mastra-ai/mastra/commit/ec4da8a09e0d2ab452c6ee2c786042ea826b77e5), [`adc44e1`](https://github.com/mastra-ai/mastra/commit/adc44e13c7e570b91e86b20ea7556e61d819db31), [`ed346c0`](https://github.com/mastra-ai/mastra/commit/ed346c0bee2d8496690a4e538bfba1e46894660f), [`9b1adf7`](https://github.com/mastra-ai/mastra/commit/9b1adf7f39943c869182106bc4016e793b3304ac), [`c9ce1b2`](https://github.com/mastra-ai/mastra/commit/c9ce1b28d10871110648f9d7b6d76e880b9fa999), [`3ef01fd`](https://github.com/mastra-ai/mastra/commit/3ef01fd130b53d5bd4f828beb174e516a2eb1158), [`245a9a3`](https://github.com/mastra-ai/mastra/commit/245a9a315705fce17ddd980f78a92504b6615c4a), [`dc0b611`](https://github.com/mastra-ai/mastra/commit/dc0b6119b769bd00ee2c5df9259fb376fe63077a), [`38b5de8`](https://github.com/mastra-ai/mastra/commit/38b5de8e5d1d41a69522addf53d96f4b3a1d5bf0), [`dc0b611`](https://github.com/mastra-ai/mastra/commit/dc0b6119b769bd00ee2c5df9259fb376fe63077a), [`dd6a66e`](https://github.com/mastra-ai/mastra/commit/dd6a66ea0b32e0dea8059aec6b35d151e2c87dc4), [`d785c59`](https://github.com/mastra-ai/mastra/commit/d785c593b67fcb4cdc4fab9fdbde5f3b7665efc0), [`1fa3e12`](https://github.com/mastra-ai/mastra/commit/1fa3e123582b63cfe49de4ee52dc6a065e8d956a), [`8b984f4`](https://github.com/mastra-ai/mastra/commit/8b984f4361c202270ceb69257185c4756c9a7c56), [`bf08402`](https://github.com/mastra-ai/mastra/commit/bf084022374fa5d06ca70ed67a86dd64e379071b), [`81fe587`](https://github.com/mastra-ai/mastra/commit/81fe587275035715c1720ddf3fee0505cf053036), [`1fa3e12`](https://github.com/mastra-ai/mastra/commit/1fa3e123582b63cfe49de4ee52dc6a065e8d956a), [`403c438`](https://github.com/mastra-ai/mastra/commit/403c438e417278989ce247233d2c465b8d902cdd), [`f8ba195`](https://github.com/mastra-ai/mastra/commit/f8ba1954e27ee2b20586cc6cd9cf13c002c232f2)]:
|
|
24
|
+
- @mastra/core@1.43.0
|
|
25
|
+
- @mastra/schema-compat@1.2.12
|
|
26
|
+
|
|
27
|
+
## 1.20.3
|
|
28
|
+
|
|
29
|
+
### Patch Changes
|
|
30
|
+
|
|
31
|
+
- Fix final assistant text being lost after tool-approval resume when Observational Memory is enabled. During resume, input processors are skipped so no OM turn is created. The OM processor now directly persists new response messages in `processOutputResult` when no active turn exists. ([#17757](https://github.com/mastra-ai/mastra/pull/17757))
|
|
32
|
+
|
|
33
|
+
- Updated dependencies [[`d468acb`](https://github.com/mastra-ai/mastra/commit/d468acb07aec1bb19a2cb0ada8042b05b46746b2), [`575f815`](https://github.com/mastra-ai/mastra/commit/575f815c5c3567b71c0b83cbb7fa98c8253a9d9c), [`34839c1`](https://github.com/mastra-ai/mastra/commit/34839c1910b6964bf59ed0cee58844efebbb684e), [`053735a`](https://github.com/mastra-ai/mastra/commit/053735a75c2c18e23ce34d9468007efa4a45f4c4), [`306909a`](https://github.com/mastra-ai/mastra/commit/306909a693de77d709b38706e2673c9547d24a28), [`5191af8`](https://github.com/mastra-ai/mastra/commit/5191af80c799eea25357c545fc05d91b3883531d), [`43bd3d4`](https://github.com/mastra-ai/mastra/commit/43bd3d421987463fdf35386a45199c49499ed069), [`e6fa79e`](https://github.com/mastra-ai/mastra/commit/e6fa79ec72a2ddffdd25e85270398951e9d552a4), [`904bcdf`](https://github.com/mastra-ai/mastra/commit/904bcdf7b8004aa7be823f9f70ca63580e47e470), [`7f5ee1d`](https://github.com/mastra-ai/mastra/commit/7f5ee1dca46daee8d2817f2ebe49e6335da81956), [`1e9aab5`](https://github.com/mastra-ai/mastra/commit/1e9aab50ff11e6e88fde4d7cbf512c44a9fe8d61), [`2bccba4`](https://github.com/mastra-ai/mastra/commit/2bccba4c03cadc815c2d54cbf4dd43a922140a8d), [`bf8eb6d`](https://github.com/mastra-ai/mastra/commit/bf8eb6d0ec213a403eb9265a594ad283c44ab3dc), [`e9be4e7`](https://github.com/mastra-ai/mastra/commit/e9be4e747ec3d8b65548bff92f9377db06105376), [`493a328`](https://github.com/mastra-ai/mastra/commit/493a328f4346a1deeb9f1e2e44c8f2a3a4d7591b), [`d53cfc2`](https://github.com/mastra-ai/mastra/commit/d53cfc2c7f8d78343a4aa84ec4e129ba25f3325e), [`65799d4`](https://github.com/mastra-ai/mastra/commit/65799d4d549e5ebb9c848fbe3f51ac090f64becf), [`c268c89`](https://github.com/mastra-ai/mastra/commit/c268c89f4c63a93ee474d3cffdf3ea60bf00d4f2), [`34839c1`](https://github.com/mastra-ai/mastra/commit/34839c1910b6964bf59ed0cee58844efebbb684e), [`014e00f`](https://github.com/mastra-ai/mastra/commit/014e00f2b3a597a016b72f9901c6ab27d491f822), [`029a414`](https://github.com/mastra-ai/mastra/commit/029a4141719793bd3e898a39eb5a0466a55f5f3a), [`d468acb`](https://github.com/mastra-ai/mastra/commit/d468acb07aec1bb19a2cb0ada8042b05b46746b2), [`b147b29`](https://github.com/mastra-ai/mastra/commit/b147b2907f0cd1aa812efe6d6e3f58d22e66fc88), [`d371ac1`](https://github.com/mastra-ai/mastra/commit/d371ac1d9820afaaf7cfdbc380a475946a994d8f), [`2bccba4`](https://github.com/mastra-ai/mastra/commit/2bccba4c03cadc815c2d54cbf4dd43a922140a8d), [`0c72f03`](https://github.com/mastra-ai/mastra/commit/0c72f032abb13254df5a7856d64be2f207b8006d), [`cf182b7`](https://github.com/mastra-ai/mastra/commit/cf182b7fb495767946d9840ef29f19cfa906f31f), [`3b45ea9`](https://github.com/mastra-ai/mastra/commit/3b45ea95015557a6cb9d70dc5252af54ab1b78ac), [`a049c2a`](https://github.com/mastra-ai/mastra/commit/a049c2a9dfb41d0ee2e7a28874a88cd64fd5669f), [`f084be1`](https://github.com/mastra-ai/mastra/commit/f084be1fcbe33ad7480913e44d6130c421c0976f), [`b147b29`](https://github.com/mastra-ai/mastra/commit/b147b2907f0cd1aa812efe6d6e3f58d22e66fc88), [`2a96528`](https://github.com/mastra-ai/mastra/commit/2a9652848dfa3c5a2426f952e9d93554c26fd90f), [`f2ab060`](https://github.com/mastra-ai/mastra/commit/f2ab060162bea81505fda553e2cee29c1979fd04), [`5d302c8`](https://github.com/mastra-ai/mastra/commit/5d302c8eda1a6ac74eab5e442c4f64db6cc97a06), [`34839c1`](https://github.com/mastra-ai/mastra/commit/34839c1910b6964bf59ed0cee58844efebbb684e), [`a952852`](https://github.com/mastra-ai/mastra/commit/a952852c971a21fb646cd907c75fcf4443cdc963), [`2656d9c`](https://github.com/mastra-ai/mastra/commit/2656d9c2976d4f3354253bfbbbf9b88a1b2bbf34), [`63e3fe1`](https://github.com/mastra-ai/mastra/commit/63e3fe13cc1ea96f91d7c68aea92f400faf9e4da), [`1d4ce8d`](https://github.com/mastra-ai/mastra/commit/1d4ce8daaa54511f325c1b609d31b8e54009d677), [`8c68372`](https://github.com/mastra-ai/mastra/commit/8c68372e85fe0b066ec12c58bd29ffb93e54c552)]:
|
|
34
|
+
- @mastra/core@1.42.0
|
|
35
|
+
|
|
3
36
|
## 1.20.3-alpha.0
|
|
4
37
|
|
|
5
38
|
### Patch Changes
|
|
@@ -11,6 +11,7 @@ var path = require('path');
|
|
|
11
11
|
var crypto$1 = require('crypto');
|
|
12
12
|
var tokenx = require('tokenx');
|
|
13
13
|
var agent = require('@mastra/core/agent');
|
|
14
|
+
var requestContext = require('@mastra/core/request-context');
|
|
14
15
|
var observability = require('@mastra/core/observability');
|
|
15
16
|
var util = require('util');
|
|
16
17
|
var async_hooks = require('async_hooks');
|
|
@@ -250,16 +251,23 @@ var BufferingCoordinator = class _BufferingCoordinator {
|
|
|
250
251
|
};
|
|
251
252
|
|
|
252
253
|
// src/processors/observational-memory/model-context.ts
|
|
254
|
+
function parseComparableModelContext(model) {
|
|
255
|
+
const slashIndex = model.indexOf("/");
|
|
256
|
+
if (slashIndex === -1) return { modelId: model };
|
|
257
|
+
return {
|
|
258
|
+
provider: model.slice(0, slashIndex).split(".")[0],
|
|
259
|
+
modelId: model.slice(slashIndex + 1)
|
|
260
|
+
};
|
|
261
|
+
}
|
|
253
262
|
function didProviderChange(actorModel, lastModel) {
|
|
254
263
|
if (actorModel === void 0 || lastModel === void 0) return false;
|
|
255
|
-
const
|
|
256
|
-
const
|
|
257
|
-
if (
|
|
258
|
-
|
|
264
|
+
const actorContext = parseComparableModelContext(actorModel);
|
|
265
|
+
const lastContext = parseComparableModelContext(lastModel);
|
|
266
|
+
if (actorContext.modelId !== lastContext.modelId) return true;
|
|
267
|
+
if (actorContext.provider && lastContext.provider) {
|
|
268
|
+
return actorContext.provider !== lastContext.provider;
|
|
259
269
|
}
|
|
260
|
-
|
|
261
|
-
const lastModelId = lastHasSlash ? lastModel.slice(lastModel.indexOf("/") + 1) : lastModel;
|
|
262
|
-
return actorModelId !== lastModelId;
|
|
270
|
+
return false;
|
|
263
271
|
}
|
|
264
272
|
|
|
265
273
|
// src/processors/observational-memory/date-utils.ts
|
|
@@ -3913,6 +3921,14 @@ function optimizeObservationsForContext(observations) {
|
|
|
3913
3921
|
optimized = optimized.replace(/\n{3,}/g, "\n\n");
|
|
3914
3922
|
return optimized.trim();
|
|
3915
3923
|
}
|
|
3924
|
+
function withOmInternalThreadId(requestContext$1, omAgentId) {
|
|
3925
|
+
if (!requestContext$1) return void 0;
|
|
3926
|
+
const parentThreadId = requestContext$1.get(requestContext.MASTRA_THREAD_ID_KEY);
|
|
3927
|
+
if (typeof parentThreadId !== "string" || !parentThreadId) return requestContext$1;
|
|
3928
|
+
const internalRequestContext = new requestContext.RequestContext(requestContext$1.entries());
|
|
3929
|
+
internalRequestContext.set(requestContext.MASTRA_THREAD_ID_KEY, `${parentThreadId}-${omAgentId}`);
|
|
3930
|
+
return internalRequestContext;
|
|
3931
|
+
}
|
|
3916
3932
|
|
|
3917
3933
|
// src/processors/observational-memory/retry.ts
|
|
3918
3934
|
var RETRY_CONFIG = {
|
|
@@ -4174,6 +4190,7 @@ var ObserverRunner = class {
|
|
|
4174
4190
|
const inputTokens = this.tokenCounter.countMessages(messagesToObserve);
|
|
4175
4191
|
const resolvedModel = options?.model ? { model: options.model } : this.resolveModel(inputTokens);
|
|
4176
4192
|
const agent = this.createAgent(resolvedModel.model);
|
|
4193
|
+
const internalRequestContext = withOmInternalThreadId(options?.requestContext, agent.id);
|
|
4177
4194
|
const attachmentFilter = this.resolveAttachmentFilter(resolvedModel.model, options?.requestContext);
|
|
4178
4195
|
const observerMessages = [
|
|
4179
4196
|
{
|
|
@@ -4209,7 +4226,7 @@ var ObserverRunner = class {
|
|
|
4209
4226
|
modelSettings: { ...this.observationConfig.modelSettings },
|
|
4210
4227
|
providerOptions: this.observationConfig.providerOptions,
|
|
4211
4228
|
...abortSignal ? { abortSignal } : {},
|
|
4212
|
-
...
|
|
4229
|
+
...internalRequestContext ? { requestContext: internalRequestContext } : {},
|
|
4213
4230
|
...childObservabilityContext
|
|
4214
4231
|
});
|
|
4215
4232
|
return streamResult.getFullOutput();
|
|
@@ -4271,6 +4288,7 @@ var ObserverRunner = class {
|
|
|
4271
4288
|
);
|
|
4272
4289
|
const resolvedModel = model ? { model } : this.resolveModel(inputTokens);
|
|
4273
4290
|
const agent = this.createAgent(resolvedModel.model, true);
|
|
4291
|
+
const internalRequestContext = withOmInternalThreadId(requestContext, agent.id);
|
|
4274
4292
|
const multiThreadAttachmentFilter = this.resolveAttachmentFilter(resolvedModel.model, requestContext);
|
|
4275
4293
|
const observerMessages = [
|
|
4276
4294
|
{
|
|
@@ -4313,7 +4331,7 @@ var ObserverRunner = class {
|
|
|
4313
4331
|
modelSettings: { ...this.observationConfig.modelSettings },
|
|
4314
4332
|
providerOptions: this.observationConfig.providerOptions,
|
|
4315
4333
|
...abortSignal ? { abortSignal } : {},
|
|
4316
|
-
...
|
|
4334
|
+
...internalRequestContext ? { requestContext: internalRequestContext } : {},
|
|
4317
4335
|
...childObservabilityContext
|
|
4318
4336
|
});
|
|
4319
4337
|
return streamResult.getFullOutput();
|
|
@@ -4748,6 +4766,7 @@ var ReflectorRunner = class {
|
|
|
4748
4766
|
const originalTokens = this.tokenCounter.countObservations(observations);
|
|
4749
4767
|
const resolvedModel = model ? { model } : this.resolveModel(originalTokens);
|
|
4750
4768
|
const agent = this.createAgent(resolvedModel.model);
|
|
4769
|
+
const internalRequestContext = withOmInternalThreadId(requestContext, agent.id);
|
|
4751
4770
|
const targetThreshold = observationTokensThreshold ?? getMaxThreshold(this.reflectionConfig.observationTokens);
|
|
4752
4771
|
let totalUsage = { inputTokens: 0, outputTokens: 0, totalTokens: 0 };
|
|
4753
4772
|
const startLevel = compressionStartLevel ?? 0;
|
|
@@ -4788,7 +4807,7 @@ var ReflectorRunner = class {
|
|
|
4788
4807
|
},
|
|
4789
4808
|
providerOptions: this.reflectionConfig.providerOptions,
|
|
4790
4809
|
...abortSignal ? { abortSignal } : {},
|
|
4791
|
-
...
|
|
4810
|
+
...internalRequestContext ? { requestContext: internalRequestContext } : {},
|
|
4792
4811
|
...childObservabilityContext,
|
|
4793
4812
|
...attemptNumber === 1 ? {
|
|
4794
4813
|
onChunk(chunk) {
|
|
@@ -10019,5 +10038,5 @@ exports.stripEphemeralAnchorIds = stripEphemeralAnchorIds;
|
|
|
10019
10038
|
exports.stripObservationGroups = stripObservationGroups;
|
|
10020
10039
|
exports.truncateStringByTokens = truncateStringByTokens;
|
|
10021
10040
|
exports.wrapInObservationGroup = wrapInObservationGroup;
|
|
10022
|
-
//# sourceMappingURL=chunk-
|
|
10023
|
-
//# sourceMappingURL=chunk-
|
|
10041
|
+
//# sourceMappingURL=chunk-2ZNDDQ6X.cjs.map
|
|
10042
|
+
//# sourceMappingURL=chunk-2ZNDDQ6X.cjs.map
|