@mastra/memory 0.0.0-error-handler-fix-20251020202607 → 0.0.0-execa-dynamic-import-20260304221256

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 (119) hide show
  1. package/CHANGELOG.md +2181 -3
  2. package/LICENSE.md +15 -0
  3. package/dist/_types/@internal_ai-sdk-v4/dist/index.d.ts +7562 -0
  4. package/dist/chunk-23EXJLET.cjs +84 -0
  5. package/dist/chunk-23EXJLET.cjs.map +1 -0
  6. package/dist/chunk-33ZIVK5L.js +5220 -0
  7. package/dist/chunk-33ZIVK5L.js.map +1 -0
  8. package/dist/chunk-BSDWQEU3.js +79 -0
  9. package/dist/chunk-BSDWQEU3.js.map +1 -0
  10. package/dist/chunk-DGUM43GV.js +10 -0
  11. package/dist/chunk-DGUM43GV.js.map +1 -0
  12. package/dist/chunk-EQ4M72KU.js +439 -0
  13. package/dist/chunk-EQ4M72KU.js.map +1 -0
  14. package/dist/chunk-HJYHDIOC.js +250 -0
  15. package/dist/chunk-HJYHDIOC.js.map +1 -0
  16. package/dist/chunk-IDRQZVB4.cjs +84 -0
  17. package/dist/chunk-IDRQZVB4.cjs.map +1 -0
  18. package/dist/chunk-JEQ2X3Z6.cjs +12 -0
  19. package/dist/chunk-JEQ2X3Z6.cjs.map +1 -0
  20. package/dist/chunk-LIBOSOHM.cjs +252 -0
  21. package/dist/chunk-LIBOSOHM.cjs.map +1 -0
  22. package/dist/chunk-Q7VDGOMJ.cjs +5240 -0
  23. package/dist/chunk-Q7VDGOMJ.cjs.map +1 -0
  24. package/dist/chunk-RC6RZVYE.js +79 -0
  25. package/dist/chunk-RC6RZVYE.js.map +1 -0
  26. package/dist/chunk-ZD3BKU5O.cjs +441 -0
  27. package/dist/chunk-ZD3BKU5O.cjs.map +1 -0
  28. package/dist/docs/SKILL.md +55 -0
  29. package/dist/docs/assets/SOURCE_MAP.json +103 -0
  30. package/dist/docs/references/docs-agents-agent-approval.md +588 -0
  31. package/dist/docs/references/docs-agents-agent-memory.md +209 -0
  32. package/dist/docs/references/docs-agents-network-approval.md +275 -0
  33. package/dist/docs/references/docs-agents-networks.md +299 -0
  34. package/dist/docs/references/docs-agents-supervisor-agents.md +304 -0
  35. package/dist/docs/references/docs-memory-memory-processors.md +314 -0
  36. package/dist/docs/references/docs-memory-message-history.md +260 -0
  37. package/dist/docs/references/docs-memory-observational-memory.md +255 -0
  38. package/dist/docs/references/docs-memory-overview.md +45 -0
  39. package/dist/docs/references/docs-memory-semantic-recall.md +288 -0
  40. package/dist/docs/references/docs-memory-storage.md +261 -0
  41. package/dist/docs/references/docs-memory-working-memory.md +400 -0
  42. package/dist/docs/references/reference-core-getMemory.md +50 -0
  43. package/dist/docs/references/reference-core-listMemory.md +56 -0
  44. package/dist/docs/references/reference-memory-clone-utilities.md +199 -0
  45. package/dist/docs/references/reference-memory-cloneThread.md +142 -0
  46. package/dist/docs/references/reference-memory-createThread.md +68 -0
  47. package/dist/docs/references/reference-memory-getThreadById.md +24 -0
  48. package/dist/docs/references/reference-memory-listThreads.md +145 -0
  49. package/dist/docs/references/reference-memory-memory-class.md +147 -0
  50. package/dist/docs/references/reference-memory-observational-memory.md +577 -0
  51. package/dist/docs/references/reference-processors-token-limiter-processor.md +115 -0
  52. package/dist/docs/references/reference-storage-dynamodb.md +282 -0
  53. package/dist/docs/references/reference-storage-libsql.md +135 -0
  54. package/dist/docs/references/reference-storage-mongodb.md +262 -0
  55. package/dist/docs/references/reference-storage-postgresql.md +526 -0
  56. package/dist/docs/references/reference-storage-upstash.md +160 -0
  57. package/dist/docs/references/reference-vectors-libsql.md +305 -0
  58. package/dist/docs/references/reference-vectors-mongodb.md +295 -0
  59. package/dist/docs/references/reference-vectors-pg.md +408 -0
  60. package/dist/docs/references/reference-vectors-upstash.md +294 -0
  61. package/dist/index.cjs +16008 -291
  62. package/dist/index.cjs.map +1 -1
  63. package/dist/index.d.ts +252 -49
  64. package/dist/index.d.ts.map +1 -1
  65. package/dist/index.js +15970 -295
  66. package/dist/index.js.map +1 -1
  67. package/dist/observational-memory-3NJCJNCQ.cjs +64 -0
  68. package/dist/observational-memory-3NJCJNCQ.cjs.map +1 -0
  69. package/dist/observational-memory-SKDDNPFW.js +3 -0
  70. package/dist/observational-memory-SKDDNPFW.js.map +1 -0
  71. package/dist/processors/index.cjs +57 -158
  72. package/dist/processors/index.cjs.map +1 -1
  73. package/dist/processors/index.d.ts +1 -2
  74. package/dist/processors/index.d.ts.map +1 -1
  75. package/dist/processors/index.js +1 -156
  76. package/dist/processors/index.js.map +1 -1
  77. package/dist/processors/observational-memory/date-utils.d.ts +35 -0
  78. package/dist/processors/observational-memory/date-utils.d.ts.map +1 -0
  79. package/dist/processors/observational-memory/index.d.ts +18 -0
  80. package/dist/processors/observational-memory/index.d.ts.map +1 -0
  81. package/dist/processors/observational-memory/markers.d.ts +94 -0
  82. package/dist/processors/observational-memory/markers.d.ts.map +1 -0
  83. package/dist/processors/observational-memory/observational-memory.d.ts +842 -0
  84. package/dist/processors/observational-memory/observational-memory.d.ts.map +1 -0
  85. package/dist/processors/observational-memory/observer-agent.d.ts +140 -0
  86. package/dist/processors/observational-memory/observer-agent.d.ts.map +1 -0
  87. package/dist/processors/observational-memory/operation-registry.d.ts +14 -0
  88. package/dist/processors/observational-memory/operation-registry.d.ts.map +1 -0
  89. package/dist/processors/observational-memory/reflector-agent.d.ts +55 -0
  90. package/dist/processors/observational-memory/reflector-agent.d.ts.map +1 -0
  91. package/dist/processors/observational-memory/thresholds.d.ts +52 -0
  92. package/dist/processors/observational-memory/thresholds.d.ts.map +1 -0
  93. package/dist/processors/observational-memory/token-counter.d.ts +33 -0
  94. package/dist/processors/observational-memory/token-counter.d.ts.map +1 -0
  95. package/dist/processors/observational-memory/types.d.ts +539 -0
  96. package/dist/processors/observational-memory/types.d.ts.map +1 -0
  97. package/dist/token-6GSAFR2W-ABXTQD64.js +61 -0
  98. package/dist/token-6GSAFR2W-ABXTQD64.js.map +1 -0
  99. package/dist/token-6GSAFR2W-TW2P7HCS.cjs +63 -0
  100. package/dist/token-6GSAFR2W-TW2P7HCS.cjs.map +1 -0
  101. package/dist/token-APYSY3BW-2DN6RAUY.js +61 -0
  102. package/dist/token-APYSY3BW-2DN6RAUY.js.map +1 -0
  103. package/dist/token-APYSY3BW-ZQ7TMBY7.cjs +63 -0
  104. package/dist/token-APYSY3BW-ZQ7TMBY7.cjs.map +1 -0
  105. package/dist/token-util-NEHG7TUY-GYFEVMWP.cjs +10 -0
  106. package/dist/token-util-NEHG7TUY-GYFEVMWP.cjs.map +1 -0
  107. package/dist/token-util-NEHG7TUY-XQP3QSPX.js +8 -0
  108. package/dist/token-util-NEHG7TUY-XQP3QSPX.js.map +1 -0
  109. package/dist/token-util-RMHT2CPJ-6TGPE335.cjs +10 -0
  110. package/dist/token-util-RMHT2CPJ-6TGPE335.cjs.map +1 -0
  111. package/dist/token-util-RMHT2CPJ-RJEA3FAN.js +8 -0
  112. package/dist/token-util-RMHT2CPJ-RJEA3FAN.js.map +1 -0
  113. package/dist/tools/working-memory.d.ts +17 -24
  114. package/dist/tools/working-memory.d.ts.map +1 -1
  115. package/package.json +26 -25
  116. package/dist/processors/token-limiter.d.ts +0 -32
  117. package/dist/processors/token-limiter.d.ts.map +0 -1
  118. package/dist/processors/tool-call-filter.d.ts +0 -20
  119. package/dist/processors/tool-call-filter.d.ts.map +0 -1
