@mastra/memory 1.28.0-alpha.2 → 1.28.0-alpha.4
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 +22 -0
- package/dist/docs/SKILL.md +2 -1
- package/dist/docs/assets/SOURCE_MAP.json +1 -1
- package/dist/docs/references/docs-memory-semantic-recall.md +19 -0
- package/dist/docs/references/docs-storage.md +1 -0
- package/dist/docs/references/docs-subagents.md +6 -6
- package/dist/docs/references/integrations-channels-github.md +56 -9
- 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/observational-memory.d.ts.map +1 -1
- package/dist/processors/observational-memory/processor.d.ts.map +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-BATJenuZ.js} +210 -160
- package/dist/src-BATJenuZ.js.map +1 -0
- package/dist/{src-CIBCjg2A.cjs → src-C7Ozl6Pf.cjs} +209 -159
- package/dist/src-C7Ozl6Pf.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
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reflector-runner.d.ts","sourceRoot":"","sources":["../../../src/processors/observational-memory/reflector-runner.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAGlD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,4BAA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;;;;OAIG;IACG,YAAY,CAAC,IAAI,EAAE;QACvB,MAAM,EAAE,yBAAyB,CAAC;QAClC,iBAAiB,EAAE,MAAM,CAAC;QAC1B,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,MAAM,CAAC,EAAE,qBAAqB,CAAC;QAC/B,WAAW,CAAC,EAAE,WAAW,CAAC;QAC1B,SAAS,CAAC,EAAE,gBAAgB,CAAC,OAAO,CAAC,CAAC;QACtC,UAAU,CAAC,EAAE,gBAAgB,CAAC,YAAY,CAAC,CAAC;QAC5C,eAAe,CAAC,EAAE,gBAAgB,CAAC,iBAAiB,CAAC,CAAC;QACtD,WAAW,CAAC,EAAE,WAAW,CAAC;QAC1B,YAAY,CAAC,EAAE,uBAAuB,CAAC;QACvC,eAAe,CAAC,EAAE,IAAI,CAAC,YAAY,EAAE,mBAAmB,GAAG,iBAAiB,CAAC,CAAC;QAC9E,cAAc,CAAC,EAAE,cAAc,CAAC;QAChC,oBAAoB,CAAC,EAAE,oBAAoB,CAAC;QAC5C,cAAc,CAAC,EAAE,MAAM,CAAC;KACzB,GAAG,OAAO,CAAC,IAAI,CAAC;CAoXlB"}
|
|
@@ -24,8 +24,8 @@ import probeImageSizeSync from "probe-image-size/sync.js";
|
|
|
24
24
|
import { isStandardSchemaWithJSON as isStandardSchemaWithJSON$1, toStandardSchema as toStandardSchema$1 } from "@mastra/core/schema";
|
|
25
25
|
import { ErrorCategory, ErrorDomain, MastraError } from "@mastra/core/error";
|
|
26
26
|
import { MessageHistory, MessageHistory as MessageHistory$1, SemanticRecall, WorkingMemory } from "@mastra/core/processors";
|
|
27
|
-
import { inspect } from "util";
|
|
28
27
|
import { structuredPatch } from "diff";
|
|
28
|
+
import { inspect } from "util";
|
|
29
29
|
//#region \0rolldown/runtime.js
|
|
30
30
|
var __defProp$3 = Object.defineProperty;
|
|
31
31
|
var __exportAll = (all, no_symbols) => {
|
|
@@ -3713,7 +3713,7 @@ function trimStartOfStream() {
|
|
|
3713
3713
|
};
|
|
3714
3714
|
}
|
|
3715
3715
|
//#endregion
|
|
3716
|
-
//#region ../_vendored/ai_v5/dist/dist-
|
|
3716
|
+
//#region ../_vendored/ai_v5/dist/dist-nVfjvSbw.js
|
|
3717
3717
|
var marker$1$4 = "vercel.ai.error";
|
|
3718
3718
|
var symbol$1$3 = Symbol.for(marker$1$4);
|
|
3719
3719
|
var _a$1$3;
|
|
@@ -4266,6 +4266,7 @@ async function cancelResponseBody$1(response) {
|
|
|
4266
4266
|
var initialGlobalFetch$1 = globalThis.fetch;
|
|
4267
4267
|
isNodeDefaultFetch$1(initialGlobalFetch$1);
|
|
4268
4268
|
function isNodeDefaultFetch$1(fetch) {
|
|
4269
|
+
if (typeof fetch !== "function") return false;
|
|
4269
4270
|
const source = Function.prototype.toString.call(fetch);
|
|
4270
4271
|
return source.includes("internal/deps/undici") || source.includes("lazy loading of undici");
|
|
4271
4272
|
}
|
|
@@ -8601,7 +8602,7 @@ var object$1 = ({ schema: inputSchema }) => {
|
|
|
8601
8602
|
};
|
|
8602
8603
|
};
|
|
8603
8604
|
//#endregion
|
|
8604
|
-
//#region ../_vendored/ai_v6/dist/dist-
|
|
8605
|
+
//#region ../_vendored/ai_v6/dist/dist-Gd4EIxPM.js
|
|
8605
8606
|
var marker$1 = "vercel.ai.error";
|
|
8606
8607
|
var symbol$1$1 = Symbol.for(marker$1);
|
|
8607
8608
|
var _a$1$1;
|
|
@@ -9175,6 +9176,7 @@ var DownloadError = class extends (_b$2 = AISDKError, _a$2 = symbol$2, _b$2) {
|
|
|
9175
9176
|
var initialGlobalFetch = globalThis.fetch;
|
|
9176
9177
|
isNodeDefaultFetch(initialGlobalFetch);
|
|
9177
9178
|
function isNodeDefaultFetch(fetch) {
|
|
9179
|
+
if (typeof fetch !== "function") return false;
|
|
9178
9180
|
const source = Function.prototype.toString.call(fetch);
|
|
9179
9181
|
return source.includes("internal/deps/undici") || source.includes("lazy loading of undici");
|
|
9180
9182
|
}
|
|
@@ -10753,7 +10755,7 @@ function withoutTrailingSlash(url) {
|
|
|
10753
10755
|
return url == null ? void 0 : url.replace(/\/$/, "");
|
|
10754
10756
|
}
|
|
10755
10757
|
//#endregion
|
|
10756
|
-
//#region ../_vendored/ai_v6/dist/dist-
|
|
10758
|
+
//#region ../_vendored/ai_v6/dist/dist-BoeKQsDe.js
|
|
10757
10759
|
function getContext() {
|
|
10758
10760
|
return { headers: {} };
|
|
10759
10761
|
}
|
|
@@ -22413,6 +22415,151 @@ function createWorkingMemoryTool(config, options = {}) {
|
|
|
22413
22415
|
};
|
|
22414
22416
|
}
|
|
22415
22417
|
//#endregion
|
|
22418
|
+
//#region src/processors/working-memory-state/processor.ts
|
|
22419
|
+
/**
|
|
22420
|
+
* WorkingMemoryStateProcessor
|
|
22421
|
+
*
|
|
22422
|
+
* Experimental: delivers working memory to the model as a state signal instead
|
|
22423
|
+
* of folding it into the system message. Storage and the `setWorkingMemory`
|
|
22424
|
+
* tool are unchanged — this processor only changes the delivery path.
|
|
22425
|
+
*
|
|
22426
|
+
* Pattern matches `BrowserContextProcessor` in `@mastra/core/browser`:
|
|
22427
|
+
* - `stateId` namespaces the state lane on the thread.
|
|
22428
|
+
* - `cacheKey` is derived from the rendered payload so dedup is automatic.
|
|
22429
|
+
* - `contextWindow.hasSnapshot` re-injection ensures the model still sees the
|
|
22430
|
+
* current snapshot after older messages drop out of the window.
|
|
22431
|
+
*
|
|
22432
|
+
* Delta emission (markdown mode only): when a prior snapshot exists in the
|
|
22433
|
+
* context window, the processor emits a unified-diff delta against that
|
|
22434
|
+
* snapshot's contents. Schema mode and the snapshot fallback always emit a
|
|
22435
|
+
* full snapshot.
|
|
22436
|
+
*
|
|
22437
|
+
* @example
|
|
22438
|
+
* ```ts
|
|
22439
|
+
* new Memory({
|
|
22440
|
+
* options: {
|
|
22441
|
+
* workingMemory: {
|
|
22442
|
+
* enabled: true,
|
|
22443
|
+
* template: '...',
|
|
22444
|
+
* useStateSignals: true, // auto-attaches this processor
|
|
22445
|
+
* },
|
|
22446
|
+
* },
|
|
22447
|
+
* });
|
|
22448
|
+
* ```
|
|
22449
|
+
*/
|
|
22450
|
+
const WORKING_MEMORY_STATE_ID = "working-memory";
|
|
22451
|
+
const WORKING_MEMORY_STATE_PROCESSOR_ID = "working-memory-state";
|
|
22452
|
+
var WorkingMemoryStateProcessor = class {
|
|
22453
|
+
memory;
|
|
22454
|
+
memoryConfig;
|
|
22455
|
+
id = WORKING_MEMORY_STATE_PROCESSOR_ID;
|
|
22456
|
+
stateId = WORKING_MEMORY_STATE_ID;
|
|
22457
|
+
constructor(memory, memoryConfig) {
|
|
22458
|
+
this.memory = memory;
|
|
22459
|
+
this.memoryConfig = memoryConfig;
|
|
22460
|
+
}
|
|
22461
|
+
async computeStateSignal(args) {
|
|
22462
|
+
const template = await this.memory.getWorkingMemoryTemplate({ memoryConfig: this.memoryConfig });
|
|
22463
|
+
if (!template) return;
|
|
22464
|
+
const contents = (await this.memory.getWorkingMemory({
|
|
22465
|
+
threadId: args.threadId,
|
|
22466
|
+
resourceId: args.resourceId,
|
|
22467
|
+
memoryConfig: this.memoryConfig
|
|
22468
|
+
}))?.trim();
|
|
22469
|
+
if (!contents) return;
|
|
22470
|
+
const cacheKey = stableWorkingMemoryCacheKey({
|
|
22471
|
+
format: template.format,
|
|
22472
|
+
data: contents
|
|
22473
|
+
});
|
|
22474
|
+
const shouldMakeSnapshot = !args.contextWindow.hasSnapshot;
|
|
22475
|
+
if (args.tracking?.currentCacheKey === cacheKey && !shouldMakeSnapshot) return;
|
|
22476
|
+
const scope = this.memory.getMergedThreadConfig(this.memoryConfig).workingMemory?.scope ?? "resource";
|
|
22477
|
+
const deltaCandidate = template.format === "markdown" && !shouldMakeSnapshot ? buildMarkdownDelta({
|
|
22478
|
+
lastSnapshot: args.lastSnapshot,
|
|
22479
|
+
deltasSinceSnapshot: args.deltasSinceSnapshot,
|
|
22480
|
+
nextContents: contents
|
|
22481
|
+
}) : void 0;
|
|
22482
|
+
if (deltaCandidate) return {
|
|
22483
|
+
id: WORKING_MEMORY_STATE_ID,
|
|
22484
|
+
mode: "delta",
|
|
22485
|
+
cacheKey,
|
|
22486
|
+
tagName: "working-memory",
|
|
22487
|
+
contents: deltaCandidate.contents,
|
|
22488
|
+
delta: deltaCandidate.contents,
|
|
22489
|
+
value: contents,
|
|
22490
|
+
attributes: {
|
|
22491
|
+
format: template.format,
|
|
22492
|
+
scope,
|
|
22493
|
+
patch: "unified-diff"
|
|
22494
|
+
}
|
|
22495
|
+
};
|
|
22496
|
+
return {
|
|
22497
|
+
id: WORKING_MEMORY_STATE_ID,
|
|
22498
|
+
mode: "snapshot",
|
|
22499
|
+
cacheKey,
|
|
22500
|
+
tagName: "working-memory",
|
|
22501
|
+
contents,
|
|
22502
|
+
value: contents,
|
|
22503
|
+
attributes: {
|
|
22504
|
+
format: template.format,
|
|
22505
|
+
scope
|
|
22506
|
+
}
|
|
22507
|
+
};
|
|
22508
|
+
}
|
|
22509
|
+
};
|
|
22510
|
+
/**
|
|
22511
|
+
* Stable cache key for the rendered working memory payload. Returns a SHA-256
|
|
22512
|
+
* digest so dedup metadata stays compact regardless of payload size (working
|
|
22513
|
+
* memory blobs can grow arbitrarily long).
|
|
22514
|
+
*/
|
|
22515
|
+
function stableWorkingMemoryCacheKey(input) {
|
|
22516
|
+
const hash = createHash("sha256");
|
|
22517
|
+
hash.update(input.format);
|
|
22518
|
+
hash.update("\0");
|
|
22519
|
+
hash.update(input.data ?? "");
|
|
22520
|
+
return `sha256:${hash.digest("hex")}`;
|
|
22521
|
+
}
|
|
22522
|
+
/**
|
|
22523
|
+
* Build a unified-diff delta against the most recently emitted state. Prefers
|
|
22524
|
+
* the latest delta's `value` (the post-edit full text) when available, falling
|
|
22525
|
+
* back to the snapshot's `value` and finally the snapshot's `contents`. This
|
|
22526
|
+
* keeps deltas incremental (B→C) instead of cumulative against a stale
|
|
22527
|
+
* snapshot (A→C), which matters when many small edits land between snapshots.
|
|
22528
|
+
*
|
|
22529
|
+
* Returns undefined when:
|
|
22530
|
+
* - there's no prior state to diff against
|
|
22531
|
+
* - the prior state isn't a plain string (multimodal signal)
|
|
22532
|
+
*
|
|
22533
|
+
* In either case the caller falls back to emitting a full snapshot.
|
|
22534
|
+
*/
|
|
22535
|
+
function buildMarkdownDelta(args) {
|
|
22536
|
+
const { lastSnapshot, deltasSinceSnapshot, nextContents } = args;
|
|
22537
|
+
const prior = pickStringValue(readSignalValue(deltasSinceSnapshot.at(-1))) ?? pickStringValue(readSignalValue(lastSnapshot)) ?? (typeof lastSnapshot?.contents === "string" ? lastSnapshot.contents : void 0);
|
|
22538
|
+
if (!prior) return;
|
|
22539
|
+
return { contents: renderHunksOnly(prior, nextContents) };
|
|
22540
|
+
}
|
|
22541
|
+
function pickStringValue(value) {
|
|
22542
|
+
return typeof value === "string" ? value : void 0;
|
|
22543
|
+
}
|
|
22544
|
+
function readSignalValue(signal) {
|
|
22545
|
+
return (signal?.metadata)?.value;
|
|
22546
|
+
}
|
|
22547
|
+
/**
|
|
22548
|
+
* Render a unified-diff-style patch body containing only `@@` hunks and their
|
|
22549
|
+
* lines — dropping the filename preamble (`Index:` / `===` / `---` / `+++`)
|
|
22550
|
+
* that `createPatch` emits and the `` trailer.
|
|
22551
|
+
* The preamble exists for tooling like `patch -p1` to know which file to
|
|
22552
|
+
* apply to; we only ever diff a single working-memory blob. The newline
|
|
22553
|
+
* trailer is semantically meaningless to the model and adds noise to the
|
|
22554
|
+
* state signal.
|
|
22555
|
+
*/
|
|
22556
|
+
function renderHunksOnly(prior, next) {
|
|
22557
|
+
const { hunks } = structuredPatch("", "", prior, next, "", "", { context: 0 });
|
|
22558
|
+
return hunks.map((hunk) => {
|
|
22559
|
+
return [`@@ -${hunk.oldStart},${hunk.oldLines} +${hunk.newStart},${hunk.newLines} @@`, ...hunk.lines.filter((line) => !line.startsWith("\"))].join("\n");
|
|
22560
|
+
}).join("\n");
|
|
22561
|
+
}
|
|
22562
|
+
//#endregion
|
|
22416
22563
|
//#region src/processors/observational-memory/activation-ttl.ts
|
|
22417
22564
|
const MINUTE = 6e4;
|
|
22418
22565
|
const HOUR = 60 * MINUTE;
|
|
@@ -25391,6 +25538,21 @@ var ReflectorRunner = class {
|
|
|
25391
25538
|
memory;
|
|
25392
25539
|
onReflectionCommitted;
|
|
25393
25540
|
mastra;
|
|
25541
|
+
/**
|
|
25542
|
+
* Per-lock-key observation-token count of the last unproductive synchronous
|
|
25543
|
+
* reflection (failed, or committed while still over the reflection
|
|
25544
|
+
* threshold). `call()` already runs the full bounded compression ladder for
|
|
25545
|
+
* a given input, so re-running it against unchanged observations cannot
|
|
25546
|
+
* succeed — threshold-triggered sync reflection is skipped while the count
|
|
25547
|
+
* is unchanged and retried as soon as the input differs.
|
|
25548
|
+
* Keyed by lock key (thread/resource), which is stable across generations —
|
|
25549
|
+
* record ids change every time a generation is created.
|
|
25550
|
+
*
|
|
25551
|
+
* Lifecycle: an entry is deleted when a sync reflection finishes under
|
|
25552
|
+
* threshold and replaced on each unproductive attempt. Entries are one
|
|
25553
|
+
* number per active thread/resource key and live for the runner's lifetime.
|
|
25554
|
+
*/
|
|
25555
|
+
syncReflectionSuppression = /* @__PURE__ */ new Map();
|
|
25394
25556
|
constructor(opts) {
|
|
25395
25557
|
this.reflectionConfig = opts.reflectionConfig;
|
|
25396
25558
|
this.observationConfig = opts.observationConfig;
|
|
@@ -25473,6 +25635,8 @@ var ReflectorRunner = class {
|
|
|
25473
25635
|
};
|
|
25474
25636
|
let reflectedTokens = 0;
|
|
25475
25637
|
let attemptNumber = 0;
|
|
25638
|
+
/** True when the latest attempt returned an empty block for non-empty input. */
|
|
25639
|
+
let emptyOutput = false;
|
|
25476
25640
|
while (currentLevel <= maxLevel) {
|
|
25477
25641
|
attemptNumber++;
|
|
25478
25642
|
const isRetry = attemptNumber > 1;
|
|
@@ -25536,14 +25700,18 @@ var ReflectorRunner = class {
|
|
|
25536
25700
|
}
|
|
25537
25701
|
finalProviderMetadata = result.providerMetadata ?? finalProviderMetadata;
|
|
25538
25702
|
parsed = parseReflectorOutput(result.text, observations, activeExtractors);
|
|
25703
|
+
emptyOutput = !parsed.degenerate && observations.trim().length > 0 && parsed.observations.trim().length === 0;
|
|
25539
25704
|
if (parsed.degenerate) {
|
|
25540
25705
|
omDebug(`[OM:callReflector] attempt #${attemptNumber}: degenerate repetition detected, treating as compression failure. ${describeDegenerateOutput(result.text, 2e3)}`);
|
|
25541
25706
|
reflectedTokens = originalTokens;
|
|
25707
|
+
} else if (emptyOutput) {
|
|
25708
|
+
omDebug(`[OM:callReflector] attempt #${attemptNumber}: empty observations block for non-empty input, treating as compression failure`);
|
|
25709
|
+
reflectedTokens = originalTokens;
|
|
25542
25710
|
} else reflectedTokens = this.tokenCounter.countObservations(parsed.observations);
|
|
25543
25711
|
omDebug(`[OM:callReflector] attempt #${attemptNumber} parsed: reflectedTokens=${reflectedTokens}, targetThreshold=${targetThreshold}, compressionValid=${validateCompression(reflectedTokens, targetThreshold)}, parsedObsLen=${parsed.observations?.length}, degenerate=${parsed.degenerate ?? false}`);
|
|
25544
|
-
if (!parsed.degenerate && (validateCompression(reflectedTokens, targetThreshold) || currentLevel >= maxLevel)) break;
|
|
25545
|
-
if (parsed.degenerate && currentLevel >= maxLevel) {
|
|
25546
|
-
omDebug(`[OM:callReflector] degenerate output persists at maxLevel=${maxLevel}, breaking`);
|
|
25712
|
+
if (!parsed.degenerate && !emptyOutput && (validateCompression(reflectedTokens, targetThreshold) || currentLevel >= maxLevel)) break;
|
|
25713
|
+
if ((parsed.degenerate || emptyOutput) && currentLevel >= maxLevel) {
|
|
25714
|
+
omDebug(`[OM:callReflector] ${parsed.degenerate ? "degenerate" : "empty"} output persists at maxLevel=${maxLevel}, breaking`);
|
|
25547
25715
|
break;
|
|
25548
25716
|
}
|
|
25549
25717
|
if (streamContext?.writer) {
|
|
@@ -25581,6 +25749,7 @@ var ReflectorRunner = class {
|
|
|
25581
25749
|
}
|
|
25582
25750
|
currentLevel = Math.min(currentLevel + 1, maxLevel);
|
|
25583
25751
|
}
|
|
25752
|
+
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`);
|
|
25584
25753
|
const structuredExtraction = await extractStructuredValues({
|
|
25585
25754
|
agent,
|
|
25586
25755
|
source: "reflector",
|
|
@@ -25934,6 +26103,13 @@ var ReflectorRunner = class {
|
|
|
25934
26103
|
return;
|
|
25935
26104
|
}
|
|
25936
26105
|
}
|
|
26106
|
+
if (activationTriggeredBy === "threshold") {
|
|
26107
|
+
const suppressedAtTokens = this.syncReflectionSuppression.get(lockKey);
|
|
26108
|
+
if (suppressedAtTokens !== void 0 && observationTokens === suppressedAtTokens) {
|
|
26109
|
+
omDebug(`[OM:reflect] skipping sync reflection — observations unchanged at ${observationTokens} tokens since the last unproductive attempt; retrying once they change`);
|
|
26110
|
+
return;
|
|
26111
|
+
}
|
|
26112
|
+
}
|
|
25937
26113
|
await this.storage.setReflectingFlag(record.id, true);
|
|
25938
26114
|
registerOp(record.id, "reflecting");
|
|
25939
26115
|
const cycleId = crypto.randomUUID();
|
|
@@ -25994,6 +26170,8 @@ var ReflectorRunner = class {
|
|
|
25994
26170
|
reflection: reflectResult.observations,
|
|
25995
26171
|
tokenCount: reflectionTokenCount
|
|
25996
26172
|
});
|
|
26173
|
+
if (reflectionTokenCount >= reflectThreshold) this.syncReflectionSuppression.set(lockKey, reflectionTokenCount);
|
|
26174
|
+
else this.syncReflectionSuppression.delete(lockKey);
|
|
25997
26175
|
await this.notifyReflectionCommitted({
|
|
25998
26176
|
parentThreadId: requestedThreadId ?? record.threadId ?? "",
|
|
25999
26177
|
resourceId: record.resourceId ?? "",
|
|
@@ -26053,6 +26231,7 @@ var ReflectorRunner = class {
|
|
|
26053
26231
|
}
|
|
26054
26232
|
reflectionError = error instanceof Error ? error : new Error(String(error));
|
|
26055
26233
|
if (lifecycleError !== void 0 || abortSignal?.aborted) throw error;
|
|
26234
|
+
this.syncReflectionSuppression.set(lockKey, observationTokens);
|
|
26056
26235
|
omError("[OM] Reflection failed", error);
|
|
26057
26236
|
} finally {
|
|
26058
26237
|
try {
|
|
@@ -26399,10 +26578,24 @@ function getLatestStepParts(parts) {
|
|
|
26399
26578
|
return parts;
|
|
26400
26579
|
}
|
|
26401
26580
|
/**
|
|
26402
|
-
* Returns true
|
|
26403
|
-
*
|
|
26404
|
-
*
|
|
26581
|
+
* Returns true for persisted Working Memory state signals (`role: 'signal'`,
|
|
26582
|
+
* `signal.type: 'state'`, `state.id: 'working-memory'`). OM must not observe these:
|
|
26583
|
+
* they mirror memory OM itself manages, and re-observing them creates a self-feedback
|
|
26584
|
+
* loop that can overwrite stored working memory (#21961). Only the working-memory lane
|
|
26585
|
+
* is filtered — other state lanes are outside OM's write path, so re-observing them
|
|
26586
|
+
* cannot corrupt OM-managed state; excluding them broadly is a separate decision.
|
|
26405
26587
|
*/
|
|
26588
|
+
function isWorkingMemoryStateSignal(message) {
|
|
26589
|
+
if (message.role !== "signal") return false;
|
|
26590
|
+
const signal = message.content.metadata?.signal;
|
|
26591
|
+
if (!signal || typeof signal !== "object" || Array.isArray(signal)) return false;
|
|
26592
|
+
const signalRecord = signal;
|
|
26593
|
+
if ((signalRecord.type ?? message.type) !== "state") return false;
|
|
26594
|
+
const metadata = signalRecord.metadata;
|
|
26595
|
+
if (!metadata || typeof metadata !== "object" || Array.isArray(metadata)) return false;
|
|
26596
|
+
const state = metadata.state;
|
|
26597
|
+
return !!state && typeof state === "object" && !Array.isArray(state) && state.id === "working-memory";
|
|
26598
|
+
}
|
|
26406
26599
|
function messageHasVisibleContent(msg) {
|
|
26407
26600
|
const content = msg.content;
|
|
26408
26601
|
if (content?.parts && Array.isArray(content.parts)) return content.parts.some((p) => {
|
|
@@ -27173,7 +27366,7 @@ var ObservationalMemory = class ObservationalMemory {
|
|
|
27173
27366
|
}
|
|
27174
27367
|
const result = [];
|
|
27175
27368
|
for (const msg of allMessages) {
|
|
27176
|
-
if (msg.role === "system") continue;
|
|
27369
|
+
if (msg.role === "system" || isWorkingMemoryStateSignal(msg)) continue;
|
|
27177
27370
|
if (observedMessageIds?.has(msg.id)) continue;
|
|
27178
27371
|
const endMarkerIndex = findLastCompletedObservationBoundary(msg);
|
|
27179
27372
|
if (this.hasInProgressObservation(msg)) result.push(msg);
|
|
@@ -27395,7 +27588,7 @@ var ObservationalMemory = class ObservationalMemory {
|
|
|
27395
27588
|
},
|
|
27396
27589
|
filter: startDate ? { dateRange: { start: startDate } } : void 0
|
|
27397
27590
|
});
|
|
27398
|
-
return result.messages.filter((msg) => msg.role !== "system");
|
|
27591
|
+
return result.messages.filter((msg) => msg.role !== "system" && !isWorkingMemoryStateSignal(msg));
|
|
27399
27592
|
}
|
|
27400
27593
|
/**
|
|
27401
27594
|
* Format unobserved messages from other threads as <unobserved-context> blocks.
|
|
@@ -27854,7 +28047,7 @@ ${formattedMessages}
|
|
|
27854
28047
|
direction: "ASC"
|
|
27855
28048
|
},
|
|
27856
28049
|
filter: startDate ? { dateRange: { start: startDate } } : void 0
|
|
27857
|
-
})).messages.filter((
|
|
28050
|
+
})).messages.filter((message) => !this.observedMessageIds.has(message.id) && !isWorkingMemoryStateSignal(message));
|
|
27858
28051
|
if (filtered.length > 0) messagesByThread.set(thread.id, filtered);
|
|
27859
28052
|
}
|
|
27860
28053
|
if (messagesByThread.size === 0) return void 0;
|
|
@@ -29280,151 +29473,6 @@ var observational_memory_exports = /* @__PURE__ */ __exportAll({
|
|
|
29280
29473
|
wrapInObservationGroup: () => wrapInObservationGroup
|
|
29281
29474
|
});
|
|
29282
29475
|
//#endregion
|
|
29283
|
-
//#region src/processors/working-memory-state/processor.ts
|
|
29284
|
-
/**
|
|
29285
|
-
* WorkingMemoryStateProcessor
|
|
29286
|
-
*
|
|
29287
|
-
* Experimental: delivers working memory to the model as a state signal instead
|
|
29288
|
-
* of folding it into the system message. Storage and the `setWorkingMemory`
|
|
29289
|
-
* tool are unchanged — this processor only changes the delivery path.
|
|
29290
|
-
*
|
|
29291
|
-
* Pattern matches `BrowserContextProcessor` in `@mastra/core/browser`:
|
|
29292
|
-
* - `stateId` namespaces the state lane on the thread.
|
|
29293
|
-
* - `cacheKey` is derived from the rendered payload so dedup is automatic.
|
|
29294
|
-
* - `contextWindow.hasSnapshot` re-injection ensures the model still sees the
|
|
29295
|
-
* current snapshot after older messages drop out of the window.
|
|
29296
|
-
*
|
|
29297
|
-
* Delta emission (markdown mode only): when a prior snapshot exists in the
|
|
29298
|
-
* context window, the processor emits a unified-diff delta against that
|
|
29299
|
-
* snapshot's contents. Schema mode and the snapshot fallback always emit a
|
|
29300
|
-
* full snapshot.
|
|
29301
|
-
*
|
|
29302
|
-
* @example
|
|
29303
|
-
* ```ts
|
|
29304
|
-
* new Memory({
|
|
29305
|
-
* options: {
|
|
29306
|
-
* workingMemory: {
|
|
29307
|
-
* enabled: true,
|
|
29308
|
-
* template: '...',
|
|
29309
|
-
* useStateSignals: true, // auto-attaches this processor
|
|
29310
|
-
* },
|
|
29311
|
-
* },
|
|
29312
|
-
* });
|
|
29313
|
-
* ```
|
|
29314
|
-
*/
|
|
29315
|
-
const WORKING_MEMORY_STATE_ID = "working-memory";
|
|
29316
|
-
const WORKING_MEMORY_STATE_PROCESSOR_ID = "working-memory-state";
|
|
29317
|
-
var WorkingMemoryStateProcessor = class {
|
|
29318
|
-
memory;
|
|
29319
|
-
memoryConfig;
|
|
29320
|
-
id = WORKING_MEMORY_STATE_PROCESSOR_ID;
|
|
29321
|
-
stateId = WORKING_MEMORY_STATE_ID;
|
|
29322
|
-
constructor(memory, memoryConfig) {
|
|
29323
|
-
this.memory = memory;
|
|
29324
|
-
this.memoryConfig = memoryConfig;
|
|
29325
|
-
}
|
|
29326
|
-
async computeStateSignal(args) {
|
|
29327
|
-
const template = await this.memory.getWorkingMemoryTemplate({ memoryConfig: this.memoryConfig });
|
|
29328
|
-
if (!template) return;
|
|
29329
|
-
const contents = (await this.memory.getWorkingMemory({
|
|
29330
|
-
threadId: args.threadId,
|
|
29331
|
-
resourceId: args.resourceId,
|
|
29332
|
-
memoryConfig: this.memoryConfig
|
|
29333
|
-
}))?.trim();
|
|
29334
|
-
if (!contents) return;
|
|
29335
|
-
const cacheKey = stableWorkingMemoryCacheKey({
|
|
29336
|
-
format: template.format,
|
|
29337
|
-
data: contents
|
|
29338
|
-
});
|
|
29339
|
-
const shouldMakeSnapshot = !args.contextWindow.hasSnapshot;
|
|
29340
|
-
if (args.tracking?.currentCacheKey === cacheKey && !shouldMakeSnapshot) return;
|
|
29341
|
-
const scope = this.memory.getMergedThreadConfig(this.memoryConfig).workingMemory?.scope ?? "resource";
|
|
29342
|
-
const deltaCandidate = template.format === "markdown" && !shouldMakeSnapshot ? buildMarkdownDelta({
|
|
29343
|
-
lastSnapshot: args.lastSnapshot,
|
|
29344
|
-
deltasSinceSnapshot: args.deltasSinceSnapshot,
|
|
29345
|
-
nextContents: contents
|
|
29346
|
-
}) : void 0;
|
|
29347
|
-
if (deltaCandidate) return {
|
|
29348
|
-
id: WORKING_MEMORY_STATE_ID,
|
|
29349
|
-
mode: "delta",
|
|
29350
|
-
cacheKey,
|
|
29351
|
-
tagName: "working-memory",
|
|
29352
|
-
contents: deltaCandidate.contents,
|
|
29353
|
-
delta: deltaCandidate.contents,
|
|
29354
|
-
value: contents,
|
|
29355
|
-
attributes: {
|
|
29356
|
-
format: template.format,
|
|
29357
|
-
scope,
|
|
29358
|
-
patch: "unified-diff"
|
|
29359
|
-
}
|
|
29360
|
-
};
|
|
29361
|
-
return {
|
|
29362
|
-
id: WORKING_MEMORY_STATE_ID,
|
|
29363
|
-
mode: "snapshot",
|
|
29364
|
-
cacheKey,
|
|
29365
|
-
tagName: "working-memory",
|
|
29366
|
-
contents,
|
|
29367
|
-
value: contents,
|
|
29368
|
-
attributes: {
|
|
29369
|
-
format: template.format,
|
|
29370
|
-
scope
|
|
29371
|
-
}
|
|
29372
|
-
};
|
|
29373
|
-
}
|
|
29374
|
-
};
|
|
29375
|
-
/**
|
|
29376
|
-
* Stable cache key for the rendered working memory payload. Returns a SHA-256
|
|
29377
|
-
* digest so dedup metadata stays compact regardless of payload size (working
|
|
29378
|
-
* memory blobs can grow arbitrarily long).
|
|
29379
|
-
*/
|
|
29380
|
-
function stableWorkingMemoryCacheKey(input) {
|
|
29381
|
-
const hash = createHash("sha256");
|
|
29382
|
-
hash.update(input.format);
|
|
29383
|
-
hash.update("\0");
|
|
29384
|
-
hash.update(input.data ?? "");
|
|
29385
|
-
return `sha256:${hash.digest("hex")}`;
|
|
29386
|
-
}
|
|
29387
|
-
/**
|
|
29388
|
-
* Build a unified-diff delta against the most recently emitted state. Prefers
|
|
29389
|
-
* the latest delta's `value` (the post-edit full text) when available, falling
|
|
29390
|
-
* back to the snapshot's `value` and finally the snapshot's `contents`. This
|
|
29391
|
-
* keeps deltas incremental (B→C) instead of cumulative against a stale
|
|
29392
|
-
* snapshot (A→C), which matters when many small edits land between snapshots.
|
|
29393
|
-
*
|
|
29394
|
-
* Returns undefined when:
|
|
29395
|
-
* - there's no prior state to diff against
|
|
29396
|
-
* - the prior state isn't a plain string (multimodal signal)
|
|
29397
|
-
*
|
|
29398
|
-
* In either case the caller falls back to emitting a full snapshot.
|
|
29399
|
-
*/
|
|
29400
|
-
function buildMarkdownDelta(args) {
|
|
29401
|
-
const { lastSnapshot, deltasSinceSnapshot, nextContents } = args;
|
|
29402
|
-
const prior = pickStringValue(readSignalValue(deltasSinceSnapshot.at(-1))) ?? pickStringValue(readSignalValue(lastSnapshot)) ?? (typeof lastSnapshot?.contents === "string" ? lastSnapshot.contents : void 0);
|
|
29403
|
-
if (!prior) return;
|
|
29404
|
-
return { contents: renderHunksOnly(prior, nextContents) };
|
|
29405
|
-
}
|
|
29406
|
-
function pickStringValue(value) {
|
|
29407
|
-
return typeof value === "string" ? value : void 0;
|
|
29408
|
-
}
|
|
29409
|
-
function readSignalValue(signal) {
|
|
29410
|
-
return (signal?.metadata)?.value;
|
|
29411
|
-
}
|
|
29412
|
-
/**
|
|
29413
|
-
* Render a unified-diff-style patch body containing only `@@` hunks and their
|
|
29414
|
-
* lines — dropping the filename preamble (`Index:` / `===` / `---` / `+++`)
|
|
29415
|
-
* that `createPatch` emits and the `` trailer.
|
|
29416
|
-
* The preamble exists for tooling like `patch -p1` to know which file to
|
|
29417
|
-
* apply to; we only ever diff a single working-memory blob. The newline
|
|
29418
|
-
* trailer is semantically meaningless to the model and adds noise to the
|
|
29419
|
-
* state signal.
|
|
29420
|
-
*/
|
|
29421
|
-
function renderHunksOnly(prior, next) {
|
|
29422
|
-
const { hunks } = structuredPatch("", "", prior, next, "", "", { context: 0 });
|
|
29423
|
-
return hunks.map((hunk) => {
|
|
29424
|
-
return [`@@ -${hunk.oldStart},${hunk.oldLines} +${hunk.newStart},${hunk.newLines} @@`, ...hunk.lines.filter((line) => !line.startsWith("\"))].join("\n");
|
|
29425
|
-
}).join("\n");
|
|
29426
|
-
}
|
|
29427
|
-
//#endregion
|
|
29428
29476
|
//#region src/processors/working-memory-state/index.ts
|
|
29429
29477
|
var working_memory_state_exports = /* @__PURE__ */ __exportAll({
|
|
29430
29478
|
WORKING_MEMORY_STATE_ID: () => WORKING_MEMORY_STATE_ID,
|
|
@@ -30521,6 +30569,7 @@ ${workingMemory}`;
|
|
|
30521
30569
|
instruction: omConfig.observation.instruction,
|
|
30522
30570
|
threadTitle: omConfig.observation.threadTitle,
|
|
30523
30571
|
observeAttachments: omConfig.observation.observeAttachments,
|
|
30572
|
+
continuationHints: omConfig.observation.continuationHints,
|
|
30524
30573
|
extract: omConfig.observation.extract
|
|
30525
30574
|
} : void 0,
|
|
30526
30575
|
reflection: omConfig.reflection ? {
|
|
@@ -30531,6 +30580,7 @@ ${workingMemory}`;
|
|
|
30531
30580
|
bufferActivation: omConfig.reflection.bufferActivation,
|
|
30532
30581
|
blockAfter: omConfig.reflection.blockAfter,
|
|
30533
30582
|
instruction: omConfig.reflection.instruction,
|
|
30583
|
+
continuationHints: omConfig.reflection.continuationHints,
|
|
30534
30584
|
extract: omConfig.reflection.extract
|
|
30535
30585
|
} : void 0
|
|
30536
30586
|
});
|
|
@@ -31443,6 +31493,6 @@ Notes:
|
|
|
31443
31493
|
}
|
|
31444
31494
|
};
|
|
31445
31495
|
//#endregion
|
|
31446
|
-
export { formatMessagesForObserver as A, OBSERVATION_CONTINUATION_HINT as B, SUMMARIZE_THREAD_DEFAULTS as C, buildObserverPrompt as D, OBSERVER_SYSTEM_PROMPT as E, parseAnchorId as F, ModelByInputTokens as G, KnowledgeSemanticIndexCoordinator as H, stripEphemeralAnchorIds as I, SUBCONSCIOUS_ACTIVITY_STATE_ID as J, SubconsciousCaptureExtractor as K, OBSERVATIONAL_MEMORY_DEFAULTS as L, optimizeObservationsForContext as M, parseObserverOutput as N, buildObserverSystemPrompt as O, injectAnchorIds as P, Extractor as Q, OBSERVATION_CONTEXT_INSTRUCTIONS as R, WorkingMemoryExtractor as S, TokenCounter as T, StaleKnowledgeSemanticIndexError as U, Subconscious as V, SubconsciousRemindExtractor as W, publishSubconsciousActivity as X, buildSubconsciousActivitySnapshot as Y, renderSubconsciousActivity as Z,
|
|
31496
|
+
export { formatMessagesForObserver as A, OBSERVATION_CONTINUATION_HINT as B, SUMMARIZE_THREAD_DEFAULTS as C, buildObserverPrompt as D, OBSERVER_SYSTEM_PROMPT as E, parseAnchorId as F, ModelByInputTokens as G, KnowledgeSemanticIndexCoordinator as H, stripEphemeralAnchorIds as I, SUBCONSCIOUS_ACTIVITY_STATE_ID as J, SubconsciousCaptureExtractor as K, OBSERVATIONAL_MEMORY_DEFAULTS as L, optimizeObservationsForContext as M, parseObserverOutput as N, buildObserverSystemPrompt as O, injectAnchorIds as P, Extractor as Q, OBSERVATION_CONTEXT_INSTRUCTIONS as R, WorkingMemoryExtractor as S, TokenCounter as T, StaleKnowledgeSemanticIndexError as U, Subconscious as V, SubconsciousRemindExtractor as W, publishSubconsciousActivity as X, buildSubconsciousActivitySnapshot as Y, renderSubconsciousActivity as Z, wrapInObservationGroup as _, extractWorkingMemoryContent as a, WorkingMemoryStateProcessor as b, getObservationsAsOf as c, combineObservationGroupRanges as d, deriveObservationGroupProvenance as f, stripObservationGroups as g, renderObservationGroupsForReflection as h, WorkingMemory as i, hasCurrentTaskSection as j, extractCurrentTask as k, ObservationalMemoryProcessor as l, reconcileObservationGroupsFromReflection as m, MessageHistory$1 as n, extractWorkingMemoryTags as o, parseObservationGroups as p, subconsciousCaptureSchema as q, SemanticRecall as r, removeWorkingMemoryTags as s, Memory as t, ObservationalMemory as u, WORKING_MEMORY_STATE_ID as v, summarizeConversation as w, deepMergeWorkingMemory as x, WORKING_MEMORY_STATE_PROCESSOR_ID as y, OBSERVATION_CONTEXT_PROMPT as z };
|
|
31447
31497
|
|
|
31448
|
-
//# sourceMappingURL=src-
|
|
31498
|
+
//# sourceMappingURL=src-BATJenuZ.js.map
|