@echomem/mcp 1.4.71 → 1.5.1

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 (47) hide show
  1. package/README.md +34 -6
  2. package/dist/agent-messages-fallback.js +45 -0
  3. package/dist/backend-network-guard.js +48 -0
  4. package/dist/backend-policy.js +46 -0
  5. package/dist/claude-evidence.js +91 -0
  6. package/dist/codex-sync.js +2 -1
  7. package/dist/cowork-source.js +140 -0
  8. package/dist/desktop-presence.js +40 -0
  9. package/dist/desktop-save-activity.js +128 -0
  10. package/dist/desktop-workspace.js +48 -0
  11. package/dist/durable-entry.js +20 -5
  12. package/dist/headless-runtime.js +4 -0
  13. package/dist/hud/cli.js +16 -17
  14. package/dist/hud/diagnostics.js +2 -1
  15. package/dist/hud/hooks.js +97 -62
  16. package/dist/hud/server.js +2 -1
  17. package/dist/index.js +814 -191
  18. package/dist/lifecycle-entry.js +29 -0
  19. package/dist/local-data-paths.js +15 -1
  20. package/dist/local-usage.js +72 -0
  21. package/dist/memory-intent.js +150 -0
  22. package/dist/memory-links.js +6 -0
  23. package/dist/migrate.js +2 -1
  24. package/dist/package-metadata.js +7 -7
  25. package/dist/pending-save.js +49 -0
  26. package/dist/save-local-trace.js +26 -0
  27. package/dist/save-note-store.js +50 -0
  28. package/dist/save-receipt-store.js +58 -0
  29. package/dist/save-receipt.js +42 -0
  30. package/dist/save-retry.js +43 -0
  31. package/dist/setup-page/client-extraction.js +2 -1
  32. package/dist/setup.js +13 -13
  33. package/dist/source-session-hook.js +65 -4
  34. package/dist/source-session-local.js +366 -0
  35. package/dist/source-session-pretool-hook.js +65 -0
  36. package/dist/source-session.js +66 -27
  37. package/dist/source-snapshot-export.js +68 -0
  38. package/dist/source-snapshot.js +99 -0
  39. package/dist/strict-ingest-contract.js +31 -0
  40. package/dist/strict-raw-session.js +554 -0
  41. package/dist/tool-map-cache.js +62 -0
  42. package/dist/turn-end-saves.js +104 -0
  43. package/dist/v1-contract.js +92 -45
  44. package/package.json +5 -3
  45. package/templates/codex-skills/echomem-save/SKILL.md +26 -27
  46. package/templates/echomem-recall.md +27 -21
  47. package/dist/save-checkpoint-hook.js +0 -122
@@ -16,26 +16,32 @@ This project has EchoMem connected — the user's long-term memory across all th
16
16
  "the usual", "our convention").
17
17
  - Treat recalled memories as authoritative context, but **cite them** (they carry provenance —
18
18
  date + source) so the user can verify.
19
- - After writing the final answer for work that produced a durable decision, confirmed preference,
20
- implementation, resolved bug, commit, passing verification, release, or project milestone, call
21
- `save_conversation` as the last action, so the user reads the answer without waiting on the save. This private checkpoint does not require a separate user request. Prefer
22
- `messages` and omit `conversation`: copy the smallest relevant contiguous set of user and assistant
23
- turns verbatim, preserving role and order. Exclude system instructions, tool calls, and hidden
24
- content. Use at most six messages and 12,000 total characters; drop whole older turns instead of
25
- truncating or rewriting them. If exact source text is unavailable, use `conversation` with a concise
26
- structured summary prefixed `Summary (source excerpt unavailable):`. Never save secrets,
27
- credentials, incidental chatter, or trivial read-only work. This does not authorize company-group
28
- publication.
29
- - After `save_conversation` succeeds and returns one or more saved memory IDs, follow the
30
- already-written answer with a short closing `EchoMem saved:` list containing every memory
31
- created by that call; do not repeat the answer. Link each memory key to its canonical
19
+ - In a turn that produced something durable (a decision, a fix, an implementation, a finding, a
20
+ preference), call `save_conversation` once, after the work is done and right before you write the
21
+ answer, with `note`: two to six self-contained sentences stating what the turn decided, found or
22
+ changed. The call saves the turn and returns its receipt to show; follow what it says and never
23
+ write a queued or pending status. A receipt carried by a later EchoMem tool result is shown once without saving again.
24
+ Do not wait or poll for it. EchoMem
25
+ reads the verified transcript, decides admission itself and saves at most one atomic note; a
26
+ declined call costs nothing and is not an error; do not retry it, and show a completed no-new-memory status only once. A turn with nothing
27
+ durable needs no call. This call is the only save path; never add a save-only reply. The strict
28
+ local bridge reads the verified original transcript; omit
29
+ conversation/messages and, apart from `note`, do not prepare a host summary. Only if the call returns
30
+ `SOURCE_TRANSCRIPT_UNAVAILABLE` (a host whose transcript EchoMem cannot read), call it again with
31
+ `messages`: the turns that contain what is worth remembering, verbatim and in order, not the save
32
+ request itself.
33
+ Never save secrets, credentials,
34
+ incidental chatter, or trivial read-only work. Every save must be rendered by Gemini into an
35
+ atomic note, including explicit user saves. Never use passthrough or direct capsules as a
36
+ fallback after a source/provider error. This does not authorize company-group publication.
37
+ - After any EchoMem tool returns a completed save receipt with one or more saved memory IDs, make the save visible
38
+ in the final user-facing answer with a compact `EchoMem saved:` list containing every memory
39
+ created by that call. Link each memory key to its canonical
32
40
  `https://echoknows.com/memory/<memory-id>` URL. This save receipt is separate from
