UNPKG

adk-typescript

Version:

TypeScript port of Google's Agent Development Kit (ADK)

86 lines (85 loc) 2.53 kB
"use strict"; /** * Memory module - Provides memory systems for agents */ Object.defineProperty(exports, "__esModule", { value: true }); exports.ConversationMemory = exports.Memory = exports.VertexAiRagMemoryService = exports.InMemoryMemoryService = void 0; var InMemoryMemoryService_1 = require("./InMemoryMemoryService"); Object.defineProperty(exports, "InMemoryMemoryService", { enumerable: true, get: function () { return InMemoryMemoryService_1.InMemoryMemoryService; } }); var VertexAiRagMemoryService_1 = require("./VertexAiRagMemoryService"); Object.defineProperty(exports, "VertexAiRagMemoryService", { enumerable: true, get: function () { return VertexAiRagMemoryService_1.VertexAiRagMemoryService; } }); /** * Default memory implementation */ class Memory { constructor() { this.items = []; } /** * Add an item to memory * @param item The item to add to memory */ add(item) { this.items.push({ timestamp: Date.now(), content: item }); } /** * Get items from memory, optionally filtered by a query * @param query Optional query to filter memory items * @returns Matching memory items */ get(query) { if (!query) { return [...this.items]; } // Simple implementation - will be expanded in the future return this.items.filter(item => JSON.stringify(item).includes(JSON.stringify(query))); } /** * Clear all items from memory */ clear() { this.items = []; } } exports.Memory = Memory; /** * Conversation memory specialized for chat history */ class ConversationMemory { constructor() { this.messages = []; } /** * Add a message to the conversation * @param item Message to add */ add(item) { this.messages.push({ timestamp: Date.now(), role: item.role || 'user', content: item.content }); } /** * Get conversation history * @param query Optional query to filter messages * @returns Conversation messages */ get(query) { if (!query) { return [...this.messages]; } // Simple implementation - will be expanded in the future return this.messages.filter(msg => JSON.stringify(msg).includes(JSON.stringify(query))); } /** * Clear conversation history */ clear() { this.messages = []; } } exports.ConversationMemory = ConversationMemory;