Skip to content

Open source file-system and knowledge based agent template. Build AI agents that stay up to date with your knowledge base

cleaning

Hugo Richard790f53f14bca
diff --git a/apps/chat/app/components/ChatLoading.vue b/apps/chat/app/components/ChatLoading.vue
index 329137d..e83bc2e 100644
--- a/apps/chat/app/components/ChatLoading.vue
+++ b/apps/chat/app/components/ChatLoading.vue
@@ -1,29 +1,7 @@
<script setup lang="ts">
import { motion } from 'motion-v'
import { useIntervalFn, useRafFn } from '@vueuse/core'
-
-interface CommandResult {
- command: string
- stdout: string
- stderr: string
- exitCode: number
- success: boolean
-}
-
-interface ToolExecutionResult {
- commands: CommandResult[]
- success: boolean
- durationMs: number
- error?: string
-}
-
-interface ToolCall {
- toolCallId: string
- toolName: string
- args: Record<string, unknown>
- state: 'loading' | 'done' | 'error'
- result?: ToolExecutionResult
-}
+import type { ToolCall } from '#shared/types/tool-call'
const props = defineProps<{
text?: string
diff --git a/apps/chat/app/components/ChatMatrix.vue b/apps/chat/app/components/ChatMatrix.vue
index 9fbd26c..a5dad02 100644
--- a/apps/chat/app/components/ChatMatrix.vue
+++ b/apps/chat/app/components/ChatMatrix.vue
@@ -17,9 +17,6 @@ const totalDots = computed(() => props.size * props.size)
const activeDots = shallowRef<Set<number>>(new Set())
const patterns = [
- // Spiral pattern from outside to center
- [[0], [1], [2], [3], [4], [9], [14], [19], [24], [23], [22], [21], [20], [15], [10], [5], [6], [7], [8], [13], [18], [17], [16], [11], [12]],
-
// Vertical waves
[[0, 5, 10, 15, 20], [1, 6, 11, 16, 21], [2, 7, 12, 17, 22], [3, 8, 13, 18, 23], [4, 9, 14, 19, 24]],
@@ -29,9 +26,6 @@ const patterns = [
// Horizontal waves
[[0, 1, 2, 3, 4], [5, 6, 7, 8, 9], [10, 11, 12, 13, 14], [15, 16, 17, 18, 19], [20, 21, 22, 23, 24]],
- // Corners
- [[0], [4], [24], [20], [12]],
-
// Cross pattern
[[2, 10, 11, 12, 13, 14, 22], [6, 7, 8, 16, 17, 18], [0, 1, 3, 4, 5, 9, 15, 19, 20, 21, 23, 24]],
@@ -41,15 +35,21 @@ const patterns = [
// Random clusters
[[6, 7, 8, 11, 12, 13, 16, 17, 18], [1, 3, 5, 9, 10, 14, 15, 19, 21, 23], [0, 2, 4, 20, 22, 24]],
+ // Rows converging
+ [[0, 1, 2, 3, 4, 20, 21, 22, 23, 24], [5, 6, 7, 8, 9, 15, 16, 17, 18, 19], [10, 11, 12, 13, 14]],
+
+ // Quadrants then cross
+ [[0, 1, 5, 6], [3, 4, 8, 9], [15, 16, 20, 21], [18, 19, 23, 24], [2, 7, 10, 11, 12, 13, 14, 17, 22]],
+
+ // Corners inward
+ [[0, 4, 20, 24], [1, 3, 5, 9, 15, 19, 21, 23], [2, 6, 8, 10, 14, 16, 18, 22], [7, 11, 12, 13, 17]],
+
// Checkerboard
[
[0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24],
[1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23]
],
- // Rain drops (columns falling one by one)
- [[0], [5], [10], [15], [20], [1], [6], [11], [16], [21], [2], [7], [12], [17], [22], [3], [8], [13], [18], [23], [4], [9], [14], [19], [24]],
-
// Square outline inwards
[
[0, 1, 2, 3, 4, 9, 14, 19, 24, 23, 22, 21, 20, 15, 10, 5],
@@ -113,10 +113,10 @@ const gridStyle = computed(() => ({
height: `${props.size * props.dotSize + (props.size - 1) * props.gap}px`,
}))
-const dotStyle = computed(() => ({
- width: `${props.dotSize}px`,
- height: `${props.dotSize}px`,
-}))
+const dotStyle = computed(() => {
+ const size = `${props.dotSize}px`
+ return { width: size, height: size }
+})
useIntervalFn(nextStep, 120, { immediateCallback: true })
</script>
diff --git a/apps/chat/app/components/SourceModal.vue b/apps/chat/app/components/SourceModal.vue
index 6522b5e..cacbdf3 100644
--- a/apps/chat/app/components/SourceModal.vue
+++ b/apps/chat/app/components/SourceModal.vue
@@ -125,7 +125,6 @@ async function save() {
<template #body>
<div class="flex flex-col gap-5 p-5">
- <!-- Section 1: Basic Info -->
<div class="grid grid-cols-2 gap-4">
<div class="flex flex-col gap-1.5">
<label class="text-sm font-medium text-highlighted">Type</label>
@@ -145,7 +144,6 @@ async function save() {
</div>
</div>
- <!-- Section 2: Snapshot Location -->
<div class="p-4 bg-muted/30 rounded-lg border border-default">
<div class="flex items-start gap-3 mb-3">
<div class="size-8 rounded-lg bg-primary/10 flex items-center justify-center shrink-0">
@@ -185,9 +183,7 @@ async function save() {
</div>
</div>
- <!-- Section 3: Source-specific fields -->
<div class="flex flex-col gap-4">
- <!-- GitHub Fields -->
<template v-if="form.type === 'github'">
<div class="grid grid-cols-2 gap-4">
<div class="flex flex-col gap-1.5">
@@ -244,7 +240,6 @@ async function save() {
</div>
</template>
- <!-- YouTube Fields -->
<template v-if="form.type === 'youtube'">
<div class="grid grid-cols-2 gap-4">
<div class="flex flex-col gap-1.5">
diff --git a/apps/chat/app/components/ToolCallItem.vue b/apps/chat/app/components/ToolCallItem.vue
index 3008947..0e8e588 100644
--- a/apps/chat/app/components/ToolCallItem.vue
+++ b/apps/chat/app/components/ToolCallItem.vue
@@ -1,29 +1,7 @@
<script setup lang="ts">
import { motion, AnimatePresence } from 'motion-v'
import { useTimeoutFn } from '@vueuse/core'
-
-interface CommandResult {
- command: string
- stdout: string
- stderr: string
- exitCode: number
- success: boolean
-}
-
-interface ToolExecutionResult {
- commands: CommandResult[]
- success: boolean
- durationMs: number
- error?: string
-}
-
-interface ToolCall {
- toolCallId: string
- toolName: string
- args: Record<string, unknown>
- state: 'loading' | 'done' | 'error'
- result?: ToolExecutionResult
-}
+import type { ToolCall } from '#shared/types/tool-call'
const props = defineProps<{
tool: ToolCall
diff --git a/apps/chat/app/layouts/default.vue b/apps/chat/app/layouts/default.vue
index f694e2a..9515eb1 100644
--- a/apps/chat/app/layouts/default.vue
+++ b/apps/chat/app/layouts/default.vue
@@ -27,8 +27,6 @@ const shareModal = overlay.create(LazyModalShare, {
const { data: chats, refresh: refreshChats } = await useFetch<Chat[]>('/api/chats', {
key: 'chats',
- getCachedData: (key, nuxtApp) =>
- nuxtApp.payload.data[key] ?? nuxtApp.static.data[key],
transform: data => data.map(chat => ({
id: chat.id,
label: chat.title || 'Untitled',
diff --git a/apps/chat/app/pages/admin/agent.vue b/apps/chat/app/pages/admin/agent.vue
index 60940d6..a8f1d14 100644
--- a/apps/chat/app/pages/admin/agent.vue
+++ b/apps/chat/app/pages/admin/agent.vue
@@ -19,7 +19,6 @@ const cachedConfig = useState<AgentConfig | null>('admin-agent-config', () => nu
const { data: config, refresh, status } = useLazyFetch<AgentConfig>('/api/agent-config')
-// Restore cached data for instant navigation, fetch updates silently in background
if (!config.value && cachedConfig.value) {
config.value = cachedConfig.value
}
@@ -160,7 +159,6 @@ async function resetConfig() {
</p>
</header>
- <!-- Skeleton loading state -->
<div v-if="status === 'pending' && !config" class="space-y-8">
<div v-for="i in 3" :key="i">
<USkeleton class="h-3 w-20 mb-3" />
@@ -177,7 +175,6 @@ async function resetConfig() {
</div>
<form v-else class="space-y-8" @submit.prevent="saveConfig">
- <!-- General -->
<section>
<h2 class="text-[10px] text-muted uppercase tracking-wide mb-3 font-pixel">
General
@@ -234,7 +231,6 @@ async function resetConfig() {
</div>
</section>
- <!-- Tuning -->
<section>
<h2 class="text-[10px] text-muted uppercase tracking-wide mb-3 font-pixel">
Tuning
@@ -271,7 +267,6 @@ async function resetConfig() {
</div>
</section>
- <!-- Instructions -->
<section>
<h2 class="text-[10px] text-muted uppercase tracking-wide mb-3 font-pixel">
Instructions
@@ -306,7 +301,6 @@ async function resetConfig() {
</div>
</section>
- <!-- Actions -->
<div class="flex items-center gap-3">
<UButton
type="submit"
diff --git a/apps/chat/app/pages/admin/index.vue b/apps/chat/app/pages/admin/index.vue
index 8ca5da6..034b3a4 100644
--- a/apps/chat/app/pages/admin/index.vue
+++ b/apps/chat/app/pages/admin/index.vue
@@ -27,7 +27,6 @@ const overlay = useOverlay()
const { data: sources, refresh, status } = useLazyFetch('/api/sources')
-// Persist data across navigations via useState, fetch updates silently in background
const cachedSources = useState('admin-sources', () => sources.value)
if (!sources.value && cachedSources.value) {
sources.value = cachedSources.value
@@ -95,7 +94,6 @@ async function deleteSource(source: SerializedSource) {
if (!confirmed) return
- // Optimistic update: remove from list immediately
const previousData = sources.value
if (sources.value) {
sources.value = {
@@ -121,7 +119,6 @@ async function deleteSource(source: SerializedSource) {
icon: 'i-lucide-check',
})
} catch (error: unknown) {
- // Rollback on error
sources.value = previousData
toast.add({
title: 'Error',
@@ -176,7 +173,6 @@ const hasSources = computed(() => (sources.value?.github?.count || 0) + (sources
</p>
</header>
- <!-- Skeleton loading state -->
<div v-if="status === 'pending' && !sources" class="space-y-4">
<div class="flex items-center gap-2 mb-6">
<USkeleton class="h-7 w-20 rounded-md" />
diff --git a/apps/chat/app/pages/admin/new.vue b/apps/chat/app/pages/admin/new.vue
index 66bd299..bee2527 100644
--- a/apps/chat/app/pages/admin/new.vue
+++ b/apps/chat/app/pages/admin/new.vue
@@ -1,5 +1,5 @@
<script setup lang="ts">
-import type { SourceOcrItem } from '~/shared/utils/source-ocr'
+import type { SourceOcrItem } from '#shared/utils/source-ocr'
interface PendingFile {
id: string
@@ -33,12 +33,9 @@ const router = useRouter()
const route = useRoute()
const toast = useToast()
-// Fetch sources to check if YouTube is enabled (non-blocking, only used for a boolean flag)
const { data: sourcesData } = useLazyFetch('/api/sources')
const youtubeEnabled = computed(() => sourcesData.value?.youtubeEnabled ?? false)
-// Get type from query param (defaults to 'github')
-// If YouTube is requested but not enabled, fallback to GitHub
const requestedType = route.query.type === 'youtube' ? 'youtube' : 'github'
const initialType = (requestedType === 'youtube' && !youtubeEnabled.value ? 'github' : requestedType) as 'github' | 'youtube'
@@ -68,7 +65,6 @@ const sources = ref<ExtractedSource[]>([
])
const fileInputRef = ref<HTMLInputElement | null>(null)
-// Auto-expand Quick Import when files are dragged
watch(pendingFiles, (files) => {
if (files.length > 0 && !showQuickImport.value) {
showQuickImport.value = true
@@ -244,7 +240,6 @@ function handleFileSelect(event: Event) {
}
function removeSource(id: string) {
- // Keep at least one source
if (sources.value.length > 1) {
sources.value = sources.value.filter(s => s.id !== id)
}
@@ -304,7 +299,12 @@ async function saveAll() {
})
created++
} catch (error) {
- console.error('Failed to create source:', error)
+ toast.add({
+ title: 'Failed to create source',
+ description: error instanceof Error ? error.message : 'Unknown error',
+ color: 'error',
+ icon: 'i-lucide-alert-circle',
+ })
}
}
@@ -350,7 +350,6 @@ const validSourcesCount = computed(() => sources.value.filter(s => s.data.label)
</p>
</header>
- <!-- Expandable Quick Import Section -->
<section v-if="showQuickImport" class="mb-8">
<p class="text-[10px] text-muted mb-3 font-pixel tracking-wide uppercase">
Quick import
@@ -546,7 +545,6 @@ const validSourcesCount = computed(() => sources.value.filter(s => s.data.label)
</div>
</section>
- <!-- Power users notice above separator -->
<div class="mb-2 text-center">
<button
class="text-xs text-muted hover:text-primary transition-colors inline-flex items-center gap-1.5"
diff --git a/apps/chat/app/pages/admin/stats.vue b/apps/chat/app/pages/admin/stats.vue
index 9e809e7..652013e 100644
--- a/apps/chat/app/pages/admin/stats.vue
+++ b/apps/chat/app/pages/admin/stats.vue
@@ -22,13 +22,11 @@ const { data: stats, refresh, status } = useLazyFetch<GlobalStatsResponse>('/api
watch: [selectedPeriod, selectedSources, selectedModels],
})
-// Restore cached data for instant navigation, fetch updates silently in background
if (!stats.value && cachedStats.value) {
stats.value = cachedStats.value
}
watch(stats, (v) => { if (v) cachedStats.value = v })
-// Track if we're refreshing (vs initial load) to avoid flickering
const isRefreshing = computed(() => status.value === 'pending' && stats.value !== null)
const hasFilters = computed(() => selectedSources.value.length > 0 || selectedModels.value.length > 0)
@@ -74,7 +72,6 @@ function formatCost(amount: number): string {
return `$${amount.toFixed(4)}`
}
-// Feedback score color
function getScoreColor(score: number | null): string {
if (score === null) return 'text-muted'
if (score >= 80) return 'text-success'
@@ -82,14 +79,12 @@ function getScoreColor(score: number | null): string {
return 'text-error'
}
-// Model satisfaction rate
function getModelSatisfaction(model: { positive: number, negative: number }): number | null {
const total = model.positive + model.negative
if (total === 0) return null
return Math.round((model.positive / total) * 100)
}
-// Trend formatting
function formatTrend(trend: number | null): string {
if (trend === null) return '—'
const sign = trend >= 0 ? '+' : ''
@@ -110,7 +105,6 @@ function getTrendIcon(trend: number | null): string {
return 'i-lucide-minus'
}
-// Source color map
const sourceColorMap: Record<string, string> = {
'web': 'bg-primary',
'github-bot': 'bg-emerald-500',
@@ -122,7 +116,6 @@ function getSourceColor(source: string): string {
return sourceColorMap[source] ?? 'bg-gray-400'
}
-// Stacked-by-source chart data
const chartDataBySource = computed(() => {
if (!stats.value?.dailyBySource) return []
@@ -166,7 +159,6 @@ const chartMax = computed(() => {
return max || 1
})
-// Get evenly spaced date labels for the x-axis (5 labels max)
const chartDateLabels = computed(() => {
if (chartDataBySource.value.length === 0) return []
if (chartDataBySource.value.length <= 5) {
@@ -182,7 +174,6 @@ const chartDateLabels = computed(() => {
})
})
-// Peak hours
const peakHoursData = computed(() => stats.value?.hourlyDistribution ?? [])
const peakHoursMax = computed(() => {
let max = 0
@@ -192,7 +183,6 @@ const peakHoursMax = computed(() => {
return max || 1
})
-// Model cost lookup from estimatedCost
function getModelCost(modelId: string): number | null {
const entry = stats.value?.estimatedCost?.byModel?.find(m => m.model === modelId)
return entry ? entry.totalCost : null
@@ -243,7 +233,6 @@ function getModelCost(modelId: string): number | null {
</div>
</header>
- <!-- Skeleton loading state -->
<div v-if="status === 'pending' && !stats">
<div class="grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-6 gap-4 mb-8">
<div v-for="i in 6" :key="i" class="rounded-lg border border-default bg-elevated/50 p-4">
@@ -264,7 +253,6 @@ function getModelCost(modelId: string): number | null {
class="transition-opacity duration-200"
:class="isRefreshing ? 'opacity-50 pointer-events-none' : 'opacity-100'"
>
- <!-- Filter Bar -->
<div v-if="sourceOptions.length > 0 || modelOptions.length > 0" class="flex items-center gap-3 mb-6 flex-wrap">
<USelectMenu
v-if="sourceOptions.length > 0"
@@ -298,7 +286,6 @@ function getModelCost(modelId: string): number | null {
</UButton>
</div>
- <!-- KPI Cards with Trends -->
<div class="grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-6 gap-4 mb-8">
<div class="rounded-lg border border-default bg-elevated/50 p-4">
<p class="text-xs text-muted mb-1">
@@ -373,7 +360,6 @@ function getModelCost(modelId: string): number | null {
</div>
</div>
- <!-- Usage Chart (Stacked by Source) -->
<section class="mb-10">
<div class="flex items-center justify-between mb-3">
<h2 class="text-sm font-medium text-highlighted">
@@ -446,7 +432,6 @@ function getModelCost(modelId: string): number | null {
</div>
</section>
- <!-- Peak Hours -->
<section v-if="peakHoursData.some(h => h.messageCount > 0)" class="mb-10">
<h2 class="text-xs text-highlighted mb-3 font-pixel tracking-wide uppercase">
Peak Hours (UTC)
@@ -477,9 +462,7 @@ function getModelCost(modelId: string): number | null {
</div>
</section>
- <!-- Two column layout for tables -->
<div class="grid md:grid-cols-2 gap-8 mb-8 items-start">
- <!-- Top Users -->
<section>
<h2 class="text-xs text-highlighted mb-3 font-pixel tracking-wide uppercase">
Top Users
@@ -536,7 +519,6 @@ function getModelCost(modelId: string): number | null {
</div>
</section>
- <!-- By Source -->
<section v-if="stats.bySource && stats.bySource.length > 0">
<h2 class="text-xs text-highlighted mb-3 font-pixel tracking-wide uppercase">
By Source
@@ -580,7 +562,6 @@ function getModelCost(modelId: string): number | null {
</section>
</div>
- <!-- By Model (full width) -->
<section>
<h2 class="text-xs text-highlighted mb-3 font-pixel tracking-wide uppercase">
By Model
diff --git a/apps/chat/app/pages/chat/[id].vue b/apps/chat/app/pages/chat/[id].vue
index 1e95dc5..2f2fedb 100644
--- a/apps/chat/app/pages/chat/[id].vue
+++ b/apps/chat/app/pages/chat/[id].vue
@@ -5,6 +5,7 @@ import { DefaultChatTransport } from 'ai'
import type { UIMessage } from 'ai'
import { useClipboard } from '@vueuse/core'
import { getTextFromMessage } from '@nuxt/ui/utils/ai'
+import type { ToolCall } from '#shared/types/tool-call'
import ProseStreamPre from '../../components/prose/PreStream.vue'
const components = {
@@ -157,33 +158,9 @@ function getAssistantActions(message: UIMessage) {
]
}
-interface CommandResult {
- command: string
- stdout: string
- stderr: string
- exitCode: number
- success: boolean
-}
-
-interface ToolExecutionResult {
- commands: CommandResult[]
- success: boolean
- durationMs: number
- error?: string
-}
-
-interface ToolCallInfo {
- toolCallId: string
- toolName: string
- args: Record<string, unknown>
- state: 'loading' | 'done' | 'error'
- result?: ToolExecutionResult
-}
-
-function getMessageToolCalls(message: UIMessage): ToolCallInfo[] {
+function getMessageToolCalls(message: UIMessage): ToolCall[] {
if (!message?.parts) return []
- // Extract individual tool call data parts (reconciled by ID)
- return (message.parts as Array<{ type: string, data?: ToolCallInfo }>)
+ return (message.parts as Array<{ type: string, data?: ToolCall }>)
.filter(p => p.type === 'data-tool-call')
.map(p => p.data!)
.filter(Boolean)
diff --git a/apps/chat/server/api/chats/[id].post.ts b/apps/chat/server/api/chats/[id].post.ts
index 8902c96..ebe7bd1 100644
--- a/apps/chat/server/api/chats/[id].post.ts
+++ b/apps/chat/server/api/chats/[id].post.ts
@@ -152,10 +152,8 @@ export default defineEventHandler(async (event) => {
let stepStartTime = Date.now()
const stepDurations: number[] = []
- // Writer reference to be used by onToolCall callback
let streamWriter: any = null
- // Try to reuse an active sandbox session (shared across all chats)
const existingSessionId = await kv.get<string>(KV_KEYS.ACTIVE_SANDBOX_SESSION)
if (existingSessionId) {
log.info('chat', `[${requestId}] Found active sandbox session ${existingSessionId}`)
@@ -187,7 +185,6 @@ export default defineEventHandler(async (event) => {
},
})
- // Get both router config and admin-defined agent config
const [routerConfig, agentConfigData] = await Promise.all([
routeQuestion(messages, requestId),
getAgentConfig(),
@@ -201,7 +198,6 @@ export default defineEventHandler(async (event) => {
log.info('chat', `[${requestId}] Starting agent with ${effectiveModel} (routed: ${routerConfig.complexity}, ${effectiveMaxSteps} steps, multiplier: ${agentConfigData.maxStepsMultiplier}x)`)
- // Track overall request timing for stats
const requestStartTime = Date.now()
const stream = createUIMessageStream({
@@ -231,7 +227,6 @@ export default defineEventHandler(async (event) => {
log.info('chat', `[${requestId}] Step ${stepCount}: response (${stepDurationMs}ms)`)
}
- // Reset timer for next step
stepStartTime = Date.now()
},
onFinish: (result) => {
@@ -272,11 +267,10 @@ export default defineEventHandler(async (event) => {
const totalDurationMs = Date.now() - requestStartTime
await db.insert(schema.messages).values(responseMessages.map((message: UIMessage) => ({
- id: message.id, // Preserve the ID from the streaming response
+ id: message.id,
chatId: chat.id,
role: message.role as 'user' | 'assistant',
parts: message.parts,
- // Stats fields for assistant messages
...(message.role === 'assistant' && {
model: effectiveModel,
inputTokens: totalInputTokens,
@@ -286,7 +280,6 @@ export default defineEventHandler(async (event) => {
})))
const dbDurationMs = Date.now() - dbStartTime
- // Persist sandbox session for reuse across all chats
const currentSessionId = savoir.getSessionId()
if (currentSessionId) {
await kv.set(KV_KEYS.ACTIVE_SANDBOX_SESSION, currentSessionId)
diff --git a/apps/chat/shared/types/tool-call.ts b/apps/chat/shared/types/tool-call.ts
new file mode 100644
index 0000000..58ade52
--- /dev/null
+++ b/apps/chat/shared/types/tool-call.ts
@@ -0,0 +1,22 @@
+export interface CommandResult {
+ command: string
+ stdout: string
+ stderr: string
+ exitCode: number
+ success: boolean
+}
+
+export interface ToolExecutionResult {
+ commands: CommandResult[]
+ success: boolean
+ durationMs: number
+ error?: string
+}
+
+export interface ToolCall {
+ toolCallId: string
+ toolName: string
+ args: Record<string, unknown>
+ state: 'loading' | 'done' | 'error'
+ result?: ToolExecutionResult
+}