"use client"; import { useState, useEffect } from "react"; interface ResearchResult { title: string; url: string; score: number; content: string; } interface Research { id: string; name: string; query: string; results_count: number; created_at: string; saved: boolean; summary: string; results?: ResearchResult[]; } export default function MissionResearchPage() { const [research, setResearch] = useState([]); const [loading, setLoading] = useState(true); const [newResearch, setNewResearch] = useState({ name: "", query: "" }); const [searching, setSearching] = useState(false); const [expanded, setExpanded] = useState(null); useEffect(() => { fetchResearch(); }, []); const fetchResearch = async () => { setLoading(true); try { const res = await fetch("/api/research"); const data = await res.json(); setResearch(data); } catch (e) { console.error(e); } setLoading(false); }; const handleSearch = async () => { if (!newResearch.name || !newResearch.query) return; setSearching(true); try { const tavilyRes = await fetch('https://api.tavily.com/search', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ api_key: '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', query: newResearch.query, max_results: 20, search_depth: 'advanced' }) }); const tavilyData = await tavilyRes.json(); const results = (tavilyData.results || []).map((r: any) => ({ title: r.title || 'No title', url: r.url || '', score: r.score || 0, content: (r.content || '').substring(0, 400) })); const summary = results.slice(0, 5).map((r: any) => r.title).join('; ') || 'No results'; const res = await fetch("/api/research", { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ name: newResearch.name, query: newResearch.query, results_count: results.length, summary: summary.substring(0, 150), results: results }) }); await res.json(); setNewResearch({ name: "", query: "" }); fetchResearch(); } catch (e) { console.error(e); } setSearching(false); }; const deleteResearch = async (id: string) => { try { await fetch(`/api/research?id=${id}`, { method: "DELETE" }); fetchResearch(); } catch (e) { console.error(e); } }; return (

🔒 Security Rule: Never install skills from the web. Read the content, understand what it does, then BUILD IT yourself. We build, we don't install. One compromised skill can wipe everything.

🔍 Deep Research

{/* Search Form */}
setNewResearch({ ...newResearch, name: e.target.value })} className="bg-gray-700 text-white px-4 py-2 rounded" /> setNewResearch({ ...newResearch, query: e.target.value })} className="bg-gray-700 text-white px-4 py-2 rounded" />
{/* Research List */} {loading ? (

Loading...

) : research.length === 0 ? (

No research yet. Run your first search!

) : (
{research.map((r) => (
{/* Header */}

{r.name}

{r.query}

{/* Table View */} {expanded === r.id && r.results && (
{r.results.map((result, i) => ( ))}
Skill / Tool What It Does Score Link
{result.title} {result.content.substring(0, 150)}... 0.9 ? 'bg-green-900 text-green-400' : result.score > 0.7 ? 'bg-yellow-900 text-yellow-400' : 'bg-gray-700 text-gray-400' }`}> {(result.score * 100).toFixed(1)}% Open →
)}
))}
)}
); }