@mastra/memory 1.26.1-alpha.4 → 1.26.1-alpha.7
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 +32 -0
- package/dist/docs/SKILL.md +15 -9
- package/dist/docs/assets/SOURCE_MAP.json +1 -1
- package/dist/docs/references/docs-agents-agent-approval.md +14 -0
- package/dist/docs/references/docs-agents-networks.md +2 -2
- package/dist/docs/references/docs-capabilities-subagents.md +6 -3
- package/dist/docs/references/docs-long-running-agents-goals.md +1 -1
- package/dist/docs/references/docs-memory-memory-processors.md +5 -5
- package/dist/docs/references/docs-memory-message-history.md +3 -3
- package/dist/docs/references/docs-memory-observational-memory.md +1 -1
- package/dist/docs/references/docs-storage-overview.md +14 -13
- package/dist/docs/references/integrations-channels-github.md +103 -0
- package/dist/docs/references/{reference-storage-dsql.md → integrations-databases-aurora-dsql.md} +1 -1
- package/dist/docs/references/{reference-storage-dynamodb.md → integrations-databases-dynamodb.md} +1 -1
- package/dist/docs/references/{reference-storage-libsql.md → integrations-databases-libsql.md} +2 -2
- package/dist/docs/references/{reference-storage-mongodb.md → integrations-databases-mongodb.md} +1 -1
- package/dist/docs/references/{reference-storage-oracledb.md → integrations-databases-oracledb.md} +1 -1
- package/dist/docs/references/{reference-storage-postgresql.md → integrations-databases-postgresql.md} +1 -1
- package/dist/docs/references/{reference-storage-redis.md → integrations-databases-redis.md} +1 -1
- package/dist/docs/references/{reference-storage-upstash.md → integrations-databases-upstash.md} +1 -1
- package/dist/docs/references/reference-file-based-agents-memory.md +2 -0
- package/dist/docs/references/reference-migrations-agentnetwork.md +100 -0
- package/dist/docs/references/reference-migrations-upgrade-to-v1-memory.md +288 -0
- package/dist/docs/references/reference-vectors-oracledb.md +2 -2
- 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/measure-image-buffer.d.ts +23 -0
- package/dist/processors/observational-memory/measure-image-buffer.d.ts.map +1 -0
- package/dist/processors/observational-memory/observation-strategies/async-buffer.d.ts.map +1 -1
- package/dist/{src-kjoZv97r.cjs → src-CTwoCwmY.cjs} +65 -32
- package/dist/src-CTwoCwmY.cjs.map +1 -0
- package/dist/{src-hv0DMVM-.js → src-DGdlH4fo.js} +64 -31
- package/dist/src-DGdlH4fo.js.map +1 -0
- package/package.json +4 -5
- package/dist/src-hv0DMVM-.js.map +0 -1
- package/dist/src-kjoZv97r.cjs.map +0 -1
|
@@ -19,7 +19,7 @@ import { estimateTokenCount } from "tokenx";
|
|
|
19
19
|
import { createHash, randomBytes, randomUUID } from "crypto";
|
|
20
20
|
import { InMemoryStore } from "@mastra/core/storage";
|
|
21
21
|
import { AsyncLocalStorage } from "async_hooks";
|
|
22
|
-
import
|
|
22
|
+
import probeImageSizeSync from "probe-image-size/sync.js";
|
|
23
23
|
import { createTool } from "@mastra/core/tools";
|
|
24
24
|
import { isStandardSchemaWithJSON as isStandardSchemaWithJSON$1, toStandardSchema as toStandardSchema$1 } from "@mastra/core/schema";
|
|
25
25
|
import { ErrorCategory, ErrorDomain, MastraError } from "@mastra/core/error";
|
|
@@ -17345,6 +17345,42 @@ var ObserverRunner = class {
|
|
|
17345
17345
|
}
|
|
17346
17346
|
};
|
|
17347
17347
|
//#endregion
|
|
17348
|
+
//#region src/processors/observational-memory/measure-image-buffer.ts
|
|
17349
|
+
/**
|
|
17350
|
+
* Synchronous image dimension lookup for in-memory image buffers.
|
|
17351
|
+
*
|
|
17352
|
+
* Uses `probe-image-size`'s sync parsers rather than `image-size`, which has unfixed
|
|
17353
|
+
* denial-of-service advisories (GHSA-w3rx-r6r6-pgpr / CVE-2025-71330 and
|
|
17354
|
+
* GHSA-5p2g-fcmc-qvqq) affecting every published version, on an archived repository
|
|
17355
|
+
* with no fixed release coming. A malformed 32-byte ICNS buffer was enough to hang the
|
|
17356
|
+
* parse loop and exhaust the heap, and image bytes reaching agent memory are untrusted.
|
|
17357
|
+
*
|
|
17358
|
+
* `probe-image-size` covers the formats models actually accept (PNG, JPEG, WebP, GIF,
|
|
17359
|
+
* AVIF, BMP, ICO, PSD, SVG, TIFF). Anything else returns `undefined`, which callers
|
|
17360
|
+
* already handle as "dimensions unknown".
|
|
17361
|
+
*/
|
|
17362
|
+
const probeBuffer = probeImageSizeSync;
|
|
17363
|
+
/**
|
|
17364
|
+
* Read the pixel dimensions of an image buffer.
|
|
17365
|
+
*
|
|
17366
|
+
* @returns The dimensions, or `undefined` if the buffer isn't a recognized image.
|
|
17367
|
+
*/
|
|
17368
|
+
function measureImageBuffer(buffer) {
|
|
17369
|
+
let probed;
|
|
17370
|
+
try {
|
|
17371
|
+
probed = probeBuffer(buffer);
|
|
17372
|
+
} catch {
|
|
17373
|
+
return;
|
|
17374
|
+
}
|
|
17375
|
+
if (!probed) return;
|
|
17376
|
+
const { width, height } = probed;
|
|
17377
|
+
if (typeof width !== "number" || !Number.isFinite(width) || typeof height !== "number" || !Number.isFinite(height)) return;
|
|
17378
|
+
return {
|
|
17379
|
+
width,
|
|
17380
|
+
height
|
|
17381
|
+
};
|
|
17382
|
+
}
|
|
17383
|
+
//#endregion
|
|
17348
17384
|
//#region src/processors/observational-memory/token-counter.ts
|
|
17349
17385
|
const IMAGE_FILE_EXTENSIONS = /* @__PURE__ */ new Set([
|
|
17350
17386
|
"png",
|
|
@@ -17651,26 +17687,23 @@ function resolveImageDimensions(part) {
|
|
|
17651
17687
|
width,
|
|
17652
17688
|
height
|
|
17653
17689
|
};
|
|
17654
|
-
|
|
17655
|
-
|
|
17656
|
-
|
|
17657
|
-
|
|
17658
|
-
|
|
17659
|
-
|
|
17660
|
-
|
|
17661
|
-
|
|
17662
|
-
|
|
17663
|
-
|
|
17664
|
-
|
|
17665
|
-
|
|
17666
|
-
|
|
17667
|
-
|
|
17668
|
-
}
|
|
17669
|
-
|
|
17670
|
-
|
|
17671
|
-
height
|
|
17672
|
-
};
|
|
17673
|
-
}
|
|
17690
|
+
const measured = measureImageBuffer(buffer);
|
|
17691
|
+
if (!measured) return {
|
|
17692
|
+
width,
|
|
17693
|
+
height
|
|
17694
|
+
};
|
|
17695
|
+
const measuredWidth = getFiniteNumber(measured.width);
|
|
17696
|
+
const measuredHeight = getFiniteNumber(measured.height);
|
|
17697
|
+
if (!measuredWidth || !measuredHeight) return {
|
|
17698
|
+
width,
|
|
17699
|
+
height
|
|
17700
|
+
};
|
|
17701
|
+
const resolved = {
|
|
17702
|
+
width: width ?? measuredWidth,
|
|
17703
|
+
height: height ?? measuredHeight
|
|
17704
|
+
};
|
|
17705
|
+
persistImageDimensions(part, resolved);
|
|
17706
|
+
return resolved;
|
|
17674
17707
|
}
|
|
17675
17708
|
function getBase64Size(base64) {
|
|
17676
17709
|
const sanitized = base64.replace(/\s+/g, "");
|
|
@@ -21379,7 +21412,7 @@ var SyncObservationStrategy = class extends ObservationStrategy {
|
|
|
21379
21412
|
},
|
|
21380
21413
|
lastObservedMessageCursor: getLastObservedMessageCursor(messages)
|
|
21381
21414
|
});
|
|
21382
|
-
await this.storage.
|
|
21415
|
+
await this.storage.patchThread({
|
|
21383
21416
|
id: threadId,
|
|
21384
21417
|
...shouldUpdateThreadTitle ? { title: newTitle } : {},
|
|
21385
21418
|
metadata: newMetadata
|
|
@@ -21571,7 +21604,7 @@ var AsyncBufferObservationStrategy = class extends ObservationStrategy {
|
|
|
21571
21604
|
...metadataUpdate.extracted ?? {}
|
|
21572
21605
|
}
|
|
21573
21606
|
});
|
|
21574
|
-
await this.storage.
|
|
21607
|
+
await this.storage.patchThread({
|
|
21575
21608
|
id: threadId,
|
|
21576
21609
|
...shouldUpdateThreadTitle ? { title: newTitle } : {},
|
|
21577
21610
|
metadata: newMetadata
|
|
@@ -21916,7 +21949,7 @@ var ResourceScopedObservationStrategy = class extends ObservationStrategy {
|
|
|
21916
21949
|
},
|
|
21917
21950
|
lastObservedMessageCursor: update.lastObservedMessageCursor
|
|
21918
21951
|
});
|
|
21919
|
-
await this.storage.
|
|
21952
|
+
await this.storage.patchThread({
|
|
21920
21953
|
id: update.threadId,
|
|
21921
21954
|
...shouldUpdateThreadTitle ? { title: newTitle } : {},
|
|
21922
21955
|
metadata: newMetadata
|
|
@@ -22859,7 +22892,7 @@ async function persistThreadExtractedValues(storage, extractors, threadId, value
|
|
|
22859
22892
|
...metadataUpdate.extracted ?? {}
|
|
22860
22893
|
}
|
|
22861
22894
|
});
|
|
22862
|
-
await storage.
|
|
22895
|
+
await storage.patchThread({
|
|
22863
22896
|
id: threadId,
|
|
22864
22897
|
metadata: newMetadata
|
|
22865
22898
|
});
|
|
@@ -25830,7 +25863,7 @@ ${formattedMessages}
|
|
|
25830
25863
|
const oldTitle = thread.title?.trim();
|
|
25831
25864
|
const newTitle = chunkThreadTitle?.trim();
|
|
25832
25865
|
const shouldUpdateThreadTitle = !!newTitle && newTitle.length >= 3 && newTitle !== oldTitle;
|
|
25833
|
-
await this.storage.
|
|
25866
|
+
await this.storage.patchThread({
|
|
25834
25867
|
id: threadId,
|
|
25835
25868
|
...shouldUpdateThreadTitle ? { title: newTitle } : {},
|
|
25836
25869
|
metadata: newMetadata
|
|
@@ -26048,7 +26081,7 @@ ${formattedMessages}
|
|
|
26048
26081
|
...metadataUpdate.extracted ?? {}
|
|
26049
26082
|
}
|
|
26050
26083
|
});
|
|
26051
|
-
await this.storage.
|
|
26084
|
+
await this.storage.patchThread({
|
|
26052
26085
|
id: threadId,
|
|
26053
26086
|
metadata: newMetadata
|
|
26054
26087
|
});
|
|
@@ -27102,7 +27135,7 @@ var Memory = class extends MastraMemory {
|
|
|
27102
27135
|
return savedThread;
|
|
27103
27136
|
}
|
|
27104
27137
|
async updateThread({ id, title, metadata, memoryConfig }) {
|
|
27105
|
-
const updatedThread = await (await this.getMemoryStore()).
|
|
27138
|
+
const updatedThread = await (await this.getMemoryStore()).patchThread({
|
|
27106
27139
|
id,
|
|
27107
27140
|
title,
|
|
27108
27141
|
metadata
|
|
@@ -27193,7 +27226,7 @@ var Memory = class extends MastraMemory {
|
|
|
27193
27226
|
else {
|
|
27194
27227
|
const thread = await this.getThreadById({ threadId });
|
|
27195
27228
|
if (!thread) throw new Error(`Thread ${threadId} not found`);
|
|
27196
|
-
await memoryStore.
|
|
27229
|
+
await memoryStore.patchThread({
|
|
27197
27230
|
id: threadId,
|
|
27198
27231
|
metadata: {
|
|
27199
27232
|
...thread.metadata,
|
|
@@ -27281,7 +27314,7 @@ ${workingMemory}`;
|
|
|
27281
27314
|
} else {
|
|
27282
27315
|
const thread = await this.getThreadById({ threadId });
|
|
27283
27316
|
if (!thread) throw new Error(`Thread ${threadId} not found`);
|
|
27284
|
-
await memoryStore.
|
|
27317
|
+
await memoryStore.patchThread({
|
|
27285
27318
|
id: threadId,
|
|
27286
27319
|
metadata: {
|
|
27287
27320
|
...thread.metadata,
|
|
@@ -28619,4 +28652,4 @@ Notes:
|
|
|
28619
28652
|
//#endregion
|
|
28620
28653
|
export { extractCurrentTask as A, OBSERVATION_CONTEXT_INSTRUCTIONS as B, WorkingMemoryExtractor as C, OBSERVER_SYSTEM_PROMPT as D, TokenCounter as E, injectAnchorIds as F, OBSERVATION_CONTINUATION_HINT as H, parseAnchorId as I, stripEphemeralAnchorIds as L, hasCurrentTaskSection as M, optimizeObservationsForContext as N, buildObserverPrompt as O, parseObserverOutput as P, Extractor as R, deepMergeWorkingMemory as S, summarizeConversation as T, OBSERVATION_CONTEXT_PROMPT as V, reconcileObservationGroupsFromReflection as _, extractWorkingMemoryContent as a, wrapInObservationGroup as b, WORKING_MEMORY_STATE_ID as c, getObservationsAsOf as d, ObservationalMemoryProcessor as f, parseObservationGroups as g, deriveObservationGroupProvenance as h, WorkingMemory as i, formatMessagesForObserver as j, buildObserverSystemPrompt as k, WORKING_MEMORY_STATE_PROCESSOR_ID as l, combineObservationGroupRanges as m, MessageHistory$1 as n, extractWorkingMemoryTags as o, ObservationalMemory as p, SemanticRecall as r, removeWorkingMemoryTags as s, Memory as t, WorkingMemoryStateProcessor as u, renderObservationGroupsForReflection as v, SUMMARIZE_THREAD_DEFAULTS as w, ModelByInputTokens as x, stripObservationGroups as y, OBSERVATIONAL_MEMORY_DEFAULTS as z };
|
|
28621
28654
|
|
|
28622
|
-
//# sourceMappingURL=src-
|
|
28655
|
+
//# sourceMappingURL=src-DGdlH4fo.js.map
|