@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.
Files changed (33) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/dist/{chunk-HF2E2T6Z.js → chunk-FNWCP2TI.js} +48 -6
  3. package/dist/chunk-FNWCP2TI.js.map +1 -0
  4. package/dist/{chunk-5HE6DK63.cjs → chunk-WZKTIB4U.cjs} +48 -6
  5. package/dist/chunk-WZKTIB4U.cjs.map +1 -0
  6. package/dist/docs/SKILL.md +2 -1
  7. package/dist/docs/assets/SOURCE_MAP.json +57 -57
  8. package/dist/docs/references/docs-agents-supervisor-agents.md +3 -4
  9. package/dist/docs/references/docs-evals-evals-with-memory.md +1 -3
  10. package/dist/docs/references/docs-long-running-agents-background-tasks.md +1 -1
  11. package/dist/docs/references/docs-long-running-agents-goals.md +1 -3
  12. package/dist/docs/references/docs-memory-observational-memory.md +2 -1
  13. package/dist/docs/references/docs-memory-overview.md +6 -4
  14. package/dist/docs/references/docs-memory-semantic-recall.md +1 -1
  15. package/dist/docs/references/docs-memory-working-memory.md +3 -3
  16. package/dist/docs/references/reference-file-based-agents-memory.md +58 -0
  17. package/dist/docs/references/reference-memory-memory-class.md +1 -1
  18. package/dist/index.cjs +15 -15
  19. package/dist/index.js +1 -1
  20. package/dist/{observational-memory-XKEEBG2S.js → observational-memory-GAYCVM5R.js} +3 -3
  21. package/dist/{observational-memory-XKEEBG2S.js.map → observational-memory-GAYCVM5R.js.map} +1 -1
  22. package/dist/{observational-memory-LEIZSPQ5.cjs → observational-memory-HZP3D5IO.cjs} +29 -29
  23. package/dist/{observational-memory-LEIZSPQ5.cjs.map → observational-memory-HZP3D5IO.cjs.map} +1 -1
  24. package/dist/processors/index.cjs +27 -27
  25. package/dist/processors/index.js +1 -1
  26. package/dist/processors/observational-memory/observation-turn/step.d.ts +13 -0
  27. package/dist/processors/observational-memory/observation-turn/step.d.ts.map +1 -1
  28. package/dist/processors/observational-memory/observation-turn/turn.d.ts +25 -0
  29. package/dist/processors/observational-memory/observation-turn/turn.d.ts.map +1 -1
  30. package/dist/processors/observational-memory/processor.d.ts.map +1 -1
  31. package/package.json +4 -4
  32. package/dist/chunk-5HE6DK63.cjs.map +0 -1
  33. package/dist/chunk-HF2E2T6Z.js.map +0 -1
@@ -2807,6 +2807,18 @@ var ObservationStep = class {
2807
2807
  get prepared() {
2808
2808
  return this._prepared;
2809
2809
  }
2810
+ /**
2811
+ * Serialize to a minimal, acyclic snapshot.
2812
+ *
2813
+ * The `turn` back-reference exists only so a step can read context off its parent turn at
2814
+ * runtime. It closes the `ObservationTurn._currentStep -> ObservationStep.turn` cycle, so
2815
+ * serializing it throws "Converting circular structure to JSON" (e.g. when a turn is stashed
2816
+ * in processor state that flows into a processor-workflow snapshot). The parent turn fully
2817
+ * owns the step, so omitting the back-reference is lossless.
2818
+ */
2819
+ toJSON() {
2820
+ return { stepNumber: this.stepNumber, prepared: this._prepared };
2821
+ }
2810
2822
  /** Step context from prepare(). Throws if prepare() hasn't been called. */
2811
2823
  get context() {
2812
2824
  if (!this._context) throw new Error("Step not prepared yet \u2014 call prepare() first");
@@ -3270,6 +3282,33 @@ var ObservationTurn = class {
3270
3282
  }
3271
3283
  return this._context?.otherThreadsContext;
3272
3284
  }
3285
+ /**
3286
+ * Serialize to a minimal, acyclic snapshot of the turn's identity and lifecycle.
3287
+ *
3288
+ * `ObservationTurn` is a request-scoped runtime orchestration object: it holds live
3289
+ * references (the `ObservationalMemory` engine, the `MessageList`, the stream writer, the
3290
+ * memory provider, lifecycle hooks) and a back-reference to its current `ObservationStep`,
3291
+ * which points back at the turn — a cycle. None of that is persistable state. The turn is
3292
+ * stashed in the shared processor-state map (`state.__omTurn`) only so the input and output
3293
+ * OM processor instances can reach the *live* object within a single request; that map is
3294
+ * also threaded into processor workflows, whose snapshots the storage layer serializes with
3295
+ * `JSON.stringify`. Without this projection, that serialization throws "Converting circular
3296
+ * structure to JSON" via `_currentStep` <-> `turn`.
3297
+ *
3298
+ * The projection is lossless: the dropped fields are live runtime objects that cannot and
3299
+ * should not round-trip through storage, and OM never reads the turn back from a snapshot —
3300
+ * it always reads the live `__omTurn` from the in-memory map and re-establishes a fresh turn
3301
+ * when a deserialized `MessageList` no longer matches (see the processor's turn handling).
3302
+ */
3303
+ toJSON() {
3304
+ return {
3305
+ threadId: this.threadId,
3306
+ resourceId: this.resourceId,
3307
+ started: this._started,
3308
+ ended: this._ended,
3309
+ currentStepNumber: this._currentStep?.stepNumber
3310
+ };
3311
+ }
3273
3312
  };