@@ -0,0 +1,64 @@
1
+ 'use strict';
2
+
3
+ var chunkQ7VDGOMJ_cjs = require('./chunk-Q7VDGOMJ.cjs');
4
+
5
+
6
+
7
+ Object.defineProperty(exports, "OBSERVATIONAL_MEMORY_DEFAULTS", {
8
+ enumerable: true,
9
+ get: function () { return chunkQ7VDGOMJ_cjs.OBSERVATIONAL_MEMORY_DEFAULTS; }
10
+ });
11
+ Object.defineProperty(exports, "OBSERVATION_CONTEXT_INSTRUCTIONS", {
12
+ enumerable: true,
13
+ get: function () { return chunkQ7VDGOMJ_cjs.OBSERVATION_CONTEXT_INSTRUCTIONS; }
14
+ });
15
+ Object.defineProperty(exports, "OBSERVATION_CONTEXT_PROMPT", {
16
+ enumerable: true,
17
+ get: function () { return chunkQ7VDGOMJ_cjs.OBSERVATION_CONTEXT_PROMPT; }
18
+ });
19
+ Object.defineProperty(exports, "OBSERVATION_CONTINUATION_HINT", {
20
+ enumerable: true,
21
+ get: function () { return chunkQ7VDGOMJ_cjs.OBSERVATION_CONTINUATION_HINT; }
22
+ });
23
+ Object.defineProperty(exports, "OBSERVER_SYSTEM_PROMPT", {
24
+ enumerable: true,
25
+ get: function () { return chunkQ7VDGOMJ_cjs.OBSERVER_SYSTEM_PROMPT; }
26
+ });
27
+ Object.defineProperty(exports, "ObservationalMemory", {
28
+ enumerable: true,
29
+ get: function () { return chunkQ7VDGOMJ_cjs.ObservationalMemory; }
30
+ });
31
+ Object.defineProperty(exports, "TokenCounter", {
32
+ enumerable: true,
33
+ get: function () { return chunkQ7VDGOMJ_cjs.TokenCounter; }
34
+ });
35
+ Object.defineProperty(exports, "buildObserverPrompt", {
36
+ enumerable: true,
37
+ get: function () { return chunkQ7VDGOMJ_cjs.buildObserverPrompt; }
38
+ });
39
+ Object.defineProperty(exports, "buildObserverSystemPrompt", {
40
+ enumerable: true,
41
+ get: function () { return chunkQ7VDGOMJ_cjs.buildObserverSystemPrompt; }
42
+ });
43
+ Object.defineProperty(exports, "extractCurrentTask", {
44
+ enumerable: true,
45
+ get: function () { return chunkQ7VDGOMJ_cjs.extractCurrentTask; }
46
+ });
47
+ Object.defineProperty(exports, "formatMessagesForObserver", {
48
+ enumerable: true,
49
+ get: function () { return chunkQ7VDGOMJ_cjs.formatMessagesForObserver; }
50
+ });
51
+ Object.defineProperty(exports, "hasCurrentTaskSection", {
52
+ enumerable: true,
53
+ get: function () { return chunkQ7VDGOMJ_cjs.hasCurrentTaskSection; }
54
+ });
55
+ Object.defineProperty(exports, "optimizeObservationsForContext", {
56
+ enumerable: true,
57
+ get: function () { return chunkQ7VDGOMJ_cjs.optimizeObservationsForContext; }
58
+ });
59
+ Object.defineProperty(exports, "parseObserverOutput", {
60
+ enumerable: true,
61
+ get: function () { return chunkQ7VDGOMJ_cjs.parseObserverOutput; }
62
+ });
63
+ //# sourceMappingURL=observational-memory-3NJCJNCQ.cjs.map
64
+ //# sourceMappingURL=observational-memory-3NJCJNCQ.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"observational-memory-3NJCJNCQ.cjs"}
@@ -0,0 +1,3 @@
1
+ export { OBSERVATIONAL_MEMORY_DEFAULTS, OBSERVATION_CONTEXT_INSTRUCTIONS, OBSERVATION_CONTEXT_PROMPT, OBSERVATION_CONTINUATION_HINT, OBSERVER_SYSTEM_PROMPT, ObservationalMemory, TokenCounter, buildObserverPrompt, buildObserverSystemPrompt, extractCurrentTask, formatMessagesForObserver, hasCurrentTaskSection, optimizeObservationsForContext, parseObserverOutput } from './chunk-33ZIVK5L.js';
2
+ //# sourceMappingURL=observational-memory-SKDDNPFW.js.map
3
+ //# sourceMappingURL=observational-memory-SKDDNPFW.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"observational-memory-SKDDNPFW.js"}
@@ -1,165 +1,64 @@
1
1
  'use strict';
2
2
 
3
- var memory = require('@mastra/core/memory');
4
- var lite = require('js-tiktoken/lite');
5
- var o200k_base = require('js-tiktoken/ranks/o200k_base');
3
+ var chunkQ7VDGOMJ_cjs = require('../chunk-Q7VDGOMJ.cjs');
6
4
 
