@mastra/memory 0.0.2-alpha.2 → 0.0.2-alpha.21

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,152 @@
1
1
  # @mastra/memory
2
2
 
3
+ ## 0.0.2-alpha.21
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [4a54c82]
8
+ - @mastra/core@0.1.27-alpha.42
9
+
10
+ ## 0.0.2-alpha.20
11
+
12
+ ### Patch Changes
13
+
14
+ - Updated dependencies [5cdfb88]
15
+ - @mastra/core@0.1.27-alpha.41
16
+
17
+ ## 0.0.2-alpha.19
18
+
19
+ ### Patch Changes
20
+
21
+ - Updated dependencies [9029796]
22
+ - @mastra/core@0.1.27-alpha.40
23
+
24
+ ## 0.0.2-alpha.18
25
+
26
+ ### Patch Changes
27
+
28
+ - Updated dependencies [2b01511]
29
+ - @mastra/core@0.1.27-alpha.39
30
+
31
+ ## 0.0.2-alpha.17
32
+
33
+ ### Patch Changes
34
+
35
+ - Updated dependencies [f031a1f]
36
+ - @mastra/core@0.1.27-alpha.38
37
+
38
+ ## 0.0.2-alpha.16
39
+
40
+ ### Patch Changes
41
+
42
+ - b5393f1: New example: Dane and many fixes to make it work
43
+ - Updated dependencies [c872875]
44
+ - Updated dependencies [f6da688]
45
+ - Updated dependencies [b5393f1]
46
+ - @mastra/core@0.1.27-alpha.37
47
+
48
+ ## 0.0.2-alpha.15
49
+
50
+ ### Patch Changes
51
+
52
+ - b898fad: Fix get context window in memory
53
+ - Updated dependencies [f537e33]
54
+ - Updated dependencies [bc40916]
55
+ - Updated dependencies [f7d1131]
56
+ - Updated dependencies [75bf3f0]
57
+ - Updated dependencies [3c4488b]
58
+ - Updated dependencies [d38f7a6]
59
+ - @mastra/core@0.1.27-alpha.36
60
+
61
+ ## 0.0.2-alpha.14
62
+
63
+ ### Patch Changes
64
+
65
+ - 033eda6: More fixes for refactor
66
+ - Updated dependencies [033eda6]
67
+ - @mastra/core@0.1.27-alpha.35
68
+
69
+ ## 0.0.2-alpha.13
70
+
71
+ ### Patch Changes
72
+
73
+ - 837a288: MAJOR Revamp of tools, workflows, syncs.
74
+ - Updated dependencies [837a288]
75
+ - Updated dependencies [5811de6]
76
+ - @mastra/core@0.1.27-alpha.34
77
+
78
+ ## 0.0.2-alpha.12
79
+
80
+ ### Patch Changes
81
+
82
+ - Updated dependencies [e1dd94a]
83
+ - @mastra/core@0.1.27-alpha.33
84
+
85
+ ## 0.0.2-alpha.11
86
+
87
+ ### Patch Changes
88
+
89
+ - Updated dependencies [2712098]
90
+ - @mastra/core@0.1.27-alpha.32
91
+
92
+ ## 0.0.2-alpha.10
93
+
94
+ ### Patch Changes
95
+
96
+ - Updated dependencies [c2dd6b5]
97
+ - @mastra/core@0.1.27-alpha.31
98
+
99
+ ## 0.0.2-alpha.9
100
+
101
+ ### Patch Changes
102
+
103
+ - Updated dependencies [963c15a]
104
+ - @mastra/core@0.1.27-alpha.30
105
+
106
+ ## 0.0.2-alpha.8
107
+
108
+ ### Patch Changes
109
+
110
+ - Updated dependencies [7d87a15]
111
+ - @mastra/core@0.1.27-alpha.29
112
+
113
+ ## 0.0.2-alpha.7
114
+
115
+ ### Patch Changes
116
+
117
+ - Updated dependencies [1ebd071]
118
+ - @mastra/core@0.1.27-alpha.28
119
+
120
+ ## 0.0.2-alpha.6
121
+
122
+ ### Patch Changes
123
+
124
+ - Updated dependencies [cd02c56]
125
+ - @mastra/core@0.1.27-alpha.27
126
+
127
+ ## 0.0.2-alpha.5
128
+
129
+ ### Patch Changes
130
+
131
+ - Updated dependencies [d5e12de]
132
+ - @mastra/core@0.1.27-alpha.26
133
+
134
+ ## 0.0.2-alpha.4
135
+
136
+ ### Patch Changes
137
+
138
+ - 01502b0: fix thread title containing unnecessary text and removed unnecessary logs in memory
139
+ - Updated dependencies [01502b0]
140
+ - @mastra/core@0.1.27-alpha.25
141
+
142
+ ## 0.0.2-alpha.3
143
+
144
+ ### Patch Changes
145
+
146
+ - 836f4e3: Fixed some issues with memory, added Upstash as a memory provider. Silenced dev logs in core
147
+ - Updated dependencies [836f4e3]
148
+ - @mastra/core@0.1.27-alpha.24
149
+
3
150
  ## 0.0.2-alpha.2
