@echomem/mcp 1.4.53 → 1.4.55
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 +3 -1
- package/dist/index.js +26 -10
- package/dist/setup-page/client-core.js +4 -0
- package/dist/setup-page/client-extraction.js +30 -5
- package/dist/setup-page/styles-mvp.js +19 -0
- package/dist/source-session-hook.js +95 -2
- package/dist/source-session.js +23 -0
- package/dist/v1-contract.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -139,13 +139,15 @@ Cloud Cowork inference cannot use the local hook or transcript-verification path
|
|
|
139
139
|
MCP process also must not retain one cloud conversation as global bridge state. Cloud Cowork agents
|
|
140
140
|
therefore pass their runtime-issued `session_...` identifier as `cloudCoworkSessionId` on each
|
|
141
141
|
EchoMem tool call. EchoMem binds that request to the canonical `cowork:session_...` context with
|
|
142
|
-
`cloud_cowork_tool_argument` evidence and `
|
|
142
|
+
`cloud_cowork_tool_argument` evidence and `local_mcp` origin, then links or saves against that
|
|
143
143
|
context without changing shared bridge state.
|
|
144
144
|
|
|
145
145
|
This identity is intentionally reported as **provisional**: the authenticated user owns the
|
|
146
146
|
context and ticket link, but EchoMem cannot independently corroborate the cloud identifier from a
|
|
147
147
|
local transcript. Verified local Cowork remains `cowork:local_...` with trusted local evidence.
|
|
148
148
|
Never convert one form into the other or silently present a provisional cloud link as verified.
|
|
149
|
+
`remote-devices` is a relay into the installed local MCP process; it is not EchoMem's hosted
|
|
150
|
+
Streamable HTTP MCP endpoint. Transport origin and session-identity evidence are independent.
|
|
149
151
|
|
|
150
152
|
### Manual / headless (SSH, containers, CI)
|
|
151
153
|
|
package/dist/index.js
CHANGED
|
@@ -737,15 +737,28 @@ class EchoMemApiClient {
|
|
|
737
737
|
const response = await this.axios.post("/api/extension/source-sessions/bind", {
|
|
738
738
|
provider: identity.provider,
|
|
739
739
|
providerSessionId: identity.providerSessionId,
|
|
740
|
+
providerSessionAliases: identity.providerSessionAliases,
|
|
740
741
|
evidence: identity.evidence,
|
|
741
|
-
});
|
|
742
|
+
}, { headers: { "X-EchoMem-Origin-Channel": "local_mcp" } });
|
|
742
743
|
const contextId = readString(response.data, "contextId");
|
|
743
744
|
const canonicalKey = readString(response.data, "canonicalKey");
|
|
744
|
-
|
|
745
|
+
const provider = readString(response.data, "provider");
|
|
746
|
+
const providerSessionId = readString(response.data, "providerSessionId");
|
|
747
|
+
if (response.data?.success !== true
|
|
748
|
+
|| !contextId
|
|
749
|
+
|| provider !== identity.provider
|
|
750
|
+
|| !providerSessionId
|
|
751
|
+
|| canonicalKey !== `${provider}:${providerSessionId}`) {
|
|
745
752
|
throw new Error("EchoMem returned an invalid source-session binding receipt");
|
|
746
753
|
}
|
|
747
|
-
const bound = {
|
|
754
|
+
const bound = {
|
|
755
|
+
...identity,
|
|
756
|
+
providerSessionId,
|
|
757
|
+
canonicalKey,
|
|
758
|
+
contextId,
|
|
759
|
+
};
|
|
748
760
|
this.sourceSessionsByCanonicalKey.set(identity.canonicalKey, bound);
|
|
761
|
+
this.sourceSessionsByCanonicalKey.set(canonicalKey, bound);
|
|
749
762
|
if (this.sourceSessionsByCanonicalKey.size > 64) {
|
|
750
763
|
const oldestKey = this.sourceSessionsByCanonicalKey.keys().next().value;
|
|
751
764
|
if (oldestKey)
|
|
@@ -1045,13 +1058,13 @@ class EchoMemApiClient {
|
|
|
1045
1058
|
// so it encrypts at rest (mirrors the extension's write path, spec §3.1a). Locked → LockedError.
|
|
1046
1059
|
const enc = await this.encState();
|
|
1047
1060
|
const boundSourceSession = this.getBoundSourceSession();
|
|
1048
|
-
const originChannel = boundSourceSession?.evidence === SOURCE_SESSION_CLOUD_TOOL_ARGUMENT_EVIDENCE
|
|
1049
|
-
? "remote_mcp"
|
|
1050
|
-
: "local_mcp";
|
|
1051
1061
|
const config = {
|
|
1052
1062
|
headers: {
|
|
1053
1063
|
"X-EchoMem-Request-Id": randomUUID(),
|
|
1054
|
-
|
|
1064
|
+
// This package is the installed local MCP bridge. A Cloud Cowork
|
|
1065
|
+
// session can reach it through remote-devices, but its provisional
|
|
1066
|
+
// identity evidence does not change the bridge's transport channel.
|
|
1067
|
+
"X-EchoMem-Origin-Channel": "local_mcp",
|
|
1055
1068
|
...(enc.enabled && enc.key ? { "X-Encryption-Key": enc.key } : {}),
|
|
1056
1069
|
},
|
|
1057
1070
|
};
|
|
@@ -1062,7 +1075,7 @@ class EchoMemApiClient {
|
|
|
1062
1075
|
source: parsed.source || "mcp_server",
|
|
1063
1076
|
title: parsed.title,
|
|
1064
1077
|
// A source-session identity owns the memory context. Provisional Cloud Cowork identity
|
|
1065
|
-
// is explicitly marked by its evidence
|
|
1078
|
+
// is explicitly marked by its evidence. The independent opaque scope still
|
|
1066
1079
|
// governs group-sharing consent and never becomes the source-session identity.
|
|
1067
1080
|
conversationKey: boundSourceSession?.canonicalKey ?? groupSharingScopeId,
|
|
1068
1081
|
groupSharingScopeId,
|
|
@@ -2068,8 +2081,11 @@ Details: ${m.details || "N/A"}`)
|
|
|
2068
2081
|
content: [{
|
|
2069
2082
|
type: "text",
|
|
2070
2083
|
text: [
|
|
2071
|
-
|
|
2072
|
-
"
|
|
2084
|
+
"Status: accepted_for_desktop_recovery",
|
|
2085
|
+
"Final: false",
|
|
2086
|
+
`Ticket ${parsed.ticketId} was accepted for verified source-session discovery.`,
|
|
2087
|
+
"This is not a failed link. Echo Desktop can finish it asynchronously from the structured ticket marker or this exact local tool invocation.",
|
|
2088
|
+
"The agent cannot verify final completion from this shared MCP request; use the ticket Activity as the current final-state evidence.",
|
|
2073
2089
|
"Do not guess a context ID or call bind_source_session on the user's behalf unless its documented compatibility fallback is actually needed.",
|
|
2074
2090
|
].join("\n"),
|
|
2075
2091
|
}],
|
|
@@ -53,11 +53,15 @@ export const SETUP_PAGE_CLIENT_CORE = String.raw ` var params = new URLSear
|
|
|
53
53
|
var accountStateEpoch = 0;
|
|
54
54
|
var statsPollStarted = false;
|
|
55
55
|
var readyStage = "";
|
|
56
|
+
// Apply the automatic Free fallback only once per connected-account lifecycle. After the
|
|
57
|
+
// user deliberately reopens plan selection, background billing refreshes must not close it.
|
|
58
|
+
var freePlanFallbackApplied = false;
|
|
56
59
|
|
|
57
60
|
try {
|
|
58
61
|
var storedSetupPlanChoice = sessionStorage.getItem("echomem:setup-plan:" + nonce) || "";
|
|
59
62
|
if (storedSetupPlanChoice === "free" || storedSetupPlanChoice === "pro" || storedSetupPlanChoice === "power") {
|
|
60
63
|
setupPlanChoice = storedSetupPlanChoice;
|
|
64
|
+
freePlanFallbackApplied = true;
|
|
61
65
|
}
|
|
62
66
|
var storedCheckoutSessionId = sessionStorage.getItem("echomem:checkout-session:" + nonce) || "";
|
|
63
67
|
if (/^cs_(?:test_|live_)?[A-Za-z0-9_]+$/.test(storedCheckoutSessionId)) {
|
|
@@ -99,9 +99,12 @@ export const SETUP_PAGE_CLIENT_EXTRACTION = String.raw ` /* ---------- dash
|
|
|
99
99
|
'<section class="planGateDecision">' +
|
|
100
100
|
'<div class="setupPlanSlot" id="setupPlan"></div>' +
|
|
101
101
|
'<aside class="planGateAccount" aria-label="Connected account"><div class="setupAccountSlot" id="setupAccount"></div></aside>' +
|
|
102
|
-
'</section>'
|
|
102
|
+
'</section>' +
|
|
103
|
+
'<div class="planGateSkip"><button type="button" class="textButton skipHistoryButton" id="skipPlanSelection">Continue without importing</button><p>You can import your local history later.</p></div>';
|
|
103
104
|
renderSetupPlan(true);
|
|
104
105
|
renderAccountChoice();
|
|
106
|
+
var skipPlan = document.getElementById("skipPlanSelection");
|
|
107
|
+
if (skipPlan) skipPlan.onclick = skip;
|
|
105
108
|
}
|
|
106
109
|
function renderDashboard(error) {
|
|
107
110
|
setExtractMode(false);
|
|
@@ -128,7 +131,7 @@ export const SETUP_PAGE_CLIENT_EXTRACTION = String.raw ` /* ---------- dash
|
|
|
128
131
|
var pendingCodex = typeof migratable.pendingCodex === "number" ? migratable.pendingCodex : null;
|
|
129
132
|
var pendingClaudeCode = typeof migratable.pendingClaudeCode === "number" ? migratable.pendingClaudeCode : null;
|
|
130
133
|
var pendingCowork = typeof migratable.pendingCowork === "number" ? migratable.pendingCowork : null;
|
|
131
|
-
if (connected && !
|
|
134
|
+
if (connected && !setupPlanConfirmed()) {
|
|
132
135
|
renderPlanGate();
|
|
133
136
|
return;
|
|
134
137
|
}
|
|
@@ -191,12 +194,14 @@ export const SETUP_PAGE_CLIENT_EXTRACTION = String.raw ` /* ---------- dash
|
|
|
191
194
|
'<div class="readyGo">' +
|
|
192
195
|
'<div class="actions">' +
|
|
193
196
|
'<button id="migrate" class="primary"></button>' +
|
|
197
|
+
'<button type="button" id="skipImport" class="skipHistoryButton">Continue without importing</button>' +
|
|
194
198
|
'</div>' +
|
|
195
199
|
'<p class="ctaMeta" id="exEta"></p>' +
|
|
196
200
|
'</div>' +
|
|
197
201
|
'</section>' +
|
|
198
202
|
'<dialog class="sessionPicker" id="sessionPicker" aria-labelledby="sessionPickerTitle"></dialog>';
|
|
199
203
|
document.getElementById("migrate").onclick = openSessionPicker;
|
|
204
|
+
document.getElementById("skipImport").onclick = skip;
|
|
200
205
|
dashMounted = true;
|
|
201
206
|
}
|
|
202
207
|
document.getElementById("exBanner").innerHTML =
|
|
@@ -239,6 +244,8 @@ export const SETUP_PAGE_CLIENT_EXTRACTION = String.raw ` /* ---------- dash
|
|
|
239
244
|
// While still counting, hide the primary button entirely; the headline + source split
|
|
240
245
|
// already say it is working, and the ready state should present one clear action.
|
|
241
246
|
var migrateBtn = document.getElementById("migrate");
|
|
247
|
+
var skipImportBtn = document.getElementById("skipImport");
|
|
248
|
+
if (skipImportBtn) skipImportBtn.style.display = canExtract ? "" : "none";
|
|
242
249
|
if (pendingTrusted || degradedWithoutCounts) {
|
|
243
250
|
migrateBtn.style.display = "";
|
|
244
251
|
var candidatesReady = !canExtract || candidateSessions().length > 0;
|
|
@@ -968,6 +975,7 @@ export const SETUP_PAGE_CLIENT_EXTRACTION = String.raw ` /* ---------- dash
|
|
|
968
975
|
billingStatus = null;
|
|
969
976
|
billingStatusLoading = false;
|
|
970
977
|
connected = false;
|
|
978
|
+
freePlanFallbackApplied = false;
|
|
971
979
|
rememberSetupPlanChoice("");
|
|
972
980
|
selectedSessionKeys = Object.create(null);
|
|
973
981
|
sessionSelectionTouched = false;
|
|
@@ -1098,6 +1106,16 @@ export const SETUP_PAGE_CLIENT_EXTRACTION = String.raw ` /* ---------- dash
|
|
|
1098
1106
|
function setupPlanConfirmed() {
|
|
1099
1107
|
return setupPlanChoice === "free" || paidRecallPlan(billingStatus && billingStatus.plan);
|
|
1100
1108
|
}
|
|
1109
|
+
function paidCheckoutPending() {
|
|
1110
|
+
return paidRecallPlan(billingActivationPendingPlan) ||
|
|
1111
|
+
(!!pendingCheckoutSessionId && paidRecallPlan(setupPlanChoice));
|
|
1112
|
+
}
|
|
1113
|
+
function applyFreePlanFallback() {
|
|
1114
|
+
if (freePlanFallbackApplied || setupPlanConfirmed() || paidCheckoutPending()) return false;
|
|
1115
|
+
freePlanFallbackApplied = true;
|
|
1116
|
+
rememberSetupPlanChoice("free");
|
|
1117
|
+
return true;
|
|
1118
|
+
}
|
|
1101
1119
|
function setupPlanDefinition(plan) {
|
|
1102
1120
|
var trialAvailable = !billingStatus || billingStatus.trialAvailable !== false;
|
|
1103
1121
|
var limits = quotaLimitsForPlan(plan);
|
|
@@ -1197,16 +1215,19 @@ export const SETUP_PAGE_CLIENT_EXTRACTION = String.raw ` /* ---------- dash
|
|
|
1197
1215
|
});
|
|
1198
1216
|
var free = document.getElementById("chooseFreePlan");
|
|
1199
1217
|
if (free) free.onclick = function () {
|
|
1218
|
+
freePlanFallbackApplied = true;
|
|
1200
1219
|
rememberSetupPlanChoice("free");
|
|
1201
1220
|
renderDashboard();
|
|
1202
1221
|
};
|
|
1203
1222
|
var pro = document.getElementById("chooseProPlan");
|
|
1204
1223
|
if (pro) pro.onclick = function () {
|
|
1224
|
+
freePlanFallbackApplied = true;
|
|
1205
1225
|
rememberSetupPlanChoice("pro");
|
|
1206
1226
|
openPaidPricing("pro");
|
|
1207
1227
|
};
|
|
1208
1228
|
var power = document.getElementById("choosePowerPlan");
|
|
1209
1229
|
if (power) power.onclick = function () {
|
|
1230
|
+
freePlanFallbackApplied = true;
|
|
1210
1231
|
rememberSetupPlanChoice("power");
|
|
1211
1232
|
openPaidPricing("power");
|
|
1212
1233
|
};
|
|
@@ -1372,13 +1393,15 @@ export const SETUP_PAGE_CLIENT_EXTRACTION = String.raw ` /* ---------- dash
|
|
|
1372
1393
|
var nextBillingStatus = await getJson("/billing-status");
|
|
1373
1394
|
if (billingEpoch !== accountStateEpoch || !connected) return;
|
|
1374
1395
|
billingStatus = nextBillingStatus;
|
|
1396
|
+
if (!paidRecallPlan(billingStatus && billingStatus.plan)) applyFreePlanFallback();
|
|
1375
1397
|
await refreshPlanQuotaCatalog();
|
|
1376
1398
|
billingLastCheckedAt = Date.now();
|
|
1377
1399
|
billingCheckMessage = "";
|
|
1378
|
-
if (
|
|
1400
|
+
if (stats && setupPlanConfirmed()) {
|
|
1379
1401
|
// Keep the visible promise in sync with the authoritative plan/quota response.
|
|
1380
|
-
//
|
|
1381
|
-
//
|
|
1402
|
+
// This also replaces the plan gate after the initial billing lookup. If the dashboard
|
|
1403
|
+
// is already mounted, renderDashboard patches it in place; an open picker is refreshed
|
|
1404
|
+
// after an upgrade so its quota and action stay authoritative.
|
|
1382
1405
|
renderDashboard();
|
|
1383
1406
|
var openPicker = document.getElementById("sessionPicker");
|
|
1384
1407
|
if (openPicker && openPicker.open) renderSessionPicker();
|
|
@@ -1392,6 +1415,8 @@ export const SETUP_PAGE_CLIENT_EXTRACTION = String.raw ` /* ---------- dash
|
|
|
1392
1415
|
if (billingEpoch !== accountStateEpoch || !connected) return;
|
|
1393
1416
|
billingLastCheckedAt = Date.now();
|
|
1394
1417
|
billingCheckMessage = "Could not check payment yet. Echo will keep trying automatically.";
|
|
1418
|
+
var fellBackToFree = applyFreePlanFallback();
|
|
1419
|
+
if (fellBackToFree && stats) renderDashboard();
|
|
1395
1420
|
setSetupPlanStatus("Plan check unavailable. Original still works.");
|
|
1396
1421
|
} finally {
|
|
1397
1422
|
if (billingEpoch === accountStateEpoch) billingStatusLoading = false;
|
|
@@ -570,6 +570,25 @@ export const SETUP_PAGE_STYLES_MVP = String.raw `
|
|
|
570
570
|
font-size: 11px;
|
|
571
571
|
font-weight: 700;
|
|
572
572
|
}
|
|
573
|
+
.planGateSkip {
|
|
574
|
+
display: grid;
|
|
575
|
+
justify-items: center;
|
|
576
|
+
gap: 2px;
|
|
577
|
+
margin-top: 14px;
|
|
578
|
+
text-align: center;
|
|
579
|
+
}
|
|
580
|
+
.planGateSkip .skipHistoryButton {
|
|
581
|
+
min-height: 36px;
|
|
582
|
+
border: 0;
|
|
583
|
+
background: transparent;
|
|
584
|
+
color: var(--echo-ink-mute);
|
|
585
|
+
box-shadow: none;
|
|
586
|
+
}
|
|
587
|
+
.planGateSkip p {
|
|
588
|
+
margin: 0;
|
|
589
|
+
color: var(--echo-ink-faint);
|
|
590
|
+
font-size: 11px;
|
|
591
|
+
}
|
|
573
592
|
.mvpPricing {
|
|
574
593
|
width: 100%;
|
|
575
594
|
}
|
|
@@ -2,9 +2,12 @@ import fs from "node:fs";
|
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
import axios from "axios";
|
|
4
4
|
import { KeyStore } from "./keystore.js";
|
|
5
|
-
import { SOURCE_SESSION_HOOK_EVIDENCE, verifiedSourceSession, } from "./source-session.js";
|
|
5
|
+
import { SOURCE_SESSION_HOOK_EVIDENCE, verifiedClaudeDesktopSession, verifiedSourceSession, } from "./source-session.js";
|
|
6
6
|
const API_BASE = (process.env.ECHO_API_BASE_URL || "https://echo-mem-chrome.vercel.app").replace(/\/$/, "");
|
|
7
7
|
const MAX_HEAD_BYTES = 256 * 1024;
|
|
8
|
+
const MAX_CLAUDE_DESKTOP_INDEX_FILES = 2_000;
|
|
9
|
+
const UUID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
10
|
+
const CLAUDE_DESKTOP_ID_RE = /^local_[A-Za-z0-9_-]{1,194}$/;
|
|
8
11
|
function isRecord(value) {
|
|
9
12
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
10
13
|
}
|
|
@@ -43,6 +46,88 @@ function codexSessionFromTranscript(file) {
|
|
|
43
46
|
function coworkSessionFromPath(file) {
|
|
44
47
|
return file.split(path.sep).find((part) => /^local_[A-Za-z0-9_-]{1,194}$/.test(part)) ?? null;
|
|
45
48
|
}
|
|
49
|
+
function claudeDesktopSessionsRoot() {
|
|
50
|
+
const support = process.env.CLAUDE_DESKTOP_SUPPORT_DIR?.trim()
|
|
51
|
+
|| path.join(process.env.HOME || "", "Library", "Application Support", "Claude");
|
|
52
|
+
return path.join(support, "claude-code-sessions");
|
|
53
|
+
}
|
|
54
|
+
function readClaudeDesktopClaim(file) {
|
|
55
|
+
try {
|
|
56
|
+
const stat = fs.statSync(file);
|
|
57
|
+
if (!stat.isFile() || stat.size > MAX_HEAD_BYTES)
|
|
58
|
+
return null;
|
|
59
|
+
const row = JSON.parse(fs.readFileSync(file, "utf8"));
|
|
60
|
+
if (!isRecord(row) || row.isArchived === true)
|
|
61
|
+
return null;
|
|
62
|
+
const desktopSessionId = typeof row.sessionId === "string" ? row.sessionId.trim() : "";
|
|
63
|
+
const currentCliSessionId = typeof row.cliSessionId === "string"
|
|
64
|
+
? row.cliSessionId.trim().toLowerCase()
|
|
65
|
+
: "";
|
|
66
|
+
if (!CLAUDE_DESKTOP_ID_RE.test(desktopSessionId) || !UUID_RE.test(currentCliSessionId)) {
|
|
67
|
+
return null;
|
|
68
|
+
}
|
|
69
|
+
const prior = Array.isArray(row.priorCliSessionIds)
|
|
70
|
+
? row.priorCliSessionIds
|
|
71
|
+
.filter((value) => typeof value === "string")
|
|
72
|
+
.map((value) => value.trim().toLowerCase())
|
|
73
|
+
.filter((value) => UUID_RE.test(value))
|
|
74
|
+
: [];
|
|
75
|
+
const focusedAt = typeof row.lastFocusedAt === "number"
|
|
76
|
+
? row.lastFocusedAt
|
|
77
|
+
: typeof row.lastActivityAt === "number"
|
|
78
|
+
? row.lastActivityAt
|
|
79
|
+
: typeof row.createdAt === "number"
|
|
80
|
+
? row.createdAt
|
|
81
|
+
: 0;
|
|
82
|
+
return {
|
|
83
|
+
desktopSessionId,
|
|
84
|
+
cliSessionIds: [...new Set([currentCliSessionId, ...prior])].slice(0, 32),
|
|
85
|
+
selfNamed: desktopSessionId === `local_${currentCliSessionId}`,
|
|
86
|
+
focusedAt,
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
catch {
|
|
90
|
+
return null;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
function claudeDesktopSessionForCliId(cliSessionId) {
|
|
94
|
+
const root = claudeDesktopSessionsRoot();
|
|
95
|
+
const pending = [root];
|
|
96
|
+
let inspected = 0;
|
|
97
|
+
let best = null;
|
|
98
|
+
while (pending.length > 0 && inspected < MAX_CLAUDE_DESKTOP_INDEX_FILES) {
|
|
99
|
+
const directory = pending.pop();
|
|
100
|
+
if (!directory)
|
|
101
|
+
break;
|
|
102
|
+
let entries;
|
|
103
|
+
try {
|
|
104
|
+
entries = fs.readdirSync(directory, { withFileTypes: true });
|
|
105
|
+
}
|
|
106
|
+
catch {
|
|
107
|
+
continue;
|
|
108
|
+
}
|
|
109
|
+
for (const entry of entries) {
|
|
110
|
+
const item = path.join(directory, entry.name);
|
|
111
|
+
if (entry.isDirectory()) {
|
|
112
|
+
pending.push(item);
|
|
113
|
+
continue;
|
|
114
|
+
}
|
|
115
|
+
if (!entry.isFile() || !entry.name.startsWith("local_") || !entry.name.endsWith(".json")) {
|
|
116
|
+
continue;
|
|
117
|
+
}
|
|
118
|
+
inspected += 1;
|
|
119
|
+
const claim = readClaudeDesktopClaim(item);
|
|
120
|
+
if (!claim || !claim.cliSessionIds.includes(cliSessionId))
|
|
121
|
+
continue;
|
|
122
|
+
if (!best
|
|
123
|
+
|| (best.selfNamed && !claim.selfNamed)
|
|
124
|
+
|| (best.selfNamed === claim.selfNamed && claim.focusedAt > best.focusedAt)) {
|
|
125
|
+
best = claim;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
return best ? verifiedClaudeDesktopSession(best.desktopSessionId, best.cliSessionIds) : null;
|
|
130
|
+
}
|
|
46
131
|
export function resolveSourceSessionFromHookPayload(payload) {
|
|
47
132
|
const requestedSessionId = typeof payload.session_id === "string" ? payload.session_id.trim() : "";
|
|
48
133
|
const transcriptPath = typeof payload.transcript_path === "string" ? payload.transcript_path.trim() : "";
|
|
@@ -71,6 +156,9 @@ export function resolveSourceSessionFromHookPayload(payload) {
|
|
|
71
156
|
const filenameSession = path.basename(file, path.extname(file));
|
|
72
157
|
if (filenameSession !== requestedSessionId)
|
|
73
158
|
return null;
|
|
159
|
+
const desktopSession = claudeDesktopSessionForCliId(filenameSession.toLowerCase());
|
|
160
|
+
if (desktopSession)
|
|
161
|
+
return desktopSession;
|
|
74
162
|
return verifiedSourceSession("claude-code", filenameSession, SOURCE_SESSION_HOOK_EVIDENCE);
|
|
75
163
|
}
|
|
76
164
|
async function bindSourceSession(identity) {
|
|
@@ -80,9 +168,14 @@ async function bindSourceSession(identity) {
|
|
|
80
168
|
await axios.post(`${API_BASE}/api/extension/source-sessions/bind`, {
|
|
81
169
|
provider: identity.provider,
|
|
82
170
|
providerSessionId: identity.providerSessionId,
|
|
171
|
+
providerSessionAliases: identity.providerSessionAliases,
|
|
83
172
|
evidence: identity.evidence,
|
|
84
173
|
}, {
|
|
85
|
-
headers: {
|
|
174
|
+
headers: {
|
|
175
|
+
Authorization: `Bearer ${token}`,
|
|
176
|
+
"Content-Type": "application/json",
|
|
177
|
+
"X-EchoMem-Origin-Channel": "local_mcp",
|
|
178
|
+
},
|
|
86
179
|
timeout: 3_500,
|
|
87
180
|
});
|
|
88
181
|
}
|
package/dist/source-session.js
CHANGED
|
@@ -5,6 +5,7 @@ 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";
|
|
7
7
|
export const SOURCE_SESSION_CLOUD_TOOL_ARGUMENT_EVIDENCE = "cloud_cowork_tool_argument";
|
|
8
|
+
export const SOURCE_SESSION_DESKTOP_INDEX_EVIDENCE = "echo_desktop_conversation_index";
|
|
8
9
|
const UUID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
9
10
|
const UUID_IN_TEXT_RE = /[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/i;
|
|
10
11
|
const MAX_TAIL_BYTES = 512 * 1024;
|
|
@@ -40,6 +41,28 @@ export function verifiedSourceSession(provider, providerSessionId, evidence) {
|
|
|
40
41
|
evidence,
|
|
41
42
|
};
|
|
42
43
|
}
|
|
44
|
+
export function verifiedClaudeDesktopSession(providerSessionId, providerSessionAliases) {
|
|
45
|
+
const normalized = normalizedProviderSessionId("claude-code", providerSessionId);
|
|
46
|
+
if (!/^local_[A-Za-z0-9_-]{1,194}$/.test(normalized)) {
|
|
47
|
+
throw new Error("Claude Desktop source-session ID must use its durable local_ conversation identifier");
|
|
48
|
+
}
|
|
49
|
+
if (providerSessionAliases.length === 0 || providerSessionAliases.length > 32) {
|
|
50
|
+
throw new Error("Claude Desktop source-session identity requires 1-32 CLI session aliases");
|
|
51
|
+
}
|
|
52
|
+
const aliases = [...new Set(providerSessionAliases.map((value) => {
|
|
53
|
+
const alias = normalizedProviderSessionId("claude-code", value);
|
|
54
|
+
if (!UUID_RE.test(alias))
|
|
55
|
+
throw new Error("Claude Desktop CLI session aliases must be UUIDs");
|
|
56
|
+
return alias;
|
|
57
|
+
}))];
|
|
58
|
+
return {
|
|
59
|
+
provider: "claude-code",
|
|
60
|
+
providerSessionId: normalized,
|
|
61
|
+
providerSessionAliases: aliases,
|
|
62
|
+
canonicalKey: `claude-code:${normalized}`,
|
|
63
|
+
evidence: SOURCE_SESSION_DESKTOP_INDEX_EVIDENCE,
|
|
64
|
+
};
|
|
65
|
+
}
|
|
43
66
|
export function provisionalCloudCoworkSession(providerSessionId) {
|
|
44
67
|
const normalized = normalizedProviderSessionId("cowork", providerSessionId);
|
|
45
68
|
if (!normalized.startsWith("session_")) {
|
package/dist/v1-contract.js
CHANGED
|
@@ -503,7 +503,7 @@ export function listToolSpecs(opts = {}) {
|
|
|
503
503
|
{
|
|
504
504
|
name: canonicalToolNames.linkWorkspaceTicketSession,
|
|
505
505
|
title: "Link this agent conversation to an Echo workspace ticket",
|
|
506
|
-
description: withMcpVersion("Call when the user asks to work on, continue, attach, or bind this conversation to an Echo workspace ticket and supplies its UUID. Pass the ticketId exactly; pass workspaceId when a structured Echo ticket marker provides it. The operation is idempotent. A verified local source session links immediately. Cloud Cowork has no local transcript, so pass its current session_ runtime identifier as cloudCoworkSessionId; EchoMem records that path explicitly as provisional and links it immediately. Otherwise Echo Desktop can recover this exact invocation from a local transcript. Never guess or ask the user for a source-session/context ID."),
|
|
506
|
+
description: withMcpVersion("Call when the user asks to work on, continue, attach, or bind this conversation to an Echo workspace ticket and supplies its UUID. Pass the ticketId exactly; pass workspaceId when a structured Echo ticket marker provides it. The operation is idempotent. A verified local source session links immediately. Cloud Cowork has no local transcript, so pass its current session_ runtime identifier as cloudCoworkSessionId; EchoMem records that path explicitly as provisional and links it immediately. Otherwise Echo Desktop can recover this exact invocation from a local transcript. An accepted_for_desktop_recovery response is asynchronous acceptance, not a failed link; do not claim final success or failure until ticket Activity provides final-state evidence. Never guess or ask the user for a source-session/context ID."),
|
|
507
507
|
inputSchema: {
|
|
508
508
|
type: "object",
|
|
509
509
|
properties: {
|