@hasna/mementos 0.4.19 → 0.4.20
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/mcp/index.js +59 -0
- package/dist/server/index.d.ts.map +1 -1
- package/dist/server/index.js +29 -0
- package/package.json +1 -1
package/dist/mcp/index.js
CHANGED
|
@@ -5376,6 +5376,28 @@ function cleanExpiredMemories(db) {
|
|
|
5376
5376
|
}
|
|
5377
5377
|
return count;
|
|
5378
5378
|
}
|
|
5379
|
+
function getMemoryVersions(memoryId, db) {
|
|
5380
|
+
const d = db || getDatabase();
|
|
5381
|
+
try {
|
|
5382
|
+
const rows = d.query("SELECT * FROM memory_versions WHERE memory_id = ? ORDER BY version ASC").all(memoryId);
|
|
5383
|
+
return rows.map((row) => ({
|
|
5384
|
+
id: row["id"],
|
|
5385
|
+
memory_id: row["memory_id"],
|
|
5386
|
+
version: row["version"],
|
|
5387
|
+
value: row["value"],
|
|
5388
|
+
importance: row["importance"],
|
|
5389
|
+
scope: row["scope"],
|
|
5390
|
+
category: row["category"],
|
|
5391
|
+
tags: JSON.parse(row["tags"] || "[]"),
|
|
5392
|
+
summary: row["summary"] || null,
|
|
5393
|
+
pinned: !!row["pinned"],
|
|
5394
|
+
status: row["status"],
|
|
5395
|
+
created_at: row["created_at"]
|
|
5396
|
+
}));
|
|
5397
|
+
} catch {
|
|
5398
|
+
return [];
|
|
5399
|
+
}
|
|
5400
|
+
}
|
|
5379
5401
|
|
|
5380
5402
|
// src/lib/search.ts
|
|
5381
5403
|
function parseMemoryRow2(row) {
|
|
@@ -6144,6 +6166,35 @@ server.tool("memory_get", "Get a single memory by ID.", {
|
|
|
6144
6166
|
return { content: [{ type: "text", text: formatError(e) }], isError: true };
|
|
6145
6167
|
}
|
|
6146
6168
|
});
|
|
6169
|
+
server.tool("memory_versions", "Get version history for a memory. Shows what changed across updates.", {
|
|
6170
|
+
id: exports_external.string()
|
|
6171
|
+
}, async (args) => {
|
|
6172
|
+
try {
|
|
6173
|
+
const id = resolveId(args.id);
|
|
6174
|
+
const memory = getMemory(id);
|
|
6175
|
+
if (!memory) {
|
|
6176
|
+
return { content: [{ type: "text", text: `Memory not found: ${args.id}` }] };
|
|
6177
|
+
}
|
|
6178
|
+
const versions = getMemoryVersions(id);
|
|
6179
|
+
if (versions.length === 0) {
|
|
6180
|
+
return { content: [{ type: "text", text: `No version history for "${memory.key}" (current: v${memory.version})` }] };
|
|
6181
|
+
}
|
|
6182
|
+
const lines = versions.map((v) => `v${v.version} [${v.created_at.slice(0, 16)}] scope=${v.scope} importance=${v.importance} status=${v.status}
|
|
6183
|
+
value: ${v.value.slice(0, 120)}${v.value.length > 120 ? "..." : ""}`);
|
|
6184
|
+
return {
|
|
6185
|
+
content: [{
|
|
6186
|
+
type: "text",
|
|
6187
|
+
text: `Version history for "${memory.key}" (${versions.length} version${versions.length === 1 ? "" : "s"}, current: v${memory.version}):
|
|
6188
|
+
|
|
6189
|
+
${lines.join(`
|
|
6190
|
+
|
|
6191
|
+
`)}`
|
|
6192
|
+
}]
|
|
6193
|
+
};
|
|
6194
|
+
} catch (e) {
|
|
6195
|
+
return { content: [{ type: "text", text: formatError(e) }], isError: true };
|
|
6196
|
+
}
|
|
6197
|
+
});
|
|
6147
6198
|
server.tool("memory_list", "List memories. Default: compact lines. full=true for complete JSON objects.", {
|
|
6148
6199
|
scope: exports_external.enum(["global", "shared", "private"]).optional(),
|
|
6149
6200
|
category: exports_external.enum(["preference", "fact", "knowledge", "history"]).optional(),
|
|
@@ -7083,6 +7134,14 @@ var FULL_SCHEMAS = {
|
|
|
7083
7134
|
},
|
|
7084
7135
|
example: '{"key":"preferred-language","value":"TypeScript","scope":"global","importance":8,"tags":["language","preference"]}'
|
|
7085
7136
|
},
|
|
7137
|
+
memory_versions: {
|
|
7138
|
+
description: "Get full version history for a memory \u2014 all past values, scopes, importance scores.",
|
|
7139
|
+
category: "memory",
|
|
7140
|
+
params: {
|
|
7141
|
+
id: { type: "string", description: "Memory ID (partial OK)", required: true }
|
|
7142
|
+
},
|
|
7143
|
+
example: '{"id":"abc12345"}'
|
|
7144
|
+
},
|
|
7086
7145
|
memory_get: {
|
|
7087
7146
|
description: "Get a single memory by ID (partial IDs resolved).",
|
|
7088
7147
|
category: "memory",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/server/index.ts"],"names":[],"mappings":";AACA;;;GAGG;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/server/index.ts"],"names":[],"mappings":";AACA;;;GAGG;AAkoCH,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAkH9C"}
|
package/dist/server/index.js
CHANGED
|
@@ -1456,6 +1456,28 @@ function cleanExpiredMemories(db) {
|
|
|
1456
1456
|
}
|
|
1457
1457
|
return count;
|
|
1458
1458
|
}
|
|
1459
|
+
function getMemoryVersions(memoryId, db) {
|
|
1460
|
+
const d = db || getDatabase();
|
|
1461
|
+
try {
|
|
1462
|
+
const rows = d.query("SELECT * FROM memory_versions WHERE memory_id = ? ORDER BY version ASC").all(memoryId);
|
|
1463
|
+
return rows.map((row) => ({
|
|
1464
|
+
id: row["id"],
|
|
1465
|
+
memory_id: row["memory_id"],
|
|
1466
|
+
version: row["version"],
|
|
1467
|
+
value: row["value"],
|
|
1468
|
+
importance: row["importance"],
|
|
1469
|
+
scope: row["scope"],
|
|
1470
|
+
category: row["category"],
|
|
1471
|
+
tags: JSON.parse(row["tags"] || "[]"),
|
|
1472
|
+
summary: row["summary"] || null,
|
|
1473
|
+
pinned: !!row["pinned"],
|
|
1474
|
+
status: row["status"],
|
|
1475
|
+
created_at: row["created_at"]
|
|
1476
|
+
}));
|
|
1477
|
+
} catch {
|
|
1478
|
+
return [];
|
|
1479
|
+
}
|
|
1480
|
+
}
|
|
1459
1481
|
|
|
1460
1482
|
// src/lib/search.ts
|
|
1461
1483
|
function parseMemoryRow2(row) {
|
|
@@ -2478,6 +2500,13 @@ addRoute("PATCH", "/api/memories/:id", async (req, _url, params) => {
|
|
|
2478
2500
|
throw e;
|
|
2479
2501
|
}
|
|
2480
2502
|
});
|
|
2503
|
+
addRoute("GET", "/api/memories/:id/versions", (_req, _url, params) => {
|
|
2504
|
+
const memory = getMemory(params["id"]);
|
|
2505
|
+
if (!memory)
|
|
2506
|
+
return errorResponse("Memory not found", 404);
|
|
2507
|
+
const versions = getMemoryVersions(memory.id);
|
|
2508
|
+
return json({ versions, count: versions.length, current_version: memory.version });
|
|
2509
|
+
});
|
|
2481
2510
|
addRoute("DELETE", "/api/memories/:id", (_req, _url, params) => {
|
|
2482
2511
|
const deleted = deleteMemory(params["id"]);
|
|
2483
2512
|
if (!deleted) {
|