diff --git a/packages/server/src/services/hermes/session-sync.ts b/packages/server/src/services/hermes/session-sync.ts index 6ae2215..e3f8315 100644 --- a/packages/server/src/services/hermes/session-sync.ts +++ b/packages/server/src/services/hermes/session-sync.ts @@ -112,6 +112,13 @@ function syncProfileSessions(profile: string): { const db = openHermesStateDb(profile) try { + // Check if sessions table has estimated_cost_usd column + const tableInfo = db.prepare('PRAGMA table_info(sessions)').all() as Array<{ name: string }> + const hasEstimatedCost = tableInfo.some(col => col.name === 'estimated_cost_usd') + + // Build SELECT query - only include estimated_cost_usd if column exists + const estimatedCostCol = hasEstimatedCost ? ', COALESCE(estimated_cost_usd, 0) AS estimated_cost_usd' : ', 0 AS estimated_cost_usd' + // Get all api_server sessions const sessions = db.prepare(` SELECT @@ -128,8 +135,7 @@ function syncProfileSessions(profile: string): { output_tokens, cache_read_tokens, cache_write_tokens, - reasoning_tokens, - estimated_cost_usd + reasoning_tokens${estimatedCostCol} FROM sessions WHERE source = 'api_server' ORDER BY started_at ASC @@ -218,7 +224,7 @@ function syncProfileSessions(profile: string): { cache_read_tokens: hermesSession.cache_read_tokens, cache_write_tokens: hermesSession.cache_write_tokens, reasoning_tokens: hermesSession.reasoning_tokens, - estimated_cost_usd: hermesSession.estimated_cost_usd, + estimated_cost_usd: hermesSession.estimated_cost_usd || 0, last_active: hermesSession.started_at, // Use started_at as fallback since last_active doesn't exist in Hermes state.db preview, })