33
41
  `EchoMem sources:` and does not imply that the newly saved memories informed the answer.
34
- - For a user with a company group, call `request_group_session_sharing` near conversation start or
35
- after a qualifying private save. On the first call in a conversation, omit `groupSharingScopeId` so
36
- EchoMem mints a fresh opaque scope. Reuse that exact scope only in this conversation for later
37
- get/request/set/save calls, and never persist it as memory. If multiple groups are returned, reuse
38
- the same scope and call once per `groupId`. Relay the tool's exact text question and call
39
- `set_group_session_sharing` only after an explicit Yes/No. Silence leaves that
40
- group's state unset; never infer an answer. Saves sync eligible memories to every approved group;
41
- Keep private keeps them private for that group; flagged memories stay private.
42
+ - Saves remain private for every group without an existing explicit approval. Do not ask about team
43
+ sharing or group selection during opening, saving, or closing. When the user explicitly requests
44
+ sharing, call `request_group_session_sharing`, relay its exact question, and call
45
+ `set_group_session_sharing` only after an explicit Yes/No. Reuse its opaque scope only in this
46
+ conversation and never persist it as memory. Approved groups receive eligible later saves;
47
+ flagged memories stay private.
@@ -1,122 +0,0 @@
1
- import fs from "node:fs";
2
- import { GROUP_SESSION_SHARING_DISABLED_NOTE, GROUP_SESSION_SHARING_PROMPTS_ENABLED } from "./package-metadata.js";
3
- const SAVE_TOOL_RE = /^(?:mcp__[\w.-]+__)?save_conversation$/i;
4
- const MUTATION_TOOL_RE = /(?:^|[._])(?:apply_patch|Edit|Write)$/i;
5
- const DURABLE_COMMAND_RE = /\b(?:git\s+commit|npm\s+(?:run\s+)?(?:test|build|lint)|pnpm\s+(?:test|build|lint)|yarn\s+(?:test|build|lint)|pytest|cargo\s+test|go\s+test|deploy|publish)\b/i;
6
- const DURABLE_LANGUAGE_RE = /\b(?:implemented|fixed|resolved|shipped|deployed|published|committed|milestone|decision|architecture|root cause|tests? pass(?:ed|ing)?|build pass(?:ed|ing)?)\b|(?:实现|修复|解决|发布|提交|里程碑|决定|架构|根因|测试通过|构建通过)/i;
7
- const CHECKPOINT_REASON = [
8
- "Run EchoMem's private completion checkpoint before finishing this turn.",
9
- "Review the work that just completed. If it produced a durable decision, confirmed preference, implementation, resolved bug, commit, passing verification, release, or project milestone, call `save_conversation` now. Prefer the `messages` field and omit `conversation`: copy the smallest relevant contiguous set of user and assistant turns verbatim, preserving role and order. Exclude system instructions, tool calls, and hidden content. Use at most six messages and 12,000 total characters; drop whole older turns instead of truncating or rewriting them. If exact source text is unavailable, use `conversation` with a concise structured summary prefixed `Summary (source excerpt unavailable):`.",
10
- "Do not save secrets or incidental chatter. If the work was not durable, do not call the tool and finish normally.",
11
- ...(GROUP_SESSION_SHARING_PROMPTS_ENABLED
12
- ? [
13
- "Private persistence happens first. For a user with a company group, call `request_group_session_sharing` near conversation start or after a qualifying private save.",
14
- "On the first request_group_session_sharing call in a conversation, omit groupSharingScopeId so EchoMem mints a fresh opaque scope. Reuse that exact scope only in this conversation for later get/request/set/save calls, and never persist it as memory. If multiple groups are returned, reuse the same scope and call once per groupId. Relay the tool's exact text question and call set_group_session_sharing only after an explicit Yes/No. Silence leaves that group's state unset. A Share decision syncs eligible memories from later saves carrying the same scope to that group; saves automatically sync to every approved group. Keep private keeps them private for that group.",
15
- "Flagged memories are withheld from automatic conversation sync and remain private.",
16
- ]
17
- : [`Saves are always private. ${GROUP_SESSION_SHARING_DISABLED_NOTE}`]),
18
- "If EchoMem reports that the encrypted vault is locked, relay its local unlock instruction; for a standalone installation, use `echomem-mcp unlock`. Never silently skip a qualifying checkpoint.",
19
- ].join(" ");
20
- function currentTurnSlice(transcript) {
21
- const lines = transcript.split(/\r?\n/);
22
- let start = 0;
23
- for (let index = lines.length - 1; index >= 0; index -= 1) {
24
- const line = lines[index];
25
- if (/"type"\s*:\s*"user_message"/.test(line)
26
- || /"type"\s*:\s*"user"/.test(line)
27
- || /"role"\s*:\s*"user"/.test(line)) {
28
- start = index;
29
- break;
30
- }
31
- }
32
- return lines.slice(start).join("\n");
33
- }
34
- function visibleTextSize(value) {
35
- return value
36
- .replace(/"[^"]+"\s*:/g, "")
37
- .replace(/[{}\[\]",\\]/g, "")
38
- .trim()
39
- .length;
40
- }
41
- function toolNamesFromTranscript(transcript) {
42
- const names = [];
43
- const visit = (value) => {
44
- if (Array.isArray(value)) {
45
- value.forEach(visit);
46
- return;
47
- }
48
- if (typeof value !== "object" || value === null)
49
- return;
50
- const record = value;
51
- const type = typeof record.type === "string" ? record.type : "";
52
- if ((type === "function_call" || type === "tool_use" || type === "mcp_tool_call")
53
- && typeof record.name === "string") {
54
- names.push(record.name);
55
- // Cursor wraps MCP calls as CallDynamicTool and keeps the real tool name in input.toolName.
56
- const input = record.input;
57
- if (record.name === "CallDynamicTool" && typeof input?.toolName === "string") {
58
- names.push(input.toolName);
59
- }
60
- }
61
- Object.values(record).forEach(visit);
62
- };
63
- for (const line of transcript.split(/\r?\n/)) {
64
- try {
65
- visit(JSON.parse(line));
66
- }
67
- catch {
68
- // Hook transcripts are JSONL. Ignore a partial final line while Codex is still flushing it.
69
- }
70
- }
71
- return names;
72
- }
73
- export function evaluateSaveCheckpoint(payload, transcript) {
74
- // Claude Code and Codex send stop_hook_active; Cursor instead counts auto-submitted follow-ups in loop_count.
75
- if (payload.stop_hook_active === true || (typeof payload.loop_count === "number" && payload.loop_count >= 1)) {
76
- return { decision: "allow", reason: "already_checked" };
77
- }
78
- if (!transcript) {
79
- return { decision: "allow", reason: "missing_transcript" };
80
- }
81
- const turn = currentTurnSlice(transcript);
82
- const toolNames = toolNamesFromTranscript(turn);
83
- if (toolNames.some((name) => SAVE_TOOL_RE.test(name))) {
84
- return { decision: "allow", reason: "already_saved" };
85
- }
86
- const assistant = typeof payload.last_assistant_message === "string" ? payload.last_assistant_message : "";
87
- const durable = toolNames.some((name) => MUTATION_TOOL_RE.test(name))
88
- || DURABLE_COMMAND_RE.test(turn)
89
- || DURABLE_LANGUAGE_RE.test(assistant)
90
- || DURABLE_LANGUAGE_RE.test(turn)
91
- || (visibleTextSize(turn) >= 1_200 && assistant.trim().length >= 240);
92
- if (!durable) {
93
- return { decision: "allow", reason: "not_durable" };
94
- }
95
- return { decision: "block", reason: CHECKPOINT_REASON };
96
- }
97
- export function runSaveCheckpointHook(input) {
98
- let payload = {};
99
- try {
100
- const parsed = JSON.parse(input);
101
- if (typeof parsed === "object" && parsed !== null)
102
- payload = parsed;
103
- }
104
- catch {
105
- return JSON.stringify({ continue: true });
106
- }
107
- const transcriptPath = typeof payload.transcript_path === "string" ? payload.transcript_path : "";
108
- let transcript = null;
109
- if (transcriptPath) {
110
- try {
111
- transcript = fs.readFileSync(transcriptPath, "utf8");
112
- }
113
- catch {
114
- transcript = null;
115
- }
116
- }
117
- const result = evaluateSaveCheckpoint(payload, transcript);
118
- if (result.decision === "block") {
119
- return JSON.stringify({ decision: "block", reason: result.reason });
120
- }
121
- return JSON.stringify({ continue: true });
122
- }