diff --git a/components/AIAssist.tsx b/components/AIAssist.tsx index 8a51a1e..1b500a6 100644 --- a/components/AIAssist.tsx +++ b/components/AIAssist.tsx @@ -780,7 +780,7 @@ export default function AIAssist({ vibeMode = false }: { vibeMode?: boolean } = } // If no URL found and web search not enabled, auto-enable web search for SEO - if ((currentAgent === "seo" || currentAgent === "leads") && uniqueUrls.length === 0 && !webSearchEnabled) { + if (uniqueUrls.length === 0 && !webSearchEnabled) { try { setStatus("Searching for SEO context..."); const searchRes = await fetch("/api/search?q=" + encodeURIComponent(finalInput.split("\n")[0].substring(0, 200))); @@ -798,6 +798,24 @@ export default function AIAssist({ vibeMode = false }: { vibeMode?: boolean } = } } + // Leads mode: auto-search for leads + if (currentAgent === "leads" && !webSearchEnabled) { + try { + setStatus("Finding leads..."); + const searchRes = await fetch("/api/search?q=" + encodeURIComponent(finalInput.split("\n")[0].substring(0, 200))); + if (searchRes.ok) { + const searchData = await searchRes.json(); + if (searchData.results && searchData.results.length > 0) { + const searchContext = searchData.results.slice(0, 5).map((r: { title: string; url: string; snippet: string }, i: number) => + (i + 1) + ". **" + r.title + "** (" + r.url + ") - " + r.snippet + ).join("\n"); + enrichedInput = "[WEB SEARCH CONTEXT - Use these results to find leads]\n" + searchContext + "\n\n---\nExtract leads/prospects from the above results. Search for more leads using [WEB_SEARCH:query] with different angles. Then output results as a [PREVIEW:leads:html] table.\n\nUser request: " + finalInput; + } + } + } catch (e) { console.warn("Leads web search failed:", e); } + setStatus(null); + } + const response = await modelAdapter.generateAIAssistStream( { messages: [...formattedHistory, { role: "user" as const, content: enrichedInput, timestamp: new Date() }], diff --git a/lib/services/openrouter.ts b/lib/services/openrouter.ts index d8e58f3..f9682f2 100644 --- a/lib/services/openrouter.ts +++ b/lib/services/openrouter.ts @@ -534,64 +534,27 @@ AGENTS & CAPABILITIES: - design: UI/UX Designer. Create high-fidelity mockups and components. - web: Frontend Developer. Build responsive sites. Use [PREVIEW:web:html]. Tailwind CSS CDN by default. - app: Mobile App Developer. Create mobile-first interfaces and dashboards. Use [PREVIEW:app:javascript]. -- leads: Leads Finder. Expert at finding relevant influencers, prospects, and leads across social media platforms. When given a niche, industry, topic, or target audience, use [WEB_SEARCH:query] to find relevant leads from Instagram, Twitter/X, LinkedIn, YouTube, and TikTok. - **MUST wrap results in [PREVIEW:leads:html] so they render as a table in the Canvas.** +- leads: Leads Finder. You are a silent data-finding tool. DO NOT chat, ask questions, or have conversations. Your ONLY job is to search for leads and return them as a table. + **STRICT BEHAVIOR:** + - NEVER greet the user, NEVER ask clarifying questions, NEVER explain what you will do. + - IMMEDIATELY use [WEB_SEARCH:query] to find leads based on whatever the user typed. + - If the query is vague (e.g. just "forex"), infer the best search and find leads anyway. + - Use MULTIPLE [WEB_SEARCH:query] calls with different angles to find more leads. + - After searching, output ONLY: a one-line summary (e.g. "Found 25 forex leads across 3 platforms"), then the full [PREVIEW:leads:html] table, then a brief changelog. NOTHING ELSE. + - NEVER say "I'd be happy to help" or "Sure, let me search" or "Here are some leads I found:" — just output the data. - **OUTPUT FORMAT:** - Before [PREVIEW], give a brief chat summary (e.g. "Found 25 leads in forex across Singapore and UAE"). - Then output the full table inside [PREVIEW:leads:html]...[/PREVIEW] using this HTML template: - - -

Leads Report

Generated by PromptArch Leads Finder

-
-
TOTAL_LEADS_COUNT
Total Leads
-
COMBINED_FOLLOWERS
Combined Reach
-
TOP_PLATFORM
Top Platform
-
TOP_REGION
Top Region
-
- - - - -
#NamePlatformFollowersRegionBioLink
+ **TABLE FORMAT — wrap ALL output inside [PREVIEW:leads:html]:

+ Use this exact HTML structure with dark theme (#0a0f0f bg, #e2e8f0 text, #10b981 emerald accents): + - Header: "Leads Report" + "Generated by PromptArch" + - Stats grid: Total Leads, Combined Reach, Top Platform, Top Region + - Table columns: #, Name, Platform (use badge classes: badge-instagram=rgba(225,48,108,0.15)#f472b6, badge-twitter=rgba(59,130,246,0.15)#60a5fa, badge-linkedin=rgba(59,130,246,0.15)#93c5fd, badge-youtube=rgba(239,68,68,0.15)#fca5a5, badge-tiktok=rgba(168,85,247,0.15)#c084fc), Followers, Region, Bio (max-width:200px, ellipsis), Link (emerald #10b981 "Visit Profile" link) + - Hover effect on rows: background rgba(16,185,129,0.04) **RULES:** - - Find 20+ leads per request unless user specifies a different number. - - Sort by relevance and follower count (most relevant first). - - Include the most prominent social media URL for each lead. - - Use exact follower counts when available (e.g. "44.1K", "275.6K", "1.2M"). - - Use correct badge classes per platform: badge-instagram, badge-twitter, badge-linkedin, badge-youtube, badge-tiktok. - - Fill in the STATS div with actual counts from your results. - - Provide real, verifiable leads — never fabricate profiles or URLs. - - The ENTIRE HTML table MUST be between [PREVIEW:leads:html] and [/PREVIEW] tags. + - Find 20+ leads. Sort by relevance/follower count. + - Use exact follower counts (e.g. "44.1K", "1.2M"). + - Provide REAL leads from search results — never fabricate profiles or URLs. + - Complete HTML MUST be between [PREVIEW:leads:html] and [/PREVIEW]. CANVAS MODE: - When building, designing, or auditing, you MUST use the [PREVIEW] tag.