@hasna/mementos 0.4.17 → 0.4.19
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 +54 -0
- package/dist/server/index.d.ts.map +1 -1
- package/dist/server/index.js +37 -0
- package/package.json +1 -1
package/dist/mcp/index.js
CHANGED
|
@@ -6357,6 +6357,49 @@ server.tool("memory_stats", "Get aggregate statistics about stored memories", {}
|
|
|
6357
6357
|
return { content: [{ type: "text", text: formatError(e) }], isError: true };
|
|
6358
6358
|
}
|
|
6359
6359
|
});
|
|
6360
|
+
server.tool("memory_activity", "Get daily memory creation activity over N days.", {
|
|
6361
|
+
days: exports_external.coerce.number().optional(),
|
|
6362
|
+
scope: exports_external.enum(["global", "shared", "private"]).optional(),
|
|
6363
|
+
agent_id: exports_external.string().optional(),
|
|
6364
|
+
project_id: exports_external.string().optional()
|
|
6365
|
+
}, async (args) => {
|
|
6366
|
+
try {
|
|
6367
|
+
const days = Math.min(args.days || 30, 365);
|
|
6368
|
+
const db = getDatabase();
|
|
6369
|
+
const conditions = ["status = 'active'"];
|
|
6370
|
+
const params = [];
|
|
6371
|
+
if (args.scope) {
|
|
6372
|
+
conditions.push("scope = ?");
|
|
6373
|
+
params.push(args.scope);
|
|
6374
|
+
}
|
|
6375
|
+
if (args.agent_id) {
|
|
6376
|
+
conditions.push("agent_id = ?");
|
|
6377
|
+
params.push(args.agent_id);
|
|
6378
|
+
}
|
|
6379
|
+
if (args.project_id) {
|
|
6380
|
+
conditions.push("project_id = ?");
|
|
6381
|
+
params.push(args.project_id);
|
|
6382
|
+
}
|
|
6383
|
+
const where = conditions.slice(1).map((c) => `AND ${c}`).join(" ");
|
|
6384
|
+
const rows = db.query(`
|
|
6385
|
+
SELECT date(created_at) AS date, COUNT(*) AS memories_created
|
|
6386
|
+
FROM memories
|
|
6387
|
+
WHERE status = 'active' AND date(created_at) >= date('now', '-${days} days') ${where}
|
|
6388
|
+
GROUP BY date(created_at)
|
|
6389
|
+
ORDER BY date ASC
|
|
6390
|
+
`).all(...params);
|
|
6391
|
+
if (rows.length === 0) {
|
|
6392
|
+
return { content: [{ type: "text", text: `No memory activity in last ${days} days.` }] };
|
|
6393
|
+
}
|
|
6394
|
+
const total = rows.reduce((s, r) => s + r.memories_created, 0);
|
|
6395
|
+
const lines = rows.map((r) => `${r.date}: ${r.memories_created} memor${r.memories_created === 1 ? "y" : "ies"}`);
|
|
6396
|
+
return { content: [{ type: "text", text: `Memory activity (last ${days} days \u2014 ${total} total):
|
|
6397
|
+
${lines.join(`
|
|
6398
|
+
`)}` }] };
|
|
6399
|
+
} catch (e) {
|
|
6400
|
+
return { content: [{ type: "text", text: formatError(e) }], isError: true };
|
|
6401
|
+
}
|
|
6402
|
+
});
|
|
6360
6403
|
server.tool("memory_export", "Export memories as JSON", {
|
|
6361
6404
|
scope: exports_external.enum(["global", "shared", "private"]).optional(),
|
|
6362
6405
|
category: exports_external.enum(["preference", "fact", "knowledge", "history"]).optional(),
|
|
@@ -7146,6 +7189,17 @@ var FULL_SCHEMAS = {
|
|
|
7146
7189
|
},
|
|
7147
7190
|
example: '{"query":"typescript","scope":"global","limit":10}'
|
|
7148
7191
|
},
|
|
7192
|
+
memory_activity: {
|
|
7193
|
+
description: "Get daily memory creation counts over N days (max 365). Like 'git log --stat' for memories.",
|
|
7194
|
+
category: "memory",
|
|
7195
|
+
params: {
|
|
7196
|
+
days: { type: "number", description: "Number of days to look back (default 30)" },
|
|
7197
|
+
scope: { type: "string", description: "Filter by scope", enum: ["global", "shared", "private"] },
|
|
7198
|
+
agent_id: { type: "string", description: "Filter by agent" },
|
|
7199
|
+
project_id: { type: "string", description: "Filter by project" }
|
|
7200
|
+
},
|
|
7201
|
+
example: '{"days":14,"project_id":"proj-uuid"}'
|
|
7202
|
+
},
|
|
7149
7203
|
memory_stats: {
|
|
7150
7204
|
description: "Aggregate statistics: total, by scope, by category, pinned, expired counts.",
|
|
7151
7205
|
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;AAynCH,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAkH9C"}
|
package/dist/server/index.js
CHANGED
|
@@ -2217,6 +2217,43 @@ addRoute("GET", "/api/memories/stats", (_req) => {
|
|
|
2217
2217
|
stats.by_agent[row.agent_id] = row.c;
|
|
2218
2218
|
return json(stats);
|
|
2219
2219
|
});
|
|
2220
|
+
addRoute("GET", "/api/activity", (_req, url) => {
|
|
2221
|
+
const q = getSearchParams(url);
|
|
2222
|
+
const days = Math.min(parseInt(q["days"] || "30", 10), 365);
|
|
2223
|
+
const scope = q["scope"];
|
|
2224
|
+
const agentId = q["agent_id"];
|
|
2225
|
+
const projectId = q["project_id"];
|
|
2226
|
+
const db = getDatabase();
|
|
2227
|
+
const conditions = ["status = 'active'"];
|
|
2228
|
+
const params = [];
|
|
2229
|
+
if (scope) {
|
|
2230
|
+
conditions.push("scope = ?");
|
|
2231
|
+
params.push(scope);
|
|
2232
|
+
}
|
|
2233
|
+
if (agentId) {
|
|
2234
|
+
conditions.push("agent_id = ?");
|
|
2235
|
+
params.push(agentId);
|
|
2236
|
+
}
|
|
2237
|
+
if (projectId) {
|
|
2238
|
+
conditions.push("project_id = ?");
|
|
2239
|
+
params.push(projectId);
|
|
2240
|
+
}
|
|
2241
|
+
const where = conditions.map((c) => `AND ${c}`).join(" ");
|
|
2242
|
+
const rows = db.query(`
|
|
2243
|
+
SELECT
|
|
2244
|
+
date(created_at) AS date,
|
|
2245
|
+
COUNT(*) AS memories_created,
|
|
2246
|
+
SUM(CASE WHEN scope = 'global' THEN 1 ELSE 0 END) AS global_count,
|
|
2247
|
+
SUM(CASE WHEN scope = 'shared' THEN 1 ELSE 0 END) AS shared_count,
|
|
2248
|
+
SUM(CASE WHEN scope = 'private' THEN 1 ELSE 0 END) AS private_count,
|
|
2249
|
+
AVG(importance) AS avg_importance
|
|
2250
|
+
FROM memories
|
|
2251
|
+
WHERE date(created_at) >= date('now', '-${days} days') ${where}
|
|
2252
|
+
GROUP BY date(created_at)
|
|
2253
|
+
ORDER BY date ASC
|
|
2254
|
+
`).all(...params);
|
|
2255
|
+
return json({ activity: rows, days, total: rows.reduce((s, r) => s + r.memories_created, 0) });
|
|
2256
|
+
});
|
|
2220
2257
|
addRoute("POST", "/api/memories/search", async (req) => {
|
|
2221
2258
|
const body = await readJson(req);
|
|
2222
2259
|
if (!body || typeof body["query"] !== "string") {
|