@hasna/mementos 0.10.4 → 0.10.6
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/cli/index.js
CHANGED
|
@@ -10921,4 +10921,29 @@ program2.command("get-focus").description("Show the current project focus for an
|
|
|
10921
10921
|
else
|
|
10922
10922
|
console.log(chalk.dim("No focus set."));
|
|
10923
10923
|
});
|
|
10924
|
+
program2.command("remove <nameOrId>").description("Remove/delete a memory by name or ID (alias for memory delete)").option("--agent <id>", "Agent ID").action((nameOrId, opts) => {
|
|
10925
|
+
const globalOpts = program2.opts();
|
|
10926
|
+
const agentId = opts.agent || globalOpts.agent;
|
|
10927
|
+
const { deleteMemory: deleteMemory2, getMemoryByKey: getMemoryByKey2, resolvePartialMemoryId } = (init_memories(), __toCommonJS(exports_memories));
|
|
10928
|
+
let id = null;
|
|
10929
|
+
try {
|
|
10930
|
+
id = resolvePartialMemoryId?.(nameOrId) || null;
|
|
10931
|
+
} catch {}
|
|
10932
|
+
if (!id) {
|
|
10933
|
+
const mem = getMemoryByKey2?.(nameOrId, agentId);
|
|
10934
|
+
if (mem)
|
|
10935
|
+
id = mem.id;
|
|
10936
|
+
}
|
|
10937
|
+
if (!id) {
|
|
10938
|
+
console.error(chalk.red(`Memory not found: ${nameOrId}`));
|
|
10939
|
+
process.exit(1);
|
|
10940
|
+
}
|
|
10941
|
+
const deleted = deleteMemory2(id);
|
|
10942
|
+
if (deleted)
|
|
10943
|
+
console.log(chalk.green(`\u2713 Memory ${id.slice(0, 8)} removed`));
|
|
10944
|
+
else {
|
|
10945
|
+
console.error(chalk.red(`Memory not found: ${nameOrId}`));
|
|
10946
|
+
process.exit(1);
|
|
10947
|
+
}
|
|
10948
|
+
});
|
|
10924
10949
|
program2.parse(process.argv);
|
package/dist/mcp/index.js
CHANGED
|
@@ -3257,6 +3257,40 @@ var init_built_in_hooks = __esm(() => {
|
|
|
3257
3257
|
});
|
|
3258
3258
|
});
|
|
3259
3259
|
|
|
3260
|
+
// src/mcp/memory-broadcast.ts
|
|
3261
|
+
var exports_memory_broadcast = {};
|
|
3262
|
+
__export(exports_memory_broadcast, {
|
|
3263
|
+
broadcastSharedMemory: () => broadcastSharedMemory
|
|
3264
|
+
});
|
|
3265
|
+
async function broadcastSharedMemory(memory, savingAgentId) {
|
|
3266
|
+
if (!memory.project_id)
|
|
3267
|
+
return;
|
|
3268
|
+
try {
|
|
3269
|
+
const listRes = await fetch(`${CONVERSATIONS_API}/api/v1/agents?active=true&project_id=${memory.project_id}`, {
|
|
3270
|
+
signal: AbortSignal.timeout(3000)
|
|
3271
|
+
});
|
|
3272
|
+
if (!listRes.ok)
|
|
3273
|
+
return;
|
|
3274
|
+
const { agents } = await listRes.json();
|
|
3275
|
+
if (!agents?.length)
|
|
3276
|
+
return;
|
|
3277
|
+
const otherAgents = agents.filter((a) => a.id !== savingAgentId);
|
|
3278
|
+
if (!otherAgents.length)
|
|
3279
|
+
return;
|
|
3280
|
+
const notification = `[Memory Update] Agent ${savingAgentId} saved shared memory: "${memory.key}" \u2014 ${memory.summary || memory.value.slice(0, 100)}. Consider recalling this memory if relevant to your current task.`;
|
|
3281
|
+
await Promise.all(otherAgents.map((agent) => fetch(`${CONVERSATIONS_API}/api/v1/messages`, {
|
|
3282
|
+
method: "POST",
|
|
3283
|
+
headers: { "Content-Type": "application/json" },
|
|
3284
|
+
body: JSON.stringify({ from: savingAgentId, to: agent.id, content: notification }),
|
|
3285
|
+
signal: AbortSignal.timeout(3000)
|
|
3286
|
+
}).catch(() => {})));
|
|
3287
|
+
} catch {}
|
|
3288
|
+
}
|
|
3289
|
+
var CONVERSATIONS_API;
|
|
3290
|
+
var init_memory_broadcast = __esm(() => {
|
|
3291
|
+
CONVERSATIONS_API = process.env.CONVERSATIONS_API_URL || "http://localhost:7020";
|
|
3292
|
+
});
|
|
3293
|
+
|
|
3260
3294
|
// src/mcp/index.ts
|
|
3261
3295
|
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
3262
3296
|
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
@@ -9160,6 +9194,12 @@ server.tool("memory_save", "Save/upsert a memory. scope: global=all agents, shar
|
|
|
9160
9194
|
const memory = createMemory(input);
|
|
9161
9195
|
if (args.agent_id)
|
|
9162
9196
|
touchAgent(args.agent_id);
|
|
9197
|
+
if (memory.scope === "shared" && memory.project_id && args.agent_id) {
|
|
9198
|
+
try {
|
|
9199
|
+
const { broadcastSharedMemory: broadcastSharedMemory2 } = await Promise.resolve().then(() => (init_memory_broadcast(), exports_memory_broadcast));
|
|
9200
|
+
broadcastSharedMemory2(memory, args.agent_id).catch(() => {});
|
|
9201
|
+
} catch {}
|
|
9202
|
+
}
|
|
9163
9203
|
return { content: [{ type: "text", text: `Saved: ${memory.key} (${memory.id.slice(0, 8)})` }] };
|
|
9164
9204
|
} catch (e) {
|
|
9165
9205
|
return { content: [{ type: "text", text: formatError(e) }], isError: true };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Memory broadcast utility — notifies active agents when shared memories are saved.
|
|
3
|
+
* Uses the conversations MCP service if available.
|
|
4
|
+
* Non-blocking: failures are silently ignored.
|
|
5
|
+
*/
|
|
6
|
+
import type { Memory } from '../types/index.js';
|
|
7
|
+
/**
|
|
8
|
+
* Broadcast a newly saved shared memory to all active agents on the project
|
|
9
|
+
* via the conversations MCP send_message endpoint.
|
|
10
|
+
*/
|
|
11
|
+
export declare function broadcastSharedMemory(memory: Memory, savingAgentId: string): Promise<void>;
|
|
12
|
+
//# sourceMappingURL=memory-broadcast.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"memory-broadcast.d.ts","sourceRoot":"","sources":["../../src/mcp/memory-broadcast.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAIhD;;;GAGG;AACH,wBAAsB,qBAAqB,CAAC,MAAM,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CA4BhG"}
|