claude-memory-layer 1.0.34 → 1.0.36

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/mcp/index.js CHANGED
@@ -13999,6 +13999,16 @@ var SQLiteEventStore = class {
13999
13999
  getDatabase() {
14000
14000
  return this.db;
14001
14001
  }
14002
+ hasTableColumn(tableName, columnName) {
14003
+ if (!/^[A-Za-z_][A-Za-z0-9_]*$/.test(tableName))
14004
+ return false;
14005
+ try {
14006
+ const rows = sqliteAll(this.db, `PRAGMA table_info("${tableName}")`, []);
14007
+ return rows.some((row) => row.name === columnName);
14008
+ } catch {
14009
+ return false;
14010
+ }
14011
+ }
14002
14012
  async recordRetrievalTrace(input) {
14003
14013
  await this.initialize();
14004
14014
  const traceId = randomUUID5();
@@ -14064,17 +14074,18 @@ var SQLiteEventStore = class {
14064
14074
  async getRetrievalTraceStats() {
14065
14075
  await this.initialize();
14066
14076
  try {
14077
+ const rewrittenQueryRewriteKindSql = this.hasTableColumn("retrieval_traces", "query_rewrite_kind") ? REWRITTEN_QUERY_REWRITE_KIND_SQL : "0";
14067
14078
  const row = sqliteGet(
14068
14079
  this.db,
14069
14080
  `SELECT
14070
14081
  COUNT(*) as total_queries,
14071
14082
  AVG(candidate_count) as avg_candidate_count,
14072
14083
  AVG(selected_count) as avg_selected_count,
14073
- SUM(CASE WHEN ${REWRITTEN_QUERY_REWRITE_KIND_SQL} THEN 1 ELSE 0 END) as rewritten_queries,
14074
- SUM(CASE WHEN ${REWRITTEN_QUERY_REWRITE_KIND_SQL} AND selected_count > 0 THEN 1 ELSE 0 END) as rewritten_queries_with_selection,
14075
- SUM(CASE WHEN NOT (${REWRITTEN_QUERY_REWRITE_KIND_SQL}) AND selected_count > 0 THEN 1 ELSE 0 END) as raw_queries_with_selection,
14076
- AVG(CASE WHEN ${REWRITTEN_QUERY_REWRITE_KIND_SQL} THEN selected_count END) as avg_selected_count_for_rewritten_queries,
14077
- AVG(CASE WHEN NOT (${REWRITTEN_QUERY_REWRITE_KIND_SQL}) THEN selected_count END) as avg_selected_count_for_raw_queries,
14084
+ SUM(CASE WHEN ${rewrittenQueryRewriteKindSql} THEN 1 ELSE 0 END) as rewritten_queries,
14085
+ SUM(CASE WHEN ${rewrittenQueryRewriteKindSql} AND selected_count > 0 THEN 1 ELSE 0 END) as rewritten_queries_with_selection,
14086
+ SUM(CASE WHEN NOT (${rewrittenQueryRewriteKindSql}) AND selected_count > 0 THEN 1 ELSE 0 END) as raw_queries_with_selection,
14087
+ AVG(CASE WHEN ${rewrittenQueryRewriteKindSql} THEN selected_count END) as avg_selected_count_for_rewritten_queries,
14088
+ AVG(CASE WHEN NOT (${rewrittenQueryRewriteKindSql}) THEN selected_count END) as avg_selected_count_for_raw_queries,
14078
14089
  CASE
14079
14090
  WHEN SUM(candidate_count) > 0 THEN (SUM(selected_count) * 1.0 / SUM(candidate_count))
14080
14091
  ELSE 0