@mastra/memory 0.0.2-alpha.2 → 0.0.2-alpha.3
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 +8 -0
- package/dist/index.d.ts +1 -0
- package/dist/kv/upstash.d.ts +71 -0
- package/dist/memory.cjs.development.js +937 -448
- package/dist/memory.cjs.development.js.map +1 -1
- package/dist/memory.cjs.production.min.js +1 -1
- package/dist/memory.cjs.production.min.js.map +1 -1
- package/dist/memory.esm.js +937 -449
- package/dist/memory.esm.js.map +1 -1
- package/dist/postgres/index.d.ts +28 -18
- package/package.json +2 -2
- package/src/index.ts +1 -0
- package/src/kv/upstash.test.ts +253 -0
- package/src/kv/upstash.ts +298 -0
- package/src/postgres/index.ts +175 -257
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# @mastra/memory
|
|
2
2
|
|
|
3
|
+
## 0.0.2-alpha.3
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 836f4e3: Fixed some issues with memory, added Upstash as a memory provider. Silenced dev logs in core
|
|
8
|
+
- Updated dependencies [836f4e3]
|
|
9
|
+
- @mastra/core@0.1.27-alpha.24
|
|
10
|
+
|
|
3
11
|
## 0.0.2-alpha.2
|
|
4
12
|
|
|
5
13
|
### Patch Changes
|
package/dist/index.d.ts
CHANGED
|
@@ -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 {};
|