@mastra/memory 1.17.5-alpha.1 → 1.17.6-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/CHANGELOG.md +19 -0
- package/dist/{chunk-BPJLUC2F.js → chunk-NUYSX3DD.js} +78 -3
- package/dist/chunk-NUYSX3DD.js.map +1 -0
- package/dist/{chunk-UZDSNIGD.cjs → chunk-ZUUSLGY6.cjs} +78 -3
- package/dist/chunk-ZUUSLGY6.cjs.map +1 -0
- package/dist/docs/SKILL.md +1 -1
- package/dist/docs/assets/SOURCE_MAP.json +35 -35
- package/dist/index.cjs +13 -13
- package/dist/index.js +4 -4
- package/dist/{observational-memory-KWFKMLG6.cjs → observational-memory-BOXSRJOR.cjs} +26 -26
- package/dist/{observational-memory-KWFKMLG6.cjs.map → observational-memory-BOXSRJOR.cjs.map} +1 -1
- package/dist/{observational-memory-FBBKXNO5.js → observational-memory-KH7G7Y6B.js} +3 -3
- package/dist/{observational-memory-FBBKXNO5.js.map → observational-memory-KH7G7Y6B.js.map} +1 -1
- package/dist/processors/index.cjs +24 -24
- package/dist/processors/index.js +1 -1
- package/dist/processors/observational-memory/observer-agent.d.ts.map +1 -1
- package/package.json +7 -7
- package/dist/chunk-BPJLUC2F.js.map +0 -1
- package/dist/chunk-UZDSNIGD.cjs.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,24 @@
|
|
|
1
1
|
# @mastra/memory
|
|
2
2
|
|
|
3
|
+
## 1.17.6-alpha.0
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Fixed an issue where tool results containing AI SDK v5 `image-data` content blocks (returned via `toModelOutput`) were stringified into the observational memory prompt as raw base64 text. The base64 data overflowed the observer's context, causing token-limit errors and degenerate output. ([#16117](https://github.com/mastra-ai/mastra/pull/16117))
|
|
8
|
+
|
|
9
|
+
Image and file blocks (`image-data`, `image-url`, `file-data`, `file-url`, and `media`) inside tool results are now hoisted into the observer's input as proper attachments, the same way image and file message parts already are. The text body shows a placeholder like `[Image #1: image/png]` so the observer keeps positional context without seeing the bytes.
|
|
10
|
+
|
|
11
|
+
## 1.17.5
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- Fixed Observational Memory model resolution for user-defined gateways. Models such as `cloudflare/google/gemini-2.5-flash-lite` now resolve through registered gateways instead of failing with provider-config errors. Closes #13841. ([#16083](https://github.com/mastra-ai/mastra/pull/16083))
|
|
16
|
+
|
|
17
|
+
- Fixed async reflection buffering incorrectly triggering during idle timeout and provider-change activations when observation tokens are below the reflection activation threshold ([#16076](https://github.com/mastra-ai/mastra/pull/16076))
|
|
18
|
+
|
|
19
|
+
- Updated dependencies [[`6dcd65f`](https://github.com/mastra-ai/mastra/commit/6dcd65f2a34069e6dc43ba35f1d11119b9b40bef), [`86c0298`](https://github.com/mastra-ai/mastra/commit/86c0298e647306423c842f9d5ac827bd616bd13d), [`c05c9a1`](https://github.com/mastra-ai/mastra/commit/c05c9a13230988cef6d438a62f37760f31927bc7), [`ca28c23`](https://github.com/mastra-ai/mastra/commit/ca28c232a2f18801a6cf20fe053479237b4d4fb0), [`e24aacb`](https://github.com/mastra-ai/mastra/commit/e24aacba07bd66f5d95b636dc24016fca26b52cf), [`7679a63`](https://github.com/mastra-ai/mastra/commit/7679a634eae8e8ca459fd87538fdf72b4389b07f), [`7fce309`](https://github.com/mastra-ai/mastra/commit/7fce30912b14170bfc41f0ac736cca0f39fe0cd4), [`1d64a76`](https://github.com/mastra-ai/mastra/commit/1d64a765861a0772ea187bab76e5ed37bf82d042), [`1c2dda8`](https://github.com/mastra-ai/mastra/commit/1c2dda805fbfccc0abf55d4cb20cc34402dc3f0c), [`c721164`](https://github.com/mastra-ai/mastra/commit/c7211643f7ac861f83b19a3757cc921487fc9d75), [`1b55954`](https://github.com/mastra-ai/mastra/commit/1b559541c1e08a10e49d01ffc51a634dfc37a286), [`7997c2e`](https://github.com/mastra-ai/mastra/commit/7997c2e55ddd121562a4098cd8d2b89c68433bf1), [`5adc55e`](https://github.com/mastra-ai/mastra/commit/5adc55e63407be8ee977914957d68bcc2a075ceb), [`7679a63`](https://github.com/mastra-ai/mastra/commit/7679a634eae8e8ca459fd87538fdf72b4389b07f), [`a0d9b6d`](https://github.com/mastra-ai/mastra/commit/a0d9b6d6b810aeaa9e177a0dcc99a4402e609634), [`e97ccb9`](https://github.com/mastra-ai/mastra/commit/e97ccb900f8b7a390ce82c9f8eb8d6eb2c5e3777), [`c5daf48`](https://github.com/mastra-ai/mastra/commit/c5daf48556e98c46ae06caf00f92c249912007e9), [`70017d7`](https://github.com/mastra-ai/mastra/commit/70017d72ab741b5d7040e2a15c251a317782e39e), [`cd96779`](https://github.com/mastra-ai/mastra/commit/cd9677937f113b2856dc8b9f3d4bdabcee58bb2e), [`b0c7022`](https://github.com/mastra-ai/mastra/commit/b0c70224f80dad7c0cdbfb22cbff22e0f75c064f), [`e4942bc`](https://github.com/mastra-ai/mastra/commit/e4942bc7fdc903572f7d84f26d5e15f9d39c763d)]:
|
|
20
|
+
- @mastra/core@1.32.0
|
|
21
|
+
|
|
3
22
|
## 1.17.5-alpha.1
|
|
4
23
|
|
|
5
24
|
### Patch Changes
|
|
@@ -3158,6 +3158,71 @@ function formatObserverAttachmentPlaceholder(part, counter) {
|
|
|
3158
3158
|
const label = resolveObserverAttachmentLabel(part);
|
|
3159
3159
|
return label ? `[${attachmentType} #${attachmentId}: ${label}]` : `[${attachmentType} #${attachmentId}]`;
|
|
3160
3160
|
}
|
|
3161
|
+
function isRecord(value) {
|
|
3162
|
+
return !!value && typeof value === "object";
|
|
3163
|
+
}
|
|
3164
|
+
function mapToolResultBlockToAttachment(block) {
|
|
3165
|
+
if (!isRecord(block) || typeof block.type !== "string") {
|
|
3166
|
+
return void 0;
|
|
3167
|
+
}
|
|
3168
|
+
const mediaType = typeof block.mediaType === "string" ? block.mediaType : void 0;
|
|
3169
|
+
const filename = typeof block.filename === "string" ? block.filename : void 0;
|
|
3170
|
+
switch (block.type) {
|
|
3171
|
+
case "image-data": {
|
|
3172
|
+
const data = block.data;
|
|
3173
|
+
if (typeof data !== "string") return void 0;
|
|
3174
|
+
const image = mediaType ? `data:${mediaType};base64,${data}` : data;
|
|
3175
|
+
return { type: "image", image, mimeType: mediaType };
|
|
3176
|
+
}
|
|
3177
|
+
case "image-url": {
|
|
3178
|
+
const url = block.url;
|
|
3179
|
+
if (typeof url !== "string") return void 0;
|
|
3180
|
+
return { type: "image", image: url, mimeType: mediaType };
|
|
3181
|
+
}
|
|
3182
|
+
case "media": {
|
|
3183
|
+
const data = block.data;
|
|
3184
|
+
if (typeof data !== "string" || !mediaType) return void 0;
|
|
3185
|
+
const dataUri = `data:${mediaType};base64,${data}`;
|
|
3186
|
+
if (mediaType.toLowerCase().startsWith("image/")) {
|
|
3187
|
+
return { type: "image", image: dataUri, mimeType: mediaType };
|
|
3188
|
+
}
|
|
3189
|
+
return { type: "file", data: dataUri, mimeType: mediaType };
|
|
3190
|
+
}
|
|
3191
|
+
case "file-data": {
|
|
3192
|
+
const data = block.data;
|
|
3193
|
+
if (typeof data !== "string") return void 0;
|
|
3194
|
+
const dataUri = mediaType ? `data:${mediaType};base64,${data}` : data;
|
|
3195
|
+
return { type: "file", data: dataUri, mimeType: mediaType, filename };
|
|
3196
|
+
}
|
|
3197
|
+
case "file-url": {
|
|
3198
|
+
const url = block.url;
|
|
3199
|
+
if (typeof url !== "string") return void 0;
|
|
3200
|
+
return { type: "file", data: url, mimeType: mediaType, filename };
|
|
3201
|
+
}
|
|
3202
|
+
default:
|
|
3203
|
+
return void 0;
|
|
3204
|
+
}
|
|
3205
|
+
}
|
|
3206
|
+
function extractToolResultAttachments(result, counter) {
|
|
3207
|
+
if (!isRecord(result) || result.type !== "content" || !Array.isArray(result.value)) {
|
|
3208
|
+
return { resultWithoutAttachments: result, attachments: [] };
|
|
3209
|
+
}
|
|
3210
|
+
const record = result;
|
|
3211
|
+
const attachments = [];
|
|
3212
|
+
const newValue = record.value.map((block) => {
|
|
3213
|
+
const attachment = mapToolResultBlockToAttachment(block);
|
|
3214
|
+
if (!attachment) {
|
|
3215
|
+
return block;
|
|
3216
|
+
}
|
|
3217
|
+
attachments.push(toObserverInputAttachmentPart(attachment));
|
|
3218
|
+
const placeholder = formatObserverAttachmentPlaceholder(attachment, counter);
|
|
3219
|
+
return { type: isRecord(block) ? block.type : void 0, placeholder };
|
|
3220
|
+
});
|
|
3221
|
+
if (attachments.length === 0) {
|
|
3222
|
+
return { resultWithoutAttachments: result, attachments };
|
|
3223
|
+
}
|
|
3224
|
+
return { resultWithoutAttachments: { ...record, value: newValue }, attachments };
|
|
3225
|
+
}
|
|
3161
3226
|
function formatObserverPartLine(title, body, time, previousTime) {
|
|
3162
3227
|
const timeLabel = time && time !== previousTime ? `(${time})` : "";
|
|
3163
3228
|
if (!title) {
|
|
@@ -3247,9 +3312,19 @@ function formatObserverMessage(msg, counter, options) {
|
|
|
3247
3312
|
part,
|
|
3248
3313
|
inv.result
|
|
3249
3314
|
);
|
|
3315
|
+
const { resultWithoutAttachments, attachments: extractedAttachments } = extractToolResultAttachments(
|
|
3316
|
+
resultForObserver,
|
|
3317
|
+
counter
|
|
3318
|
+
);
|
|
3319
|
+
if (extractedAttachments.length > 0) {
|
|
3320
|
+
attachments.push(...extractedAttachments);
|
|
3321
|
+
}
|
|
3250
3322
|
pushLine(
|
|
3251
3323
|
`Tool Result ${inv.toolName}`,
|
|
3252
|
-
maybeTruncate(
|
|
3324
|
+
maybeTruncate(
|
|
3325
|
+
formatToolResultForObserver(resultWithoutAttachments, { maxTokens: maxToolResultTokens }),
|
|
3326
|
+
maxLen
|
|
3327
|
+
),
|
|
3253
3328
|
partCreatedAt
|
|
3254
3329
|
);
|
|
3255
3330
|
return;
|
|
@@ -9366,5 +9441,5 @@ function getObservationsAsOf(activeObservations, asOf) {
|
|
|
9366
9441
|
}
|
|
9367
9442
|
|
|
9368
9443
|
export { ModelByInputTokens, OBSERVER_SYSTEM_PROMPT, ObservationalMemory, ObservationalMemoryProcessor, TokenCounter, buildObserverPrompt, buildObserverSystemPrompt, combineObservationGroupRanges, deriveObservationGroupProvenance, extractCurrentTask, formatMessagesForObserver, formatToolResultForObserver, getObservationsAsOf, hasCurrentTaskSection, injectAnchorIds, optimizeObservationsForContext, parseAnchorId, parseObservationGroups, parseObserverOutput, reconcileObservationGroupsFromReflection, renderObservationGroupsForReflection, resolveToolResultValue, stripEphemeralAnchorIds, stripObservationGroups, truncateStringByTokens, wrapInObservationGroup };
|
|
9369
|
-
//# sourceMappingURL=chunk-
|
|
9370
|
-
//# sourceMappingURL=chunk-
|
|
9444
|
+
//# sourceMappingURL=chunk-NUYSX3DD.js.map
|
|
9445
|
+
//# sourceMappingURL=chunk-NUYSX3DD.js.map
|