@mastra/memory 0.0.2-alpha.4 → 0.0.2-alpha.41

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 CHANGED
@@ -1,5 +1,291 @@
1
1
  # @mastra/memory
2
2
 
3
+ ## 0.0.2-alpha.41
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [dc90663]
8
+ - @mastra/core@0.1.27-alpha.61
9
+
10
+ ## 0.0.2-alpha.40
11
+
12
+ ### Patch Changes
13
+
14
+ - Updated dependencies [3967e69]
15
+ - @mastra/core@0.1.27-alpha.60
16
+
17
+ ## 0.0.2-alpha.39
18
+
19
+ ### Patch Changes
20
+
21
+ - Updated dependencies [b524c22]
22
+ - @mastra/core@0.1.27-alpha.59
23
+
24
+ ## 0.0.2-alpha.38
25
+
26
+ ### Patch Changes
27
+
28
+ - Updated dependencies [1874f40]
29
+ - Updated dependencies [4b1ce2c]
30
+ - @mastra/core@0.1.27-alpha.58
31
+
32
+ ## 0.0.2-alpha.37
33
+
34
+ ### Patch Changes
35
+
36
+ - Updated dependencies [fd494a3]
37
+ - @mastra/core@0.1.27-alpha.57
38
+
39
+ ## 0.0.2-alpha.36
40
+
41
+ ### Patch Changes
42
+
43
+ - Updated dependencies [9f3ab05]
44
+ - @mastra/core@0.1.27-alpha.56
45
+
46
+ ## 0.0.2-alpha.35
47
+
48
+ ### Patch Changes
49
+
50
+ - 837a288: MAJOR Revamp of tools, workflows, syncs.
51
+ - 0b74006: Workflow updates
52
+ - Updated dependencies [592e3cf]
53
+ - Updated dependencies [837a288]
54
+ - Updated dependencies [0b74006]
55
+ - @mastra/core@0.1.27-alpha.55
56
+
57
+ ## 0.0.2-alpha.34
58
+
59
+ ### Patch Changes
60
+
61
+ - Updated dependencies [d2cd535]
62
+ - @mastra/core@0.1.27-alpha.54
63
+
64
+ ## 0.0.2-alpha.33
65
+
66
+ ### Patch Changes
67
+
68
+ - Updated dependencies [8e7814f]
69
+ - @mastra/core@0.1.27-alpha.53
70
+
71
+ ## 0.0.2-alpha.32
72
+
73
+ ### Patch Changes
74
+
75
+ - Updated dependencies [eedb829]
76
+ - @mastra/core@0.1.27-alpha.52
77
+
78
+ ## 0.0.2-alpha.31
79
+
80
+ ### Patch Changes
81
+
82
+ - Updated dependencies [a7b016d]
83
+ - Updated dependencies [da2e8d3]
84
+ - Updated dependencies [538a136]
85
+ - @mastra/core@0.1.27-alpha.51
86
+
87
+ ## 0.0.2-alpha.30
88
+
89
+ ### Patch Changes
90
+
91
+ - Updated dependencies [401a4d9]
92
+ - @mastra/core@0.1.27-alpha.50
93
+
94
+ ## 0.0.2-alpha.29
95
+
96
+ ### Patch Changes
97
+
98
+ - Updated dependencies [79acad0]
99
+ - Updated dependencies [f5dfa20]
100
+ - @mastra/core@0.1.27-alpha.49
101
+
102
+ ## 0.0.2-alpha.28
103
+
104
+ ### Patch Changes
105
+
106
+ - Updated dependencies [b726bf5]
107
+ - @mastra/core@0.1.27-alpha.48
108
+
109
+ ## 0.0.2-alpha.27
110
+
111
+ ### Patch Changes
112
+
113
+ - Updated dependencies [f6ba259]
114
+ - @mastra/core@0.1.27-alpha.47
115
+
116
+ ## 0.0.2-alpha.26
117
+
118
+ ### Patch Changes
119
+
120
+ - 8ae2bbc: Dane publishing
121
+ - 0bd142c: Fixes learned from docs
122
+ - ee4de15: Dane fixes
123
+ - Updated dependencies [8ae2bbc]
124
+ - Updated dependencies [0bd142c]
125
+ - Updated dependencies [ee4de15]
126
+ - @mastra/core@0.1.27-alpha.46
127
+
128
+ ## 0.0.2-alpha.25
129
+
130
+ ### Patch Changes
131
+
132
+ - 3220d26: Fix lastStep error in agent stream
133
+
134
+ ## 0.0.2-alpha.24
135
+
136
+ ### Patch Changes
137
+
138
+ - 002d6d8: add memory to playground agent
139
+ - Updated dependencies [e608d8c]
140
+ - Updated dependencies [002d6d8]
141
+ - @mastra/core@0.1.27-alpha.45
142
+
143
+ ## 0.0.2-alpha.23
144
+
145
+ ### Patch Changes
146
+
147
+ - Updated dependencies [2fa7f53]
148
+ - @mastra/core@0.1.27-alpha.44
149
+
150
+ ## 0.0.2-alpha.22
151
+
152
+ ### Patch Changes
153
+
154
+ - Updated dependencies [2e099d2]
155
+ - Updated dependencies [d6d8159]
156
+ - @mastra/core@0.1.27-alpha.43
157
+
158
+ ## 0.0.2-alpha.21
159
+
160
+ ### Patch Changes
161
+
162
+ - Updated dependencies [4a54c82]
163
+ - @mastra/core@0.1.27-alpha.42
164
+
165
+ ## 0.0.2-alpha.20
166
+
167
+ ### Patch Changes
168
+
169
+ - Updated dependencies [5cdfb88]
170
+ - @mastra/core@0.1.27-alpha.41
171
+
172
+ ## 0.0.2-alpha.19
173
+
174
+ ### Patch Changes
175
+
176
+ - Updated dependencies [9029796]
177
+ - @mastra/core@0.1.27-alpha.40
178
+
179
+ ## 0.0.2-alpha.18
180
+
181
+ ### Patch Changes
182
+
183
+ - Updated dependencies [2b01511]
184
+ - @mastra/core@0.1.27-alpha.39
185
+
186
+ ## 0.0.2-alpha.17
187
+
188
+ ### Patch Changes
189
+
190
+ - Updated dependencies [f031a1f]
191
+ - @mastra/core@0.1.27-alpha.38
192
+
193
+ ## 0.0.2-alpha.16
194
+
195
+ ### Patch Changes
196
+
197
+ - b5393f1: New example: Dane and many fixes to make it work
198
+ - Updated dependencies [c872875]
199
+ - Updated dependencies [f6da688]
200
+ - Updated dependencies [b5393f1]
201
+ - @mastra/core@0.1.27-alpha.37
202
+
203
+ ## 0.0.2-alpha.15
204
+
205
+ ### Patch Changes
206
+
207
+ - b898fad: Fix get context window in memory
208
+ - Updated dependencies [f537e33]
209
+ - Updated dependencies [bc40916]
210
+ - Updated dependencies [f7d1131]
211
+ - Updated dependencies [75bf3f0]
212
+ - Updated dependencies [3c4488b]
213
+ - Updated dependencies [d38f7a6]
214
+ - @mastra/core@0.1.27-alpha.36
215
+
216
+ ## 0.0.2-alpha.14
217
+
218
+ ### Patch Changes
219
+
220
+ - 033eda6: More fixes for refactor
221
+ - Updated dependencies [033eda6]
222
+ - @mastra/core@0.1.27-alpha.35
223
+
224
+ ## 0.0.2-alpha.13
225
+
226
+ ### Patch Changes
227
+
228
+ - 837a288: MAJOR Revamp of tools, workflows, syncs.
229
+ - Updated dependencies [837a288]
230
+ - Updated dependencies [5811de6]
231
+ - @mastra/core@0.1.27-alpha.34
232
+
233
+ ## 0.0.2-alpha.12
234
+
235
+ ### Patch Changes
236
+
237
+ - Updated dependencies [e1dd94a]
238
+ - @mastra/core@0.1.27-alpha.33
239
+
240
+ ## 0.0.2-alpha.11
241
+
242
+ ### Patch Changes
243
+
244
+ - Updated dependencies [2712098]
245
+ - @mastra/core@0.1.27-alpha.32
246
+
247
+ ## 0.0.2-alpha.10
248
+
249
+ ### Patch Changes
250
+
251
+ - Updated dependencies [c2dd6b5]
252
+ - @mastra/core@0.1.27-alpha.31
253
+
254
+ ## 0.0.2-alpha.9
255
+
256
+ ### Patch Changes
257
+
258
+ - Updated dependencies [963c15a]
259
+ - @mastra/core@0.1.27-alpha.30
260
+
261
+ ## 0.0.2-alpha.8
262
+
263
+ ### Patch Changes
264
+
265
+ - Updated dependencies [7d87a15]
266
+ - @mastra/core@0.1.27-alpha.29
267
+
268
+ ## 0.0.2-alpha.7
269
+
270
+ ### Patch Changes
271
+
272
+ - Updated dependencies [1ebd071]
273
+ - @mastra/core@0.1.27-alpha.28
274
+
275
+ ## 0.0.2-alpha.6
276
+
277
+ ### Patch Changes
278
+
279
+ - Updated dependencies [cd02c56]
280
+ - @mastra/core@0.1.27-alpha.27
281
+
282
+ ## 0.0.2-alpha.5
283
+
284
+ ### Patch Changes
285
+
286
+ - Updated dependencies [d5e12de]
287
+ - @mastra/core@0.1.27-alpha.26
288
+
3
289
  ## 0.0.2-alpha.4
