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/index.js CHANGED
@@ -3297,6 +3297,16 @@ var SQLiteEventStore = class {
3297
3297
  getDatabase() {
3298
3298
  return this.db;
3299
3299
  }
3300
+ hasTableColumn(tableName, columnName) {
3301
+ if (!/^[A-Za-z_][A-Za-z0-9_]*$/.test(tableName))
3302
+ return false;
3303
+ try {
3304
+ const rows = sqliteAll(this.db, `PRAGMA table_info("${tableName}")`, []);
3305
+ return rows.some((row) => row.name === columnName);
3306
+ } catch {
3307
+ return false;
3308
+ }
3309
+ }
3300
3310
  async recordRetrievalTrace(input) {
3301
3311
  await this.initialize();
3302
3312
  const traceId = randomUUID();
@@ -3362,17 +3372,18 @@ var SQLiteEventStore = class {
3362
3372
  async getRetrievalTraceStats() {
3363
3373
  await this.initialize();
3364
3374
  try {
3375
+ const rewrittenQueryRewriteKindSql = this.hasTableColumn("retrieval_traces", "query_rewrite_kind") ? REWRITTEN_QUERY_REWRITE_KIND_SQL : "0";
3365
3376
  const row = sqliteGet(
3366
3377
  this.db,
3367
3378
  `SELECT
3368
3379
  COUNT(*) as total_queries,
3369
3380
  AVG(candidate_count) as avg_candidate_count,
3370
3381
  AVG(selected_count) as avg_selected_count,
3371
- SUM(CASE WHEN ${REWRITTEN_QUERY_REWRITE_KIND_SQL} THEN 1 ELSE 0 END) as rewritten_queries,
3372
- SUM(CASE WHEN ${REWRITTEN_QUERY_REWRITE_KIND_SQL} AND selected_count > 0 THEN 1 ELSE 0 END) as rewritten_queries_with_selection,
3373
- SUM(CASE WHEN NOT (${REWRITTEN_QUERY_REWRITE_KIND_SQL}) AND selected_count > 0 THEN 1 ELSE 0 END) as raw_queries_with_selection,
3374
- AVG(CASE WHEN ${REWRITTEN_QUERY_REWRITE_KIND_SQL} THEN selected_count END) as avg_selected_count_for_rewritten_queries,
3375
- AVG(CASE WHEN NOT (${REWRITTEN_QUERY_REWRITE_KIND_SQL}) THEN selected_count END) as avg_selected_count_for_raw_queries,
3382
+ SUM(CASE WHEN ${rewrittenQueryRewriteKindSql} THEN 1 ELSE 0 END) as rewritten_queries,
3383
+ SUM(CASE WHEN ${rewrittenQueryRewriteKindSql} AND selected_count > 0 THEN 1 ELSE 0 END) as rewritten_queries_with_selection,
3384
+ SUM(CASE WHEN NOT (${rewrittenQueryRewriteKindSql}) AND selected_count > 0 THEN 1 ELSE 0 END) as raw_queries_with_selection,
3385
+ AVG(CASE WHEN ${rewrittenQueryRewriteKindSql} THEN selected_count END) as avg_selected_count_for_rewritten_queries,
3386
+ AVG(CASE WHEN NOT (${rewrittenQueryRewriteKindSql}) THEN selected_count END) as avg_selected_count_for_raw_queries,
3376
3387
  CASE
3377
3388
  WHEN SUM(candidate_count) > 0 THEN (SUM(selected_count) * 1.0 / SUM(candidate_count))
3378
3389
  ELSE 0