UNPKG

crewai-ts

Version:

TypeScript port of crewAI for agent-based workflows

88 lines 2.35 kB
export interface Entity { id: string; name: string; type: string; attributes: Record<string, any>; timestamp: number; lastAccessed?: number; } /** * Entity memory storage implementation * Uses efficient indexing for fast entity retrieval */ export declare class EntityMemoryStorage { private dbPath; private cache; private nameIndex; private typeIndex; /** * Initialize storage with optimized indexing * @param dbPath Optional custom database path */ constructor(dbPath?: string); /** * Ensure storage directory exists */ private ensureStorageExists; /** * Save an entity * @param entity Entity to save (with or without ID and timestamp) * @returns Saved entity with ID and timestamps */ save(entity: Omit<Entity, 'id' | 'timestamp'> & { id?: string; timestamp?: number; }): Promise<Entity>; /** * Get all entities * @returns Array of entities */ getAll(): Promise<Entity[]>; /** * Get an entity by ID * Uses efficient caching for performance * @param id Entity ID * @returns Entity or null if not found */ getById(id: string): Promise<Entity | null>; /** * Get entities by name * Uses efficient name indexing * @param name Entity name * @returns Array of matching entities */ getByName(name: string): Promise<Entity[]>; /** * Get entities by type * Uses efficient type indexing * @param type Entity type * @returns Array of matching entities */ getByType(type: string): Promise<Entity[]>; /** * Delete an entity by ID * @param id Entity ID * @returns True if deleted, false if not found */ delete(id: string): Promise<boolean>; /** * Clear all entities */ clear(): Promise<void>; /** * Rebuild indices for efficient lookup * @param entities Array of entities */ private rebuildIndices; /** * Update cache and indices with an entity * @param entity Entity to update in cache and indices */ private updateCacheAndIndices; /** * Remove entity from indices * @param entity Entity to remove from indices */ private removeFromIndices; } //# sourceMappingURL=EntityMemoryStorage.d.ts.map