@memoraone/mcp 0.1.42 → 0.1.43

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/daemon.cjs CHANGED
@@ -170,11 +170,11 @@ function ensureBaseDir() {
170
170
 
171
171
  // src/projectBinding.ts
172
172
  var fs7 = __toESM(require("fs/promises"), 1);
173
- var path9 = __toESM(require("path"), 1);
173
+ var path10 = __toESM(require("path"), 1);
174
174
 
175
175
  // src/localState/resolveLocalBinding.ts
176
176
  var fs6 = __toESM(require("fs/promises"), 1);
177
- var path8 = __toESM(require("path"), 1);
177
+ var path9 = __toESM(require("path"), 1);
178
178
 
179
179
  // src/localState/bindingStore.ts
180
180
  var fs4 = __toESM(require("fs/promises"), 1);
@@ -416,7 +416,7 @@ async function acquireLocalLock(lockName, options = {}) {
416
416
  `[memoraone-mcp] Failed to acquire lock ${lockName} after ${maxRetries} retries`
417
417
  );
418
418
  }
419
- await new Promise((resolve9) => setTimeout(resolve9, retryDelayMs));
419
+ await new Promise((resolve10) => setTimeout(resolve10, retryDelayMs));
420
420
  continue;
421
421
  }
422
422
  throw err;
@@ -868,6 +868,9 @@ function identityMatchesStored(stored, current) {
868
868
  return identitiesMatch(stored, current);
869
869
  }
870
870
 
871
+ // src/localState/localConnectClient.ts
872
+ var path8 = __toESM(require("path"), 1);
873
+
871
874
  // src/client/memoraClient.ts
872
875
  var crypto2 = __toESM(require("crypto"), 1);
873
876
  var PROJECT_ID_HEADER = "x-project-id";
@@ -977,9 +980,9 @@ var MemoraClient = class {
977
980
  ...options?.headers ?? {}
978
981
  };
979
982
  }
