@mastra/memory 1.28.0-alpha.2 → 1.28.0-alpha.3
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 +13 -0
- package/dist/docs/SKILL.md +2 -1
- package/dist/docs/assets/SOURCE_MAP.json +1 -1
- package/dist/docs/references/docs-storage.md +1 -0
- package/dist/docs/references/integrations-databases-elasticsearch.md +156 -0
- package/dist/docs/references/integrations-databases-libsql.md +16 -0
- package/dist/docs/references/integrations-databases-postgresql.md +24 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts.map +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/reflector-runner.d.ts +15 -0
- package/dist/processors/observational-memory/reflector-runner.d.ts.map +1 -1
- package/dist/{src-kLYHhPqh.js → src-BTHCV1ov.js} +43 -7
- package/dist/src-BTHCV1ov.js.map +1 -0
- package/dist/{src-CIBCjg2A.cjs → src-D8byb8Ge.cjs} +43 -7
- package/dist/src-D8byb8Ge.cjs.map +1 -0
- package/package.json +4 -4
- package/dist/src-CIBCjg2A.cjs.map +0 -1
- package/dist/src-kLYHhPqh.js.map +0 -1
|
@@ -3734,7 +3734,7 @@ function trimStartOfStream() {
|
|
|
3734
3734
|
};
|
|
3735
3735
|
}
|
|
3736
3736
|
//#endregion
|
|
3737
|
-
//#region ../_vendored/ai_v5/dist/dist-
|
|
3737
|
+
//#region ../_vendored/ai_v5/dist/dist-nVfjvSbw.js
|
|
3738
3738
|
var marker$1$4 = "vercel.ai.error";
|
|
3739
3739
|
var symbol$1$3 = Symbol.for(marker$1$4);
|
|
3740
3740
|
var _a$1$3;
|
|
@@ -4287,6 +4287,7 @@ async function cancelResponseBody$1(response) {
|
|
|
4287
4287
|
var initialGlobalFetch$1 = globalThis.fetch;
|
|
4288
4288
|
isNodeDefaultFetch$1(initialGlobalFetch$1);
|
|
4289
4289
|
function isNodeDefaultFetch$1(fetch) {
|
|
4290
|
+
if (typeof fetch !== "function") return false;
|
|
4290
4291
|
const source = Function.prototype.toString.call(fetch);
|
|
4291
4292
|
return source.includes("internal/deps/undici") || source.includes("lazy loading of undici");
|
|
4292
4293
|
}
|
|
@@ -8622,7 +8623,7 @@ var object$1 = ({ schema: inputSchema }) => {
|
|
|
8622
8623
|
};
|
|
8623
8624
|
};
|
|
8624
8625
|
//#endregion
|
|
8625
|
-
//#region ../_vendored/ai_v6/dist/dist-
|
|
8626
|
+
//#region ../_vendored/ai_v6/dist/dist-Gd4EIxPM.js
|
|
8626
8627
|
var marker$1 = "vercel.ai.error";
|
|
8627
8628
|
var symbol$1$1 = Symbol.for(marker$1);
|
|
8628
8629
|
var _a$1$1;
|
|
@@ -9196,6 +9197,7 @@ var DownloadError = class extends (_b$2 = AISDKError, _a$2 = symbol$2, _b$2) {
|
|
|
9196
9197
|
var initialGlobalFetch = globalThis.fetch;
|
|
9197
9198
|
isNodeDefaultFetch(initialGlobalFetch);
|
|
9198
9199
|
function isNodeDefaultFetch(fetch) {
|
|
9200
|
+
if (typeof fetch !== "function") return false;
|
|
9199
9201
|
const source = Function.prototype.toString.call(fetch);
|
|
9200
9202
|
return source.includes("internal/deps/undici") || source.includes("lazy loading of undici");
|
|
9201
9203
|
}
|
|
@@ -10774,7 +10776,7 @@ function withoutTrailingSlash(url) {
|
|
|
10774
10776
|
return url == null ? void 0 : url.replace(/\/$/, "");
|
|
10775
10777
|
}
|
|
10776
10778
|
//#endregion
|
|
10777
|
-
//#region ../_vendored/ai_v6/dist/dist-
|
|
10779
|
+
//#region ../_vendored/ai_v6/dist/dist-BoeKQsDe.js
|
|
10778
10780
|
function getContext() {
|
|
10779
10781
|
return { headers: {} };
|
|
10780
10782
|
}
|
|
@@ -25412,6 +25414,21 @@ var ReflectorRunner = class {
|
|
|
25412
25414
|
memory;
|
|
25413
25415
|
onReflectionCommitted;
|
|
25414
25416
|
mastra;
|
|
25417
|
+
/**
|
|
25418
|
+
* Per-lock-key observation-token count of the last unproductive synchronous
|
|
25419
|
+
* reflection (failed, or committed while still over the reflection
|
|
25420
|
+
* threshold). `call()` already runs the full bounded compression ladder for
|
|
25421
|
+
* a given input, so re-running it against unchanged observations cannot
|
|
25422
|
+
* succeed — threshold-triggered sync reflection is skipped while the count
|
|
25423
|
+
* is unchanged and retried as soon as the input differs.
|
|
25424
|
+
* Keyed by lock key (thread/resource), which is stable across generations —
|
|
25425
|
+
* record ids change every time a generation is created.
|
|
25426
|
+
*
|
|
25427
|
+
* Lifecycle: an entry is deleted when a sync reflection finishes under
|
|
25428
|
+
* threshold and replaced on each unproductive attempt. Entries are one
|
|
25429
|
+
* number per active thread/resource key and live for the runner's lifetime.
|
|
25430
|
+
*/
|
|
25431
|
+
syncReflectionSuppression = /* @__PURE__ */ new Map();
|
|
25415
25432
|
constructor(opts) {
|
|
25416
25433
|
this.reflectionConfig = opts.reflectionConfig;
|
|
25417
25434
|
this.observationConfig = opts.observationConfig;
|
|
@@ -25494,6 +25511,8 @@ var ReflectorRunner = class {
|
|
|
25494
25511
|
};
|
|
25495
25512
|
let reflectedTokens = 0;
|
|
25496
25513
|
let attemptNumber = 0;
|
|
25514
|
+
/** True when the latest attempt returned an empty block for non-empty input. */
|
|
25515
|
+
let emptyOutput = false;
|
|
25497
25516
|
while (currentLevel <= maxLevel) {
|
|
25498
25517
|
attemptNumber++;
|
|
25499
25518
|
const isRetry = attemptNumber > 1;
|
|
@@ -25557,14 +25576,18 @@ var ReflectorRunner = class {
|
|
|
25557
25576
|
}
|
|
25558
25577
|
finalProviderMetadata = result.providerMetadata ?? finalProviderMetadata;
|
|
25559
25578
|
parsed = parseReflectorOutput(result.text, observations, activeExtractors);
|
|
25579
|
+
emptyOutput = !parsed.degenerate && observations.trim().length > 0 && parsed.observations.trim().length === 0;
|
|
25560
25580
|
if (parsed.degenerate) {
|
|
25561
25581
|
omDebug(`[OM:callReflector] attempt #${attemptNumber}: degenerate repetition detected, treating as compression failure. ${describeDegenerateOutput(result.text, 2e3)}`);
|
|
25562
25582
|
reflectedTokens = originalTokens;
|
|
25583
|
+
} else if (emptyOutput) {
|
|
25584
|
+
omDebug(`[OM:callReflector] attempt #${attemptNumber}: empty observations block for non-empty input, treating as compression failure`);
|
|
25585
|
+
reflectedTokens = originalTokens;
|
|
25563
25586
|
} else reflectedTokens = this.tokenCounter.countObservations(parsed.observations);
|
|
25564
25587
|
omDebug(`[OM:callReflector] attempt #${attemptNumber} parsed: reflectedTokens=${reflectedTokens}, targetThreshold=${targetThreshold}, compressionValid=${validateCompression(reflectedTokens, targetThreshold)}, parsedObsLen=${parsed.observations?.length}, degenerate=${parsed.degenerate ?? false}`);
|
|
25565
|
-
if (!parsed.degenerate && (validateCompression(reflectedTokens, targetThreshold) || currentLevel >= maxLevel)) break;
|
|
25566
|
-
if (parsed.degenerate && currentLevel >= maxLevel) {
|
|
25567
|
-
omDebug(`[OM:callReflector] degenerate output persists at maxLevel=${maxLevel}, breaking`);
|
|
25588
|
+
if (!parsed.degenerate && !emptyOutput && (validateCompression(reflectedTokens, targetThreshold) || currentLevel >= maxLevel)) break;
|
|
25589
|
+
if ((parsed.degenerate || emptyOutput) && currentLevel >= maxLevel) {
|
|
25590
|
+
omDebug(`[OM:callReflector] ${parsed.degenerate ? "degenerate" : "empty"} output persists at maxLevel=${maxLevel}, breaking`);
|
|
25568
25591
|
break;
|
|
25569
25592
|
}
|
|
25570
25593
|
if (streamContext?.writer) {
|
|
@@ -25602,6 +25625,7 @@ var ReflectorRunner = class {
|
|
|
25602
25625
|
}
|
|
25603
25626
|
currentLevel = Math.min(currentLevel + 1, maxLevel);
|
|
25604
25627
|
}
|
|
25628
|
+
if (observations.trim().length > 0 && parsed.observations.trim().length === 0) throw new Error(`Reflector produced empty output after ${attemptNumber} attempt(s)${parsed.degenerate ? " (degenerate repetition)" : ""} — refusing to commit an empty reflection over ${originalTokens} observation tokens`);
|
|
25605
25629
|
const structuredExtraction = await extractStructuredValues({
|
|
25606
25630
|
agent,
|
|
25607
25631
|
source: "reflector",
|
|
@@ -25955,6 +25979,13 @@ var ReflectorRunner = class {
|
|
|
25955
25979
|
return;
|
|
25956
25980
|
}
|
|
25957
25981
|
}
|
|
25982
|
+
if (activationTriggeredBy === "threshold") {
|
|
25983
|
+
const suppressedAtTokens = this.syncReflectionSuppression.get(lockKey);
|
|
25984
|
+
if (suppressedAtTokens !== void 0 && observationTokens === suppressedAtTokens) {
|
|
25985
|
+
omDebug(`[OM:reflect] skipping sync reflection — observations unchanged at ${observationTokens} tokens since the last unproductive attempt; retrying once they change`);
|
|
25986
|
+
return;
|
|
25987
|
+
}
|
|
25988
|
+
}
|
|
25958
25989
|
await this.storage.setReflectingFlag(record.id, true);
|
|
25959
25990
|
registerOp(record.id, "reflecting");
|
|
25960
25991
|
const cycleId = crypto.randomUUID();
|
|
@@ -26015,6 +26046,8 @@ var ReflectorRunner = class {
|
|
|
26015
26046
|
reflection: reflectResult.observations,
|
|
26016
26047
|
tokenCount: reflectionTokenCount
|
|
26017
26048
|
});
|
|
26049
|
+
if (reflectionTokenCount >= reflectThreshold) this.syncReflectionSuppression.set(lockKey, reflectionTokenCount);
|
|
26050
|
+
else this.syncReflectionSuppression.delete(lockKey);
|
|
26018
26051
|
await this.notifyReflectionCommitted({
|
|
26019
26052
|
parentThreadId: requestedThreadId ?? record.threadId ?? "",
|
|
26020
26053
|
resourceId: record.resourceId ?? "",
|
|
@@ -26074,6 +26107,7 @@ var ReflectorRunner = class {
|
|
|
26074
26107
|
}
|
|
26075
26108
|
reflectionError = error instanceof Error ? error : new Error(String(error));
|
|
26076
26109
|
if (lifecycleError !== void 0 || abortSignal?.aborted) throw error;
|
|
26110
|
+
this.syncReflectionSuppression.set(lockKey, observationTokens);
|
|
26077
26111
|
omError("[OM] Reflection failed", error);
|
|
26078
26112
|
} finally {
|
|
26079
26113
|
try {
|
|
@@ -30542,6 +30576,7 @@ ${workingMemory}`;
|
|
|
30542
30576
|
instruction: omConfig.observation.instruction,
|
|
30543
30577
|
threadTitle: omConfig.observation.threadTitle,
|
|
30544
30578
|
observeAttachments: omConfig.observation.observeAttachments,
|
|
30579
|
+
continuationHints: omConfig.observation.continuationHints,
|
|
30545
30580
|
extract: omConfig.observation.extract
|
|
30546
30581
|
} : void 0,
|
|
30547
30582
|
reflection: omConfig.reflection ? {
|
|
@@ -30552,6 +30587,7 @@ ${workingMemory}`;
|
|
|
30552
30587
|
bufferActivation: omConfig.reflection.bufferActivation,
|
|
30553
30588
|
blockAfter: omConfig.reflection.blockAfter,
|
|
30554
30589
|
instruction: omConfig.reflection.instruction,
|
|
30590
|
+
continuationHints: omConfig.reflection.continuationHints,
|
|
30555
30591
|
extract: omConfig.reflection.extract
|
|
30556
30592
|
} : void 0
|
|
30557
30593
|
});
|
|
@@ -31759,4 +31795,4 @@ Object.defineProperty(exports, "wrapInObservationGroup", {
|
|
|
31759
31795
|
}
|
|
31760
31796
|
});
|
|
31761
31797
|
|
|
31762
|
-
//# sourceMappingURL=src-
|
|
31798
|
+
//# sourceMappingURL=src-D8byb8Ge.cjs.map
|