@mastra/memory 1.17.5 → 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 +8 -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
|
@@ -3165,6 +3165,71 @@ function formatObserverAttachmentPlaceholder(part, counter) {
|
|
|
3165
3165
|
const label = resolveObserverAttachmentLabel(part);
|
|
3166
3166
|
return label ? `[${attachmentType} #${attachmentId}: ${label}]` : `[${attachmentType} #${attachmentId}]`;
|
|
3167
3167
|
}
|
|
3168
|
+
function isRecord(value) {
|
|
3169
|
+
return !!value && typeof value === "object";
|
|
3170
|
+
}
|
|
3171
|
+
function mapToolResultBlockToAttachment(block) {
|
|
3172
|
+
if (!isRecord(block) || typeof block.type !== "string") {
|
|
3173
|
+
return void 0;
|
|
3174
|
+
}
|
|
3175
|
+
const mediaType = typeof block.mediaType === "string" ? block.mediaType : void 0;
|
|
3176
|
+
const filename = typeof block.filename === "string" ? block.filename : void 0;
|
|
3177
|
+
switch (block.type) {
|
|
3178
|
+
case "image-data": {
|
|
3179
|
+
const data = block.data;
|
|
3180
|
+
if (typeof data !== "string") return void 0;
|
|
3181
|
+
const image = mediaType ? `data:${mediaType};base64,${data}` : data;
|
|
3182
|
+
return { type: "image", image, mimeType: mediaType };
|
|
3183
|
+
}
|
|
3184
|
+
case "image-url": {
|
|
3185
|
+
const url = block.url;
|
|
3186
|
+
if (typeof url !== "string") return void 0;
|
|
3187
|
+
return { type: "image", image: url, mimeType: mediaType };
|
|
3188
|
+
}
|
|
3189
|
+
case "media": {
|
|
3190
|
+
const data = block.data;
|
|
3191
|
+
if (typeof data !== "string" || !mediaType) return void 0;
|
|
3192
|
+
const dataUri = `data:${mediaType};base64,${data}`;
|
|
3193
|
+
if (mediaType.toLowerCase().startsWith("image/")) {
|
|
3194
|
+
return { type: "image", image: dataUri, mimeType: mediaType };
|
|
3195
|
+
}
|
|
3196
|
+
return { type: "file", data: dataUri, mimeType: mediaType };
|
|
3197
|
+
}
|
|
3198
|
+
case "file-data": {
|
|
3199
|
+
const data = block.data;
|
|
3200
|
+
if (typeof data !== "string") return void 0;
|
|
3201
|
+
const dataUri = mediaType ? `data:${mediaType};base64,${data}` : data;
|
|
3202
|
+
return { type: "file", data: dataUri, mimeType: mediaType, filename };
|
|
3203
|
+
}
|
|
3204
|
+
case "file-url": {
|
|
3205
|
+
const url = block.url;
|
|
3206
|
+
if (typeof url !== "string") return void 0;
|
|
3207
|
+
return { type: "file", data: url, mimeType: mediaType, filename };
|
|
3208
|
+
}
|
|
3209
|
+
default:
|
|
3210
|
+
return void 0;
|
|
3211
|
+
}
|
|
3212
|
+
}
|
|
3213
|
+
function extractToolResultAttachments(result, counter) {
|
|
3214
|
+
if (!isRecord(result) || result.type !== "content" || !Array.isArray(result.value)) {
|
|
3215
|
+
return { resultWithoutAttachments: result, attachments: [] };
|
|
3216
|
+
}
|
|
3217
|
+
const record = result;
|
|
3218
|
+
const attachments = [];
|
|
3219
|
+
const newValue = record.value.map((block) => {
|
|
3220
|
+
const attachment = mapToolResultBlockToAttachment(block);
|
|
3221
|
+
if (!attachment) {
|
|
3222
|
+
return block;
|
|
3223
|
+
}
|
|
3224
|
+
attachments.push(toObserverInputAttachmentPart(attachment));
|
|
3225
|
+
const placeholder = formatObserverAttachmentPlaceholder(attachment, counter);
|
|
3226
|
+
return { type: isRecord(block) ? block.type : void 0, placeholder };
|
|
3227
|
+
});
|
|
3228
|
+
if (attachments.length === 0) {
|
|
3229
|
+
return { resultWithoutAttachments: result, attachments };
|
|
3230
|
+
}
|
|
3231
|
+
return { resultWithoutAttachments: { ...record, value: newValue }, attachments };
|
|
3232
|
+
}
|
|
3168
3233
|
function formatObserverPartLine(title, body, time, previousTime) {
|
|
3169
3234
|
const timeLabel = time && time !== previousTime ? `(${time})` : "";
|
|
3170
3235
|
if (!title) {
|
|
@@ -3254,9 +3319,19 @@ function formatObserverMessage(msg, counter, options) {
|
|
|
3254
3319
|
part,
|
|
3255
3320
|
inv.result
|
|
3256
3321
|
);
|
|
3322
|
+
const { resultWithoutAttachments, attachments: extractedAttachments } = extractToolResultAttachments(
|
|
3323
|
+
resultForObserver,
|
|
3324
|
+
counter
|
|
3325
|
+
);
|
|
3326
|
+
if (extractedAttachments.length > 0) {
|
|
3327
|
+
attachments.push(...extractedAttachments);
|
|
3328
|
+
}
|
|
3257
3329
|
pushLine(
|
|
3258
3330
|
`Tool Result ${inv.toolName}`,
|
|
3259
|
-
maybeTruncate(
|
|
3331
|
+
maybeTruncate(
|
|
3332
|
+
formatToolResultForObserver(resultWithoutAttachments, { maxTokens: maxToolResultTokens }),
|
|
3333
|
+
maxLen
|
|
3334
|
+
),
|
|
3260
3335
|
partCreatedAt
|
|
3261
3336
|
);
|
|
3262
3337
|
return;
|
|
@@ -9398,5 +9473,5 @@ exports.stripEphemeralAnchorIds = stripEphemeralAnchorIds;
|
|
|
9398
9473
|
exports.stripObservationGroups = stripObservationGroups;
|
|
9399
9474
|
exports.truncateStringByTokens = truncateStringByTokens;
|
|
9400
9475
|
exports.wrapInObservationGroup = wrapInObservationGroup;
|
|
9401
|
-
//# sourceMappingURL=chunk-
|
|
9402
|
-
//# sourceMappingURL=chunk-
|
|
9476
|
+
//# sourceMappingURL=chunk-ZUUSLGY6.cjs.map
|
|
9477
|
+
//# sourceMappingURL=chunk-ZUUSLGY6.cjs.map
|