@hasna/mementos 0.3.1 → 0.3.2

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 +61 -7
  2. package/package.json +1 -1
package/dist/mcp/index.js CHANGED
@@ -4954,8 +4954,7 @@ server.tool("memory_save", "Save/upsert a memory. scope: global=all agents, shar
4954
4954
  try {
4955
4955
  ensureAutoProject();
4956
4956
  const memory = createMemory(args);
4957
- return { content: [{ type: "text", text: `Memory saved:
4958
- ${formatMemory(memory)}` }] };
4957
+ return { content: [{ type: "text", text: `Saved: ${memory.key} (${memory.id.slice(0, 8)})` }] };
4959
4958
  } catch (e) {
4960
4959
  return { content: [{ type: "text", text: formatError(e) }], isError: true };
4961
4960
  }
@@ -5007,22 +5006,32 @@ server.tool("memory_list", "List memories. Default: compact lines. full=true for
5007
5006
  project_id: exports_external.string().optional(),
5008
5007
  session_id: exports_external.string().optional(),
5009
5008
  status: exports_external.enum(["active", "archived", "expired"]).optional(),
5010
- limit: exports_external.coerce.number().optional().describe("Max results (default: 50)"),
5009
+ limit: exports_external.coerce.number().optional().describe("Max results (default: 10)"),
5011
5010
  offset: exports_external.coerce.number().optional(),
5012
- full: exports_external.boolean().optional().describe("Return full Memory objects as JSON instead of compact lines")
5011
+ full: exports_external.boolean().optional().describe("Return full Memory objects as JSON instead of compact lines"),
5012
+ fields: exports_external.array(exports_external.string()).optional().describe("Filter fields in full mode: e.g. ['key','value','importance']")
5013
5013
  }, async (args) => {
5014
5014
  try {
5015
- const { full, ...filterArgs } = args;
5015
+ const { full, fields, ...filterArgs } = args;
5016
5016
  const filter = {
5017
5017
  ...filterArgs,
5018
- limit: filterArgs.limit || 50
5018
+ limit: filterArgs.limit || 10
5019
5019
  };
5020
5020
  const memories = listMemories(filter);
5021
5021
  if (memories.length === 0) {
5022
5022
  return { content: [{ type: "text", text: "No memories found." }] };
5023
5023
  }
5024
5024
  if (full) {
5025
- const compact = memories.map((m) => Object.fromEntries(Object.entries(m).filter(([, v]) => v !== null && v !== undefined && v !== 0 && v !== "")));
5025
+ const compact = memories.map((m) => {
5026
+ const obj = Object.fromEntries(Object.entries(m).filter(([k, v]) => {
5027
+ if (v === null || v === undefined)
5028
+ return false;
5029
+ if (fields && fields.length > 0)
5030
+ return fields.includes(k);
5031
+ return true;
5032
+ }));
5033
+ return obj;
5034
+ });
5026
5035
  return { content: [{ type: "text", text: JSON.stringify(compact, null, 2) }] };
5027
5036
  }
5028
5037
  const lines = memories.map((m, i) => `${i + 1}. [${m.scope}/${m.category}] ${m.key} = ${m.value.slice(0, 100)}${m.value.length > 100 ? "..." : ""} (imp:${m.importance} id:${m.id.slice(0, 8)})`);
@@ -5473,6 +5482,51 @@ server.tool("memory_context", "Get memories relevant to current context, filtere
5473
5482
  return { content: [{ type: "text", text: formatError(e) }], isError: true };
5474
5483
  }
5475
5484
  });
5485
+ var TOOL_REGISTRY = [
5486
+ { name: "memory_save", description: "Save/upsert a memory. scope: global=all agents, shared=project, private=single agent.", category: "memory" },
5487
+ { name: "memory_recall", description: "Recall a memory by key. Returns the best matching active memory.", category: "memory" },
5488
+ { name: "memory_list", description: "List memories. Default: compact lines. full=true for complete JSON objects.", category: "memory" },
5489
+ { name: "memory_update", description: "Update a memory's metadata (value, importance, tags, etc.)", category: "memory" },
5490
+ { name: "memory_forget", description: "Delete a memory by ID or key", category: "memory" },
5491
+ { name: "memory_search", description: "Search memories by keyword across key, value, summary, and tags", category: "memory" },
5492
+ { name: "memory_stats", description: "Get aggregate statistics about stored memories", category: "memory" },
5493
+ { name: "memory_export", description: "Export memories as JSON", category: "memory" },
5494
+ { name: "memory_import", description: "Import memories from JSON array", category: "memory" },
5495
+ { name: "memory_inject", description: "Get memory context for system prompt injection. Selects by scope, importance, recency.", category: "memory" },
5496
+ { name: "memory_context", description: "Get memories relevant to current context, filtered by scope/importance/recency.", category: "memory" },
5497
+ { name: "register_agent", description: "Register an agent. Idempotent \u2014 same name returns existing agent.", category: "agent" },
5498
+ { name: "list_agents", description: "List all registered agents", category: "agent" },
5499
+ { name: "get_agent", description: "Get agent details by ID or name", category: "agent" },
5500
+ { name: "update_agent", description: "Update agent name, description, role, or metadata.", category: "agent" },
5501
+ { name: "register_project", description: "Register a project for memory scoping", category: "project" },
5502
+ { name: "list_projects", description: "List all registered projects", category: "project" },
5503
+ { name: "bulk_forget", description: "Delete multiple memories by IDs", category: "bulk" },
5504
+ { name: "bulk_update", description: "Update multiple memories with the same changes", category: "bulk" },
5505
+ { name: "clean_expired", description: "Remove expired memories from the database", category: "utility" },
5506
+ { name: "search_tools", description: "Search available tools by name or keyword. Returns names only.", category: "meta" },
5507
+ { name: "describe_tools", description: "Get full schemas for specific tools by name.", category: "meta" }
5508
+ ];
5509
+ server.tool("search_tools", "Search available tools by name or keyword. Returns names only.", {
5510
+ query: exports_external.string().describe("Search term to match against tool names and descriptions"),
5511
+ category: exports_external.enum(["memory", "agent", "project", "bulk", "utility", "meta"]).optional()
5512
+ }, async (args) => {
5513
+ const q = args.query.toLowerCase();
5514
+ const results = TOOL_REGISTRY.filter((t) => (!args.category || t.category === args.category) && (t.name.includes(q) || t.description.toLowerCase().includes(q)));
5515
+ if (results.length === 0)
5516
+ return { content: [{ type: "text", text: "No tools found." }] };
5517
+ return { content: [{ type: "text", text: results.map((t) => `${t.name} [${t.category}]`).join(`
5518
+ `) }] };
5519
+ });
5520
+ server.tool("describe_tools", "Get full schemas for specific tools by name.", {
5521
+ names: exports_external.array(exports_external.string()).describe("Tool names to describe")
5522
+ }, async (args) => {
5523
+ const found = TOOL_REGISTRY.filter((t) => args.names.includes(t.name));
5524
+ if (found.length === 0)
5525
+ return { content: [{ type: "text", text: "No matching tools." }] };
5526
+ const lines = found.map((t) => `**${t.name}** [${t.category}]: ${t.description}`);
5527
+ return { content: [{ type: "text", text: lines.join(`
5528
+ `) }] };
5529
+ });
5476
5530
  server.resource("memories", "mementos://memories", { description: "All active memories", mimeType: "application/json" }, async () => {
5477
5531
  const memories = listMemories({ status: "active", limit: 1000 });
5478
5532
  return { contents: [{ uri: "mementos://memories", text: JSON.stringify(memories, null, 2), mimeType: "application/json" }] };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hasna/mementos",
3
- "version": "0.3.1",
3
+ "version": "0.3.2",
4
4
  "description": "Universal memory system for AI agents - CLI + MCP server + library API",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",