@ainetwork/adk-provider-memory-inmemory 0.2.3 → 0.3.0
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/dist/index.cjs +62 -32
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +12 -38
- package/dist/index.d.ts +12 -38
- package/dist/index.js +61 -30
- package/dist/index.js.map +1 -1
- package/implements/agent.memory.ts +13 -0
- package/implements/base.memory.ts +47 -0
- package/implements/intent.memory.ts +11 -17
- package/implements/thread.memory.ts +10 -16
- package/index.ts +1 -2
- package/package.json +3 -3
package/dist/index.cjs
CHANGED
|
@@ -20,22 +20,50 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
20
20
|
// index.ts
|
|
21
21
|
var index_exports = {};
|
|
22
22
|
__export(index_exports, {
|
|
23
|
-
|
|
24
|
-
InMemoryThread: () => InMemoryThread
|
|
23
|
+
InMemoryMemory: () => InMemoryMemory
|
|
25
24
|
});
|
|
26
25
|
module.exports = __toCommonJS(index_exports);
|
|
27
26
|
|
|
27
|
+
// implements/agent.memory.ts
|
|
28
|
+
var InMemoryAgent = class {
|
|
29
|
+
prompt = "";
|
|
30
|
+
async getAgentPrompt() {
|
|
31
|
+
return this.prompt;
|
|
32
|
+
}
|
|
33
|
+
async updateAgentPrompt(prompt) {
|
|
34
|
+
this.prompt = prompt;
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
// implements/intent.memory.ts
|
|
39
|
+
var import_node_crypto = require("crypto");
|
|
40
|
+
var InMemoryIntent = class {
|
|
41
|
+
intents = /* @__PURE__ */ new Map();
|
|
42
|
+
async getIntent(intentId) {
|
|
43
|
+
return this.intents.get(intentId);
|
|
44
|
+
}
|
|
45
|
+
async getIntentByName(intentName) {
|
|
46
|
+
return Array.from(this.intents.values()).find((intent) => intent.name === intentName);
|
|
47
|
+
}
|
|
48
|
+
async saveIntent(intent) {
|
|
49
|
+
const newId = (0, import_node_crypto.randomUUID)();
|
|
50
|
+
this.intents.set(newId, intent);
|
|
51
|
+
}
|
|
52
|
+
async updateIntent(intentId, intent) {
|
|
53
|
+
this.intents.set(intentId, intent);
|
|
54
|
+
}
|
|
55
|
+
async deleteIntent(intentId) {
|
|
56
|
+
this.intents.delete(intentId);
|
|
57
|
+
}
|
|
58
|
+
async listIntents() {
|
|
59
|
+
return Array.from(this.intents.values());
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
|
|
28
63
|
// implements/thread.memory.ts
|
|
29
64
|
var InMemoryThread = class {
|
|
30
65
|
threads = /* @__PURE__ */ new Map();
|
|
31
66
|
userThreadIndex = /* @__PURE__ */ new Map();
|
|
32
|
-
async connect() {
|
|
33
|
-
}
|
|
34
|
-
async disconnect() {
|
|
35
|
-
}
|
|
36
|
-
isConnected() {
|
|
37
|
-
return true;
|
|
38
|
-
}
|
|
39
67
|
generateKey(userId, threadId) {
|
|
40
68
|
return `${userId}:${threadId}`;
|
|
41
69
|
}
|
|
@@ -95,40 +123,42 @@ var InMemoryThread = class {
|
|
|
95
123
|
}
|
|
96
124
|
};
|
|
97
125
|
|
|
98
|
-
// implements/
|
|
99
|
-
var
|
|
100
|
-
|
|
101
|
-
|
|
126
|
+
// implements/base.memory.ts
|
|
127
|
+
var InMemoryMemory = class _InMemoryMemory {
|
|
128
|
+
static instance;
|
|
129
|
+
connected = false;
|
|
130
|
+
agentMemory;
|
|
131
|
+
intentMemory;
|
|
132
|
+
threadMemory;
|
|
133
|
+
constructor() {
|
|
134
|
+
if (!_InMemoryMemory.instance) {
|
|
135
|
+
_InMemoryMemory.instance = this;
|
|
136
|
+
}
|
|
137
|
+
this.agentMemory = new InMemoryAgent();
|
|
138
|
+
this.threadMemory = new InMemoryThread();
|
|
139
|
+
this.intentMemory = new InMemoryIntent();
|
|
140
|
+
}
|
|
102
141
|
async connect() {
|
|
142
|
+
this.connected = true;
|
|
103
143
|
}
|
|
104
144
|
async disconnect() {
|
|
145
|
+
this.connected = false;
|
|
105
146
|
}
|
|
106
147
|
isConnected() {
|
|
107
|
-
return
|
|
108
|
-
}
|
|
109
|
-
async getIntent(intentId) {
|
|
110
|
-
return this.intents.get(intentId);
|
|
111
|
-
}
|
|
112
|
-
async getIntentByName(intentName) {
|
|
113
|
-
return Array.from(this.intents.values()).find((intent) => intent.name === intentName);
|
|
114
|
-
}
|
|
115
|
-
async saveIntent(intent) {
|
|
116
|
-
const newId = (0, import_node_crypto.randomUUID)();
|
|
117
|
-
this.intents.set(newId, intent);
|
|
148
|
+
return this.connected;
|
|
118
149
|
}
|
|
119
|
-
|
|
120
|
-
this.
|
|
150
|
+
getAgentMemory() {
|
|
151
|
+
return this.agentMemory;
|
|
121
152
|
}
|
|
122
|
-
|
|
123
|
-
this.
|
|
153
|
+
getThreadMemory() {
|
|
154
|
+
return this.threadMemory;
|
|
124
155
|
}
|
|
125
|
-
|
|
126
|
-
return
|
|
156
|
+
getIntentMemory() {
|
|
157
|
+
return this.intentMemory;
|
|
127
158
|
}
|
|
128
159
|
};
|
|
129
160
|
// Annotate the CommonJS export names for ESM import in node:
|
|
130
161
|
0 && (module.exports = {
|
|
131
|
-
|
|
132
|
-
InMemoryThread
|
|
162
|
+
InMemoryMemory
|
|
133
163
|
});
|
|
134
164
|
//# sourceMappingURL=index.cjs.map
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../index.ts","../implements/
|
|
1
|
+
{"version":3,"sources":["../index.ts","../implements/agent.memory.ts","../implements/intent.memory.ts","../implements/thread.memory.ts","../implements/base.memory.ts"],"sourcesContent":["export { InMemoryMemory } from \"./implements/base.memory\";","import { IAgentMemory } from \"@ainetwork/adk/modules\";\n\nexport class InMemoryAgent implements IAgentMemory {\n private prompt: string = \"\";\n\n public async getAgentPrompt(): Promise<string> {\n return this.prompt;\n }\n\n public async updateAgentPrompt(prompt: string): Promise<void> {\n this.prompt = prompt;\n }\n}\n","import { randomUUID } from \"node:crypto\";\nimport type { Intent } from \"@ainetwork/adk/types/memory\";\nimport { IIntentMemory } from \"@ainetwork/adk/modules\";\n\nexport class InMemoryIntent implements IIntentMemory {\n public intents: Map<string, Intent> = new Map();\n\n public async getIntent(intentId: string): Promise<Intent | undefined> {\n return this.intents.get(intentId);\n }\n\n public async getIntentByName(intentName: string): Promise<Intent | undefined> {\n return Array.from(this.intents.values()).find(intent => intent.name === intentName);\n }\n\n public async saveIntent(intent: Intent): Promise<void> {\n const newId = randomUUID();\n this.intents.set(newId, intent);\n }\n\n public async updateIntent(intentId: string, intent: Intent): Promise<void> {\n this.intents.set(intentId, intent);\n }\n\n public async deleteIntent(intentId: string): Promise<void> {\n this.intents.delete(intentId);\n }\n\n public async listIntents(): Promise<Intent[]> {\n return Array.from(this.intents.values());\n }\n}","import type { MessageObject, ThreadObject, ThreadMetadata, ThreadType } from \"@ainetwork/adk/types/memory\";\nimport { IThreadMemory } from \"@ainetwork/adk/modules\";\n\ntype InMemoryThreadObject = {\n type: ThreadType;\n title: string;\n messages: Array<MessageObject>;\n}\n\ntype InMemoryThreadMetadata = {\n type: ThreadType;\n userId: string;\n threadId: string;\n title: string;\n updatedAt: number;\n createdAt: number;\n}\n\nexport class InMemoryThread implements IThreadMemory {\n public threads: Map<string, InMemoryThreadObject> = new Map();\n public userThreadIndex: Map<string, Set<InMemoryThreadMetadata>> = new Map();\n\n private generateKey(userId: string, threadId: string) {\n return `${userId}:${threadId}`;\n }\n\n public async getThread(\n userId: string,\n threadId: string\n ): Promise<ThreadObject | undefined> {\n const key = this.generateKey(userId, threadId);\n const res = this.threads.get(key);\n if (res) {\n const threadObject: ThreadObject = {\n threadId,\n userId,\n type: res.type,\n title: res.title,\n messages: res.messages,\n };\n return threadObject;\n }\n return undefined;\n }\n\n public async createThread(\n type: ThreadType,\n userId: string,\n threadId: string,\n title: string\n ): Promise<ThreadObject> {\n const now = Date.now();\n const key = this.generateKey(userId, threadId);\n if (!this.userThreadIndex.has(userId)) {\n this.userThreadIndex.set(userId, new Set());\n }\n if (!this.threads.has(key)) {\n this.threads.set(key, { type, title, messages: [] });\n const metadata: InMemoryThreadMetadata = {\n type, userId, threadId, title, createdAt: now, updatedAt: now,\n }\n this.userThreadIndex.get(userId)?.add(metadata);\n }\n\n return { type, title, threadId, userId, messages: [] };\n }\n\n public async addMessagesToThread(\n userId: string,\n threadId: string,\n messages: MessageObject[]\n ): Promise<void> {\n const key = this.generateKey(userId, threadId);\n const thread = this.threads.get(key);\n for (const message of messages) {\n thread?.messages.push(message);\n }\n }\n\n public async deleteThread(userId: string, threadId: string): Promise<void> {\n const key = this.generateKey(userId, threadId);\n this.threads.delete(key);\n this.userThreadIndex.delete(threadId);\n }\n\n public async listThreads(userId: string): Promise<ThreadMetadata[]> {\n const threads = this.userThreadIndex.get(userId);\n if (threads) {\n return Array.from(threads);\n }\n return [];\n }\n}","import { IAgentMemory, IIntentMemory, IMemory, IThreadMemory } from \"node_modules/@ainetwork/adk/dist/esm/modules/memory/base.memory\";\nimport { InMemoryAgent } from \"./agent.memory\";\nimport { InMemoryIntent } from \"./intent.memory\";\nimport { InMemoryThread } from \"./thread.memory\";\n\nexport class InMemoryMemory implements IMemory {\n private static instance: InMemoryMemory;\n private connected: boolean = false;\n\n private agentMemory: InMemoryAgent;\n private intentMemory: InMemoryIntent;\n private threadMemory: InMemoryThread;\n\n constructor() {\n if (!InMemoryMemory.instance) {\n InMemoryMemory.instance = this;\n }\n\n this.agentMemory = new InMemoryAgent();\n this.threadMemory = new InMemoryThread();\n this.intentMemory = new InMemoryIntent();\n }\n\n public async connect(): Promise<void> {\n this.connected = true;\n }\n\n public async disconnect(): Promise<void> {\n this.connected = false;\n }\n\n public isConnected(): boolean {\n return this.connected;\n }\n\n public getAgentMemory(): IAgentMemory {\n return this.agentMemory;\n }\n\n public getThreadMemory(): IThreadMemory {\n return this.threadMemory;\n }\n\n public getIntentMemory(): IIntentMemory {\n return this.intentMemory;\n }\n}\n"],"mappings":";;;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AAK,OAAO;AAAA,IAC3B;AACA,WAAO,CAAC;AAAA,EACV;AACF;;;ACvFO,IAAM,iBAAN,MAAM,gBAAkC;AAAA,EAC7C,OAAe;AAAA,EACP,YAAqB;AAAA,EAErB;AAAA,EACA;AAAA,EACA;AAAA,EAER,cAAc;AACZ,QAAI,CAAC,gBAAe,UAAU;AAC5B,sBAAe,WAAW;AAAA,IAC5B;AAEA,SAAK,cAAc,IAAI,cAAc;AACrC,SAAK,eAAe,IAAI,eAAe;AACvC,SAAK,eAAe,IAAI,eAAe;AAAA,EACzC;AAAA,EAEA,MAAa,UAAyB;AACpC,SAAK,YAAY;AAAA,EACnB;AAAA,EAEA,MAAa,aAA4B;AACvC,SAAK,YAAY;AAAA,EACnB;AAAA,EAEO,cAAuB;AAC5B,WAAO,KAAK;AAAA,EACd;AAAA,EAEO,iBAA+B;AACpC,WAAO,KAAK;AAAA,EACd;AAAA,EAEO,kBAAiC;AACtC,WAAO,KAAK;AAAA,EACd;AAAA,EAEO,kBAAiC;AACtC,WAAO,KAAK;AAAA,EACd;AACF;","names":[]}
|
package/dist/index.d.cts
CHANGED
|
@@ -1,44 +1,18 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { IThreadMemory, IIntentMemory } from '@ainetwork/adk/modules';
|
|
1
|
+
import { IMemory, IAgentMemory, IThreadMemory, IIntentMemory } from 'node_modules/@ainetwork/adk/dist/esm/modules/memory/base.memory';
|
|
3
2
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
userId: string;
|
|
12
|
-
threadId: string;
|
|
13
|
-
title: string;
|
|
14
|
-
updatedAt: number;
|
|
15
|
-
createdAt: number;
|
|
16
|
-
};
|
|
17
|
-
declare class InMemoryThread implements IThreadMemory {
|
|
18
|
-
threads: Map<string, InMemoryThreadObject>;
|
|
19
|
-
userThreadIndex: Map<string, Set<InMemoryThreadMetadata>>;
|
|
3
|
+
declare class InMemoryMemory implements IMemory {
|
|
4
|
+
private static instance;
|
|
5
|
+
private connected;
|
|
6
|
+
private agentMemory;
|
|
7
|
+
private intentMemory;
|
|
8
|
+
private threadMemory;
|
|
9
|
+
constructor();
|
|
20
10
|
connect(): Promise<void>;
|
|
21
11
|
disconnect(): Promise<void>;
|
|
22
12
|
isConnected(): boolean;
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
addMessagesToThread(userId: string, threadId: string, messages: MessageObject[]): Promise<void>;
|
|
27
|
-
deleteThread(userId: string, threadId: string): Promise<void>;
|
|
28
|
-
listThreads(userId: string): Promise<ThreadMetadata[]>;
|
|
13
|
+
getAgentMemory(): IAgentMemory;
|
|
14
|
+
getThreadMemory(): IThreadMemory;
|
|
15
|
+
getIntentMemory(): IIntentMemory;
|
|
29
16
|
}
|
|
30
17
|
|
|
31
|
-
|
|
32
|
-
intents: Map<string, Intent>;
|
|
33
|
-
connect(): Promise<void>;
|
|
34
|
-
disconnect(): Promise<void>;
|
|
35
|
-
isConnected(): boolean;
|
|
36
|
-
getIntent(intentId: string): Promise<Intent | undefined>;
|
|
37
|
-
getIntentByName(intentName: string): Promise<Intent | undefined>;
|
|
38
|
-
saveIntent(intent: Intent): Promise<void>;
|
|
39
|
-
updateIntent(intentId: string, intent: Intent): Promise<void>;
|
|
40
|
-
deleteIntent(intentId: string): Promise<void>;
|
|
41
|
-
listIntents(): Promise<Intent[]>;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
export { InMemoryIntent, InMemoryThread };
|
|
18
|
+
export { InMemoryMemory };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,44 +1,18 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { IThreadMemory, IIntentMemory } from '@ainetwork/adk/modules';
|
|
1
|
+
import { IMemory, IAgentMemory, IThreadMemory, IIntentMemory } from 'node_modules/@ainetwork/adk/dist/esm/modules/memory/base.memory';
|
|
3
2
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
userId: string;
|
|
12
|
-
threadId: string;
|
|
13
|
-
title: string;
|
|
14
|
-
updatedAt: number;
|
|
15
|
-
createdAt: number;
|
|
16
|
-
};
|
|
17
|
-
declare class InMemoryThread implements IThreadMemory {
|
|
18
|
-
threads: Map<string, InMemoryThreadObject>;
|
|
19
|
-
userThreadIndex: Map<string, Set<InMemoryThreadMetadata>>;
|
|
3
|
+
declare class InMemoryMemory implements IMemory {
|
|
4
|
+
private static instance;
|
|
5
|
+
private connected;
|
|
6
|
+
private agentMemory;
|
|
7
|
+
private intentMemory;
|
|
8
|
+
private threadMemory;
|
|
9
|
+
constructor();
|
|
20
10
|
connect(): Promise<void>;
|
|
21
11
|
disconnect(): Promise<void>;
|
|
22
12
|
isConnected(): boolean;
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
addMessagesToThread(userId: string, threadId: string, messages: MessageObject[]): Promise<void>;
|
|
27
|
-
deleteThread(userId: string, threadId: string): Promise<void>;
|
|
28
|
-
listThreads(userId: string): Promise<ThreadMetadata[]>;
|
|
13
|
+
getAgentMemory(): IAgentMemory;
|
|
14
|
+
getThreadMemory(): IThreadMemory;
|
|
15
|
+
getIntentMemory(): IIntentMemory;
|
|
29
16
|
}
|
|
30
17
|
|
|
31
|
-
|
|
32
|
-
intents: Map<string, Intent>;
|
|
33
|
-
connect(): Promise<void>;
|
|
34
|
-
disconnect(): Promise<void>;
|
|
35
|
-
isConnected(): boolean;
|
|
36
|
-
getIntent(intentId: string): Promise<Intent | undefined>;
|
|
37
|
-
getIntentByName(intentName: string): Promise<Intent | undefined>;
|
|
38
|
-
saveIntent(intent: Intent): Promise<void>;
|
|
39
|
-
updateIntent(intentId: string, intent: Intent): Promise<void>;
|
|
40
|
-
deleteIntent(intentId: string): Promise<void>;
|
|
41
|
-
listIntents(): Promise<Intent[]>;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
export { InMemoryIntent, InMemoryThread };
|
|
18
|
+
export { InMemoryMemory };
|
package/dist/index.js
CHANGED
|
@@ -1,14 +1,43 @@
|
|
|
1
|
+
// implements/agent.memory.ts
|
|
2
|
+
var InMemoryAgent = class {
|
|
3
|
+
prompt = "";
|
|
4
|
+
async getAgentPrompt() {
|
|
5
|
+
return this.prompt;
|
|
6
|
+
}
|
|
7
|
+
async updateAgentPrompt(prompt) {
|
|
8
|
+
this.prompt = prompt;
|
|
9
|
+
}
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
// implements/intent.memory.ts
|
|
13
|
+
import { randomUUID } from "crypto";
|
|
14
|
+
var InMemoryIntent = class {
|
|
15
|
+
intents = /* @__PURE__ */ new Map();
|
|
16
|
+
async getIntent(intentId) {
|
|
17
|
+
return this.intents.get(intentId);
|
|
18
|
+
}
|
|
19
|
+
async getIntentByName(intentName) {
|
|
20
|
+
return Array.from(this.intents.values()).find((intent) => intent.name === intentName);
|
|
21
|
+
}
|
|
22
|
+
async saveIntent(intent) {
|
|
23
|
+
const newId = randomUUID();
|
|
24
|
+
this.intents.set(newId, intent);
|
|
25
|
+
}
|
|
26
|
+
async updateIntent(intentId, intent) {
|
|
27
|
+
this.intents.set(intentId, intent);
|
|
28
|
+
}
|
|
29
|
+
async deleteIntent(intentId) {
|
|
30
|
+
this.intents.delete(intentId);
|
|
31
|
+
}
|
|
32
|
+
async listIntents() {
|
|
33
|
+
return Array.from(this.intents.values());
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
|
|
1
37
|
// implements/thread.memory.ts
|
|
2
38
|
var InMemoryThread = class {
|
|
3
39
|
threads = /* @__PURE__ */ new Map();
|
|
4
40
|
userThreadIndex = /* @__PURE__ */ new Map();
|
|
5
|
-
async connect() {
|
|
6
|
-
}
|
|
7
|
-
async disconnect() {
|
|
8
|
-
}
|
|
9
|
-
isConnected() {
|
|
10
|
-
return true;
|
|
11
|
-
}
|
|
12
41
|
generateKey(userId, threadId) {
|
|
13
42
|
return `${userId}:${threadId}`;
|
|
14
43
|
}
|
|
@@ -68,39 +97,41 @@ var InMemoryThread = class {
|
|
|
68
97
|
}
|
|
69
98
|
};
|
|
70
99
|
|
|
71
|
-
// implements/
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
100
|
+
// implements/base.memory.ts
|
|
101
|
+
var InMemoryMemory = class _InMemoryMemory {
|
|
102
|
+
static instance;
|
|
103
|
+
connected = false;
|
|
104
|
+
agentMemory;
|
|
105
|
+
intentMemory;
|
|
106
|
+
threadMemory;
|
|
107
|
+
constructor() {
|
|
108
|
+
if (!_InMemoryMemory.instance) {
|
|
109
|
+
_InMemoryMemory.instance = this;
|
|
110
|
+
}
|
|
111
|
+
this.agentMemory = new InMemoryAgent();
|
|
112
|
+
this.threadMemory = new InMemoryThread();
|
|
113
|
+
this.intentMemory = new InMemoryIntent();
|
|
114
|
+
}
|
|
75
115
|
async connect() {
|
|
116
|
+
this.connected = true;
|
|
76
117
|
}
|
|
77
118
|
async disconnect() {
|
|
119
|
+
this.connected = false;
|
|
78
120
|
}
|
|
79
121
|
isConnected() {
|
|
80
|
-
return
|
|
81
|
-
}
|
|
82
|
-
async getIntent(intentId) {
|
|
83
|
-
return this.intents.get(intentId);
|
|
84
|
-
}
|
|
85
|
-
async getIntentByName(intentName) {
|
|
86
|
-
return Array.from(this.intents.values()).find((intent) => intent.name === intentName);
|
|
87
|
-
}
|
|
88
|
-
async saveIntent(intent) {
|
|
89
|
-
const newId = randomUUID();
|
|
90
|
-
this.intents.set(newId, intent);
|
|
122
|
+
return this.connected;
|
|
91
123
|
}
|
|
92
|
-
|
|
93
|
-
this.
|
|
124
|
+
getAgentMemory() {
|
|
125
|
+
return this.agentMemory;
|
|
94
126
|
}
|
|
95
|
-
|
|
96
|
-
this.
|
|
127
|
+
getThreadMemory() {
|
|
128
|
+
return this.threadMemory;
|
|
97
129
|
}
|
|
98
|
-
|
|
99
|
-
return
|
|
130
|
+
getIntentMemory() {
|
|
131
|
+
return this.intentMemory;
|
|
100
132
|
}
|
|
101
133
|
};
|
|
102
134
|
export {
|
|
103
|
-
|
|
104
|
-
InMemoryThread
|
|
135
|
+
InMemoryMemory
|
|
105
136
|
};
|
|
106
137
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../implements/
|
|
1
|
+
{"version":3,"sources":["../implements/agent.memory.ts","../implements/intent.memory.ts","../implements/thread.memory.ts","../implements/base.memory.ts"],"sourcesContent":["import { IAgentMemory } from \"@ainetwork/adk/modules\";\n\nexport class InMemoryAgent implements IAgentMemory {\n private prompt: string = \"\";\n\n public async getAgentPrompt(): Promise<string> {\n return this.prompt;\n }\n\n public async updateAgentPrompt(prompt: string): Promise<void> {\n this.prompt = prompt;\n }\n}\n","import { randomUUID } from \"node:crypto\";\nimport type { Intent } from \"@ainetwork/adk/types/memory\";\nimport { IIntentMemory } from \"@ainetwork/adk/modules\";\n\nexport class InMemoryIntent implements IIntentMemory {\n public intents: Map<string, Intent> = new Map();\n\n public async getIntent(intentId: string): Promise<Intent | undefined> {\n return this.intents.get(intentId);\n }\n\n public async getIntentByName(intentName: string): Promise<Intent | undefined> {\n return Array.from(this.intents.values()).find(intent => intent.name === intentName);\n }\n\n public async saveIntent(intent: Intent): Promise<void> {\n const newId = randomUUID();\n this.intents.set(newId, intent);\n }\n\n public async updateIntent(intentId: string, intent: Intent): Promise<void> {\n this.intents.set(intentId, intent);\n }\n\n public async deleteIntent(intentId: string): Promise<void> {\n this.intents.delete(intentId);\n }\n\n public async listIntents(): Promise<Intent[]> {\n return Array.from(this.intents.values());\n }\n}","import type { MessageObject, ThreadObject, ThreadMetadata, ThreadType } from \"@ainetwork/adk/types/memory\";\nimport { IThreadMemory } from \"@ainetwork/adk/modules\";\n\ntype InMemoryThreadObject = {\n type: ThreadType;\n title: string;\n messages: Array<MessageObject>;\n}\n\ntype InMemoryThreadMetadata = {\n type: ThreadType;\n userId: string;\n threadId: string;\n title: string;\n updatedAt: number;\n createdAt: number;\n}\n\nexport class InMemoryThread implements IThreadMemory {\n public threads: Map<string, InMemoryThreadObject> = new Map();\n public userThreadIndex: Map<string, Set<InMemoryThreadMetadata>> = new Map();\n\n private generateKey(userId: string, threadId: string) {\n return `${userId}:${threadId}`;\n }\n\n public async getThread(\n userId: string,\n threadId: string\n ): Promise<ThreadObject | undefined> {\n const key = this.generateKey(userId, threadId);\n const res = this.threads.get(key);\n if (res) {\n const threadObject: ThreadObject = {\n threadId,\n userId,\n type: res.type,\n title: res.title,\n messages: res.messages,\n };\n return threadObject;\n }\n return undefined;\n }\n\n public async createThread(\n type: ThreadType,\n userId: string,\n threadId: string,\n title: string\n ): Promise<ThreadObject> {\n const now = Date.now();\n const key = this.generateKey(userId, threadId);\n if (!this.userThreadIndex.has(userId)) {\n this.userThreadIndex.set(userId, new Set());\n }\n if (!this.threads.has(key)) {\n this.threads.set(key, { type, title, messages: [] });\n const metadata: InMemoryThreadMetadata = {\n type, userId, threadId, title, createdAt: now, updatedAt: now,\n }\n this.userThreadIndex.get(userId)?.add(metadata);\n }\n\n return { type, title, threadId, userId, messages: [] };\n }\n\n public async addMessagesToThread(\n userId: string,\n threadId: string,\n messages: MessageObject[]\n ): Promise<void> {\n const key = this.generateKey(userId, threadId);\n const thread = this.threads.get(key);\n for (const message of messages) {\n thread?.messages.push(message);\n }\n }\n\n public async deleteThread(userId: string, threadId: string): Promise<void> {\n const key = this.generateKey(userId, threadId);\n this.threads.delete(key);\n this.userThreadIndex.delete(threadId);\n }\n\n public async listThreads(userId: string): Promise<ThreadMetadata[]> {\n const threads = this.userThreadIndex.get(userId);\n if (threads) {\n return Array.from(threads);\n }\n return [];\n }\n}","import { IAgentMemory, IIntentMemory, IMemory, IThreadMemory } from \"node_modules/@ainetwork/adk/dist/esm/modules/memory/base.memory\";\nimport { InMemoryAgent } from \"./agent.memory\";\nimport { InMemoryIntent } from \"./intent.memory\";\nimport { InMemoryThread } from \"./thread.memory\";\n\nexport class InMemoryMemory implements IMemory {\n private static instance: InMemoryMemory;\n private connected: boolean = false;\n\n private agentMemory: InMemoryAgent;\n private intentMemory: InMemoryIntent;\n private threadMemory: InMemoryThread;\n\n constructor() {\n if (!InMemoryMemory.instance) {\n InMemoryMemory.instance = this;\n }\n\n this.agentMemory = new InMemoryAgent();\n this.threadMemory = new InMemoryThread();\n this.intentMemory = new InMemoryIntent();\n }\n\n public async connect(): Promise<void> {\n this.connected = true;\n }\n\n public async disconnect(): Promise<void> {\n this.connected = false;\n }\n\n public isConnected(): boolean {\n return this.connected;\n }\n\n public getAgentMemory(): IAgentMemory {\n return this.agentMemory;\n }\n\n public getThreadMemory(): IThreadMemory {\n return this.threadMemory;\n }\n\n public getIntentMemory(): IIntentMemory {\n return this.intentMemory;\n }\n}\n"],"mappings":";AAEO,IAAM,gBAAN,MAA4C;AAAA,EACzC,SAAiB;AAAA,EAEzB,MAAa,iBAAkC;AAC7C,WAAO,KAAK;AAAA,EACd;AAAA,EAEA,MAAa,kBAAkB,QAA+B;AAC5D,SAAK,SAAS;AAAA,EAChB;AACF;;;ACZA,SAAS,kBAAkB;AAIpB,IAAM,iBAAN,MAA8C;AAAA,EAC5C,UAA+B,oBAAI,IAAI;AAAA,EAE9C,MAAa,UAAU,UAA+C;AACpE,WAAO,KAAK,QAAQ,IAAI,QAAQ;AAAA,EAClC;AAAA,EAEA,MAAa,gBAAgB,YAAiD;AAC5E,WAAO,MAAM,KAAK,KAAK,QAAQ,OAAO,CAAC,EAAE,KAAK,YAAU,OAAO,SAAS,UAAU;AAAA,EACpF;AAAA,EAEA,MAAa,WAAW,QAA+B;AACrD,UAAM,QAAQ,WAAW;AACzB,SAAK,QAAQ,IAAI,OAAO,MAAM;AAAA,EAChC;AAAA,EAEA,MAAa,aAAa,UAAkB,QAA+B;AACzE,SAAK,QAAQ,IAAI,UAAU,MAAM;AAAA,EACnC;AAAA,EAEA,MAAa,aAAa,UAAiC;AACzD,S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
|
3
|
+
export class InMemoryAgent implements IAgentMemory {
|
|
4
|
+
private prompt: string = "";
|
|
5
|
+
|
|
6
|
+
public async getAgentPrompt(): Promise<string> {
|
|
7
|
+
return this.prompt;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
public async updateAgentPrompt(prompt: string): Promise<void> {
|
|
11
|
+
this.prompt = prompt;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { IAgentMemory, IIntentMemory, IMemory, IThreadMemory } from "node_modules/@ainetwork/adk/dist/esm/modules/memory/base.memory";
|
|
2
|
+
import { InMemoryAgent } from "./agent.memory";
|
|
3
|
+
import { InMemoryIntent } from "./intent.memory";
|
|
4
|
+
import { InMemoryThread } from "./thread.memory";
|
|
5
|
+
|
|
6
|
+
export class InMemoryMemory implements IMemory {
|
|
7
|
+
private static instance: InMemoryMemory;
|
|
8
|
+
private connected: boolean = false;
|
|
9
|
+
|
|
10
|
+
private agentMemory: InMemoryAgent;
|
|
11
|
+
private intentMemory: InMemoryIntent;
|
|
12
|
+
private threadMemory: InMemoryThread;
|
|
13
|
+
|
|
14
|
+
constructor() {
|
|
15
|
+
if (!InMemoryMemory.instance) {
|
|
16
|
+
InMemoryMemory.instance = this;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
this.agentMemory = new InMemoryAgent();
|
|
20
|
+
this.threadMemory = new InMemoryThread();
|
|
21
|
+
this.intentMemory = new InMemoryIntent();
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
public async connect(): Promise<void> {
|
|
25
|
+
this.connected = true;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
public async disconnect(): Promise<void> {
|
|
29
|
+
this.connected = false;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
public isConnected(): boolean {
|
|
33
|
+
return this.connected;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
public getAgentMemory(): IAgentMemory {
|
|
37
|
+
return this.agentMemory;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
public getThreadMemory(): IThreadMemory {
|
|
41
|
+
return this.threadMemory;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
public getIntentMemory(): IIntentMemory {
|
|
45
|
+
return this.intentMemory;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
@@ -3,36 +3,30 @@ import type { Intent } from "@ainetwork/adk/types/memory";
|
|
|
3
3
|
import { IIntentMemory } from "@ainetwork/adk/modules";
|
|
4
4
|
|
|
5
5
|
export class InMemoryIntent implements IIntentMemory {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
public async connect(): Promise<void> {}
|
|
9
|
-
public async disconnect(): Promise<void> {}
|
|
10
|
-
public isConnected(): boolean {
|
|
11
|
-
return true;
|
|
12
|
-
}
|
|
6
|
+
public intents: Map<string, Intent> = new Map();
|
|
13
7
|
|
|
14
8
|
public async getIntent(intentId: string): Promise<Intent | undefined> {
|
|
15
9
|
return this.intents.get(intentId);
|
|
16
|
-
}
|
|
10
|
+
}
|
|
17
11
|
|
|
18
12
|
public async getIntentByName(intentName: string): Promise<Intent | undefined> {
|
|
19
13
|
return Array.from(this.intents.values()).find(intent => intent.name === intentName);
|
|
20
|
-
}
|
|
14
|
+
}
|
|
21
15
|
|
|
22
|
-
|
|
16
|
+
public async saveIntent(intent: Intent): Promise<void> {
|
|
23
17
|
const newId = randomUUID();
|
|
24
18
|
this.intents.set(newId, intent);
|
|
25
|
-
}
|
|
19
|
+
}
|
|
26
20
|
|
|
27
|
-
|
|
21
|
+
public async updateIntent(intentId: string, intent: Intent): Promise<void> {
|
|
28
22
|
this.intents.set(intentId, intent);
|
|
29
|
-
}
|
|
23
|
+
}
|
|
30
24
|
|
|
31
|
-
|
|
25
|
+
public async deleteIntent(intentId: string): Promise<void> {
|
|
32
26
|
this.intents.delete(intentId);
|
|
33
|
-
}
|
|
27
|
+
}
|
|
34
28
|
|
|
35
|
-
|
|
29
|
+
public async listIntents(): Promise<Intent[]> {
|
|
36
30
|
return Array.from(this.intents.values());
|
|
37
|
-
}
|
|
31
|
+
}
|
|
38
32
|
}
|
|
@@ -17,15 +17,9 @@ type InMemoryThreadMetadata = {
|
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
export class InMemoryThread implements IThreadMemory {
|
|
20
|
-
|
|
20
|
+
public threads: Map<string, InMemoryThreadObject> = new Map();
|
|
21
21
|
public userThreadIndex: Map<string, Set<InMemoryThreadMetadata>> = new Map();
|
|
22
22
|
|
|
23
|
-
public async connect(): Promise<void> {}
|
|
24
|
-
public async disconnect(): Promise<void> {}
|
|
25
|
-
public isConnected(): boolean {
|
|
26
|
-
return true;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
23
|
private generateKey(userId: string, threadId: string) {
|
|
30
24
|
return `${userId}:${threadId}`;
|
|
31
25
|
}
|
|
@@ -47,9 +41,9 @@ export class InMemoryThread implements IThreadMemory {
|
|
|
47
41
|
return threadObject;
|
|
48
42
|
}
|
|
49
43
|
return undefined;
|
|
50
|
-
}
|
|
44
|
+
}
|
|
51
45
|
|
|
52
|
-
|
|
46
|
+
public async createThread(
|
|
53
47
|
type: ThreadType,
|
|
54
48
|
userId: string,
|
|
55
49
|
threadId: string,
|
|
@@ -69,9 +63,9 @@ export class InMemoryThread implements IThreadMemory {
|
|
|
69
63
|
}
|
|
70
64
|
|
|
71
65
|
return { type, title, threadId, userId, messages: [] };
|
|
72
|
-
}
|
|
66
|
+
}
|
|
73
67
|
|
|
74
|
-
|
|
68
|
+
public async addMessagesToThread(
|
|
75
69
|
userId: string,
|
|
76
70
|
threadId: string,
|
|
77
71
|
messages: MessageObject[]
|
|
@@ -81,19 +75,19 @@ export class InMemoryThread implements IThreadMemory {
|
|
|
81
75
|
for (const message of messages) {
|
|
82
76
|
thread?.messages.push(message);
|
|
83
77
|
}
|
|
84
|
-
}
|
|
78
|
+
}
|
|
85
79
|
|
|
86
|
-
|
|
80
|
+
public async deleteThread(userId: string, threadId: string): Promise<void> {
|
|
87
81
|
const key = this.generateKey(userId, threadId);
|
|
88
82
|
this.threads.delete(key);
|
|
89
83
|
this.userThreadIndex.delete(threadId);
|
|
90
|
-
}
|
|
84
|
+
}
|
|
91
85
|
|
|
92
|
-
|
|
86
|
+
public async listThreads(userId: string): Promise<ThreadMetadata[]> {
|
|
93
87
|
const threads = this.userThreadIndex.get(userId);
|
|
94
88
|
if (threads) {
|
|
95
89
|
return Array.from(threads);
|
|
96
90
|
}
|
|
97
91
|
return [];
|
|
98
|
-
}
|
|
92
|
+
}
|
|
99
93
|
}
|
package/index.ts
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export { InMemoryIntent } from "./implements/intent.memory";
|
|
1
|
+
export { InMemoryMemory } from "./implements/base.memory";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ainetwork/adk-provider-memory-inmemory",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"author": "AI Network (https://ainetwork.ai)",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"engines": {
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"clean": "rm -rf dist"
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@ainetwork/adk": "0.
|
|
24
|
+
"@ainetwork/adk": "^0.3.0"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
27
|
"typescript": "^5.0.0"
|
|
@@ -30,5 +30,5 @@
|
|
|
30
30
|
"publishConfig": {
|
|
31
31
|
"access": "public"
|
|
32
32
|
},
|
|
33
|
-
"gitHead": "
|
|
33
|
+
"gitHead": "77a4f8c8bb228f45383eea93f153c21bac3f8b3b"
|
|
34
34
|
}
|