@coreidentitylabs/open-graph-memory-mcp 1.0.1
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/.agents/skills/mcp-builder/LICENSE.txt +202 -0
- package/.agents/skills/mcp-builder/SKILL.md +236 -0
- package/.agents/skills/mcp-builder/reference/evaluation.md +602 -0
- package/.agents/skills/mcp-builder/reference/mcp_best_practices.md +249 -0
- package/.agents/skills/mcp-builder/reference/node_mcp_server.md +970 -0
- package/.agents/skills/mcp-builder/reference/python_mcp_server.md +719 -0
- package/.agents/skills/mcp-builder/scripts/connections.py +151 -0
- package/.agents/skills/mcp-builder/scripts/evaluation.py +373 -0
- package/.agents/skills/mcp-builder/scripts/example_evaluation.xml +22 -0
- package/.agents/skills/mcp-builder/scripts/requirements.txt +2 -0
- package/.env.example +26 -0
- package/Implementation Plan.md +358 -0
- package/README.md +187 -0
- package/dist/constants.d.ts +34 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/constants.js +40 -0
- package/dist/constants.js.map +1 -0
- package/dist/encoding/embedder.d.ts +12 -0
- package/dist/encoding/embedder.d.ts.map +1 -0
- package/dist/encoding/embedder.js +85 -0
- package/dist/encoding/embedder.js.map +1 -0
- package/dist/encoding/pipeline.d.ts +28 -0
- package/dist/encoding/pipeline.d.ts.map +1 -0
- package/dist/encoding/pipeline.js +146 -0
- package/dist/encoding/pipeline.js.map +1 -0
- package/dist/evolution/consolidator.d.ts +12 -0
- package/dist/evolution/consolidator.d.ts.map +1 -0
- package/dist/evolution/consolidator.js +212 -0
- package/dist/evolution/consolidator.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +53 -0
- package/dist/index.js.map +1 -0
- package/dist/llm/openai-provider.d.ts +23 -0
- package/dist/llm/openai-provider.d.ts.map +1 -0
- package/dist/llm/openai-provider.js +141 -0
- package/dist/llm/openai-provider.js.map +1 -0
- package/dist/llm/prompts.d.ts +10 -0
- package/dist/llm/prompts.d.ts.map +1 -0
- package/dist/llm/prompts.js +63 -0
- package/dist/llm/prompts.js.map +1 -0
- package/dist/llm/provider.d.ts +7 -0
- package/dist/llm/provider.d.ts.map +1 -0
- package/dist/llm/provider.js +25 -0
- package/dist/llm/provider.js.map +1 -0
- package/dist/resources/context-resource.d.ts +8 -0
- package/dist/resources/context-resource.d.ts.map +1 -0
- package/dist/resources/context-resource.js +51 -0
- package/dist/resources/context-resource.js.map +1 -0
- package/dist/retrieval/search.d.ts +24 -0
- package/dist/retrieval/search.d.ts.map +1 -0
- package/dist/retrieval/search.js +143 -0
- package/dist/retrieval/search.js.map +1 -0
- package/dist/storage/factory.d.ts +10 -0
- package/dist/storage/factory.d.ts.map +1 -0
- package/dist/storage/factory.js +35 -0
- package/dist/storage/factory.js.map +1 -0
- package/dist/storage/json-store.d.ts +34 -0
- package/dist/storage/json-store.d.ts.map +1 -0
- package/dist/storage/json-store.js +248 -0
- package/dist/storage/json-store.js.map +1 -0
- package/dist/storage/neo4j-store.d.ts +31 -0
- package/dist/storage/neo4j-store.d.ts.map +1 -0
- package/dist/storage/neo4j-store.js +440 -0
- package/dist/storage/neo4j-store.js.map +1 -0
- package/dist/tools/memory-tools.d.ts +4 -0
- package/dist/tools/memory-tools.d.ts.map +1 -0
- package/dist/tools/memory-tools.js +873 -0
- package/dist/tools/memory-tools.js.map +1 -0
- package/dist/types.d.ts +129 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +5 -0
- package/dist/types.js.map +1 -0
- package/implementation_plan.md.resolved.md +322 -0
- package/package.json +43 -0
- package/src/constants.ts +52 -0
- package/src/encoding/embedder.ts +93 -0
- package/src/encoding/pipeline.ts +197 -0
- package/src/evolution/consolidator.ts +281 -0
- package/src/index.ts +67 -0
- package/src/llm/openai-provider.ts +208 -0
- package/src/llm/prompts.ts +66 -0
- package/src/llm/provider.ts +37 -0
- package/src/resources/context-resource.ts +74 -0
- package/src/retrieval/search.ts +203 -0
- package/src/storage/factory.ts +48 -0
- package/src/storage/json-store.ts +325 -0
- package/src/storage/neo4j-store.ts +564 -0
- package/src/tools/memory-tools.ts +1067 -0
- package/src/types.ts +207 -0
- package/tsconfig.json +21 -0
|
@@ -0,0 +1,440 @@
|
|
|
1
|
+
// =============================================================================
|
|
2
|
+
// Neo4j Graph Database Storage Backend
|
|
3
|
+
// =============================================================================
|
|
4
|
+
import neo4j from "neo4j-driver";
|
|
5
|
+
import { cosineSimilarity } from "../encoding/embedder.js";
|
|
6
|
+
export class Neo4jStore {
|
|
7
|
+
driver;
|
|
8
|
+
uri;
|
|
9
|
+
user;
|
|
10
|
+
password;
|
|
11
|
+
constructor(uri, user, password) {
|
|
12
|
+
this.uri = uri;
|
|
13
|
+
this.user = user;
|
|
14
|
+
this.password = password;
|
|
15
|
+
this.driver = neo4j.driver(this.uri, neo4j.auth.basic(this.user, this.password));
|
|
16
|
+
}
|
|
17
|
+
getSession() {
|
|
18
|
+
return this.driver.session();
|
|
19
|
+
}
|
|
20
|
+
async initialize() {
|
|
21
|
+
const session = this.getSession();
|
|
22
|
+
try {
|
|
23
|
+
// Create constraints and indexes
|
|
24
|
+
await session.run(`CREATE CONSTRAINT memory_node_id IF NOT EXISTS FOR (n:MemoryNode) REQUIRE n.id IS UNIQUE`);
|
|
25
|
+
await session.run(`CREATE CONSTRAINT memory_edge_id IF NOT EXISTS FOR ()-[r:MEMORY_EDGE]-() REQUIRE r.id IS UNIQUE`);
|
|
26
|
+
await session.run(`CREATE INDEX memory_node_name IF NOT EXISTS FOR (n:MemoryNode) ON (n.name)`);
|
|
27
|
+
await session.run(`CREATE INDEX memory_node_type IF NOT EXISTS FOR (n:MemoryNode) ON (n.type)`);
|
|
28
|
+
// Verify connection
|
|
29
|
+
const result = await session.run(`MATCH (n:MemoryNode) RETURN count(n) AS count`);
|
|
30
|
+
const count = result.records[0]?.get("count")?.toNumber() ?? 0;
|
|
31
|
+
console.error(`[open-memory] Connected to Neo4j at ${this.uri}. ${count} existing nodes.`);
|
|
32
|
+
}
|
|
33
|
+
finally {
|
|
34
|
+
await session.close();
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
// -- Node Operations -------------------------------------------------------
|
|
38
|
+
async addNode(node) {
|
|
39
|
+
const session = this.getSession();
|
|
40
|
+
try {
|
|
41
|
+
await session.run(`CREATE (n:MemoryNode {
|
|
42
|
+
id: $id, name: $name, type: $type, description: $description,
|
|
43
|
+
embedding: $embedding, metadata: $metadata,
|
|
44
|
+
createdAt: $createdAt, updatedAt: $updatedAt,
|
|
45
|
+
validFrom: $validFrom, validUntil: $validUntil,
|
|
46
|
+
source: $source, accessCount: $accessCount,
|
|
47
|
+
lastAccessedAt: $lastAccessedAt
|
|
48
|
+
})`, {
|
|
49
|
+
...node,
|
|
50
|
+
embedding: node.embedding ?? [],
|
|
51
|
+
metadata: JSON.stringify(node.metadata),
|
|
52
|
+
validFrom: node.validFrom ?? null,
|
|
53
|
+
validUntil: node.validUntil ?? null,
|
|
54
|
+
source: node.source ?? null,
|
|
55
|
+
lastAccessedAt: node.lastAccessedAt ?? null,
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
finally {
|
|
59
|
+
await session.close();
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
async updateNode(id, updates) {
|
|
63
|
+
const session = this.getSession();
|
|
64
|
+
try {
|
|
65
|
+
const setClause = buildSetClause(updates);
|
|
66
|
+
if (!setClause)
|
|
67
|
+
return await this.getNode(id);
|
|
68
|
+
const result = await session.run(`MATCH (n:MemoryNode {id: $id})
|
|
69
|
+
SET ${setClause}, n.updatedAt = $updatedAt
|
|
70
|
+
RETURN n`, {
|
|
71
|
+
id,
|
|
72
|
+
updatedAt: new Date().toISOString(),
|
|
73
|
+
...serializeUpdates(updates),
|
|
74
|
+
});
|
|
75
|
+
if (result.records.length === 0)
|
|
76
|
+
return null;
|
|
77
|
+
return deserializeNode(result.records[0].get("n").properties);
|
|
78
|
+
}
|
|
79
|
+
finally {
|
|
80
|
+
await session.close();
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
async deleteNode(id) {
|
|
84
|
+
const session = this.getSession();
|
|
85
|
+
try {
|
|
86
|
+
const result = await session.run(`MATCH (n:MemoryNode {id: $id}) DETACH DELETE n RETURN count(n) AS deleted`, { id });
|
|
87
|
+
return (result.records[0]?.get("deleted")?.toNumber() ?? 0) > 0;
|
|
88
|
+
}
|
|
89
|
+
finally {
|
|
90
|
+
await session.close();
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
async getNode(id) {
|
|
94
|
+
const session = this.getSession();
|
|
95
|
+
try {
|
|
96
|
+
const result = await session.run(`MATCH (n:MemoryNode {id: $id}) RETURN n`, { id });
|
|
97
|
+
if (result.records.length === 0)
|
|
98
|
+
return null;
|
|
99
|
+
return deserializeNode(result.records[0].get("n").properties);
|
|
100
|
+
}
|
|
101
|
+
finally {
|
|
102
|
+
await session.close();
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
async getNodeByName(name) {
|
|
106
|
+
const session = this.getSession();
|
|
107
|
+
try {
|
|
108
|
+
const result = await session.run(`MATCH (n:MemoryNode) WHERE toLower(n.name) = toLower($name) RETURN n LIMIT 1`, { name });
|
|
109
|
+
if (result.records.length === 0)
|
|
110
|
+
return null;
|
|
111
|
+
return deserializeNode(result.records[0].get("n").properties);
|
|
112
|
+
}
|
|
113
|
+
finally {
|
|
114
|
+
await session.close();
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
async findNodes(filter) {
|
|
118
|
+
const session = this.getSession();
|
|
119
|
+
try {
|
|
120
|
+
const conditions = [];
|
|
121
|
+
const params = {};
|
|
122
|
+
if (filter.type) {
|
|
123
|
+
conditions.push("n.type = $type");
|
|
124
|
+
params.type = filter.type;
|
|
125
|
+
}
|
|
126
|
+
if (filter.source) {
|
|
127
|
+
conditions.push("n.source = $source");
|
|
128
|
+
params.source = filter.source;
|
|
129
|
+
}
|
|
130
|
+
if (filter.nameContains) {
|
|
131
|
+
conditions.push("toLower(n.name) CONTAINS toLower($nameContains)");
|
|
132
|
+
params.nameContains = filter.nameContains;
|
|
133
|
+
}
|
|
134
|
+
if (filter.createdAfter) {
|
|
135
|
+
conditions.push("n.createdAt >= $createdAfter");
|
|
136
|
+
params.createdAfter = filter.createdAfter;
|
|
137
|
+
}
|
|
138
|
+
if (filter.createdBefore) {
|
|
139
|
+
conditions.push("n.createdAt <= $createdBefore");
|
|
140
|
+
params.createdBefore = filter.createdBefore;
|
|
141
|
+
}
|
|
142
|
+
const whereClause = conditions.length > 0 ? `WHERE ${conditions.join(" AND ")}` : "";
|
|
143
|
+
const result = await session.run(`MATCH (n:MemoryNode) ${whereClause} RETURN n ORDER BY n.updatedAt DESC`, params);
|
|
144
|
+
return result.records.map((r) => deserializeNode(r.get("n").properties));
|
|
145
|
+
}
|
|
146
|
+
finally {
|
|
147
|
+
await session.close();
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
async getAllNodes(limit, offset) {
|
|
151
|
+
const session = this.getSession();
|
|
152
|
+
try {
|
|
153
|
+
const countResult = await session.run(`MATCH (n:MemoryNode) RETURN count(n) AS total`);
|
|
154
|
+
const total = countResult.records[0]?.get("total")?.toNumber() ?? 0;
|
|
155
|
+
const result = await session.run(`MATCH (n:MemoryNode) RETURN n ORDER BY n.updatedAt DESC SKIP $offset LIMIT $limit`, { offset: neo4j.int(offset), limit: neo4j.int(limit) });
|
|
156
|
+
const nodes = result.records.map((r) => deserializeNode(r.get("n").properties));
|
|
157
|
+
return { nodes, total };
|
|
158
|
+
}
|
|
159
|
+
finally {
|
|
160
|
+
await session.close();
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
async findNodesByEmbedding(embedding, topK) {
|
|
164
|
+
// For now, fall back to client-side cosine similarity
|
|
165
|
+
// Neo4j vector index can be used in production for better perf
|
|
166
|
+
const session = this.getSession();
|
|
167
|
+
try {
|
|
168
|
+
const result = await session.run(`MATCH (n:MemoryNode) WHERE size(n.embedding) > 0 RETURN n`);
|
|
169
|
+
const scored = [];
|
|
170
|
+
for (const record of result.records) {
|
|
171
|
+
const node = deserializeNode(record.get("n").properties);
|
|
172
|
+
if (node.embedding && node.embedding.length > 0) {
|
|
173
|
+
const score = cosineSimilarity(embedding, node.embedding);
|
|
174
|
+
scored.push({ node, score, matchType: "semantic" });
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
scored.sort((a, b) => b.score - a.score);
|
|
178
|
+
return scored.slice(0, topK);
|
|
179
|
+
}
|
|
180
|
+
finally {
|
|
181
|
+
await session.close();
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
// -- Edge Operations --------------------------------------------------------
|
|
185
|
+
async addEdge(edge) {
|
|
186
|
+
const session = this.getSession();
|
|
187
|
+
try {
|
|
188
|
+
await session.run(`MATCH (s:MemoryNode {id: $source})
|
|
189
|
+
MATCH (t:MemoryNode {id: $target})
|
|
190
|
+
CREATE (s)-[r:MEMORY_EDGE {
|
|
191
|
+
id: $id, relation: $relation, description: $description,
|
|
192
|
+
weight: $weight, metadata: $metadata,
|
|
193
|
+
createdAt: $createdAt, updatedAt: $updatedAt
|
|
194
|
+
}]->(t)`, {
|
|
195
|
+
...edge,
|
|
196
|
+
metadata: JSON.stringify(edge.metadata),
|
|
197
|
+
});
|
|
198
|
+
}
|
|
199
|
+
finally {
|
|
200
|
+
await session.close();
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
async updateEdge(id, updates) {
|
|
204
|
+
const session = this.getSession();
|
|
205
|
+
try {
|
|
206
|
+
const setClause = buildEdgeSetClause(updates);
|
|
207
|
+
if (!setClause)
|
|
208
|
+
return await this.getEdge(id);
|
|
209
|
+
const result = await session.run(`MATCH ()-[r:MEMORY_EDGE {id: $id}]-()
|
|
210
|
+
SET ${setClause}, r.updatedAt = $updatedAt
|
|
211
|
+
RETURN r, startNode(r).id AS sourceId, endNode(r).id AS targetId`, {
|
|
212
|
+
id,
|
|
213
|
+
updatedAt: new Date().toISOString(),
|
|
214
|
+
...serializeEdgeUpdates(updates),
|
|
215
|
+
});
|
|
216
|
+
if (result.records.length === 0)
|
|
217
|
+
return null;
|
|
218
|
+
return deserializeEdge(result.records[0]);
|
|
219
|
+
}
|
|
220
|
+
finally {
|
|
221
|
+
await session.close();
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
async deleteEdge(id) {
|
|
225
|
+
const session = this.getSession();
|
|
226
|
+
try {
|
|
227
|
+
const result = await session.run(`MATCH ()-[r:MEMORY_EDGE {id: $id}]-() DELETE r RETURN count(r) AS deleted`, { id });
|
|
228
|
+
return (result.records[0]?.get("deleted")?.toNumber() ?? 0) > 0;
|
|
229
|
+
}
|
|
230
|
+
finally {
|
|
231
|
+
await session.close();
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
async getEdge(id) {
|
|
235
|
+
const session = this.getSession();
|
|
236
|
+
try {
|
|
237
|
+
const result = await session.run(`MATCH (s)-[r:MEMORY_EDGE {id: $id}]->(t) RETURN r, s.id AS sourceId, t.id AS targetId`, { id });
|
|
238
|
+
if (result.records.length === 0)
|
|
239
|
+
return null;
|
|
240
|
+
return deserializeEdge(result.records[0]);
|
|
241
|
+
}
|
|
242
|
+
finally {
|
|
243
|
+
await session.close();
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
async getEdgesForNode(nodeId, direction = "both") {
|
|
247
|
+
const session = this.getSession();
|
|
248
|
+
try {
|
|
249
|
+
let query;
|
|
250
|
+
if (direction === "out") {
|
|
251
|
+
query = `MATCH (s:MemoryNode {id: $nodeId})-[r:MEMORY_EDGE]->(t) RETURN r, s.id AS sourceId, t.id AS targetId`;
|
|
252
|
+
}
|
|
253
|
+
else if (direction === "in") {
|
|
254
|
+
query = `MATCH (s)-[r:MEMORY_EDGE]->(t:MemoryNode {id: $nodeId}) RETURN r, s.id AS sourceId, t.id AS targetId`;
|
|
255
|
+
}
|
|
256
|
+
else {
|
|
257
|
+
query = `MATCH (n:MemoryNode {id: $nodeId})-[r:MEMORY_EDGE]-(m) RETURN r, startNode(r).id AS sourceId, endNode(r).id AS targetId`;
|
|
258
|
+
}
|
|
259
|
+
const result = await session.run(query, { nodeId });
|
|
260
|
+
return result.records.map((rec) => deserializeEdge(rec));
|
|
261
|
+
}
|
|
262
|
+
finally {
|
|
263
|
+
await session.close();
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
async getEdgesBetween(sourceId, targetId) {
|
|
267
|
+
const session = this.getSession();
|
|
268
|
+
try {
|
|
269
|
+
const result = await session.run(`MATCH (s:MemoryNode)-[r:MEMORY_EDGE]-(t:MemoryNode)
|
|
270
|
+
WHERE (s.id = $sourceId AND t.id = $targetId)
|
|
271
|
+
OR (s.id = $targetId AND t.id = $sourceId)
|
|
272
|
+
RETURN r, startNode(r).id AS sourceId, endNode(r).id AS targetId`, { sourceId, targetId });
|
|
273
|
+
return result.records.map((rec) => deserializeEdge(rec));
|
|
274
|
+
}
|
|
275
|
+
finally {
|
|
276
|
+
await session.close();
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
// -- Graph Traversal --------------------------------------------------------
|
|
280
|
+
async getNeighborhood(nodeId, depth) {
|
|
281
|
+
const session = this.getSession();
|
|
282
|
+
try {
|
|
283
|
+
const result = await session.run(`MATCH path = (start:MemoryNode {id: $nodeId})-[*0..${depth}]-(neighbor:MemoryNode)
|
|
284
|
+
WITH DISTINCT neighbor, relationships(path) AS rels
|
|
285
|
+
UNWIND rels AS r
|
|
286
|
+
WITH collect(DISTINCT neighbor) AS nodes,
|
|
287
|
+
collect(DISTINCT {rel: r, source: startNode(r).id, target: endNode(r).id}) AS edges
|
|
288
|
+
RETURN nodes, edges`, { nodeId });
|
|
289
|
+
if (result.records.length === 0) {
|
|
290
|
+
// Return just the start node if it exists
|
|
291
|
+
const startNode = await this.getNode(nodeId);
|
|
292
|
+
return {
|
|
293
|
+
nodes: startNode ? [startNode] : [],
|
|
294
|
+
edges: [],
|
|
295
|
+
};
|
|
296
|
+
}
|
|
297
|
+
const record = result.records[0];
|
|
298
|
+
const rawNodes = record.get("nodes");
|
|
299
|
+
const rawEdges = record.get("edges");
|
|
300
|
+
const nodes = (rawNodes || []).map((n) => deserializeNode(n.properties));
|
|
301
|
+
const edges = (rawEdges || []).map((e) => {
|
|
302
|
+
const edge = e;
|
|
303
|
+
return {
|
|
304
|
+
id: edge.rel.properties.id,
|
|
305
|
+
source: edge.source,
|
|
306
|
+
target: edge.target,
|
|
307
|
+
relation: edge.rel.properties.relation,
|
|
308
|
+
description: edge.rel.properties.description,
|
|
309
|
+
weight: edge.rel.properties.weight,
|
|
310
|
+
metadata: JSON.parse(edge.rel.properties.metadata || "{}"),
|
|
311
|
+
createdAt: edge.rel.properties.createdAt,
|
|
312
|
+
updatedAt: edge.rel.properties.updatedAt,
|
|
313
|
+
};
|
|
314
|
+
});
|
|
315
|
+
return { nodes, edges };
|
|
316
|
+
}
|
|
317
|
+
finally {
|
|
318
|
+
await session.close();
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
// -- Stats & Lifecycle ------------------------------------------------------
|
|
322
|
+
async getStats() {
|
|
323
|
+
const session = this.getSession();
|
|
324
|
+
try {
|
|
325
|
+
const nodesResult = await session.run(`MATCH (n:MemoryNode) RETURN n.type AS type, count(n) AS count`);
|
|
326
|
+
const nodesByType = {};
|
|
327
|
+
let totalNodes = 0;
|
|
328
|
+
for (const record of nodesResult.records) {
|
|
329
|
+
const type = record.get("type");
|
|
330
|
+
const count = record.get("count").toNumber();
|
|
331
|
+
nodesByType[type] = count;
|
|
332
|
+
totalNodes += count;
|
|
333
|
+
}
|
|
334
|
+
const edgesResult = await session.run(`MATCH ()-[r:MEMORY_EDGE]-() RETURN count(r) AS total`);
|
|
335
|
+
const totalEdges = edgesResult.records[0]?.get("total")?.toNumber() ?? 0;
|
|
336
|
+
return {
|
|
337
|
+
totalNodes,
|
|
338
|
+
totalEdges,
|
|
339
|
+
nodesByType,
|
|
340
|
+
storageBackend: "neo4j",
|
|
341
|
+
};
|
|
342
|
+
}
|
|
343
|
+
finally {
|
|
344
|
+
await session.close();
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
async close() {
|
|
348
|
+
await this.driver.close();
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
// =============================================================================
|
|
352
|
+
// Serialization Helpers
|
|
353
|
+
// =============================================================================
|
|
354
|
+
function deserializeNode(props) {
|
|
355
|
+
return {
|
|
356
|
+
id: props.id,
|
|
357
|
+
name: props.name,
|
|
358
|
+
type: props.type,
|
|
359
|
+
description: props.description,
|
|
360
|
+
embedding: props.embedding ?? [],
|
|
361
|
+
metadata: typeof props.metadata === "string"
|
|
362
|
+
? JSON.parse(props.metadata)
|
|
363
|
+
: (props.metadata ?? {}),
|
|
364
|
+
createdAt: props.createdAt,
|
|
365
|
+
updatedAt: props.updatedAt,
|
|
366
|
+
validFrom: props.validFrom ?? undefined,
|
|
367
|
+
validUntil: props.validUntil ?? undefined,
|
|
368
|
+
source: props.source ?? undefined,
|
|
369
|
+
accessCount: typeof props.accessCount === "object" && props.accessCount !== null
|
|
370
|
+
? props.accessCount.toNumber()
|
|
371
|
+
: (props.accessCount ?? 0),
|
|
372
|
+
lastAccessedAt: props.lastAccessedAt ?? undefined,
|
|
373
|
+
};
|
|
374
|
+
}
|
|
375
|
+
function deserializeEdge(record) {
|
|
376
|
+
const rel = record.get("r");
|
|
377
|
+
const props = rel.properties;
|
|
378
|
+
return {
|
|
379
|
+
id: props.id,
|
|
380
|
+
source: record.get("sourceId"),
|
|
381
|
+
target: record.get("targetId"),
|
|
382
|
+
relation: props.relation,
|
|
383
|
+
description: props.description,
|
|
384
|
+
weight: props.weight,
|
|
385
|
+
metadata: typeof props.metadata === "string"
|
|
386
|
+
? JSON.parse(props.metadata)
|
|
387
|
+
: (props.metadata ?? {}),
|
|
388
|
+
createdAt: props.createdAt,
|
|
389
|
+
updatedAt: props.updatedAt,
|
|
390
|
+
};
|
|
391
|
+
}
|
|
392
|
+
function buildSetClause(updates) {
|
|
393
|
+
const parts = [];
|
|
394
|
+
if (updates.name !== undefined)
|
|
395
|
+
parts.push("n.name = $name");
|
|
396
|
+
if (updates.description !== undefined)
|
|
397
|
+
parts.push("n.description = $description");
|
|
398
|
+
if (updates.type !== undefined)
|
|
399
|
+
parts.push("n.type = $type");
|
|
400
|
+
if (updates.embedding !== undefined)
|
|
401
|
+
parts.push("n.embedding = $embedding");
|
|
402
|
+
if (updates.metadata !== undefined)
|
|
403
|
+
parts.push("n.metadata = $metadata");
|
|
404
|
+
if (updates.validFrom !== undefined)
|
|
405
|
+
parts.push("n.validFrom = $validFrom");
|
|
406
|
+
if (updates.validUntil !== undefined)
|
|
407
|
+
parts.push("n.validUntil = $validUntil");
|
|
408
|
+
if (updates.accessCount !== undefined)
|
|
409
|
+
parts.push("n.accessCount = $accessCount");
|
|
410
|
+
if (updates.lastAccessedAt !== undefined)
|
|
411
|
+
parts.push("n.lastAccessedAt = $lastAccessedAt");
|
|
412
|
+
return parts.join(", ");
|
|
413
|
+
}
|
|
414
|
+
function buildEdgeSetClause(updates) {
|
|
415
|
+
const parts = [];
|
|
416
|
+
if (updates.relation !== undefined)
|
|
417
|
+
parts.push("r.relation = $relation");
|
|
418
|
+
if (updates.description !== undefined)
|
|
419
|
+
parts.push("r.description = $description");
|
|
420
|
+
if (updates.weight !== undefined)
|
|
421
|
+
parts.push("r.weight = $weight");
|
|
422
|
+
if (updates.metadata !== undefined)
|
|
423
|
+
parts.push("r.metadata = $metadata");
|
|
424
|
+
return parts.join(", ");
|
|
425
|
+
}
|
|
426
|
+
function serializeUpdates(updates) {
|
|
427
|
+
const result = { ...updates };
|
|
428
|
+
if (updates.metadata !== undefined) {
|
|
429
|
+
result.metadata = JSON.stringify(updates.metadata);
|
|
430
|
+
}
|
|
431
|
+
return result;
|
|
432
|
+
}
|
|
433
|
+
function serializeEdgeUpdates(updates) {
|
|
434
|
+
const result = { ...updates };
|
|
435
|
+
if (updates.metadata !== undefined) {
|
|
436
|
+
result.metadata = JSON.stringify(updates.metadata);
|
|
437
|
+
}
|
|
438
|
+
return result;
|
|
439
|
+
}
|
|
440
|
+
//# sourceMappingURL=neo4j-store.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"neo4j-store.js","sourceRoot":"","sources":["../../src/storage/neo4j-store.ts"],"names":[],"mappings":"AAAA,gFAAgF;AAChF,uCAAuC;AACvC,gFAAgF;AAEhF,OAAO,KAA0B,MAAM,cAAc,CAAC;AAUtD,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAE3D,MAAM,OAAO,UAAU;IACb,MAAM,CAAS;IACf,GAAG,CAAS;IACZ,IAAI,CAAS;IACb,QAAQ,CAAS;IAEzB,YAAY,GAAW,EAAE,IAAY,EAAE,QAAgB;QACrD,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC,MAAM,CACxB,IAAI,CAAC,GAAG,EACR,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,QAAQ,CAAC,CAC3C,CAAC;IACJ,CAAC;IAEO,UAAU;QAChB,OAAO,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;IAC/B,CAAC;IAED,KAAK,CAAC,UAAU;QACd,MAAM,OAAO,GAAG,IAAI,CAAC,UAAU,EAAE,CAAC;QAClC,IAAI,CAAC;YACH,iCAAiC;YACjC,MAAM,OAAO,CAAC,GAAG,CACf,0FAA0F,CAC3F,CAAC;YACF,MAAM,OAAO,CAAC,GAAG,CACf,iGAAiG,CAClG,CAAC;YACF,MAAM,OAAO,CAAC,GAAG,CACf,4EAA4E,CAC7E,CAAC;YACF,MAAM,OAAO,CAAC,GAAG,CACf,4EAA4E,CAC7E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AAC,SAAS,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;IACrD,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
2
|
+
import type { StorageBackend, LLMProvider } from "../types.js";
|
|
3
|
+
export declare function registerMemoryTools(server: McpServer, store: StorageBackend, llm?: LLMProvider | null): void;
|
|
4
|
+
//# sourceMappingURL=memory-tools.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"memory-tools.d.ts","sourceRoot":"","sources":["../../src/tools/memory-tools.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAGpE,OAAO,KAAK,EACV,cAAc,EAKd,WAAW,EACZ,MAAM,aAAa,CAAC;AAerB,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,SAAS,EACjB,KAAK,EAAE,cAAc,EACrB,GAAG,CAAC,EAAE,WAAW,GAAG,IAAI,GACvB,IAAI,CA6BN"}
|