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.
@@ -4481,7 +4481,7 @@ function emptyLatencyAggregate() {
4481
4481
  return { count: 0, failedCount: 0, totalMs: 0, maxMs: 0 };
4482
4482
  }
4483
4483
  function runtimeVersion() {
4484
- const value = "2.5.0"?.trim();
4484
+ const value = "2.5.1"?.trim();
4485
4485
  return sanitizeRuntimeVersion(value || "development");
4486
4486
  }
4487
4487
  function sanitizeRuntimeVersion(value) {
@@ -25385,20 +25385,77 @@ var SyncWorker = class {
25385
25385
 
25386
25386
  // src/core/mongo-sync-worker.ts
25387
25387
  import { randomUUID as randomUUID27 } from "crypto";
25388
- import * as os8 from "os";
25388
+ import * as os9 from "os";
25389
25389
  import { MongoClient } from "mongodb";
25390
+
25391
+ // src/core/mongo-sync-config.ts
25392
+ import * as dns from "dns";
25393
+ import * as os8 from "os";
25394
+ var UNPARSEABLE_URI = "<unparseable MongoDB connection string>";
25395
+ function splitMongoUri(uri) {
25396
+ const match = /^([a-z][a-z0-9+.-]*:\/\/)(.*)$/is.exec(uri);
25397
+ if (!match) return null;
25398
+ const [, scheme, rest] = match;
25399
+ const authorityEnd = rest.search(/[/?]/);
25400
+ const authority = authorityEnd === -1 ? rest : rest.slice(0, authorityEnd);
25401
+ const remainder = authorityEnd === -1 ? "" : rest.slice(authorityEnd);
25402
+ if (remainder.includes("@") || authority.indexOf("@") !== authority.lastIndexOf("@")) return null;
25403
+ const atIdx = authority.indexOf("@");
25404
+ const creds = atIdx === -1 ? null : authority.slice(0, atIdx);
25405
+ const hosts = authority.slice(atIdx + 1);
25406
+ if (!hosts) return null;
25407
+ const colonIdx = creds?.indexOf(":") ?? -1;
25408
+ const queryIdx = remainder.indexOf("?");
25409
+ return {
25410
+ scheme,
25411
+ username: creds === null ? null : colonIdx === -1 ? creds : creds.slice(0, colonIdx),
25412
+ password: creds === null || colonIdx === -1 ? null : creds.slice(colonIdx + 1),
25413
+ hosts,
25414
+ path: queryIdx === -1 ? remainder : remainder.slice(0, queryIdx),
25415
+ query: queryIdx === -1 ? null : remainder.slice(queryIdx + 1)
25416
+ };
25417
+ }
25390
25418
  function redactMongoUri(uri) {
25391
- const schemeIdx = uri.indexOf("://");
25392
- if (schemeIdx === -1) return uri;
25393
- const atIdx = uri.indexOf("@", schemeIdx + 3);
25394
- if (atIdx === -1) return uri;
25395
- const creds = uri.slice(schemeIdx + 3, atIdx);
25396
- const colonIdx = creds.indexOf(":");
25397
- if (colonIdx === -1) return uri;
25398
- const prefix = uri.slice(0, schemeIdx + 3 + colonIdx + 1);
25399
- const suffix = uri.slice(atIdx);
25400
- return `${prefix}***${suffix}`;
25419
+ const parts = splitMongoUri(uri);
25420
+ if (!parts) return UNPARSEABLE_URI;
25421
+ const creds = parts.username === null ? "" : parts.password === null ? `${parts.username}@` : `${parts.username}:***@`;
25422
+ const query = parts.query === null ? "" : "?***";
25423
+ return `${parts.scheme}${creds}${parts.hosts}${parts.path}${query}`;
25424
+ }
25425
+ var PARSE_ERROR_NAMES = /* @__PURE__ */ new Set([
25426
+ "MongoParseError",
25427
+ "MongoInvalidArgumentError",
25428
+ "MongoAPIError",
25429
+ "MongoRuntimeError",
25430
+ "MongoMissingCredentialsError",
25431
+ "TypeError",
25432
+ "URIError"
25433
+ ]);
25434
+ var PARSE_HINT = "connection string could not be parsed; percent-encode special characters in the password and check option names";
25435
+ var ERRNO_CODES = /* @__PURE__ */ new Set([
25436
+ ...Object.keys(os8.constants.errno),
25437
+ ...Object.values(dns).filter((value) => typeof value === "string" && /^E[A-Z_]+$/.test(value)),
25438
+ "EAI_AGAIN"
25439
+ ]);
25440
+ function describeMongoConnectionError(error, uri) {
25441
+ const name = error instanceof Error ? error.name : "Error";
25442
+ if (!splitMongoUri(uri) || PARSE_ERROR_NAMES.has(name)) return `${name}: ${PARSE_HINT}`;
25443
+ const facts = connectionErrorFacts(error);
25444
+ return facts.length > 0 ? `${name} (${facts.join(", ")})` : name;
25445
+ }
25446
+ function connectionErrorFacts(error) {
25447
+ const facts = /* @__PURE__ */ new Set();
25448
+ let current = error;
25449
+ for (let depth = 0; depth < 5 && current instanceof Error; depth++) {
25450
+ const { code, codeName } = current;
25451
+ if (typeof code === "string" && ERRNO_CODES.has(code)) facts.add(code);
25452
+ if (typeof codeName === "string" && /^[A-Za-z]+$/.test(codeName)) facts.add(codeName);
25453
+ current = current.cause;
25454
+ }
25455
+ return [...facts];
25401
25456
  }
25457
+
25458
+ // src/core/mongo-sync-worker.ts
25402
25459
  function isRecord8(value) {
25403
25460
  return typeof value === "object" && value !== null && !Array.isArray(value);
25404
25461
  }
@@ -25531,7 +25588,8 @@ var MongoSyncWorker = class {
25531
25588
  this.events = this.db.collection("cml_events");
25532
25589
  } catch (err) {
25533
25590
  const safeUri = redactMongoUri(this.config.uri);
25534
- throw new Error(`MongoDB connection failed (${safeUri}, db=${this.config.dbName}): ${String(err)}`);
25591
+ const reason = describeMongoConnectionError(err, this.config.uri);
25592
+ throw new Error(`MongoDB connection failed (${safeUri}, db=${this.config.dbName}): ${reason}`);
25535
25593
  }
25536
25594
  }
25537
25595
  async disconnect() {
@@ -25592,7 +25650,7 @@ var MongoSyncWorker = class {
25592
25650
  if (batch.length === 0) break;
25593
25651
  const startSeq = await this.allocateSeqRange("events", batch.length);
25594
25652
  const now = /* @__PURE__ */ new Date();
25595
- const hostname2 = os8.hostname();
25653
+ const hostname2 = os9.hostname();
25596
25654
  const ops = batch.map((item, idx) => {
25597
25655
  const event = item.event;
25598
25656
  const seq = startSeq + idx;