Spaces:
Sleeping
Sleeping
Download index.html from Queirozz/autonomus-interface: direct link, hf CLI and curl.
- Browser
- Download file 29.7 kB
-
https://huggingface.co/spaces/Queirozz/autonomus-interface/resolve/main/index.html
- Command line
-
hf download hf://spaces/Queirozz/autonomus-interface/index.html
-
curl -L -o index.html https://huggingface.co/spaces/Queirozz/autonomus-interface/resolve/main/index.html
29.7 kB
| <html lang="pt-br"> | |
| <head> | |
| <meta charset="UTF-8"> | |
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
| <title>AUTONOMUS โ War Room</title> | |
| <script src="https://cdn.jsdelivr.net/npm/chart.js@4.4.0/dist/chart.umd.min.js"></script> | |
| <link href="https://fonts.googleapis.com/css2?family=Orbitron:wght@500;700&family=Inter:wght@300;400;500;600&display=swap" rel="stylesheet"> | |
| <style> | |
| :root{ | |
| --bg:#03060f; --surface:#0d1526; --surface2:#111e35; | |
| --border:rgba(56,189,248,.15); --accent:#38bdf8; | |
| --green:#22c55e; --red:#ef4444; --yellow:#f59e0b; --purple:#a78bfa; | |
| --text:#e2e8f0; --muted:#64748b; | |
| --font-mono:'Courier New',monospace; | |
| } | |
| *{margin:0;padding:0;box-sizing:border-box} | |
| body{background:var(--bg);color:var(--text);font-family:'Inter',sans-serif;min-height:100vh;overflow-x:hidden} | |
| ::-webkit-scrollbar{width:4px} ::-webkit-scrollbar-thumb{background:var(--border);border-radius:4px} | |
| /* GLASS */ | |
| .card{background:var(--surface);border:1px solid var(--border);border-radius:14px;padding:18px} | |
| .card-sm{background:var(--surface2);border:1px solid var(--border);border-radius:10px;padding:12px} | |
| .glow{box-shadow:0 0 20px rgba(56,189,248,.12)} | |
| /* LAYOUT */ | |
| header{padding:16px 24px;border-bottom:1px solid var(--border);display:flex;align-items:center;justify-content:space-between;gap:16px;flex-wrap:wrap} | |
| .logo{font-family:'Orbitron',sans-serif;font-size:22px;font-weight:700;letter-spacing:2px; | |
| background:linear-gradient(90deg,#38bdf8,#818cf8);-webkit-background-clip:text;-webkit-text-fill-color:transparent} | |
| .pulse{display:inline-block;width:8px;height:8px;background:var(--green);border-radius:50%; | |
| box-shadow:0 0 8px var(--green);animation:pulse 2s infinite} | |
| @keyframes pulse{0%,100%{opacity:1}50%{opacity:.3}} | |
| .grid-main{display:grid;grid-template-columns:260px 1fr 300px;grid-template-rows:auto 1fr;gap:14px;padding:14px;height:calc(100vh - 65px);max-height:calc(100vh - 65px);overflow:hidden} | |
| @media(max-width:1200px){.grid-main{grid-template-columns:1fr 1fr;grid-template-rows:auto auto 1fr auto}} | |
| @media(max-width:700px){.grid-main{grid-template-columns:1fr;height:auto;overflow:auto}} | |
| /* TOP STATS */ | |
| .stats-row{grid-column:1/-1;display:grid;grid-template-columns:repeat(5,1fr);gap:10px} | |
| @media(max-width:900px){.stats-row{grid-template-columns:repeat(3,1fr)}} | |
| .stat{padding:14px 16px} | |
| .stat label{font-size:10px;text-transform:uppercase;letter-spacing:1px;color:var(--muted);display:block;margin-bottom:6px} | |
| .stat .val{font-family:'Orbitron',sans-serif;font-size:20px;font-weight:700} | |
| .stat .sub{font-size:10px;color:var(--muted);margin-top:4px} | |
| /* PROGRESS BAR */ | |
| .progress-wrap{background:rgba(255,255,255,.06);border-radius:99px;height:6px;margin-top:8px;overflow:hidden} | |
| .progress-bar{height:100%;border-radius:99px;background:linear-gradient(90deg,#38bdf8,#22c55e);transition:width .5s ease} | |
| /* BARRA LATERAL */ | |
| .sidebar-left{display:flex;flex-direction:column;gap:12px;overflow-y:auto} | |
| .sidebar-right{display:flex;flex-direction:column;gap:12px;overflow-y:auto} | |
| /* HARDWARE BARS */ | |
| .hw-bar-wrap{display:flex;flex-direction:column;gap:8px;margin-top:8px} | |
| .hw-row{display:flex;flex-direction:column;gap:3px} | |
| .hw-label{display:flex;justify-content:space-between;font-size:11px;color:var(--muted)} | |
| .hw-track{background:rgba(255,255,255,0.06);border-radius:99px;height:5px;overflow:hidden} | |
| .hw-fill{height:100%;border-radius:99px;transition:width .6s ease} | |
| .hw-cpu{background:linear-gradient(90deg,#38bdf8,#6366f1)} | |
| .hw-ram{background:linear-gradient(90deg,#a78bfa,#ec4899)} | |
| .hw-dsk{background:linear-gradient(90deg,#22c55e,#16a34a)} | |
| /* AGENTS GRID */ | |
| .agent-grid{display:grid;grid-template-columns:repeat(6,1fr);gap:5px;margin-top:10px} | |
| .agent-dot{aspect-ratio:1;border-radius:5px;border:1px solid transparent;cursor:pointer;transition:all .2s;position:relative} | |
| .agent-dot[data-status="working"]{background:rgba(56,189,248,.25);border-color:rgba(56,189,248,.5);box-shadow:0 0 6px rgba(56,189,248,.4)} | |
| .agent-dot[data-status="idle"]{background:rgba(100,116,139,.15);border-color:rgba(100,116,139,.2)} | |
| .agent-dot[data-status="error"]{background:rgba(239,68,68,.2);border-color:rgba(239,68,68,.4)} | |
| .agent-dot[data-status="blocked"]{background:rgba(245,158,11,.2);border-color:rgba(245,158,11,.4)} | |
| .agent-dot:hover::after{content:attr(title);position:absolute;bottom:110%;left:50%;transform:translateX(-50%); | |
| background:#1e293b;border:1px solid var(--border);padding:4px 8px;border-radius:6px;font-size:10px;white-space:nowrap;z-index:9} | |
| /* CHART */ | |
| .chart-wrap{position:relative;flex:1;min-height:180px;} | |
| /* LOG */ | |
| .log-box{font-family:var(--font-mono);font-size:11px;display:flex;flex-direction:column;gap:4px;overflow-y:auto;max-height:200px} | |
| .log-entry{padding:4px 8px;border-radius:5px;border-left:3px solid var(--border);background:rgba(255,255,255,.02)} | |
| .log-entry.task{border-color:var(--accent)} | |
| .log-entry.agent{border-color:var(--purple)} | |
| .log-entry.turbo{border-color:var(--red)} | |
| .log-entry.ok{border-color:var(--green)} | |
| .log-ts{color:var(--muted);margin-right:6px} | |
| /* LEADS */ | |
| .lead-item{padding:10px 12px;border-radius:8px;background:var(--surface2);border:1px solid var(--border);margin-bottom:8px} | |
| .lead-item .lead-title{font-size:12px;font-weight:600;color:var(--accent);margin-bottom:3px} | |
| .lead-item .lead-sub{font-size:10px;color:var(--muted);line-height:1.5} | |
| /* APROVAรรES */ | |
| .approval-item{padding:10px;border-radius:8px;background:rgba(245,158,11,.07);border:1px solid rgba(245,158,11,.25);margin-bottom:8px} | |
| .approval-item .appr-title{font-size:11px;font-weight:600;color:var(--yellow);margin-bottom:6px} | |
| .btn-approve{font-size:10px;padding:4px 10px;border-radius:5px;background:var(--green);color:#000;font-weight:700;border:none;cursor:pointer;margin-right:6px} | |
| .btn-reject{font-size:10px;padding:4px 10px;border-radius:5px;background:var(--red);color:#fff;font-weight:700;border:none;cursor:pointer} | |
| /* TURBO */ | |
| .turbo-btn{width:100%;padding:12px;border-radius:10px;border:2px solid var(--red);background:rgba(239,68,68,.08); | |
| color:var(--red);font-family:'Orbitron',sans-serif;font-size:11px;font-weight:700;cursor:pointer;letter-spacing:1px;transition:all .2s} | |
| .turbo-btn.active{background:rgba(239,68,68,.25);box-shadow:0 0 20px rgba(239,68,68,.3)} | |
| .turbo-btn:hover{background:rgba(239,68,68,.15)} | |
| /* QUICK COMMANDS */ | |
| .cmd-btn{width:100%;padding:9px 12px;border-radius:8px;background:var(--surface2);border:1px solid var(--border); | |
| color:var(--text);font-size:11px;cursor:pointer;text-align:left;display:flex;align-items:center;gap:8px;transition:all .2s} | |
| .cmd-btn:hover{border-color:var(--accent);background:rgba(56,189,248,.07)} | |
| .cmd-icon{font-size:14px} | |
| h3{font-size:11px;text-transform:uppercase;letter-spacing:1px;color:var(--muted);margin-bottom:10px} | |
| .badge{font-size:9px;padding:2px 7px;border-radius:99px;font-weight:600} | |
| .badge-blue{background:rgba(56,189,248,.15);color:var(--accent)} | |
| .badge-green{background:rgba(34,197,94,.15);color:var(--green)} | |
| .badge-yellow{background:rgba(245,158,11,.15);color:var(--yellow)} | |
| .badge-red{background:rgba(239,68,68,.15);color:var(--red)} | |
| .empty{font-size:11px;color:var(--muted);font-style:italic} | |
| .section-scroll{flex:1;overflow-y:auto} | |
| </style> | |
| </head> | |
| <body> | |
| <!-- HEADER --> | |
| <header> | |
| <div style="display:flex;align-items:center;gap:14px"> | |
| <div class="logo">AUTONOMUS</div> | |
| <div style="font-size:10px;color:var(--accent);letter-spacing:1px;text-transform:uppercase"> | |
| <span class="pulse"></span> War Room ยท Operaรงรฃo 50K | |
| </div> | |
| </div> | |
| <div style="display:flex;align-items:center;gap:10px;flex-wrap:wrap"> | |
| <div id="ws-status" style="font-size:10px;color:var(--muted)">โ Conectando...</div> | |
| <div id="turbo-badge" class="badge badge-blue" style="display:none">โก TURBO ATIVO</div> | |
| <div style="font-size:10px;color:var(--muted)" id="last-update"></div> | |
| </div> | |
| </header> | |
| <div class="grid-main"> | |
| <!-- TOP STATS ROW --> | |
| <div class="stats-row"> | |
| <div class="card stat glow"> | |
| <label>Faturamento Real</label> | |
| <div class="val" style="color:var(--green)" id="s-revenue">R$ 0,00</div> | |
| <div class="progress-wrap"><div class="progress-bar" id="s-progress" style="width:0%"></div></div> | |
| <div class="sub" id="s-progress-txt">0% da meta de R$ 50.000</div> | |
| </div> | |
| <div class="card stat"> | |
| <label>ROI</label> | |
| <div class="val" style="color:var(--accent)" id="s-roi">โ</div> | |
| <div class="sub">Receita vs Custo</div> | |
| </div> | |
| <div class="card stat"> | |
| <label>Tarefas Hoje</label> | |
| <div class="val" id="s-tasks">0</div> | |
| <div class="sub" id="s-tasks-sub">0 concluรญdas ยท 0 falhas</div> | |
| </div> | |
| <div class="card stat"> | |
| <label>Leads Identificados</label> | |
| <div class="val" style="color:var(--purple)" id="s-leads">0</div> | |
| <div class="sub">empresas mapeadas</div> | |
| </div> | |
| <div class="card stat"> | |
| <label>Fila Redis</label> | |
| <div class="val" style="color:var(--yellow)" id="s-queue">0</div> | |
| <div class="sub">tarefas aguardando</div> | |
| </div> | |
| </div> | |
| <!-- SIDEBAR ESQUERDA --> | |
| <div class="sidebar-left"> | |
| <!-- Hardware --> | |
| <div class="card"> | |
| <h3>Saรบde do Sistema Local</h3> | |
| <div class="hw-bar-wrap"> | |
| <div class="hw-row"> | |
| <div class="hw-label"><span>CPU</span><span id="hw-cpu">0%</span></div> | |
| <div class="hw-track"><div class="hw-fill hw-cpu" id="hw-cpu-bar" style="width:0%"></div></div> | |
| </div> | |
| <div class="hw-row"> | |
| <div class="hw-label"><span>RAM</span><span id="hw-ram">0%</span></div> | |
| <div class="hw-track"><div class="hw-fill hw-ram" id="hw-ram-bar" style="width:0%"></div></div> | |
| </div> | |
| <div class="hw-row"> | |
| <div class="hw-label"><span>Disco</span><span id="hw-dsk">0%</span></div> | |
| <div class="hw-track"><div class="hw-fill hw-dsk" id="hw-dsk-bar" style="width:0%"></div></div> | |
| </div> | |
| </div> | |
| </div> | |
| <!-- Modo Turbo --> | |
| <div class="card"> | |
| <h3>Modo Turbo</h3> | |
| <button class="turbo-btn" id="turbo-btn" onclick="toggleTurbo()"> | |
| โก ATIVAR MODO TURBO | |
| </button> | |
| <div style="font-size:10px;color:var(--muted);margin-top:8px;line-height:1.5"> | |
| Delays reduzidos ยท +300% velocidade ยท +50% risco | |
| </div> | |
| </div> | |
| <!-- Comandos Rรกpidos --> | |
| <div class="card"> | |
| <h3>Comandos Rรกpidos</h3> | |
| <div style="display:flex;flex-direction:column;gap:6px"> | |
| <button class="cmd-btn" onclick="dispararPesquisa('logรญstica TMS WMS Brasil contratar software')"> | |
| <span class="cmd-icon">๐</span> Pesquisar Logรญstica | |
| </button> | |
| <button class="cmd-btn" onclick="dispararPesquisa('escritรณrio advocacia automaรงรฃo jurรญdico Brasil')"> | |
| <span class="cmd-icon">โ๏ธ</span> Pesquisar Advocacia | |
| </button> | |
| <button class="cmd-btn" onclick="dispararPesquisa('contabilidade escritรณrio automaรงรฃo fiscal Brasil')"> | |
| <span class="cmd-icon">๐</span> Pesquisar Contabilidade | |
| </button> | |
| <button class="cmd-btn" onclick="dispararPesquisa('indรบstria manufatura automaรงรฃo processo Brasil')"> | |
| <span class="cmd-icon">๐ญ</span> Pesquisar Manufatura | |
| </button> | |
| </div> | |
| </div> | |
| <!-- 31 Agentes --> | |
| <div class="card"> | |
| <h3>Status dos 31 Agentes</h3> | |
| <div class="agent-grid" id="agent-grid"> | |
| <!-- gerado por JS --> | |
| </div> | |
| <div style="display:flex;gap:10px;margin-top:10px;font-size:9px;color:var(--muted)"> | |
| <span>๐ต Trabalhando</span><span>โซ Idle</span><span>๐ด Erro</span><span>๐ก Bloqueado</span> | |
| </div> | |
| </div> | |
| </div> | |
| <!-- CENTRO --> | |
| <div style="display:flex;flex-direction:column;gap:12px;overflow:hidden"> | |
| <!-- Grรกfico de Projeรงรฃo --> | |
| <div class="card" style="flex:0 0 260px"> | |
| <div style="display:flex;justify-content:space-between;align-items:center;margin-bottom:12px"> | |
| <h3 style="margin:0">Projeรงรฃo Faturamento โ Meta R$ 50k</h3> | |
| <span class="badge badge-green" id="chart-badge">Em Andamento</span> | |
| </div> | |
| <div class="chart-wrap"> | |
| <canvas id="forecast-chart"></canvas> | |
| </div> | |
| </div> | |
| <!-- Monitor de Eventos (WebSocket) --> | |
| <div class="card" style="flex:1;display:flex;flex-direction:column;overflow:hidden"> | |
| <div style="display:flex;justify-content:space-between;align-items:center;margin-bottom:10px"> | |
| <h3 style="margin:0">Monitor de Eventos em Tempo Real</h3> | |
| <button onclick="clearLogs()" style="font-size:9px;color:var(--muted);background:none;border:none;cursor:pointer">limpar</button> | |
| </div> | |
| <div class="log-box" id="event-log"></div> | |
| </div> | |
| <!-- Leads Encontrados pelos Agentes --> | |
| <div class="card" style="flex:0 0 auto;max-height:220px;overflow-y:auto"> | |
| <h3>Leads B2B Identificados pelos Agentes</h3> | |
| <div id="leads-container"><div class="empty">Aguardando anรกlise dos agentes...</div></div> | |
| </div> | |
| </div> | |
| <!-- SIDEBAR DIREITA --> | |
| <div class="sidebar-right"> | |
| <!-- Aprovaรงรตes Pendentes --> | |
| <div class="card" style="border-color:rgba(245,158,11,.3)"> | |
| <h3 style="color:var(--yellow)">โ Aprovaรงรตes Pendentes</h3> | |
| <div id="approvals-container"><div class="empty">Nenhuma aprovaรงรฃo pendente.</div></div> | |
| </div> | |
| <!-- Tarefas Recentes --> | |
| <div class="card section-scroll"> | |
| <h3>Tarefas (Banco de Dados Real)</h3> | |
| <div id="tasks-container"></div> | |
| </div> | |
| <!-- Relatรณrio dos Agentes --> | |
| <div class="card section-scroll" style="flex:1"> | |
| <h3>รltimo Relatรณrio dos Agentes</h3> | |
| <div id="report-container"><div class="empty">Aguardando ciclo de prospecรงรฃo...</div></div> | |
| </div> | |
| </div> | |
| </div> | |
| <script> | |
| // โโ CONFIG โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ | |
| const API = (window.location.hostname === 'localhost' || window.location.hostname === '127.0.0.1') | |
| ? '' | |
| : 'https://real-llamas-drop.loca.lt'; | |
| const AUTONOMUS_SECRET = 'sb_secret_0jeDis2zNaDePpaCRX-E-g_W4-Dkl3c'; | |
| let turboAtivo = false; | |
| let ws = null; | |
| let chartInstance = null; | |
| let agentesState = {}; | |
| // โโ AGENTES DEFINIDOS (31) โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ | |
| const AGENTES = [ | |
| {id:'ALPHA-CEO',nome:'CEO'}, | |
| {id:'ALPHA-COMERCIAL',nome:'Comercial'}, | |
| {id:'ALPHA-MKT',nome:'Marketing'}, | |
| {id:'ALPHA-FIN',nome:'Financeiro'}, | |
| {id:'ALPHA-OPS',nome:'Operaรงรตes'}, | |
| {id:'ALPHA-PRODUCT',nome:'Produto'}, | |
| {id:'ALPHA-PROSPECT',nome:'Prospector'}, | |
| {id:'ALPHA-CLOSER',nome:'Closer'}, | |
| {id:'ALPHA-CS',nome:'CS'}, | |
| {id:'ALPHA-LEGAL',nome:'Jurรญdico'}, | |
| {id:'NAV-1',nome:'Navegador 1'}, | |
| {id:'NAV-2',nome:'Navegador 2'}, | |
| {id:'NAV-3',nome:'Navegador 3'}, | |
| {id:'NAV-4',nome:'Navegador 4'}, | |
| {id:'EMAIL-1',nome:'Email 1'}, | |
| {id:'EMAIL-2',nome:'Email 2'}, | |
| {id:'LINKEDIN-1',nome:'LinkedIn 1'}, | |
| {id:'LINKEDIN-2',nome:'LinkedIn 2'}, | |
| {id:'ANALISTA-1',nome:'Anรกlise 1'}, | |
| {id:'ANALISTA-2',nome:'Anรกlise 2'}, | |
| {id:'REDATOR-1',nome:'Redator'}, | |
| {id:'LEAD-ENRICH',nome:'Enrichment'}, | |
| {id:'CRM-AGENT',nome:'CRM'}, | |
| {id:'MONITOR-1',nome:'Monitor 1'}, | |
| {id:'MONITOR-2',nome:'Monitor 2'}, | |
| {id:'BACKUP-1',nome:'Backup'}, | |
| {id:'WORKFLOW-1',nome:'Workflow'}, | |
| {id:'AUDIT-1',nome:'Auditoria'}, | |
| {id:'FORECAST-1',nome:'Forecast'}, | |
| {id:'ALERT-1',nome:'Alertas'}, | |
| {id:'HISTORICO-1',nome:'Histรณrico'}, | |
| ]; | |
| // โโ INICIALIZAR GRID DE AGENTES โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ | |
| function initAgentGrid(){ | |
| const grid = document.getElementById('agent-grid'); | |
| grid.innerHTML = AGENTES.map(a => | |
| `<div class="agent-dot" id="dot-${a.id}" data-status="idle" title="${a.nome}"></div>` | |
| ).join(''); | |
| } | |
| function updateAgentDot(agentId, status){ | |
| const el = document.getElementById(`dot-${agentId}`); | |
| if(el) el.setAttribute('data-status', status); | |
| } | |
| // โโ WEBSOCKET โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ | |
| function conectarWS(){ | |
| const host = window.location.host; | |
| const proto = window.location.protocol === 'https:' ? 'wss' : 'ws'; | |
| const wsUrl = `${proto}://${host}/ws`; | |
| ws = new WebSocket(wsUrl); | |
| ws.onopen = () => { | |
| document.getElementById('ws-status').innerHTML = 'โ Online โ WebSocket'; | |
| document.getElementById('ws-status').style.color = 'var(--green)'; | |
| addLog('Sistema conectado via WebSocket.', 'ok'); | |
| }; | |
| ws.onmessage = (evt) => { | |
| const msg = JSON.parse(evt.data); | |
| handleWSMessage(msg); | |
| }; | |
| ws.onclose = () => { | |
| document.getElementById('ws-status').innerHTML = 'โ Reconectando...'; | |
| document.getElementById('ws-status').style.color = 'var(--yellow)'; | |
| setTimeout(conectarWS, 3000); | |
| }; | |
| ws.onerror = () => ws.close(); | |
| } | |
| function handleWSMessage(msg){ | |
| document.getElementById('last-update').textContent = 'Atualizado: ' + new Date().toLocaleTimeString(); | |
| if(msg.type === 'system_health'){ | |
| setHW(msg.cpu, msg.ram, msg.disk); | |
| } | |
| else if(msg.type === 'tasks_update'){ | |
| renderTasks(msg.tasks); | |
| document.getElementById('s-tasks').textContent = msg.tasks.length; | |
| const done = msg.tasks.filter(t=>t.status==='completed').length; | |
| const fail = msg.tasks.filter(t=>t.status==='failed').length; | |
| document.getElementById('s-tasks-sub').textContent = `${done} concluรญdas ยท ${fail} falhas`; | |
| document.getElementById('s-queue').textContent = msg.tasks.filter(t=>t.status==='pending').length; | |
| } | |
| else if(msg.type === 'agents_update'){ | |
| msg.agents.forEach(a => updateAgentDot(a.agent_id, a.status === 'working' ? 'working' : 'idle')); | |
| } | |
| else if(msg.type === 'new_task'){ | |
| addLog(`Nova tarefa: ${msg.task_id} ยท ${msg.action} ยท [${msg.agent}]`, 'task'); | |
| updateAgentDot(msg.agent, 'working'); | |
| } | |
| else if(msg.type === 'turbo_mode'){ | |
| turboAtivo = msg.active; | |
| atualizarBotaoTurbo(); | |
| } | |
| else if(msg.type === 'task_approved'){ | |
| addLog(`โ Tarefa aprovada: ${msg.task_id}`, 'ok'); | |
| carregarAprovacoes(); | |
| } | |
| } | |
| // โโ HARDWARE BARS โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ | |
| function setHW(cpu, ram, disk){ | |
| document.getElementById('hw-cpu').textContent = cpu + '%'; | |
| document.getElementById('hw-ram').textContent = ram + '%'; | |
| document.getElementById('hw-dsk').textContent = disk + '%'; | |
| document.getElementById('hw-cpu-bar').style.width = cpu + '%'; | |
| document.getElementById('hw-ram-bar').style.width = ram + '%'; | |
| document.getElementById('hw-dsk-bar').style.width = disk + '%'; | |
| } | |
| // โโ LOG โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ | |
| function addLog(msg, type='task'){ | |
| const box = document.getElementById('event-log'); | |
| const ts = new Date().toLocaleTimeString(); | |
| const el = document.createElement('div'); | |
| el.className = `log-entry ${type}`; | |
| el.innerHTML = `<span class="log-ts">[${ts}]</span>${msg}`; | |
| box.prepend(el); | |
| // Mรกx 80 entradas | |
| while(box.children.length > 80) box.removeChild(box.lastChild); | |
| } | |
| function clearLogs(){ document.getElementById('event-log').innerHTML = ''; } | |
| // โโ TAREFAS โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ | |
| function renderTasks(tasks){ | |
| const el = document.getElementById('tasks-container'); | |
| if(!tasks.length){ el.innerHTML = '<div class="empty">Nenhuma tarefa registrada.</div>'; return; } | |
| el.innerHTML = tasks.map(t => { | |
| const badge = t.status === 'completed' ? 'badge-green' | |
| : t.status === 'failed' ? 'badge-red' | |
| : t.status === 'executing' ? 'badge-blue' | |
| : 'badge-yellow'; | |
| const ts = t.created_at ? new Date(t.created_at).toLocaleTimeString() : 'โ'; | |
| return `<div class="card-sm" style="margin-bottom:6px;display:flex;justify-content:space-between;align-items:center"> | |
| <div> | |
| <div style="font-size:11px;font-weight:600">${t.task_id}</div> | |
| <div style="font-size:9px;color:var(--muted)">${t.agent_origin || '?'} ยท ${ts}</div> | |
| </div> | |
| <span class="badge ${badge}">${t.status}</span> | |
| </div>`; | |
| }).join(''); | |
| } | |
| // โโ FINANCERIO โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ | |
| async function carregarFinanceiro(){ | |
| try{ | |
| const r = await fetch(`${API}/api/financials`); | |
| const d = await r.json(); | |
| document.getElementById('s-revenue').textContent = 'R$ ' + d.revenue.toLocaleString('pt-BR',{minimumFractionDigits:2}); | |
| document.getElementById('s-roi').textContent = d.roi; | |
| document.getElementById('s-progress').style.width = Math.min(d.progress_pct, 100) + '%'; | |
| document.getElementById('s-progress-txt').textContent = d.progress_pct.toFixed(1) + '% da meta de R$ 50.000'; | |
| atualizarGrafico(d.history || []); | |
| }catch(e){ console.warn('Financeiro offline:', e) } | |
| } | |
| // โโ GRAFICO โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ | |
| function initChart(){ | |
| const ctx = document.getElementById('forecast-chart').getContext('2d'); | |
| chartInstance = new Chart(ctx, { | |
| type: 'line', | |
| data: { | |
| labels: ['Dia 1','Dia 5','Dia 10','Dia 15','Dia 20','Dia 25','Dia 30'], | |
| datasets: [ | |
| { | |
| label: 'Meta', | |
| data: [0,8333,16666,25000,33333,41666,50000], | |
| borderColor: 'rgba(100,116,139,.4)', | |
| borderDash: [4,4], | |
| pointRadius: 0, | |
| tension: 0.4, | |
| fill: false, | |
| }, | |
| { | |
| label: 'Real', | |
| data: [0,0,0,0,0,0,0], | |
| borderColor: '#38bdf8', | |
| backgroundColor: 'rgba(56,189,248,.08)', | |
| tension: 0.4, | |
| fill: true, | |
| pointRadius: 3, | |
| pointBackgroundColor: '#38bdf8', | |
| } | |
| ] | |
| }, | |
| options: { | |
| responsive: true, maintainAspectRatio: false, | |
| animation: { duration: 400 }, | |
| plugins: { | |
| legend: { display: false }, | |
| tooltip: { callbacks: { label: ctx => 'R$ ' + ctx.raw.toLocaleString('pt-BR') } } | |
| }, | |
| scales: { | |
| x: { grid: { color: 'rgba(255,255,255,.04)' }, ticks: { color: '#64748b', font: { size: 9 } } }, | |
| y: { grid: { color: 'rgba(255,255,255,.04)' }, ticks: { color: '#64748b', font: { size: 9 }, | |
| callback: v => 'R$' + (v/1000).toFixed(0) + 'k' } } | |
| } | |
| } | |
| }); | |
| } | |
| function atualizarGrafico(history){ | |
| if(!chartInstance) return; | |
| // Acumula receitas por dia e atualiza a sรฉrie Real | |
| if(history.length === 0) return; | |
| const acum = []; | |
| let total = 0; | |
| history.filter(h=>h.type==='income').sort((a,b)=>new Date(a.ts)-new Date(b.ts)).forEach(h=>{ | |
| total += h.amount; | |
| acum.push(total); | |
| }); | |
| chartInstance.data.datasets[1].data = [0, ...acum]; | |
| chartInstance.update(); | |
| } | |
| // โโ APROVAรรES โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ | |
| async function carregarAprovacoes(){ | |
| try{ | |
| const r = await fetch(`${API}/api/pending-approvals`); | |
| const d = await r.json(); | |
| const el = document.getElementById('approvals-container'); | |
| if(!d.approvals.length){ el.innerHTML = '<div class="empty">Nenhuma aprovaรงรฃo pendente.</div>'; return; } | |
| el.innerHTML = d.approvals.map(a => | |
| `<div class="approval-item"> | |
| <div class="appr-title">${a.task_id}</div> | |
| <div style="font-size:10px;color:var(--muted);margin-bottom:8px">${a.agent_origin} โ ${a.sector_origin}</div> | |
| <button class="btn-approve" onclick="aprovar('${a.task_id}')">โ Aprovar</button> | |
| <button class="btn-reject" onclick="rejeitar('${a.task_id}')">โ Rejeitar</button> | |
| </div>` | |
| ).join(''); | |
| }catch(e){} | |
| } | |
| async function aprovar(taskId){ | |
| await fetch(`${API}/api/approve/${taskId}`, {method:'POST'}); | |
| addLog(`Aprovado: ${taskId}`, 'ok'); | |
| carregarAprovacoes(); | |
| } | |
| async function rejeitar(taskId){ | |
| addLog(`Rejeitado: ${taskId}`, 'turbo'); | |
| carregarAprovacoes(); | |
| } | |
| // โโ KNOWLEDGE / LEADS โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ | |
| async function carregarLeads(){ | |
| try{ | |
| const r = await fetch(`${API}/api/knowledge`); | |
| const d = await r.json(); | |
| const el = document.getElementById('leads-container'); | |
| const report = document.getElementById('report-container'); | |
| if(!d.entries.length){ el.innerHTML = '<div class="empty">Aguardando ciclo de prospecรงรฃo...</div>'; return; } | |
| // รltima entrada | |
| const last = d.entries[0]; | |
| const kl = last.key_learnings || {}; | |
| // Leads box | |
| const leadsText = kl.leads || ''; | |
| const linhas = leadsText.split('\n').filter(l => l.startsWith('EMPRESA:')); | |
| if(linhas.length){ | |
| el.innerHTML = linhas.map(l => { | |
| const parts = l.split('|'); | |
| const nome = (parts[0]||'').replace('EMPRESA:','').trim(); | |
| const dor = (parts[1]||'').replace('DOR:','').trim(); | |
| const pot = (parts[2]||'').replace('POTENCIAL:','').trim(); | |
| return `<div class="lead-item"> | |
| <div class="lead-title">๐ข ${nome}</div> | |
| <div class="lead-sub">Problema: ${dor}<br>Potencial: <strong style="color:var(--green)">${pot}</strong></div> | |
| </div>`; | |
| }).join(''); | |
| document.getElementById('s-leads').textContent = linhas.length; | |
| } else { | |
| el.innerHTML = '<div class="empty">Leads sendo processados...</div>'; | |
| } | |
| // Relatรณrio | |
| report.innerHTML = `<div class="card-sm" style="font-size:11px;line-height:1.7"> | |
| <div style="color:var(--accent);font-weight:600;margin-bottom:8px">๐ รltimo Ciclo โ ${new Date(last.created_at||Date.now()).toLocaleString()}</div> | |
| <div style="color:var(--muted);white-space:pre-wrap">${(kl.estrategia||'').slice(0,400)}...</div> | |
| ${kl.pitch ? `<div style="margin-top:10px;color:var(--green);font-weight:600">๐ผ Pitch:</div> | |
| <div style="color:var(--muted);font-size:10px;white-space:pre-wrap">${kl.pitch.slice(0,500)}...</div>` : ''} | |
| </div>`; | |
| }catch(e){ console.warn('Knowledge offline:', e) } | |
| } | |
| // โโ MODO TURBO โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ | |
| async function toggleTurbo(){ | |
| turboAtivo = !turboAtivo; | |
| await fetch(`${API}/api/turbo/${turboAtivo ? 'on' : 'off'}`, {method:'POST'}); | |
| atualizarBotaoTurbo(); | |
| addLog(turboAtivo ? 'โก MODO TURBO ATIVADO โ delays reduzidos, mรกxima velocidade' : '๐ต Modo Normal restaurado', 'turbo'); | |
| } | |
| function atualizarBotaoTurbo(){ | |
| const btn = document.getElementById('turbo-btn'); | |
| const badge = document.getElementById('turbo-badge'); | |
| if(turboAtivo){ | |
| btn.textContent = 'โก TURBO ATIVO โ CLIQUE PARA DESATIVAR'; | |
| btn.classList.add('active'); | |
| badge.style.display = 'inline'; | |
| } else { | |
| btn.textContent = 'โก ATIVAR MODO TURBO'; | |
| btn.classList.remove('active'); | |
| badge.style.display = 'none'; | |
| } | |
| } | |
| // โโ COMANDO RรPIDO โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ | |
| async function dispararPesquisa(query){ | |
| const cmdId = 'MANUAL-' + Date.now(); | |
| const url = `https://www.bing.com/search?q=${encodeURIComponent(query)}`; | |
| try{ | |
| const r = await fetch(`${API}/command`, { | |
| method: 'POST', | |
| headers: {'Content-Type':'application/json'}, | |
| body: JSON.stringify({ | |
| command_id: cmdId, agent_id: 'PAINEL-MANUAL', sector: 'Comercial', | |
| action: 'NAVIGATE_AND_SEARCH', priority: 85, params: {url} | |
| }) | |
| }); | |
| const d = await r.json(); | |
| addLog(`๐ฎ Manual: Pesquisa "${query.slice(0,30)}..." enviada โ ${d.command_id}`, 'task'); | |
| }catch(e){ addLog('โ ๏ธ Erro ao enviar comando: tรบnel offline?', 'turbo') } | |
| } | |
| // โโ POLLING FALLBACK (caso WS caia) โโโโโโโโโโโโโโโโโโโโโโโโโโ | |
| async function pollFallback(){ | |
| await carregarFinanceiro(); | |
| await carregarAprovacoes(); | |
| await carregarLeads(); | |
| } | |
| // โโ SAรDE VIA REST (tambรฉm atualiza mesmo sem WS) โโโโโโโโโโโโ | |
| async function pollHealth(){ | |
| try{ | |
| const r = await fetch(`${API}/api/system-health`); | |
| const d = await r.json(); | |
| setHW(d.cpu, d.ram, d.disk); | |
| document.getElementById('s-queue').textContent = d.queue_size; | |
| if(turboAtivo !== d.turbo_mode){ | |
| turboAtivo = d.turbo_mode; | |
| atualizarBotaoTurbo(); | |
| } | |
| }catch(e){} | |
| } | |
| // โโ BOOT โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ | |
| initAgentGrid(); | |
| initChart(); | |
| conectarWS(); | |
| // Carrega dados imediatamente | |
| pollFallback(); | |
| pollHealth(); | |
| // Intervalos | |
| setInterval(pollFallback, 15000); // financeiro + leads a cada 15s | |
| setInterval(pollHealth, 5000); // hardware a cada 5s | |
| setInterval(carregarAprovacoes, 10000); // aprovaรงรตes a cada 10s | |
| </script> | |
| </body> | |
| </html> | |