@henrychong-ai/mcp-neo4j-knowledge-graph 1.0.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/LICENSE +21 -0
- package/README.md +718 -0
- package/dist/KnowledgeGraphManager.d.ts +215 -0
- package/dist/KnowledgeGraphManager.js +910 -0
- package/dist/KnowledgeGraphManager.js.map +1 -0
- package/dist/callToolHandler.d.ts +5 -0
- package/dist/callToolHandler.js +26 -0
- package/dist/callToolHandler.js.map +1 -0
- package/dist/cli/neo4j-setup.d.ts +52 -0
- package/dist/cli/neo4j-setup.js +258 -0
- package/dist/cli/neo4j-setup.js.map +1 -0
- package/dist/config/paths.d.ts +13 -0
- package/dist/config/paths.js +41 -0
- package/dist/config/paths.js.map +1 -0
- package/dist/config/storage.d.ts +35 -0
- package/dist/config/storage.js +52 -0
- package/dist/config/storage.js.map +1 -0
- package/dist/embeddings/DefaultEmbeddingService.d.ts +64 -0
- package/dist/embeddings/DefaultEmbeddingService.js +139 -0
- package/dist/embeddings/DefaultEmbeddingService.js.map +1 -0
- package/dist/embeddings/EmbeddingJobManager.d.ts +212 -0
- package/dist/embeddings/EmbeddingJobManager.js +545 -0
- package/dist/embeddings/EmbeddingJobManager.js.map +1 -0
- package/dist/embeddings/EmbeddingService.d.ts +96 -0
- package/dist/embeddings/EmbeddingService.js +44 -0
- package/dist/embeddings/EmbeddingService.js.map +1 -0
- package/dist/embeddings/EmbeddingServiceFactory.d.ts +72 -0
- package/dist/embeddings/EmbeddingServiceFactory.js +147 -0
- package/dist/embeddings/EmbeddingServiceFactory.js.map +1 -0
- package/dist/embeddings/OpenAIEmbeddingService.d.ts +73 -0
- package/dist/embeddings/OpenAIEmbeddingService.js +195 -0
- package/dist/embeddings/OpenAIEmbeddingService.js.map +1 -0
- package/dist/embeddings/config.d.ts +83 -0
- package/dist/embeddings/config.js +65 -0
- package/dist/embeddings/config.js.map +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +220 -0
- package/dist/index.js.map +1 -0
- package/dist/server/handlers/callToolHandler.d.ts +20 -0
- package/dist/server/handlers/callToolHandler.js +505 -0
- package/dist/server/handlers/callToolHandler.js.map +1 -0
- package/dist/server/handlers/listToolsHandler.d.ts +7 -0
- package/dist/server/handlers/listToolsHandler.js +511 -0
- package/dist/server/handlers/listToolsHandler.js.map +1 -0
- package/dist/server/handlers/toolHandlers/addObservations.d.ts +12 -0
- package/dist/server/handlers/toolHandlers/addObservations.js +99 -0
- package/dist/server/handlers/toolHandlers/addObservations.js.map +1 -0
- package/dist/server/handlers/toolHandlers/createEntities.d.ts +12 -0
- package/dist/server/handlers/toolHandlers/createEntities.js +20 -0
- package/dist/server/handlers/toolHandlers/createEntities.js.map +1 -0
- package/dist/server/handlers/toolHandlers/createRelations.d.ts +12 -0
- package/dist/server/handlers/toolHandlers/createRelations.js +20 -0
- package/dist/server/handlers/toolHandlers/createRelations.js.map +1 -0
- package/dist/server/handlers/toolHandlers/deleteEntities.d.ts +12 -0
- package/dist/server/handlers/toolHandlers/deleteEntities.js +20 -0
- package/dist/server/handlers/toolHandlers/deleteEntities.js.map +1 -0
- package/dist/server/handlers/toolHandlers/index.d.ts +8 -0
- package/dist/server/handlers/toolHandlers/index.js +9 -0
- package/dist/server/handlers/toolHandlers/index.js.map +1 -0
- package/dist/server/handlers/toolHandlers/readGraph.d.ts +12 -0
- package/dist/server/handlers/toolHandlers/readGraph.js +20 -0
- package/dist/server/handlers/toolHandlers/readGraph.js.map +1 -0
- package/dist/server/setup.d.ts +8 -0
- package/dist/server/setup.js +48 -0
- package/dist/server/setup.js.map +1 -0
- package/dist/storage/FileStorageProvider.d.ts +125 -0
- package/dist/storage/FileStorageProvider.js +322 -0
- package/dist/storage/FileStorageProvider.js.map +1 -0
- package/dist/storage/SearchResultCache.d.ts +102 -0
- package/dist/storage/SearchResultCache.js +258 -0
- package/dist/storage/SearchResultCache.js.map +1 -0
- package/dist/storage/StorageProvider.d.ts +171 -0
- package/dist/storage/StorageProvider.js +46 -0
- package/dist/storage/StorageProvider.js.map +1 -0
- package/dist/storage/StorageProviderFactory.d.ts +63 -0
- package/dist/storage/StorageProviderFactory.js +113 -0
- package/dist/storage/StorageProviderFactory.js.map +1 -0
- package/dist/storage/VectorStoreFactory.d.ts +43 -0
- package/dist/storage/VectorStoreFactory.js +41 -0
- package/dist/storage/VectorStoreFactory.js.map +1 -0
- package/dist/storage/neo4j/Neo4jConfig.d.ts +37 -0
- package/dist/storage/neo4j/Neo4jConfig.js +13 -0
- package/dist/storage/neo4j/Neo4jConfig.js.map +1 -0
- package/dist/storage/neo4j/Neo4jConnectionManager.d.ts +40 -0
- package/dist/storage/neo4j/Neo4jConnectionManager.js +58 -0
- package/dist/storage/neo4j/Neo4jConnectionManager.js.map +1 -0
- package/dist/storage/neo4j/Neo4jSchemaManager.d.ts +74 -0
- package/dist/storage/neo4j/Neo4jSchemaManager.js +224 -0
- package/dist/storage/neo4j/Neo4jSchemaManager.js.map +1 -0
- package/dist/storage/neo4j/Neo4jStorageProvider.d.ts +225 -0
- package/dist/storage/neo4j/Neo4jStorageProvider.js +1900 -0
- package/dist/storage/neo4j/Neo4jStorageProvider.js.map +1 -0
- package/dist/storage/neo4j/Neo4jVectorStore.d.ts +80 -0
- package/dist/storage/neo4j/Neo4jVectorStore.js +396 -0
- package/dist/storage/neo4j/Neo4jVectorStore.js.map +1 -0
- package/dist/types/entity-embedding.d.ts +156 -0
- package/dist/types/entity-embedding.js +2 -0
- package/dist/types/entity-embedding.js.map +1 -0
- package/dist/types/relation.d.ts +77 -0
- package/dist/types/relation.js +93 -0
- package/dist/types/relation.js.map +1 -0
- package/dist/types/temporalEntity.d.ts +55 -0
- package/dist/types/temporalEntity.js +66 -0
- package/dist/types/temporalEntity.js.map +1 -0
- package/dist/types/temporalRelation.d.ts +60 -0
- package/dist/types/temporalRelation.js +89 -0
- package/dist/types/temporalRelation.js.map +1 -0
- package/dist/types/vector-index.d.ts +48 -0
- package/dist/types/vector-index.js +2 -0
- package/dist/types/vector-index.js.map +1 -0
- package/dist/types/vector-store.d.ts +16 -0
- package/dist/types/vector-store.js +2 -0
- package/dist/types/vector-store.js.map +1 -0
- package/dist/utils/fs.d.ts +2 -0
- package/dist/utils/fs.js +3 -0
- package/dist/utils/fs.js.map +1 -0
- package/dist/utils/logger.d.ts +10 -0
- package/dist/utils/logger.js +35 -0
- package/dist/utils/logger.js.map +1 -0
- package/package.json +85 -0
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Handles the create_entities tool request
|
|
3
|
+
* @param args The arguments for the tool request
|
|
4
|
+
* @param knowledgeGraphManager The KnowledgeGraphManager instance
|
|
5
|
+
* @returns A response object with the result content
|
|
6
|
+
*/
|
|
7
|
+
export async function handleCreateEntities(args,
|
|
8
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
9
|
+
knowledgeGraphManager) {
|
|
10
|
+
const result = await knowledgeGraphManager.createEntities(args.entities);
|
|
11
|
+
return {
|
|
12
|
+
content: [
|
|
13
|
+
{
|
|
14
|
+
type: 'text',
|
|
15
|
+
text: JSON.stringify(result, null, 2),
|
|
16
|
+
},
|
|
17
|
+
],
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=createEntities.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createEntities.js","sourceRoot":"","sources":["../../../../src/server/handlers/toolHandlers/createEntities.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,CAAC,KAAK,UAAU,oBAAoB,CACxC,IAA6B;AAC7B,8DAA8D;AAC9D,qBAA0B;IAE1B,MAAM,MAAM,GAAG,MAAM,qBAAqB,CAAC,cAAc,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IACzE,OAAO;QACL,OAAO,EAAE;YACP;gBACE,IAAI,EAAE,MAAM;gBACZ,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC;aACtC;SACF;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Handles the create_relations tool request
|
|
3
|
+
* @param args The arguments for the tool request
|
|
4
|
+
* @param knowledgeGraphManager The KnowledgeGraphManager instance
|
|
5
|
+
* @returns A response object with the result content
|
|
6
|
+
*/
|
|
7
|
+
export declare function handleCreateRelations(args: Record<string, unknown>, knowledgeGraphManager: any): Promise<{
|
|
8
|
+
content: Array<{
|
|
9
|
+
type: string;
|
|
10
|
+
text: string;
|
|
11
|
+
}>;
|
|
12
|
+
}>;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Handles the create_relations tool request
|
|
3
|
+
* @param args The arguments for the tool request
|
|
4
|
+
* @param knowledgeGraphManager The KnowledgeGraphManager instance
|
|
5
|
+
* @returns A response object with the result content
|
|
6
|
+
*/
|
|
7
|
+
export async function handleCreateRelations(args,
|
|
8
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
9
|
+
knowledgeGraphManager) {
|
|
10
|
+
const result = await knowledgeGraphManager.createRelations(args.relations);
|
|
11
|
+
return {
|
|
12
|
+
content: [
|
|
13
|
+
{
|
|
14
|
+
type: 'text',
|
|
15
|
+
text: JSON.stringify(result, null, 2),
|
|
16
|
+
},
|
|
17
|
+
],
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=createRelations.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createRelations.js","sourceRoot":"","sources":["../../../../src/server/handlers/toolHandlers/createRelations.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,CAAC,KAAK,UAAU,qBAAqB,CACzC,IAA6B;AAC7B,8DAA8D;AAC9D,qBAA0B;IAE1B,MAAM,MAAM,GAAG,MAAM,qBAAqB,CAAC,eAAe,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;IAC3E,OAAO;QACL,OAAO,EAAE;YACP;gBACE,IAAI,EAAE,MAAM;gBACZ,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC;aACtC;SACF;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Handles the delete_entities tool request
|
|
3
|
+
* @param args The arguments for the tool request
|
|
4
|
+
* @param knowledgeGraphManager The KnowledgeGraphManager instance
|
|
5
|
+
* @returns A response object with the success message
|
|
6
|
+
*/
|
|
7
|
+
export declare function handleDeleteEntities(args: Record<string, unknown>, knowledgeGraphManager: any): Promise<{
|
|
8
|
+
content: Array<{
|
|
9
|
+
type: string;
|
|
10
|
+
text: string;
|
|
11
|
+
}>;
|
|
12
|
+
}>;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Handles the delete_entities tool request
|
|
3
|
+
* @param args The arguments for the tool request
|
|
4
|
+
* @param knowledgeGraphManager The KnowledgeGraphManager instance
|
|
5
|
+
* @returns A response object with the success message
|
|
6
|
+
*/
|
|
7
|
+
export async function handleDeleteEntities(args,
|
|
8
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
9
|
+
knowledgeGraphManager) {
|
|
10
|
+
await knowledgeGraphManager.deleteEntities(args.entityNames);
|
|
11
|
+
return {
|
|
12
|
+
content: [
|
|
13
|
+
{
|
|
14
|
+
type: 'text',
|
|
15
|
+
text: 'Entities deleted successfully',
|
|
16
|
+
},
|
|
17
|
+
],
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=deleteEntities.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deleteEntities.js","sourceRoot":"","sources":["../../../../src/server/handlers/toolHandlers/deleteEntities.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,CAAC,KAAK,UAAU,oBAAoB,CACxC,IAA6B;AAC7B,8DAA8D;AAC9D,qBAA0B;IAE1B,MAAM,qBAAqB,CAAC,cAAc,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;IAC7D,OAAO;QACL,OAAO,EAAE;YACP;gBACE,IAAI,EAAE,MAAM;gBACZ,IAAI,EAAE,+BAA+B;aACtC;SACF;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Exports all tool handlers
|
|
3
|
+
*/
|
|
4
|
+
export { handleReadGraph } from './readGraph.js';
|
|
5
|
+
export { handleCreateEntities } from './createEntities.js';
|
|
6
|
+
export { handleCreateRelations } from './createRelations.js';
|
|
7
|
+
export { handleAddObservations } from './addObservations.js';
|
|
8
|
+
export { handleDeleteEntities } from './deleteEntities.js';
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Exports all tool handlers
|
|
3
|
+
*/
|
|
4
|
+
export { handleReadGraph } from './readGraph.js';
|
|
5
|
+
export { handleCreateEntities } from './createEntities.js';
|
|
6
|
+
export { handleCreateRelations } from './createRelations.js';
|
|
7
|
+
export { handleAddObservations } from './addObservations.js';
|
|
8
|
+
export { handleDeleteEntities } from './deleteEntities.js';
|
|
9
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/server/handlers/toolHandlers/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACjD,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAC7D,OAAO,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAC7D,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Handles the read_graph tool request
|
|
3
|
+
* @param args The arguments for the tool request
|
|
4
|
+
* @param knowledgeGraphManager The KnowledgeGraphManager instance
|
|
5
|
+
* @returns A response object with the result content
|
|
6
|
+
*/
|
|
7
|
+
export declare function handleReadGraph(args: Record<string, unknown>, knowledgeGraphManager: any): Promise<{
|
|
8
|
+
content: Array<{
|
|
9
|
+
type: string;
|
|
10
|
+
text: string;
|
|
11
|
+
}>;
|
|
12
|
+
}>;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Handles the read_graph tool request
|
|
3
|
+
* @param args The arguments for the tool request
|
|
4
|
+
* @param knowledgeGraphManager The KnowledgeGraphManager instance
|
|
5
|
+
* @returns A response object with the result content
|
|
6
|
+
*/
|
|
7
|
+
export async function handleReadGraph(args,
|
|
8
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
9
|
+
knowledgeGraphManager) {
|
|
10
|
+
const result = await knowledgeGraphManager.readGraph();
|
|
11
|
+
return {
|
|
12
|
+
content: [
|
|
13
|
+
{
|
|
14
|
+
type: 'text',
|
|
15
|
+
text: JSON.stringify(result, null, 2),
|
|
16
|
+
},
|
|
17
|
+
],
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=readGraph.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"readGraph.js","sourceRoot":"","sources":["../../../../src/server/handlers/toolHandlers/readGraph.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,CAAC,KAAK,UAAU,eAAe,CACnC,IAA6B;AAC7B,8DAA8D;AAC9D,qBAA0B;IAE1B,MAAM,MAAM,GAAG,MAAM,qBAAqB,CAAC,SAAS,EAAE,CAAC;IACvD,OAAO;QACL,OAAO,EAAE;YACP;gBACE,IAAI,EAAE,MAAM;gBACZ,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC;aACtC;SACF;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Server } from '@modelcontextprotocol/sdk/server/index.js';
|
|
2
|
+
/**
|
|
3
|
+
* Sets up and configures the MCP server with the appropriate request handlers.
|
|
4
|
+
*
|
|
5
|
+
* @param knowledgeGraphManager The KnowledgeGraphManager instance to use for request handling
|
|
6
|
+
* @returns The configured server instance
|
|
7
|
+
*/
|
|
8
|
+
export declare function setupServer(knowledgeGraphManager: any): Server;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { Server } from '@modelcontextprotocol/sdk/server/index.js';
|
|
2
|
+
import { CallToolRequestSchema, ListToolsRequestSchema } from '@modelcontextprotocol/sdk/types.js';
|
|
3
|
+
import { handleListToolsRequest } from './handlers/listToolsHandler.js';
|
|
4
|
+
import { handleCallToolRequest } from './handlers/callToolHandler.js';
|
|
5
|
+
/**
|
|
6
|
+
* Sets up and configures the MCP server with the appropriate request handlers.
|
|
7
|
+
*
|
|
8
|
+
* @param knowledgeGraphManager The KnowledgeGraphManager instance to use for request handling
|
|
9
|
+
* @returns The configured server instance
|
|
10
|
+
*/
|
|
11
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
12
|
+
export function setupServer(knowledgeGraphManager) {
|
|
13
|
+
// Create server instance
|
|
14
|
+
const server = new Server({
|
|
15
|
+
name: 'memento-mcp',
|
|
16
|
+
version: '1.0.0',
|
|
17
|
+
description: 'Memento MCP: Your persistent knowledge graph memory system',
|
|
18
|
+
publisher: 'gannonh',
|
|
19
|
+
}, {
|
|
20
|
+
capabilities: {
|
|
21
|
+
tools: {},
|
|
22
|
+
serverInfo: {}, // Add this capability to fix the error
|
|
23
|
+
notifications: {}, // Add this capability for complete support
|
|
24
|
+
logging: {}, // Add this capability for complete support
|
|
25
|
+
},
|
|
26
|
+
});
|
|
27
|
+
// Register request handlers
|
|
28
|
+
server.setRequestHandler(ListToolsRequestSchema, async (_request) => {
|
|
29
|
+
try {
|
|
30
|
+
const result = await handleListToolsRequest();
|
|
31
|
+
return result;
|
|
32
|
+
}
|
|
33
|
+
catch (error) {
|
|
34
|
+
throw error;
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
38
|
+
try {
|
|
39
|
+
const result = await handleCallToolRequest(request, knowledgeGraphManager);
|
|
40
|
+
return result;
|
|
41
|
+
}
|
|
42
|
+
catch (error) {
|
|
43
|
+
throw error;
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
return server;
|
|
47
|
+
}
|
|
48
|
+
//# sourceMappingURL=setup.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"setup.js","sourceRoot":"","sources":["../../src/server/setup.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AACnE,OAAO,EAAE,qBAAqB,EAAE,sBAAsB,EAAE,MAAM,oCAAoC,CAAC;AACnG,OAAO,EAAE,sBAAsB,EAAE,MAAM,gCAAgC,CAAC;AACxE,OAAO,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAC;AAEtE;;;;;GAKG;AACH,8DAA8D;AAC9D,MAAM,UAAU,WAAW,CAAC,qBAA0B;IACpD,yBAAyB;IACzB,MAAM,MAAM,GAAG,IAAI,MAAM,CACvB;QACE,IAAI,EAAE,aAAa;QACnB,OAAO,EAAE,OAAO;QAChB,WAAW,EAAE,4DAA4D;QACzE,SAAS,EAAE,SAAS;KACrB,EACD;QACE,YAAY,EAAE;YACZ,KAAK,EAAE,EAAE;YACT,UAAU,EAAE,EAAE,EAAE,uCAAuC;YACvD,aAAa,EAAE,EAAE,EAAE,2CAA2C;YAC9D,OAAO,EAAE,EAAE,EAAE,2CAA2C;SACzD;KACF,CACF,CAAC;IAEF,4BAA4B;IAC5B,MAAM,CAAC,iBAAiB,CAAC,sBAAsB,EAAE,KAAK,EAAE,QAAQ,EAAE,EAAE;QAClE,IAAI,CAAC;YACH,MAAM,MAAM,GAAG,MAAM,sBAAsB,EAAE,CAAC;YAC9C,OAAO,MAAM,CAAC;QAChB,CAAC;QAAC,OAAO,KAAc,EAAE,CAAC;YACxB,MAAM,KAAK,CAAC;QACd,CAAC;IACH,CAAC,CAAC,CAAC;IAEH,MAAM,CAAC,iBAAiB,CAAC,qBAAqB,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE;QAChE,IAAI,CAAC;YACH,MAAM,MAAM,GAAG,MAAM,qBAAqB,CAAC,OAAO,EAAE,qBAAqB,CAAC,CAAC;YAC3E,OAAO,MAAM,CAAC;QAChB,CAAC;QAAC,OAAO,KAAc,EAAE,CAAC;YACxB,MAAM,KAAK,CAAC;QACd,CAAC;IACH,CAAC,CAAC,CAAC;IAEH,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import type { StorageProvider, SearchOptions } from './StorageProvider.js';
|
|
2
|
+
import * as fs from 'fs';
|
|
3
|
+
import type { KnowledgeGraph, Relation } from '../KnowledgeGraphManager.js';
|
|
4
|
+
import type { VectorStoreFactoryOptions } from './VectorStoreFactory.js';
|
|
5
|
+
interface FileStorageProviderOptions {
|
|
6
|
+
memoryFilePath?: string;
|
|
7
|
+
filePath?: string;
|
|
8
|
+
vectorStoreOptions?: VectorStoreFactoryOptions;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* A storage provider that uses the file system to store the knowledge graph
|
|
12
|
+
* @deprecated This storage provider is deprecated and will be removed in a future version.
|
|
13
|
+
* Please migrate to SqliteStorageProvider.
|
|
14
|
+
*/
|
|
15
|
+
export declare class FileStorageProvider implements StorageProvider {
|
|
16
|
+
private _fs;
|
|
17
|
+
private filePath;
|
|
18
|
+
private graph;
|
|
19
|
+
private vectorStoreOptions?;
|
|
20
|
+
/**
|
|
21
|
+
* Create a new FileStorageProvider
|
|
22
|
+
* @param options Configuration options for the file storage provider
|
|
23
|
+
* @deprecated This storage provider is deprecated and will be removed in a future version.
|
|
24
|
+
* Please migrate to SqliteStorageProvider.
|
|
25
|
+
*/
|
|
26
|
+
constructor(options?: FileStorageProviderOptions);
|
|
27
|
+
/**
|
|
28
|
+
* Set the fs module (for testing purposes)
|
|
29
|
+
*/
|
|
30
|
+
setFs(fsModule: typeof fs): void;
|
|
31
|
+
/**
|
|
32
|
+
* Load the entire knowledge graph from the file
|
|
33
|
+
* @returns Promise resolving to the loaded KnowledgeGraph
|
|
34
|
+
*/
|
|
35
|
+
loadGraph(): Promise<KnowledgeGraph>;
|
|
36
|
+
/**
|
|
37
|
+
* Save the entire knowledge graph to the file
|
|
38
|
+
* @param graph The KnowledgeGraph to save
|
|
39
|
+
* @returns Promise that resolves when the save is complete
|
|
40
|
+
*/
|
|
41
|
+
saveGraph(graph: KnowledgeGraph): Promise<void>;
|
|
42
|
+
/**
|
|
43
|
+
* Search for nodes in the graph that match the query
|
|
44
|
+
* @param query The search query string
|
|
45
|
+
* @param options Optional search parameters
|
|
46
|
+
* @returns Promise resolving to a KnowledgeGraph containing matching nodes
|
|
47
|
+
*/
|
|
48
|
+
searchNodes(query: string, options?: SearchOptions): Promise<KnowledgeGraph>;
|
|
49
|
+
/**
|
|
50
|
+
* Open specific nodes by their exact names
|
|
51
|
+
* @param names Array of node names to open
|
|
52
|
+
* @returns Promise resolving to a KnowledgeGraph containing the specified nodes
|
|
53
|
+
*/
|
|
54
|
+
openNodes(names: string[]): Promise<KnowledgeGraph>;
|
|
55
|
+
/**
|
|
56
|
+
* Create new relations between entities
|
|
57
|
+
* @param relations Array of relations to create
|
|
58
|
+
* @returns Promise resolving to array of newly created relations
|
|
59
|
+
*/
|
|
60
|
+
createRelations(relations: Relation[]): Promise<Relation[]>;
|
|
61
|
+
/**
|
|
62
|
+
* Add observations to entities
|
|
63
|
+
* @param observations Array of observations to add
|
|
64
|
+
* @returns Promise resolving to array of added observations
|
|
65
|
+
*/
|
|
66
|
+
addObservations(observations: {
|
|
67
|
+
entityName: string;
|
|
68
|
+
contents: string[];
|
|
69
|
+
}[]): Promise<{
|
|
70
|
+
entityName: string;
|
|
71
|
+
addedObservations: string[];
|
|
72
|
+
}[]>;
|
|
73
|
+
/**
|
|
74
|
+
* Delete entities and their relations from the knowledge graph
|
|
75
|
+
* @param entityNames Array of entity names to delete
|
|
76
|
+
* @returns Promise that resolves when deletion is complete
|
|
77
|
+
*/
|
|
78
|
+
deleteEntities(entityNames: string[]): Promise<void>;
|
|
79
|
+
/**
|
|
80
|
+
* Delete specific observations from entities
|
|
81
|
+
* @param deletions Array of objects with entity name and observations to delete
|
|
82
|
+
* @returns Promise that resolves when deletion is complete
|
|
83
|
+
*/
|
|
84
|
+
deleteObservations(deletions: {
|
|
85
|
+
entityName: string;
|
|
86
|
+
observations: string[];
|
|
87
|
+
}[]): Promise<void>;
|
|
88
|
+
/**
|
|
89
|
+
* Delete relations from the graph
|
|
90
|
+
* @param relations Array of relations to delete
|
|
91
|
+
* @returns Promise that resolves when deletion is complete
|
|
92
|
+
* @deprecated FileStorageProvider is deprecated. Use SqliteStorageProvider instead.
|
|
93
|
+
*/
|
|
94
|
+
deleteRelations(relations: Relation[]): Promise<void>;
|
|
95
|
+
/**
|
|
96
|
+
* Get a specific relation by its identifying properties
|
|
97
|
+
* @param from Source entity name
|
|
98
|
+
* @param to Target entity name
|
|
99
|
+
* @param relationType Type of relation
|
|
100
|
+
* @returns Promise resolving to the relation or null if not found
|
|
101
|
+
*/
|
|
102
|
+
getRelation(from: string, to: string, relationType: string): Promise<Relation | null>;
|
|
103
|
+
/**
|
|
104
|
+
* Update an existing relation with new properties
|
|
105
|
+
* @param relation The relation with updated properties (from, to, and relationType identify the relation)
|
|
106
|
+
* @returns Promise that resolves when the update is complete
|
|
107
|
+
* @throws Error if the relation doesn't exist
|
|
108
|
+
*/
|
|
109
|
+
updateRelation(relation: Relation): Promise<void>;
|
|
110
|
+
/**
|
|
111
|
+
* Create new entities in the knowledge graph
|
|
112
|
+
* @param entities Array of entities to create
|
|
113
|
+
* @returns Promise resolving to the array of created entities with timestamps
|
|
114
|
+
* @deprecated FileStorageProvider is deprecated. Use SqliteStorageProvider instead.
|
|
115
|
+
*/
|
|
116
|
+
createEntities(entities: any[]): Promise<any[]>;
|
|
117
|
+
/**
|
|
118
|
+
* Get an entity by name
|
|
119
|
+
* @param entityName Name of the entity to retrieve
|
|
120
|
+
* @returns Promise resolving to the entity or null if not found
|
|
121
|
+
* @deprecated FileStorageProvider is deprecated. Use SqliteStorageProvider instead.
|
|
122
|
+
*/
|
|
123
|
+
getEntity(entityName: string): Promise<any | null>;
|
|
124
|
+
}
|
|
125
|
+
export {};
|