import type { KnowledgeGraph } from '../KnowledgeGraphManager.js'; import type { Relation } from '../types/relation.js'; import type { EntityEmbedding, SemanticSearchOptions } from '../types/entity-embedding.js'; /** * Options for searching nodes in the knowledge graph */ export interface SearchOptions { /** * Maximum number of results to return */ limit?: number; /** * Whether the search should be case-sensitive */ caseSensitive?: boolean; /** * Filter results by entity types */ entityTypes?: string[]; } /** * Interface for storage providers that can load and save knowledge graphs */ export interface StorageProvider { /** * Load a knowledge graph from storage * @returns Promise resolving to the loaded knowledge graph */ loadGraph(): Promise; /** * Save a knowledge graph to storage * @param graph The knowledge graph to save * @returns Promise that resolves when the save is complete */ saveGraph(graph: KnowledgeGraph): Promise; /** * Search for nodes in the graph that match the query * @param query The search query string * @param options Optional search parameters * @returns Promise resolving to a KnowledgeGraph containing matching nodes */ searchNodes(query: string, options?: SearchOptions): Promise; /** * Open specific nodes by their exact names * @param names Array of node names to open * @returns Promise resolving to a KnowledgeGraph containing the specified nodes */ openNodes(names: string[]): Promise; /** * Create new entities in the knowledge graph * @param entities Array of entities to create * @returns Promise resolving to array of newly created entities with temporal metadata */ createEntities(entities: any[]): Promise; /** * Create new relations between entities * @param relations Array of relations to create * @returns Promise resolving to array of newly created relations */ createRelations(relations: Relation[]): Promise; /** * Add observations to entities * @param observations Array of objects with entity name and observation contents * @returns Promise resolving to array of objects with entity name and added observations */ addObservations(observations: { entityName: string; contents: string[]; }[]): Promise<{ entityName: string; addedObservations: string[]; }[]>; /** * Delete entities and their relations * @param entityNames Array of entity names to delete * @returns Promise that resolves when deletion is complete */ deleteEntities(entityNames: string[]): Promise; /** * Delete observations from entities * @param deletions Array of objects with entity name and observations to delete * @returns Promise that resolves when deletion is complete */ deleteObservations(deletions: { entityName: string; observations: string[]; }[]): Promise; /** * Delete relations from the graph * @param relations Array of relations to delete * @returns Promise that resolves when deletion is complete */ deleteRelations(relations: Relation[]): Promise; /** * Get a specific relation by its source, target, and type * @param from Source entity name * @param to Target entity name * @param type Relation type * @returns Promise resolving to the relation or null if not found */ getRelation?(from: string, to: string, type: string): Promise; /** * Update an existing relation with new properties * @param relation The relation with updated properties * @returns Promise that resolves when the update is complete */ updateRelation?(relation: Relation): Promise; /** * Get the history of all versions of an entity * @param entityName The name of the entity to retrieve history for * @returns Promise resolving to an array of entity versions in chronological order */ getEntityHistory?(entityName: string): Promise; /** * Get the history of all versions of a relation * @param from Source entity name * @param to Target entity name * @param relationType Type of the relation * @returns Promise resolving to an array of relation versions in chronological order */ getRelationHistory?(from: string, to: string, relationType: string): Promise; /** * Get the state of the knowledge graph at a specific point in time * @param timestamp The timestamp to get the graph state at * @returns Promise resolving to the knowledge graph as it was at the specified time */ getGraphAtTime?(timestamp: number): Promise; /** * Get the current knowledge graph with confidence decay applied to relations * based on their age and the configured decay settings * @returns Promise resolving to the knowledge graph with decayed confidence values */ getDecayedGraph?(): Promise; /** * Store or update the embedding vector for an entity * @param entityName The name of the entity to update * @param embedding The embedding data to store * @returns Promise that resolves when the update is complete */ updateEntityEmbedding?(entityName: string, embedding: EntityEmbedding): Promise; /** * Find entities similar to a query vector * @param queryVector The vector to compare against * @param limit Maximum number of results to return * @returns Promise resolving to array of entities with similarity scores */ findSimilarEntities?(queryVector: number[], limit?: number): Promise; /** * Search for entities using semantic search * @param query The search query text * @param options Search options including semantic search parameters * @returns Promise resolving to a KnowledgeGraph containing matching entities */ semanticSearch?(query: string, options?: SearchOptions & SemanticSearchOptions): Promise; /** * Get an entity by name * @param entityName Name of the entity to retrieve * @returns Promise resolving to the entity or null if not found */ getEntity(entityName: string): Promise; } export declare namespace StorageProvider { function isStorageProvider(obj: any): boolean; } /** * Validator class for StorageProvider interface * This exists to ensure there's a concrete export for JavaScript tests */ export declare class StorageProviderValidator { static isStorageProvider(obj: any): boolean; }