7
- function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
8
5
 
9
- var o200k_base__default = /*#__PURE__*/_interopDefault(o200k_base);
10
6
 
11
- // src/processors/token-limiter.ts
12
- var TokenLimiter = class extends memory.MemoryProcessor {
13
- encoder;
14
- maxTokens;
15
- // Token overheads per OpenAI's documentation
16
- // See: https://cookbook.openai.com/examples/how_to_count_tokens_with_tiktoken#6-counting-tokens-for-chat-completions-api-calls
17
- // Every message follows <|start|>{role/name}\n{content}<|end|>
18
- TOKENS_PER_MESSAGE = 3.8;
19
- // tokens added for each message (start & end tokens)
20
- TOKENS_PER_CONVERSATION = 24;
21
- // fixed overhead for the conversation
22
- /**
23
- * Create a token limiter for messages.
24
- * @param options Either a number (token limit) or a configuration object
25
- */
26
- constructor(options) {
27
- super({
28
- name: "TokenLimiter"
29
- });
30
- if (typeof options === "number") {
31
- this.maxTokens = options;
32
- this.encoder = new lite.Tiktoken(o200k_base__default.default);
33
- } else {
34
- this.maxTokens = options.limit;
35
- this.encoder = new lite.Tiktoken(options.encoding || o200k_base__default.default);
36
- }
37
- }
38
- process(messages, { systemMessage, memorySystemMessage, newMessages } = {}) {
39
- let totalTokens = 0;
40
- totalTokens += this.TOKENS_PER_CONVERSATION;
41
- if (systemMessage) {
42
- totalTokens += this.countTokens(systemMessage);
43
- totalTokens += this.TOKENS_PER_MESSAGE;
44
- }
45
- if (memorySystemMessage) {
46
- totalTokens += this.countTokens(memorySystemMessage);
47
- totalTokens += this.TOKENS_PER_MESSAGE;
48
- }
49
- const allMessages = [...messages, ...newMessages || []];
50
- const result = [];
51
- for (let i = allMessages.length - 1; i >= 0; i--) {
52
- const message = allMessages[i];
53
- if (!message) continue;
54
- const messageTokens = this.countTokens(message);
55
- if (totalTokens + messageTokens <= this.maxTokens) {
56
- if (i < messages.length) {
57
- result.unshift(message);
58
- }
59
- totalTokens += messageTokens;
60
- } else {
61
- this.logger.info(
62
- `filtering ${allMessages.length - result.length}/${allMessages.length} messages, token limit of ${this.maxTokens} exceeded`
63
- );
64
- break;
65
- }
66
- }
67
- return result;
68
- }
69
- countTokens(message) {
70
- if (typeof message === `string`) {
71
- return this.encoder.encode(message).length;
72
- }
73
- let tokenString = message.role;
74
- let overhead = 0;
75
- if (typeof message.content === "string" && message.content) {
76
- tokenString += message.content;
77
- } else if (Array.isArray(message.content)) {
78
- for (const part of message.content) {
79
- if (part.type === "text") {
80
- tokenString += part.text;
81
- } else if (part.type === "tool-call" || part.type === `tool-result`) {
82
- if (`args` in part && part.args && part.type === `tool-call`) {
83
- tokenString += part.toolName;
84
- if (typeof part.args === "string") {
85
- tokenString += part.args;
86
- } else {
87
- tokenString += JSON.stringify(part.args);
88
- overhead -= 12;
89
- }
90
- }
91
- if (`result` in part && part.result !== void 0 && part.type === `tool-result`) {
92
- if (typeof part.result === "string") {
93
- tokenString += part.result;
94
- } else {
95
- tokenString += JSON.stringify(part.result);
96
- overhead -= 12;
97
- }
98
- }
99
- } else {
100
- tokenString += JSON.stringify(part);
101
- }
102
- }
103
- }
104
- if (typeof message.content === `string` || // if the message included non-tool parts, add our message overhead
105
- message.content.some((p) => p.type !== `tool-call` && p.type !== `tool-result`)) {
106
- overhead += this.TOKENS_PER_MESSAGE;
107
- }
108
- return this.encoder.encode(tokenString).length + overhead;
109
- }
110
- };
111
- var ToolCallFilter = class extends memory.MemoryProcessor {
112
- exclude;
113
- /**
114
- * Create a filter for tool calls and results.
115
- * @param options Configuration options
116
- * @param options.exclude List of specific tool names to exclude. If not provided, all tool calls are excluded.
117
- */
118
- constructor(options = {}) {
119
- super({ name: "ToolCallFilter" });
120
- if (!options || !options.exclude) {
121
- this.exclude = "all";
122
- } else {
123
- this.exclude = Array.isArray(options.exclude) ? options.exclude : [];
124
- }
125
- }
126
- process(messages) {
127
- if (this.exclude === "all") {
128
- return messages.filter((message) => {
129
- if (Array.isArray(message.content)) {
130
- return !message.content.some((part) => part.type === "tool-call" || part.type === "tool-result");
131
- }
132
- return true;
133
- });
134
- }
135
- if (this.exclude.length > 0) {
136
- const excludedToolCallIds = /* @__PURE__ */ new Set();
137
- return messages.filter((message) => {
138
- if (!Array.isArray(message.content)) return true;
139
- if (message.role === "assistant") {
140
- let shouldExclude = false;
141
- for (const part of message.content) {
142
- if (part.type === "tool-call" && this.exclude.includes(part.toolName)) {
143
- excludedToolCallIds.add(part.toolCallId);
144
- shouldExclude = true;
145
- }
146
- }
147
- return !shouldExclude;
148
- }
149
- if (message.role === "tool") {
150
- const shouldExclude = message.content.some(
151
- (part) => part.type === "tool-result" && excludedToolCallIds.has(part.toolCallId)
152
- );
153
- return !shouldExclude;
154
- }
155
- return true;
156
- });
157
- }
158
- return messages;
159
- }
160
- };
161
-
162
- exports.TokenLimiter = TokenLimiter;
163
- exports.ToolCallFilter = ToolCallFilter;
7
+ Object.defineProperty(exports, "OBSERVATIONAL_MEMORY_DEFAULTS", {
8
+ enumerable: true,
9
+ get: function () { return chunkQ7VDGOMJ_cjs.OBSERVATIONAL_MEMORY_DEFAULTS; }
10
+ });
11
+ Object.defineProperty(exports, "OBSERVATION_CONTEXT_INSTRUCTIONS", {
12
+ enumerable: true,
13
+ get: function () { return chunkQ7VDGOMJ_cjs.OBSERVATION_CONTEXT_INSTRUCTIONS; }
14
+ });
15
+ Object.defineProperty(exports, "OBSERVATION_CONTEXT_PROMPT", {
16
+ enumerable: true,
17
+ get: function () { return chunkQ7VDGOMJ_cjs.OBSERVATION_CONTEXT_PROMPT; }
18
+ });
19
+ Object.defineProperty(exports, "OBSERVATION_CONTINUATION_HINT", {
20
+ enumerable: true,
21
+ get: function () { return chunkQ7VDGOMJ_cjs.OBSERVATION_CONTINUATION_HINT; }
22
+ });
23
+ Object.defineProperty(exports, "OBSERVER_SYSTEM_PROMPT", {
24
+ enumerable: true,
25
+ get: function () { return chunkQ7VDGOMJ_cjs.OBSERVER_SYSTEM_PROMPT; }
26
+ });
27
+ Object.defineProperty(exports, "ObservationalMemory", {
28
+ enumerable: true,
29
+ get: function () { return chunkQ7VDGOMJ_cjs.ObservationalMemory; }
30
+ });
31
+ Object.defineProperty(exports, "TokenCounter", {
32
+ enumerable: true,
33
+ get: function () { return chunkQ7VDGOMJ_cjs.TokenCounter; }
34
+ });
35
+ Object.defineProperty(exports, "buildObserverPrompt", {
36
+ enumerable: true,
37
+ get: function () { return chunkQ7VDGOMJ_cjs.buildObserverPrompt; }
38
+ });
39
+ Object.defineProperty(exports, "buildObserverSystemPrompt", {
40
+ enumerable: true,
41
+ get: function () { return chunkQ7VDGOMJ_cjs.buildObserverSystemPrompt; }
42
+ });
43
+ Object.defineProperty(exports, "extractCurrentTask", {
44
+ enumerable: true,
45
+ get: function () { return chunkQ7VDGOMJ_cjs.extractCurrentTask; }
46
+ });
47
+ Object.defineProperty(exports, "formatMessagesForObserver", {
48
+ enumerable: true,
49
+ get: function () { return chunkQ7VDGOMJ_cjs.formatMessagesForObserver; }
50
+ });
51
+ Object.defineProperty(exports, "hasCurrentTaskSection", {
52
+ enumerable: true,
53
+ get: function () { return chunkQ7VDGOMJ_cjs.hasCurrentTaskSection; }
54
+ });
55
+ Object.defineProperty(exports, "optimizeObservationsForContext", {
56
+ enumerable: true,
57
+ get: function () { return chunkQ7VDGOMJ_cjs.optimizeObservationsForContext; }
58
+ });
59
+ Object.defineProperty(exports, "parseObserverOutput", {
60
+ enumerable: true,
61
+ get: function () { return chunkQ7VDGOMJ_cjs.parseObserverOutput; }
62
+ });
164
63
  //# sourceMappingURL=index.cjs.map
