@ainetwork/adk-provider-memory-inmemory 0.1.1

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 ADDED
@@ -0,0 +1,50 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // index.ts
21
+ var index_exports = {};
22
+ __export(index_exports, {
23
+ InMemoryMemory: () => InMemoryMemory
24
+ });
25
+ module.exports = __toCommonJS(index_exports);
26
+ var import_node_crypto = require("crypto");
27
+ var import_modules = require("@ainetwork/adk/modules");
28
+ var InMemoryMemory = class extends import_modules.BaseMemory {
29
+ sessionHistory;
30
+ constructor() {
31
+ super();
32
+ this.sessionHistory = /* @__PURE__ */ new Map();
33
+ }
34
+ async getSessionHistory(sessionId) {
35
+ return this.sessionHistory.get(sessionId) || { chats: {} };
36
+ }
37
+ async updateSessionHistory(sessionId, chat) {
38
+ const newChatId = (0, import_node_crypto.randomUUID)();
39
+ const history = await this.getSessionHistory(sessionId);
40
+ history.chats[newChatId] = chat;
41
+ this.sessionHistory.set(sessionId, history);
42
+ }
43
+ async storeQueryAndIntent(query, intent, sessionId) {
44
+ }
45
+ };
46
+ // Annotate the CommonJS export names for ESM import in node:
47
+ 0 && (module.exports = {
48
+ InMemoryMemory
49
+ });
50
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../index.ts"],"sourcesContent":["import { randomUUID } from \"node:crypto\";\nimport type { ChatObject, SessionObject } from \"@ainetwork/adk/types/memory\";\nimport { BaseMemory } from \"@ainetwork/adk/modules\";\n\nexport class InMemoryMemory extends BaseMemory {\n\tpublic sessionHistory: Map<string, SessionObject>;\n\n\tconstructor() {\n\t\tsuper();\n\t\tthis.sessionHistory = new Map<string, SessionObject>();\n\t}\n\n\tpublic async getSessionHistory(sessionId: string): Promise<SessionObject> {\n\t\treturn this.sessionHistory.get(sessionId) || { chats: {} };\n\t}\n\n\tpublic async updateSessionHistory(\n\t\tsessionId: string,\n\t\tchat: ChatObject,\n\t): Promise<void> {\n\t\tconst newChatId = randomUUID();\n\t\tconst history = await this.getSessionHistory(sessionId);\n\t\thistory.chats[newChatId] = chat;\n\t\tthis.sessionHistory.set(sessionId, history);\n\t}\n\n\tpublic async storeQueryAndIntent(\n\t\tquery: string,\n\t\tintent: string,\n\t\tsessionId: string,\n\t) {}\n}"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,yBAA2B;AAE3B,qBAA2B;AAEpB,IAAM,iBAAN,cAA6B,0BAAW;AAAA,EACvC;AAAA,EAEP,cAAc;AACb,UAAM;AACN,SAAK,iBAAiB,oBAAI,IAA2B;AAAA,EACtD;AAAA,EAEA,MAAa,kBAAkB,WAA2C;AACzE,WAAO,KAAK,eAAe,IAAI,SAAS,KAAK,EAAE,OAAO,CAAC,EAAE;AAAA,EAC1D;AAAA,EAEA,MAAa,qBACZ,WACA,MACgB;AAChB,UAAM,gBAAY,+BAAW;AAC7B,UAAM,UAAU,MAAM,KAAK,kBAAkB,SAAS;AACtD,YAAQ,MAAM,SAAS,IAAI;AAC3B,SAAK,eAAe,IAAI,WAAW,OAAO;AAAA,EAC3C;AAAA,EAEA,MAAa,oBACZ,OACA,QACA,WACC;AAAA,EAAC;AACJ;","names":[]}
@@ -0,0 +1,12 @@
1
+ import { SessionObject, ChatObject } from '@ainetwork/adk/types/memory';
2
+ import { BaseMemory } from '@ainetwork/adk/modules';
3
+
4
+ declare class InMemoryMemory extends BaseMemory {
5
+ sessionHistory: Map<string, SessionObject>;
6
+ constructor();
7
+ getSessionHistory(sessionId: string): Promise<SessionObject>;
8
+ updateSessionHistory(sessionId: string, chat: ChatObject): Promise<void>;
9
+ storeQueryAndIntent(query: string, intent: string, sessionId: string): Promise<void>;
10
+ }
11
+
12
+ export { InMemoryMemory };
@@ -0,0 +1,12 @@
1
+ import { SessionObject, ChatObject } from '@ainetwork/adk/types/memory';
2
+ import { BaseMemory } from '@ainetwork/adk/modules';
3
+
4
+ declare class InMemoryMemory extends BaseMemory {
5
+ sessionHistory: Map<string, SessionObject>;
6
+ constructor();
7
+ getSessionHistory(sessionId: string): Promise<SessionObject>;
8
+ updateSessionHistory(sessionId: string, chat: ChatObject): Promise<void>;
9
+ storeQueryAndIntent(query: string, intent: string, sessionId: string): Promise<void>;
10
+ }
11
+
12
+ export { InMemoryMemory };
package/dist/index.js ADDED
@@ -0,0 +1,25 @@
1
+ // index.ts
2
+ import { randomUUID } from "crypto";
3
+ import { BaseMemory } from "@ainetwork/adk/modules";
4
+ var InMemoryMemory = class extends BaseMemory {
5
+ sessionHistory;
6
+ constructor() {
7
+ super();
8
+ this.sessionHistory = /* @__PURE__ */ new Map();
9
+ }
10
+ async getSessionHistory(sessionId) {
11
+ return this.sessionHistory.get(sessionId) || { chats: {} };
12
+ }
13
+ async updateSessionHistory(sessionId, chat) {
14
+ const newChatId = randomUUID();
15
+ const history = await this.getSessionHistory(sessionId);
16
+ history.chats[newChatId] = chat;
17
+ this.sessionHistory.set(sessionId, history);
18
+ }
19
+ async storeQueryAndIntent(query, intent, sessionId) {
20
+ }
21
+ };
22
+ export {
23
+ InMemoryMemory
24
+ };
25
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../index.ts"],"sourcesContent":["import { randomUUID } from \"node:crypto\";\nimport type { ChatObject, SessionObject } from \"@ainetwork/adk/types/memory\";\nimport { BaseMemory } from \"@ainetwork/adk/modules\";\n\nexport class InMemoryMemory extends BaseMemory {\n\tpublic sessionHistory: Map<string, SessionObject>;\n\n\tconstructor() {\n\t\tsuper();\n\t\tthis.sessionHistory = new Map<string, SessionObject>();\n\t}\n\n\tpublic async getSessionHistory(sessionId: string): Promise<SessionObject> {\n\t\treturn this.sessionHistory.get(sessionId) || { chats: {} };\n\t}\n\n\tpublic async updateSessionHistory(\n\t\tsessionId: string,\n\t\tchat: ChatObject,\n\t): Promise<void> {\n\t\tconst newChatId = randomUUID();\n\t\tconst history = await this.getSessionHistory(sessionId);\n\t\thistory.chats[newChatId] = chat;\n\t\tthis.sessionHistory.set(sessionId, history);\n\t}\n\n\tpublic async storeQueryAndIntent(\n\t\tquery: string,\n\t\tintent: string,\n\t\tsessionId: string,\n\t) {}\n}"],"mappings":";AAAA,SAAS,kBAAkB;AAE3B,SAAS,kBAAkB;AAEpB,IAAM,iBAAN,cAA6B,WAAW;AAAA,EACvC;AAAA,EAEP,cAAc;AACb,UAAM;AACN,SAAK,iBAAiB,oBAAI,IAA2B;AAAA,EACtD;AAAA,EAEA,MAAa,kBAAkB,WAA2C;AACzE,WAAO,KAAK,eAAe,IAAI,SAAS,KAAK,EAAE,OAAO,CAAC,EAAE;AAAA,EAC1D;AAAA,EAEA,MAAa,qBACZ,WACA,MACgB;AAChB,UAAM,YAAY,WAAW;AAC7B,UAAM,UAAU,MAAM,KAAK,kBAAkB,SAAS;AACtD,YAAQ,MAAM,SAAS,IAAI;AAC3B,SAAK,eAAe,IAAI,WAAW,OAAO;AAAA,EAC3C;AAAA,EAEA,MAAa,oBACZ,OACA,QACA,WACC;AAAA,EAAC;AACJ;","names":[]}
package/index.ts ADDED
@@ -0,0 +1,32 @@
1
+ import { randomUUID } from "node:crypto";
2
+ import type { ChatObject, SessionObject } from "@ainetwork/adk/types/memory";
3
+ import { BaseMemory } from "@ainetwork/adk/modules";
4
+
5
+ export class InMemoryMemory extends BaseMemory {
6
+ public sessionHistory: Map<string, SessionObject>;
7
+
8
+ constructor() {
9
+ super();
10
+ this.sessionHistory = new Map<string, SessionObject>();
11
+ }
12
+
13
+ public async getSessionHistory(sessionId: string): Promise<SessionObject> {
14
+ return this.sessionHistory.get(sessionId) || { chats: {} };
15
+ }
16
+
17
+ public async updateSessionHistory(
18
+ sessionId: string,
19
+ chat: ChatObject,
20
+ ): Promise<void> {
21
+ const newChatId = randomUUID();
22
+ const history = await this.getSessionHistory(sessionId);
23
+ history.chats[newChatId] = chat;
24
+ this.sessionHistory.set(sessionId, history);
25
+ }
26
+
27
+ public async storeQueryAndIntent(
28
+ query: string,
29
+ intent: string,
30
+ sessionId: string,
31
+ ) {}
32
+ }
package/package.json ADDED
@@ -0,0 +1,34 @@
1
+ {
2
+ "name": "@ainetwork/adk-provider-memory-inmemory",
3
+ "version": "0.1.1",
4
+ "author": "AI Network (https://ainetwork.ai)",
5
+ "type": "module",
6
+ "engines": {
7
+ "node": ">=20"
8
+ },
9
+ "main": "./dist/index.cjs",
10
+ "module": "./dist/index.js",
11
+ "types": "./dist/index.d.ts",
12
+ "exports": {
13
+ ".": {
14
+ "types": "./dist/index.d.ts",
15
+ "import": "./dist/index.js",
16
+ "require": "./dist/index.cjs"
17
+ }
18
+ },
19
+ "scripts": {
20
+ "build": "tsup",
21
+ "clean": "rm -rf dist"
22
+ },
23
+ "dependencies": {
24
+ "@ainetwork/adk": "^0.1.2"
25
+ },
26
+ "devDependencies": {
27
+ "typescript": "^5.0.0"
28
+ },
29
+ "license": "MIT",
30
+ "publishConfig": {
31
+ "access": "public"
32
+ },
33
+ "gitHead": "cb6205738fd84533ce56bbeeab00ea9dfe2aaf3a"
34
+ }
package/tsconfig.json ADDED
@@ -0,0 +1,9 @@
1
+ {
2
+ "extends": "../../../tsconfig.json",
3
+ "compilerOptions": {
4
+ "outDir": "./dist",
5
+ "rootDir": ".",
6
+ },
7
+ "include": ["index.ts", "models/**/*.ts"],
8
+ "exclude": ["node_modules", "dist"]
9
+ }
package/tsup.config.ts ADDED
@@ -0,0 +1,9 @@
1
+ import { defineConfig } from 'tsup'
2
+
3
+ export default defineConfig({
4
+ entry: ['index.ts', 'models/**/*.ts'],
5
+ format: ['cjs', 'esm'],
6
+ dts: true,
7
+ sourcemap: true,
8
+ clean: true,
9
+ })