/* === agents-achados.jsx ==============================================
PreviewAgents (with tabs + library + video demos)
PreviewAchados (saved analyses with filters)
===================================================================== */
const AGENT_TAG_COLORS = {
alertas: { bg: '#FEE2E2', fg: '#991B1B', label: 'Alertas' },
priorizador: { bg: '#FEF3C7', fg: '#92400E', label: 'Priorizador' },
insights: { bg: '#DBEAFE', fg: '#1E40AF', label: 'Insights' },
autonomos: { bg: '#D1FAE5', fg: '#065F46', label: 'Autônomos' },
};
/* ==================================================================
AGENTS — main screen with Agentes / Biblioteca tabs
================================================================== */
function PreviewAgents({ state, onSetState }) {
const a = state.agents;
const setA = (patch) => onSetState({
...state,
agents: { ...a, ...(typeof patch === 'function' ? patch(a) : patch) }
});
const [showVideo, setShowVideo] = React.useState(null);
return (
Agentes
Automatize análises recorrentes com agentes inteligentes
{a.activeTab === 'agentes'
?
:
}
{showVideo &&
setShowVideo(null)} />}
{a.showNewTemplate && }
);
}
/* ============ AGENTES TAB ============ */
function AgentesTab({ state, setA, onPlayVideo }) {
const a = state.agents;
const filtered = a.active.filter(ag => a.filter === 'all' || ag.category === a.filter);
return (
<>
Agentes Autônomos P2P ({filtered.length})
>
);
}
function AgentCard({ agent, state, setA, onPlay }) {
const tag = AGENT_TAG_COLORS[agent.category] || AGENT_TAG_COLORS.insights;
const [editingVideo, setEditingVideo] = React.useState(false);
const updateAgent = (patch) => {
setA(curr => ({
...curr,
active: curr.active.map(a => a.id === agent.id ? { ...a, ...patch } : a),
}));
};
return (
{agent.status === 'live' ? 'Ao vivo' : agent.status === 'paused' ? 'Pausada' : 'Rascunho'}
{tag.label}
{(agent.tags || []).map(t => (
{t}
))}
{agent.demoVideo ? (
) : (
Sem vídeo demo
)}
{' · '}
{' ações'}
{editingVideo && (
)}
);
}
function AgentVideoModal({ video, onClose }) {
return (
e.stopPropagation()}>
{video.name}
Demo gravado · {video.lastRun} · {video.actions} ações
{video.demoVideo && (
)}
{video.prompt && (
Prompt do agente
{video.prompt}
)}
);
}
/* ============ BIBLIOTECA TAB ============ */
function BibliotecaTab({ state, setA }) {
const a = state.agents;
return (
<>
{a.library.map(group => (
{group.category.toUpperCase()} ({group.items.length})
{group.items.map(item => )}
))}
>
);
}
function TemplateCard({ item }) {
const tag = AGENT_TAG_COLORS[item.tag] || AGENT_TAG_COLORS.insights;
return (
);
}
function FilterChips({ state, setA }) {
const a = state.agents;
return (
{a.availableTags.map(t => (
))}
);
}
function NewTemplateForm({ state, setA }) {
const [form, setForm] = React.useState({ name: '', desc: '', category: 'autonomos', tags: 'p2p', prompt: '' });
const close = () => setA({ showNewTemplate: false });
const publish = () => {
if (!form.name.trim()) return;
const id = 'tpl-' + Date.now().toString(36);
const cat = state.agents.library.find(g => g.category === 'P2P') || state.agents.library[0];
setA(curr => ({
...curr,
showNewTemplate: false,
library: curr.library.map(g => g === cat
? { ...g, items: [{ id, name: form.name, desc: form.desc, tag: form.category }, ...g.items] }
: g),
}));
};
return (
e.stopPropagation()}>
Novo Template para Biblioteca
Cria um agente reutilizável para qualquer prospect.
);
}
/* ==================================================================
ACHADOS — saved analyses
================================================================== */
function PreviewAchados({ state, onSetState }) {
const ach = state.achados;
const setAch = (patch) => onSetState({
...state,
achados: { ...ach, ...(typeof patch === 'function' ? patch(ach) : patch) }
});
const [search, setSearch] = React.useState('');
const filtered = ach.items.filter(it => {
if (ach.filter !== 'all' && ach.filter !== 'Todos' && it.category !== ach.filter) return false;
if (search && !it.title.toLowerCase().includes(search.toLowerCase())) return false;
return true;
});
const removeItem = (id) => setAch(curr => ({ ...curr, items: curr.items.filter(i => i.id !== id) }));
return (
Achados
Salve análises importantes direto do chat para encontrá-las aqui.
{filtered.map(item => (
{item.type}
·
{item.preview && (
{' · '}
)}
{item.category && (
{item.category}
)}
))}
{filtered.length === 0 && (
Nenhum achado para esse filtro.
)}
);
}
Object.assign(window, { PreviewAgents, PreviewAchados });