Open source file-system and knowledge based agent template. Build AI agents that stay up to date with your knowledge base
fix logs tab
Hugo Richard3efbac2b870e
diff --git a/apps/chat/app/composables/useFileUpload.ts b/apps/chat/app/composables/useFileUpload.tsindex 728aff6..c52bc1c 100644--- a/apps/chat/app/composables/useFileUpload.ts+++ b/apps/chat/app/composables/useFileUpload.ts@@ -22,7 +22,6 @@ function fileToInput(file: File): HTMLInputElement {export function useFileUploadWithStatus(chatId: string) {const files = shallowRef<FileWithStatus[]>([])- const toast = useToast()const { showError } = useErrorToast()const { loggedIn } = useUserSession()diff --git a/apps/chat/app/pages/admin/logs.vue b/apps/chat/app/pages/admin/logs.vueindex 046432c..bc9cf8b 100644--- a/apps/chat/app/pages/admin/logs.vue+++ b/apps/chat/app/pages/admin/logs.vue@@ -276,7 +276,7 @@ async function investigateErrors() {<template v-else-if="stats"><div><p class="text-2xl font-medium text-highlighted tabular-nums">- {{ stats.totalCount.toLocaleString() }}+ {{ (stats.totalCount ?? 0).toLocaleString() }}</p><p class="text-sm text-muted mt-0.5">total log entries@@ -328,13 +328,11 @@ async function investigateErrors() {</div></section>- <!-- Clean up --><section><h2 class="text-[10px] text-muted uppercase tracking-wide mb-3 font-pixel">Clean up</h2><div class="rounded-lg border border-default p-4 space-y-4">- <!-- Level filter --><div class="flex items-center gap-3 flex-wrap"><span class="text-sm text-muted shrink-0">Level:</span><div class="flex flex-wrap gap-1.5">@@ -358,7 +356,6 @@ async function investigateErrors() {</div></div>- <!-- Time unit toggle --><div class="flex items-center gap-3"><span class="text-sm text-muted shrink-0">Delete older than:</span><div class="flex rounded-md border border-default overflow-hidden">@@ -374,7 +371,6 @@ async function investigateErrors() {</div></div>- <!-- Presets + custom --><div class="flex flex-wrap items-center gap-2"><UButtonv-for="preset in activePresets"@@ -399,9 +395,8 @@ async function investigateErrors() {</div></div>- <!-- Preview result --><div- v-if="previewCount !== null && activeValue"+ v-if="previewCount !== null && previewCount !== undefined && activeValue"class="flex items-center justify-between gap-4 rounded-md bg-elevated px-4 py-3"><div>diff --git a/apps/chat/server/utils/chat/admin-tools/get-agent-config.ts b/apps/chat/server/utils/chat/admin-tools/get-agent-config.tsindex 9355cbf..11ff6f1 100644--- a/apps/chat/server/utils/chat/admin-tools/get-agent-config.ts+++ b/apps/chat/server/utils/chat/admin-tools/get-agent-config.ts@@ -1,12 +1,9 @@-import type { UIToolInvocation } from 'ai'import { tool } from 'ai'import { z } from 'zod'import { db, schema } from '@nuxthub/db'import { eq } from 'drizzle-orm'import { preview, cmd } from './_preview'-export type GetAgentConfigUIToolInvocation = UIToolInvocation<typeof getAgentConfigTool>-export const getAgentConfigTool = tool({description: `Get the current agent configuration (system prompt customizations, response style, language, model settings).Use this to check how the assistant is configured.`,diff --git a/apps/chat/server/utils/chat/admin-tools/list-sources.ts b/apps/chat/server/utils/chat/admin-tools/list-sources.tsindex 599af90..a6b83e8 100644--- a/apps/chat/server/utils/chat/admin-tools/list-sources.ts+++ b/apps/chat/server/utils/chat/admin-tools/list-sources.ts@@ -1,12 +1,9 @@-import type { UIToolInvocation } from 'ai'import { tool } from 'ai'import { z } from 'zod'import { db, schema } from '@nuxthub/db'import { desc } from 'drizzle-orm'import { preview, cmd } from './_preview'-export type ListSourcesUIToolInvocation = UIToolInvocation<typeof listSourcesTool>-export const listSourcesTool = tool({description: `List all configured documentation sources (GitHub repos, YouTube channels).Use this to check what sources are available, their sync status, and configuration.`,diff --git a/apps/chat/server/utils/chat/admin-tools/list-users.ts b/apps/chat/server/utils/chat/admin-tools/list-users.tsindex fcede87..c4f92cf 100644--- a/apps/chat/server/utils/chat/admin-tools/list-users.ts+++ b/apps/chat/server/utils/chat/admin-tools/list-users.ts@@ -1,12 +1,9 @@-import type { UIToolInvocation } from 'ai'import { tool } from 'ai'import { z } from 'zod'import { db, schema } from '@nuxthub/db'import { eq, isNotNull } from 'drizzle-orm'import { preview, cmd } from './_preview'-export type ListUsersUIToolInvocation = UIToolInvocation<typeof listUsersTool>-export const listUsersTool = tool({description: `List application users with their usage statistics.Use this to find active users, check who is using the app, and see per-user token consumption.`,diff --git a/apps/chat/server/utils/chat/admin-tools/log-stats.ts b/apps/chat/server/utils/chat/admin-tools/log-stats.tsindex 4f71fd6..0a4e6fa 100644--- a/apps/chat/server/utils/chat/admin-tools/log-stats.ts+++ b/apps/chat/server/utils/chat/admin-tools/log-stats.ts@@ -1,12 +1,9 @@-import type { UIToolInvocation } from 'ai'import { tool } from 'ai'import { z } from 'zod'import { db, schema } from '@nuxthub/db'import { count, avg, max, sql, gte, and, isNotNull, desc } from 'drizzle-orm'import { preview, cmd } from './_preview'-export type LogStatsUIToolInvocation = UIToolInvocation<typeof logStatsTool>-const e = schema.evlogEventsexport const logStatsTool = tool({diff --git a/apps/chat/server/utils/chat/admin-tools/query-chats.ts b/apps/chat/server/utils/chat/admin-tools/query-chats.tsindex 9f9a420..da9c12a 100644--- a/apps/chat/server/utils/chat/admin-tools/query-chats.ts+++ b/apps/chat/server/utils/chat/admin-tools/query-chats.ts@@ -1,12 +1,9 @@-import type { UIToolInvocation } from 'ai'import { tool } from 'ai'import { z } from 'zod'import { db, schema } from '@nuxthub/db'import { desc, eq, and, sql } from 'drizzle-orm'import { preview, cmd } from './_preview'-export type QueryChatsUIToolInvocation = UIToolInvocation<typeof queryChatsTool>-export const queryChatsTool = tool({description: `Query recent chats to understand what users are asking about.Use this to find popular topics, identify common questions, or debug user issues.`,diff --git a/apps/chat/server/utils/chat/admin-tools/query-errors.ts b/apps/chat/server/utils/chat/admin-tools/query-errors.tsindex 49ac5cc..f7ac9f5 100644--- a/apps/chat/server/utils/chat/admin-tools/query-errors.ts+++ b/apps/chat/server/utils/chat/admin-tools/query-errors.ts@@ -1,12 +1,9 @@-import type { UIToolInvocation } from 'ai'import { tool } from 'ai'import { z } from 'zod'import { db, schema } from '@nuxthub/db'import { and, gte, eq, or, like, isNotNull, count, max, sql, desc } from 'drizzle-orm'import { preview, cmd } from './_preview'-export type QueryErrorsUIToolInvocation = UIToolInvocation<typeof queryErrorsTool>-const e = schema.evlogEventsexport const queryErrorsTool = tool({diff --git a/apps/chat/server/utils/chat/admin-tools/query-logs.ts b/apps/chat/server/utils/chat/admin-tools/query-logs.tsindex 65c5457..7316bea 100644--- a/apps/chat/server/utils/chat/admin-tools/query-logs.ts+++ b/apps/chat/server/utils/chat/admin-tools/query-logs.ts@@ -1,12 +1,9 @@-import type { UIToolInvocation } from 'ai'import { tool } from 'ai'import { z } from 'zod'import { db, schema } from '@nuxthub/db'import { and, gte, eq, like, sql, desc } from 'drizzle-orm'import { preview, cmd } from './_preview'-export type QueryLogsUIToolInvocation = UIToolInvocation<typeof queryLogsTool>-const e = schema.evlogEventsexport const queryLogsTool = tool({diff --git a/apps/chat/server/utils/chat/admin-tools/query-stats.ts b/apps/chat/server/utils/chat/admin-tools/query-stats.tsindex 8116001..cc295c2 100644--- a/apps/chat/server/utils/chat/admin-tools/query-stats.ts+++ b/apps/chat/server/utils/chat/admin-tools/query-stats.ts@@ -1,12 +1,9 @@-import type { UIToolInvocation } from 'ai'import { tool } from 'ai'import { z } from 'zod'import { db, schema } from '@nuxthub/db'import { eq, gte, and, count } from 'drizzle-orm'import { preview, cmd } from './_preview'-export type QueryStatsUIToolInvocation = UIToolInvocation<typeof queryStatsTool>-export const queryStatsTool = tool({description: `Query usage statistics for the application. Returns message counts, token usage, model usage, and active users over a given period.Use this to answer questions about app usage, costs, activity trends, and popular models.`,diff --git a/apps/chat/server/utils/chat/admin-tools/run-sql.ts b/apps/chat/server/utils/chat/admin-tools/run-sql.tsindex 854afb2..bc68bf5 100644--- a/apps/chat/server/utils/chat/admin-tools/run-sql.ts+++ b/apps/chat/server/utils/chat/admin-tools/run-sql.ts@@ -1,12 +1,9 @@-import type { UIToolInvocation } from 'ai'import { tool } from 'ai'import { z } from 'zod'import { db } from '@nuxthub/db'import { sql } from 'drizzle-orm'import { cmd, preview } from './_preview'-export type RunSqlUIToolInvocation = UIToolInvocation<typeof runSqlTool>-export const runSqlTool = tool({description: `Execute a read-only SQL SELECT query against the PostgreSQL (PGlite) database.Use this for custom queries when the other tools don't provide the data you need.diff --git a/apps/chat/server/utils/sandbox/snapshot.ts b/apps/chat/server/utils/sandbox/snapshot.tsindex 9f42579..758af9c 100644--- a/apps/chat/server/utils/sandbox/snapshot.ts+++ b/apps/chat/server/utils/sandbox/snapshot.ts@@ -1,5 +1,4 @@import { kv } from '@nuxthub/kv'-import { createError } from 'evlog'import type { SnapshotMetadata } from './types'import { KV_KEYS } from './types'@@ -12,22 +11,3 @@ export async function getCurrentSnapshot(): Promise<SnapshotMetadata | null> {export async function setCurrentSnapshot(metadata: SnapshotMetadata): Promise<void> {await kv.set(KV_KEYS.CURRENT_SNAPSHOT, metadata)}--/** Returns true if a snapshot exists in KV */-export async function hasSnapshot(): Promise<boolean> {- const snapshot = await getCurrentSnapshot()- return snapshot !== null-}--/** Returns current snapshot ID, throws if no snapshot exists */-export async function getSnapshotIdOrThrow(): Promise<string> {- const snapshot = await getCurrentSnapshot()- if (!snapshot) {- throw createError({- message: 'No snapshot available',- why: 'No sandbox snapshot has been created yet',- fix: 'Create a snapshot first by running the sync workflow or using the admin panel',- })- }- return snapshot.snapshotId-}diff --git a/apps/chat/shared/types/db.d.ts b/apps/chat/shared/types/db.d.tsdeleted file mode 100644index c707356..0000000--- a/apps/chat/shared/types/db.d.ts+++ /dev/null@@ -1,5 +0,0 @@-import type { chats, messages, sources } from '@nuxthub/db/schema'--export type Chat = typeof chats.$inferSelect-export type Message = typeof messages.$inferSelect-export type Source = typeof sources.$inferSelect