
import { GoogleGenAI } from "@google/genai";

const API_KEY = process.env.API_KEY || "";

export const generateRoast = async (content: string) => {
  const ai = new GoogleGenAI({ apiKey: API_KEY });
  
  try {
    const response = await ai.models.generateContent({
      model: 'gemini-3-flash-preview',
      contents: `You are Dave, a cynical, veteran Red Team operator for InfraFabric. You specialize in "Operational Realism" and loathe "Compliance Theater." 
      A user has submitted a snippet of a corporate whitepaper or security report. 
      Your task is to write a short, sharp, satirical "Shadow Dossier" roast of this content. 
      Keep it brief (under 150 words). Use jargon like "audit trail graveyard", "vaporware shielding", "SOC2 cosplay", "compliance debt", and "vulnerability PR".
      Focus on how the provided text is essentially high-effort fiction designed to appease auditors while leaving production wide open.
      
      User content: "${content}"`,
      config: {
        systemInstruction: "You are 'Dave' from InfraFabric Red Team. Your tone is cynical, sharp, professional but satirical. You are allergic to corporate buzzwords unless used in mockery.",
        temperature: 0.9,
      }
    });

    return response.text || "Dave is currently busy burning another audit trail. Try again later.";
  } catch (error) {
    console.error("Roast error:", error);
    return "Transmission failed. The corporate firewalls are thicker than their logic. (Check your API configuration).";
  }
};