980
- async perform(method, path14, body, options, retried = false) {
983
+ async perform(method, path15, body, options, retried = false) {
981
984
  const nonce = crypto2.randomBytes(8).toString("hex");
982
- const url = `${this.baseUrl}${path14.startsWith("/") ? path14 : `/${path14}`}`;
985
+ const url = `${this.baseUrl}${path15.startsWith("/") ? path15 : `/${path15}`}`;
983
986
  this.resolveProjectId();
984
987
  console.error(
985
988
  `[memoraone-mcp][info] requestJson nonce=${nonce} stage=before_fetch method=${method} url=${url}`
@@ -1003,10 +1006,10 @@ var MemoraClient = class {
1003
1006
  if (accepted) {
1004
1007
  return res.text ? JSON.parse(res.text) : null;
1005
1008
  }
1006
- if ((res.status === 401 || res.status === 403) && !options?.skipAuthRefresh && !retried) {
1009
+ if (res.status === 401 && !options?.skipAuthRefresh && !retried) {
1007
1010
  try {
1008
1011
  await this.refreshAccessToken();
1009
- return this.perform(method, path14, body, options, true);
1012
+ return this.perform(method, path15, body, options, true);
1010
1013
  } catch (err) {
1011
1014
  if (err instanceof ReconnectRequiredError) {
1012
1015
  await this.markReconnectRequired();
@@ -1014,9 +1017,6 @@ var MemoraClient = class {
1014
1017
  throw err;
1015
1018
  }
1016
1019
  }
1017
- if (res.status === 401 || res.status === 403) {
1018
- await this.markReconnectRequired();
1019
- }
1020
1020
  const quiet = options?.quietHttpStatuses?.includes(res.status);
1021
1021
  if (!quiet) {
1022
1022
  const snippet = res.text.length > 200 ? `${res.text.slice(0, 200)}...` : res.text;
@@ -1029,22 +1029,22 @@ var MemoraClient = class {
1029
1029
  }
1030
1030
  return res.text ? JSON.parse(res.text) : null;
1031
1031
  }
1032
- async post(path14, body, options) {
1033
- console.error(`[memoraone-mcp][info] MemoraClient.post ENTER path=${path14}`);
1034
- const result = await this.perform("POST", path14, body, options);
1035
- console.error(`[memoraone-mcp][info] MemoraClient.post EXIT path=${path14}`);
1032
+ async post(path15, body, options) {
1033
+ console.error(`[memoraone-mcp][info] MemoraClient.post ENTER path=${path15}`);
1034
+ const result = await this.perform("POST", path15, body, options);
1035
+ console.error(`[memoraone-mcp][info] MemoraClient.post EXIT path=${path15}`);
1036
1036
  return result;
1037
1037
  }
1038
- async get(path14, options) {
1039
- return this.perform("GET", path14, void 0, options);
1038
+ async get(path15, options) {
1039
+ return this.perform("GET", path15, void 0, options);
1040
1040
  }
1041
1041
  };
1042
1042
  var memoraClient_default = MemoraClient;
1043
1043
 
1044
1044
  // src/localState/localConnectClient.ts
1045
- async function requestJson2(baseUrl, method, path14, options = {}) {
1045
+ async function requestJson2(baseUrl, method, path15, options = {}) {
1046
1046
  const fetchImpl = options.fetchImpl ?? fetch;
1047
- const url = `${baseUrl.replace(/\/+$/, "")}${path14.startsWith("/") ? path14 : `/${path14}`}`;
1047
+ const url = `${baseUrl.replace(/\/+$/, "")}${path15.startsWith("/") ? path15 : `/${path15}`}`;
1048
1048
  const res = await fetchImpl(url, {
1049
1049
  method,
1050
1050
  headers: {
@@ -1150,7 +1150,7 @@ async function refreshInstallationAccessToken(options) {
1150
1150
 
1151
1151
  // src/localState/resolveLocalBinding.ts
1152
1152
  async function detectLegacyM1Warning(workspaceRoot) {
1153
- const candidate = path8.join(path8.resolve(workspaceRoot), CANONICAL_M1_FILENAME);
1153
+ const candidate = path9.join(path9.resolve(workspaceRoot), CANONICAL_M1_FILENAME);
1154
1154
  try {
1155
1155
  await fs6.access(candidate);
1156
1156
  return candidate;
@@ -1159,7 +1159,7 @@ async function detectLegacyM1Warning(workspaceRoot) {
1159
1159
  }
1160
1160
  }
1161
1161
  async function ensureRepositoryBindingForRoot(workspaceRoot, options = {}) {
1162
- const resolved = path8.resolve(workspaceRoot);
1162
+ const resolved = path9.resolve(workspaceRoot);
1163
1163
  const identity = await captureRootFilesystemIdentity(resolved, options.identityDeps);
1164
1164
  const legacyM1WarningPath = await detectLegacyM1Warning(resolved);
1165
1165
  const index = await loadPathIndex(options.homeDir);
@@ -1167,7 +1167,7 @@ async function ensureRepositoryBindingForRoot(workspaceRoot, options = {}) {
1167
1167
  if (lookup.kind === "path") {
1168
1168
  const record = await readBindingRecord(lookup.repositoryBindingId, options.homeDir);
1169
1169
  if (record && identityMatchesStored(record.filesystemIdentity, identity)) {
1170
- if (path8.resolve(record.workspaceRoot) !== resolved) {
1170
+ if (path9.resolve(record.workspaceRoot) !== resolved) {
1171
1171
  const updated = {
1172
1172
  ...record,
1173
1173
  workspaceRoot: resolved,
@@ -1229,7 +1229,7 @@ async function ensureRepositoryBindingForRoot(workspaceRoot, options = {}) {
1229
1229
  };
1230
1230
  }
1231
1231
  async function resolveLocalBinding(workspaceRoot, options = {}) {
1232
- const resolved = path8.resolve(workspaceRoot);
1232
+ const resolved = path9.resolve(workspaceRoot);
1233
1233
  const { repositoryBindingId, legacyM1WarningPath } = await ensureRepositoryBindingForRoot(
1234
1234
  resolved,
1235
1235
  { ...options, createIfMissing: false }
@@ -1301,7 +1301,7 @@ function toResolvedBinding(local) {
1301
1301
  };
1302
1302
  }
1303
1303
  async function warnLegacyM1IfPresent(workspaceRoot) {
1304
- const candidate = path9.join(path9.resolve(workspaceRoot), CANONICAL_M1_FILENAME);
1304
+ const candidate = path10.join(path10.resolve(workspaceRoot), CANONICAL_M1_FILENAME);
1305
1305
  try {
1306
1306
  await fs7.access(candidate);
1307
1307
  process.stderr.write(
@@ -1360,7 +1360,7 @@ function normalizeWorkspaceSearchRoots(workspaceRoot) {
1360
1360
  if (raw === void 0) continue;
1361
1361
  const trimmed = String(raw).trim();
1362
1362
  if (trimmed === "") continue;
1363
- const resolved = path9.resolve(trimmed);
1363
+ const resolved = path10.resolve(trimmed);
1364
1364
  if (!seen.has(resolved)) {
1365
1365
  seen.add(resolved);
1366
1366
  out.push(resolved);
@@ -1371,7 +1371,7 @@ function normalizeWorkspaceSearchRoots(workspaceRoot) {
1371
1371
  function bindingRelevantValuesMatch(a, b) {
1372
1372
  const envA = a.environment ?? void 0;
1373
1373
  const envB = b.environment ?? void 0;
1374
- return a.repositoryBindingId === b.repositoryBindingId && a.projectId.trim().toLowerCase() === b.projectId.trim().toLowerCase() && path9.resolve(a.workspaceRoot) === path9.resolve(b.workspaceRoot) && (a.installationPublicId ?? void 0) === (b.installationPublicId ?? void 0) && envA === envB && a.status === b.status;
1374
+ return a.repositoryBindingId === b.repositoryBindingId && a.projectId.trim().toLowerCase() === b.projectId.trim().toLowerCase() && path10.resolve(a.workspaceRoot) === path10.resolve(b.workspaceRoot) && (a.installationPublicId ?? void 0) === (b.installationPublicId ?? void 0) && envA === envB && a.status === b.status;
1375
1375
  }
1376
1376
  async function reconcileResolvedBindingWithDisk(cached, options = {}) {
1377
1377
  const repositoryBindingId = assertRepositoryBindingId(cached.repositoryBindingId);
@@ -1381,7 +1381,7 @@ async function reconcileResolvedBindingWithDisk(cached, options = {}) {
1381
1381
  `[memoraone-mcp] Cached binding missing for ${repositoryBindingId}. Run: memoraone-mcp connect <code>`
1382
1382
  );
1383
1383
  }
1384
- const workspaceRoot = path9.resolve(record.workspaceRoot);
1384
+ const workspaceRoot = path10.resolve(record.workspaceRoot);
1385
1385
  const identity = await captureRootFilesystemIdentity(workspaceRoot);
1386
1386
  if (!identitiesMatch(record.filesystemIdentity, identity)) {
1387
1387
  throw new ReconnectRequiredError(
@@ -1482,7 +1482,7 @@ function decodeResolvedBinding(value) {
1482
1482
 
1483
1483
  // src/bindingSidecar.ts
1484
1484
  var fs8 = __toESM(require("fs"), 1);
1485
- var path10 = __toESM(require("path"), 1);
1485
+ var path11 = __toESM(require("path"), 1);
1486
1486
  function bindingSidecarPath(socketPath) {
1487
1487
  if (socketPath.endsWith(".sock")) {
1488
1488
  return `${socketPath.slice(0, -".sock".length)}.binding.json`;
@@ -1523,7 +1523,7 @@ var import_stdio = require("@modelcontextprotocol/sdk/server/stdio.js");
1523
1523
  // src/config.ts
1524
1524
  var process2 = __toESM(require("process"), 1);
1525
1525
  var fs9 = __toESM(require("fs"), 1);
1526
- var path11 = __toESM(require("path"), 1);
1526
+ var path12 = __toESM(require("path"), 1);
1527
1527
  var dotenv = __toESM(require("dotenv"), 1);
1528
1528
  var import_v4 = require("zod/v4");
1529
1529
 
@@ -1546,7 +1546,7 @@ function resolveApiUrl(env2) {
1546
1546
  }
1547
1547
 
1548
1548
  // src/config.ts
1549
- var dotenvPath = path11.resolve(process2.cwd(), ".env");
1549
+ var dotenvPath = path12.resolve(process2.cwd(), ".env");
1550
1550
  if (fs9.existsSync(dotenvPath)) {
1551
1551
  try {
1552
1552
  dotenv.config({ path: dotenvPath });
@@ -1616,7 +1616,7 @@ var config2 = {
1616
1616
  };
1617
1617
 
1618
1618
  // src/initializeBinding.ts
1619
- var path12 = __toESM(require("path"), 1);
1619
+ var path13 = __toESM(require("path"), 1);
1620
1620
  var import_node_url = require("url");
1621
1621
  var MEMORAONE_WORKSPACE_ROOT_ENV = "MEMORAONE_WORKSPACE_ROOT";
1622
1622
  function getBridgeBindingResolveOptions(env2 = process.env) {
@@ -1636,8 +1636,8 @@ function getEnvWorkspaceRootCandidates() {
1636
1636
  const raw = process.env.WORKSPACE_FOLDER_PATHS;
1637
1637
  const parts = [];
1638
1638
  if (raw !== void 0 && raw.trim() !== "") {
1639
- for (const p of raw.split(path12.delimiter).map((s) => s.trim()).filter(Boolean)) {
1640
- parts.push(path12.resolve(p));
1639
+ for (const p of raw.split(path13.delimiter).map((s) => s.trim()).filter(Boolean)) {
1640
+ parts.push(path13.resolve(p));
1641
1641
  }
1642
1642
  }
1643
1643
  parts.push(process.cwd());
@@ -1661,7 +1661,7 @@ function extractWorkspaceRootsFromInitialize(params) {
1661
1661
  if (uri === void 0 || uri.trim() === "") {
1662
1662
  return;
1663
1663
  }
1664
- const resolved = path12.resolve(uriToPath(uri));
1664
+ const resolved = path13.resolve(uriToPath(uri));
1665
1665
  if (!seen.has(resolved)) {
1666
1666
  seen.add(resolved);
1667
1667
  roots.push(resolved);
@@ -1683,7 +1683,7 @@ function getRepoScopedWorkspaceHint(env2 = process.env) {
1683
1683
  if (raw === void 0 || raw.trim() === "") {
1684
1684
  return null;
1685
1685
  }
1686
- return path12.resolve(raw.trim());
1686
+ return path13.resolve(raw.trim());
1687
1687
  }
1688
1688
  function formatWorkspaceAmbiguityError(bindings) {
1689
1689
  const lines = bindings.map(
@@ -1766,8 +1766,8 @@ async function resolveBindingFromInitializeParams(params, options = {}) {
1766
1766
  const rootsListUris = options.rootsListUris ?? [];
1767
1767
  const rootsListPaths = rootsListUris.map((uri) => uriToPath(uri)).filter(Boolean);
1768
1768
  if (rootsListPaths.length > 1 && repoHint !== null) {
1769
- const hintResolved = path12.resolve(repoHint);
1770
- const matchingRoot = rootsListPaths.find((root) => path12.resolve(root) === hintResolved);
1769
+ const hintResolved = path13.resolve(repoHint);
1770
+ const matchingRoot = rootsListPaths.find((root) => path13.resolve(root) === hintResolved);
1771
1771
  if (!matchingRoot) {
1772
1772
  throw new Error(formatRepoHintNotInRootsListError(repoHint, rootsListPaths));
1773
1773
  }
@@ -2227,9 +2227,9 @@ function buildPersonalContextPath(parsed2) {
2227
2227
  }
2228
2228
  async function handleGetPersonalContext(client, args) {
2229
2229
  const parsed2 = getPersonalContextInputSchema.parse(args ?? {});
2230
- const path14 = buildPersonalContextPath(parsed2);
2230
+ const path15 = buildPersonalContextPath(parsed2);
2231
2231
  try {
2232
- const result = await client.get(path14);
2232
+ const result = await client.get(path15);
2233
2233
  return { ok: true, result };
2234
2234
  } catch (err) {
2235
2235
  if (err instanceof MemoraOneHttpError) {
@@ -2701,8 +2701,8 @@ async function handleCreateConceptVersion(client, args) {
2701
2701
  if (input.tags !== void 0) body.tags = input.tags;
2702
2702
  if (input.parent_id !== void 0) body.parent_id = input.parent_id;
2703
2703
  try {
2704
- const path14 = `/concepts/${encodeURIComponent(input.id)}/versions`;
2705
- return projectCreatedConceptVersionResponse(await client.post(path14, body));
2704
+ const path15 = `/concepts/${encodeURIComponent(input.id)}/versions`;
2705
+ return projectCreatedConceptVersionResponse(await client.post(path15, body));
2706
2706
  } catch (error) {
2707
2707
  rethrowToolRequestError("memora_create_concept_version", error);
2708
2708
  }
@@ -2737,7 +2737,7 @@ function handleBindingStatus(binding, options = {}) {
2737
2737
  // src/heartbeat.ts
2738
2738
  var crypto5 = __toESM(require("crypto"), 1);
2739
2739
  var fs10 = __toESM(require("fs"), 1);
2740
- var path13 = __toESM(require("path"), 1);
2740
+ var path14 = __toESM(require("path"), 1);
2741
2741
 
2742
2742
  // src/localState/mcpSessionId.ts
2743
2743
  var import_node_crypto4 = require("crypto");
@@ -2770,9 +2770,9 @@ function resolvePackageVersion() {
2770
2770
  if (fromEnv) return fromEnv;
2771
2771
  const moduleDir = typeof __dirname !== "undefined" ? __dirname : void 0;
2772
2772
  const candidates = [
2773
- ...moduleDir ? [path13.join(moduleDir, "..", "package.json"), path13.join(moduleDir, "package.json")] : [],
2774
- path13.join(process.cwd(), "package.json"),
2775
- path13.join(process.cwd(), "packages", "mcp", "package.json")
2773
+ ...moduleDir ? [path14.join(moduleDir, "..", "package.json"), path14.join(moduleDir, "package.json")] : [],
2774
+ path14.join(process.cwd(), "package.json"),
2775
+ path14.join(process.cwd(), "packages", "mcp", "package.json")
2776
2776
  ];
2777
2777
  for (const candidate of candidates) {
2778
2778
  try {
@@ -2848,19 +2848,6 @@ async function sendProjectHeartbeat(client, ctx) {
2848
2848
  const raw = await client.post("/v1/local-mcp/heartbeat", body, { log: false });
2849
2849
  return { active: parseActiveFlag(raw) };
2850
2850
  } catch (err) {
2851
- if (err instanceof ReconnectRequiredError) {
2852
- try {
2853
- const record = await readBindingRecord(ctx.repositoryBindingId);
2854
- if (record) {
2855
- await writeBindingRecord({
2856
- ...record,
2857
- status: "reconnect_required",
2858
- updatedAt: (/* @__PURE__ */ new Date()).toISOString()
2859
- });
2860
- }
2861
- } catch {
2862
- }
2863
- }
2864
2851
  process.stderr.write(
2865
2852
  `[memoraone-mcp][info] heartbeat error (silent) ${redactSensitiveText(String(err))}
2866
2853
  `
@@ -3304,8 +3291,8 @@ function registerToolWithWorklog(server, runtime, sessionContext, toolName, desc
3304
3291
  async function main(opts = {}) {
3305
3292
  let bindingReadyResolve = null;
3306
3293
  let bindingReadyReject = null;
3307
- const bindingReady = new Promise((resolve9, reject) => {
3308
- bindingReadyResolve = resolve9;
3294
+ const bindingReady = new Promise((resolve10, reject) => {
3295
+ bindingReadyResolve = resolve10;
3309
3296
  bindingReadyReject = reject;
3310
3297
  });
3311
3298
  const devMode = Boolean(config2.devMode);
@@ -3778,10 +3765,10 @@ async function main(opts = {}) {
3778
3765
  console.error("[memoraone-mcp] MCP server ready");
3779
3766
  }
3780
3767
  if (opts.sessionSocket) {
3781
- await new Promise((resolve9) => {
3768
+ await new Promise((resolve10) => {
3782
3769
  opts.sessionSocket.once("close", () => {
3783
3770
  shutdown("session closed", false);
3784
- resolve9();
3771
+ resolve10();
3785
3772
  });
3786
3773
  });
3787
3774
  }
@@ -3825,7 +3812,7 @@ async function ensureSocketClean(socketPath) {
3825
3812
  } catch {
3826
3813
  return;
3827
3814
  }
3828
- return new Promise((resolve9) => {
3815
+ return new Promise((resolve10) => {
3829
3816
  const client = net.createConnection({ path: socketPath }, () => {
3830
3817
  client.destroy();
3831
3818
  log("daemon already running, exiting");
@@ -3837,7 +3824,7 @@ async function ensureSocketClean(socketPath) {
3837
3824
  log("stale socket removed");
3838
3825
  } catch {
3839
3826
  }
3840
- resolve9();
3827
+ resolve10();
3841
3828
  });
3842
3829
  });
3843
3830
  }
@@ -3928,14 +3915,14 @@ async function runDaemon() {
3928
3915
  process.on("SIGINT", () => shutdownNow("SIGINT"));
3929
3916
  process.on("SIGTERM", () => shutdownNow("SIGTERM"));
3930
3917
  process.on("exit", cleanupSocketFile);
3931
- return new Promise((resolve9) => {
3918
+ return new Promise((resolve10) => {
3932
3919
  server.listen(socketPath, () => {
3933
3920
  writeBindingSidecar(socketPath, binding, ideType ?? "");
3934
3921
  log(`daemon started, listening on ${socketPath}`);
3935
3922
  void daemonHeartbeat.start().catch((err) => {
3936
3923
  log(`daemon heartbeat start error: ${String(err)}`);
3937
3924
  });
3938
- resolve9();
3925
+ resolve10();
3939
3926
  });
3940
3927
  });
3941
3928
  }