4
290
 
5
291
  ### Patch Changes
package/dist/index.d.ts CHANGED
@@ -1,2 +1,3 @@
1
1
  export * from './postgres';
2
2
  export * from './kv/upstash';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC"}
@@ -1,6 +1,6 @@
1
- import { MastraMemory, MessageType as BaseMastraMessageType, ThreadType, MessageResponse } from '@mastra/core';
1
+ import { MastraMemory, MessageType as BaseMastraMessageType, ThreadType, MessageResponse, AiMessageType } from '@mastra/core';
2
2
  import { Redis } from '@upstash/redis';
3
- import { ToolResultPart, Message as AiMessage } from 'ai';
3
+ import { ToolResultPart } from 'ai';
4
4
  interface MessageType extends BaseMastraMessageType {
5
5
  tokens?: number;
6
6
  }
@@ -51,11 +51,11 @@ export declare class UpstashKVMemory extends MastraMemory {
51
51
  /**
52
52
  * Messages
53
53
  */
54
- getMessages({ threadId }: {
54
+ getMessages({ threadId, }: {
55
55
  threadId: string;
56
56
  }): Promise<{
57
57
  messages: MessageType[];
58
- uiMessages: AiMessage[];
58
+ uiMessages: AiMessageType[];
59
59
  }>;
60
60
  saveMessages({ messages }: {
61
61
  messages: MessageType[];
@@ -69,3 +69,4 @@ export declare class UpstashKVMemory extends MastraMemory {
69
69
  parseMessages(messages: MessageType[]): MessageType[];
70
70
  }
71
71
  export {};
72
+ //# sourceMappingURL=upstash.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"upstash.d.ts","sourceRoot":"","sources":["../../src/kv/upstash.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EACZ,WAAW,IAAI,qBAAqB,EACpC,UAAU,EACV,eAAe,EACf,aAAa,EACd,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AACvC,OAAO,EAAE,cAAc,EAAY,MAAM,IAAI,CAAC;AAQ9C,UAAU,WAAY,SAAQ,qBAAqB;IACjD,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAGD,UAAU,oBAAqB,SAAQ,IAAI,CA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Q,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QAClC,QAAQ,EAAE,MAAM,CAAC;KAClB,GAAG,OAAO,CAAC,cAAc,CAAC,QAAQ,CAAC,GAAG,IAAI,CAAC;IAgBtC,gBAAgB,CAAC,CAAC,SAAS,KAAK,GAAG,cAAc,EAAE,EACvD,QAAQ,EACR,SAAS,EACT,OAAO,EAEP,MAAmB,GACpB,EAAE;QACD,MAAM,CAAC,EAAE,CAAC,CAAC;QACX,QAAQ,EAAE,MAAM,CAAC;QACjB,SAAS,CAAC,EAAE,IAAI,CAAC;QACjB,OAAO,CAAC,EAAE,IAAI,CAAC;KAChB;IAgDD;;OAEG;IAEG,WAAW,CAAC,EAChB,QAAQ,GACT,EAAE;QACD,QAAQ,EAAE,MAAM,CAAC;KAClB,GAAG,OAAO,CAAC;QAAE,QAAQ,EAAE,WAAW,EAAE,CAAC;QAAC,UAAU,EAAE,aAAa,EAAE,CAAA;KAAE,CAAC;IAS/D,YAAY,CAAC,EAAE,QAAQ,EAAE,EAAE;QAAE,QAAQ,EAAE,WAAW,EAAE,CAAA;KAAE,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC;IAiD/E,aAAa,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAiB9C;;OAEG;IAEG,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAQ3B,WAAW,CAAC,MAAM,EAAE,oBAAoB,GAAG,UAAU;IAQrD,aAAa,CAAC,QAAQ,EAAE,WAAW,EAAE,GAAG,WAAW,EAAE;CAMtD"}
@@ -712,14 +712,14 @@ var PgMemory = /*#__PURE__*/function (_MastraMemory) {
712
712
  break;
713
713
  }
714
714
  _context8.next = 10;
715
- return client.query("WITH RankedMessages AS (\n SELECT *,\n SUM(tokens) OVER (ORDER BY created_at DESC) as running_total\n FROM mastra_messages\n WHERE thread_id = $1\n AND type = 'text'\n " + (startDate ? "AND created_at >= '" + startDate.toISOString() + "'" : '') + "\n " + (endDate ? "AND created_at <= '" + endDate.toISOString() + "'" : '') + "\n ORDER BY created_at DESC\n )\n SELECT id, \n content, \n role, \n type,\n created_at AS createdAt, \n thread_id AS threadId\n FROM RankedMessages\n WHERE running_total <= $2\n ORDER BY created_at ASC", [threadId, this.MAX_CONTEXT_TOKENS]);
715
+ return client.query("WITH RankedMessages AS (\n SELECT *,\n SUM(tokens) OVER (ORDER BY created_at DESC) as running_total\n FROM mastra_messages\n WHERE thread_id = $1\n " + (startDate ? "AND created_at >= '" + startDate.toISOString() + "'" : '') + "\n " + (endDate ? "AND created_at <= '" + endDate.toISOString() + "'" : '') + "\n ORDER BY created_at DESC\n )\n SELECT id, \n content, \n role, \n type,\n created_at AS createdAt, \n thread_id AS threadId\n FROM RankedMessages\n WHERE running_total <= $2\n ORDER BY created_at ASC", [threadId, this.MAX_CONTEXT_TOKENS]);
716
716
  case 10:
717
717
  _result = _context8.sent;
718
718
  console.log('Format', format);
719
719
  return _context8.abrupt("return", this.parseMessages(_result.rows));
720
720
  case 13:
721
721
  _context8.next = 15;
722
- return client.query("SELECT id, \n content, \n role, \n type,\n created_at AS createdAt, \n thread_id AS threadId\n FROM mastra_messages\n WHERE thread_id = $1\n AND type = 'text'\n " + (startDate ? "AND created_at >= '" + startDate.toISOString() + "'" : '') + "\n " + (endDate ? "AND created_at <= '" + endDate.toISOString() + "'" : '') + "\n ORDER BY created_at ASC", [threadId]);
722
+ return client.query("SELECT id, \n content, \n role, \n type,\n created_at AS createdAt, \n thread_id AS threadId\n FROM mastra_messages\n WHERE thread_id = $1\n " + (startDate ? "AND created_at >= '" + startDate.toISOString() + "'" : '') + "\n " + (endDate ? "AND created_at <= '" + endDate.toISOString() + "'" : '') + "\n ORDER BY created_at ASC", [threadId]);
723
723
  case 15:
724
724
  result = _context8.sent;
725
725
  console.log('Format', format);
@@ -1261,19 +1261,17 @@ var UpstashKVMemory = /*#__PURE__*/function (_MastraMemory) {
1261
1261
  }();
1262
1262
  _proto.getContextWindow = /*#__PURE__*/function () {
1263
1263
  var _getContextWindow = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee8(_ref6) {
1264
- var threadId, startDate, endDate, _ref6$format, format, messagesKey, messages, filteredMessages, totalTokens, messagesWithinTokenLimit, _iterator, _step, _message$content$, message, content, tokens;
1264
+ var threadId, startDate, endDate, messagesKey, messages, filteredMessages, totalTokens, messagesWithinTokenLimit, _iterator, _step, _message$content$, message, content, tokens;
1265
1265
  return _regeneratorRuntime().wrap(function _callee8$(_context8) {
1266
1266
  while (1) switch (_context8.prev = _context8.next) {
1267
1267
  case 0:
1268
- threadId = _ref6.threadId, startDate = _ref6.startDate, endDate = _ref6.endDate, _ref6$format = _ref6.format, format = _ref6$format === void 0 ? 'raw' : _ref6$format;
1268
+ threadId = _ref6.threadId, startDate = _ref6.startDate, endDate = _ref6.endDate;
1269
1269
  messagesKey = this.getMessagesKey(threadId);
1270
1270
  _context8.next = 4;
1271
1271
  return this.kv.lrange(messagesKey, 0, -1);
1272
1272
  case 4:
1273
1273
  messages = _context8.sent;
1274
- filteredMessages = messages.filter(function (msg) {
1275
- return msg.type === 'text';
1276
- });
1274
+ filteredMessages = messages;
1277
1275
  if (startDate) {
1278
1276
  filteredMessages = filteredMessages.filter(function (msg) {
1279
1277
  return new Date(msg.createdAt) >= startDate;
@@ -1285,7 +1283,7 @@ var UpstashKVMemory = /*#__PURE__*/function (_MastraMemory) {
1285
1283
  });
1286
1284
  }
1287
1285
  if (!this.MAX_CONTEXT_TOKENS) {
1288
- _context8.next = 24;
1286
+ _context8.next = 23;
1289
1287
  break;
1290
1288
  }
1291
1289
  totalTokens = 0;
@@ -1314,12 +1312,10 @@ var UpstashKVMemory = /*#__PURE__*/function (_MastraMemory) {
1314
1312
  _context8.next = 12;
1315
1313
  break;
1316
1314
  case 22:
1317
- console.log('Format:', format);
1318
- // Return messages in chronological order
1319
1315
  return _context8.abrupt("return", this.parseMessages(messagesWithinTokenLimit));
1320
- case 24:
1316
+ case 23:
1321
1317
  return _context8.abrupt("return", this.parseMessages(filteredMessages));
1322
- case 25:
1318
+ case 24:
1323
1319
  case "end":
1324
1320
  return _context8.stop();
1325
1321
  }