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

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,145 @@
1
1
  # @mastra/memory
2
2
 
3
+ ## 0.0.2-alpha.20
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [5cdfb88]
8
+ - @mastra/core@0.1.27-alpha.41
9
+
10
+ ## 0.0.2-alpha.19
11
+
12
+ ### Patch Changes
13
+
14
+ - Updated dependencies [9029796]
15
+ - @mastra/core@0.1.27-alpha.40
16
+
17
+ ## 0.0.2-alpha.18
18
+
19
+ ### Patch Changes
20
+
21
+ - Updated dependencies [2b01511]
22
+ - @mastra/core@0.1.27-alpha.39
23
+
24
+ ## 0.0.2-alpha.17
25
+
26
+ ### Patch Changes
27
+
28
+ - Updated dependencies [f031a1f]
29
+ - @mastra/core@0.1.27-alpha.38
30
+
31
+ ## 0.0.2-alpha.16
32
+
33
+ ### Patch Changes
34
+
35
+ - b5393f1: New example: Dane and many fixes to make it work
36
+ - Updated dependencies [c872875]
37
+ - Updated dependencies [f6da688]
38
+ - Updated dependencies [b5393f1]
39
+ - @mastra/core@0.1.27-alpha.37
40
+
41
+ ## 0.0.2-alpha.15
42
+
43
+ ### Patch Changes
44
+
45
+ - b898fad: Fix get context window in memory
46
+ - Updated dependencies [f537e33]
47
+ - Updated dependencies [bc40916]
48
+ - Updated dependencies [f7d1131]
49
+ - Updated dependencies [75bf3f0]
50
+ - Updated dependencies [3c4488b]
51
+ - Updated dependencies [d38f7a6]
52
+ - @mastra/core@0.1.27-alpha.36
53
+
54
+ ## 0.0.2-alpha.14
55
+
56
+ ### Patch Changes
57
+
58
+ - 033eda6: More fixes for refactor
59
+ - Updated dependencies [033eda6]
60
+ - @mastra/core@0.1.27-alpha.35
61
+
62
+ ## 0.0.2-alpha.13
63
+
64
+ ### Patch Changes
65
+
66
+ - 837a288: MAJOR Revamp of tools, workflows, syncs.
67
+ - Updated dependencies [837a288]
68
+ - Updated dependencies [5811de6]
69
+ - @mastra/core@0.1.27-alpha.34
70
+
71
+ ## 0.0.2-alpha.12
72
+
73
+ ### Patch Changes
74
+
75
+ - Updated dependencies [e1dd94a]
76
+ - @mastra/core@0.1.27-alpha.33
77
+
78
+ ## 0.0.2-alpha.11
79
+
80
+ ### Patch Changes
81
+
82
+ - Updated dependencies [2712098]
83
+ - @mastra/core@0.1.27-alpha.32
84
+
85
+ ## 0.0.2-alpha.10
86
+
87
+ ### Patch Changes
88
+
89
+ - Updated dependencies [c2dd6b5]
90
+ - @mastra/core@0.1.27-alpha.31
91
+
92
+ ## 0.0.2-alpha.9
93
+
94
+ ### Patch Changes
95
+
96
+ - Updated dependencies [963c15a]
97
+ - @mastra/core@0.1.27-alpha.30
98
+
99
+ ## 0.0.2-alpha.8
100
+
101
+ ### Patch Changes
102
+
103
+ - Updated dependencies [7d87a15]
104
+ - @mastra/core@0.1.27-alpha.29
105
+
106
+ ## 0.0.2-alpha.7
107
+
108
+ ### Patch Changes
109
+
110
+ - Updated dependencies [1ebd071]
111
+ - @mastra/core@0.1.27-alpha.28
112
+
113
+ ## 0.0.2-alpha.6
114
+
115
+ ### Patch Changes
116
+
117
+ - Updated dependencies [cd02c56]
118
+ - @mastra/core@0.1.27-alpha.27
119
+
120
+ ## 0.0.2-alpha.5
121
+
122
+ ### Patch Changes
123
+
124
+ - Updated dependencies [d5e12de]
125
+ - @mastra/core@0.1.27-alpha.26
126
+
127
+ ## 0.0.2-alpha.4
128
+
129
+ ### Patch Changes
130
+
131
+ - 01502b0: fix thread title containing unnecessary text and removed unnecessary logs in memory
132
+ - Updated dependencies [01502b0]
133
+ - @mastra/core@0.1.27-alpha.25
134
+
135
+ ## 0.0.2-alpha.3
136
+
137
+ ### Patch Changes
138
+
139
+ - 836f4e3: Fixed some issues with memory, added Upstash as a memory provider. Silenced dev logs in core
140
+ - Updated dependencies [836f4e3]
141
+ - @mastra/core@0.1.27-alpha.24
142
+
3
143
  ## 0.0.2-alpha.2
4
144
 
5
145
  ### 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,MAAM,CAAS;IAEvB,EAAE,EAAE,KAAK,CAAC;gBAEE,MAAM,EAAE;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,KAAK,EA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