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

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,21 @@
1
1
  # @mastra/memory
2
2
 
3
+ ## 0.0.2-alpha.4
4
+
5
+ ### Patch Changes
6
+
7
+ - 01502b0: fix thread title containing unnecessary text and removed unnecessary logs in memory
8
+ - Updated dependencies [01502b0]
9
+ - @mastra/core@0.1.27-alpha.25
10
+
11
+ ## 0.0.2-alpha.3
12
+
13
+ ### Patch Changes
14
+
15
+ - 836f4e3: Fixed some issues with memory, added Upstash as a memory provider. Silenced dev logs in core
16
+ - Updated dependencies [836f4e3]
17
+ - @mastra/core@0.1.27-alpha.24
18
+
3
19
  ## 0.0.2-alpha.2
4
20
 
5
21
  ### Patch Changes
package/dist/index.d.ts CHANGED
@@ -1 +1,2 @@
1
1
  export * from './postgres';
2
+ export * from './kv/upstash';
@@ -0,0 +1,71 @@
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 {};