@ainetwork/adk-provider-memory-inmemory 0.3.6 → 0.4.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 CHANGED
@@ -26,12 +26,40 @@ module.exports = __toCommonJS(index_exports);
26
26
 
27
27
  // implements/agent.memory.ts
28
28
  var InMemoryAgent = class {
29
- prompt = "";
29
+ agentPrompt = "";
30
+ aggregatePrompt = "";
31
+ generateTitlePrompt = "";
32
+ singleTriggerPrompt = "";
33
+ multiTriggerPrompt = "";
34
+ toolSelectPrompt = "";
35
+ piiDetectPrompt = "";
36
+ piiFilterPrompt = "";
30
37
  async getAgentPrompt() {
31
- return this.prompt;
38
+ return this.agentPrompt;
32
39
  }
33
40
  async updateAgentPrompt(prompt) {
34
- this.prompt = prompt;
41
+ this.agentPrompt = prompt;
42
+ }
43
+ async getAggregatePrompt() {
44
+ return this.aggregatePrompt;
45
+ }
46
+ async getGenerateTitlePrompt() {
47
+ return this.generateTitlePrompt;
48
+ }
49
+ async getSingleTriggerPrompt() {
50
+ return this.singleTriggerPrompt;
51
+ }
52
+ async getMultiTriggerPrompt() {
53
+ return this.multiTriggerPrompt;
54
+ }
55
+ async getToolSelectPrompt() {
56
+ return this.toolSelectPrompt;
57
+ }
58
+ async getPIIDetectPrompt() {
59
+ return this.piiDetectPrompt;
60
+ }
61
+ async getPIIFilterPrompt() {
62
+ return this.piiFilterPrompt;
35
63
  }
36
64
  };
37
65
 
