refactor(insights): use provider abstraction in settings and generate routes

Replace direct OpenAI API calls with resolveProvider() abstraction.
Settings route now returns codexStatus/codexConnectedAt/hasAdminKey
instead of hasKey. Generate route validates AI response with
insightResultSchema and logs providerType/model. Also fixes
AppSettings lookup id from 1 to "singleton" in provider.ts.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Marc-André BombeckandClaude Opus 4.6 committed 2026-04-06 00:42:46 +02:00
1 parent fde3a0941a
commit 249a2c74ba
3 files changed
+46 -115

No files matched your search

+1 -1
View File
@@ -18,7 +18,7 @@ class NoProvider implements AIProvider {
}
async function resolveAdminProvider(): Promise<AIProvider> {
const settings = await prisma.appSettings.findUnique({ where: { id: 1 } });
const settings = await prisma.appSettings.findUnique({ where: { id: "singleton" } });
if (settings?.adminAiKeyEncrypted) {
return new OpenAIClient({