@mastra/memory 1.37.1-alpha.0 → 1.37.1-alpha.2
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-multi-user-threads.md +1 -1
- package/dist/docs/references/reference-memory-listThreads.md +1 -1
- package/dist/docs/references/reference-processors-token-limiter-processor.md +2 -2
- package/dist/docs/references/reference-vectors-libsql.md +1 -1
- package/dist/docs/references/reference-vectors-mongodb.md +2 -1
- package/dist/docs/references/reference-vectors-pg.md +16 -11
- package/dist/docs/references/reference-vectors-upstash.md +10 -4
- 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/extraction-runner.d.ts.map +1 -1
- package/dist/processors/observational-memory/working-memory-extractor.d.ts.map +1 -1
- package/dist/{src-ThciS3vu.js → src-CYkACM_1.js} +30 -11
- package/dist/{src-ThciS3vu.js.map → src-CYkACM_1.js.map} +1 -1
- package/dist/{src-BpxX0T2g.cjs → src-DTJFmjDz.cjs} +30 -11
- package/dist/{src-BpxX0T2g.cjs.map → src-DTJFmjDz.cjs.map} +1 -1
- package/package.json +5 -5
|
@@ -19251,8 +19251,12 @@ function formatOmError(error) {
|
|
|
19251
19251
|
function isAbortError(error, abortSignal) {
|
|
19252
19252
|
return abortSignal?.aborted === true || hasAbortInChain(error);
|
|
19253
19253
|
}
|
|
19254
|
+
function hasEmptyObjectValue(object, extractor) {
|
|
19255
|
+
const value = object[extractor.slug];
|
|
19256
|
+
return typeof value === "object" && value !== null && !Array.isArray(value) && Object.keys(value).length === 0;
|
|
19257
|
+
}
|
|
19254
19258
|
function shouldRetryEmptyStructuredObject(object, extractors) {
|
|
19255
|
-
return Object.keys(object).length === 0
|
|
19259
|
+
return extractors.some((extractor) => extractor.retryStructuredExtractionOnEmptyObject && (Object.keys(object).length === 0 || hasEmptyObjectValue(object, extractor)));
|
|
19256
19260
|
}
|
|
19257
19261
|
async function extractStructuredValues(opts) {
|
|
19258
19262
|
const structuredExtractors = (opts.extractors ?? []).filter((extractor) => extractor.mode === "structured");
|
|
@@ -19326,17 +19330,28 @@ ${extractorInstructions}${priorLines.length > 0 ? `\n\n## Prior Extracted Values
|
|
|
19326
19330
|
}
|
|
19327
19331
|
}
|
|
19328
19332
|
if (retryEmptyObject) try {
|
|
19329
|
-
|
|
19333
|
+
const fallbackJsonPromptInjection = _mastra_core_features.coreFeatures.has("json-prompt-injection:inline") ? "inline" : true;
|
|
19334
|
+
object = {
|
|
19335
|
+
...object,
|
|
19336
|
+
...await streamWithStructuredOutput(fallbackJsonPromptInjection)
|
|
19337
|
+
};
|
|
19330
19338
|
} catch (fallbackError) {
|
|
19331
19339
|
if (isAbortError(fallbackError, opts.abortSignal)) throw fallbackError;
|
|
19332
19340
|
const message = fallbackError instanceof Error ? fallbackError.message : String(fallbackError);
|
|
19333
|
-
return {
|
|
19341
|
+
if (Object.keys(object).length === 0) return {
|
|
19334
19342
|
values,
|
|
19335
19343
|
failures: structuredExtractors.map((extractor) => ({
|
|
19336
19344
|
slug: extractor.slug,
|
|
19337
19345
|
error: message
|
|
19338
19346
|
}))
|
|
19339
19347
|
};
|
|
19348
|
+
for (const extractor of structuredExtractors) if (extractor.retryStructuredExtractionOnEmptyObject && hasEmptyObjectValue(object, extractor)) {
|
|
19349
|
+
failures.push({
|
|
19350
|
+
slug: extractor.slug,
|
|
19351
|
+
error: message
|
|
19352
|
+
});
|
|
19353
|
+
delete object[extractor.slug];
|
|
19354
|
+
}
|
|
19340
19355
|
}
|
|
19341
19356
|
for (const extractor of structuredExtractors) {
|
|
19342
19357
|
const value = object[extractor.slug];
|
|
@@ -24162,6 +24177,9 @@ async function validateAgainstConfiguredSchema(schema, value) {
|
|
|
24162
24177
|
}).join("; ");
|
|
24163
24178
|
throw new Error(`Working memory update does not match the configured schema, so it was not saved: ${details}`);
|
|
24164
24179
|
}
|
|
24180
|
+
function isEmptyPlainObject(value) {
|
|
24181
|
+
return typeof value === "object" && value !== null && !Array.isArray(value) && Object.keys(value).length === 0;
|
|
24182
|
+
}
|
|
24165
24183
|
async function getWorkingMemoryDetails(context) {
|
|
24166
24184
|
const memory = context.memory;
|
|
24167
24185
|
const memoryConfig = (0, _mastra_core_memory.parseMemoryRequestContext)(context.requestContext)?.memoryConfig;
|
|
@@ -24209,8 +24227,9 @@ var WorkingMemoryExtractor = class extends Extractor {
|
|
|
24209
24227
|
const configuredSchema = memory.getMergedThreadConfig(memoryConfig ?? {}).workingMemory?.schema;
|
|
24210
24228
|
let document = current;
|
|
24211
24229
|
if (configuredSchema) {
|
|
24212
|
-
if (current === null) return;
|
|
24230
|
+
if (current === null || isEmptyPlainObject(current)) return;
|
|
24213
24231
|
document = await validateAgainstConfiguredSchema(configuredSchema, current);
|
|
24232
|
+
if (document === null || isEmptyPlainObject(document)) return;
|
|
24214
24233
|
}
|
|
24215
24234
|
const workingMemory = typeof document === "string" ? document : JSON.stringify(document) ?? "";
|
|
24216
24235
|
if (!workingMemory.trim()) return;
|
|
@@ -24397,10 +24416,10 @@ function filterObservedMessages(opts) {
|
|
|
24397
24416
|
const msg = allMessages[i];
|
|
24398
24417
|
if (msg?.id && msg.id !== "om-continuation" && !preserveMessageIds.has(msg.id) && !hasPendingToolResultPair(msg, pendingToolResultIds)) messagesToRemove.push(msg.id);
|
|
24399
24418
|
}
|
|
24400
|
-
if (messagesToRemove.length > 0) messageList.removeByIds(messagesToRemove);
|
|
24419
|
+
if (messagesToRemove.length > 0) messageList.removeByIds(messagesToRemove, { pruned: true });
|
|
24401
24420
|
const unobserved = getUnobservedPartsPreservingToolCallPairs(markerMessage);
|
|
24402
24421
|
if (unobserved.length === 0) {
|
|
24403
|
-
if (markerMessage.id) messageList.removeByIds([markerMessage.id]);
|
|
24422
|
+
if (markerMessage.id) messageList.removeByIds([markerMessage.id], { pruned: true });
|
|
24404
24423
|
} else if (unobserved.length < (markerMessage.content?.parts?.length ?? 0)) markerMessage.content.parts = unobserved;
|
|
24405
24424
|
} else if (record) {
|
|
24406
24425
|
const pendingToolResultIds = collectPendingToolResultIds(allMessages, observedIds);
|
|
@@ -24427,7 +24446,7 @@ function filterObservedMessages(opts) {
|
|
|
24427
24446
|
}
|
|
24428
24447
|
}
|
|
24429
24448
|
}
|
|
24430
|
-
if (messagesToRemove.length > 0) messageList.removeByIds(messagesToRemove);
|
|
24449
|
+
if (messagesToRemove.length > 0) messageList.removeByIds(messagesToRemove, { pruned: true });
|
|
24431
24450
|
}
|
|
24432
24451
|
}
|
|
24433
24452
|
function getBufferedChunks(record) {
|
|
@@ -28851,7 +28870,7 @@ var ObservationStep = class {
|
|
|
28851
28870
|
this.turn.setRecord(activation.record);
|
|
28852
28871
|
if (activation.activated) {
|
|
28853
28872
|
activated = true;
|
|
28854
|
-
if (activation.activatedMessageIds?.length) messageList.removeByIds(activation.activatedMessageIds);
|
|
28873
|
+
if (activation.activatedMessageIds?.length) messageList.removeByIds(activation.activatedMessageIds, { pruned: true });
|
|
28855
28874
|
await om.resetBufferingState({
|
|
28856
28875
|
threadId,
|
|
28857
28876
|
resourceId,
|
|
@@ -32446,7 +32465,7 @@ ${formattedMessages}
|
|
|
32446
32465
|
preserveMessageIds
|
|
32447
32466
|
});
|
|
32448
32467
|
if (messageList) {
|
|
32449
|
-
if (idsToRemoveList.length > 0) messageList.removeByIds(idsToRemoveList);
|
|
32468
|
+
if (idsToRemoveList.length > 0) messageList.removeByIds(idsToRemoveList, { pruned: true });
|
|
32450
32469
|
return messageList.get.all.db();
|
|
32451
32470
|
}
|
|
32452
32471
|
this.removeIdsFromArray(allMsgs, idsToRemoveList);
|
|
@@ -32471,7 +32490,7 @@ ${formattedMessages}
|
|
|
32471
32490
|
} else if (unobservedParts.length < (markerMsg.content?.parts?.length ?? 0)) markerMsg.content.parts = unobservedParts;
|
|
32472
32491
|
}
|
|
32473
32492
|
if (messageList) {
|
|
32474
|
-
if (idsToRemove.length > 0) messageList.removeByIds(idsToRemove);
|
|
32493
|
+
if (idsToRemove.length > 0) messageList.removeByIds(idsToRemove, { pruned: true });
|
|
32475
32494
|
if (messagesToSave.length > 0) await this.persistMessages(messagesToSave, threadId, resourceId);
|
|
32476
32495
|
omDebug(`[OM:cleanupMarker] removed ${idsToRemove.length} messages, saved ${messagesToSave.length}`);
|
|
32477
32496
|
return messageList.get.all.db();
|
|
@@ -36881,4 +36900,4 @@ Object.defineProperty(exports, "wrapInObservationGroup", {
|
|
|
36881
36900
|
}
|
|
36882
36901
|
});
|
|
36883
36902
|
|
|
36884
|
-
//# sourceMappingURL=src-
|
|
36903
|
+
//# sourceMappingURL=src-DTJFmjDz.cjs.map
|