@aeriondyseti/vector-memory-mcp 2.2.2 → 2.2.6-dev.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/README.md +33 -13
- package/package.json +12 -12
- package/{src → server}/config/index.ts +10 -2
- package/{src/db → server/core}/connection.ts +10 -2
- package/{src/db → server/core}/conversation.repository.ts +1 -1
- package/{src/services → server/core}/conversation.service.ts +2 -2
- package/server/core/embeddings.service.ts +125 -0
- package/{src/db → server/core}/memory.repository.ts +5 -1
- package/{src/services → server/core}/memory.service.ts +20 -4
- package/server/core/migration.service.ts +882 -0
- package/server/core/migrations.ts +263 -0
- package/{src/services → server/core}/parsers/claude-code.parser.ts +1 -1
- package/{src/services → server/core}/parsers/types.ts +1 -1
- package/{src → server}/index.ts +16 -48
- package/{src → server/transports}/http/mcp-transport.ts +2 -2
- package/{src → server/transports}/http/server.ts +6 -4
- package/{src → server/transports}/mcp/handlers.ts +5 -5
- package/server/transports/mcp/resources.ts +20 -0
- package/{src → server/transports}/mcp/server.ts +14 -3
- package/server/utils/formatting.ts +143 -0
- package/scripts/lancedb-extract.ts +0 -116
- package/scripts/migrate-from-lancedb.ts +0 -56
- package/scripts/smoke-test.ts +0 -699
- package/scripts/test-runner.ts +0 -76
- package/scripts/warmup.ts +0 -72
- package/src/db/migrations.ts +0 -108
- package/src/migration.ts +0 -203
- package/src/services/embeddings.service.ts +0 -48
- /package/{src/types → server/core}/conversation.ts +0 -0
- /package/{src/types → server/core}/memory.ts +0 -0
- /package/{src/db → server/core}/sqlite-utils.ts +0 -0
- /package/{src → server/transports}/mcp/tools.ts +0 -0
|
@@ -1,116 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env bun
|
|
2
|
-
/**
|
|
3
|
-
* Standalone LanceDB data extractor — runs in a child process so that
|
|
4
|
-
* @lancedb/lancedb native bindings never coexist with bun:sqlite's
|
|
5
|
-
* extension loading in the same process.
|
|
6
|
-
*
|
|
7
|
-
* Usage: bun scripts/lancedb-extract.ts <lance-db-path>
|
|
8
|
-
* Output: JSON on stdout — { memories: Row[], conversations: Row[] }
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
const source = process.argv[2];
|
|
12
|
-
if (!source) {
|
|
13
|
-
console.error("Usage: bun scripts/lancedb-extract.ts <lance-db-path>");
|
|
14
|
-
process.exit(1);
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* Read a value from an Arrow column at a given row index.
|
|
19
|
-
* Arrow timestamp columns return BigInt — we convert to epoch-ms here
|
|
20
|
-
* without going through Arrow's bigIntToNumber safety check.
|
|
21
|
-
*/
|
|
22
|
-
function columnValue(batch: any, colName: string, rowIdx: number): unknown {
|
|
23
|
-
const col = batch.getChild(colName);
|
|
24
|
-
if (!col) return undefined;
|
|
25
|
-
return col.get(rowIdx);
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
function toEpochMs(value: unknown): number {
|
|
29
|
-
if (typeof value === "number") return value;
|
|
30
|
-
if (value instanceof Date) return value.getTime();
|
|
31
|
-
if (typeof value === "bigint") {
|
|
32
|
-
// Arrow timestamps are microseconds; convert to milliseconds.
|
|
33
|
-
const ms = value / 1000n;
|
|
34
|
-
return Number(ms);
|
|
35
|
-
}
|
|
36
|
-
return Date.now();
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
function toFloatArray(vec: unknown): number[] {
|
|
40
|
-
if (Array.isArray(vec)) return vec;
|
|
41
|
-
if (vec instanceof Float32Array) return Array.from(vec);
|
|
42
|
-
if (vec && typeof (vec as any).toArray === "function") {
|
|
43
|
-
return Array.from((vec as any).toArray());
|
|
44
|
-
}
|
|
45
|
-
if (ArrayBuffer.isView(vec)) {
|
|
46
|
-
const view = vec as DataView;
|
|
47
|
-
return Array.from(new Float32Array(view.buffer, view.byteOffset, view.byteLength / 4));
|
|
48
|
-
}
|
|
49
|
-
return [];
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
const lancedb = await import("@lancedb/lancedb");
|
|
53
|
-
const db = await lancedb.connect(source);
|
|
54
|
-
const tableNames = await db.tableNames();
|
|
55
|
-
console.error(`Found tables: ${tableNames.join(", ")}`);
|
|
56
|
-
|
|
57
|
-
const result: { memories: any[]; conversations: any[] } = {
|
|
58
|
-
memories: [],
|
|
59
|
-
conversations: [],
|
|
60
|
-
};
|
|
61
|
-
|
|
62
|
-
if (tableNames.includes("memories")) {
|
|
63
|
-
const table = await db.openTable("memories");
|
|
64
|
-
const total = await table.countRows();
|
|
65
|
-
console.error(`Reading ${total} memories...`);
|
|
66
|
-
|
|
67
|
-
// Use toArrow() to get raw Arrow RecordBatches, bypassing StructRow
|
|
68
|
-
// property accessors that throw on BigInt timestamps.
|
|
69
|
-
const arrowTable = await table.query().toArrow();
|
|
70
|
-
for (const batch of arrowTable.batches) {
|
|
71
|
-
for (let i = 0; i < batch.numRows; i++) {
|
|
72
|
-
const lastAccessed = columnValue(batch, "last_accessed", i);
|
|
73
|
-
result.memories.push({
|
|
74
|
-
id: columnValue(batch, "id", i),
|
|
75
|
-
content: columnValue(batch, "content", i),
|
|
76
|
-
metadata: columnValue(batch, "metadata", i) ?? "{}",
|
|
77
|
-
vector: toFloatArray(columnValue(batch, "vector", i)),
|
|
78
|
-
created_at: toEpochMs(columnValue(batch, "created_at", i)),
|
|
79
|
-
updated_at: toEpochMs(columnValue(batch, "updated_at", i)),
|
|
80
|
-
last_accessed: lastAccessed != null ? toEpochMs(lastAccessed) : null,
|
|
81
|
-
superseded_by: columnValue(batch, "superseded_by", i) ?? null,
|
|
82
|
-
usefulness: columnValue(batch, "usefulness", i) ?? 0,
|
|
83
|
-
access_count: columnValue(batch, "access_count", i) ?? 0,
|
|
84
|
-
});
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
console.error(` ${result.memories.length} memories read`);
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
if (tableNames.includes("conversation_history")) {
|
|
91
|
-
const table = await db.openTable("conversation_history");
|
|
92
|
-
const total = await table.countRows();
|
|
93
|
-
console.error(`Reading ${total} conversation chunks...`);
|
|
94
|
-
|
|
95
|
-
const arrowTable = await table.query().toArrow();
|
|
96
|
-
for (const batch of arrowTable.batches) {
|
|
97
|
-
for (let i = 0; i < batch.numRows; i++) {
|
|
98
|
-
result.conversations.push({
|
|
99
|
-
id: columnValue(batch, "id", i),
|
|
100
|
-
content: columnValue(batch, "content", i),
|
|
101
|
-
metadata: columnValue(batch, "metadata", i) ?? "{}",
|
|
102
|
-
vector: toFloatArray(columnValue(batch, "vector", i)),
|
|
103
|
-
created_at: toEpochMs(columnValue(batch, "created_at", i)),
|
|
104
|
-
session_id: columnValue(batch, "session_id", i),
|
|
105
|
-
role: columnValue(batch, "role", i),
|
|
106
|
-
message_index_start: columnValue(batch, "message_index_start", i) ?? 0,
|
|
107
|
-
message_index_end: columnValue(batch, "message_index_end", i) ?? 0,
|
|
108
|
-
project: columnValue(batch, "project", i) ?? "",
|
|
109
|
-
});
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
console.error(` ${result.conversations.length} conversation chunks read`);
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
await db.close?.();
|
|
116
|
-
process.stdout.write(JSON.stringify(result));
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env bun
|
|
2
|
-
/**
|
|
3
|
-
* Standalone migration script: LanceDB → SQLite (sqlite-vec)
|
|
4
|
-
*
|
|
5
|
-
* This is a thin wrapper around src/migration.ts for direct invocation.
|
|
6
|
-
* The preferred way to migrate is `vector-memory-mcp migrate`.
|
|
7
|
-
*
|
|
8
|
-
* Usage:
|
|
9
|
-
* bun scripts/migrate-from-lancedb.ts [--source <lancedb-dir>] [--target <sqlite-file>]
|
|
10
|
-
*
|
|
11
|
-
* Defaults:
|
|
12
|
-
* --source .vector-memory/memories.db (the old LanceDB directory)
|
|
13
|
-
* --target .vector-memory/memories.db.sqlite (new SQLite file)
|
|
14
|
-
*
|
|
15
|
-
* @deprecated Use `vector-memory-mcp migrate` instead. This script will be
|
|
16
|
-
* removed in the next major version.
|
|
17
|
-
*/
|
|
18
|
-
|
|
19
|
-
import { migrate, formatMigrationSummary } from "../src/migration.js";
|
|
20
|
-
|
|
21
|
-
function parseArgs(): { source: string; target: string } {
|
|
22
|
-
const args = process.argv.slice(2);
|
|
23
|
-
let source = ".vector-memory/memories.db";
|
|
24
|
-
let target = ".vector-memory/memories.db.sqlite";
|
|
25
|
-
|
|
26
|
-
for (let i = 0; i < args.length; i++) {
|
|
27
|
-
if (args[i] === "--source" && args[i + 1]) source = args[++i];
|
|
28
|
-
else if (args[i] === "--target" && args[i + 1]) target = args[++i];
|
|
29
|
-
else if (args[i] === "--help" || args[i] === "-h") {
|
|
30
|
-
console.log(`
|
|
31
|
-
Usage: bun scripts/migrate-from-lancedb.ts [options]
|
|
32
|
-
|
|
33
|
-
Prefer: vector-memory-mcp migrate
|
|
34
|
-
|
|
35
|
-
Options:
|
|
36
|
-
--source <path> LanceDB directory (default: .vector-memory/memories.db)
|
|
37
|
-
--target <path> SQLite output file (default: .vector-memory/memories.db.sqlite)
|
|
38
|
-
--help Show this help
|
|
39
|
-
`);
|
|
40
|
-
process.exit(0);
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
return { source, target };
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
async function main() {
|
|
48
|
-
const { source, target } = parseArgs();
|
|
49
|
-
const result = await migrate({ source, target });
|
|
50
|
-
console.error(formatMigrationSummary(source, target, result));
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
main().catch((err) => {
|
|
54
|
-
console.error("❌ Migration failed:", err.message ?? err);
|
|
55
|
-
process.exit(1);
|
|
56
|
-
});
|