@mastra/memory 1.1.0-alpha.0 → 1.1.0

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 (38) hide show
  1. package/CHANGELOG.md +95 -0
  2. package/dist/chunk-6TXUWFIU.js +3188 -0
  3. package/dist/chunk-6TXUWFIU.js.map +1 -0
  4. package/dist/chunk-FQJWVCDF.cjs +3205 -0
  5. package/dist/chunk-FQJWVCDF.cjs.map +1 -0
  6. package/dist/docs/README.md +1 -1
  7. package/dist/docs/SKILL.md +12 -1
  8. package/dist/docs/SOURCE_MAP.json +62 -2
  9. package/dist/docs/memory/02-storage.md +10 -0
  10. package/dist/index.cjs +96 -1
  11. package/dist/index.cjs.map +1 -1
  12. package/dist/index.d.ts +53 -1
  13. package/dist/index.d.ts.map +1 -1
  14. package/dist/index.js +96 -1
  15. package/dist/index.js.map +1 -1
  16. package/dist/observational-memory-3Q42SITP.cjs +52 -0
  17. package/dist/observational-memory-3Q42SITP.cjs.map +1 -0
  18. package/dist/observational-memory-VXLHOSDZ.js +3 -0
  19. package/dist/observational-memory-VXLHOSDZ.js.map +1 -0
  20. package/dist/processors/index.cjs +52 -0
  21. package/dist/processors/index.cjs.map +1 -0
  22. package/dist/processors/index.d.ts +2 -0
  23. package/dist/processors/index.d.ts.map +1 -0
  24. package/dist/processors/index.js +3 -0
  25. package/dist/processors/index.js.map +1 -0
  26. package/dist/processors/observational-memory/index.d.ts +18 -0
  27. package/dist/processors/observational-memory/index.d.ts.map +1 -0
  28. package/dist/processors/observational-memory/observational-memory.d.ts +579 -0
  29. package/dist/processors/observational-memory/observational-memory.d.ts.map +1 -0
  30. package/dist/processors/observational-memory/observer-agent.d.ts +117 -0
  31. package/dist/processors/observational-memory/observer-agent.d.ts.map +1 -0
  32. package/dist/processors/observational-memory/reflector-agent.d.ts +46 -0
  33. package/dist/processors/observational-memory/reflector-agent.d.ts.map +1 -0
  34. package/dist/processors/observational-memory/token-counter.d.ts +30 -0
  35. package/dist/processors/observational-memory/token-counter.d.ts.map +1 -0
  36. package/dist/processors/observational-memory/types.d.ts +288 -0
  37. package/dist/processors/observational-memory/types.d.ts.map +1 -0
  38. package/package.json +18 -8
package/CHANGELOG.md CHANGED
@@ -1,5 +1,100 @@
1
1
  # @mastra/memory
2
2
 