165
64
  //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/processors/token-limiter.ts","../../src/processors/tool-call-filter.ts"],"names":["MemoryProcessor","Tiktoken","o200k_base"],"mappings":";;;;;;;;;;;AAsBO,IAAM,YAAA,GAAN,cAA2BA,sBAAA,CAAgB;AAAA,EACxC,OAAA;AAAA,EACA,SAAA;AAAA;AAAA;AAAA;AAAA,EAKD,kBAAA,GAAqB,GAAA;AAAA;AAAA,EACrB,uBAAA,GAA0B,EAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMjC,YAAY,OAAA,EAAuC;AACjD,IAAA,KAAA,CAAM;AAAA,MACJ,IAAA,EAAM;AAAA,KACP,CAAA;AAED,IAAA,IAAI,OAAO,YAAY,QAAA,EAAU;AAE/B,MAAA,IAAA,CAAK,SAAA,GAAY,OAAA;AACjB,MAAA,IAAA,CAAK,OAAA,GAAU,IAAIC,aAAA,CAASC,2BAAU,CAAA;AAAA,IACxC,CAAA,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,cAAA,aAAA,GAAgB,IAAA;AAAA,YAClB;AAAA,UACF;AAEA,UAAA,OAAO,CAAC,aAAA;AAAA,QACV;AAGA,QAAA,IAAI,OAAA,CAAQ,SAAS,MAAA,EAAQ;AAC3B,UAAA,MAAM,aAAA,GAAgB,QAAQ,OAAA,CAAQ,IAAA;AAAA,YACpC,UAAQ,IAAA,CAAK,IAAA,KAAS,iBAAiB,mBAAA,CAAoB,GAAA,CAAI,KAAK,UAAU;AAAA,WAChF;AAEA,UAAA,OAAO,CAAC,aAAA;AAAA,QACV;AAEA,QAAA,OAAO,IAAA;AAAA,MACT,CAAC,CAAA;AAAA,IACH;AAGA,IAAA,OAAO,QAAA;AAAA,EACT;AACF","file":"index.cjs","sourcesContent":["import type { CoreMessage } from '@mastra/core/llm';\nimport { MemoryProcessor } from '@mastra/core/memory';\nimport type { MemoryProcessorOpts } from '@mastra/core/memory';\n\nimport { Tiktoken } from 'js-tiktoken/lite';\nimport type { TiktokenBPE } from 'js-tiktoken/lite';\nimport o200k_base from 'js-tiktoken/ranks/o200k_base';\n\n/**\n * Configuration options for TokenLimiter\n */\ninterface TokenLimiterOptions {\n /** Maximum number of tokens to allow */\n limit: number;\n /** Optional encoding to use (defaults to o200k_base which is used by gpt-4o) */\n encoding?: TiktokenBPE;\n}\n\n/**\n * Limits the total number of tokens in the messages.\n * Uses js-tiktoken with o200k_base encoding by default for accurate token counting with modern models.\n */\nexport class TokenLimiter extends MemoryProcessor {\n private encoder: Tiktoken;\n private maxTokens: number;\n\n // Token overheads per OpenAI's documentation\n // See: https://cookbook.openai.com/examples/how_to_count_tokens_with_tiktoken#6-counting-tokens-for-chat-completions-api-calls\n // Every message follows <|start|>{role/name}\\n{content}<|end|>\n public TOKENS_PER_MESSAGE = 3.8; // tokens added for each message (start & end tokens)\n public TOKENS_PER_CONVERSATION = 24; // fixed overhead for the conversation\n\n /**\n * Create a token limiter for messages.\n * @param options Either a number (token limit) or a configuration object\n */\n constructor(options: number | TokenLimiterOptions) {\n super({\n name: 'TokenLimiter',\n });\n\n if (typeof options === 'number') {\n // Simple number format - just the token limit with default encoding\n this.maxTokens = options;\n this.encoder = new Tiktoken(o200k_base);\n } else {\n // Object format with limit and optional encoding\n this.maxTokens = options.limit;\n this.encoder = new Tiktoken(options.encoding || o200k_base);\n }\n }\n\n process(\n messages: CoreMessage[],\n { systemMessage, memorySystemMessage, newMessages }: MemoryProcessorOpts = {},\n ): CoreMessage[] {\n // Messages are already chronologically ordered - take most recent ones up to the token limit\n let totalTokens = 0;\n\n // Start with the conversation overhead\n totalTokens += this.TOKENS_PER_CONVERSATION;\n\n if (systemMessage) {\n totalTokens += this.countTokens(systemMessage);\n totalTokens += this.TOKENS_PER_MESSAGE; // Add message overhead for system message\n }\n\n if (memorySystemMessage) {\n totalTokens += this.countTokens(memorySystemMessage);\n totalTokens += this.TOKENS_PER_MESSAGE; // Add message overhead for memory system message\n }\n\n const allMessages = [...messages, ...(newMessages || [])];\n\n const result: CoreMessage[] = [];\n\n // Process messages in reverse (newest first) so that we stop estimating tokens on old messages. Once we get to our limit of tokens there's no reason to keep processing older messages\n for (let i = allMessages.length - 1; i >= 0; i--) {\n const message = allMessages[i];\n\n // Skip undefined messages (shouldn't happen, but TypeScript is concerned)\n if (!message) continue;\n\n const messageTokens = this.countTokens(message);\n\n if (totalTokens + messageTokens <= this.maxTokens) {\n // Insert at the beginning to maintain chronological order, but only if it's not a new message\n if (i < messages.length) {\n // less than messages.length because we're iterating in reverse. If the index is greater than messages.length it's a new message\n result.unshift(message);\n }\n totalTokens += messageTokens;\n } else {\n this.logger.info(\n `filtering ${allMessages.length - result.length}/${allMessages.length} messages, token limit of ${this.maxTokens} exceeded`,\n );\n // If we can't fit the message, we stop\n break;\n }\n }\n\n return result;\n }\n\n public countTokens(message: string | CoreMessage): number {\n if (typeof message === `string`) {\n return this.encoder.encode(message).length;\n }\n\n let tokenString = message.role;\n let overhead = 0;\n\n if (typeof message.content === 'string' && message.content) {\n tokenString += message.content;\n } else if (Array.isArray(message.content)) {\n // Calculate tokens for each content part\n for (const part of message.content) {\n if (part.type === 'text') {\n tokenString += part.text;\n } else if (part.type === 'tool-call' || part.type === `tool-result`) {\n if (`args` in part && part.args && part.type === `tool-call`) {\n tokenString += part.toolName as any;\n if (typeof part.args === 'string') {\n tokenString += part.args;\n } else {\n tokenString += JSON.stringify(part.args);\n // minus some tokens for JSON\n overhead -= 12;\n }\n }\n // Token cost for result if present\n if (`result` in part && part.result !== undefined && part.type === `tool-result`) {\n if (typeof part.result === 'string') {\n tokenString += part.result;\n } else {\n tokenString += JSON.stringify(part.result);\n // minus some tokens for JSON\n overhead -= 12;\n }\n }\n } else {\n tokenString += JSON.stringify(part);\n }\n }\n }\n\n if (\n typeof message.content === `string` ||\n // if the message included non-tool parts, add our message overhead\n message.content.some(p => p.type !== `tool-call` && p.type !== `tool-result`)\n ) {\n // Ensure we account for message formatting tokens\n // See: https://cookbook.openai.com/examples/how_to_count_tokens_with_tiktoken#6-counting-tokens-for-chat-completions-api-calls\n overhead += this.TOKENS_PER_MESSAGE;\n }\n\n return this.encoder.encode(tokenString).length + overhead;\n }\n}\n","import type { CoreMessage } from '@mastra/core/llm';\nimport { MemoryProcessor } from '@mastra/core/memory';\n\n/**\n * Filters out tool calls and results from messages.\n * By default (with no arguments), excludes all tool calls and their results.\n * Can be configured to exclude only specific tools by name.\n */\nexport class ToolCallFilter extends MemoryProcessor {\n private exclude: string[] | 'all';\n\n /**\n * Create a filter for tool calls and results.\n * @param options Configuration options\n * @param options.exclude List of specific tool names to exclude. If not provided, all tool calls are excluded.\n */\n constructor(options: { exclude?: string[] } = {}) {\n super({ name: 'ToolCallFilter' });\n // If no options or exclude is provided, exclude all tools\n if (!options || !options.exclude) {\n this.exclude = 'all'; // Exclude all tools\n } else {\n // Exclude specific tools\n this.exclude = Array.isArray(options.exclude) ? options.exclude : [];\n }\n }\n\n process(messages: CoreMessage[]): CoreMessage[] {\n // Case 1: Exclude all tool calls and tool results\n if (this.exclude === 'all') {\n return messages.filter(message => {\n if (Array.isArray(message.content)) {\n return !message.content.some(part => part.type === 'tool-call' || part.type === 'tool-result');\n }\n return true;\n });\n }\n\n // Case 2: Exclude specific tools by name\n if (this.exclude.length > 0) {\n // Single pass approach - track excluded tool call IDs while filtering\n const excludedToolCallIds = new Set<string>();\n\n return messages.filter(message => {\n if (!Array.isArray(message.content)) return true;\n\n // For assistant messages, check for excluded tool calls and track their IDs\n if (message.role === 'assistant') {\n let shouldExclude = false;\n\n for (const part of message.content) {\n if (part.type === 'tool-call' && this.exclude.includes(part.toolName)) {\n excludedToolCallIds.add(part.toolCallId);\n shouldExclude = true;\n }\n }\n\n return !shouldExclude;\n }\n\n // For tool messages, filter out results for excluded tool calls\n if (message.role === 'tool') {\n const shouldExclude = message.content.some(\n part => part.type === 'tool-result' && excludedToolCallIds.has(part.toolCallId),\n );\n\n return !shouldExclude;\n }\n\n return true;\n });\n }\n\n // Case 3: Empty exclude array, return original messages\n return messages;\n }\n}\n"]}
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"index.cjs"}
@@ -1,3 +1,2 @@
1
- export * from './token-limiter.js';
2
- export * from './tool-call-filter.js';
1
+ export * from './observational-memory/index.js';
3
2
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/processors/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,cAAc,oBAAoB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/processors/index.ts"],"names":[],"mappings":"AAAA,cAAc,wBAAwB,CAAC"}
@@ -1,158 +1,3 @@
1
- import { MemoryProcessor } from '@mastra/core/memory';
2
- import { Tiktoken } from 'js-tiktoken/lite';
3
- import o200k_base from 'js-tiktoken/ranks/o200k_base';
4
-
5
- // src/processors/token-limiter.ts
6
- var TokenLimiter = class extends MemoryProcessor {
7
- encoder;
8
- maxTokens;
9
- // Token overheads per OpenAI's documentation
10
- // See: https://cookbook.openai.com/examples/how_to_count_tokens_with_tiktoken#6-counting-tokens-for-chat-completions-api-calls
11
- // Every message follows <|start|>{role/name}\n{content}<|end|>
12
- TOKENS_PER_MESSAGE = 3.8;
13
- // tokens added for each message (start & end tokens)
14
- TOKENS_PER_CONVERSATION = 24;
15
- // fixed overhead for the conversation
16
- /**
17
- * Create a token limiter for messages.
18
- * @param options Either a number (token limit) or a configuration object
19
- */
20
- constructor(options) {
21
- super({
22
- name: "TokenLimiter"
23
- });
24
- if (typeof options === "number") {
25
- this.maxTokens = options;
26
- this.encoder = new Tiktoken(o200k_base);
27
- } else {
28
- this.maxTokens = options.limit;
29
- this.encoder = new Tiktoken(options.encoding || o200k_base);
30
- }
31
- }
32
- process(messages, { systemMessage, memorySystemMessage, newMessages } = {}) {
33
- let totalTokens = 0;
34
- totalTokens += this.TOKENS_PER_CONVERSATION;
35
- if (systemMessage) {
36
- totalTokens += this.countTokens(systemMessage);
37
- totalTokens += this.TOKENS_PER_MESSAGE;
38
- }
39
- if (memorySystemMessage) {
40
- totalTokens += this.countTokens(memorySystemMessage);
41
- totalTokens += this.TOKENS_PER_MESSAGE;
42
- }
43
- const allMessages = [...messages, ...newMessages || []];
44
- const result = [];
45
- for (let i = allMessages.length - 1; i >= 0; i--) {
46
- const message = allMessages[i];
47
- if (!message) continue;
48
- const messageTokens = this.countTokens(message);
49
- if (totalTokens + messageTokens <= this.maxTokens) {
50
- if (i < messages.length) {
51
- result.unshift(message);
52
- }
53
- totalTokens += messageTokens;
54
- } else {
55
- this.logger.info(
56
- `filtering ${allMessages.length - result.length}/${allMessages.length} messages, token limit of ${this.maxTokens} exceeded`
57
- );
58
- break;
59
- }
60
- }
61
- return result;
62
- }
63
- countTokens(message) {
64
- if (typeof message === `string`) {
65
- return this.encoder.encode(message).length;
66
- }
67
- let tokenString = message.role;
68
- let overhead = 0;
69
- if (typeof message.content === "string" && message.content) {
70
- tokenString += message.content;
71
- } else if (Array.isArray(message.content)) {
72
- for (const part of message.content) {
73
- if (part.type === "text") {
74
- tokenString += part.text;
75
- } else if (part.type === "tool-call" || part.type === `tool-result`) {
76
- if (`args` in part && part.args && part.type === `tool-call`) {
77
- tokenString += part.toolName;
78
- if (typeof part.args === "string") {
79
- tokenString += part.args;
80
- } else {
81
- tokenString += JSON.stringify(part.args);
82
- overhead -= 12;
83
- }
84
- }
85
- if (`result` in part && part.result !== void 0 && part.type === `tool-result`) {
86
- if (typeof part.result === "string") {
87
- tokenString += part.result;
88
- } else {
89
- tokenString += JSON.stringify(part.result);
90
- overhead -= 12;
91
- }
92
- }
93
- } else {
94
- tokenString += JSON.stringify(part);
95
- }
96
- }
97
- }
98
- if (typeof message.content === `string` || // if the message included non-tool parts, add our message overhead
99
- message.content.some((p) => p.type !== `tool-call` && p.type !== `tool-result`)) {
100
- overhead += this.TOKENS_PER_MESSAGE;
101
- }
102
- return this.encoder.encode(tokenString).length + overhead;
103
- }
104
- };
105
- var ToolCallFilter = class extends MemoryProcessor {
106
- exclude;
107
- /**
108
- * Create a filter for tool calls and results.
109
- * @param options Configuration options
110
- * @param options.exclude List of specific tool names to exclude. If not provided, all tool calls are excluded.
111
- */
112
- constructor(options = {}) {
113
- super({ name: "ToolCallFilter" });
114
- if (!options || !options.exclude) {
115
- this.exclude = "all";
116
- } else {
117
- this.exclude = Array.isArray(options.exclude) ? options.exclude : [];
118
- }
119
- }
120
- process(messages) {
121
- if (this.exclude === "all") {
122
- return messages.filter((message) => {
123
- if (Array.isArray(message.content)) {
124
- return !message.content.some((part) => part.type === "tool-call" || part.type === "tool-result");
125
- }
126
- return true;
127
- });
128
- }
129
- if (this.exclude.length > 0) {
130
- const excludedToolCallIds = /* @__PURE__ */ new Set();
131
- return messages.filter((message) => {
132
- if (!Array.isArray(message.content)) return true;
133
- if (message.role === "assistant") {
134
- let shouldExclude = false;
135
- for (const part of message.content) {
136
- if (part.type === "tool-call" && this.exclude.includes(part.toolName)) {
137
- excludedToolCallIds.add(part.toolCallId);
138
- shouldExclude = true;
139
- }
140
- }
141
- return !shouldExclude;
142
- }
143
- if (message.role === "tool") {
144
- const shouldExclude = message.content.some(
145
- (part) => part.type === "tool-result" && excludedToolCallIds.has(part.toolCallId)
146
- );
147
- return !shouldExclude;
148
- }
149
- return true;
150
- });
151
- }
152
- return messages;
153
- }
154
- };
155
-
156
- export { TokenLimiter, ToolCallFilter };
1
+ export { OBSERVATIONAL_MEMORY_DEFAULTS, OBSERVATION_CONTEXT_INSTRUCTIONS, OBSERVATION_CONTEXT_PROMPT, OBSERVATION_CONTINUATION_HINT, OBSERVER_SYSTEM_PROMPT, ObservationalMemory, TokenCounter, buildObserverPrompt, buildObserverSystemPrompt, extractCurrentTask, formatMessagesForObserver, hasCurrentTaskSection, optimizeObservationsForContext, parseObserverOutput } from '../chunk-33ZIVK5L.js';
157
2
  //# sourceMappingURL=index.js.map
