@hasna/mementos 0.10.13 → 0.10.14

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.
Files changed (2) hide show
  1. package/dist/mcp/index.js +68 -0
  2. package/package.json +1 -1
package/dist/mcp/index.js CHANGED
@@ -10586,6 +10586,74 @@ IDs: ${created.join(", ")}` : ""}`
10586
10586
  return { content: [{ type: "text", text: formatError(e) }], isError: true };
10587
10587
  }
10588
10588
  });
10589
+ server.tool("memory_briefing", "Lightweight delta briefing: what memories changed since an agent's last session. Use at session start instead of memory_context to avoid re-reading everything.", {
10590
+ agent_id: exports_external.string().optional().describe("Agent ID or name. If provided, defaults since to agent's last_seen_at."),
10591
+ since: exports_external.string().optional().describe("ISO 8601 timestamp. Defaults to agent's last_seen_at if agent_id provided, otherwise 24h ago."),
10592
+ project_id: exports_external.string().optional(),
10593
+ scope: exports_external.enum(["global", "shared", "private"]).optional(),
10594
+ limit: exports_external.coerce.number().optional().describe("Max memories per category (default: 20)")
10595
+ }, async (args) => {
10596
+ try {
10597
+ const db = getDatabase();
10598
+ const limit = args.limit || 20;
10599
+ let since = args.since;
10600
+ if (!since && args.agent_id) {
10601
+ const ag = getAgent(args.agent_id);
10602
+ if (ag?.last_seen_at)
10603
+ since = ag.last_seen_at;
10604
+ }
10605
+ if (!since) {
10606
+ since = new Date(Date.now() - 24 * 60 * 60 * 1000).toISOString();
10607
+ }
10608
+ const scopeClause = args.scope ? `AND scope = ?` : "";
10609
+ const projectClause = args.project_id ? `AND project_id = ?` : "";
10610
+ const extraParams = [
10611
+ ...args.scope ? [args.scope] : [],
10612
+ ...args.project_id ? [args.project_id] : []
10613
+ ];
10614
+ const newMems = db.prepare(`SELECT id, key, value, summary, importance, scope, category, agent_id, created_at
10615
+ FROM memories WHERE status = 'active' AND created_at > ? ${scopeClause} ${projectClause}
10616
+ ORDER BY importance DESC, created_at DESC LIMIT ?`).all(since, ...extraParams, limit);
10617
+ const updatedMems = db.prepare(`SELECT id, key, value, summary, importance, scope, category, agent_id, updated_at
10618
+ FROM memories WHERE status = 'active' AND updated_at > ? AND created_at <= ? ${scopeClause} ${projectClause}
10619
+ ORDER BY importance DESC, updated_at DESC LIMIT ?`).all(since, since, ...extraParams, limit);
10620
+ const expiredMems = db.prepare(`SELECT id, key, scope, category, updated_at, status
10621
+ FROM memories WHERE status != 'active' AND updated_at > ? ${scopeClause} ${projectClause}
10622
+ ORDER BY updated_at DESC LIMIT ?`).all(since, ...extraParams, Math.min(limit, 10));
10623
+ const parts = [`Memory briefing since ${since}`];
10624
+ if (newMems.length > 0) {
10625
+ parts.push(`
10626
+ **New (${newMems.length}):**`);
10627
+ for (const m of newMems) {
10628
+ parts.push(`\u2022 [${m.scope}/${m.category}] ${m.key} (importance:${m.importance}${m.agent_id ? `, by:${m.agent_id}` : ""}): ${(m.summary || m.value).slice(0, 100)}`);
10629
+ }
10630
+ }
10631
+ if (updatedMems.length > 0) {
10632
+ parts.push(`
10633
+ **Updated (${updatedMems.length}):**`);
10634
+ for (const m of updatedMems) {
10635
+ parts.push(`\u2022 [${m.scope}] ${m.key}: ${(m.summary || m.value).slice(0, 80)}`);
10636
+ }
10637
+ }
10638
+ if (expiredMems.length > 0) {
10639
+ parts.push(`
10640
+ **Expired/archived (${expiredMems.length}):**`);
10641
+ for (const m of expiredMems) {
10642
+ parts.push(`\u2022 [${m.scope}] ${m.key} \u2014 ${m.status}`);
10643
+ }
10644
+ }
10645
+ if (newMems.length === 0 && updatedMems.length === 0 && expiredMems.length === 0) {
10646
+ parts.push(`
10647
+ No memory changes since last session.`);
10648
+ }
10649
+ parts.push(`
10650
+ Summary: ${newMems.length} new, ${updatedMems.length} updated, ${expiredMems.length} expired.`);
10651
+ return { content: [{ type: "text", text: parts.join(`
10652
+ `) }] };
10653
+ } catch (e) {
10654
+ return { content: [{ type: "text", text: formatError(e) }], isError: true };
10655
+ }
10656
+ });
10589
10657
  server.tool("memory_context", "Get memories relevant to current context, filtered by scope/importance/recency.", {
10590
10658
  agent_id: exports_external.string().optional(),
10591
10659
  project_id: exports_external.string().optional(),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hasna/mementos",
3
- "version": "0.10.13",
3
+ "version": "0.10.14",
4
4
  "description": "Universal memory system for AI agents - CLI + MCP server + library API",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",