3
+ ## 1.1.0
4
+
5
+ ### Minor Changes
6
+
7
+ - Added Observational Memory — a new memory system that keeps your agent's context window small while preserving long-term memory across conversations. ([#12599](https://github.com/mastra-ai/mastra/pull/12599))
8
+
9
+ **Why:** Long conversations cause context rot and waste tokens. Observational Memory compresses conversation history into observations (5–40x compression) and periodically condenses those into reflections. Your agent stays fast and focused, even after thousands of messages.
10
+
11
+ **Usage:**
12
+
13
+ ```ts
14
+ import { Memory } from '@mastra/memory';
15
+ import { PostgresStore } from '@mastra/pg';
16
+
17
+ const memory = new Memory({
18
+ storage: new PostgresStore({ connectionString: process.env.DATABASE_URL }),
19
+ options: {
20
+ observationalMemory: true,
21
+ },
22
+ });
23
+
24
+ const agent = new Agent({
25
+ name: 'my-agent',
26
+ model: openai('gpt-4o'),
27
+ memory,
28
+ });
29
+ ```
30
+
31
+ **What's new:**
32
+ - `observationalMemory: true` enables the three-tier memory system (recent messages → observations → reflections)
33
+ - Thread-scoped (per-conversation) and resource-scoped (shared across all threads for a user) modes
34
+ - Manual `observe()` API for triggering observation outside the normal agent loop
35
+ - New OM storage methods for pg, libsql, and mongodb adapters (conditionally enabled)
36
+ - `Agent.findProcessor()` method for looking up processors by ID
37
+ - `processorStates` for persisting processor state across loop iterations
38
+ - Abort signal propagation to processors
39
+ - `ProcessorStreamWriter` for custom stream events from processors
40
+
41
+ - Expose token usage from embedding operations ([#12556](https://github.com/mastra-ai/mastra/pull/12556))
42
+ - `saveMessages` now returns `usage: { tokens: number }` with aggregated token count from all embeddings
43
+ - `recall` now returns `usage: { tokens: number }` from the vector search query embedding
44
+ - Updated abstract method signatures in `MastraMemory` to include optional `usage` in return types
45
+
46
+ This allows users to track embedding token usage when using the Memory class.
47
+
48
+ ### Patch Changes
49
+
50
+ - Updated dependencies [[`e6fc281`](https://github.com/mastra-ai/mastra/commit/e6fc281896a3584e9e06465b356a44fe7faade65), [`97be6c8`](https://github.com/mastra-ai/mastra/commit/97be6c8963130fca8a664fcf99d7b3a38e463595), [`2770921`](https://github.com/mastra-ai/mastra/commit/2770921eec4d55a36b278d15c3a83f694e462ee5), [`b1695db`](https://github.com/mastra-ai/mastra/commit/b1695db2d7be0c329d499619c7881899649188d0), [`5fe1fe0`](https://github.com/mastra-ai/mastra/commit/5fe1fe0109faf2c87db34b725d8a4571a594f80e), [`4133d48`](https://github.com/mastra-ai/mastra/commit/4133d48eaa354cdb45920dc6265732ffbc96788d), [`abae238`](https://github.com/mastra-ai/mastra/commit/abae238c755ebaf867bbfa1a3a219ef003a1021a), [`5dd01cc`](https://github.com/mastra-ai/mastra/commit/5dd01cce68d61874aa3ecbd91ee17884cfd5aca2), [`13e0a2a`](https://github.com/mastra-ai/mastra/commit/13e0a2a2bcec01ff4d701274b3727d5e907a6a01), [`f6673b8`](https://github.com/mastra-ai/mastra/commit/f6673b893b65b7d273ad25ead42e990704cc1e17), [`cd6be8a`](https://github.com/mastra-ai/mastra/commit/cd6be8ad32741cd41cabf508355bb31b71e8a5bd), [`9eb4e8e`](https://github.com/mastra-ai/mastra/commit/9eb4e8e39efbdcfff7a40ff2ce07ce2714c65fa8), [`c987384`](https://github.com/mastra-ai/mastra/commit/c987384d6c8ca844a9701d7778f09f5a88da7f9f), [`cb8cc12`](https://github.com/mastra-ai/mastra/commit/cb8cc12bfadd526aa95a01125076f1da44e4afa7), [`aa37c84`](https://github.com/mastra-ai/mastra/commit/aa37c84d29b7db68c72517337932ef486c316275), [`62f5d50`](https://github.com/mastra-ai/mastra/commit/62f5d5043debbba497dacb7ab008fe86b38b8de3), [`47eba72`](https://github.com/mastra-ai/mastra/commit/47eba72f0397d0d14fbe324b97940c3d55e5a525)]:
51
+ - @mastra/core@1.2.0
52
+ - @mastra/schema-compat@1.1.0
53
+
54
+ ## 1.1.0-alpha.1
55
+
56
+ ### Minor Changes
57
+
58
+ - Added Observational Memory — a new memory system that keeps your agent's context window small while preserving long-term memory across conversations. ([#12599](https://github.com/mastra-ai/mastra/pull/12599))
59
+
60
+ **Why:** Long conversations cause context rot and waste tokens. Observational Memory compresses conversation history into observations (5–40x compression) and periodically condenses those into reflections. Your agent stays fast and focused, even after thousands of messages.
61
+
62
+ **Usage:**
63
+
64
+ ```ts
65
+ import { Memory } from '@mastra/memory';
66
+ import { PostgresStore } from '@mastra/pg';
67
+
68
+ const memory = new Memory({
69
+ storage: new PostgresStore({ connectionString: process.env.DATABASE_URL }),
70
+ options: {
71
+ observationalMemory: true,
72
+ },
73
+ });
74
+
75
+ const agent = new Agent({
76
+ name: 'my-agent',
77
+ model: openai('gpt-4o'),
78
+ memory,
79
+ });
80
+ ```
81
+
82
+ **What's new:**
83
+ - `observationalMemory: true` enables the three-tier memory system (recent messages → observations → reflections)
84
+ - Thread-scoped (per-conversation) and resource-scoped (shared across all threads for a user) modes
85
+ - Manual `observe()` API for triggering observation outside the normal agent loop
86
+ - New OM storage methods for pg, libsql, and mongodb adapters (conditionally enabled)
87
+ - `Agent.findProcessor()` method for looking up processors by ID
88
+ - `processorStates` for persisting processor state across loop iterations
89
+ - Abort signal propagation to processors
90
+ - `ProcessorStreamWriter` for custom stream events from processors
91
+
92
+ ### Patch Changes
93
+
94
+ - Updated dependencies [[`2770921`](https://github.com/mastra-ai/mastra/commit/2770921eec4d55a36b278d15c3a83f694e462ee5), [`b1695db`](https://github.com/mastra-ai/mastra/commit/b1695db2d7be0c329d499619c7881899649188d0), [`4133d48`](https://github.com/mastra-ai/mastra/commit/4133d48eaa354cdb45920dc6265732ffbc96788d), [`abae238`](https://github.com/mastra-ai/mastra/commit/abae238c755ebaf867bbfa1a3a219ef003a1021a), [`5dd01cc`](https://github.com/mastra-ai/mastra/commit/5dd01cce68d61874aa3ecbd91ee17884cfd5aca2), [`13e0a2a`](https://github.com/mastra-ai/mastra/commit/13e0a2a2bcec01ff4d701274b3727d5e907a6a01), [`c987384`](https://github.com/mastra-ai/mastra/commit/c987384d6c8ca844a9701d7778f09f5a88da7f9f), [`cb8cc12`](https://github.com/mastra-ai/mastra/commit/cb8cc12bfadd526aa95a01125076f1da44e4afa7), [`62f5d50`](https://github.com/mastra-ai/mastra/commit/62f5d5043debbba497dacb7ab008fe86b38b8de3)]:
95
+ - @mastra/core@1.2.0-alpha.1
96
+ - @mastra/schema-compat@1.1.0-alpha.0
97
+
3
98
  ## 1.1.0-alpha.0
4
99
 
5
100
  ### Minor Changes