@mastra/memory 1.37.1-alpha.0 → 1.37.1-alpha.1
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-BpxX0T2g.cjs → src-BcRCGtUY.cjs} +24 -5
- package/dist/{src-BpxX0T2g.cjs.map → src-BcRCGtUY.cjs.map} +1 -1
- package/dist/{src-ThciS3vu.js → src-DjDnBIS0.js} +24 -5
- package/dist/{src-ThciS3vu.js.map → src-DjDnBIS0.js.map} +1 -1
- package/package.json +3 -3
|
@@ -19230,8 +19230,12 @@ function formatOmError(error) {
|
|
|
19230
19230
|
function isAbortError(error, abortSignal) {
|
|
19231
19231
|
return abortSignal?.aborted === true || hasAbortInChain(error);
|
|
19232
19232
|
}
|
|
19233
|
+
function hasEmptyObjectValue(object, extractor) {
|
|
19234
|
+
const value = object[extractor.slug];
|
|
19235
|
+
return typeof value === "object" && value !== null && !Array.isArray(value) && Object.keys(value).length === 0;
|
|
19236
|
+
}
|
|
19233
19237
|
function shouldRetryEmptyStructuredObject(object, extractors) {
|
|
19234
|
-
return Object.keys(object).length === 0
|
|
19238
|
+
return extractors.some((extractor) => extractor.retryStructuredExtractionOnEmptyObject && (Object.keys(object).length === 0 || hasEmptyObjectValue(object, extractor)));
|
|
19235
19239
|
}
|
|
19236
19240
|
async function extractStructuredValues(opts) {
|
|
19237
19241
|
const structuredExtractors = (opts.extractors ?? []).filter((extractor) => extractor.mode === "structured");
|
|
@@ -19305,17 +19309,28 @@ ${extractorInstructions}${priorLines.length > 0 ? `\n\n## Prior Extracted Values
|
|
|
19305
19309
|
}
|
|
19306
19310
|
}
|
|
19307
19311
|
if (retryEmptyObject) try {
|
|
19308
|
-
|
|
19312
|
+
const fallbackJsonPromptInjection = coreFeatures.has("json-prompt-injection:inline") ? "inline" : true;
|
|
19313
|
+
object = {
|
|
19314
|
+
...object,
|
|
19315
|
+
...await streamWithStructuredOutput(fallbackJsonPromptInjection)
|
|
19316
|
+
};
|
|
19309
19317
|
} catch (fallbackError) {
|
|
19310
19318
|
if (isAbortError(fallbackError, opts.abortSignal)) throw fallbackError;
|
|
19311
19319
|
const message = fallbackError instanceof Error ? fallbackError.message : String(fallbackError);
|
|
19312
|
-
return {
|
|
19320
|
+
if (Object.keys(object).length === 0) return {
|
|
19313
19321
|
values,
|
|
19314
19322
|
failures: structuredExtractors.map((extractor) => ({
|
|
19315
19323
|
slug: extractor.slug,
|
|
19316
19324
|
error: message
|
|
19317
19325
|
}))
|
|
19318
19326
|
};
|
|
19327
|
+
for (const extractor of structuredExtractors) if (extractor.retryStructuredExtractionOnEmptyObject && hasEmptyObjectValue(object, extractor)) {
|
|
19328
|
+
failures.push({
|
|
19329
|
+
slug: extractor.slug,
|
|
19330
|
+
error: message
|
|
19331
|
+
});
|
|
19332
|
+
delete object[extractor.slug];
|
|
19333
|
+
}
|
|
19319
19334
|
}
|
|
19320
19335
|
for (const extractor of structuredExtractors) {
|
|
19321
19336
|
const value = object[extractor.slug];
|
|
@@ -24141,6 +24156,9 @@ async function validateAgainstConfiguredSchema(schema, value) {
|
|
|
24141
24156
|
}).join("; ");
|
|
24142
24157
|
throw new Error(`Working memory update does not match the configured schema, so it was not saved: ${details}`);
|
|
24143
24158
|
}
|
|
24159
|
+
function isEmptyPlainObject(value) {
|
|
24160
|
+
return typeof value === "object" && value !== null && !Array.isArray(value) && Object.keys(value).length === 0;
|
|
24161
|
+
}
|
|
24144
24162
|
async function getWorkingMemoryDetails(context) {
|
|
24145
24163
|
const memory = context.memory;
|
|
24146
24164
|
const memoryConfig = parseMemoryRequestContext(context.requestContext)?.memoryConfig;
|
|
@@ -24188,8 +24206,9 @@ var WorkingMemoryExtractor = class extends Extractor {
|
|
|
24188
24206
|
const configuredSchema = memory.getMergedThreadConfig(memoryConfig ?? {}).workingMemory?.schema;
|
|
24189
24207
|
let document = current;
|
|
24190
24208
|
if (configuredSchema) {
|
|
24191
|
-
if (current === null) return;
|
|
24209
|
+
if (current === null || isEmptyPlainObject(current)) return;
|
|
24192
24210
|
document = await validateAgainstConfiguredSchema(configuredSchema, current);
|
|
24211
|
+
if (document === null || isEmptyPlainObject(document)) return;
|
|
24193
24212
|
}
|
|
24194
24213
|
const workingMemory = typeof document === "string" ? document : JSON.stringify(document) ?? "";
|
|
24195
24214
|
if (!workingMemory.trim()) return;
|
|
@@ -36555,4 +36574,4 @@ Notes:
|
|
|
36555
36574
|
//#endregion
|
|
36556
36575
|
export { renderSubconsciousActivity as $, buildObserverSystemPrompt as A, OBSERVATION_CONTEXT_INSTRUCTIONS as B, WorkingMemoryExtractor as C, TokenCounter as D, summarizeConversation as E, parseObserverOutput as F, Subconscious as G, OBSERVATION_CONTEXT_PROMPT_THREAD as H, injectAnchorIds as I, SubconsciousRemindExtractor as J, KnowledgeSemanticIndexCoordinator as K, parseAnchorId as L, formatMessagesForObserver as M, hasCurrentTaskSection as N, OBSERVER_SYSTEM_PROMPT as O, optimizeObservationsForContext as P, publishSubconsciousActivity as Q, stripEphemeralAnchorIds as R, wrapInObservationGroup as S, SUMMARIZE_THREAD_DEFAULTS as T, OBSERVATION_CONTINUATION_HINT as U, OBSERVATION_CONTEXT_PROMPT as V, getObservationContextPrompt as W, SUBCONSCIOUS_ACTIVITY_STATE_ID as X, ModelByInputTokens as Y, buildSubconsciousActivitySnapshot as Z, deriveObservationGroupProvenance as _, extractWorkingMemoryContent as a, renderObservationGroupsForReflection as b, getObservationsAsOf as c, AUTO_MODEL_BY_PROVIDER as d, Extractor as et, resolveAutoModelId as f, combineObservationGroupRanges as g, WorkingMemoryStateProcessor as h, WorkingMemory as i, extractCurrentTask as j, buildObserverPrompt as k, ObservationalMemoryProcessor as l, WORKING_MEMORY_STATE_PROCESSOR_ID as m, MessageHistory$1 as n, extractWorkingMemoryTags as o, WORKING_MEMORY_STATE_ID as p, StaleKnowledgeSemanticIndexError as q, SemanticRecall as r, removeWorkingMemoryTags as s, Memory as t, ObservationalMemory as u, parseObservationGroups as v, deepMergeWorkingMemory as w, stripObservationGroups as x, reconcileObservationGroupsFromReflection as y, OBSERVATIONAL_MEMORY_DEFAULTS as z };
|
|
36557
36576
|
|
|
36558
|
-
//# sourceMappingURL=src-
|
|
36577
|
+
//# sourceMappingURL=src-DjDnBIS0.js.map
|