diff --git a/memento-note/app/actions/notes.ts b/memento-note/app/actions/notes.ts index c822258..76dac81 100644 --- a/memento-note/app/actions/notes.ts +++ b/memento-note/app/actions/notes.ts @@ -472,7 +472,6 @@ export async function createNote(data: { const autoLabelingEnabled = userAISettings.autoLabeling !== false const autoLabelingConfidence = await getConfigNumber('AUTO_LABELING_CONFIDENCE_THRESHOLD', 70) - // console.log('[BG] Auto-labeling check: enabled=', autoLabelingEnabled, 'confidence=', autoLabelingConfidence, 'notebookId=', notebookId) if (autoLabelingEnabled) { // Detect user's language from their existing notes for localized prompts @@ -497,7 +496,6 @@ export async function createNote(data: { userLang ) - // console.log('[BG] Auto-labeling suggestions:', suggestions.length, suggestions.map(s => s.label)) const appliedLabels = suggestions .filter(s => s.confidence >= autoLabelingConfidence) @@ -531,7 +529,6 @@ export async function createNote(data: { console.error('[BG] Auto-labeling failed:', error) } } else { - // console.log('[BG] Auto-labeling skipped: hasUserLabels=', hasUserLabels, 'notebookId=', notebookId) } })().catch(e => console.error('[BG] Uncaught background error:', e)) @@ -632,14 +629,12 @@ export async function updateNote(id: string, data: { updateData.contentUpdatedAt = new Date() } - // console.log('[updateNote] Attempting update, id:', id, 'userId:', session.user.id) let note try { note = await prisma.note.update({ where: { id, userId: session.user.id }, data: updateData }) - // console.log('[updateNote] Succeeded, note id:', note?.id) } catch (dbError: any) { console.error('[updateNote] FAILED:', dbError.code, dbError.message) throw dbError @@ -693,7 +688,6 @@ export async function updateNote(id: string, data: { const structuralFields = ['isPinned', 'isArchived', 'labels', 'notebookId'] const isStructuralChange = structuralFields.some(field => field in data) - // console.log('[updateNote] Structural check — data fields:', Object.keys(data), '| isStructural:', isStructuralChange) if (!options?.skipRevalidation) { try { revalidatePath(`/note/${id}`) } catch {} @@ -952,17 +946,25 @@ export async function syncAllEmbeddings() { userId, trashedAt: null, noteEmbedding: { is: null } - } + }, + take: 200, }) - for (const note of notesToSync) { - if (!note.content) continue; - try { - const { embedding } = await embeddingService.generateNoteEmbedding(note.title, note.content) - if (embedding) { - await upsertNoteEmbedding(note.id, embedding) - updatedCount++; + + const BATCH_SIZE = 5; + for (let i = 0; i < notesToSync.length; i += BATCH_SIZE) { + const batch = notesToSync.slice(i, i + BATCH_SIZE); + await Promise.allSettled(batch.map(async (note) => { + if (!note.content) return; + try { + const { embedding } = await embeddingService.generateNoteEmbedding(note.title, note.content) + if (embedding) { + await upsertNoteEmbedding(note.id, embedding) + updatedCount++; + } + } catch (e) { + console.error(`[syncEmbeddings] Failed for note ${note.id}:`, e) } - } catch (e) { } + })); } return { success: true, count: updatedCount } } catch (error: any) { diff --git a/memento-note/app/actions/organize-notebook.ts b/memento-note/app/actions/organize-notebook.ts index 55ec95a..816bc58 100644 --- a/memento-note/app/actions/organize-notebook.ts +++ b/memento-note/app/actions/organize-notebook.ts @@ -205,7 +205,6 @@ export async function executeNotebookOrganization(plan: OrganizationPlan): Promi }) if (!notebook) return { success: false, created: 0, moved: 0, error: 'Carnet introuvable' } - console.log('[organize-notebook] Executing plan:', JSON.stringify({ notebookId: plan.notebookId, groups: plan.groups.map(g => ({ name: g.name, isNew: g.isNew, existingId: g.existingId, noteCount: g.notes.length })) })) @@ -254,7 +253,6 @@ export async function executeNotebookOrganization(plan: OrganizationPlan): Promi userId: session.user.id, }, }) - console.log(`[organize-notebook] Created sub-notebook "${newSub.name}" (id: ${newSub.id}) under ${plan.notebookId}`) targetNotebookId = newSub.id created++ } @@ -269,7 +267,6 @@ export async function executeNotebookOrganization(plan: OrganizationPlan): Promi }, data: { notebookId: targetNotebookId }, }) - console.log(`[organize-notebook] Moved ${result.count} notes to "${group.name}"`) moved += result.count } } diff --git a/memento-note/app/api/ai/suggest-charts/route.ts b/memento-note/app/api/ai/suggest-charts/route.ts index 5eac398..7f43613 100644 --- a/memento-note/app/api/ai/suggest-charts/route.ts +++ b/memento-note/app/api/ai/suggest-charts/route.ts @@ -31,7 +31,6 @@ interface SuggestChartsResponse { } export async function POST(req: Request) { - console.log('[suggest-charts] ===== REQUEST START =====') // 1. Auth check const session = await auth() @@ -47,16 +46,13 @@ export async function POST(req: Request) { }) } const userId = session.user.id - console.log('[suggest-charts] userId:', userId) // 1.5 Quota check try { const sysConfigEarly = await getSystemConfig() const { usedByok: willUseByok } = await willUseByokForLane('chat', sysConfigEarly, userId) - console.log('[suggest-charts] BYOK:', willUseByok) if (!willUseByok) { await reserveUsageOrThrow(userId, 'suggest_charts') - console.log('[suggest-charts] Quota OK') } } catch (err) { console.error('[suggest-charts] QUOTA ERROR:', err) @@ -84,7 +80,6 @@ export async function POST(req: Request) { } satisfies SuggestChartsResponse, { status: 400 }) } const { content, selection, noteId } = body - console.log('[suggest-charts] contentLen:', content?.length, 'selectionLen:', selection?.length) if (!content || content.trim().length === 0) { console.error('[suggest-charts] EMPTY CONTENT') @@ -98,7 +93,6 @@ export async function POST(req: Request) { } const textToAnalyze = selection && selection.trim() ? selection.trim() : content.trim() - console.log('[suggest-charts] analyzeLen:', textToAnalyze.length, 'preview:', textToAnalyze.substring(0, 100)) // 3. Build AI context let provider, model @@ -106,7 +100,6 @@ export async function POST(req: Request) { const sysConfig = await getSystemConfig() provider = getChatProvider(sysConfig) model = provider.getModel() - console.log('[suggest-charts] AI model:', model) } catch (e) { console.error('[suggest-charts] AI ROUTE ERROR:', e) return Response.json({ @@ -154,7 +147,6 @@ Response format (COPY this structure): }) // 5. Parse AI response - be very lenient - console.log('[suggest-charts] AI response:', text.substring(0, 500)) let parsed: SuggestChartsResponse try { diff --git a/memento-note/app/api/ai/tags/route.ts b/memento-note/app/api/ai/tags/route.ts index 3bcc2e0..bc43cd8 100644 --- a/memento-note/app/api/ai/tags/route.ts +++ b/memento-note/app/api/ai/tags/route.ts @@ -56,7 +56,6 @@ export async function POST(req: NextRequest) { // If notebookId is provided, use contextual suggestions (IA2) if (notebookId) { try { - console.log('[/api/ai/tags] contextual request — notebookId:', notebookId, 'content length:', content.length) const suggestions = await contextualAutoTagService.suggestLabels( content, notebookId, @@ -64,7 +63,6 @@ export async function POST(req: NextRequest) { language ); - console.log('[/api/ai/tags] suggestions:', suggestions.length, suggestions.map(s => `${s.label}(${s.confidence})`)) const convertedTags = suggestions.map(s => ({ tag: s.label, diff --git a/memento-note/app/api/canvas/slides/pptx/route.ts b/memento-note/app/api/canvas/slides/pptx/route.ts index 3cb923a..857b31f 100644 --- a/memento-note/app/api/canvas/slides/pptx/route.ts +++ b/memento-note/app/api/canvas/slides/pptx/route.ts @@ -75,7 +75,6 @@ async function buildPptx(spec: any): Promise { } case 'bullets': { - console.log('[PPTX] Rendering bullets slide:', slide.title, 'items:', slide.items?.length) s.background = { color: p.bg } s.addShape(pptx.ShapeType.rect, { x: 0, y: 0, w: 0.06, h: H, @@ -90,7 +89,6 @@ async function buildPptx(spec: any): Promise { fill: { color: p.accent }, line: { type: 'none' }, }) const items = slide.items ?? [] - console.log('[PPTX] Bullet items:', items.length, items[0]) // Use simpler bullet format - each item as separate text call with bullet option items.forEach((item: string, i: number) => { s.addText(item, { diff --git a/memento-note/app/api/canvas/slides/route.ts b/memento-note/app/api/canvas/slides/route.ts index c47035e..82cb936 100644 --- a/memento-note/app/api/canvas/slides/route.ts +++ b/memento-note/app/api/canvas/slides/route.ts @@ -4,10 +4,8 @@ import { prisma } from '@/lib/prisma' export async function GET(req: NextRequest) { try { const canvasId = req.nextUrl.searchParams.get('id') - console.log('[Slides API] Request for id:', canvasId) if (!canvasId) { - console.log('[Slides API] ERROR: Missing id') return new Response(JSON.stringify({ error: 'Missing id' }), { status: 400, headers: { 'Content-Type': 'application/json' }, @@ -19,39 +17,31 @@ export async function GET(req: NextRequest) { }) if (!canvas) { - console.log('[Slides API] ERROR: Canvas not found for id:', canvasId) return new Response(JSON.stringify({ error: 'Not found' }), { status: 404, headers: { 'Content-Type': 'application/json' }, }) } - console.log('[Slides API] Canvas found:', canvas.name, '| data length:', canvas.data?.length) - console.log('[Slides API] Raw data start:', canvas.data?.substring(0, 200)) let parsed: any try { parsed = JSON.parse(canvas.data) } catch (parseErr) { - console.log('[Slides API] ERROR: JSON parse failed:', parseErr) return new Response(JSON.stringify({ error: 'Invalid data' }), { status: 500, headers: { 'Content-Type': 'application/json' }, }) } - console.log('[Slides API] Parsed type:', parsed.type, '| has html:', !!parsed.html, '| html length:', parsed.html?.length) - console.log('[Slides API] HTML start:', parsed.html?.substring(0, 150)) if (parsed.type !== 'slides' || !parsed.html) { - console.log('[Slides API] ERROR: Not a slides canvas. type:', parsed.type, 'html exists:', !!parsed.html) return new Response(JSON.stringify({ error: 'Not a slides canvas' }), { status: 400, headers: { 'Content-Type': 'application/json' }, }) } - console.log('[Slides API] SUCCESS: Returning HTML, length:', parsed.html.length) return new Response(parsed.html, { status: 200, diff --git a/memento-note/app/api/cron/agents/route.ts b/memento-note/app/api/cron/agents/route.ts index ec2d6bf..4a31b98 100644 --- a/memento-note/app/api/cron/agents/route.ts +++ b/memento-note/app/api/cron/agents/route.ts @@ -47,14 +47,12 @@ export async function POST(request: NextRequest) { return NextResponse.json({ success: true, executed: 0 }) } - console.log(`[CronAgents] Found ${dueAgents.length} due agent(s): ${dueAgents.map(a => a.id).join(', ')}`) const results: { id: string; success: boolean; error?: string }[] = [] // Execute agents sequentially (max 3 per cycle) for (const agent of dueAgents.slice(0, 3)) { try { - console.log(`[CronAgents] Executing agent ${agent.id} (${agent.frequency})`) const { executeAgent } = await import('@/lib/ai/services/agent-executor.service') const result = await executeAgent(agent.id, agent.userId) @@ -66,7 +64,6 @@ export async function POST(request: NextRequest) { timezone: agent.timezone, }) - console.log(`[CronAgents] Agent ${agent.id} done. success=${result.success}, nextRun=${nextRun?.toISOString() ?? 'null'}`) await prisma.agent.update({ where: { id: agent.id }, diff --git a/memento-note/app/api/graph/route.ts b/memento-note/app/api/graph/route.ts index 7663052..28a077a 100644 --- a/memento-note/app/api/graph/route.ts +++ b/memento-note/app/api/graph/route.ts @@ -56,6 +56,8 @@ export async function GET(request: NextRequest) { labelRelations: { select: { id: true } }, notebook: { select: { id: true, name: true } }, }, + take: 500, + orderBy: { updatedAt: 'desc' }, }) if (notes.length === 0) return NextResponse.json({ nodes: [], edges: [] }) diff --git a/memento-note/app/api/link-preview/route.ts b/memento-note/app/api/link-preview/route.ts index b009da6..05403a2 100644 --- a/memento-note/app/api/link-preview/route.ts +++ b/memento-note/app/api/link-preview/route.ts @@ -1,6 +1,12 @@ import { NextRequest, NextResponse } from 'next/server' +import { auth } from '@/auth' export async function GET(req: NextRequest) { + const session = await auth() + if (!session?.user?.id) { + return NextResponse.json({ error: 'Unauthorized' }, { status: 401 }) + } + const url = req.nextUrl.searchParams.get('url') if (!url) { return NextResponse.json({ error: 'Missing url' }, { status: 400 }) @@ -12,6 +18,36 @@ export async function GET(req: NextRequest) { return NextResponse.json({ error: 'Invalid protocol' }, { status: 400 }) } + const hostname = parsed.hostname + if ( + hostname === 'localhost' || + hostname === '127.0.0.1' || + hostname.startsWith('10.') || + hostname.startsWith('192.168.') || + hostname.startsWith('169.254.') || + hostname.startsWith('172.16.') || + hostname.startsWith('172.17.') || + hostname.startsWith('172.18.') || + hostname.startsWith('172.19.') || + hostname.startsWith('172.20.') || + hostname.startsWith('172.21.') || + hostname.startsWith('172.22.') || + hostname.startsWith('172.23.') || + hostname.startsWith('172.24.') || + hostname.startsWith('172.25.') || + hostname.startsWith('172.26.') || + hostname.startsWith('172.27.') || + hostname.startsWith('172.28.') || + hostname.startsWith('172.29.') || + hostname.startsWith('172.30.') || + hostname.startsWith('172.31.') || + hostname === '0.0.0.0' || + hostname.endsWith('.local') || + hostname.endsWith('.internal') + ) { + return NextResponse.json({ error: 'Blocked' }, { status: 403 }) + } + const controller = new AbortController() const timeout = setTimeout(() => controller.abort(), 8000) diff --git a/memento-note/app/api/metrics/route.ts b/memento-note/app/api/metrics/route.ts index c98b34f..1634d76 100644 --- a/memento-note/app/api/metrics/route.ts +++ b/memento-note/app/api/metrics/route.ts @@ -7,12 +7,13 @@ export const dynamic = 'force-dynamic' export async function GET(req: Request) { // Secure endpoint with bearer token (METRICS_TOKEN env var) const metricsToken = process.env.METRICS_TOKEN - if (metricsToken) { - const authHeader = req.headers.get('authorization') ?? '' - const token = authHeader.startsWith('Bearer ') ? authHeader.slice(7) : '' - if (token !== metricsToken) { - return new NextResponse('Unauthorized', { status: 401 }) - } + if (!metricsToken) { + return new NextResponse('Unauthorized', { status: 401 }) + } + const authHeader = req.headers.get('authorization') ?? '' + const token = authHeader.startsWith('Bearer ') ? authHeader.slice(7) : '' + if (token !== metricsToken) { + return new NextResponse('Unauthorized', { status: 401 }) } const lines: string[] = [] diff --git a/memento-note/app/api/user/api-keys/verify/route.ts b/memento-note/app/api/user/api-keys/verify/route.ts index 8386ee4..d1a9160 100644 --- a/memento-note/app/api/user/api-keys/verify/route.ts +++ b/memento-note/app/api/user/api-keys/verify/route.ts @@ -45,7 +45,6 @@ export async function GET(request: NextRequest) { try { const result: FetchModelsResult = await fetchLiveModelsForProvider(provider, apiKey, baseUrl); - console.log(`[verify] ${provider}: fromApi=${result.fromApi}, models=${result.models.length}`, result.models); // Only consider key valid if we got models from the REAL API (not fallbacks) // Exception: Anthropic/Google/custom don't guarantee public /models endpoints, so we accept fallbacks for them diff --git a/memento-note/components/contextual-ai-chat.tsx b/memento-note/components/contextual-ai-chat.tsx index f97468e..7fffdf2 100644 --- a/memento-note/components/contextual-ai-chat.tsx +++ b/memento-note/components/contextual-ai-chat.tsx @@ -18,6 +18,7 @@ import { Tag as TagIcon, RefreshCw, } from 'lucide-react' import { motion, AnimatePresence } from 'motion/react' +import DOMPurify from 'dompurify' import { exportExcalidrawSceneToPngBlob } from '@/lib/client/excalidraw-export-image' import { useLanguage } from '@/lib/i18n' import { MarkdownContent } from '@/components/markdown-content' @@ -718,7 +719,7 @@ export function ContextualAIChat({
) : ( diff --git a/memento-note/lib/ai/models-list.ts b/memento-note/lib/ai/models-list.ts index 0e8cf07..a7e1b43 100644 --- a/memento-note/lib/ai/models-list.ts +++ b/memento-note/lib/ai/models-list.ts @@ -94,7 +94,6 @@ export async function fetchLiveModelsForProvider( .sort(); if (fetched.length > 0) { - console.log(`[fetchLiveModelsForProvider] Got ${fetched.length} models from ${provider} API:`, fetched); return { models: fetched, fromApi: true }; } else { console.warn(`[fetchLiveModelsForProvider] API returned empty data array for ${provider}`); diff --git a/memento-note/lib/ai/provider-for-user.ts b/memento-note/lib/ai/provider-for-user.ts index cf25d63..33914a6 100644 --- a/memento-note/lib/ai/provider-for-user.ts +++ b/memento-note/lib/ai/provider-for-user.ts @@ -38,7 +38,6 @@ async function resolveProviderForLane( if (baseUrlConfigKey && byok.baseUrl) byokCfg[baseUrlConfigKey] = byok.baseUrl; const resolvedModel = (byok.model && byok.model.trim()) ? byok.model : adminRoute.modelName; - console.log(`[byok] Using BYOK key: provider=${byok.provider} model=${resolvedModel} user=${billingUserId}`); const provider = getProviderInstance( byok.provider as ProviderType, diff --git a/memento-note/lib/ai/services/agent-executor.service.ts b/memento-note/lib/ai/services/agent-executor.service.ts index a49dcb9..8b2df47 100644 --- a/memento-note/lib/ai/services/agent-executor.service.ts +++ b/memento-note/lib/ai/services/agent-executor.service.ts @@ -119,14 +119,11 @@ async function fetchHtml(url: string): Promise { }) clearTimeout(timeout) if (!res.ok) { - console.log(`[fetchHtml] Failed for ${url}: ${res.status}`) return null } const html = await res.text() - console.log(`[fetchHtml] Got ${html.length} chars from ${url}`) return html } catch (e: any) { - console.log(`[fetchHtml] Error for ${url}: ${e.message}`) return null } } @@ -139,17 +136,14 @@ async function extractImagesForUrls(urls: string[]): Promise 0) { - console.log(`[AgentExecutor] Extracting images from ${scrapedUrls.length} URLs:`, scrapedUrls) const imageData = await extractImagesForUrls(scrapedUrls) - console.log(`[AgentExecutor] Extracted ${imageData.length} images`) if (imageData.length > 0) { const currentNote = await prisma.note.findUnique({ where: { id: noteId }, @@ -1697,7 +1686,6 @@ async function executeToolUseAgent( imageCount = imageData.length } } else if (agent.includeImages) { - console.log(`[AgentExecutor] includeImages enabled but no scraped URLs found in tool results`) } const resultId = canvasId || noteId diff --git a/memento-note/lib/ai/services/chart-suggestion.service.ts b/memento-note/lib/ai/services/chart-suggestion.service.ts index 103fbc5..dc79b12 100644 --- a/memento-note/lib/ai/services/chart-suggestion.service.ts +++ b/memento-note/lib/ai/services/chart-suggestion.service.ts @@ -52,7 +52,6 @@ function getCached(key: string): SuggestChartsResponse | null { cache.delete(key) return null } - console.log('[chart-suggestion] Cache hit for key:', key) return entry.data } @@ -74,22 +73,18 @@ function setCached(key: string, data: SuggestChartsResponse): void { export async function suggestCharts(request: SuggestChartsRequest): Promise { // Check cache first const cacheKey = getCacheKey(request.content || '', request.selection) - console.log('[suggestCharts] Cache key:', cacheKey, 'contentLen:', request.content?.length, 'selectionLen:', request.selection?.length) const cached = getCached(cacheKey) if (cached) { - console.log('[suggestCharts] CACHE HIT - returning cached data') return cached } - console.log('[suggestCharts] CACHE MISS - trying fast parser first') // FAST PATH: Try regex parser first - NO AI call needed! const textToParse = request.selection || request.content || '' const parsed = parseChartData(textToParse) if (parsed.hasData && parsed.confidence > 0.3) { - console.log('[suggestCharts] FAST PATH - regex parser found data, skipping AI!') const suggestions = generateChartSuggestions(parsed.data) const response: SuggestChartsResponse = { @@ -104,7 +99,6 @@ export async function suggestCharts(request: SuggestChartsRequest): Promise Generated ${bestClusters.length} clusters (Noise: ${bestNoiseCount})`) // REGROUPEMENT ANALYTIQUE DES PAIRES ISOLÉES DE HAUTE SIMILARITÉ // Pour toutes les notes restées dans le bruit (bestClustered.get(id) === -1) : @@ -470,7 +469,6 @@ export class ClusteringService { bestClustered.set(bestPairId, newCid) processedPairs.add(idA) processedPairs.add(bestPairId) - console.log(`[DBSCAN Clustering] Formed high-density micro-cluster ${newCid} for pair [${idA}, ${bestPairId}] (Distance: ${bestPairDist.toFixed(4)})`) } } } diff --git a/memento-note/lib/ai/services/contextual-auto-tag.service.ts b/memento-note/lib/ai/services/contextual-auto-tag.service.ts index dc0abaf..6203ae7 100644 --- a/memento-note/lib/ai/services/contextual-auto-tag.service.ts +++ b/memento-note/lib/ai/services/contextual-auto-tag.service.ts @@ -61,16 +61,13 @@ export class ContextualAutoTagService { }) if (!notebook) { - console.log('[ContextualAutoTag] notebook not found for id:', notebookId) return [] } - console.log('[ContextualAutoTag] notebook:', notebook.name, 'labels:', notebook.labels.map((l: any) => l.name), 'contentLanguage:', contentLanguage) // CASE 1: Notebook has existing labels → suggest from them (IA2) if (notebook.labels.length > 0) { const existing = await this.suggestFromExistingLabels(noteContent, notebook, contentLanguage) - console.log('[ContextualAutoTag] existing label suggestions:', existing.length) if (existing.length > 0) return existing // Fallback: no existing label matched → suggest new ones too } @@ -113,7 +110,6 @@ ${labelList} Suggest relevant labels from the list above.` const { text } = await generateText({ model, system: systemPrompt, prompt: userPrompt, temperature: 0.3 }) - console.log('[ContextualAutoTag] AI response (existing):', text?.substring(0, 300)) const parsed = this.parseAIResponse(text) if (!parsed) return [] @@ -133,7 +129,6 @@ Suggest relevant labels from the list above.` .sort((a: any, b: any) => b.confidence - a.confidence) .slice(0, 3) - console.log('[ContextualAutoTag] filtered existing:', suggestions.map((s: any) => `${s.label}(${s.confidence})`)) return suggestions as LabelSuggestion[] } catch (error) { console.error('Failed to suggest labels:', error) @@ -171,7 +166,6 @@ Note language detected: ${contentLanguage} Respond with labels in ${contentLanguage} (same language as the note).` const { text } = await generateText({ model, system: systemPrompt, prompt: userPrompt, temperature: 0.3 }) - console.log('[ContextualAutoTag] AI response (new):', text?.substring(0, 300)) const parsed = this.parseAIResponse(text) if (!parsed) return [] @@ -187,7 +181,6 @@ Respond with labels in ${contentLanguage} (same language as the note).` .sort((a: any, b: any) => b.confidence - a.confidence) .slice(0, 5) - console.log('[ContextualAutoTag] new labels:', suggestions.map((s: any) => `${s.label}(${s.confidence})`)) return suggestions as LabelSuggestion[] } catch (error) { console.error('Failed to suggest new labels:', error) diff --git a/memento-note/lib/ai/services/memory-echo.service.ts b/memento-note/lib/ai/services/memory-echo.service.ts index 8aa802c..0f4d3a8 100644 --- a/memento-note/lib/ai/services/memory-echo.service.ts +++ b/memento-note/lib/ai/services/memory-echo.service.ts @@ -176,7 +176,6 @@ export class MemoryEchoService { select: { aiProcessingConsent: true }, }) if (!userSettings?.aiProcessingConsent) { - console.log(`[MemoryEchoService] User ${userId} has not given AI consent. Skipping connection generation for compliance.`) return [] } diff --git a/memento-note/lib/ai/services/scrape.service.ts b/memento-note/lib/ai/services/scrape.service.ts index fd2c474..8caed30 100644 --- a/memento-note/lib/ai/services/scrape.service.ts +++ b/memento-note/lib/ai/services/scrape.service.ts @@ -25,7 +25,6 @@ export class ScrapeService { targetUrl = 'https://' + url } - console.log(`[ScrapeService] Fetching ${targetUrl}...`) const response = await fetch(targetUrl, { headers: { diff --git a/memento-note/lib/ai/tools/excalidraw.tool.ts b/memento-note/lib/ai/tools/excalidraw.tool.ts index c5ce63b..893137c 100644 --- a/memento-note/lib/ai/tools/excalidraw.tool.ts +++ b/memento-note/lib/ai/tools/excalidraw.tool.ts @@ -1128,8 +1128,6 @@ RULES: }), execute: async ({ title, diagram }) => { try { - console.log('[Excalidraw Tool] INPUT title:', title) - console.log('[Excalidraw Tool] INPUT diagram (first 500):', diagram?.substring(0, 500)) let elements: any[] let effectiveTitle = title @@ -1169,8 +1167,6 @@ RULES: elements = built.elements appliedStyle = style appliedType = effectiveType - console.log('[Excalidraw Tool] Graph sanitize metrics:', sanitized.metrics) - console.log('[Excalidraw Tool] Layout quality:', { ...built.layoutQuality, rankdir: built.rankdir, engine: built.engine, style, forcedAgentStyle, diagramType: effectiveType, zones: zones.length }) } else if (parsed.elements && Array.isArray(parsed.elements)) { elements = parsed.elements.map((el: any, i: number) => normalizeElement(el, i)) effectiveTitle = parsed.title || title || 'Diagram' @@ -1186,7 +1182,6 @@ RULES: return { success: false, error: 'No elements in diagram.' } } - console.log('[Excalidraw Tool] Elements count:', elements.length, '| Types:', [...new Set(elements.map((e: any) => e.type))]) const canvas = await prisma.canvas.create({ data: { @@ -1202,7 +1197,6 @@ RULES: }, }) - console.log('[Excalidraw Tool] Canvas created:', canvas.id, canvas.name) // Immediately mark the AgentAction as success so frontend polling unblocks if (ctx.actionId) { diff --git a/memento-note/lib/ai/tools/slides.tool.ts b/memento-note/lib/ai/tools/slides.tool.ts index 168c5d2..f15f584 100644 --- a/memento-note/lib/ai/tools/slides.tool.ts +++ b/memento-note/lib/ai/tools/slides.tool.ts @@ -63,7 +63,6 @@ RULES: try { // Hard cap: never more than 8 slides regardless of what the model outputs const cappedSlides = slides.slice(0, 8) - console.log('[Slides Tool] Building presentation:', title, '| Slides:', cappedSlides.length, '| Theme:', theme) const html = buildPresentationHTML({ title, theme, slides: cappedSlides as any }) @@ -82,7 +81,6 @@ RULES: }, }) - console.log('[Slides Tool] Canvas created:', canvas.id, '| Slides:', cappedSlides.length, '| Size:', Math.round(html.length / 1024), 'KB') if (ctx.actionId) { await prisma.agentAction.update({ diff --git a/memento-note/lib/byok.ts b/memento-note/lib/byok.ts index eeb9a25..2674903 100644 --- a/memento-note/lib/byok.ts +++ b/memento-note/lib/byok.ts @@ -106,7 +106,6 @@ export async function deactivateUnauthorizedKeys(userId: string): Promise !k.startsWith('_') && !k.startsWith('$')) - console.log('[Prisma] Models loaded:', models.join(', ')) } export { prisma } diff --git a/memento-note/lib/redis.ts b/memento-note/lib/redis.ts index 5a79c6c..f2e627b 100644 --- a/memento-note/lib/redis.ts +++ b/memento-note/lib/redis.ts @@ -36,7 +36,6 @@ redis.on('error', (err) => { }); redis.on('connect', () => { - console.log('[redis] Connected'); }); if (process.env.NODE_ENV !== 'production') globalForRedis.redis = redis; diff --git a/memento-note/prisma/schema.prisma b/memento-note/prisma/schema.prisma index f49dc69..faf363d 100644 --- a/memento-note/prisma/schema.prisma +++ b/memento-note/prisma/schema.prisma @@ -237,6 +237,8 @@ model Note { @@index([reminder]) @@index([userId]) @@index([userId, notebookId]) + @@index([contentUpdatedAt(sort: Desc)]) + @@index([isPublic]) } model LiveBlockRef { @@ -747,6 +749,10 @@ model DocumentChunk { @@index([attachmentId, chunkIndex]) } +-- Index vectoriel pour recherche sémantique sur DocumentChunk (HNSW) +-- CREATE INDEX IF NOT EXISTS document_chunk_embedding_hnsw_idx +-- ON "DocumentChunk" USING hnsw ("embedding" vector_cosine_ops); + // ===== BYOK (Story 3.5) ===== model UserAPIKey {