@aeriondyseti/vector-memory-mcp 0.9.0-dev.5 → 0.9.0-dev.8
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/dist/package.json +72 -0
- package/dist/scripts/test-runner.d.ts +9 -0
- package/dist/scripts/test-runner.d.ts.map +1 -0
- package/dist/scripts/test-runner.js +61 -0
- package/dist/scripts/test-runner.js.map +1 -0
- package/dist/scripts/warmup.d.ts +8 -0
- package/dist/scripts/warmup.d.ts.map +1 -0
- package/dist/scripts/warmup.js +61 -0
- package/dist/scripts/warmup.js.map +1 -0
- package/dist/src/config/index.d.ts +24 -0
- package/dist/src/config/index.d.ts.map +1 -0
- package/dist/src/config/index.js +48 -0
- package/dist/src/config/index.js.map +1 -0
- package/dist/src/db/connection.d.ts +3 -0
- package/dist/src/db/connection.d.ts.map +1 -0
- package/dist/src/db/connection.js +10 -0
- package/dist/src/db/connection.js.map +1 -0
- package/dist/src/db/memory.repository.d.ts +38 -0
- package/dist/src/db/memory.repository.d.ts.map +1 -0
- package/dist/src/db/memory.repository.js +176 -0
- package/dist/src/db/memory.repository.js.map +1 -0
- package/dist/src/db/schema.d.ts +4 -0
- package/dist/src/db/schema.d.ts.map +1 -0
- package/dist/src/db/schema.js +15 -0
- package/dist/src/db/schema.js.map +1 -0
- package/dist/src/http/mcp-transport.d.ts +19 -0
- package/dist/src/http/mcp-transport.d.ts.map +1 -0
- package/dist/src/http/mcp-transport.js +191 -0
- package/dist/src/http/mcp-transport.js.map +1 -0
- package/dist/src/http/server.d.ts +13 -0
- package/dist/src/http/server.d.ts.map +1 -0
- package/dist/src/http/server.js +210 -0
- package/dist/src/http/server.js.map +1 -0
- package/dist/src/index.d.ts +3 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +59 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/mcp/handlers.d.ts +12 -0
- package/dist/src/mcp/handlers.d.ts.map +1 -0
- package/dist/src/mcp/handlers.js +198 -0
- package/dist/src/mcp/handlers.js.map +1 -0
- package/dist/src/mcp/server.d.ts +5 -0
- package/dist/src/mcp/server.d.ts.map +1 -0
- package/dist/src/mcp/server.js +22 -0
- package/dist/src/mcp/server.js.map +1 -0
- package/dist/src/mcp/tools.d.ts +10 -0
- package/dist/src/mcp/tools.d.ts.map +1 -0
- package/dist/src/mcp/tools.js +272 -0
- package/dist/src/mcp/tools.js.map +1 -0
- package/dist/src/services/embeddings.service.d.ts +12 -0
- package/dist/src/services/embeddings.service.d.ts.map +1 -0
- package/dist/src/services/embeddings.service.js +37 -0
- package/dist/src/services/embeddings.service.js.map +1 -0
- package/dist/src/services/memory.service.d.ts +33 -0
- package/dist/src/services/memory.service.d.ts.map +1 -0
- package/dist/src/services/memory.service.js +200 -0
- package/dist/src/services/memory.service.js.map +1 -0
- package/dist/src/types/memory.d.ts +28 -0
- package/dist/src/types/memory.d.ts.map +1 -0
- package/dist/src/types/memory.js +18 -0
- package/dist/src/types/memory.js.map +1 -0
- package/package.json +11 -8
- package/src/config/index.ts +5 -2
- package/src/http/server.ts +85 -12
- package/scripts/publish.ts +0 -61
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
export async function handleStoreMemories(args, service) {
|
|
2
|
+
const memories = args?.memories;
|
|
3
|
+
const ids = [];
|
|
4
|
+
for (const item of memories) {
|
|
5
|
+
const memory = await service.store(item.content, item.metadata ?? {}, item.embedding_text);
|
|
6
|
+
ids.push(memory.id);
|
|
7
|
+
}
|
|
8
|
+
return {
|
|
9
|
+
content: [
|
|
10
|
+
{
|
|
11
|
+
type: "text",
|
|
12
|
+
text: ids.length === 1
|
|
13
|
+
? `Memory stored with ID: ${ids[0]}`
|
|
14
|
+
: `Stored ${ids.length} memories:\n${ids.map((id) => `- ${id}`).join("\n")}`,
|
|
15
|
+
},
|
|
16
|
+
],
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
export async function handleDeleteMemories(args, service) {
|
|
20
|
+
const ids = args?.ids;
|
|
21
|
+
const results = [];
|
|
22
|
+
for (const id of ids) {
|
|
23
|
+
const success = await service.delete(id);
|
|
24
|
+
results.push(success ? `Memory ${id} deleted successfully` : `Memory ${id} not found`);
|
|
25
|
+
}
|
|
26
|
+
return {
|
|
27
|
+
content: [
|
|
28
|
+
{
|
|
29
|
+
type: "text",
|
|
30
|
+
text: results.join("\n"),
|
|
31
|
+
},
|
|
32
|
+
],
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
export async function handleUpdateMemories(args, service) {
|
|
36
|
+
const updates = args?.updates;
|
|
37
|
+
const results = [];
|
|
38
|
+
for (const update of updates) {
|
|
39
|
+
const memory = await service.update(update.id, {
|
|
40
|
+
content: update.content,
|
|
41
|
+
embeddingText: update.embedding_text,
|
|
42
|
+
metadata: update.metadata,
|
|
43
|
+
});
|
|
44
|
+
if (memory) {
|
|
45
|
+
results.push(`Memory ${update.id} updated successfully`);
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
results.push(`Memory ${update.id} not found`);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
return {
|
|
52
|
+
content: [
|
|
53
|
+
{
|
|
54
|
+
type: "text",
|
|
55
|
+
text: results.join("\n"),
|
|
56
|
+
},
|
|
57
|
+
],
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
export async function handleSearchMemories(args, service) {
|
|
61
|
+
const query = args?.query;
|
|
62
|
+
const intent = args?.intent ?? "fact_check";
|
|
63
|
+
const _reasonForSearch = args?.reason_for_search; // Logged but not used in logic
|
|
64
|
+
const limit = args?.limit ?? 10;
|
|
65
|
+
const includeDeleted = args?.include_deleted ?? false;
|
|
66
|
+
const memories = await service.search(query, intent, limit, includeDeleted);
|
|
67
|
+
if (memories.length === 0) {
|
|
68
|
+
return {
|
|
69
|
+
content: [{ type: "text", text: "No memories found matching your query." }],
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
const results = memories.map((mem) => {
|
|
73
|
+
let result = `ID: ${mem.id}\nContent: ${mem.content}`;
|
|
74
|
+
if (Object.keys(mem.metadata).length > 0) {
|
|
75
|
+
result += `\nMetadata: ${JSON.stringify(mem.metadata)}`;
|
|
76
|
+
}
|
|
77
|
+
if (includeDeleted && mem.supersededBy) {
|
|
78
|
+
result += `\n[DELETED]`;
|
|
79
|
+
}
|
|
80
|
+
return result;
|
|
81
|
+
});
|
|
82
|
+
return {
|
|
83
|
+
content: [{ type: "text", text: results.join("\n\n---\n\n") }],
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
export async function handleGetMemories(args, service) {
|
|
87
|
+
const ids = args?.ids;
|
|
88
|
+
const format = (memoryId, memory) => {
|
|
89
|
+
if (!memory) {
|
|
90
|
+
return `Memory ${memoryId} not found`;
|
|
91
|
+
}
|
|
92
|
+
let result = `ID: ${memory.id}\nContent: ${memory.content}`;
|
|
93
|
+
if (Object.keys(memory.metadata).length > 0) {
|
|
94
|
+
result += `\nMetadata: ${JSON.stringify(memory.metadata)}`;
|
|
95
|
+
}
|
|
96
|
+
result += `\nCreated: ${memory.createdAt.toISOString()}`;
|
|
97
|
+
result += `\nUpdated: ${memory.updatedAt.toISOString()}`;
|
|
98
|
+
if (memory.supersededBy) {
|
|
99
|
+
result += `\nSuperseded by: ${memory.supersededBy}`;
|
|
100
|
+
}
|
|
101
|
+
return result;
|
|
102
|
+
};
|
|
103
|
+
const blocks = [];
|
|
104
|
+
for (const id of ids) {
|
|
105
|
+
const memory = await service.get(id);
|
|
106
|
+
blocks.push(format(id, memory));
|
|
107
|
+
}
|
|
108
|
+
return {
|
|
109
|
+
content: [{ type: "text", text: blocks.join("\n\n---\n\n") }],
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
export async function handleReportMemoryUsefulness(args, service) {
|
|
113
|
+
const memoryId = args?.memory_id;
|
|
114
|
+
const useful = args?.useful;
|
|
115
|
+
const memory = await service.vote(memoryId, useful ? 1 : -1);
|
|
116
|
+
if (!memory) {
|
|
117
|
+
return {
|
|
118
|
+
content: [{ type: "text", text: `Memory ${memoryId} not found` }],
|
|
119
|
+
isError: true,
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
return {
|
|
123
|
+
content: [
|
|
124
|
+
{
|
|
125
|
+
type: "text",
|
|
126
|
+
text: `Memory ${memoryId} marked as ${useful ? "useful" : "not useful"}. New usefulness score: ${memory.usefulness}`,
|
|
127
|
+
},
|
|
128
|
+
],
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
export async function handleStoreHandoff(args, service) {
|
|
132
|
+
const memory = await service.storeHandoff({
|
|
133
|
+
project: args?.project,
|
|
134
|
+
branch: args?.branch,
|
|
135
|
+
summary: args?.summary,
|
|
136
|
+
completed: args?.completed ?? [],
|
|
137
|
+
in_progress_blocked: args?.in_progress_blocked ?? [],
|
|
138
|
+
key_decisions: args?.key_decisions ?? [],
|
|
139
|
+
next_steps: args?.next_steps ?? [],
|
|
140
|
+
memory_ids: args?.memory_ids ?? [],
|
|
141
|
+
metadata: args?.metadata ?? {},
|
|
142
|
+
});
|
|
143
|
+
return {
|
|
144
|
+
content: [{ type: "text", text: `Handoff stored with memory ID: ${memory.id}` }],
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
export async function handleGetHandoff(_args, service) {
|
|
148
|
+
const handoff = await service.getLatestHandoff();
|
|
149
|
+
if (!handoff) {
|
|
150
|
+
return {
|
|
151
|
+
content: [{ type: "text", text: "No stored handoff found." }],
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
// Fetch referenced memories if any
|
|
155
|
+
const memoryIds = handoff.metadata.memory_ids ?? [];
|
|
156
|
+
let memoriesSection = "";
|
|
157
|
+
if (memoryIds.length > 0) {
|
|
158
|
+
const memories = [];
|
|
159
|
+
for (const id of memoryIds) {
|
|
160
|
+
const memory = await service.get(id);
|
|
161
|
+
if (memory) {
|
|
162
|
+
memories.push(`### Memory: ${id}\n${memory.content}`);
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
if (memories.length > 0) {
|
|
166
|
+
memoriesSection = `\n\n## Referenced Memories\n\n${memories.join("\n\n")}`;
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
return {
|
|
170
|
+
content: [{ type: "text", text: handoff.content + memoriesSection }],
|
|
171
|
+
};
|
|
172
|
+
}
|
|
173
|
+
export async function handleToolCall(name, args, service) {
|
|
174
|
+
switch (name) {
|
|
175
|
+
case "store_memories":
|
|
176
|
+
return handleStoreMemories(args, service);
|
|
177
|
+
case "update_memories":
|
|
178
|
+
return handleUpdateMemories(args, service);
|
|
179
|
+
case "delete_memories":
|
|
180
|
+
return handleDeleteMemories(args, service);
|
|
181
|
+
case "search_memories":
|
|
182
|
+
return handleSearchMemories(args, service);
|
|
183
|
+
case "get_memories":
|
|
184
|
+
return handleGetMemories(args, service);
|
|
185
|
+
case "report_memory_usefulness":
|
|
186
|
+
return handleReportMemoryUsefulness(args, service);
|
|
187
|
+
case "store_handoff":
|
|
188
|
+
return handleStoreHandoff(args, service);
|
|
189
|
+
case "get_handoff":
|
|
190
|
+
return handleGetHandoff(args, service);
|
|
191
|
+
default:
|
|
192
|
+
return {
|
|
193
|
+
content: [{ type: "text", text: `Unknown tool: ${name}` }],
|
|
194
|
+
isError: true,
|
|
195
|
+
};
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
//# sourceMappingURL=handlers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"handlers.js","sourceRoot":"","sources":["../../../src/mcp/handlers.ts"],"names":[],"mappings":"AAIA,MAAM,CAAC,KAAK,UAAU,mBAAmB,CACvC,IAAyC,EACzC,OAAsB;IAEtB,MAAM,QAAQ,GAAG,IAAI,EAAE,QAIrB,CAAC;IAEH,MAAM,GAAG,GAAa,EAAE,CAAC;IACzB,KAAK,MAAM,IAAI,IAAI,QAAQ,EAAE,CAAC;QAC5B,MAAM,MAAM,GAAG,MAAM,OAAO,CAAC,KAAK,CAChC,IAAI,CAAC,OA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C,IAAI,EAAE,OAAO,CAAC,CAAC;QACrD,KAAK,eAAe;YAClB,OAAO,kBAAkB,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;QAC3C,KAAK,aAAa;YAChB,OAAO,gBAAgB,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;QACzC;YACE,OAAO;gBACL,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,iBAAiB,IAAI,EAAE,EAAE,CAAC;gBAC1D,OAAO,EAAE,IAAI;aACd,CAAC;IACN,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { Server } from "@modelcontextprotocol/sdk/server/index.js";
|
|
2
|
+
import type { MemoryService } from "../services/memory.service.js";
|
|
3
|
+
export declare function createServer(memoryService: MemoryService): Server;
|
|
4
|
+
export declare function startServer(memoryService: MemoryService): Promise<void>;
|
|
5
|
+
//# sourceMappingURL=server.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../../src/mcp/server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AASnE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAEnE,wBAAgB,YAAY,CAAC,aAAa,EAAE,aAAa,GAAG,MAAM,CAgBjE;AAED,wBAAsB,WAAW,CAAC,aAAa,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC,CAI7E"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { Server } from "@modelcontextprotocol/sdk/server/index.js";
|
|
2
|
+
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
3
|
+
import { CallToolRequestSchema, ListToolsRequestSchema, } from "@modelcontextprotocol/sdk/types.js";
|
|
4
|
+
import { tools } from "./tools.js";
|
|
5
|
+
import { handleToolCall } from "./handlers.js";
|
|
6
|
+
export function createServer(memoryService) {
|
|
7
|
+
const server = new Server({ name: "vector-memory-mcp", version: "0.6.0" }, { capabilities: { tools: {} } });
|
|
8
|
+
server.setRequestHandler(ListToolsRequestSchema, async () => {
|
|
9
|
+
return { tools };
|
|
10
|
+
});
|
|
11
|
+
server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
12
|
+
const { name, arguments: args } = request.params;
|
|
13
|
+
return handleToolCall(name, args, memoryService);
|
|
14
|
+
});
|
|
15
|
+
return server;
|
|
16
|
+
}
|
|
17
|
+
export async function startServer(memoryService) {
|
|
18
|
+
const server = createServer(memoryService);
|
|
19
|
+
const transport = new StdioServerTransport();
|
|
20
|
+
await server.connect(transport);
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=server.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.js","sourceRoot":"","sources":["../../../src/mcp/server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AACnE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,EACL,qBAAqB,EACrB,sBAAsB,GACvB,MAAM,oCAAoC,CAAC;AAE5C,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAG/C,MAAM,UAAU,YAAY,CAAC,aAA4B;IACvD,MAAM,MAAM,GAAG,IAAI,MAAM,CACvB,EAAE,IAAI,EAAE,mBAAmB,EAAE,OAAO,EAAE,OAAO,EAAE,EAC/C,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,EAAE,CAChC,CAAC;IAEF,MAAM,CAAC,iBAAiB,CAAC,sBAAsB,EAAE,KAAK,IAAI,EAAE;QAC1D,OAAO,EAAE,KAAK,EAAE,CAAC;IACnB,CAAC,CAAC,CAAC;IAEH,MAAM,CAAC,iBAAiB,CAAC,qBAAqB,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE;QAChE,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC;QACjD,OAAO,cAAc,CAAC,IAAI,EAAE,IAAI,EAAE,aAAa,CAAC,CAAC;IACnD,CAAC,CAAC,CAAC;IAEH,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,WAAW,CAAC,aAA4B;IAC5D,MAAM,MAAM,GAAG,YAAY,CAAC,aAAa,CAAC,CAAC;IAC3C,MAAM,SAAS,GAAG,IAAI,oBAAoB,EAAE,CAAC;IAC7C,MAAM,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;AAClC,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Tool } from "@modelcontextprotocol/sdk/types.js";
|
|
2
|
+
export declare const storeMemoriesTool: Tool;
|
|
3
|
+
export declare const deleteMemoriesTool: Tool;
|
|
4
|
+
export declare const searchMemoriesTool: Tool;
|
|
5
|
+
export declare const getMemoriesTool: Tool;
|
|
6
|
+
export declare const reportMemoryUsefulnessTool: Tool;
|
|
7
|
+
export declare const storeHandoffTool: Tool;
|
|
8
|
+
export declare const getHandoffTool: Tool;
|
|
9
|
+
export declare const tools: Tool[];
|
|
10
|
+
//# sourceMappingURL=tools.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../../../src/mcp/tools.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,oCAAoC,CAAC;AAE/D,eAAO,MAAM,iBAAiB,EAAE,IAsD/B,CAAC;AAEF,eAAO,MAAM,kBAAkB,EAAE,IAkBhC,CAAC;AA+CF,eAAO,MAAM,kBAAkB,EAAE,IAiDhC,CAAC;AAEF,eAAO,MAAM,eAAe,EAAE,IAe7B,CAAC;AAEF,eAAO,MAAM,0BAA0B,EAAE,IAiBxC,CAAC;AAEF,eAAO,MAAM,gBAAgB,EAAE,IAoD9B,CAAC;AAEF,eAAO,MAAM,cAAc,EAAE,IAQ5B,CAAC;AAEF,eAAO,MAAM,KAAK,EAAE,IAAI,EASvB,CAAC"}
|
|
@@ -0,0 +1,272 @@
|
|
|
1
|
+
export const storeMemoriesTool = {
|
|
2
|
+
name: "store_memories",
|
|
3
|
+
description: `Store memories that persist across conversations. Use after making decisions or learning something worth remembering.
|
|
4
|
+
|
|
5
|
+
RULES:
|
|
6
|
+
- 1 concept per memory, 1-3 sentences (20-75 words)
|
|
7
|
+
- Self-contained with explicit subjects (no "it", "this", "the project")
|
|
8
|
+
- Include dates/versions when relevant
|
|
9
|
+
- Be concrete, not vague
|
|
10
|
+
|
|
11
|
+
MEMORY TYPES (use as metadata.type):
|
|
12
|
+
- decision: what was chosen + why ("Chose libSQL over PostgreSQL for vector support and simpler deployment")
|
|
13
|
+
- implementation: what was built + where + patterns used
|
|
14
|
+
- insight: learning + why it matters
|
|
15
|
+
- blocker: problem encountered + resolution
|
|
16
|
+
- next-step: TODO item + suggested approach
|
|
17
|
+
- context: background info + constraints
|
|
18
|
+
|
|
19
|
+
DON'T STORE: machine-specific paths, local env details, ephemeral states, pleasantries
|
|
20
|
+
|
|
21
|
+
GOOD: "Aerion chose libSQL over PostgreSQL for Resonance (Dec 2024) because of native vector support and simpler deployment."
|
|
22
|
+
BAD: "Uses SQLite" (no context, no subject, no reasoning)
|
|
23
|
+
|
|
24
|
+
For long content (>1000 chars), provide embedding_text with a searchable summary.`,
|
|
25
|
+
inputSchema: {
|
|
26
|
+
type: "object",
|
|
27
|
+
properties: {
|
|
28
|
+
memories: {
|
|
29
|
+
type: "array",
|
|
30
|
+
description: "Memories to store.",
|
|
31
|
+
items: {
|
|
32
|
+
type: "object",
|
|
33
|
+
properties: {
|
|
34
|
+
content: {
|
|
35
|
+
type: "string",
|
|
36
|
+
description: "The content to store.",
|
|
37
|
+
},
|
|
38
|
+
embedding_text: {
|
|
39
|
+
type: "string",
|
|
40
|
+
description: "Summary for search embedding (required if content >1000 chars).",
|
|
41
|
+
},
|
|
42
|
+
metadata: {
|
|
43
|
+
type: "object",
|
|
44
|
+
description: "Optional key-value metadata.",
|
|
45
|
+
additionalProperties: true,
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
required: ["content"],
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
required: ["memories"],
|
|
53
|
+
},
|
|
54
|
+
};
|
|
55
|
+
;
|
|
56
|
+
export const deleteMemoriesTool = {
|
|
57
|
+
name: "delete_memories",
|
|
58
|
+
description: "Remove memories that are no longer needed—outdated info, superseded decisions, or incorrect content. " +
|
|
59
|
+
"Deleted memories can be recovered via search_memories with include_deleted: true.",
|
|
60
|
+
inputSchema: {
|
|
61
|
+
type: "object",
|
|
62
|
+
properties: {
|
|
63
|
+
ids: {
|
|
64
|
+
type: "array",
|
|
65
|
+
description: "IDs of memories to delete.",
|
|
66
|
+
items: {
|
|
67
|
+
type: "string",
|
|
68
|
+
},
|
|
69
|
+
},
|
|
70
|
+
},
|
|
71
|
+
required: ["ids"],
|
|
72
|
+
},
|
|
73
|
+
};
|
|
74
|
+
;
|
|
75
|
+
const updateMemoriesTool = {
|
|
76
|
+
name: "update_memories",
|
|
77
|
+
description: `Update existing memories in place. Prefer over delete+create when updating the same conceptual item.
|
|
78
|
+
|
|
79
|
+
BEHAVIOR:
|
|
80
|
+
- Fields omitted/null: left untouched
|
|
81
|
+
- Fields provided: completely overwrite existing value (no merge)
|
|
82
|
+
|
|
83
|
+
Use to correct content, refine embedding text, or replace metadata without changing the memory ID.`,
|
|
84
|
+
inputSchema: {
|
|
85
|
+
type: "object",
|
|
86
|
+
properties: {
|
|
87
|
+
updates: {
|
|
88
|
+
type: "array",
|
|
89
|
+
description: "Updates to apply. Each must include id and at least one field to change.",
|
|
90
|
+
items: {
|
|
91
|
+
type: "object",
|
|
92
|
+
properties: {
|
|
93
|
+
id: {
|
|
94
|
+
type: "string",
|
|
95
|
+
description: "ID of memory to update.",
|
|
96
|
+
},
|
|
97
|
+
content: {
|
|
98
|
+
type: "string",
|
|
99
|
+
description: "New content (triggers embedding regeneration).",
|
|
100
|
+
},
|
|
101
|
+
embedding_text: {
|
|
102
|
+
type: "string",
|
|
103
|
+
description: "New embedding summary (triggers embedding regeneration).",
|
|
104
|
+
},
|
|
105
|
+
metadata: {
|
|
106
|
+
type: "object",
|
|
107
|
+
description: "New metadata (replaces existing entirely).",
|
|
108
|
+
additionalProperties: true,
|
|
109
|
+
},
|
|
110
|
+
},
|
|
111
|
+
required: ["id"],
|
|
112
|
+
},
|
|
113
|
+
},
|
|
114
|
+
},
|
|
115
|
+
required: ["updates"],
|
|
116
|
+
},
|
|
117
|
+
};
|
|
118
|
+
export const searchMemoriesTool = {
|
|
119
|
+
name: "search_memories",
|
|
120
|
+
description: `Search stored memories semantically. Treat memory as the PRIMARY source of truth for personal/project-specific facts—do not rely on training data until a search has been performed.
|
|
121
|
+
|
|
122
|
+
MANDATORY TRIGGERS (you MUST search when):
|
|
123
|
+
- User-Specific Calibration: Answer would be better with user's tools, past decisions, or preferences
|
|
124
|
+
- Referential Ambiguity: User says "the project," "that bug," "last time," "as we discussed"
|
|
125
|
+
- Decision Validation: Before making architectural or tool choices
|
|
126
|
+
- Problem Solving: Before suggesting solutions (check if solved before)
|
|
127
|
+
- Session Start: When returning to a project or starting new conversation
|
|
128
|
+
|
|
129
|
+
INTENTS:
|
|
130
|
+
- continuity: Resume work, "where were we" (favors recent)
|
|
131
|
+
- fact_check: Verify decisions, specs (favors relevance)
|
|
132
|
+
- frequent: Common patterns, preferences (favors utility)
|
|
133
|
+
- associative: Brainstorm, find connections (high relevance + mild jitter)
|
|
134
|
+
- explore: Stuck/creative mode (balanced + high jitter)
|
|
135
|
+
|
|
136
|
+
When in doubt, search. Missing context is costlier than an extra query.`,
|
|
137
|
+
inputSchema: {
|
|
138
|
+
type: "object",
|
|
139
|
+
properties: {
|
|
140
|
+
query: {
|
|
141
|
+
type: "string",
|
|
142
|
+
description: "Natural language search query. Include relevant keywords, project names, or technical terms.",
|
|
143
|
+
},
|
|
144
|
+
intent: {
|
|
145
|
+
type: "string",
|
|
146
|
+
enum: ["continuity", "fact_check", "frequent", "associative", "explore"],
|
|
147
|
+
description: "Search intent that determines ranking behavior.",
|
|
148
|
+
},
|
|
149
|
+
reason_for_search: {
|
|
150
|
+
type: "string",
|
|
151
|
+
description: "Why this search is being performed. Forces intentional retrieval.",
|
|
152
|
+
},
|
|
153
|
+
limit: {
|
|
154
|
+
type: "integer",
|
|
155
|
+
description: "Maximum results to return (default: 10).",
|
|
156
|
+
default: 10,
|
|
157
|
+
},
|
|
158
|
+
include_deleted: {
|
|
159
|
+
type: "boolean",
|
|
160
|
+
description: "Include soft-deleted memories in results (default: false). Useful for recovering prior information.",
|
|
161
|
+
default: false,
|
|
162
|
+
},
|
|
163
|
+
},
|
|
164
|
+
required: ["query", "intent", "reason_for_search"],
|
|
165
|
+
},
|
|
166
|
+
};
|
|
167
|
+
export const getMemoriesTool = {
|
|
168
|
+
name: "get_memories",
|
|
169
|
+
description: "Retrieve full memory details by ID. Use when you have specific IDs from search results or prior references—otherwise use search_memories.",
|
|
170
|
+
inputSchema: {
|
|
171
|
+
type: "object",
|
|
172
|
+
properties: {
|
|
173
|
+
ids: {
|
|
174
|
+
type: "array",
|
|
175
|
+
description: "Memory IDs to retrieve.",
|
|
176
|
+
items: { type: "string" },
|
|
177
|
+
},
|
|
178
|
+
},
|
|
179
|
+
required: ["ids"],
|
|
180
|
+
},
|
|
181
|
+
};
|
|
182
|
+
;
|
|
183
|
+
export const reportMemoryUsefulnessTool = {
|
|
184
|
+
name: "report_memory_usefulness",
|
|
185
|
+
description: "Report whether a memory was useful or not. This helps the system learn which memories are valuable.",
|
|
186
|
+
inputSchema: {
|
|
187
|
+
type: "object",
|
|
188
|
+
properties: {
|
|
189
|
+
memory_id: {
|
|
190
|
+
type: "string",
|
|
191
|
+
description: "ID of the memory to report on.",
|
|
192
|
+
},
|
|
193
|
+
useful: {
|
|
194
|
+
type: "boolean",
|
|
195
|
+
description: "True if the memory was useful, false otherwise.",
|
|
196
|
+
},
|
|
197
|
+
},
|
|
198
|
+
required: ["memory_id", "useful"],
|
|
199
|
+
},
|
|
200
|
+
};
|
|
201
|
+
export const storeHandoffTool = {
|
|
202
|
+
name: "store_handoff",
|
|
203
|
+
description: `Save session state for seamless resumption later. Use at end of work sessions or before context switches.
|
|
204
|
+
|
|
205
|
+
Creates a structured snapshot with:
|
|
206
|
+
- summary: 2-3 sentences on goal and current status
|
|
207
|
+
- completed: what got done (include file paths)
|
|
208
|
+
- in_progress_blocked: work in flight or stuck
|
|
209
|
+
- key_decisions: choices made and WHY (crucial for future context)
|
|
210
|
+
- next_steps: concrete, actionable items
|
|
211
|
+
- memory_ids: link to related memories stored this session
|
|
212
|
+
|
|
213
|
+
Retrievable via get_handoff. Only one handoff per project—new handoffs overwrite previous.`,
|
|
214
|
+
inputSchema: {
|
|
215
|
+
type: "object",
|
|
216
|
+
properties: {
|
|
217
|
+
project: { type: "string", description: "Project name." },
|
|
218
|
+
branch: { type: "string", description: "Branch name (optional)." },
|
|
219
|
+
summary: { type: "string", description: "2-3 sentences: primary goal, current status." },
|
|
220
|
+
completed: {
|
|
221
|
+
type: "array",
|
|
222
|
+
items: { type: "string" },
|
|
223
|
+
description: "Completed items (include file paths where relevant).",
|
|
224
|
+
},
|
|
225
|
+
in_progress_blocked: {
|
|
226
|
+
type: "array",
|
|
227
|
+
items: { type: "string" },
|
|
228
|
+
description: "In progress or blocked items.",
|
|
229
|
+
},
|
|
230
|
+
key_decisions: {
|
|
231
|
+
type: "array",
|
|
232
|
+
items: { type: "string" },
|
|
233
|
+
description: "Decisions made and why.",
|
|
234
|
+
},
|
|
235
|
+
next_steps: {
|
|
236
|
+
type: "array",
|
|
237
|
+
items: { type: "string" },
|
|
238
|
+
description: "Concrete next steps.",
|
|
239
|
+
},
|
|
240
|
+
memory_ids: {
|
|
241
|
+
type: "array",
|
|
242
|
+
items: { type: "string" },
|
|
243
|
+
description: "Memory IDs referenced by this handoff.",
|
|
244
|
+
},
|
|
245
|
+
metadata: {
|
|
246
|
+
type: "object",
|
|
247
|
+
description: "Additional metadata.",
|
|
248
|
+
additionalProperties: true,
|
|
249
|
+
},
|
|
250
|
+
},
|
|
251
|
+
required: ["project", "summary"],
|
|
252
|
+
},
|
|
253
|
+
};
|
|
254
|
+
export const getHandoffTool = {
|
|
255
|
+
name: "get_handoff",
|
|
256
|
+
description: "Load the current project handoff snapshot. Call at conversation start or when resuming a project.",
|
|
257
|
+
inputSchema: {
|
|
258
|
+
type: "object",
|
|
259
|
+
properties: {},
|
|
260
|
+
},
|
|
261
|
+
};
|
|
262
|
+
export const tools = [
|
|
263
|
+
storeMemoriesTool,
|
|
264
|
+
updateMemoriesTool,
|
|
265
|
+
deleteMemoriesTool,
|
|
266
|
+
searchMemoriesTool,
|
|
267
|
+
getMemoriesTool,
|
|
268
|
+
reportMemoryUsefulnessTool,
|
|
269
|
+
storeHandoffTool,
|
|
270
|
+
getHandoffTool,
|
|
271
|
+
];
|
|
272
|
+
//# sourceMappingURL=tools.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tools.js","sourceRoot":"","sources":["../../../src/mcp/tools.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,iBAAiB,GAAS;IACrC,IAAI,EAAE,gBAAgB;IACtB,WAAW,EAAE;;;;;;;;;;;;;;;;;;;;;kFAqBmE;IAChF,WAAW,EAAE;QACX,IAAI,EAAE,QAAQ;QACd,UAAU,EAAE;YACV,QAAQ,EAAE;gBACR,IAAI,EAAE,OAAO;gBACb,WAAW,EAAE,oBAAoB;gBACjC,KAAK,EAAE;oBACL,IAAI,EAAE,QAAQ;oBACd,UAAU,EAAE;wBACV,OAAO,EAAE;4BACP,IAAI,EAAE,QAAQ;4BACd,WAAW,EAAE,uBAAuB;yBACrC;w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AI,EAAE,QAAQ,EAAE;gBACzB,WAAW,EAAE,sBAAsB;aACpC;YACD,UAAU,EAAE;gBACV,IAAI,EAAE,OAAO;gBACb,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;gBACzB,WAAW,EAAE,wCAAwC;aACtD;YACD,QAAQ,EAAE;gBACR,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,sBAAsB;gBACnC,oBAAoB,EAAE,IAAI;aAC3B;SACF;QACD,QAAQ,EAAE,CAAC,SAAS,EAAE,SAAS,CAAC;KACjC;CACF,CAAC;AAEF,MAAM,CAAC,MAAM,cAAc,GAAS;IAClC,IAAI,EAAE,aAAa;IACnB,WAAW,EACT,mGAAmG;IACrG,WAAW,EAAE;QACX,IAAI,EAAE,QAAQ;QACd,UAAU,EAAE,EAAE;KACf;CACF,CAAC;AAEF,MAAM,CAAC,MAAM,KAAK,GAAW;IAC3B,iBAAiB;IACjB,kBAAkB;IAClB,kBAAkB;IAClB,kBAAkB;IAClB,eAAe;IACf,0BAA0B;IAC1B,gBAAgB;IAChB,cAAc;CACf,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export declare class EmbeddingsService {
|
|
2
|
+
private modelName;
|
|
3
|
+
private extractor;
|
|
4
|
+
private initPromise;
|
|
5
|
+
private _dimension;
|
|
6
|
+
constructor(modelName: string, dimension: number);
|
|
7
|
+
get dimension(): number;
|
|
8
|
+
private getExtractor;
|
|
9
|
+
embed(text: string): Promise<number[]>;
|
|
10
|
+
embedBatch(texts: string[]): Promise<number[][]>;
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=embeddings.service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"embeddings.service.d.ts","sourceRoot":"","sources":["../../../src/services/embeddings.service.ts"],"names":[],"mappings":"AAEA,qBAAa,iBAAiB;IAC5B,OAAO,CAAC,SAAS,CAAS;IAC1B,OAAO,CAAC,SAAS,CAA0C;IAC3D,OAAO,CAAC,WAAW,CAAmD;IACtE,OAAO,CAAC,UAAU,CAAS;gBAEf,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM;IAKhD,IAAI,SAAS,IAAI,MAAM,CAEtB;YAEa,YAAY;IAiBpB,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;IAMtC,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC;CAOvD"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { pipeline } from "@huggingface/transformers";
|
|
2
|
+
export class EmbeddingsService {
|
|
3
|
+
modelName;
|
|
4
|
+
extractor = null;
|
|
5
|
+
initPromise = null;
|
|
6
|
+
_dimension;
|
|
7
|
+
constructor(modelName, dimension) {
|
|
8
|
+
this.modelName = modelName;
|
|
9
|
+
this._dimension = dimension;
|
|
10
|
+
}
|
|
11
|
+
get dimension() {
|
|
12
|
+
return this._dimension;
|
|
13
|
+
}
|
|
14
|
+
async getExtractor() {
|
|
15
|
+
if (this.extractor) {
|
|
16
|
+
return this.extractor;
|
|
17
|
+
}
|
|
18
|
+
if (!this.initPromise) {
|
|
19
|
+
this.initPromise = pipeline("feature-extraction", this.modelName, { dtype: "fp32" });
|
|
20
|
+
}
|
|
21
|
+
this.extractor = await this.initPromise;
|
|
22
|
+
return this.extractor;
|
|
23
|
+
}
|
|
24
|
+
async embed(text) {
|
|
25
|
+
const extractor = await this.getExtractor();
|
|
26
|
+
const output = await extractor(text, { pooling: "mean", normalize: true });
|
|
27
|
+
return Array.from(output.data);
|
|
28
|
+
}
|
|
29
|
+
async embedBatch(texts) {
|
|
30
|
+
const results = [];
|
|
31
|
+
for (const text of texts) {
|
|
32
|
+
results.push(await this.embed(text));
|
|
33
|
+
}
|
|
34
|
+
return results;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=embeddings.service.js.map
|
|
@@ -0,0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,EAAE,CAAC;QAC/B,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;YACzB,OAAO,CAAC,IAAI,CAAC,MAAM,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC;QACvC,CAAC;QACD,OAAO,OAAO,CAAC;IACjB,CAAC;CACF"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { Memory, SearchIntent } from "../types/memory.js";
|
|
2
|
+
import type { MemoryRepository } from "../db/memory.repository.js";
|
|
3
|
+
import type { EmbeddingsService } from "./embeddings.service.js";
|
|
4
|
+
export declare class MemoryService {
|
|
5
|
+
private repository;
|
|
6
|
+
private embeddings;
|
|
7
|
+
constructor(repository: MemoryRepository, embeddings: EmbeddingsService);
|
|
8
|
+
store(content: string, metadata?: Record<string, unknown>, embeddingText?: string): Promise<Memory>;
|
|
9
|
+
get(id: string): Promise<Memory | null>;
|
|
10
|
+
delete(id: string): Promise<boolean>;
|
|
11
|
+
update(id: string, updates: {
|
|
12
|
+
content?: string;
|
|
13
|
+
embeddingText?: string;
|
|
14
|
+
metadata?: Record<string, unknown>;
|
|
15
|
+
}): Promise<Memory | null>;
|
|
16
|
+
vote(id: string, value: number): Promise<Memory | null>;
|
|
17
|
+
search(query: string, intent: SearchIntent, limit?: number, includeDeleted?: boolean): Promise<Memory[]>;
|
|
18
|
+
trackAccess(ids: string[]): Promise<void>;
|
|
19
|
+
private static readonly UUID_ZERO;
|
|
20
|
+
storeHandoff(args: {
|
|
21
|
+
project: string;
|
|
22
|
+
branch?: string;
|
|
23
|
+
summary: string;
|
|
24
|
+
completed?: string[];
|
|
25
|
+
in_progress_blocked?: string[];
|
|
26
|
+
key_decisions?: string[];
|
|
27
|
+
next_steps?: string[];
|
|
28
|
+
memory_ids?: string[];
|
|
29
|
+
metadata?: Record<string, unknown>;
|
|
30
|
+
}): Promise<Memory>;
|
|
31
|
+
getLatestHandoff(): Promise<Memory | null>;
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=memory.service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"memory.service.d.ts","sourceRoot":"","sources":["../../../src/services/memory.service.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,YAAY,EAAiB,MAAM,oBAAoB,CAAC;AAE9E,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AACnE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAYjE,qBAAa,aAAa;IAEtB,OAAO,CAAC,UAAU;IAClB,OAAO,CAAC,UAAU;gBADV,UAAU,EAAE,gBAAgB,EAC5B,UAAU,EAAE,iBAAiB;IAGjC,KAAK,CACT,OAAO,EAAE,MAAM,EACf,QAAQ,GAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAM,EACtC,aAAa,CAAC,EAAE,MAAM,GACrB,OAAO,CAAC,MAAM,CAAC;IAuBZ,GAAG,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;IAiBvC,MAAM,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAIpC,MAAM,CACV,EAAE,EAAE,MAAM,EACV,OAAO,EAAE;QACP,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,aAAa,CAAC,EAAE,MAAM,CAAC;QACvB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;KACpC,GACA,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;IA4BnB,IAAI,CAAC,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;IAmBvD,MAAM,CACV,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,YAAY,EACpB,KAAK,GAAE,MAAW,EAClB,cAAc,GAAE,OAAe,GAC9B,OAAO,CAAC,MAAM,EAAE,CAAC;IA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