3274
3313
 
3275
3314
  // src/processors/observational-memory/anchor-ids.ts
@@ -24584,7 +24623,7 @@ ${workingMemory}`;
24584
24623
  "Observational memory requires @mastra/core support for request-response-id-rotation. Please bump @mastra/core to a newer version."
24585
24624
  );
24586
24625
  }
24587
- const { ObservationalMemory: OMClass } = await import('./observational-memory-LEIZSPQ5.cjs');
24626
+ const { ObservationalMemory: OMClass } = await import('./observational-memory-HZP3D5IO.cjs');
24588
24627
  const onIndexObservations = this.hasRetrievalSearch(omConfig.retrieval) ? async (observation) => {
24589
24628
  await this.indexObservation(observation);
24590
24629
  } : void 0;
@@ -25632,7 +25671,7 @@ Notes:
25632
25671
  if (!effectiveConfig) return null;
25633
25672
  const engine = await this.omEngine;
25634
25673
  if (!engine) return null;
25635
- const { ObservationalMemoryProcessor: ObservationalMemoryProcessor2 } = await import('./observational-memory-LEIZSPQ5.cjs');
25674
+ const { ObservationalMemoryProcessor: ObservationalMemoryProcessor2 } = await import('./observational-memory-HZP3D5IO.cjs');
25636
25675
  return new ObservationalMemoryProcessor2(engine, this, {
25637
25676
  temporalMarkers: effectiveConfig.temporalMarkers
25638
25677
  });
@@ -30295,6 +30334,9 @@ async function insertTemporalGapMarkers({
30295
30334
  }
30296
30335
 
30297
30336
  // src/processors/observational-memory/processor.ts
30337
+ function asLiveTurn(value) {
30338
+ return value && typeof value.end === "function" ? value : void 0;
30339
+ }
30298
30340
  function getOmObservabilityContext(args) {
30299
30341
  if (!args.tracing || !args.tracingContext || !args.loggerVNext || !args.metrics) {
30300
30342
  return void 0;
@@ -30412,7 +30454,7 @@ var ObservationalMemoryProcessor = class {
30412
30454
  });
30413
30455
  return messageList;
30414
30456
  }
30415
- const activeTurn = state.__omTurn ?? this.turn;
30457
+ const activeTurn = asLiveTurn(state.__omTurn) ?? this.turn;
30416
30458
  if (activeTurn && activeTurn.messageList !== messageList) {
30417
30459
  await activeTurn.end().catch(() => {
30418
30460
  });
@@ -30529,7 +30571,7 @@ var ObservationalMemoryProcessor = class {
30529
30571
  return this.engine.getTokenCounter().runWithModelContext(state.__omActorModelContext, async () => {
30530
30572
  const memoryContext = memory.parseMemoryRequestContext(requestContext);
30531
30573
  if (memoryContext?.memoryConfig?.readOnly) return messageList;
30532
- const turn = state.__omTurn ?? this.turn;
30574
+ const turn = asLiveTurn(state.__omTurn) ?? this.turn;
30533
30575
  if (turn) {
30534
30576
  await turn.end();
30535
30577
  this.turn = void 0;
@@ -30625,5 +30667,5 @@ exports.stripEphemeralAnchorIds = stripEphemeralAnchorIds;
30625
30667
  exports.stripObservationGroups = stripObservationGroups;
30626
30668
  exports.summarizeConversation = summarizeConversation;
30627
30669
  exports.wrapInObservationGroup = wrapInObservationGroup;
30628
- //# sourceMappingURL=chunk-5HE6DK63.cjs.map
30629
- //# sourceMappingURL=chunk-5HE6DK63.cjs.map
30670
+ //# sourceMappingURL=chunk-WZKTIB4U.cjs.map
30671
+ //# sourceMappingURL=chunk-WZKTIB4U.cjs.map