claude-memory-layer 2.5.0 → 2.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.
@@ -1823,7 +1823,7 @@ function emptyLatencyAggregate() {
1823
1823
  return { count: 0, failedCount: 0, totalMs: 0, maxMs: 0 };
1824
1824
  }
1825
1825
  function runtimeVersion() {
1826
- const value = "2.5.0"?.trim();
1826
+ const value = "2.5.1"?.trim();
1827
1827
  return sanitizeRuntimeVersion(value || "development");
1828
1828
  }
1829
1829
  function sanitizeRuntimeVersion(value) {
@@ -206,7 +206,7 @@ function emptyLatencyAggregate() {
206
206
  return { count: 0, failedCount: 0, totalMs: 0, maxMs: 0 };
207
207
  }
208
208
  function runtimeVersion() {
209
- const value = "2.5.0"?.trim();
209
+ const value = "2.5.1"?.trim();
210
210
  return sanitizeRuntimeVersion(value || "development");
211
211
  }
212
212
  function sanitizeRuntimeVersion(value) {
@@ -21936,7 +21936,7 @@ async function main(options = {}) {
21936
21936
  triggerType: "session_start",
21937
21937
  deliveryClient,
21938
21938
  requestId: `${requestPrefix}:core`,
21939
- runtimeVersion: "2.5.0",
21939
+ runtimeVersion: "2.5.1",
21940
21940
  outcomeDiagnostics: {
21941
21941
  outcomeReason: "selected",
21942
21942
  laneCandidateCounts: {},
@@ -21997,7 +21997,7 @@ async function main(options = {}) {
21997
21997
  triggerType: "session_start",
21998
21998
  deliveryClient,
21999
21999
  requestId: `${requestPrefix}:lessons`,
22000
- runtimeVersion: "2.5.0",
22000
+ runtimeVersion: "2.5.1",
22001
22001
  outcomeDiagnostics: {
22002
22002
  outcomeReason: shownIds.length > 0 ? "selected" : "unknown",
22003
22003
  laneCandidateCounts: {},
@@ -22087,7 +22087,7 @@ You have worked on this project before. Here are some relevant memories:
22087
22087
  triggerType: "session_start",
22088
22088
  deliveryClient,
22089
22089
  requestId: `${requestPrefix}:recent`,
22090
- runtimeVersion: "2.5.0",
22090
+ runtimeVersion: "2.5.1",
22091
22091
  outcomeDiagnostics: {
22092
22092
  outcomeReason: "selected",
22093
22093
  laneCandidateCounts: {},
@@ -206,7 +206,7 @@ function emptyLatencyAggregate() {
206
206
  return { count: 0, failedCount: 0, totalMs: 0, maxMs: 0 };
207
207
  }
208
208
  function runtimeVersion() {
209
- const value = "2.5.0"?.trim();
209
+ const value = "2.5.1"?.trim();
210
210
  return sanitizeRuntimeVersion(value || "development");
211
211
  }
212
212
  function sanitizeRuntimeVersion(value) {
@@ -22671,7 +22671,7 @@ async function main(options = {}) {
22671
22671
  triggerType: "user_prompt",
22672
22672
  deliveryClient,
22673
22673
  requestId: retrievalRequestId,
22674
- runtimeVersion: "2.5.0",
22674
+ runtimeVersion: "2.5.1",
22675
22675
  outcomeDiagnostics
22676
22676
  });
22677
22677
  } catch {
@@ -254,7 +254,7 @@ function emptyLatencyAggregate() {
254
254
  return { count: 0, failedCount: 0, totalMs: 0, maxMs: 0 };
255
255
  }
256
256
  function runtimeVersion() {
257
- const value = "2.5.0"?.trim();
257
+ const value = "2.5.1"?.trim();
258
258
  return sanitizeRuntimeVersion(value || "development");
259
259
  }
260
260
  function sanitizeRuntimeVersion(value) {
@@ -260,7 +260,7 @@ function emptyLatencyAggregate() {
260
260
  return { count: 0, failedCount: 0, totalMs: 0, maxMs: 0 };
261
261
  }
262
262
  function runtimeVersion() {
263
- const value = "2.5.0"?.trim();
263
+ const value = "2.5.1"?.trim();
264
264
  return sanitizeRuntimeVersion(value || "development");
265
265
  }
266
266
  function sanitizeRuntimeVersion(value) {
@@ -253,7 +253,7 @@ function emptyLatencyAggregate() {
253
253
  return { count: 0, failedCount: 0, totalMs: 0, maxMs: 0 };
254
254
  }
255
255
  function runtimeVersion() {
256
- const value = "2.5.0"?.trim();
256
+ const value = "2.5.1"?.trim();
257
257
  return sanitizeRuntimeVersion(value || "development");
258
258
  }
259
259
  function sanitizeRuntimeVersion(value) {
@@ -447,7 +447,7 @@ function emptyLatencyAggregate() {
447
447
  return { count: 0, failedCount: 0, totalMs: 0, maxMs: 0 };
448
448
  }
449
449
  function runtimeVersion() {
450
- const value = "2.5.0"?.trim();
450
+ const value = "2.5.1"?.trim();
451
451
  return sanitizeRuntimeVersion(value || "development");
452
452
  }
453
453
  function sanitizeRuntimeVersion(value) {
@@ -258,7 +258,7 @@ function emptyLatencyAggregate() {
258
258
  return { count: 0, failedCount: 0, totalMs: 0, maxMs: 0 };
259
259
  }
260
260
  function runtimeVersion() {
261
- const value = "2.5.0"?.trim();
261
+ const value = "2.5.1"?.trim();
262
262
  return sanitizeRuntimeVersion(value || "development");
263
263
  }
264
264
  function sanitizeRuntimeVersion(value) {
@@ -20872,7 +20872,7 @@ async function main(options = {}) {
20872
20872
  triggerType: "session_start",
20873
20873
  deliveryClient,
20874
20874
  requestId: `${requestPrefix}:core`,
20875
- runtimeVersion: "2.5.0",
20875
+ runtimeVersion: "2.5.1",
20876
20876
  outcomeDiagnostics: {
20877
20877
  outcomeReason: "selected",
20878
20878
  laneCandidateCounts: {},
@@ -20933,7 +20933,7 @@ async function main(options = {}) {
20933
20933
  triggerType: "session_start",
20934
20934
  deliveryClient,
20935
20935
  requestId: `${requestPrefix}:lessons`,
20936
- runtimeVersion: "2.5.0",
20936
+ runtimeVersion: "2.5.1",
20937
20937
  outcomeDiagnostics: {
20938
20938
  outcomeReason: shownIds.length > 0 ? "selected" : "unknown",
20939
20939
  laneCandidateCounts: {},
@@ -21023,7 +21023,7 @@ You have worked on this project before. Here are some relevant memories:
21023
21023
  triggerType: "session_start",
21024
21024
  deliveryClient,
21025
21025
  requestId: `${requestPrefix}:recent`,
21026
- runtimeVersion: "2.5.0",
21026
+ runtimeVersion: "2.5.1",
21027
21027
  outcomeDiagnostics: {
21028
21028
  outcomeReason: "selected",
21029
21029
  laneCandidateCounts: {},
@@ -254,7 +254,7 @@ function emptyLatencyAggregate() {
254
254
  return { count: 0, failedCount: 0, totalMs: 0, maxMs: 0 };
255
255
  }
256
256
  function runtimeVersion() {
257
- const value = "2.5.0"?.trim();
257
+ const value = "2.5.1"?.trim();
258
258
  return sanitizeRuntimeVersion(value || "development");
259
259
  }
260
260
  function sanitizeRuntimeVersion(value) {
@@ -260,7 +260,7 @@ function emptyLatencyAggregate() {
260
260
  return { count: 0, failedCount: 0, totalMs: 0, maxMs: 0 };
261
261
  }
262
262
  function runtimeVersion() {
263
- const value = "2.5.0"?.trim();
263
+ const value = "2.5.1"?.trim();
264
264
  return sanitizeRuntimeVersion(value || "development");
265
265
  }
266
266
  function sanitizeRuntimeVersion(value) {
@@ -21605,7 +21605,7 @@ async function main(options = {}) {
21605
21605
  triggerType: "user_prompt",
21606
21606
  deliveryClient,
21607
21607
  requestId: retrievalRequestId,
21608
- runtimeVersion: "2.5.0",
21608
+ runtimeVersion: "2.5.1",
21609
21609
  outcomeDiagnostics
21610
21610
  });
21611
21611
  } catch {
package/dist/index.js CHANGED
@@ -4684,7 +4684,7 @@ function emptyLatencyAggregate() {
4684
4684
  return { count: 0, failedCount: 0, totalMs: 0, maxMs: 0 };
4685
4685
  }
4686
4686
  function runtimeVersion() {
4687
- const value = "2.5.0"?.trim();
4687
+ const value = "2.5.1"?.trim();
4688
4688
  return sanitizeRuntimeVersion(value || "development");
4689
4689
  }
4690
4690
  function sanitizeRuntimeVersion(value) {
@@ -25588,20 +25588,77 @@ var SyncWorker = class {
25588
25588
 
25589
25589
  // src/core/mongo-sync-worker.ts
25590
25590
  import { randomUUID as randomUUID27 } from "crypto";
25591
- import * as os8 from "os";
25591
+ import * as os9 from "os";
25592
25592
  import { MongoClient } from "mongodb";
25593
+
25594
+ // src/core/mongo-sync-config.ts
25595
+ import * as dns from "dns";
25596
+ import * as os8 from "os";
25597
+ var UNPARSEABLE_URI = "<unparseable MongoDB connection string>";
25598
+ function splitMongoUri(uri) {
25599
+ const match = /^([a-z][a-z0-9+.-]*:\/\/)(.*)$/is.exec(uri);
25600
+ if (!match) return null;
25601
+ const [, scheme, rest] = match;
25602
+ const authorityEnd = rest.search(/[/?]/);
25603
+ const authority = authorityEnd === -1 ? rest : rest.slice(0, authorityEnd);
25604
+ const remainder = authorityEnd === -1 ? "" : rest.slice(authorityEnd);
25605
+ if (remainder.includes("@") || authority.indexOf("@") !== authority.lastIndexOf("@")) return null;
25606
+ const atIdx = authority.indexOf("@");
25607
+ const creds = atIdx === -1 ? null : authority.slice(0, atIdx);
25608
+ const hosts = authority.slice(atIdx + 1);
25609
+ if (!hosts) return null;
25610
+ const colonIdx = creds?.indexOf(":") ?? -1;
25611
+ const queryIdx = remainder.indexOf("?");
25612
+ return {
25613
+ scheme,
25614
+ username: creds === null ? null : colonIdx === -1 ? creds : creds.slice(0, colonIdx),
25615
+ password: creds === null || colonIdx === -1 ? null : creds.slice(colonIdx + 1),
25616
+ hosts,
25617
+ path: queryIdx === -1 ? remainder : remainder.slice(0, queryIdx),
25618
+ query: queryIdx === -1 ? null : remainder.slice(queryIdx + 1)
25619
+ };
25620
+ }
25593
25621
  function redactMongoUri(uri) {
25594
- const schemeIdx = uri.indexOf("://");
25595
- if (schemeIdx === -1) return uri;
25596
- const atIdx = uri.indexOf("@", schemeIdx + 3);
25597
- if (atIdx === -1) return uri;
25598
- const creds = uri.slice(schemeIdx + 3, atIdx);
25599
- const colonIdx = creds.indexOf(":");
25600
- if (colonIdx === -1) return uri;
25601
- const prefix = uri.slice(0, schemeIdx + 3 + colonIdx + 1);
25602
- const suffix = uri.slice(atIdx);
25603
- return `${prefix}***${suffix}`;
25622
+ const parts = splitMongoUri(uri);
25623
+ if (!parts) return UNPARSEABLE_URI;
25624
+ const creds = parts.username === null ? "" : parts.password === null ? `${parts.username}@` : `${parts.username}:***@`;
25625
+ const query = parts.query === null ? "" : "?***";
25626
+ return `${parts.scheme}${creds}${parts.hosts}${parts.path}${query}`;
25627
+ }
25628
+ var PARSE_ERROR_NAMES = /* @__PURE__ */ new Set([
25629
+ "MongoParseError",
25630
+ "MongoInvalidArgumentError",
25631
+ "MongoAPIError",
25632
+ "MongoRuntimeError",
25633
+ "MongoMissingCredentialsError",
25634
+ "TypeError",
25635
+ "URIError"
25636
+ ]);
25637
+ var PARSE_HINT = "connection string could not be parsed; percent-encode special characters in the password and check option names";
25638
+ var ERRNO_CODES = /* @__PURE__ */ new Set([
25639
+ ...Object.keys(os8.constants.errno),
25640
+ ...Object.values(dns).filter((value) => typeof value === "string" && /^E[A-Z_]+$/.test(value)),
25641
+ "EAI_AGAIN"
25642
+ ]);
25643
+ function describeMongoConnectionError(error, uri) {
25644
+ const name = error instanceof Error ? error.name : "Error";
25645
+ if (!splitMongoUri(uri) || PARSE_ERROR_NAMES.has(name)) return `${name}: ${PARSE_HINT}`;
25646
+ const facts = connectionErrorFacts(error);
25647
+ return facts.length > 0 ? `${name} (${facts.join(", ")})` : name;
25648
+ }
25649
+ function connectionErrorFacts(error) {
25650
+ const facts = /* @__PURE__ */ new Set();
25651
+ let current = error;
25652
+ for (let depth = 0; depth < 5 && current instanceof Error; depth++) {
25653
+ const { code, codeName } = current;
25654
+ if (typeof code === "string" && ERRNO_CODES.has(code)) facts.add(code);
25655
+ if (typeof codeName === "string" && /^[A-Za-z]+$/.test(codeName)) facts.add(codeName);
25656
+ current = current.cause;
25657
+ }
25658
+ return [...facts];
25604
25659
  }
25660
+
25661
+ // src/core/mongo-sync-worker.ts
25605
25662
  function isRecord8(value) {
25606
25663
  return typeof value === "object" && value !== null && !Array.isArray(value);
25607
25664
  }
@@ -25734,7 +25791,8 @@ var MongoSyncWorker = class {
25734
25791
  this.events = this.db.collection("cml_events");
25735
25792
  } catch (err) {
25736
25793
  const safeUri = redactMongoUri(this.config.uri);
25737
- throw new Error(`MongoDB connection failed (${safeUri}, db=${this.config.dbName}): ${String(err)}`);
25794
+ const reason = describeMongoConnectionError(err, this.config.uri);
25795
+ throw new Error(`MongoDB connection failed (${safeUri}, db=${this.config.dbName}): ${reason}`);
25738
25796
  }
25739
25797
  }
25740
25798
  async disconnect() {
@@ -25795,7 +25853,7 @@ var MongoSyncWorker = class {
25795
25853
  if (batch.length === 0) break;
25796
25854
  const startSeq = await this.allocateSeqRange("events", batch.length);
25797
25855
  const now = /* @__PURE__ */ new Date();
25798
- const hostname2 = os8.hostname();
25856
+ const hostname2 = os9.hostname();
25799
25857
  const ops = batch.map((item, idx) => {
25800
25858
  const event = item.event;
25801
25859
  const seq = startSeq + idx;
@@ -29307,11 +29365,11 @@ function redactSecrets(input) {
29307
29365
  }
29308
29366
 
29309
29367
  // src/services/memory-service.ts
29310
- import * as os13 from "os";
29368
+ import * as os14 from "os";
29311
29369
 
29312
29370
  // src/core/registry/existing-store.ts
29313
29371
  import * as fs14 from "node:fs";
29314
- import * as os9 from "node:os";
29372
+ import * as os10 from "node:os";
29315
29373
  import * as path16 from "node:path";
29316
29374
  var PROJECT_HASH_PATTERN = /^[a-f0-9]{8}$/;
29317
29375
  var SQLITE_HEADER = Buffer.from("SQLite format 3\0", "utf8");
@@ -29331,7 +29389,7 @@ function resolveExistingStore(projectOrHash, options = {}) {
29331
29389
  return probe;
29332
29390
  }
29333
29391
  function locateExistingStore(projectOrHash, options) {
29334
- const homeDir = options.homeDir ?? os9.homedir();
29392
+ const homeDir = options.homeDir ?? os10.homedir();
29335
29393
  const memoryRoot = path16.join(homeDir, ".claude-code", "memory");
29336
29394
  const parsed = parseStoreInput(projectOrHash);
29337
29395
  if (parsed.status === "invalid") return { candidate: false, resolution: parsed };
@@ -29485,7 +29543,7 @@ var MemoryStoreResolutionError = class extends Error {
29485
29543
  };
29486
29544
 
29487
29545
  // src/core/engine/memory-service-composition.ts
29488
- import * as os10 from "os";
29546
+ import * as os11 from "os";
29489
29547
  import * as path17 from "path";
29490
29548
 
29491
29549
  // src/core/metadata-extractor.ts
@@ -29618,15 +29676,15 @@ function createMemoryServiceComposition(options) {
29618
29676
  }
29619
29677
  function defaultExpandPath(targetPath) {
29620
29678
  if (targetPath.startsWith("~")) {
29621
- return path17.join(os10.homedir(), targetPath.slice(1));
29679
+ return path17.join(os11.homedir(), targetPath.slice(1));
29622
29680
  }
29623
29681
  return targetPath;
29624
29682
  }
29625
29683
 
29626
29684
  // src/services/memory-service-config.ts
29627
- import * as os11 from "os";
29685
+ import * as os12 from "os";
29628
29686
  import * as path18 from "path";
29629
- var SHARED_STORAGE_PATH = path18.join(os11.homedir(), ".claude-code", "memory", "shared");
29687
+ var SHARED_STORAGE_PATH = path18.join(os12.homedir(), ".claude-code", "memory", "shared");
29630
29688
  var DISABLED_SHARED_STORE_CONFIG = {
29631
29689
  enabled: false,
29632
29690
  autoPromote: false,
@@ -29797,12 +29855,12 @@ function createMemoryServiceRegistry(deps) {
29797
29855
 
29798
29856
  // src/services/operations-config-loader.ts
29799
29857
  import * as fs15 from "fs";
29800
- import * as os12 from "os";
29858
+ import * as os13 from "os";
29801
29859
  import * as path20 from "path";
29802
29860
  function resolveOperationsConfigPath() {
29803
29861
  const override = process.env.CLAUDE_MEMORY_OPERATIONS_CONFIG_PATH;
29804
29862
  if (override && override.trim().length > 0) return override.trim();
29805
- return path20.join(os12.homedir(), ".claude-code", "memory", "operations.json");
29863
+ return path20.join(os13.homedir(), ".claude-code", "memory", "operations.json");
29806
29864
  }
29807
29865
  var cached = null;
29808
29866
  function loadMemoryOperationsConfig() {
@@ -30434,7 +30492,7 @@ var defaultRegistry = createMemoryServiceRegistry({
30434
30492
  hashProjectPath,
30435
30493
  getProjectStoragePath,
30436
30494
  getSessionProject,
30437
- homedir: os13.homedir,
30495
+ homedir: os14.homedir,
30438
30496
  disabledSharedStoreConfig: DISABLED_SHARED_STORE_CONFIG
30439
30497
  });
30440
30498
  var getDefaultMemoryService = defaultRegistry.getDefaultMemoryService;
@@ -30500,7 +30558,7 @@ async function shutdownMemoryServices(reason = "process-shutdown") {
30500
30558
  // src/services/codex-session-history-importer.ts
30501
30559
  import * as fs16 from "fs";
30502
30560
  import * as path21 from "path";
30503
- import * as os14 from "os";
30561
+ import * as os15 from "os";
30504
30562
  import * as readline from "readline";
30505
30563
  import { createHash as createHash14, randomUUID as randomUUID31 } from "crypto";
30506
30564
 
@@ -30558,7 +30616,7 @@ function extractTextFromContent(content) {
30558
30616
  return extractCodexContentText(content).text;
30559
30617
  }
30560
30618
  function getDefaultCodexSessionsDir() {
30561
- return path21.join(os14.homedir(), ".codex", "sessions");
30619
+ return path21.join(os15.homedir(), ".codex", "sessions");
30562
30620
  }
30563
30621
  function listCodexSessionFilesRecursive(rootDir) {
30564
30622
  if (!fs16.existsSync(rootDir)) return [];
@@ -30893,7 +30951,7 @@ var CodexSessionHistoryImporter = class {
30893
30951
  sessionsRoot;
30894
30952
  constructor(memoryService, options = {}) {
30895
30953
  this.memoryService = memoryService;
30896
- this.sessionsRoot = options.sessionsDir ? path21.resolve(options.sessionsDir) : path21.join(os14.homedir(), ".codex", "sessions");
30954
+ this.sessionsRoot = options.sessionsDir ? path21.resolve(options.sessionsDir) : path21.join(os15.homedir(), ".codex", "sessions");
30897
30955
  }
30898
30956
  getSessionsRoot() {
30899
30957
  return this.sessionsRoot;