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