claude-memory-layer 1.0.15 → 1.0.17

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.
@@ -2048,49 +2048,62 @@ var SQLiteEventStore = class {
2048
2048
  }
2049
2049
  async getRecentRetrievalTraces(limit = 50) {
2050
2050
  await this.initialize();
2051
- const rows = sqliteAll(
2052
- this.db,
2053
- `SELECT * FROM retrieval_traces ORDER BY created_at DESC LIMIT ?`,
2054
- [limit]
2055
- );
2056
- return rows.map((row) => ({
2057
- traceId: row.trace_id,
2058
- sessionId: row.session_id || void 0,
2059
- projectHash: row.project_hash || void 0,
2060
- queryText: row.query_text,
2061
- strategy: row.strategy || void 0,
2062
- candidateEventIds: row.candidate_event_ids ? JSON.parse(row.candidate_event_ids) : [],
2063
- selectedEventIds: row.selected_event_ids ? JSON.parse(row.selected_event_ids) : [],
2064
- candidateDetails: row.candidate_details_json ? JSON.parse(row.candidate_details_json) : [],
2065
- selectedDetails: row.selected_details_json ? JSON.parse(row.selected_details_json) : [],
2066
- candidateCount: Number(row.candidate_count || 0),
2067
- selectedCount: Number(row.selected_count || 0),
2068
- confidence: row.confidence || void 0,
2069
- fallbackTrace: row.fallback_trace ? JSON.parse(row.fallback_trace) : [],
2070
- createdAt: toDateFromSQLite(row.created_at)
2071
- }));
2051
+ try {
2052
+ const rows = sqliteAll(
2053
+ this.db,
2054
+ `SELECT * FROM retrieval_traces ORDER BY created_at DESC LIMIT ?`,
2055
+ [limit]
2056
+ );
2057
+ return rows.map((row) => ({
2058
+ traceId: row.trace_id,
2059
+ sessionId: row.session_id || void 0,
2060
+ projectHash: row.project_hash || void 0,
2061
+ queryText: row.query_text,
2062
+ strategy: row.strategy || void 0,
2063
+ candidateEventIds: row.candidate_event_ids ? JSON.parse(row.candidate_event_ids) : [],
2064
+ selectedEventIds: row.selected_event_ids ? JSON.parse(row.selected_event_ids) : [],
2065
+ candidateDetails: row.candidate_details_json ? JSON.parse(row.candidate_details_json) : [],
2066
+ selectedDetails: row.selected_details_json ? JSON.parse(row.selected_details_json) : [],
2067
+ candidateCount: Number(row.candidate_count || 0),
2068
+ selectedCount: Number(row.selected_count || 0),
2069
+ confidence: row.confidence || void 0,
2070
+ fallbackTrace: row.fallback_trace ? JSON.parse(row.fallback_trace) : [],
2071
+ createdAt: toDateFromSQLite(row.created_at)
2072
+ }));
2073
+ } catch (err) {
2074
+ if (err?.message?.includes("no such table"))
2075
+ return [];
2076
+ throw err;
2077
+ }
2072
2078
  }
2073
2079
  async getRetrievalTraceStats() {
2074
2080
  await this.initialize();
2075
- const row = sqliteGet(
2076
- this.db,
2077
- `SELECT
2078
- COUNT(*) as total_queries,
2079
- AVG(candidate_count) as avg_candidate_count,
2080
- AVG(selected_count) as avg_selected_count,
2081
- CASE
2082
- WHEN SUM(candidate_count) > 0 THEN (SUM(selected_count) * 1.0 / SUM(candidate_count))
2083
- ELSE 0
2084
- END as selection_rate
2085
- FROM retrieval_traces`,
2086
- []
2087
- );
2088
- return {
2089
- totalQueries: Number(row?.total_queries || 0),
2090
- avgCandidateCount: Number(row?.avg_candidate_count || 0),
2091
- avgSelectedCount: Number(row?.avg_selected_count || 0),
2092
- selectionRate: Number(row?.selection_rate || 0)
2093
- };
2081
+ try {
2082
+ const row = sqliteGet(
2083
+ this.db,
2084
+ `SELECT
2085
+ COUNT(*) as total_queries,
2086
+ AVG(candidate_count) as avg_candidate_count,
2087
+ AVG(selected_count) as avg_selected_count,
2088
+ CASE
2089
+ WHEN SUM(candidate_count) > 0 THEN (SUM(selected_count) * 1.0 / SUM(candidate_count))
2090
+ ELSE 0
2091
+ END as selection_rate
2092
+ FROM retrieval_traces`,
2093
+ []
2094
+ );
2095
+ return {
2096
+ totalQueries: Number(row?.total_queries || 0),
2097
+ avgCandidateCount: Number(row?.avg_candidate_count || 0),
2098
+ avgSelectedCount: Number(row?.avg_selected_count || 0),
2099
+ selectionRate: Number(row?.selection_rate || 0)
2100
+ };
2101
+ } catch (err) {
2102
+ if (err?.message?.includes("no such table")) {
2103
+ return { totalQueries: 0, avgCandidateCount: 0, avgSelectedCount: 0, selectionRate: 0 };
2104
+ }
2105
+ throw err;
2106
+ }
2094
2107
  }
2095
2108
  /**
2096
2109
  * Close database connection