@mastra/memory 1.23.0-alpha.1 → 1.23.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 +19 -0
- package/dist/{chunk-HF2E2T6Z.js → chunk-FNWCP2TI.js} +48 -6
- package/dist/chunk-FNWCP2TI.js.map +1 -0
- package/dist/{chunk-5HE6DK63.cjs → chunk-WZKTIB4U.cjs} +48 -6
- package/dist/chunk-WZKTIB4U.cjs.map +1 -0
- package/dist/docs/SKILL.md +2 -1
- package/dist/docs/assets/SOURCE_MAP.json +57 -57
- package/dist/docs/references/docs-agents-supervisor-agents.md +3 -4
- package/dist/docs/references/docs-evals-evals-with-memory.md +1 -3
- package/dist/docs/references/docs-long-running-agents-background-tasks.md +1 -1
- package/dist/docs/references/docs-long-running-agents-goals.md +1 -3
- package/dist/docs/references/docs-memory-observational-memory.md +2 -1
- package/dist/docs/references/docs-memory-overview.md +6 -4
- package/dist/docs/references/docs-memory-semantic-recall.md +1 -1
- package/dist/docs/references/docs-memory-working-memory.md +3 -3
- package/dist/docs/references/reference-file-based-agents-memory.md +58 -0
- package/dist/docs/references/reference-memory-memory-class.md +1 -1
- package/dist/index.cjs +15 -15
- package/dist/index.js +1 -1
- package/dist/{observational-memory-XKEEBG2S.js → observational-memory-GAYCVM5R.js} +3 -3
- package/dist/{observational-memory-XKEEBG2S.js.map → observational-memory-GAYCVM5R.js.map} +1 -1
- package/dist/{observational-memory-LEIZSPQ5.cjs → observational-memory-HZP3D5IO.cjs} +29 -29
- package/dist/{observational-memory-LEIZSPQ5.cjs.map → observational-memory-HZP3D5IO.cjs.map} +1 -1
- package/dist/processors/index.cjs +27 -27
- package/dist/processors/index.js +1 -1
- package/dist/processors/observational-memory/observation-turn/step.d.ts +13 -0
- package/dist/processors/observational-memory/observation-turn/step.d.ts.map +1 -1
- package/dist/processors/observational-memory/observation-turn/turn.d.ts +25 -0
- package/dist/processors/observational-memory/observation-turn/turn.d.ts.map +1 -1
- package/dist/processors/observational-memory/processor.d.ts.map +1 -1
- package/package.json +4 -4
- package/dist/chunk-5HE6DK63.cjs.map +0 -1
- package/dist/chunk-HF2E2T6Z.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,24 @@
|
|
|
1
1
|
# @mastra/memory
|
|
2
2
|
|
|
3
|
+
## 1.23.0-alpha.3
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Fixed a "Converting circular structure to JSON" crash when Observational Memory was used with an input or output processor composed as a workflow (the "run guardrails in parallel" pattern). ([#17949](https://github.com/mastra-ai/mastra/pull/17949))
|
|
8
|
+
|
|
9
|
+
The circular data reached the processor workflow's snapshot and broke storage: PostgreSQL threw, and LibSQL saved a corrupted snapshot. Observational Memory now keeps its runtime data in a serializable form, so workflow-composed processors work with it and snapshots persist correctly.
|
|
10
|
+
|
|
11
|
+
- Updated dependencies [[`a5c6337`](https://github.com/mastra-ai/mastra/commit/a5c6337d23c7686c81a32ce62f550f610543a240), [`8b97958`](https://github.com/mastra-ai/mastra/commit/8b979589f9aa59ba67cac565949475f2ffeb4ac3), [`8410541`](https://github.com/mastra-ai/mastra/commit/84105412c60ecd3bb33a9838146f59c4b588228f), [`01b338c`](https://github.com/mastra-ai/mastra/commit/01b338c56271f0219606710e3e8b26dee27ac6c2), [`8b7361d`](https://github.com/mastra-ai/mastra/commit/8b7361d35de68b80d05d30a74e0c69e7218fd612), [`c43f3a9`](https://github.com/mastra-ai/mastra/commit/c43f3a9d1efde99b38789364ba4d0ba670f430e3)]:
|
|
12
|
+
- @mastra/core@1.51.0-alpha.4
|
|
13
|
+
|
|
14
|
+
## 1.23.0-alpha.2
|
|
15
|
+
|
|
16
|
+
### Patch Changes
|
|
17
|
+
|
|
18
|
+
- Updated dependencies [[`e955965`](https://github.com/mastra-ai/mastra/commit/e955965dce575a903e37cf054d28ea99aa48785e), [`bc1121a`](https://github.com/mastra-ai/mastra/commit/bc1121a7bb98f7cd73e82e3a7913a667a9fa9911), [`860ef7e`](https://github.com/mastra-ai/mastra/commit/860ef7e77d92b63469cbe5857aa1e626197e43e9), [`17e818c`](https://github.com/mastra-ai/mastra/commit/17e818c51a958ba90641b1a959dc38faf8c034e9), [`4451dfe`](https://github.com/mastra-ai/mastra/commit/4451dfe857428e7abcc0261a507a2e186dae6d47), [`1d39058`](https://github.com/mastra-ai/mastra/commit/1d39058e548efd691799985d5c8af2737f1c3bd2)]:
|
|
19
|
+
- @mastra/core@1.51.0-alpha.2
|
|
20
|
+
- @mastra/schema-compat@1.3.4-alpha.1
|
|
21
|
+
|
|
3
22
|
## 1.23.0-alpha.1
|
|
4
23
|
|
|
5
24
|
### Minor Changes
|
|
@@ -2783,6 +2783,18 @@ var ObservationStep = class {
|
|
|
2783
2783
|
get prepared() {
|
|
2784
2784
|
return this._prepared;
|
|
2785
2785
|
}
|
|
2786
|
+
/**
|
|
2787
|
+
* Serialize to a minimal, acyclic snapshot.
|
|
2788
|
+
*
|
|
2789
|
+
* The `turn` back-reference exists only so a step can read context off its parent turn at
|
|
2790
|
+
* runtime. It closes the `ObservationTurn._currentStep -> ObservationStep.turn` cycle, so
|
|
2791
|
+
* serializing it throws "Converting circular structure to JSON" (e.g. when a turn is stashed
|
|
2792
|
+
* in processor state that flows into a processor-workflow snapshot). The parent turn fully
|
|
2793
|
+
* owns the step, so omitting the back-reference is lossless.
|
|
2794
|
+
*/
|
|
2795
|
+
toJSON() {
|
|
2796
|
+
return { stepNumber: this.stepNumber, prepared: this._prepared };
|
|
2797
|
+
}
|
|
2786
2798
|
/** Step context from prepare(). Throws if prepare() hasn't been called. */
|
|
2787
2799
|
get context() {
|
|
2788
2800
|
if (!this._context) throw new Error("Step not prepared yet \u2014 call prepare() first");
|
|
@@ -3246,6 +3258,33 @@ var ObservationTurn = class {
|
|
|
3246
3258
|
}
|
|
3247
3259
|
return this._context?.otherThreadsContext;
|
|
3248
3260
|
}
|
|
3261
|
+
/**
|
|
3262
|
+
* Serialize to a minimal, acyclic snapshot of the turn's identity and lifecycle.
|
|
3263
|
+
*
|
|
3264
|
+
* `ObservationTurn` is a request-scoped runtime orchestration object: it holds live
|
|
3265
|
+
* references (the `ObservationalMemory` engine, the `MessageList`, the stream writer, the
|
|
3266
|
+
* memory provider, lifecycle hooks) and a back-reference to its current `ObservationStep`,
|
|
3267
|
+
* which points back at the turn — a cycle. None of that is persistable state. The turn is
|
|
3268
|
+
* stashed in the shared processor-state map (`state.__omTurn`) only so the input and output
|
|
3269
|
+
* OM processor instances can reach the *live* object within a single request; that map is
|
|
3270
|
+
* also threaded into processor workflows, whose snapshots the storage layer serializes with
|
|
3271
|
+
* `JSON.stringify`. Without this projection, that serialization throws "Converting circular
|
|
3272
|
+
* structure to JSON" via `_currentStep` <-> `turn`.
|
|
3273
|
+
*
|
|
3274
|
+
* The projection is lossless: the dropped fields are live runtime objects that cannot and
|
|
3275
|
+
* should not round-trip through storage, and OM never reads the turn back from a snapshot —
|
|
3276
|
+
* it always reads the live `__omTurn` from the in-memory map and re-establishes a fresh turn
|
|
3277
|
+
* when a deserialized `MessageList` no longer matches (see the processor's turn handling).
|
|
3278
|
+
*/
|
|
3279
|
+
toJSON() {
|
|
3280
|
+
return {
|
|
3281
|
+
threadId: this.threadId,
|
|
3282
|
+
resourceId: this.resourceId,
|
|
3283
|
+
started: this._started,
|
|
3284
|
+
ended: this._ended,
|
|
3285
|
+
currentStepNumber: this._currentStep?.stepNumber
|
|
3286
|
+
};
|
|
3287
|
+
}
|
|
3249
3288
|
};
|
|
3250
3289
|
|
|
3251
3290
|
// src/processors/observational-memory/anchor-ids.ts
|
|
@@ -24560,7 +24599,7 @@ ${workingMemory}`;
|
|
|
24560
24599
|
"Observational memory requires @mastra/core support for request-response-id-rotation. Please bump @mastra/core to a newer version."
|
|
24561
24600
|
);
|
|
24562
24601
|
}
|
|
24563
|
-
const { ObservationalMemory: OMClass } = await import('./observational-memory-
|
|
24602
|
+
const { ObservationalMemory: OMClass } = await import('./observational-memory-GAYCVM5R.js');
|
|
24564
24603
|
const onIndexObservations = this.hasRetrievalSearch(omConfig.retrieval) ? async (observation) => {
|
|
24565
24604
|
await this.indexObservation(observation);
|
|
24566
24605
|
} : void 0;
|
|
@@ -25608,7 +25647,7 @@ Notes:
|
|
|
25608
25647
|
if (!effectiveConfig) return null;
|
|
25609
25648
|
const engine = await this.omEngine;
|
|
25610
25649
|
if (!engine) return null;
|
|
25611
|
-
const { ObservationalMemoryProcessor: ObservationalMemoryProcessor2 } = await import('./observational-memory-
|
|
25650
|
+
const { ObservationalMemoryProcessor: ObservationalMemoryProcessor2 } = await import('./observational-memory-GAYCVM5R.js');
|
|
25612
25651
|
return new ObservationalMemoryProcessor2(engine, this, {
|
|
25613
25652
|
temporalMarkers: effectiveConfig.temporalMarkers
|
|
25614
25653
|
});
|
|
@@ -30271,6 +30310,9 @@ async function insertTemporalGapMarkers({
|
|
|
30271
30310
|
}
|
|
30272
30311
|
|
|
30273
30312
|
// src/processors/observational-memory/processor.ts
|
|
30313
|
+
function asLiveTurn(value) {
|
|
30314
|
+
return value && typeof value.end === "function" ? value : void 0;
|
|
30315
|
+
}
|
|
30274
30316
|
function getOmObservabilityContext(args) {
|
|
30275
30317
|
if (!args.tracing || !args.tracingContext || !args.loggerVNext || !args.metrics) {
|
|
30276
30318
|
return void 0;
|
|
@@ -30388,7 +30430,7 @@ var ObservationalMemoryProcessor = class {
|
|
|
30388
30430
|
});
|
|
30389
30431
|
return messageList;
|
|
30390
30432
|
}
|
|
30391
|
-
const activeTurn = state.__omTurn ?? this.turn;
|
|
30433
|
+
const activeTurn = asLiveTurn(state.__omTurn) ?? this.turn;
|
|
30392
30434
|
if (activeTurn && activeTurn.messageList !== messageList) {
|
|
30393
30435
|
await activeTurn.end().catch(() => {
|
|
30394
30436
|
});
|
|
@@ -30505,7 +30547,7 @@ var ObservationalMemoryProcessor = class {
|
|
|
30505
30547
|
return this.engine.getTokenCounter().runWithModelContext(state.__omActorModelContext, async () => {
|
|
30506
30548
|
const memoryContext = parseMemoryRequestContext(requestContext);
|
|
30507
30549
|
if (memoryContext?.memoryConfig?.readOnly) return messageList;
|
|
30508
|
-
const turn = state.__omTurn ?? this.turn;
|
|
30550
|
+
const turn = asLiveTurn(state.__omTurn) ?? this.turn;
|
|
30509
30551
|
if (turn) {
|
|
30510
30552
|
await turn.end();
|
|
30511
30553
|
this.turn = void 0;
|
|
@@ -30558,5 +30600,5 @@ function getObservationsAsOf(activeObservations, asOf) {
|
|
|
30558
30600
|
}
|
|
30559
30601
|
|
|
30560
30602
|
export { Extractor, Memory, ModelByInputTokens, OBSERVER_SYSTEM_PROMPT, ObservationalMemory, ObservationalMemoryProcessor, SUMMARIZE_THREAD_DEFAULTS, TokenCounter, WorkingMemoryExtractor, buildObserverPrompt, buildObserverSystemPrompt, combineObservationGroupRanges, deepMergeWorkingMemory, deriveObservationGroupProvenance, extractCurrentTask, extractWorkingMemoryContent, extractWorkingMemoryTags, formatMessagesForObserver, getObservationsAsOf, hasCurrentTaskSection, injectAnchorIds, optimizeObservationsForContext, parseAnchorId, parseObservationGroups, parseObserverOutput, reconcileObservationGroupsFromReflection, removeWorkingMemoryTags, renderObservationGroupsForReflection, stripEphemeralAnchorIds, stripObservationGroups, summarizeConversation, wrapInObservationGroup };
|
|
30561
|
-
//# sourceMappingURL=chunk-
|
|
30562
|
-
//# sourceMappingURL=chunk-
|
|
30603
|
+
//# sourceMappingURL=chunk-FNWCP2TI.js.map
|
|
30604
|
+
//# sourceMappingURL=chunk-FNWCP2TI.js.map
|