fix: harden assistant integration

This commit is contained in:
ajnart committed 2026-08-14 11:32:09 +02:00
1 parent 10ef871777
commit 5db95f2def
14 files changed
+349 -189

No files matched your search

+16 -9
View File
@@ -195,15 +195,22 @@ const ownedThreadAsync = async (db: Database, threadId: string, userId: string)
};
export const assistantRouter = createTRPCRouter({
getAvailability: protectedProcedure.query(async ({ ctx }) => {
const configuration = await getConfigurationAsync(ctx.db);
const requiresApiKey = configuration?.provider === "openrouter" || configuration?.provider === "openai";
return {
enabled: Boolean(
configuration?.enabled && configuration.modelId && (!requiresApiKey || configuration.encryptedApiKey),
),
};
}),
getAvailability: protectedProcedure
.meta({
mcp: {
enabled: true,
description: "Check whether Homarr Assistant is enabled and configured for the current user",
},
})
.query(async ({ ctx }) => {
const configuration = await getConfigurationAsync(ctx.db);
const requiresApiKey = configuration?.provider === "openrouter" || configuration?.provider === "openai";
return {
enabled: Boolean(
configuration?.enabled && configuration.modelId && (!requiresApiKey || configuration.encryptedApiKey),
),
};
}),
getAdminConfiguration: adminProcedure.query(async ({ ctx }) => {
const configuration = await getConfigurationAsync(ctx.db);