158
3
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/processors/token-limiter.ts","../../src/processors/tool-call-filter.ts"],"names":["MemoryProcessor"],"mappings":";;;;;AAsBO,IAAM,YAAA,GAAN,cAA2B,eAAA,CAAgB;AAAA,EACxC,OAAA;AAAA,EACA,SAAA;AAAA;AAAA;AAAA;AAAA,EAKD,kBAAA,GAAqB,GAAA;AAAA;AAAA,EACrB,uBAAA,GAA0B,EAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMjC,YAAY,OAAA,EAAuC;AACjD,IAAA,KAAA,CAAM;AAAA,MACJ,IAAA,EAAM;AAAA,KACP,CAAA;AAED,IAAA,IAAI,OAAO,YAAY,QAAA,EAAU;AAE/B,MAAA,IAAA,CAAK,SAAA,GAAY,OAAA;AACjB,MAAA,IAAA,CAAK,OAAA,GAAU,IAAI,QAAA,CAAS,UAAU,CAAA;AAAA,IACxC,CAAA,MAAO;AAEL,MAAA,IAAA,CAAK,YAAY,OAAA,CAAQ,KAAA;AACzB,MAAA,IAAA,CAAK,OAAA,GAAU,I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QAAA,IAAI,OAAA,CAAQ,SAAS,MAAA,EAAQ;AAC3B,UAAA,MAAM,aAAA,GAAgB,QAAQ,OAAA,CAAQ,IAAA;AAAA,YACpC,UAAQ,IAAA,CAAK,IAAA,KAAS,iBAAiB,mBAAA,CAAoB,GAAA,CAAI,KAAK,UAAU;AAAA,WAChF;AAEA,UAAA,OAAO,CAAC,aAAA;AAAA,QACV;AAEA,QAAA,OAAO,IAAA;AAAA,MACT,CAAC,CAAA;AAAA,IACH;AAGA,IAAA,OAAO,QAAA;AAAA,EACT;AACF","file":"index.js","sourcesContent":["import type { CoreMessage } from '@mastra/core/llm';\nimport { MemoryProcessor } from '@mastra/core/memory';\nimport type { MemoryProcessorOpts } from '@mastra/core/memory';\n\nimport { Tiktoken } from 'js-tiktoken/lite';\nimport type { TiktokenBPE } from 'js-tiktoken/lite';\nimport o200k_base from 'js-tiktoken/ranks/o200k_base';\n\n/**\n * Configuration options for TokenLimiter\n */\ninterface TokenLimiterOptions {\n /** Maximum number of tokens to allow */\n limit: number;\n /** Optional encoding to use (defaults to o200k_base which is used by gpt-4o) */\n encoding?: TiktokenBPE;\n}\n\n/**\n * Limits the total number of tokens in the messages.\n * Uses js-tiktoken with o200k_base encoding by default for accurate token counting with modern models.\n */\nexport class TokenLimiter extends MemoryProcessor {\n private encoder: Tiktoken;\n private maxTokens: number;\n\n // Token overheads per OpenAI's documentation\n // See: https://cookbook.openai.com/examples/how_to_count_tokens_with_tiktoken#6-counting-tokens-for-chat-completions-api-calls\n // Every message follows <|start|>{role/name}\\n{content}<|end|>\n public TOKENS_PER_MESSAGE = 3.8; // tokens added for each message (start & end tokens)\n public TOKENS_PER_CONVERSATION = 24; // fixed overhead for the conversation\n\n /**\n * Create a token limiter for messages.\n * @param options Either a number (token limit) or a configuration object\n */\n constructor(options: number | TokenLimiterOptions) {\n super({\n name: 'TokenLimiter',\n });\n\n if (typeof options === 'number') {\n // Simple number format - just the token limit with default encoding\n this.maxTokens = options;\n this.encoder = new Tiktoken(o200k_base);\n } else {\n // Object format with limit and optional encoding\n this.maxTokens = options.limit;\n this.encoder = new Tiktoken(options.encoding || o200k_base);\n }\n }\n\n process(\n messages: CoreMessage[],\n { systemMessage, memorySystemMessage, newMessages }: MemoryProcessorOpts = {},\n ): CoreMessage[] {\n // Messages are already chronologically ordered - take most recent ones up to the token limit\n let totalTokens = 0;\n\n // Start with the conversation overhead\n totalTokens += this.TOKENS_PER_CONVERSATION;\n\n if (systemMessage) {\n totalTokens += this.countTokens(systemMessage);\n totalTokens += this.TOKENS_PER_MESSAGE; // Add message overhead for system message\n }\n\n if (memorySystemMessage) {\n totalTokens += this.countTokens(memorySystemMessage);\n totalTokens += this.TOKENS_PER_MESSAGE; // Add message overhead for memory system message\n }\n\n const allMessages = [...messages, ...(newMessages || [])];\n\n const result: CoreMessage[] = [];\n\n // Process messages in reverse (newest first) so that we stop estimating tokens on old messages. Once we get to our limit of tokens there's no reason to keep processing older messages\n for (let i = allMessages.length - 1; i >= 0; i--) {\n const message = allMessages[i];\n\n // Skip undefined messages (shouldn't happen, but TypeScript is concerned)\n if (!message) continue;\n\n const messageTokens = this.countTokens(message);\n\n if (totalTokens + messageTokens <= this.maxTokens) {\n // Insert at the beginning to maintain chronological order, but only if it's not a new message\n if (i < messages.length) {\n // less than messages.length because we're iterating in reverse. If the index is greater than messages.length it's a new message\n result.unshift(message);\n }\n totalTokens += messageTokens;\n } else {\n this.logger.info(\n `filtering ${allMessages.length - result.length}/${allMessages.length} messages, token limit of ${this.maxTokens} exceeded`,\n );\n // If we can't fit the message, we stop\n break;\n }\n }\n\n return result;\n }\n\n public countTokens(message: string | CoreMessage): number {\n if (typeof message === `string`) {\n return this.encoder.encode(message).length;\n }\n\n let tokenString = message.role;\n let overhead = 0;\n\n if (typeof message.content === 'string' && message.content) {\n tokenString += message.content;\n } else if (Array.isArray(message.content)) {\n // Calculate tokens for each content part\n for (const part of message.content) {\n if (part.type === 'text') {\n tokenString += part.text;\n } else if (part.type === 'tool-call' || part.type === `tool-result`) {\n if (`args` in part && part.args && part.type === `tool-call`) {\n tokenString += part.toolName as any;\n if (typeof part.args === 'string') {\n tokenString += part.args;\n } else {\n tokenString += JSON.stringify(part.args);\n // minus some tokens for JSON\n overhead -= 12;\n }\n }\n // Token cost for result if present\n if (`result` in part && part.result !== undefined && part.type === `tool-result`) {\n if (typeof part.result === 'string') {\n tokenString += part.result;\n } else {\n tokenString += JSON.stringify(part.result);\n // minus some tokens for JSON\n overhead -= 12;\n }\n }\n } else {\n tokenString += JSON.stringify(part);\n }\n }\n }\n\n if (\n typeof message.content === `string` ||\n // if the message included non-tool parts, add our message overhead\n message.content.some(p => p.type !== `tool-call` && p.type !== `tool-result`)\n ) {\n // Ensure we account for message formatting tokens\n // See: https://cookbook.openai.com/examples/how_to_count_tokens_with_tiktoken#6-counting-tokens-for-chat-completions-api-calls\n overhead += this.TOKENS_PER_MESSAGE;\n }\n\n return this.encoder.encode(tokenString).length + overhead;\n }\n}\n","import type { CoreMessage } from '@mastra/core/llm';\nimport { MemoryProcessor } from '@mastra/core/memory';\n\n/**\n * Filters out tool calls and results from messages.\n * By default (with no arguments), excludes all tool calls and their results.\n * Can be configured to exclude only specific tools by name.\n */\nexport class ToolCallFilter extends MemoryProcessor {\n private exclude: string[] | 'all';\n\n /**\n * Create a filter for tool calls and results.\n * @param options Configuration options\n * @param options.exclude List of specific tool names to exclude. If not provided, all tool calls are excluded.\n */\n constructor(options: { exclude?: string[] } = {}) {\n super({ name: 'ToolCallFilter' });\n // If no options or exclude is provided, exclude all tools\n if (!options || !options.exclude) {\n this.exclude = 'all'; // Exclude all tools\n } else {\n // Exclude specific tools\n this.exclude = Array.isArray(options.exclude) ? options.exclude : [];\n }\n }\n\n process(messages: CoreMessage[]): CoreMessage[] {\n // Case 1: Exclude all tool calls and tool results\n if (this.exclude === 'all') {\n return messages.filter(message => {\n if (Array.isArray(message.content)) {\n return !message.content.some(part => part.type === 'tool-call' || part.type === 'tool-result');\n }\n return true;\n });\n }\n\n // Case 2: Exclude specific tools by name\n if (this.exclude.length > 0) {\n // Single pass approach - track excluded tool call IDs while filtering\n const excludedToolCallIds = new Set<string>();\n\n return messages.filter(message => {\n if (!Array.isArray(message.content)) return true;\n\n // For assistant messages, check for excluded tool calls and track their IDs\n if (message.role === 'assistant') {\n let shouldExclude = false;\n\n for (const part of message.content) {\n if (part.type === 'tool-call' && this.exclude.includes(part.toolName)) {\n excludedToolCallIds.add(part.toolCallId);\n shouldExclude = true;\n }\n }\n\n return !shouldExclude;\n }\n\n // For tool messages, filter out results for excluded tool calls\n if (message.role === 'tool') {\n const shouldExclude = message.content.some(\n part => part.type === 'tool-result' && excludedToolCallIds.has(part.toolCallId),\n );\n\n return !shouldExclude;\n }\n\n return true;\n });\n }\n\n // Case 3: Empty exclude array, return original messages\n return messages;\n }\n}\n"]}
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"index.js"}
@@ -0,0 +1,35 @@
1
+ /**
2
+ * Date/time utility functions for Observational Memory.
3
+ * Pure functions for formatting relative timestamps and annotating observations.
4
+ */
5
+ /**
6
+ * Format a relative time string like "5 days ago", "2 weeks ago", "today", etc.
7
+ */
8
+ export declare function formatRelativeTime(date: Date, currentDate: Date): string;
9
+ /**
10
+ * Format the gap between two dates as a human-readable string.
11
+ * Returns null for consecutive days (no gap marker needed).
12
+ */
13
+ export declare function formatGapBetweenDates(prevDate: Date, currDate: Date): string | null;
14
+ /**
15
+ * Parses a date string like "May 30, 2023", "May 27-28, 2023", "late April 2023", etc.
16
+ * Returns the parsed Date or null if unparseable.
17
+ */
18
+ export declare function parseDateFromContent(dateContent: string): Date | null;
19
+ /**
20
+ * Detects if an observation line indicates future intent (will do, plans to, looking forward to, etc.)
21
+ */
22
+ export declare function isFutureIntentObservation(line: string): boolean;
23
+ /**
24
+ * Expand inline estimated dates with relative time.
25
+ * Matches patterns like "(estimated May 27-28, 2023)" or "(meaning May 30, 2023)"
26
+ * and expands them to "(meaning May 30, 2023 - which was 3 weeks ago)"
27
+ */
28
+ export declare function expandInlineEstimatedDates(observations: string, currentDate: Date): string;
29
+ /**
30
+ * Add relative time annotations to observations.
31
+ * Transforms "Date: May 15, 2023" headers to "Date: May 15, 2023 (5 days ago)"
32
+ * and expands inline estimated dates with relative time context.
33
+ */
34
+ export declare function addRelativeTimeToObservations(observations: string, currentDate: Date): string;
35
+ //# sourceMappingURL=date-utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"date-utils.d.ts","sourceRoot":"","sources":["../../../src/processors/observational-memory/date-utils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI,GAAG,MAAM,CAwBxE;AAED;;;GAGG;AACH,wBAAgB,qBAAqB,CAAC,QAAQ,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,GAAG,MAAM,GAAG,IAAI,CAmBnF;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI,CAuDrE;AAED;;GAEG;AACH,wBAAgB,yBAAyB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAa/D;AAED;;;;GAIG;AACH,wBAAgB,0BAA0B,CAAC,YAAY,EAAE,MAAM,EAAE,WAAW,EAAE,IAAI,GAAG,MAAM,CAkC1F;AAED;;;;GAIG;AACH,wBAAgB,6BAA6B,CAAC,YAAY,EAAE,MAAM,EAAE,WAAW,EAAE,IAAI,GAAG,MAAM,CA2D7F"}
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Observational Memory (OM)
3
+ *
4
+ * A memory system that keeps agents performant across long conversations by:
5
+ * 1. Automatically compressing turn-based message history into structured observations
6
+ * 2. Reflecting on observations when they grow too large
7
+ *
8
+ * Three-agent architecture:
9
+ * - Actor: The main agent, sees observations + recent unobserved messages
10
+ * - Observer: Extracts observations when history exceeds threshold
11
+ * - Reflector: Condenses observations when they exceed threshold
12
+ */
13
+ export { ObservationalMemory, OBSERVATIONAL_MEMORY_DEFAULTS, OBSERVATION_CONTINUATION_HINT, OBSERVATION_CONTEXT_PROMPT, OBSERVATION_CONTEXT_INSTRUCTIONS, type ObservationalMemoryConfig, type ObservationDebugEvent, type ObserveHooks, } from './observational-memory.js';
14
+ export type { ObservationConfig, ReflectionConfig, ObserverResult, ReflectorResult, DataOmBufferingStartPart, DataOmBufferingEndPart, DataOmBufferingFailedPart, DataOmBufferingPart, DataOmActivationPart, DataOmPart, } from './types.js';
15
+ export { OBSERVER_SYSTEM_PROMPT, buildObserverSystemPrompt, buildObserverPrompt, parseObserverOutput, optimizeObservationsForContext, formatMessagesForObserver, hasCurrentTaskSection, extractCurrentTask, type ObserverResult as ObserverAgentResult, } from './observer-agent.js';
16
+ export type { ObservationalMemoryRecord, ObservationalMemoryScope, ObservationalMemoryOriginType, CreateObservationalMemoryInput, UpdateActiveObservationsInput, UpdateBufferedObservationsInput, CreateReflectionGenerationInput, } from '@mastra/core/storage';
17
+ export { TokenCounter } from './token-counter.js';
18
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/processors/observational-memory/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAGH,OAAO,EACL,mBAAmB,EACnB,6BAA6B,EAC7B,6BAA6B,EAC7B,0BAA0B,EAC1B,gCAAgC,EAChC,KAAK,yBAAyB,EAC9B,KAAK,qBAAqB,EAC1B,KAAK,YAAY,GAClB,MAAM,wBAAwB,CAAC;AAGhC,YAAY,EACV,iBAAiB,EACjB,gBAAgB,EAChB,cAAc,EACd,eAAe,EAEf,wBAAwB,EACxB,sBAAsB,EACtB,yBAAyB,EACzB,mBAAmB,EAEnB,oBAAoB,EACpB,UAAU,GACX,MAAM,SAAS,CAAC;AAGjB,OAAO,EACL,sBAAsB,EACtB,yBAAyB,EACzB,mBAAmB,EACnB,mBAAmB,EACnB,8BAA8B,EAC9B,yBAAyB,EACzB,qBAAqB,EACrB,kBAAkB,EAClB,KAAK,cAAc,IAAI,mBAAmB,GAC3C,MAAM,kBAAkB,CAAC;AAG1B,YAAY,EACV,yBAAyB,EACzB,wBAAwB,EACxB,6BAA6B,EAC7B,8BAA8B,EAC9B,6BAA6B,EAC7B,+BAA+B,EAC/B,+BAA+B,GAChC,MAAM,sBAAsB,CAAC;AAG9B,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC"}