@@ -1 +1 @@
1
- {"version":3,"sources":["../index.ts","../implements/agent.memory.ts","../implements/intent.memory.ts","../implements/thread.memory.ts","../implements/workflow.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 // Intent에 이미 id가 있으면 그것을 사용하고, 없으면 새로 생성\n const intentId = intent.id || randomUUID();\n const intentToSave = { ...intent, id: intentId };\n this.intents.set(intentId, intentToSave);\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\n // userThreadIndex에서 해당 thread metadata 제거\n const userThreads = this.userThreadIndex.get(userId);\n if (userThreads) {\n const metadataToDelete = Array.from(userThreads).find(\n metadata => metadata.threadId === threadId\n );\n if (metadataToDelete) {\n userThreads.delete(metadataToDelete);\n }\n }\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 { IWorkflowMemory } from \"@ainetwork/adk/modules\";\nimport type { Workflow } from \"@ainetwork/adk/types/memory\";\n\nexport class InMemoryWorkflow implements IWorkflowMemory {\n private workflows: Map<string, Workflow> = new Map();\n private userWorkflowIndex: Map<string, Set<string>> = new Map();\n\n public async createWorkflow(workflow: Workflow): Promise<Workflow> {\n this.workflows.set(workflow.workflowId, workflow);\n\n if (workflow.userId) {\n if (!this.userWorkflowIndex.has(workflow.userId)) {\n this.userWorkflowIndex.set(workflow.userId, new Set());\n }\n this.userWorkflowIndex.get(workflow.userId)?.add(workflow.workflowId);\n }\n\n return workflow;\n }\n\n public async getWorkflow(workflowId: string): Promise<Workflow | undefined> {\n return this.workflows.get(workflowId);\n }\n\n public async updateWorkflow(workflowId: string, updates: Partial<Workflow>): Promise<void> {\n if (!updates.userId) {\n throw new Error(\"userId is required for updateWorkflow\");\n }\n\n const existing = this.workflows.get(workflowId);\n if (!existing) {\n throw new Error(`Workflow not found: ${workflowId}`);\n }\n\n if (existing.userId !== updates.userId) {\n throw new Error(\"Unauthorized: userId does not match workflow owner\");\n }\n\n const updated = { ...existing, ...updates, workflowId };\n this.workflows.set(workflowId, updated);\n }\n\n public async deleteWorkflow(workflowId: string, userId: string): Promise<void> {\n const workflow = this.workflows.get(workflowId);\n if (workflow && workflow.userId === userId) {\n this.workflows.delete(workflowId);\n this.userWorkflowIndex.get(userId)?.delete(workflowId);\n }\n }\n\n public async listWorkflows(userId?: string): Promise<Workflow[]> {\n const workflows: Workflow[] = [];\n\n // 템플릿 workflow (userId가 없는 것)은 항상 포함\n for (const workflow of this.workflows.values()) {\n if (!workflow.userId) {\n workflows.push(workflow);\n }\n }\n\n // userId가 있으면 해당 유저 소유 workflow도 포함\n if (userId) {\n const userWorkflowIds = this.userWorkflowIndex.get(userId);\n if (userWorkflowIds) {\n for (const workflowId of userWorkflowIds) {\n const workflow = this.workflows.get(workflowId);\n if (workflow) {\n workflows.push(workflow);\n }\n }\n }\n }\n\n return workflows;\n }\n}\n","import { IAgentMemory, IIntentMemory, IMemory, IThreadMemory, IWorkflowMemory } from \"@ainetwork/adk/modules\";\nimport { InMemoryAgent } from \"./agent.memory\";\nimport { InMemoryIntent } from \"./intent.memory\";\nimport { InMemoryThread } from \"./thread.memory\";\nimport { InMemoryWorkflow } from \"./workflow.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 private workflowMemory: InMemoryWorkflow;\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 this.workflowMemory = new InMemoryWorkflow();\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 public getWorkflowMemory(): IWorkflowMemory {\n return this.workflowMemory;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACEO,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,yBAA2B;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;AAErD,UAAM,WAAW,OAAO,UAAM,+BAAW;AACzC,UAAM,eAAe,EAAE,GAAG,QAAQ,IAAI,SAAS;AAC/C,SAAK,QAAQ,IAAI,UAAU,YAAY;AAAA,EACzC;AAAA,EAEA,MAAa,aAAa,UAAkB,QAA+B;AACzE,SAAK,QAAQ,IAAI,UAAU,MAAM;AAAA,EACnC;AAAA,EAEA,MAAa,aAAa,UAAiC;AACzD,SAAK,QAAQ,OAAO,QAAQ;A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e,UAAU;AAC5B,sBAAe,WAAW;AAAA,IAC5B;AAEA,SAAK,cAAc,IAAI,cAAc;AACrC,SAAK,eAAe,IAAI,eAAe;AACvC,SAAK,eAAe,IAAI,eAAe;AACvC,SAAK,iBAAiB,IAAI,iBAAiB;AAAA,EAC7C;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;AAAA,EAEO,oBAAqC;AAC1C,WAAO,KAAK;AAAA,EACd;AACF;","names":[]}
1
+ {"version":3,"sources":["../index.ts","../implements/agent.memory.ts","../implements/intent.memory.ts","../implements/thread.memory.ts","../implements/workflow.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 agentPrompt: string = \"\";\n private aggregatePrompt: string = \"\";\n private generateTitlePrompt: string = \"\";\n private singleTriggerPrompt: string = \"\";\n private multiTriggerPrompt: string = \"\";\n private toolSelectPrompt: string = \"\";\n private piiDetectPrompt: string = \"\";\n private piiFilterPrompt: string = \"\";\n\n public async getAgentPrompt(): Promise<string> {\n return this.agentPrompt;\n }\n\n public async updateAgentPrompt(prompt: string): Promise<void> {\n this.agentPrompt = prompt;\n }\n\n public async getAggregatePrompt(): Promise<string> {\n return this.aggregatePrompt;\n }\n\n public async getGenerateTitlePrompt(): Promise<string> {\n return this.generateTitlePrompt;\n }\n\n public async getSingleTriggerPrompt(): Promise<string> {\n return this.singleTriggerPrompt;\n }\n\n public async getMultiTriggerPrompt(): Promise<string> {\n return this.multiTriggerPrompt;\n }\n\n public async getToolSelectPrompt(): Promise<string> {\n return this.toolSelectPrompt;\n }\n\n public async getPIIDetectPrompt(): Promise<string> {\n return this.piiDetectPrompt;\n }\n\n public async getPIIFilterPrompt(): Promise<string> {\n return this.piiFilterPrompt;\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 // Intent에 이미 id가 있으면 그것을 사용하고, 없으면 새로 생성\n const intentId = intent.id || randomUUID();\n const intentToSave = { ...intent, id: intentId };\n this.intents.set(intentId, intentToSave);\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\n // userThreadIndex에서 해당 thread metadata 제거\n const userThreads = this.userThreadIndex.get(userId);\n if (userThreads) {\n const metadataToDelete = Array.from(userThreads).find(\n metadata => metadata.threadId === threadId\n );\n if (metadataToDelete) {\n userThreads.delete(metadataToDelete);\n }\n }\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 { IWorkflowMemory } from \"@ainetwork/adk/modules\";\nimport type { Workflow } from \"@ainetwork/adk/types/memory\";\n\nexport class InMemoryWorkflow implements IWorkflowMemory {\n private workflows: Map<string, Workflow> = new Map();\n private userWorkflowIndex: Map<string, Set<string>> = new Map();\n\n public async createWorkflow(workflow: Workflow): Promise<Workflow> {\n this.workflows.set(workflow.workflowId, workflow);\n\n if (workflow.userId) {\n if (!this.userWorkflowIndex.has(workflow.userId)) {\n this.userWorkflowIndex.set(workflow.userId, new Set());\n }\n this.userWorkflowIndex.get(workflow.userId)?.add(workflow.workflowId);\n }\n\n return workflow;\n }\n\n public async getWorkflow(workflowId: string): Promise<Workflow | undefined> {\n return this.workflows.get(workflowId);\n }\n\n public async updateWorkflow(workflowId: string, updates: Partial<Workflow>): Promise<void> {\n if (!updates.userId) {\n throw new Error(\"userId is required for updateWorkflow\");\n }\n\n const existing = this.workflows.get(workflowId);\n if (!existing) {\n throw new Error(`Workflow not found: ${workflowId}`);\n }\n\n if (existing.userId !== updates.userId) {\n throw new Error(\"Unauthorized: userId does not match workflow owner\");\n }\n\n const updated = { ...existing, ...updates, workflowId };\n this.workflows.set(workflowId, updated);\n }\n\n public async deleteWorkflow(workflowId: string, userId: string): Promise<void> {\n const workflow = this.workflows.get(workflowId);\n if (workflow && workflow.userId === userId) {\n this.workflows.delete(workflowId);\n this.userWorkflowIndex.get(userId)?.delete(workflowId);\n }\n }\n\n public async listWorkflows(userId?: string): Promise<Workflow[]> {\n const workflows: Workflow[] = [];\n\n // 템플릿 workflow (userId가 없는 것)은 항상 포함\n for (const workflow of this.workflows.values()) {\n if (!workflow.userId) {\n workflows.push(workflow);\n }\n }\n\n // userId가 있으면 해당 유저 소유 workflow도 포함\n if (userId) {\n const userWorkflowIds = this.userWorkflowIndex.get(userId);\n if (userWorkflowIds) {\n for (const workflowId of userWorkflowIds) {\n const workflow = this.workflows.get(workflowId);\n if (workflow) {\n workflows.push(workflow);\n }\n }\n }\n }\n\n return workflows;\n }\n}\n","import { IAgentMemory, IIntentMemory, IMemory, IThreadMemory, IWorkflowMemory } from \"@ainetwork/adk/modules\";\nimport { InMemoryAgent } from \"./agent.memory\";\nimport { InMemoryIntent } from \"./intent.memory\";\nimport { InMemoryThread } from \"./thread.memory\";\nimport { InMemoryWorkflow } from \"./workflow.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 private workflowMemory: InMemoryWorkflow;\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 this.workflowMemory = new InMemoryWorkflow();\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 public getWorkflowMemory(): IWorkflowMemory {\n return this.workflowMemory;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACEO,IAAM,gBAAN,MAA4C;AAAA,EACzC,cAAsB;AAAA,EACtB,kBAA0B;AAAA,EAC1B,sBAA8B;AAAA,EAC9B,sBAA8B;AAAA,EAC9B,qBAA6B;AAAA,EAC7B,mBAA2B;AAAA,EAC3B,kBAA0B;AAAA,EAC1B,kBAA0B;AAAA,EAElC,MAAa,iBAAkC;AAC7C,WAAO,KAAK;AAAA,EACd;AAAA,EAEA,MAAa,kBAAkB,QAA+B;AAC5D,SAAK,cAAc;AAAA,EACrB;AAAA,EAEA,MAAa,qBAAsC;AACjD,WAAO,KAAK;AAAA,EACd;AAAA,EAEA,MAAa,yBAA0C;AACrD,WAAO,KAAK;AAAA,EACd;AAAA,EAEA,MAAa,yBAA0C;AACrD,WAAO,KAAK;AAAA,EACd;AAAA,EAEA,MAAa,wBAAyC;AACpD,WAAO,KAAK;AAAA,EACd;AAAA,EAEA,MAAa,sBAAuC;AAClD,WAAO,KAAK;AAAA,EACd;AAAA,EAEA,MAAa,qBAAsC;AACjD,W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EACd;AACF;","names":[]}
package/dist/index.js CHANGED
@@ -1,11 +1,39 @@
1
1
  // implements/agent.memory.ts
2
2
  var InMemoryAgent = class {
3
- prompt = "";
3
+ agentPrompt = "";
4
+ aggregatePrompt = "";
5
+ generateTitlePrompt = "";
6
+ singleTriggerPrompt = "";
7
+ multiTriggerPrompt = "";
8
+ toolSelectPrompt = "";
9
+ piiDetectPrompt = "";
10
+ piiFilterPrompt = "";
4
11
  async getAgentPrompt() {
5
- return this.prompt;
12
+ return this.agentPrompt;
6
13
  }
7
14
  async updateAgentPrompt(prompt) {
8
- this.prompt = prompt;
15
+ this.agentPrompt = prompt;
16
+ }
17
+ async getAggregatePrompt() {
18
+ return this.aggregatePrompt;
19
+ }
20
+ async getGenerateTitlePrompt() {
21
+ return this.generateTitlePrompt;
22
+ }
23
+ async getSingleTriggerPrompt() {
24
+ return this.singleTriggerPrompt;
25
+ }
26
+ async getMultiTriggerPrompt() {
27
+ return this.multiTriggerPrompt;
28
+ }
29
+ async getToolSelectPrompt() {
30
+ return this.toolSelectPrompt;
31
+ }
32
+ async getPIIDetectPrompt() {
33
+ return this.piiDetectPrompt;
34
+ }
35
+ async getPIIFilterPrompt() {
36
+ return this.piiFilterPrompt;
9
37
  }
10
38
  };
11
39
 
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../implements/agent.memory.ts","../implements/intent.memory.ts","../implements/thread.memory.ts","../implements/workflow.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 // Intent에 이미 id가 있으면 그것을 사용하고, 없으면 새로 생성\n const intentId = intent.id || randomUUID();\n const intentToSave = { ...intent, id: intentId };\n this.intents.set(intentId, intentToSave);\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\n // userThreadIndex에서 해당 thread metadata 제거\n const userThreads = this.userThreadIndex.get(userId);\n if (userThreads) {\n const metadataToDelete = Array.from(userThreads).find(\n metadata => metadata.threadId === threadId\n );\n if (metadataToDelete) {\n userThreads.delete(metadataToDelete);\n }\n }\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 { IWorkflowMemory } from \"@ainetwork/adk/modules\";\nimport type { Workflow } from \"@ainetwork/adk/types/memory\";\n\nexport class InMemoryWorkflow implements IWorkflowMemory {\n private workflows: Map<string, Workflow> = new Map();\n private userWorkflowIndex: Map<string, Set<string>> = new Map();\n\n public async createWorkflow(workflow: Workflow): Promise<Workflow> {\n this.workflows.set(workflow.workflowId, workflow);\n\n if (workflow.userId) {\n if (!this.userWorkflowIndex.has(workflow.userId)) {\n this.userWorkflowIndex.set(workflow.userId, new Set());\n }\n this.userWorkflowIndex.get(workflow.userId)?.add(workflow.workflowId);\n }\n\n return workflow;\n }\n\n public async getWorkflow(workflowId: string): Promise<Workflow | undefined> {\n return this.workflows.get(workflowId);\n }\n\n public async updateWorkflow(workflowId: string, updates: Partial<Workflow>): Promise<void> {\n if (!updates.userId) {\n throw new Error(\"userId is required for updateWorkflow\");\n }\n\n const existing = this.workflows.get(workflowId);\n if (!existing) {\n throw new Error(`Workflow not found: ${workflowId}`);\n }\n\n if (existing.userId !== updates.userId) {\n throw new Error(\"Unauthorized: userId does not match workflow owner\");\n }\n\n const updated = { ...existing, ...updates, workflowId };\n this.workflows.set(workflowId, updated);\n }\n\n public async deleteWorkflow(workflowId: string, userId: string): Promise<void> {\n const workflow = this.workflows.get(workflowId);\n if (workflow && workflow.userId === userId) {\n this.workflows.delete(workflowId);\n this.userWorkflowIndex.get(userId)?.delete(workflowId);\n }\n }\n\n public async listWorkflows(userId?: string): Promise<Workflow[]> {\n const workflows: Workflow[] = [];\n\n // 템플릿 workflow (userId가 없는 것)은 항상 포함\n for (const workflow of this.workflows.values()) {\n if (!workflow.userId) {\n workflows.push(workflow);\n }\n }\n\n // userId가 있으면 해당 유저 소유 workflow도 포함\n if (userId) {\n const userWorkflowIds = this.userWorkflowIndex.get(userId);\n if (userWorkflowIds) {\n for (const workflowId of userWorkflowIds) {\n const workflow = this.workflows.get(workflowId);\n if (workflow) {\n workflows.push(workflow);\n }\n }\n }\n }\n\n return workflows;\n }\n}\n","import { IAgentMemory, IIntentMemory, IMemory, IThreadMemory, IWorkflowMemory } from \"@ainetwork/adk/modules\";\nimport { InMemoryAgent } from \"./agent.memory\";\nimport { InMemoryIntent } from \"./intent.memory\";\nimport { InMemoryThread } from \"./thread.memory\";\nimport { InMemoryWorkflow } from \"./workflow.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 private workflowMemory: InMemoryWorkflow;\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 this.workflowMemory = new InMemoryWorkflow();\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 public getWorkflowMemory(): IWorkflowMemory {\n return this.workflowMemory;\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;AAErD,UAAM,WAAW,OAAO,MAAM,WAAW;AACzC,UAAM,eAAe,EAAE,GAAG,QAAQ,IAAI,SAAS;AAC/C,SAAK,QAAQ,IAAI,UAAU,YAAY;AAAA,EACzC;AAAA,EAEA,MAAa,aAAa,UAAkB,QAA+B;AACzE,SAAK,QAAQ,IAAI,UAAU,MAAM;AAAA,EACnC;AAAA,EAEA,MAAa,aAAa,UAAiC;AACzD,SAAK,QAAQ,OAAO,QAAQ;AAAA,EAC9B;AAAA,EAEA,MAAa,cAAiC;AAC5C,WAAO,MAAM,KAAK,KAAK,QAAQ,OAAO,CAAC;AAAA,EACzC;AACF;;;ACfO,IAAM,iBAAN,MAA8C;AAAA,EAC5C,UAA6C,oBAAI,IAAI;AAAA,EACrD,kBAA4D,oBAAI,IAAI;AAAA,E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pC,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;AAAA,EAEO,oBAAqC;AAC1C,WAAO,KAAK;AAAA,EACd;AACF;","names":[]}
1
+ {"version":3,"sources":["../implements/agent.memory.ts","../implements/intent.memory.ts","../implements/thread.memory.ts","../implements/workflow.memory.ts","../implements/base.memory.ts"],"sourcesContent":["import { IAgentMemory } from \"@ainetwork/adk/modules\";\n\nexport class InMemoryAgent implements IAgentMemory {\n private agentPrompt: string = \"\";\n private aggregatePrompt: string = \"\";\n private generateTitlePrompt: string = \"\";\n private singleTriggerPrompt: string = \"\";\n private multiTriggerPrompt: string = \"\";\n private toolSelectPrompt: string = \"\";\n private piiDetectPrompt: string = \"\";\n private piiFilterPrompt: string = \"\";\n\n public async getAgentPrompt(): Promise<string> {\n return this.agentPrompt;\n }\n\n public async updateAgentPrompt(prompt: string): Promise<void> {\n this.agentPrompt = prompt;\n }\n\n public async getAggregatePrompt(): Promise<string> {\n return this.aggregatePrompt;\n }\n\n public async getGenerateTitlePrompt(): Promise<string> {\n return this.generateTitlePrompt;\n }\n\n public async getSingleTriggerPrompt(): Promise<string> {\n return this.singleTriggerPrompt;\n }\n\n public async getMultiTriggerPrompt(): Promise<string> {\n return this.multiTriggerPrompt;\n }\n\n public async getToolSelectPrompt(): Promise<string> {\n return this.toolSelectPrompt;\n }\n\n public async getPIIDetectPrompt(): Promise<string> {\n return this.piiDetectPrompt;\n }\n\n public async getPIIFilterPrompt(): Promise<string> {\n return this.piiFilterPrompt;\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 // Intent에 이미 id가 있으면 그것을 사용하고, 없으면 새로 생성\n const intentId = intent.id || randomUUID();\n const intentToSave = { ...intent, id: intentId };\n this.intents.set(intentId, intentToSave);\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\n // userThreadIndex에서 해당 thread metadata 제거\n const userThreads = this.userThreadIndex.get(userId);\n if (userThreads) {\n const metadataToDelete = Array.from(userThreads).find(\n metadata => metadata.threadId === threadId\n );\n if (metadataToDelete) {\n userThreads.delete(metadataToDelete);\n }\n }\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 { IWorkflowMemory } from \"@ainetwork/adk/modules\";\nimport type { Workflow } from \"@ainetwork/adk/types/memory\";\n\nexport class InMemoryWorkflow implements IWorkflowMemory {\n private workflows: Map<string, Workflow> = new Map();\n private userWorkflowIndex: Map<string, Set<string>> = new Map();\n\n public async createWorkflow(workflow: Workflow): Promise<Workflow> {\n this.workflows.set(workflow.workflowId, workflow);\n\n if (workflow.userId) {\n if (!this.userWorkflowIndex.has(workflow.userId)) {\n this.userWorkflowIndex.set(workflow.userId, new Set());\n }\n this.userWorkflowIndex.get(workflow.userId)?.add(workflow.workflowId);\n }\n\n return workflow;\n }\n\n public async getWorkflow(workflowId: string): Promise<Workflow | undefined> {\n return this.workflows.get(workflowId);\n }\n\n public async updateWorkflow(workflowId: string, updates: Partial<Workflow>): Promise<void> {\n if (!updates.userId) {\n throw new Error(\"userId is required for updateWorkflow\");\n }\n\n const existing = this.workflows.get(workflowId);\n if (!existing) {\n throw new Error(`Workflow not found: ${workflowId}`);\n }\n\n if (existing.userId !== updates.userId) {\n throw new Error(\"Unauthorized: userId does not match workflow owner\");\n }\n\n const updated = { ...existing, ...updates, workflowId };\n this.workflows.set(workflowId, updated);\n }\n\n public async deleteWorkflow(workflowId: string, userId: string): Promise<void> {\n const workflow = this.workflows.get(workflowId);\n if (workflow && workflow.userId === userId) {\n this.workflows.delete(workflowId);\n this.userWorkflowIndex.get(userId)?.delete(workflowId);\n }\n }\n\n public async listWorkflows(userId?: string): Promise<Workflow[]> {\n const workflows: Workflow[] = [];\n\n // 템플릿 workflow (userId가 없는 것)은 항상 포함\n for (const workflow of this.workflows.values()) {\n if (!workflow.userId) {\n workflows.push(workflow);\n }\n }\n\n // userId가 있으면 해당 유저 소유 workflow도 포함\n if (userId) {\n const userWorkflowIds = this.userWorkflowIndex.get(userId);\n if (userWorkflowIds) {\n for (const workflowId of userWorkflowIds) {\n const workflow = this.workflows.get(workflowId);\n if (workflow) {\n workflows.push(workflow);\n }\n }\n }\n }\n\n return workflows;\n }\n}\n","import { IAgentMemory, IIntentMemory, IMemory, IThreadMemory, IWorkflowMemory } from \"@ainetwork/adk/modules\";\nimport { InMemoryAgent } from \"./agent.memory\";\nimport { InMemoryIntent } from \"./intent.memory\";\nimport { InMemoryThread } from \"./thread.memory\";\nimport { InMemoryWorkflow } from \"./workflow.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 private workflowMemory: InMemoryWorkflow;\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 this.workflowMemory = new InMemoryWorkflow();\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 public getWorkflowMemory(): IWorkflowMemory {\n return this.workflowMemory;\n }\n}\n"],"mappings":";AAEO,IAAM,gBAAN,MAA4C;AAAA,EACzC,cAAsB;AAAA,EACtB,kBAA0B;AAAA,EAC1B,sBAA8B;AAAA,EAC9B,sBAA8B;AAAA,EAC9B,qBAA6B;AAAA,EAC7B,mBAA2B;AAAA,EAC3B,kBAA0B;AAAA,EAC1B,kBAA0B;AAAA,EAElC,MAAa,iBAAkC;AAC7C,WAAO,KAAK;AAAA,EACd;AAAA,EAEA,MAAa,kBAAkB,QAA+B;AAC5D,SAAK,cAAc;AAAA,EACrB;AAAA,EAEA,MAAa,qBAAsC;AACjD,WAAO,KAAK;AAAA,EACd;AAAA,EAEA,MAAa,yBAA0C;AACrD,WAAO,KAAK;AAAA,EACd;AAAA,EAEA,MAAa,yBAA0C;AACrD,WAAO,KAAK;AAAA,EACd;AAAA,EAEA,MAAa,wBAAyC;AACpD,WAAO,KAAK;AAAA,EACd;AAAA,EAEA,MAAa,sBAAuC;AAClD,WAAO,KAAK;AAAA,EACd;AAAA,EAEA,MAAa,qBAAsC;AACjD,WAAO,KAAK;AAAA,EACd;AAAA,EAEA,MAAa,qBAAsC;AACjD,WAAO,KAAK;AAAA,EACd;AACF;;;AC/CA,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,MAA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BAAkB,KAAK,kBAAkB,IAAI,MAAM;AACzD,UAAI,iBAAiB;AACnB,mBAAW,cAAc,iBAAiB;AACxC,gBAAM,WAAW,KAAK,UAAU,IAAI,UAAU;AAC9C,cAAI,UAAU;AACZ,sBAAU,KAAK,QAAQ;AAAA,UACzB;AAAA,QACF;AAAA,MACF;AAAA,IACF;AAEA,WAAO;AAAA,EACT;AACF;;;ACrEO,IAAM,iBAAN,MAAM,gBAAkC;AAAA,EAC7C,OAAe;AAAA,EACP,YAAqB;AAAA,EAErB;AAAA,EACA;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;AACvC,SAAK,iBAAiB,IAAI,iBAAiB;AAAA,EAC7C;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;AAAA,EAEO,oBAAqC;AAC1C,WAAO,KAAK;AAAA,EACd;AACF;","names":[]}
@@ -1,13 +1,48 @@
1
1
  import { IAgentMemory } from "@ainetwork/adk/modules";
2
2
 
3
3
  export class InMemoryAgent implements IAgentMemory {
4
- private prompt: string = "";
4
+ private agentPrompt: string = "";
5
+ private aggregatePrompt: string = "";
6
+ private generateTitlePrompt: string = "";
7
+ private singleTriggerPrompt: string = "";
8
+ private multiTriggerPrompt: string = "";
9
+ private toolSelectPrompt: string = "";
10
+ private piiDetectPrompt: string = "";
11
+ private piiFilterPrompt: string = "";
5
12
 
6
13
  public async getAgentPrompt(): Promise<string> {
7
- return this.prompt;
14
+ return this.agentPrompt;
8
15
  }
9
16
 
10
17
  public async updateAgentPrompt(prompt: string): Promise<void> {
11
- this.prompt = prompt;
18
+ this.agentPrompt = prompt;
19
+ }
20
+
21
+ public async getAggregatePrompt(): Promise<string> {
22
+ return this.aggregatePrompt;
23
+ }
24
+
25
+ public async getGenerateTitlePrompt(): Promise<string> {
26
+ return this.generateTitlePrompt;
27
+ }
28
+
29
+ public async getSingleTriggerPrompt(): Promise<string> {
30
+ return this.singleTriggerPrompt;
31
+ }
32
+
33
+ public async getMultiTriggerPrompt(): Promise<string> {
34
+ return this.multiTriggerPrompt;
35
+ }
36
+
37
+ public async getToolSelectPrompt(): Promise<string> {
38
+ return this.toolSelectPrompt;
39
+ }
40
+
41
+ public async getPIIDetectPrompt(): Promise<string> {
42
+ return this.piiDetectPrompt;
43
+ }
44
+
45
+ public async getPIIFilterPrompt(): Promise<string> {
46
+ return this.piiFilterPrompt;
12
47
  }
13
48
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ainetwork/adk-provider-memory-inmemory",
3
- "version": "0.3.6",
3
+ "version": "0.4.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.3.6"
24
+ "@ainetwork/adk": "^0.4.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": "519c7ef43ddb78ec85255cfe45b62b40c7f3e37b"
33
+ "gitHead": "36d311adf911c3539166e08bc2e6b7e240e8615c"
34
34
  }