@hasna/mementos 0.4.12 → 0.4.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.
- package/dist/mcp/index.js +67 -6
- package/package.json +2 -1
package/dist/mcp/index.js
CHANGED
|
@@ -6190,7 +6190,7 @@ ${lines.join(`
|
|
|
6190
6190
|
return { content: [{ type: "text", text: formatError(e) }], isError: true };
|
|
6191
6191
|
}
|
|
6192
6192
|
});
|
|
6193
|
-
server.tool("memory_update", "Update a memory's metadata (value, importance, tags, etc.)", {
|
|
6193
|
+
server.tool("memory_update", "Update a memory's metadata (value, importance, tags, etc.). version is optional \u2014 auto-fetched if omitted.", {
|
|
6194
6194
|
id: exports_external.string(),
|
|
6195
6195
|
value: exports_external.string().optional(),
|
|
6196
6196
|
category: exports_external.enum(["preference", "fact", "knowledge", "history"]).optional(),
|
|
@@ -6202,18 +6202,58 @@ server.tool("memory_update", "Update a memory's metadata (value, importance, tag
|
|
|
6202
6202
|
status: exports_external.enum(["active", "archived", "expired"]).optional(),
|
|
6203
6203
|
metadata: exports_external.record(exports_external.unknown()).optional(),
|
|
6204
6204
|
expires_at: exports_external.string().nullable().optional(),
|
|
6205
|
-
version: exports_external.coerce.number()
|
|
6205
|
+
version: exports_external.coerce.number().optional()
|
|
6206
6206
|
}, async (args) => {
|
|
6207
6207
|
try {
|
|
6208
6208
|
const id = resolveId(args.id);
|
|
6209
|
-
const { id: _id, ...updateFields } = args;
|
|
6210
|
-
const
|
|
6209
|
+
const { id: _id, version, ...updateFields } = args;
|
|
6210
|
+
const resolvedVersion = version ?? getMemory(id)?.version;
|
|
6211
|
+
if (resolvedVersion === undefined) {
|
|
6212
|
+
return { content: [{ type: "text", text: `Memory not found: ${id}` }] };
|
|
6213
|
+
}
|
|
6214
|
+
const memory = updateMemory(id, { ...updateFields, version: resolvedVersion });
|
|
6211
6215
|
return { content: [{ type: "text", text: `Memory updated:
|
|
6212
6216
|
${formatMemory(memory)}` }] };
|
|
6213
6217
|
} catch (e) {
|
|
6214
6218
|
return { content: [{ type: "text", text: formatError(e) }], isError: true };
|
|
6215
6219
|
}
|
|
6216
6220
|
});
|
|
6221
|
+
server.tool("memory_pin", "Pin or unpin a memory by ID or key. No version needed.", {
|
|
6222
|
+
id: exports_external.string().optional(),
|
|
6223
|
+
key: exports_external.string().optional(),
|
|
6224
|
+
pinned: exports_external.boolean().optional(),
|
|
6225
|
+
scope: exports_external.enum(["global", "shared", "private"]).optional(),
|
|
6226
|
+
agent_id: exports_external.string().optional(),
|
|
6227
|
+
project_id: exports_external.string().optional()
|
|
6228
|
+
}, async (args) => {
|
|
6229
|
+
try {
|
|
6230
|
+
let memory = args.id ? getMemory(resolveId(args.id)) : getMemoryByKey(args.key, args.scope, args.agent_id, args.project_id);
|
|
6231
|
+
if (!memory)
|
|
6232
|
+
return { content: [{ type: "text", text: `Memory not found.` }] };
|
|
6233
|
+
const pinned = args.pinned !== false;
|
|
6234
|
+
updateMemory(memory.id, { pinned, version: memory.version });
|
|
6235
|
+
return { content: [{ type: "text", text: `Memory "${memory.key}" ${pinned ? "pinned" : "unpinned"}.` }] };
|
|
6236
|
+
} catch (e) {
|
|
6237
|
+
return { content: [{ type: "text", text: formatError(e) }], isError: true };
|
|
6238
|
+
}
|
|
6239
|
+
});
|
|
6240
|
+
server.tool("memory_archive", "Archive a memory by ID or key (hides from lists, keeps history). No version needed.", {
|
|
6241
|
+
id: exports_external.string().optional(),
|
|
6242
|
+
key: exports_external.string().optional(),
|
|
6243
|
+
scope: exports_external.enum(["global", "shared", "private"]).optional(),
|
|
6244
|
+
agent_id: exports_external.string().optional(),
|
|
6245
|
+
project_id: exports_external.string().optional()
|
|
6246
|
+
}, async (args) => {
|
|
6247
|
+
try {
|
|
6248
|
+
let memory = args.id ? getMemory(resolveId(args.id)) : getMemoryByKey(args.key, args.scope, args.agent_id, args.project_id);
|
|
6249
|
+
if (!memory)
|
|
6250
|
+
return { content: [{ type: "text", text: `Memory not found.` }] };
|
|
6251
|
+
updateMemory(memory.id, { status: "archived", version: memory.version });
|
|
6252
|
+
return { content: [{ type: "text", text: `Memory "${memory.key}" archived.` }] };
|
|
6253
|
+
} catch (e) {
|
|
6254
|
+
return { content: [{ type: "text", text: formatError(e) }], isError: true };
|
|
6255
|
+
}
|
|
6256
|
+
});
|
|
6217
6257
|
server.tool("memory_forget", "Delete a memory by ID or key", {
|
|
6218
6258
|
id: exports_external.string().optional(),
|
|
6219
6259
|
key: exports_external.string().optional(),
|
|
@@ -7041,11 +7081,11 @@ var FULL_SCHEMAS = {
|
|
|
7041
7081
|
example: '{"scope":"global","min_importance":7,"limit":20}'
|
|
7042
7082
|
},
|
|
7043
7083
|
memory_update: {
|
|
7044
|
-
description: "Update a memory's fields.
|
|
7084
|
+
description: "Update a memory's fields. version is optional \u2014 auto-fetched if omitted (eliminates 2-round-trip pattern).",
|
|
7045
7085
|
category: "memory",
|
|
7046
7086
|
params: {
|
|
7047
7087
|
id: { type: "string", description: "Memory ID (partial OK)", required: true },
|
|
7048
|
-
version: { type: "number", description: "Current version
|
|
7088
|
+
version: { type: "number", description: "Current version for conflict detection (omit to auto-fetch)" },
|
|
7049
7089
|
value: { type: "string", description: "New value" },
|
|
7050
7090
|
category: { type: "string", description: "New category", enum: ["preference", "fact", "knowledge", "history"] },
|
|
7051
7091
|
scope: { type: "string", description: "New scope", enum: ["global", "shared", "private"] },
|
|
@@ -7059,6 +7099,27 @@ var FULL_SCHEMAS = {
|
|
|
7059
7099
|
},
|
|
7060
7100
|
example: '{"id":"abc123","version":1,"importance":9,"tags":["correction","important"]}'
|
|
7061
7101
|
},
|
|
7102
|
+
memory_pin: {
|
|
7103
|
+
description: "Pin or unpin a memory by ID or key. No version required.",
|
|
7104
|
+
category: "memory",
|
|
7105
|
+
params: {
|
|
7106
|
+
id: { type: "string", description: "Memory ID" },
|
|
7107
|
+
key: { type: "string", description: "Memory key (alternative to id)" },
|
|
7108
|
+
pinned: { type: "boolean", description: "true=pin (default), false=unpin" },
|
|
7109
|
+
scope: { type: "string", description: "Scope filter for key lookup", enum: ["global", "shared", "private"] }
|
|
7110
|
+
},
|
|
7111
|
+
example: '{"key":"project-stack","pinned":true}'
|
|
7112
|
+
},
|
|
7113
|
+
memory_archive: {
|
|
7114
|
+
description: "Archive a memory by ID or key. Hides from lists, preserves history. No version required.",
|
|
7115
|
+
category: "memory",
|
|
7116
|
+
params: {
|
|
7117
|
+
id: { type: "string", description: "Memory ID" },
|
|
7118
|
+
key: { type: "string", description: "Memory key (alternative to id)" },
|
|
7119
|
+
scope: { type: "string", description: "Scope filter for key lookup", enum: ["global", "shared", "private"] }
|
|
7120
|
+
},
|
|
7121
|
+
example: '{"key":"old-project-stack"}'
|
|
7122
|
+
},
|
|
7062
7123
|
memory_forget: {
|
|
7063
7124
|
description: "Delete a memory by ID or key.",
|
|
7064
7125
|
category: "memory",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hasna/mementos",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.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",
|
|
@@ -24,6 +24,7 @@
|
|
|
24
24
|
],
|
|
25
25
|
"scripts": {
|
|
26
26
|
"build": "bun build src/cli/index.tsx --outdir dist/cli --target bun --external ink --external react --external chalk --external @modelcontextprotocol/sdk && bun build src/mcp/index.ts --outdir dist/mcp --target bun --external @modelcontextprotocol/sdk && bun build src/server/index.ts --outdir dist/server --target bun && bun build src/index.ts --outdir dist --target bun && tsc --emitDeclarationOnly --outDir dist",
|
|
27
|
+
"prepare": "bun run build",
|
|
27
28
|
"typecheck": "tsc --noEmit",
|
|
28
29
|
"test": "bun test",
|
|
29
30
|
"dev:cli": "bun run src/cli/index.tsx",
|