@echomem/mcp 1.4.64 → 1.4.66
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/README.md +4 -3
- package/dist/index.js +25 -4
- package/dist/migrate.js +1 -1
- package/dist/save-checkpoint-hook.js +1 -1
- package/dist/setup-page/client-core.js +54 -7
- package/dist/setup-page/client-extraction.js +51 -37
- package/dist/setup-page/client-lifecycle.js +38 -4
- package/dist/setup-page/document.js +1 -1
- package/dist/setup-page/styles-extraction.js +0 -13
- package/dist/setup-page/styles-foundation.js +33 -21
- package/dist/setup-page/styles-monochrome.js +1387 -0
- package/dist/setup-page/styles-mvp.js +1 -253
- package/dist/setup-page/styles.js +2 -2
- package/dist/setup-preview.js +1 -1
- package/dist/setup.js +73 -15
- package/dist/source-session.js +135 -12
- package/dist/v1-contract.js +9 -0
- package/package.json +2 -2
- package/templates/codex-skills/echomem-save/SKILL.md +13 -8
- package/templates/echomem-recall.md +8 -3
- package/dist/setup-page/styles-website-alignment.js +0 -851
package/dist/source-session.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import fs from "node:fs";
|
|
2
2
|
import path from "node:path";
|
|
3
|
-
import { resolveClaudeCoworkSessionsDir, resolveClaudeProjectsDir, resolveCodexSessionRoots, } from "./local-data-paths.js";
|
|
3
|
+
import { resolveClaudeCoworkSessionsDir, resolveClaudeDesktopSupportRoots, resolveClaudeProjectsDir, resolveCodexSessionRoots, } from "./local-data-paths.js";
|
|
4
4
|
export const SOURCE_SESSION_BINDING_EVIDENCE = "local_jsonl_tool_call";
|
|
5
5
|
export const SOURCE_SESSION_HOOK_EVIDENCE = "local_session_start_hook";
|
|
6
6
|
export const SOURCE_SESSION_MCP_METADATA_EVIDENCE = "local_mcp_session_metadata";
|
|
@@ -158,11 +158,16 @@ function readableDirectory(candidate) {
|
|
|
158
158
|
return false;
|
|
159
159
|
}
|
|
160
160
|
}
|
|
161
|
-
function defaultRoots() {
|
|
162
|
-
const
|
|
163
|
-
|
|
161
|
+
function defaultRoots(options = {}) {
|
|
162
|
+
const pathOptions = {
|
|
163
|
+
env: options.env,
|
|
164
|
+
homeDir: options.homeDir,
|
|
165
|
+
platform: options.platform,
|
|
166
|
+
};
|
|
167
|
+
const claudeProjects = resolveClaudeProjectsDir(pathOptions);
|
|
168
|
+
const desktopRoot = resolveClaudeCoworkSessionsDir(pathOptions);
|
|
164
169
|
return {
|
|
165
|
-
codex: resolveCodexSessionRoots().map((root) => root.path),
|
|
170
|
+
codex: resolveCodexSessionRoots(pathOptions).map((root) => root.path),
|
|
166
171
|
claudeCode: claudeProjects ? [claudeProjects] : [],
|
|
167
172
|
cowork: desktopRoot ? [desktopRoot] : [],
|
|
168
173
|
};
|
|
@@ -316,7 +321,9 @@ function tailContainsBinding(file, bindingToken) {
|
|
|
316
321
|
const buffer = Buffer.allocUnsafe(bytes);
|
|
317
322
|
fs.readSync(descriptor, buffer, 0, bytes, stat.size - bytes);
|
|
318
323
|
const tail = buffer.toString("utf8");
|
|
319
|
-
return tail.
|
|
324
|
+
return tail.split(/\r?\n/).some((line) => (line.includes(bindingToken)
|
|
325
|
+
&& (line.includes("bind_source_session")
|
|
326
|
+
|| line.includes("sourceSessionBindingToken"))));
|
|
320
327
|
}
|
|
321
328
|
catch {
|
|
322
329
|
return false;
|
|
@@ -338,6 +345,89 @@ function claudeCodeSessionId(file) {
|
|
|
338
345
|
const value = path.basename(file, ".jsonl").trim();
|
|
339
346
|
return value && value.length <= 200 ? value : null;
|
|
340
347
|
}
|
|
348
|
+
function claudeDesktopClaimFiles(root) {
|
|
349
|
+
const files = [];
|
|
350
|
+
const pending = readableDirectory(root) ? [root] : [];
|
|
351
|
+
while (pending.length) {
|
|
352
|
+
const directory = pending.pop();
|
|
353
|
+
let entries;
|
|
354
|
+
try {
|
|
355
|
+
entries = fs.readdirSync(directory, { withFileTypes: true });
|
|
356
|
+
}
|
|
357
|
+
catch {
|
|
358
|
+
continue;
|
|
359
|
+
}
|
|
360
|
+
for (const entry of entries) {
|
|
361
|
+
const target = path.join(directory, entry.name);
|
|
362
|
+
if (entry.isDirectory())
|
|
363
|
+
pending.push(target);
|
|
364
|
+
else if (entry.isFile()
|
|
365
|
+
&& entry.name.startsWith("local_")
|
|
366
|
+
&& entry.name.endsWith(".json"))
|
|
367
|
+
files.push(target);
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
return files;
|
|
371
|
+
}
|
|
372
|
+
function claudeDesktopClaimForAlias(cliSessionId, options) {
|
|
373
|
+
const normalizedAlias = normalizedUuid(cliSessionId);
|
|
374
|
+
if (!normalizedAlias)
|
|
375
|
+
return null;
|
|
376
|
+
const claims = [];
|
|
377
|
+
for (const supportRoot of resolveClaudeDesktopSupportRoots({
|
|
378
|
+
env: options.env,
|
|
379
|
+
homeDir: options.homeDir,
|
|
380
|
+
platform: options.platform,
|
|
381
|
+
})) {
|
|
382
|
+
const sessionsRoot = path.join(supportRoot, "claude-code-sessions");
|
|
383
|
+
for (const file of claudeDesktopClaimFiles(sessionsRoot)) {
|
|
384
|
+
try {
|
|
385
|
+
const record = JSON.parse(fs.readFileSync(file, "utf8"));
|
|
386
|
+
if (!isRecord(record) || record.isArchived === true)
|
|
387
|
+
continue;
|
|
388
|
+
const providerSessionId = typeof record.sessionId === "string"
|
|
389
|
+
? record.sessionId.trim()
|
|
390
|
+
: "";
|
|
391
|
+
if (!/^local_[A-Za-z0-9_-]{1,194}$/.test(providerSessionId))
|
|
392
|
+
continue;
|
|
393
|
+
const rawAliases = [record.cliSessionId, ...(Array.isArray(record.priorCliSessionIds)
|
|
394
|
+
? record.priorCliSessionIds
|
|
395
|
+
: [])];
|
|
396
|
+
const aliases = [...new Set(rawAliases.map(normalizedUuid).filter((value) => !!value))]
|
|
397
|
+
.slice(0, 32);
|
|
398
|
+
if (!aliases.includes(normalizedAlias))
|
|
399
|
+
continue;
|
|
400
|
+
const focusedAt = [record.lastFocusedAt, record.lastActivityAt, record.createdAt]
|
|
401
|
+
.find((value) => typeof value === "number" && Number.isFinite(value));
|
|
402
|
+
claims.push({
|
|
403
|
+
providerSessionId,
|
|
404
|
+
providerSessionAliases: aliases,
|
|
405
|
+
focusedAt: focusedAt ?? 0,
|
|
406
|
+
});
|
|
407
|
+
}
|
|
408
|
+
catch {
|
|
409
|
+
continue;
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
const claimsByConversation = new Map();
|
|
414
|
+
for (const claim of claims) {
|
|
415
|
+
const existing = claimsByConversation.get(claim.providerSessionId);
|
|
416
|
+
if (!existing) {
|
|
417
|
+
claimsByConversation.set(claim.providerSessionId, claim);
|
|
418
|
+
continue;
|
|
419
|
+
}
|
|
420
|
+
existing.providerSessionAliases = [...new Set([
|
|
421
|
+
...existing.providerSessionAliases,
|
|
422
|
+
...claim.providerSessionAliases,
|
|
423
|
+
])].slice(0, 32);
|
|
424
|
+
existing.focusedAt = Math.max(existing.focusedAt, claim.focusedAt);
|
|
425
|
+
}
|
|
426
|
+
if (claimsByConversation.size > 1) {
|
|
427
|
+
throw new Error("The Claude Desktop transcript alias maps to multiple durable conversations; wait for Desktop metadata repair before retrying");
|
|
428
|
+
}
|
|
429
|
+
return [...claimsByConversation.values()][0] ?? null;
|
|
430
|
+
}
|
|
341
431
|
function coworkSessionId(file) {
|
|
342
432
|
const value = file.split(path.sep).find((part) => /^local_[A-Za-z0-9_-]{1,194}$/.test(part));
|
|
343
433
|
return value ?? null;
|
|
@@ -455,7 +545,7 @@ export function resolveSourceSessionFromBindingToken(bindingToken, options = {})
|
|
|
455
545
|
const needsDefaults = options.roots?.codex === undefined
|
|
456
546
|
|| options.roots?.claudeCode === undefined
|
|
457
547
|
|| options.roots?.cowork === undefined;
|
|
458
|
-
const defaults = needsDefaults ? defaultRoots() : { codex: [], claudeCode: [], cowork: [] };
|
|
548
|
+
const defaults = needsDefaults ? defaultRoots(options) : { codex: [], claudeCode: [], cowork: [] };
|
|
459
549
|
const roots = {
|
|
460
550
|
codex: options.roots?.codex ?? defaults.codex,
|
|
461
551
|
claudeCode: options.roots?.claudeCode ?? defaults.claudeCode,
|
|
@@ -478,17 +568,50 @@ export function resolveSourceSessionFromBindingToken(bindingToken, options = {})
|
|
|
478
568
|
: provider === "claude-code"
|
|
479
569
|
? claudeCodeSessionId(file)
|
|
480
570
|
: coworkSessionId(file);
|
|
481
|
-
if (providerSessionId)
|
|
482
|
-
|
|
571
|
+
if (!providerSessionId)
|
|
572
|
+
continue;
|
|
573
|
+
if (provider === "claude-code" && enabledProviders(options.hostPlatform).includes("cowork")) {
|
|
574
|
+
const claim = claudeDesktopClaimForAlias(providerSessionId, options);
|
|
575
|
+
if (claim) {
|
|
576
|
+
matches.push(verifiedClaudeDesktopSession(claim.providerSessionId, claim.providerSessionAliases));
|
|
577
|
+
continue;
|
|
578
|
+
}
|
|
579
|
+
// Claude Desktop rotates the nested CLI transcript UUID while its local_ conversation ID
|
|
580
|
+
// remains durable. Never bind the transient alias as the canonical conversation if the
|
|
581
|
+
// Desktop index is not ready yet; the bounded retry can wait for that metadata instead.
|
|
582
|
+
continue;
|
|
583
|
+
}
|
|
584
|
+
matches.push(verifiedSourceSession(provider, providerSessionId, SOURCE_SESSION_BINDING_EVIDENCE));
|
|
483
585
|
}
|
|
484
586
|
}
|
|
485
|
-
const unique = new Map(matches.map((match) => [
|
|
587
|
+
const unique = new Map(matches.map((match) => [match.canonicalKey, match]));
|
|
486
588
|
if (unique.size === 0) {
|
|
487
589
|
throw new Error("Could not verify this binding token in a recent local host JSONL. Retry bind_source_session with a new UUID after the host has recorded the tool call.");
|
|
488
590
|
}
|
|
489
591
|
if (unique.size !== 1) {
|
|
490
592
|
throw new Error("The binding token appeared in multiple source sessions; retry with a fresh UUID");
|
|
491
593
|
}
|
|
492
|
-
|
|
493
|
-
|
|
594
|
+
return [...unique.values()][0];
|
|
595
|
+
}
|
|
596
|
+
/**
|
|
597
|
+
* Claude writes a tool invocation immediately before dispatching it to the MCP server, but the
|
|
598
|
+
* filesystem notification can trail stdio by a few milliseconds. Retry only the zero-match state;
|
|
599
|
+
* ambiguity and malformed input fail immediately rather than allowing a later file to win a race.
|
|
600
|
+
*/
|
|
601
|
+
export async function resolveSourceSessionFromBindingTokenWithRetry(bindingToken, options = {}) {
|
|
602
|
+
const timeoutMs = Math.max(0, Math.min(options.timeoutMs ?? 2_000, 5_000));
|
|
603
|
+
const pollIntervalMs = Math.max(10, Math.min(options.pollIntervalMs ?? 25, 250));
|
|
604
|
+
const deadline = Date.now() + timeoutMs;
|
|
605
|
+
while (true) {
|
|
606
|
+
try {
|
|
607
|
+
return resolveSourceSessionFromBindingToken(bindingToken, options);
|
|
608
|
+
}
|
|
609
|
+
catch (error) {
|
|
610
|
+
if (!(error instanceof Error)
|
|
611
|
+
|| !error.message.startsWith("Could not verify this binding token")
|
|
612
|
+
|| Date.now() >= deadline)
|
|
613
|
+
throw error;
|
|
614
|
+
await new Promise((resolve) => setTimeout(resolve, pollIntervalMs));
|
|
615
|
+
}
|
|
616
|
+
}
|
|
494
617
|
}
|
package/dist/v1-contract.js
CHANGED
|
@@ -221,6 +221,7 @@ const triggerMetadataSchema = {
|
|
|
221
221
|
triggerMessage: z.string().optional(),
|
|
222
222
|
triggerMessageRole: z.string().optional(),
|
|
223
223
|
cloudCoworkSessionId: z.string().regex(/^session_[A-Za-z0-9_-]{1,192}$/).optional(),
|
|
224
|
+
sourceSessionBindingToken: z.string().uuid().optional(),
|
|
224
225
|
};
|
|
225
226
|
// Phrased as a capability test rather than a product name, deliberately.
|
|
226
227
|
//
|
|
@@ -254,6 +255,12 @@ const CLOUD_COWORK_SESSION_PROPERTY = {
|
|
|
254
255
|
pattern: "^session_[A-Za-z0-9_-]{1,192}$",
|
|
255
256
|
description: CLOUD_COWORK_SESSION_DESCRIPTION,
|
|
256
257
|
};
|
|
258
|
+
const SOURCE_SESSION_BINDING_TOKEN_DESCRIPTION = "Compatibility fallback only after an EchoMem call from this conversation reports source_session_unavailable. Generate a fresh random UUID for this exact retry and never reuse it. The local bridge verifies that UUID inside exactly one recent host JSONL and scopes the resulting identity to this request; do not copy a token from another conversation.";
|
|
259
|
+
const SOURCE_SESSION_BINDING_TOKEN_PROPERTY = {
|
|
260
|
+
type: "string",
|
|
261
|
+
format: "uuid",
|
|
262
|
+
description: SOURCE_SESSION_BINDING_TOKEN_DESCRIPTION,
|
|
263
|
+
};
|
|
257
264
|
const SOURCE_CONTEXT_FREE_TOOL_NAMES = new Set([
|
|
258
265
|
canonicalToolNames.bindSourceSession,
|
|
259
266
|
canonicalToolNames.updateStatus,
|
|
@@ -268,6 +275,7 @@ function injectCloudCoworkSession(specs) {
|
|
|
268
275
|
spec.inputSchema.properties = {
|
|
269
276
|
...existing,
|
|
270
277
|
cloudCoworkSessionId: CLOUD_COWORK_SESSION_PROPERTY,
|
|
278
|
+
sourceSessionBindingToken: SOURCE_SESSION_BINDING_TOKEN_PROPERTY,
|
|
271
279
|
};
|
|
272
280
|
}
|
|
273
281
|
return specs;
|
|
@@ -1274,6 +1282,7 @@ export function listToolSpecs(opts = {}) {
|
|
|
1274
1282
|
},
|
|
1275
1283
|
messages: {
|
|
1276
1284
|
type: "array",
|
|
1285
|
+
description: "Preferred source input. 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. Omit conversation when messages is used.",
|
|
1277
1286
|
items: {
|
|
1278
1287
|
type: "object",
|
|
1279
1288
|
properties: {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@echomem/mcp",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.66",
|
|
4
4
|
"description": "EchoMem MCP bridge for cross-agent memory, local history import, and recall",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"test:config-safety": "npm run build && node test/config-safety.test.mjs",
|
|
37
37
|
"test:billing-ui": "npm run build && node test/setup-ui.test.mjs billing",
|
|
38
38
|
"test:mcp-control": "npm run build && node test/mcp-control.test.mjs",
|
|
39
|
-
"test": "npm run build && node test/source-session.test.mjs && node test/cowork-ticket-session.test.mjs && node test/ticket-review-format.test.mjs && node test/schema-parity.test.mjs && node test/ticket-overview.test.mjs && node test/ticket-stewardship-contract.test.mjs && node test/stewardship-integration.test.mjs && node test/source-session-hook.test.mjs && node test/local-data-paths.test.mjs && node test/crypto.test.mjs && node test/integration.test.mjs && node test/onboarding-resilience.test.mjs && node test/local-auth.test.mjs && node test/product-analytics.test.mjs && node test/retrieval-only.test.mjs && node test/no-restart.test.mjs && node test/canonical-golden.test.mjs && node test/tools.test.mjs && node test/workspace-selector.test.mjs && node test/group-map.test.mjs && node test/update-check.test.mjs && node test/headless-runtime.test.mjs && node test/claude-code-config.test.mjs && node test/config-safety.test.mjs && node test/mcp-control.test.mjs && node test/delete.test.mjs && node test/low-touch-tools.test.mjs && node test/migrate.test.mjs && node test/restart-recovery.test.mjs && node test/save-checkpoint-hook.test.mjs && node test/durable-entry.test.mjs && node test/durable-reexec.test.mjs && node test/doctor.test.mjs && node test/environment-matrix.test.mjs",
|
|
39
|
+
"test": "npm run build && node test/source-session.test.mjs && node test/source-session-stress.test.mjs && node test/cowork-ticket-session.test.mjs && node test/ticket-review-format.test.mjs && node test/schema-parity.test.mjs && node test/ticket-overview.test.mjs && node test/ticket-stewardship-contract.test.mjs && node test/stewardship-integration.test.mjs && node test/source-session-hook.test.mjs && node test/local-data-paths.test.mjs && node test/crypto.test.mjs && node test/integration.test.mjs && node test/onboarding-resilience.test.mjs && node test/local-auth.test.mjs && node test/product-analytics.test.mjs && node test/retrieval-only.test.mjs && node test/no-restart.test.mjs && node test/canonical-golden.test.mjs && node test/tools.test.mjs && node test/workspace-selector.test.mjs && node test/group-map.test.mjs && node test/update-check.test.mjs && node test/headless-runtime.test.mjs && node test/claude-code-config.test.mjs && node test/config-safety.test.mjs && node test/mcp-control.test.mjs && node test/delete.test.mjs && node test/low-touch-tools.test.mjs && node test/migrate.test.mjs && node test/restart-recovery.test.mjs && node test/save-checkpoint-hook.test.mjs && node test/durable-entry.test.mjs && node test/durable-reexec.test.mjs && node test/doctor.test.mjs && node test/environment-matrix.test.mjs",
|
|
40
40
|
"prepack": "npm run build"
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
@@ -7,23 +7,28 @@ description: Save durable knowledge to EchoMem, the user's cross-agent long-term
|
|
|
7
7
|
|
|
8
8
|
Use the `save_conversation` tool from the `echomem` MCP server.
|
|
9
9
|
|
|
10
|
-
1.
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
10
|
+
1. Prefer structured `messages` and omit `conversation`. Copy the smallest relevant contiguous set of
|
|
11
|
+
user and assistant turns verbatim, preserving their roles and order. Exclude system instructions,
|
|
12
|
+
tool calls, hidden content, noise, and unrelated turns.
|
|
13
|
+
2. Use at most six messages and 12,000 total characters. Drop whole older turns to fit the limit;
|
|
14
|
+
never silently truncate or rewrite a selected turn.
|
|
15
|
+
3. If exact source text is unavailable, use `conversation` with a concise structured summary prefixed
|
|
16
|
+
`Summary (source excerpt unavailable):`. Add a concise title, source, and useful tags.
|
|
17
|
+
4. Use `passthrough: true` only when the user explicitly needs a verbatim session capsule.
|
|
18
|
+
5. Never include secrets, credentials, or unnecessary sensitive content.
|
|
19
|
+
6. Confirm what EchoMem saved. When the tool returns one or more saved memory IDs, end the final
|
|
15
20
|
user-facing answer with a compact `EchoMem saved:` list containing every memory created by that
|
|
16
21
|
call. Use each memory key as the Markdown label and its canonical
|
|
17
22
|
`https://echoknows.com/memory/<memory-id>` URL. Keep this separate from `EchoMem sources:`; a save
|
|
18
23
|
receipt does not imply the newly saved memories informed the answer. If saving fails, report the
|
|
19
24
|
failure without switching providers silently.
|
|
20
|
-
|
|
25
|
+
7. Before a final response, use this workflow proactively when the task produced a durable decision,
|
|
21
26
|
confirmed preference, implementation, resolved bug, commit, passing verification, release, or
|
|
22
27
|
project milestone. A private checkpoint does not require a separate user request. Skip trivial
|
|
23
28
|
read-only work and incidental chatter.
|
|
24
|
-
|
|
29
|
+
8. If the encrypted vault is locked, tell the user to run `echomem-mcp unlock`; never silently skip a
|
|
25
30
|
qualifying checkpoint.
|
|
26
|
-
|
|
31
|
+
9. For a user with a company group, call `request_group_session_sharing` near conversation start or
|
|
27
32
|
after a qualifying private save. On the first call in a conversation, omit `groupSharingScopeId` so
|
|
28
33
|
EchoMem mints a fresh opaque scope. Reuse that exact scope only in this conversation for later
|
|
29
34
|
get/request/set/save calls, and never persist it as memory. If multiple groups are returned, reuse
|
|
@@ -18,9 +18,14 @@ This project has EchoMem connected — the user's long-term memory across all th
|
|
|
18
18
|
date + source) so the user can verify.
|
|
19
19
|
- Before the final response for work that produced a durable decision, confirmed preference,
|
|
20
20
|
implementation, resolved bug, commit, passing verification, release, or project milestone, call
|
|
21
|
-
`save_conversation`. This private checkpoint does not require a separate user request.
|
|
22
|
-
|
|
23
|
-
|
|
21
|
+
`save_conversation`. 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.
|
|
24
29
|
- After `save_conversation` succeeds and returns one or more saved memory IDs, make the save visible
|
|
25
30
|
in the final user-facing answer with a compact `EchoMem saved:` list containing every memory
|
|
26
31
|
created by that call. Link each memory key to its canonical
|