claude-memory-layer 1.0.15 → 1.0.16

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