import Database from 'better-sqlite3'; import path from 'node:path'; import { ConversationLearningRepository } from '../src/database/conversation-learning-repository.js'; import { runConversationLearningEvaluation } from '../src/services/conversation-learning-evaluator.js'; const argument = (name: string): string | undefined => { const index = process.argv.indexOf(name); return index >= 0 ? process.argv[index + 1] : undefined; }; const databasePath = argument('--db'); const policyVersion = argument('--policy') ?? 'baseline-v1'; if (!databasePath) throw new Error('Usage: npm run learning:eval -- --db [--policy ]'); const db = new Database(path.resolve(process.cwd(), databasePath), { readonly: false, fileMustExist: true }); try { const run = runConversationLearningEvaluation(new ConversationLearningRepository(db), policyVersion); process.stdout.write(`${JSON.stringify(run, null, 2)}\n`); if (run.status === 'failed') process.exitCode = 1; } finally { db.close(); }