${esc(f.title)} ${esc(f.severity)}
` + `` + (f.suggested_human_action ? `Acção: ${esc(f.suggested_human_action)}
` : '') + `(function () { const esc = (s) => String(s ?? '').replace(/&/g,'&').replace(//g,'>'); async function api(path, opts = {}) { const h = { ...(opts.headers || {}), 'Content-Type': 'application/json' }; const t = window.DeskAuth?.getToken?.(); if (t) h.Authorization = `Bearer ${t}`; const r = await fetch(`/api/v1/agents${path}`, { ...opts, headers: h }); if (!r.ok) { const err = await r.text(); throw new Error(`${r.status} ${err.slice(0, 200)}`); } return r.json(); } async function sendChat(question) { return api('/chat', { method: 'POST', body: JSON.stringify({ question, include_findings: true }) }); } async function renderAgenticOps() { const el = document.getElementById('agentic-ops-content'); if (!el) return; el.innerHTML = '
Carregando Agentic Ops…
'; try { const [health, scenarios, findings, log] = await Promise.all([ api('/health'), api('/scenarios'), api('/findings?limit=30'), api('/action-log?limit=40'), ]); const tier = health.tier === 't1' ? 'T1 LLM' : 'T0'; const ollama = health.ollama ? `Ollama OK · ${esc(health.model || '')}` : 'Ollama offline — modo T0'; const sRows = (scenarios.scenarios || []).map(s => `${esc(s.id)}Acção: ${esc(f.suggested_human_action)}
` : '') + `Sem findings abertos.
'; const lRows = (log.events || []).map(e => `${esc(e.event_type)}| ID | Título | Último | Quando |
|---|
| Quando | Evento | Mensagem |
|---|
A pensar…
'; try { const res = await sendChat(q); out.innerHTML = `Resposta
${esc(res.answer)}
`; } catch (err) { out.innerHTML = `${esc(err.message)}
`; } }); } catch (err) { el.innerHTML = `Erro: ${esc(err.message)}
`; } } window.renderAgenticOps = renderAgenticOps; })();