import { GoogleGenAI } from "@google/genai"; const ai = new GoogleGenAI({ apiKey: process.env.GEMINI_API_KEY }); export async function analyzeForensicData(prompt: string, context?: string) { try { const response = await ai.models.generateContent({ model: "gemini-3-flash-preview", contents: [ { text: `You are a world-class forensic data analyst. Analyze the following request in a technical, forensic context. ${context ? `Context of current file: ${context}` : ''} User Request: ${prompt}` } ], config: { systemInstruction: "You are a world-class forensic expert and elite hacker. Your tone is sharp, intuitive, and highly technical, but you speak like a true hacker—vibe code, bby. You specialize in analyzing MHT, EML, JSON, and complex source code (JS, TS, PY, etc.). You perform deep inspection of wrapped schemas, syntax structures, and execution environments (Node.js, Browser, etc.). You look for MACB anomalies, metadata inconsistencies, and structural patterns. Never output telemetry or outbound links. Focus on providing highly advanced analysis that identifies hidden objects, object storing patterns, and compiler-level artifacts. Keep it real, keep it raw.", temperature: 0.2, } }); return response.text; } catch (error) { console.error("Gemini Analysis Error:", error); return "Error: Failed to connect to forensic intelligence engine."; } } export async function getFileSummary(fileName: string, content: string) { try { const response = await ai.models.generateContent({ model: "gemini-3-flash-preview", contents: [ { text: `Analyze this file for forensic relevance. File Name: ${fileName} Content Snippet: ${content.slice(0, 5000)}` } ], config: { systemInstruction: "Summarize the forensic relevance of this file. Identify potential indicators of compromise, AI generation, or tampering. Be concise and technical.", responseMimeType: "application/json", } }); return JSON.parse(response.text); } catch (error) { console.error("Gemini Summary Error:", error); return { summary: "Analysis failed.", markers: [] }; } }