4
151
 
5
152
  ### Patch Changes
package/dist/index.d.ts CHANGED
@@ -1 +1,3 @@
1
1
  export * from './postgres';
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"}
@@ -0,0 +1,72 @@
1
+ import { MastraMemory, MessageType as BaseMastraMessageType, ThreadType, MessageResponse } from '@mastra/core';
2
+ import { Redis } from '@upstash/redis';
3
+ import { ToolResultPart, Message as AiMessage } from 'ai';
4
+ interface MessageType extends BaseMastraMessageType {
5
+ tokens?: number;
6
+ }
7
+ interface SerializedThreadType extends Omit<ThreadType, 'createdAt' | 'updatedAt'> {
8
+ createdAt: string;
9
+ updatedAt: string;
10
+ }
11
+ export declare class UpstashKVMemory extends MastraMemory {
12
+ private prefix;
13
+ kv: Redis;
14
+ constructor(config: {
15
+ url: string;
16
+ token: string;
17
+ prefix?: string;
18
+ maxTokens?: number;
19
+ });
20
+ private getThreadKey;
21
+ private getMessagesKey;
22
+ private getToolCacheKey;
23
+ getThreadById({ threadId }: {
24
+ threadId: string;
25
+ }): Promise<ThreadType | null>;
26
+ getThreadsByResourceId({ resourceid }: {
27
+ resourceid: string;
28
+ }): Promise<ThreadType[]>;
29
+ saveThread({ thread }: {
30
+ thread: ThreadType;
31
+ }): Promise<ThreadType>;
32
+ updateThread(id: string, title: string, metadata: Record<string, unknown>): Promise<ThreadType>;
33
+ deleteThread(id: string): Promise<void>;
34
+ /**
35
+ * Tool Cache
36
+ */
37
+ validateToolCallArgs({ hashedArgs }: {
38
+ hashedArgs: string;
39
+ }): Promise<boolean>;
40
+ getToolResult({ threadId, toolArgs, toolName, }: {
41
+ threadId: string;
42
+ toolArgs: Record<string, unknown>;
43
+ toolName: string;
44
+ }): Promise<ToolResultPart['result'] | null>;
45
+ getContextWindow<T extends 'raw' | 'core_message'>({ threadId, startDate, endDate, format, }: {
46
+ format?: T;
47
+ threadId: string;
48
+ startDate?: Date;
49
+ endDate?: Date;
50
+ }): Promise<MessageResponse<T>>;
51
+ /**
52
+ * Messages
53
+ */
54
+ getMessages({ threadId }: {
55
+ threadId: string;
56
+ }): Promise<{
57
+ messages: MessageType[];
58
+ uiMessages: AiMessage[];
59
+ }>;
60
+ saveMessages({ messages }: {
61
+ messages: MessageType[];
62
+ }): Promise<MessageType[]>;
63
+ deleteMessage(id: string): Promise<void>;
64
+ /**
65
+ * Cleanup
66
+ */
67
+ drop(): Promise<void>;
68
+ parseThread(thread: SerializedThreadType): ThreadType;
69
+ parseMessages(messages: MessageType[]): MessageType[];
70
+ }
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,EAAE,YAAY,EAAE,WAAW,IAAI,qBAAqB,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAC/G,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AACvC,OAAO,EAAE,cAAc,EAAE,OAAO,IAAI,SAAS,EAAY,MAAM,IAAI,CAAC;AAQpE,UAAU,WAAY,SAAQ,qBAAqB;IACjD,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAGD,UAAU,oBAAqB,SAAQ,IAAI,CAAC,UAAU,EAAE,WAAW,GAAG,WAAW,CAAC;IAChF,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,qBAAa,eAAgB,SAAQ,YAAY;IAC/C,OAAO,CAAC,M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