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