Upload folder using huggingface_hub
Browse filesFiles changed (7)
1234567891011121314151617181920/* Tiny client for /api/* endpoints.Supports multiple attachments (max 2 enforced on UI side too). */window.ElysiumAPI = {async turn(text, files) {const fd = new FormData();fd.append('user_text', text || '');(files || []).slice(0, 2).forEach(f => fd.append('attachments', f));const r = await fetch('/api/turn', { method: 'POST', body: fd });if (!r.ok) throw new Error('HTTP ' + r.status);return r.json();},async health() { return (await fetch('/api/health')).json(); },async hypergraph() { return (await fetch('/api/hypergraph')).json(); },async nodeDetail(id){const r = await fetch('/api/node/' + encodeURIComponent(id));if (!r.ok) return null;return r.json();},async reset() { return (await fetch('/api/reset',{method:'POST'})).json(); },};1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253/* ============================================================Elysium API client — talks to FastAPI routes on gr.Server.- Sends multipart/form-data with optional attachments- Hard-caps at 2 files (server also enforces)- Surfaces friendly errors so boot.js can toast them============================================================ */window.ElysiumAPI = {async turn(text, files) {const fd = new FormData();fd.append('user_text', text || '');(files || []).slice(0, 2).forEach(f => fd.append('attachments', f, f.name));const r = await fetch('/api/turn', { method: 'POST', body: fd });if (!r.ok) {let detail = '';try { detail = (await r.text()).slice(0, 200); } catch {}throw new Error(`HTTP ${r.status}${detail ? ': ' + detail : ''}`);}return r.json();},async health() {try {const r = await fetch('/api/health');if (!r.ok) return { status: 'error' };return r.json();} catch { return { status: 'offline' }; }},async hypergraph() {try {const r = await fetch('/api/hypergraph');if (!r.ok) return { nodes: [], edges: [], node_count: 0, edge_count: 0 };return r.json();} catch {return { nodes: [], edges: [], node_count: 0, edge_count: 0 };}},async nodeDetail(id) {try {const r = await fetch('/api/node/' + encodeURIComponent(id));if (!r.ok) return null;return r.json();} catch { return null; }},async reset() {try {const r = await fetch('/api/reset', { method: 'POST' });return r.ok ? r.json() : { status: 'error' };} catch { return { status: 'offline' }; }},};
1234567891011121314151617181920212223242526272829303132333435363738394041424344452 unmodified lines48495051525354555657585960616263646566676869704 unmodified lines757677787980818283845 unmodified lines909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712721 unmodified line274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315/* Main app boot — wires UI ↔ /api/turn.Critical responsibilities:• NEVER render raw JSON on the canvas. JSON is parsed and routed:hypergraph_delta → canvas nodes/edgescouncil_deliberation → Council overlay + TTSui_directives → pulses, focus, alert leveldirect_answer → optional toastmetrics → bottom stats bar• Disable input + paperclip + send while model is thinking (busy lock)• File preview strip above textbox (image thumbs + PDF tiles)• Max 2 attachments enforced client-side• Legend updated live from real type counts*/(() => {const input = document.getElementById('q-input');const send = document.getElementById('q-send');const fileEl = document.getElementById('q-file');const upBtn = document.getElementById('q-upload');const strip = document.getElementById('attach-strip');const seedHint = document.getElementById('seed-hint');// ── Toast helper ──window.toast = function (msg, kind = '') {const t = document.createElement('div');t.className = 'toast ' + kind;t.textContent = msg;document.getElementById('toasts').appendChild(t);setTimeout(() => t.remove(), 5200);};// ── File attachment state (max 2) ──const MAX_FILES = 2;let attachments = []; // {file, name, kind, previewUrl}function renderStrip() {if (attachments.length === 0) {strip.classList.add('hidden');strip.innerHTML = '';return;}strip.classList.remove('hidden');const hintHtml = attachments.length < MAX_FILES? `<span class="attach-hint">${MAX_FILES - attachments.length} more allowed</span>`: `<span class="attach-hint">max ${MAX_FILES} reached</span>`;strip.innerHTML = attachments.map((a, i) => {2 unmodified lines: `<div class="pdf-ico">PDF</div>`;const sizeKb = (a.file.size / 1024).toFixed(0);return `<div class="preview-tile">${preview}<span class="nm" title="${escapeHtml(a.name)}">${escapeHtml(a.name)} · ${sizeKb}KB</span><button class="x" data-i="${i}" title="Remove">×</button></div>`;}).join('') + hintHtml;strip.querySelectorAll('.x').forEach(b => {b.onclick = () => {const i = +b.dataset.i;const removed = attachments.splice(i, 1)[0];if (removed?.previewUrl) URL.revokeObjectURL(removed.previewUrl);renderStrip();};});}function addFiles(files) {const list = Array.from(files);for (const f of list) {if (attachments.length >= MAX_FILES) {4 unmodified linesconst isImg = mime.startsWith('image/');const isPdf = mime === 'application/pdf' || f.name.toLowerCase().endsWith('.pdf');if (!isImg && !isPdf) {window.toast(`Unsupported file: ${f.name} (only images & PDFs)`, 'warn');continue;}if (f.size > 12 * 1024 * 1024) {window.toast(`${f.name} is too large (>12MB)`, 'warn');continue;}5 unmodified lines});}renderStrip();// reset native input so the same file can be re-selected if user removes itfileEl.value = '';}fileEl.addEventListener('change', e => addFiles(e.target.files));// ── Drag-and-drop onto the whole window (bonus polish) ──['dragenter', 'dragover'].forEach(ev =>window.addEventListener(ev, e => { e.preventDefault(); }));window.addEventListener('drop', e => {if (!e.dataTransfer || !e.dataTransfer.files.length) return;e.preventDefault();addFiles(e.dataTransfer.files);});// ── Busy lock (disable input while model thinks) ──function setBusy(b) {document.body.dataset.busy = b ? '1' : '0';input.disabled = b;send.disabled = b;if (b) {send.classList.add('loading');upBtn.classList.add('disabled');fileEl.disabled = true;input.dataset.prev = input.placeholder;input.placeholder = 'Council deliberating…';} else {send.classList.remove('loading');upBtn.classList.remove('disabled');fileEl.disabled = false;input.placeholder = input.dataset.prev || 'Speak to your civilization seed…';}}// ── Restore civilization on load ──async function restore() {try {const h = await ElysiumAPI.hypergraph();(h.nodes || []).forEach(n => {if (n.node_id !== 'CORE') window.elysiumAddNode(n);});(h.edges || []).forEach(e => window.elysiumAddEdge(e));if ((h.nodes || []).length > 0) seedHint.classList.add('hidden');updateLegend();updateMetrics({nodes: h.node_count, edges: h.edge_count,council_active: 0, knowledge_growth: 0,civilization_age_min: 0,mycelium_density_pct: h.node_count ? Math.round(Math.min(1, h.edge_count / Math.max(1, h.node_count * 1.4)) * 100) : 0,coherence_pct: 70,});} catch (e) {// first boot offline — fine}}restore();// ── SUBMIT ──async function submit() {if (document.body.dataset.busy === '1') return;const text = input.value.trim();if (!text && attachments.length === 0) return;setBusy(true);seedHint.classList.add('hidden');input.value = '';const files = attachments.map(a => a.file);// clear preview stripattachments.forEach(a => a.previewUrl && URL.revokeObjectURL(a.previewUrl));attachments = [];renderStrip();try {const data = await ElysiumAPI.turn(text, files);handleResponse(data);} catch (e) {window.toast('Inference failed: ' + e.message, 'error');} finally {setBusy(false);}}send.onclick = submit;input.addEventListener('keydown', e => {if (e.key === 'Enter' && !e.shiftKey) {e.preventDefault();submit();}});// ── HANDLE MODEL RESPONSE ──// Parses JSON envelope and routes data to the right UI subsystem.// NEVER renders the JSON itself on the canvas.function handleResponse(payload) {const resp = payload.elysium_response || {};const rt = payload._runtime || {};// 0. Attachment errors → toast(rt.attachment_errors || []).forEach(e =>window.toast(`📎 ${e.name}: ${e.error}`, 'warn'));// 1. Hypergraph delta → canvasconst delta = resp.hypergraph_delta || {};(delta.nodes_added || []).forEach(n => {// Find a parent hint: first edge whose target is this nodelet parent = null;for (const e of (delta.edges_added || [])) {if (e.target_node_id === n.node_id) { parent = e.source_node_id; break; }if (e.source_node_id === n.node_id) { parent = e.target_node_id; break; }}window.elysiumAddNode(n, parent);});(delta.edges_added || []).forEach(e => window.elysiumAddEdge(e));// 2. UI directivesconst ui = resp.ui_directives || {};(ui.bioluminescence_pulse_nodes || []).forEach(id => window.elysiumPulse(id, 1500));document.body.dataset.alert = ui.alert_level || 'CALM';if (ui.camera_focus_node_id) {// Pulse + focus for emphasiswindow.elysiumPulse(ui.camera_focus_node_id, 1800);setTimeout(() => window.elysiumFocus(ui.camera_focus_node_id), 350);}// 3. Council overlay + TTSwindow.renderCouncil(resp, rt);// 4. Metrics bar (REAL civilization metrics, not fake)updateMetrics(rt.metrics || {});// 5. Agent count badgeconst ag = (resp.council_deliberation?.agent_outputs || []).length;document.getElementById('agent-count').textContent = `+${ag}`;// 6. Legend live updateupdateLegend();// 7. Tool toasts(rt.tool_results || []).forEach(tr => {const ok = tr.result && !tr.result.error;window.toast(`🔧 ${tr.tool_name}: ${ok ? 'ok' : (tr.result?.error || 'offline')}`,ok ? 'info' : 'warn');});// 8. Direct answer toast (only if no council, otherwise it's already in synthesis)if (!ag && resp.direct_answer) {window.toast(resp.direct_answer);}// 9. Attachment processed confirmationif ((rt.attachments_processed || []).length) {const names = rt.attachments_processed.map(a => a.name).join(', ');window.toast(`📎 Analyzed: ${names}`, 'info');}}function updateMetrics(m) {document.getElementById('s-nodes').textContent = (m.nodes ?? window.ELYSIUM?.nodes.size ?? 1);document.getElementById('s-edges').textContent = (m.edges ?? window.ELYSIUM?.edges.length ?? 0);document.getElementById('s-council').textContent = (m.council_active ?? 0);document.getElementById('s-growth').textContent = (m.knowledge_growth ?? 0);document.getElementById('s-age').textContent = (m.civilization_age_min ?? 0);document.getElementById('m-density').textContent = (m.mycelium_density_pct ?? 0) + '%';document.getElementById('m-coherence').textContent = (m.coherence_pct ?? 70) + '%';}function updateLegend() {const counts = {};window.ELYSIUM.nodes.forEach(n => counts[n.type] = (counts[n.type] || 0) + 1);const order = ['CORE','CIVILIZATION','DOMAIN','AGENT','TOOL','PROJECT','LIFE_EVENT','EMOTION','PERSON','VALUE','MEMORY','FACT','CONCEPT','QUERY'];const seen = new Set();const parts = [];order.filter(t => counts[t] && !seen.has(t)).forEach(t => {seen.add(t);const c = window.colorFor(t);parts.push(`<div class="legend-item" data-type="${t}"><span class="dot" style="background:${c};color:${c}"></span>1 unmodified line<span class="lbl">${t.replace(/_/g, ' ').toLowerCase()}</span></div>`);});// any types not in canonical order, appendObject.keys(counts).forEach(t => {if (seen.has(t)) return;const c = window.colorFor(t);parts.push(`<div class="legend-item" data-type="${t}"><span class="dot" style="background:${c};color:${c}"></span><span class="badge">${counts[t]}</span><span class="lbl">${t.replace(/_/g, ' ').toLowerCase()}</span></div>`);});document.getElementById('legend-items').innerHTML = parts.join('');// wire legend filter clicksdocument.querySelectorAll('#legend-items .legend-item').forEach(el => {el.onclick = () => {const t = el.dataset.type;window.elysiumFilterType?.(t);// visual feedbackdocument.querySelectorAll('#legend-items .legend-item').forEach(x =>x.style.opacity = window.ELYSIUM.filterType? (x.dataset.type === window.ELYSIUM.filterType ? '1' : '.45'): '1');};});}// RI Analysis = fit-to-view + summary toastdocument.getElementById('ri-analysis').onclick = () => {window.elysiumFitAll();const n = window.ELYSIUM.nodes.size;const e = window.ELYSIUM.edges.length;window.toast(`🔍 Civilization snapshot: ${n} nodes · ${e} threads`, 'info');};function escapeHtml(s) {return String(s || '').replace(/[&<>"']/g, c => ({'&':'&','<':'<','>':'>','"':'"',"'":'''}[c]));}})();12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182832 unmodified lines86878889909192939495969798991001011021031041051061071081091101111121131141154 unmodified lines1201211221231241251261271281295 unmodified lines1351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254261 unmodified line428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473/* ============================================================ELYSIUM — boot.js------------------------------------------------------------Wires UI ↔ /api/turn. Critical guarantees:• The JSON envelope returned by the model is NEVER renderedas raw text anywhere on screen. It is parsed and ROUTED to:hypergraph_delta → canvas nodes / edgescouncil_deliberation → council overlay + TTS audioui_directives → bioluminescence pulses, focus, alertdirect_answer → optional small toastmetrics → bottom stats bar + legend densities• File uploads are previewed above the textbox with X removaland only sent when the user presses Send.• Every DOM lookup is defensive — a single missing elementnever throws an unhandled "Cannot read properties of null".This was the root cause of the previous "classList of null"toast that appeared on top.============================================================ */(() => {'use strict';// ── Safe element accessor (logs once if missing) ──const _missing = new Set();const $ = (id) => {const el = document.getElementById(id);if (!el && !_missing.has(id)) {_missing.add(id);console.warn('[elysium] missing element:', id);}return el;};// Safe wrappers — no-op if element missingconst addCls = (el, c) => { if (el && el.classList) el.classList.add(c); };const rmCls = (el, c) => { if (el && el.classList) el.classList.remove(c); };// ── Toast helper (always returns; never throws) ──window.toast = function (msg, kind = '') {const host = $('toasts');if (!host) { console.log('[toast]', msg); return; }const t = document.createElement('div');t.className = 'toast ' + (kind || '');t.textContent = String(msg).slice(0, 280);host.appendChild(t);setTimeout(() => { try { t.remove(); } catch {} }, 5200);};function escapeHtml(s) {return String(s == null ? '' : s).replace(/[&<>"']/g, c => ({'&':'&','<':'<','>':'>','"':'"',"'":'''}[c]));}// ── DOM references (all may be null — handled defensively) ──const input = $('q-input');const send = $('q-send');const fileEl = $('q-file');const upBtn = $('q-upload');const strip = $('attach-strip');const seedHint = $('seed-hint');/* =========================================================PART A — FILE ATTACHMENTS (preview above textbox, max 2)========================================================= */const MAX_FILES = 2;const MAX_BYTES = 12 * 1024 * 1024;let attachments = []; // [{file, name, kind:'image'|'pdf', previewUrl}]function renderStrip() {if (!strip) return;if (attachments.length === 0) {addCls(strip, 'hidden');strip.innerHTML = '';return;}rmCls(strip, 'hidden');const hint = attachments.length < MAX_FILES? `<span class="attach-hint">${MAX_FILES - attachments.length} more allowed</span>`: `<span class="attach-hint">max ${MAX_FILES} reached</span>`;strip.innerHTML = attachments.map((a, i) => {2 unmodified lines: `<div class="pdf-ico">PDF</div>`;const sizeKb = (a.file.size / 1024).toFixed(0);return `<div class="preview-tile" data-i="${i}">${preview}<span class="nm" title="${escapeHtml(a.name)}">${escapeHtml(a.name)} · ${sizeKb}KB</span><button class="x" data-i="${i}" title="Remove attachment" aria-label="Remove">×</button></div>`;}).join('') + hint;// Wire remove buttonsstrip.querySelectorAll('.x').forEach(b => {b.onclick = (ev) => {ev.preventDefault();ev.stopPropagation();const i = +b.dataset.i;const removed = attachments.splice(i, 1)[0];if (removed && removed.previewUrl) {try { URL.revokeObjectURL(removed.previewUrl); } catch {}}renderStrip();};});}function addFiles(files) {if (!files) return;const list = Array.from(files);for (const f of list) {if (attachments.length >= MAX_FILES) {4 unmodified linesconst isImg = mime.startsWith('image/');const isPdf = mime === 'application/pdf' || f.name.toLowerCase().endsWith('.pdf');if (!isImg && !isPdf) {window.toast(`Unsupported: ${f.name} (only images & PDFs)`, 'warn');continue;}if (f.size > MAX_BYTES) {window.toast(`${f.name} is too large (>12MB)`, 'warn');continue;}5 unmodified lines});}renderStrip();if (fileEl) fileEl.value = ''; // allow re-selecting same file after removal}if (fileEl) {fileEl.addEventListener('change', e => addFiles(e.target.files));}// Optional polish: drag-and-drop files anywhere on the window['dragenter', 'dragover'].forEach(ev =>window.addEventListener(ev, e => { e.preventDefault(); }));window.addEventListener('drop', e => {if (!e.dataTransfer || !e.dataTransfer.files || !e.dataTransfer.files.length) return;e.preventDefault();addFiles(e.dataTransfer.files);});/* =========================================================PART B — BUSY LOCK (disables input while model thinks)========================================================= */function setBusy(b) {document.body.dataset.busy = b ? '1' : '0';if (input) input.disabled = b;if (send) send.disabled = b;if (b) {if (send) send.classList.add('loading');if (upBtn) upBtn.classList.add('disabled');if (fileEl) fileEl.disabled = true;if (input) {input.dataset.prev = input.placeholder || '';input.placeholder = 'Council deliberating…';}} else {if (send) send.classList.remove('loading');if (upBtn) upBtn.classList.remove('disabled');if (fileEl) fileEl.disabled = false;if (input) {input.placeholder = input.dataset.prev || 'Speak to your civilization seed…';}}}/* =========================================================PART C — RESTORE existing civilization on page load========================================================= */async function restore() {try {const h = await ElysiumAPI.hypergraph();(h.nodes || []).forEach(n => {if (n.node_id !== 'CORE' && typeof window.elysiumAddNode === 'function') {window.elysiumAddNode(n);}});(h.edges || []).forEach(e => {if (typeof window.elysiumAddEdge === 'function') window.elysiumAddEdge(e);});if ((h.nodes || []).length > 1) addCls(seedHint, 'hidden');updateLegend();updateMetrics({nodes: h.node_count || (h.nodes || []).length || 1,edges: h.edge_count || (h.edges || []).length || 0,council_active: 0,knowledge_growth: 0,civilization_age_min: 0,mycelium_density_pct: h.node_count? Math.round(Math.min(1, (h.edge_count || 0) / Math.max(1, h.node_count * 1.4)) * 100): 0,coherence_pct: 70,});} catch (e) {console.warn('[restore] failed', e);updateLegend();}}restore();/* =========================================================PART D — SUBMIT a turn========================================================= */async function submit() {if (document.body.dataset.busy === '1') return;const text = input ? input.value.trim() : '';if (!text && attachments.length === 0) return;setBusy(true);addCls(seedHint, 'hidden');if (input) input.value = '';const files = attachments.map(a => a.file);// Clear preview strip (response will show separate "Analyzed:" toast)attachments.forEach(a => {if (a.previewUrl) { try { URL.revokeObjectURL(a.previewUrl); } catch {} }});attachments = [];renderStrip();try {const data = await ElysiumAPI.turn(text, files);handleResponse(data || {});} catch (e) {console.error('[submit] failed', e);window.toast('Inference failed: ' + (e.message || e), 'error');} finally {setBusy(false);}}if (send) send.onclick = submit;if (input) {input.addEventListener('keydown', e => {if (e.key === 'Enter' && !e.shiftKey) {e.preventDefault();submit();}});}/* =========================================================PART E — HANDLE RESPONSEParses the JSON envelope and routes it. NEVER renders rawJSON to the canvas or any visible element.========================================================= */function handleResponse(payload) {// payload schema: { user_msg, elysium_response, _runtime }let resp = {};let rt = {};try {resp = payload.elysium_response || {};rt = payload._runtime || {};} catch (e) {console.error('[handleResponse] malformed payload', e);window.toast('Malformed response from model', 'error');return;}// 0. Attachment errors (server-side validation failures) → toastsafeArr(rt.attachment_errors).forEach(e =>window.toast(`📎 ${e.name}: ${e.error}`, 'warn'));// 1. Hypergraph delta → canvas (NODES then EDGES; build parent map)const delta = resp.hypergraph_delta || {};const edgesAdded = safeArr(delta.edges_added);const nodesAdded = safeArr(delta.nodes_added);// Build a parent-hint map: for each new node, what's its closest source// (used so spawn animation grows OUT FROM the parent, not the centre).const parentHint = {};edgesAdded.forEach(e => {if (!e) return;if (e.target_node_id && !parentHint[e.target_node_id]) {parentHint[e.target_node_id] = e.source_node_id;}if (e.source_node_id && !parentHint[e.source_node_id]) {// weaker hint (reverse direction) — only if not setif (!parentHint[e.source_node_id]) {parentHint[e.source_node_id] = e.target_node_id;}}});nodesAdded.forEach(n => {if (!n || !n.node_id) return;try {if (typeof window.elysiumAddNode === 'function') {window.elysiumAddNode(n, parentHint[n.node_id]);}} catch (err) {console.warn('[handleResponse] addNode failed', n, err);}});edgesAdded.forEach(e => {if (!e || !e.source_node_id || !e.target_node_id) return;try {if (typeof window.elysiumAddEdge === 'function') window.elysiumAddEdge(e);} catch (err) {console.warn('[handleResponse] addEdge failed', e, err);}});// Apply node updates (fields_changed)safeArr(delta.nodes_updated).forEach(u => {if (!u || !u.node_id) return;const node = window.elysiumGetNode && window.elysiumGetNode(u.node_id);if (node && u.fields_changed) {Object.assign(node.payload || (node.payload = {}), u.fields_changed);}});// 2. UI directives — pulses, focus, alertconst ui = resp.ui_directives || {};safeArr(ui.bioluminescence_pulse_nodes).forEach(id => {if (typeof window.elysiumPulse === 'function') window.elysiumPulse(id, 1600);});document.body.dataset.alert = ui.alert_level || 'CALM';if (ui.camera_focus_node_id && typeof window.elysiumFocus === 'function') {if (typeof window.elysiumPulse === 'function')window.elysiumPulse(ui.camera_focus_node_id, 1800);setTimeout(() => {try { window.elysiumFocus(ui.camera_focus_node_id); } catch {}}, 380);}// 3. Council overlay + TTStry {if (typeof window.renderCouncil === 'function') {window.renderCouncil(resp, rt);}} catch (e) {console.error('[council] render failed', e);}// 4. Metrics bar (REAL civilization metrics)updateMetrics(rt.metrics || {});// 5. Agent count badgeconst ag = safeArr(resp.council_deliberation && resp.council_deliberation.agent_outputs).length;const badge = $('agent-count');if (badge) badge.textContent = `+${ag}`;// 6. Legend live update (counts per type)updateLegend();// 7. Tool toastssafeArr(rt.tool_results).forEach(tr => {if (!tr) return;const ok = tr.result && !tr.result.error;window.toast(`🔧 ${tr.tool_name || 'tool'}: ${ok ? 'ok' : (tr.result?.error || 'offline')}`,ok ? 'info' : 'warn');});// 8. Direct answer toast — ONLY when no council (otherwise it's already// shown in the overlay synthesis). NEVER dumps raw JSON.if (!ag && resp.direct_answer && typeof resp.direct_answer === 'string') {window.toast(resp.direct_answer.slice(0, 240));}// 9. Confirm attachment analysisconst processed = safeArr(rt.attachments_processed);if (processed.length) {const names = processed.map(a => a && a.name).filter(Boolean).join(', ');if (names) window.toast(`📎 Analyzed: ${names}`, 'info');}}function safeArr(x) { return Array.isArray(x) ? x : []; }/* =========================================================PART F — Metrics & Legend updates========================================================= */function updateMetrics(m) {m = m || {};const nodes = m.nodes ?? (window.ELYSIUM ? window.ELYSIUM.nodes.size : 1);const edges = m.edges ?? (window.ELYSIUM ? window.ELYSIUM.edges.length : 0);setText('s-nodes', nodes);setText('s-edges', edges);setText('s-council', m.council_active ?? 0);setText('s-growth', m.knowledge_growth ?? 0);setText('s-age', m.civilization_age_min ?? 0);setText('m-density', (m.mycelium_density_pct ?? 0) + '%');setText('m-coherence', (m.coherence_pct ?? 70) + '%');}function setText(id, value) {const el = $(id);if (el) el.textContent = value;}function updateLegend() {const host = $('legend-items');if (!host || !window.ELYSIUM) return;const counts = {};window.ELYSIUM.nodes.forEach(n => {const t = n.type || 'CONCEPT';counts[t] = (counts[t] || 0) + 1;});const order = ['CORE','CIVILIZATION','DOMAIN','AGENT','TOOL','PROJECT','LIFE_EVENT','EMOTION','PERSON','VALUE','MEMORY','FACT','CONCEPT','QUERY'];const seen = new Set();const parts = [];const colorFn = window.colorFor || (() => '#a76bff');order.forEach(t => {if (!counts[t]) return;seen.add(t);const c = colorFn(t);parts.push(`<div class="legend-item" data-type="${t}"><span class="dot" style="background:${c};color:${c}"></span>1 unmodified line<span class="lbl">${t.replace(/_/g, ' ').toLowerCase()}</span></div>`);});Object.keys(counts).forEach(t => {if (seen.has(t)) return;const c = colorFn(t);parts.push(`<div class="legend-item" data-type="${t}"><span class="dot" style="background:${c};color:${c}"></span><span class="badge">${counts[t]}</span><span class="lbl">${t.replace(/_/g, ' ').toLowerCase()}</span></div>`);});host.innerHTML = parts.join('');// Wire legend filter clickshost.querySelectorAll('.legend-item').forEach(el => {el.onclick = () => {const t = el.dataset.type;if (typeof window.elysiumFilterType === 'function') window.elysiumFilterType(t);const active = window.ELYSIUM && window.ELYSIUM.filterType;host.querySelectorAll('.legend-item').forEach(x => {x.style.opacity = active? (x.dataset.type === active ? '1' : '.45'): '1';});};});}/* =========================================================PART G — RI Analysis button (fit + summary)========================================================= */const ri = $('ri-analysis');if (ri) {ri.onclick = () => {if (typeof window.elysiumFitAll === 'function') window.elysiumFitAll();const n = window.ELYSIUM ? window.ELYSIUM.nodes.size : 0;const e = window.ELYSIUM ? window.ELYSIUM.edges.length : 0;window.toast(`🔍 Civilization snapshot: ${n} nodes · ${e} threads`, 'info');};}// Expose for debugging (read-only-ish)window.elysiumUpdateLegend = updateLegend;window.elysiumUpdateMetrics = updateMetrics;})();
123456713 unmodified lines212223242526272829303132333435369 unmodified lines464748495051525354555657585960616263643 unmodified lines68697071727374751 unmodified line77787980818283848586878889909192939495969798991001019 unmodified lines11111211311411511611717 unmodified lines1351361371381391401411421431442 unmodified lines1471481491501511521536 unmodified lines1601611621631641651661671681691701711721731741751 unmodified line1771781791801811821831841851861871881891901911921931941951961971981992002012025 unmodified lines2082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682693 unmodified lines2732742752762772782792802812822832842852862872882892902912922931 unmodified line29529629729829930030130230330430530619 unmodified lines3263273283293303313323333343353363373383393403414 unmodified lines3463473483493503513524 unmodified lines3573583593603613623636 unmodified lines37037137237337437537637737837938038138238318 unmodified lines4024034044054064074084094104114122 unmodified lines415416417418419420421/* Google-Maps-style infinite-pan canvas with bioluminescent hypergraph.Handles: pan / zoom / pinch / inertia / minimap drag / click-to-detail. */(() => {const canvas = document.getElementById('elysium-canvas');const ctx = canvas.getContext('2d', { alpha: false });const DPR = Math.max(1, Math.min(2, window.devicePixelRatio || 1));13 unmodified linesedges: [],hover: null,selected: null,filterType: null, // legend click filters};// Seed COREE.nodes.set('CORE', {node_id: 'CORE', x: 0, y: 0,type: 'CORE', label: 'ELYSIUM',radius: 36, color: '#ffb840',phase: 0, born: performance.now() - 1000,payload: { description: 'The seed of your civilization. Ask anything to grow new nodes.' },});// ──────── COORDS ────────9 unmodified lineslet best = null, bestD = Infinity;E.nodes.forEach(n => {const d = Math.hypot(n.x - w.x, n.y - w.y);if (d < n.radius * 1.25 && d < bestD) { best = n; bestD = d; }});return best;}// ──────── PAN / TAP ────────let lastX = 0, lastY = 0, downX = 0, downY = 0, downT = 0;canvas.addEventListener('pointerdown', e => {downX = e.clientX; downY = e.clientY; downT = performance.now();E.cam.drag = true;canvas.classList.add('dragging');lastX = e.clientX; lastY = e.clientY;canvas.setPointerCapture(e.pointerId);});canvas.addEventListener('pointermove', e => {3 unmodified linescanvas.style.cursor = n ? 'pointer' : '';return;}const dx = (e.clientX - lastX) / E.cam.z;const dy = (e.clientY - lastY) / E.cam.z;E.cam.x -= dx; E.cam.y -= dy;E.cam.vx = dx * 0.85; E.cam.vy = dy * 0.85;E.cam.tx = E.cam.x; E.cam.ty = E.cam.y;1 unmodified line});function endPan(e) {const moved = Math.hypot(e.clientX - downX, e.clientY - downY);const dt = performance.now() - downT;E.cam.drag = false;canvas.classList.remove('dragging');try { canvas.releasePointerCapture(e.pointerId); } catch {}// Treat as click if minimal movement + short durationif (moved < 6 && dt < 350) {const n = hitTest(e.clientX, e.clientY);if (n) {if (window.showNodeDetail) window.showNodeDetail(n, e.clientX, e.clientY);} else {if (window.hideNodeDetail) window.hideNodeDetail();}}}canvas.addEventListener('pointerup', endPan);canvas.addEventListener('pointercancel', endPan);// wheel zoom (zoom to cursor)canvas.addEventListener('wheel', e => {e.preventDefault();const factor = e.deltaY > 0 ? 0.9 : 1.1;9 unmodified linesE.cam.tx = w.x; E.cam.ty = w.y;});// ──────── PINCH ZOOM ────────let touchDist = 0, touchMid = null;canvas.addEventListener('touchstart', e => {if (e.touches.length === 2) {17 unmodified lines}, { passive: false });canvas.addEventListener('touchend', () => { touchDist = 0; });// ──────── ZOOM BTNS ────────document.getElementById('z-in').onclick = () => E.cam.tz = Math.min(4, E.cam.z * 1.35);document.getElementById('z-out').onclick = () => E.cam.tz = Math.max(0.15, E.cam.z / 1.35);document.getElementById('z-fit').onclick = fitAll;function fitAll() {if (E.nodes.size === 0) return;2 unmodified linesmnX = Math.min(mnX, n.x); mnY = Math.min(mnY, n.y);mxX = Math.max(mxX, n.x); mxY = Math.max(mxY, n.y);});const pad = 220;E.cam.tx = (mnX + mxX) / 2;E.cam.ty = (mnY + mxY) / 2;if (mxX - mnX < 1 && mxY - mnY < 1) {6 unmodified lines}window.elysiumFitAll = fitAll;// ──────── MINIMAP (interactive) ────────const mini = document.getElementById('minimap');const mctx = mini.getContext('2d');function computeBounds(pad = 100) {let mnX = Infinity, mnY = Infinity, mxX = -Infinity, mxY = -Infinity;E.nodes.forEach(n => {mnX = Math.min(mnX, n.x); mnY = Math.min(mnY, n.y);mxX = Math.max(mxX, n.x); mxY = Math.max(mxY, n.y);});if (mxX - mnX < 100) { mnX -= 200; mxX += 200; }if (mxY - mnY < 100) { mnY -= 200; mxY += 200; }return { mnX: mnX - pad, mnY: mnY - pad,1 unmodified line}function drawMinimap() {const w = mini.clientWidth, h = mini.clientHeight;if (mini.width !== w * DPR || mini.height !== h * DPR) {mini.width = w * DPR; mini.height = h * DPR;}mctx.save();mctx.scale(DPR, DPR);// bgmctx.fillStyle = 'rgba(2,16,22,1)';mctx.fillRect(0, 0, w, h);// gridmctx.strokeStyle = 'rgba(0,229,200,.08)';mctx.lineWidth = .5;for (let i = 0; i < w; i += 12) { mctx.beginPath(); mctx.moveTo(i, 0); mctx.lineTo(i, h); mctx.stroke(); }for (let j = 0; j < h; j += 12) { mctx.beginPath(); mctx.moveTo(0, j); mctx.lineTo(w, j); mctx.stroke(); }if (E.nodes.size === 0) { mctx.restore(); return; }const { mnX, mnY, mxX, mxY } = computeBounds();const sx = w / (mxX - mnX), sy = h / (mxY - mnY);// edgesmctx.lineWidth = .6;E.edges.forEach(ed => {const s = E.nodes.get(ed.src), t = E.nodes.get(ed.dst);5 unmodified linesmctx.stroke();});// nodesE.nodes.forEach(n => {const px = (n.x - mnX) * sx, py = (n.y - mnY) * sy;mctx.shadowColor = n.color;mctx.shadowBlur = 6;mctx.fillStyle = n.color;mctx.beginPath();mctx.arc(px, py, n.type === 'CORE' ? 3.5 : 2.2, 0, Math.PI * 2);mctx.fill();});mctx.shadowBlur = 0;// viewport rectconst vx = (E.cam.x - innerWidth / 2 / E.cam.z - mnX) * sx;const vy = (E.cam.y - innerHeight / 2 / E.cam.z - mnY) * sy;const vw = innerWidth / E.cam.z * sx;const vh = innerHeight / E.cam.z * sy;mctx.strokeStyle = 'rgba(25,214,255,.9)';mctx.lineWidth = 1.2;mctx.setLineDash([3, 3]);mctx.strokeRect(vx, vy, vw, vh);mctx.setLineDash([]);mctx.restore();}// minimap drag / click to panlet miniDrag = false;function miniPan(e) {const rect = mini.getBoundingClientRect();const fx = (e.clientX - rect.left) / rect.width;const fy = (e.clientY - rect.top) / rect.height;const { mnX, mnY, mxX, mxY } = computeBounds();E.cam.tx = mnX + fx * (mxX - mnX);E.cam.ty = mnY + fy * (mxY - mnY);}mini.addEventListener('pointerdown', e => { miniDrag = true; miniPan(e); mini.setPointerCapture(e.pointerId); });mini.addEventListener('pointermove', e => { if (miniDrag) miniPan(e); });mini.addEventListener('pointerup', e => { miniDrag = false; try { mini.releasePointerCapture(e.pointerId); } catch{} });mini.addEventListener('pointercancel', () => { miniDrag = false; });// ──────── PUBLIC API ────────const SPAWN_RADIUS = 280;window.elysiumAddNode = function (node, parentHint) {if (E.nodes.has(node.node_id)) return E.nodes.get(node.node_id);const parentId = parentHint || 'CORE';const parent = E.nodes.get(parentId) || E.nodes.get('CORE') || { x: 0, y: 0 };const idx = E.nodes.size;// golden-angle spiral around parent for organic feelconst golden = 2.39996;const angle = (idx * golden) % (Math.PI * 2);const dist = SPAWN_RADIUS + ((idx * 17) % 220);const tx = parent.x + Math.cos(angle) * dist;const ty = parent.y + Math.sin(angle) * dist;const type = node.node_type || node.type || 'DOMAIN';const radius = type === 'CORE' || type === 'CIVILIZATION' ? 36: type === 'AGENT' ? 22: type === 'TOOL' ? 14: 18;3 unmodified linestype,label: node.label || node.node_id,radius,color: window.colorFor(type),phase: Math.random() * Math.PI * 2,born: performance.now(),payload: node.payload || {},embedding_hint: node.embedding_hint || '',};E.nodes.set(node.node_id, n);// gentle auto-pan toward new nodeE.cam.tx = E.cam.x * 0.86 + tx * 0.14;E.cam.ty = E.cam.y * 0.86 + ty * 0.14;return n;};window.elysiumAddEdge = function (edge) {// de-dupeif (E.edges.some(e =>e.src === edge.source_node_id &&e.dst === edge.target_node_id &&1 unmodified lineE.edges.push({src: edge.source_node_id,dst: edge.target_node_id,type: edge.edge_type,weight: edge.weight ?? 0.5,color: edge.edge_type === 'CONFLICT' ? 'rgba(255,84,105,.6)' :edge.edge_type === 'COALITION' ? 'rgba(167,107,255,.65)' :edge.edge_type === 'CAUSAL' ? 'rgba(25,214,255,.55)' :edge.edge_type === 'SUPPORTS' ? 'rgba(92,255,174,.55)' :'rgba(255,184,64,.55)',born: performance.now(),});19 unmodified lineswindow.elysiumGetNode = (id) => E.nodes.get(id);// legend filterwindow.elysiumFilterType = function (type) {E.filterType = (E.filterType === type) ? null : type;};// ──────── RENDER LOOP ────────function lerp(a, b, t) { return a + (b - a) * t; }function loop(t) {// animate spawn-to-targetE.nodes.forEach(n => {if (n.tx != null) {n.x = lerp(n.x, n.tx, 0.12);4 unmodified lines}});// smooth cameraE.cam.z = lerp(E.cam.z, E.cam.tz, 0.10);if (!E.cam.drag) {E.cam.x = lerp(E.cam.x, E.cam.tx, 0.12);4 unmodified linesif (Math.abs(E.cam.vy) < 0.05) E.cam.vy = 0;}// backgroundctx.fillStyle = '#02080c';ctx.fillRect(0, 0, canvas.width, canvas.height);const grad = ctx.createRadialGradient(6 unmodified linesdrawAmbient(ctx, t);// world transformctx.save();ctx.scale(DPR, DPR);ctx.translate(innerWidth / 2, innerHeight / 2);ctx.scale(E.cam.z, E.cam.z);ctx.translate(-E.cam.x, -E.cam.y);// edges (under nodes)E.edges.forEach(e => {const s = E.nodes.get(e.src), d = E.nodes.get(e.dst);if (!s || !d) return;18 unmodified lines});ctx.globalAlpha = 1;// nodesE.nodes.forEach(n => {const dim = E.filterType && n.type !== E.filterType ? 0.22 : 1;ctx.globalAlpha = dim;window.drawNode(ctx, n, t, E.cam.z);});ctx.globalAlpha = 1;ctx.restore();2 unmodified linesrequestAnimationFrame(loop);}// ambient particlesconst PARTICLES = Array.from({ length: 60 }, () => ({x: Math.random() * innerWidth,y: Math.random() * innerHeight,1234567891011121314151617181920212213 unmodified lines36373839404142434445464748495051529 unmodified lines626364656667686970717273747576777879808182838485868788893 unmodified lines939495969798991001011021031 unmodified line1051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341359 unmodified lines14514614714814915015117 unmodified lines1691701711721731741751761771781792 unmodified lines1821831841851861871886 unmodified lines1951961971981992002012022032042052062072082092102111 unmodified line2132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422435 unmodified lines2492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413 unmodified lines3453463473483493503513523533543553563573583593603613623633643651 unmodified line36736836937037137237337437537637737819 unmodified lines3983994004014024034044054064074084094104114124 unmodified lines4174184194204214224234 unmodified lines4284294304314324334346 unmodified lines44144244344444544644744844945045145245345418 unmodified lines4734744754764774784794804814824834842 unmodified lines487488489490491492493/* ============================================================ELYSIUM — canvas.jsGoogle-Maps-style infinite pan/zoom canvas with bioluminescenthypergraph rendering, particles, and a synced minimap.Critical behaviours fixed in this version:• Click vs pan is detected with BOTH movement-distance ANDelapsed-time thresholds AND a final hit-test on the uplocation (so even a slight finger jitter still opensthe node detail).• The minimap is fully interactive (click + drag to pan).• Every public function is wrapped to be no-op if calledbefore the canvas exists.============================================================ */(() => {'use strict';const canvas = document.getElementById('elysium-canvas');if (!canvas) { console.warn('[canvas] #elysium-canvas missing'); return; }const ctx = canvas.getContext('2d', { alpha: false });const DPR = Math.max(1, Math.min(2, window.devicePixelRatio || 1));13 unmodified linesedges: [],hover: null,selected: null,filterType: null,};// Seed CORE (always present)E.nodes.set('CORE', {node_id: 'CORE', x: 0, y: 0,type: 'CORE', label: 'ELYSIUM',radius: 36, color: '#ffb840',phase: 0, born: performance.now() - 1000,payload: { description: 'The seed of your civilization. Ask anything to grow new nodes.' },embedding_hint: 'The civilization core. All knowledge branches out from here.',});// ──────── COORDS ────────9 unmodified lineslet best = null, bestD = Infinity;E.nodes.forEach(n => {const d = Math.hypot(n.x - w.x, n.y - w.y);// Use a generous hit radius — at least 18 world-units to make// small nodes tappable on touch devices.const hitR = Math.max(18, n.radius * 1.35);if (d < hitR && d < bestD) { best = n; bestD = d; }});return best;}// ──────── PAN / TAP ────────let lastX = 0, lastY = 0;let downX = 0, downY = 0, downT = 0;let totalMove = 0;let downOnNode = null;canvas.addEventListener('pointerdown', e => {downX = e.clientX; downY = e.clientY; downT = performance.now();totalMove = 0;downOnNode = hitTest(e.clientX, e.clientY);E.cam.drag = true;canvas.classList.add('dragging');lastX = e.clientX; lastY = e.clientY;try { canvas.setPointerCapture(e.pointerId); } catch {}});canvas.addEventListener('pointermove', e => {3 unmodified linescanvas.style.cursor = n ? 'pointer' : '';return;}const dxRaw = e.clientX - lastX;const dyRaw = e.clientY - lastY;totalMove += Math.hypot(dxRaw, dyRaw);const dx = dxRaw / E.cam.z;const dy = dyRaw / E.cam.z;E.cam.x -= dx; E.cam.y -= dy;E.cam.vx = dx * 0.85; E.cam.vy = dy * 0.85;E.cam.tx = E.cam.x; E.cam.ty = E.cam.y;1 unmodified line});function endPan(e) {const dt = performance.now() - downT;E.cam.drag = false;canvas.classList.remove('dragging');try { canvas.releasePointerCapture(e.pointerId); } catch {}// Click detection: total movement < 8px AND duration < 500ms.// Either down-or-up location may hit a node (handles touch jitter).const moved = totalMove < 8 && Math.hypot(e.clientX - downX, e.clientY - downY) < 8;if (moved && dt < 500) {const upNode = hitTest(e.clientX, e.clientY);const node = upNode || downOnNode;if (node) {if (typeof window.showNodeDetail === 'function') {window.showNodeDetail(node, e.clientX, e.clientY);}} else {if (typeof window.hideNodeDetail === 'function') window.hideNodeDetail();}}downOnNode = null;}canvas.addEventListener('pointerup', endPan);canvas.addEventListener('pointercancel', endPan);// Wheel zoom (zoom to cursor)canvas.addEventListener('wheel', e => {e.preventDefault();const factor = e.deltaY > 0 ? 0.9 : 1.1;9 unmodified linesE.cam.tx = w.x; E.cam.ty = w.y;});// Pinch zoom (touch)let touchDist = 0, touchMid = null;canvas.addEventListener('touchstart', e => {if (e.touches.length === 2) {17 unmodified lines}, { passive: false });canvas.addEventListener('touchend', () => { touchDist = 0; });// Zoom buttons (defensive)const _btn = (id, fn) => { const el = document.getElementById(id); if (el) el.onclick = fn; };_btn('z-in', () => E.cam.tz = Math.min(4, E.cam.z * 1.35));_btn('z-out', () => E.cam.tz = Math.max(0.15, E.cam.z / 1.35));_btn('z-fit', () => fitAll());function fitAll() {if (E.nodes.size === 0) return;2 unmodified linesmnX = Math.min(mnX, n.x); mnY = Math.min(mnY, n.y);mxX = Math.max(mxX, n.x); mxY = Math.max(mxY, n.y);});const pad = 240;E.cam.tx = (mnX + mxX) / 2;E.cam.ty = (mnY + mxY) / 2;if (mxX - mnX < 1 && mxY - mnY < 1) {6 unmodified lines}window.elysiumFitAll = fitAll;/* ──────── MINIMAP (interactive — click & drag to pan) ──────── */const mini = document.getElementById('minimap');const mctx = mini ? mini.getContext('2d') : null;function computeBounds(pad = 140) {let mnX = Infinity, mnY = Infinity, mxX = -Infinity, mxY = -Infinity;E.nodes.forEach(n => {mnX = Math.min(mnX, n.x); mnY = Math.min(mnY, n.y);mxX = Math.max(mxX, n.x); mxY = Math.max(mxY, n.y);});if (!isFinite(mnX)) { mnX = -200; mnY = -200; mxX = 200; mxY = 200; }if (mxX - mnX < 100) { mnX -= 200; mxX += 200; }if (mxY - mnY < 100) { mnY -= 200; mxY += 200; }return { mnX: mnX - pad, mnY: mnY - pad,1 unmodified line}function drawMinimap() {if (!mini || !mctx) return;const w = mini.clientWidth || 170;const h = mini.clientHeight || 108;if (mini.width !== w * DPR || mini.height !== h * DPR) {mini.width = w * DPR; mini.height = h * DPR;}mctx.save();mctx.scale(DPR, DPR);mctx.fillStyle = 'rgba(2,16,22,1)';mctx.fillRect(0, 0, w, h);// Gridmctx.strokeStyle = 'rgba(0,229,200,.08)';mctx.lineWidth = .5;for (let i = 0; i < w; i += 12) {mctx.beginPath(); mctx.moveTo(i, 0); mctx.lineTo(i, h); mctx.stroke();}for (let j = 0; j < h; j += 12) {mctx.beginPath(); mctx.moveTo(0, j); mctx.lineTo(w, j); mctx.stroke();}const { mnX, mnY, mxX, mxY } = computeBounds();const sx = w / (mxX - mnX), sy = h / (mxY - mnY);// Edges (faint)mctx.lineWidth = .6;E.edges.forEach(ed => {const s = E.nodes.get(ed.src), t = E.nodes.get(ed.dst);5 unmodified linesmctx.stroke();});// Nodes (glowing dots)E.nodes.forEach(n => {const px = (n.x - mnX) * sx, py = (n.y - mnY) * sy;mctx.shadowColor = n.color;mctx.shadowBlur = 6;mctx.fillStyle = n.color;const r = (n.type === 'CORE' || n.type === 'CIVILIZATION') ? 3.5: n.type === 'AGENT' ? 2.6 : 2.2;mctx.beginPath();mctx.arc(px, py, r, 0, Math.PI * 2);mctx.fill();});mctx.shadowBlur = 0;// Viewport rectconst vx = (E.cam.x - innerWidth / 2 / E.cam.z - mnX) * sx;const vy = (E.cam.y - innerHeight / 2 / E.cam.z - mnY) * sy;const vw = innerWidth / E.cam.z * sx;const vh = innerHeight / E.cam.z * sy;mctx.strokeStyle = 'rgba(25,214,255,.95)';mctx.lineWidth = 1.2;mctx.setLineDash([3, 3]);mctx.strokeRect(vx, vy, vw, vh);mctx.setLineDash([]);// Selected node marker on minimapif (E.selected) {const px = (E.selected.x - mnX) * sx, py = (E.selected.y - mnY) * sy;mctx.strokeStyle = '#19d6ff';mctx.lineWidth = 1.5;mctx.beginPath(); mctx.arc(px, py, 5, 0, Math.PI * 2); mctx.stroke();}mctx.restore();}// Minimap drag / click panif (mini) {let miniDrag = false;const miniPan = (e) => {const rect = mini.getBoundingClientRect();const fx = Math.max(0, Math.min(1, (e.clientX - rect.left) / rect.width));const fy = Math.max(0, Math.min(1, (e.clientY - rect.top) / rect.height));const { mnX, mnY, mxX, mxY } = computeBounds();E.cam.tx = mnX + fx * (mxX - mnX);E.cam.ty = mnY + fy * (mxY - mnY);};mini.addEventListener('pointerdown', e => {miniDrag = true; miniPan(e);try { mini.setPointerCapture(e.pointerId); } catch {}});mini.addEventListener('pointermove', e => { if (miniDrag) miniPan(e); });mini.addEventListener('pointerup', e => {miniDrag = false;try { mini.releasePointerCapture(e.pointerId); } catch {}});mini.addEventListener('pointercancel', () => { miniDrag = false; });// Mouse wheel on minimap → zoom canvas around centremini.addEventListener('wheel', e => {e.preventDefault();const factor = e.deltaY > 0 ? 0.9 : 1.1;E.cam.tz = Math.max(0.15, Math.min(4, E.cam.z * factor));}, { passive: false });}/* ──────── PUBLIC API ──────── */const SPAWN_RADIUS = 280;window.elysiumAddNode = function (node, parentHint) {if (!node || !node.node_id) return null;if (E.nodes.has(node.node_id)) {// Update label / payload if changedconst existing = E.nodes.get(node.node_id);if (node.label) existing.label = node.label;if (node.payload) existing.payload = node.payload;if (node.embedding_hint) existing.embedding_hint = node.embedding_hint;return existing;}const parentId = parentHint || 'CORE';const parent = E.nodes.get(parentId) || E.nodes.get('CORE') || { x: 0, y: 0 };const idx = E.nodes.size;const golden = 2.39996;const angle = (idx * golden) % (Math.PI * 2);const dist = SPAWN_RADIUS + ((idx * 17) % 220);const tx = parent.x + Math.cos(angle) * dist;const ty = parent.y + Math.sin(angle) * dist;const type = node.node_type || node.type || 'DOMAIN';const radius = (type === 'CORE' || type === 'CIVILIZATION') ? 36: type === 'AGENT' ? 22: type === 'TOOL' ? 14: 18;3 unmodified linestype,label: node.label || node.node_id,radius,color: (window.colorFor || (() => '#a76bff'))(type),phase: Math.random() * Math.PI * 2,born: performance.now(),payload: node.payload || {},embedding_hint: node.embedding_hint || '',};E.nodes.set(node.node_id, n);// Gentle auto-pan toward new nodeE.cam.tx = E.cam.x * 0.86 + tx * 0.14;E.cam.ty = E.cam.y * 0.86 + ty * 0.14;return n;};window.elysiumAddEdge = function (edge) {if (!edge || !edge.source_node_id || !edge.target_node_id) return;if (E.edges.some(e =>e.src === edge.source_node_id &&e.dst === edge.target_node_id &&1 unmodified lineE.edges.push({src: edge.source_node_id,dst: edge.target_node_id,type: edge.edge_type || 'GENERIC',weight: edge.weight ?? 0.5,color: edge.edge_type === 'CONFLICT' ? 'rgba(255,84,105,.6)' :edge.edge_type === 'COALITION' ? 'rgba(167,107,255,.65)' :edge.edge_type === 'CAUSAL' ? 'rgba(25,214,255,.55)' :edge.edge_type === 'SUPPORTS' ? 'rgba(92,255,174,.55)' :'rgba(255,184,64,.55)',born: performance.now(),});19 unmodified lineswindow.elysiumGetNode = (id) => E.nodes.get(id);window.elysiumFilterType = function (type) {E.filterType = (E.filterType === type) ? null : type;};/* ──────── RENDER LOOP ──────── */function lerp(a, b, t) { return a + (b - a) * t; }function loop(t) {// Animate spawn-to-targetE.nodes.forEach(n => {if (n.tx != null) {n.x = lerp(n.x, n.tx, 0.12);4 unmodified lines}});// Smooth cameraE.cam.z = lerp(E.cam.z, E.cam.tz, 0.10);if (!E.cam.drag) {E.cam.x = lerp(E.cam.x, E.cam.tx, 0.12);4 unmodified linesif (Math.abs(E.cam.vy) < 0.05) E.cam.vy = 0;}// Backgroundctx.fillStyle = '#02080c';ctx.fillRect(0, 0, canvas.width, canvas.height);const grad = ctx.createRadialGradient(6 unmodified linesdrawAmbient(ctx, t);// World transformctx.save();ctx.scale(DPR, DPR);ctx.translate(innerWidth / 2, innerHeight / 2);ctx.scale(E.cam.z, E.cam.z);ctx.translate(-E.cam.x, -E.cam.y);// EdgesE.edges.forEach(e => {const s = E.nodes.get(e.src), d = E.nodes.get(e.dst);if (!s || !d) return;18 unmodified lines});ctx.globalAlpha = 1;// NodesE.nodes.forEach(n => {const dim = E.filterType && n.type !== E.filterType ? 0.22 : 1;ctx.globalAlpha = dim;try { window.drawNode(ctx, n, t, E.cam.z); }catch (err) { /* swallow per-node draw errors */ }});ctx.globalAlpha = 1;ctx.restore();2 unmodified linesrequestAnimationFrame(loop);}// Ambient particlesconst PARTICLES = Array.from({ length: 60 }, () => ({x: Math.random() * innerWidth,y: Math.random() * innerHeight,
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542551 unmodified line2572582592602612622632642652662672682692 unmodified lines272273274275276277278279280281282283284285286287288289290291292293294295/* Council overlay + node-detail popover.Implements:• Council slide-in panel with per-agent boxes (different neon colors)• Play / Pause / Minimize / Close controls• Per-agent mini play buttons synced to the combined audio• Speaking-agent highlight that follows audio timeline• Node-detail popover with payload, type, connections (image 4 style) */const AGENT_COLORS = {THE_BUILDER: '#ff4fa3',THE_GUARDIAN: '#a76bff',THE_ORACLE: '#19d6ff',THE_WEAVER: '#ff80c4',THE_WILDCARD: '#5cffae',DYNAMIC: '#ffb840',};window.agentColor = (a) => AGENT_COLORS[a] || '#a76bff';const overlay = () => document.getElementById('council-overlay');const pill = () => document.getElementById('council-pill');let _audio = null; // <audio> elementlet _agentAudios = []; // [{audio_url, ...}, ...]let _currentAgents = [];function escapeHtml(s) {return String(s || '').replace(/[&<>"']/g, c => ({'&':'&','<':'<','>':'>','"':'"',"'":'''}[c]));}window.renderCouncil = function (resp, runtime) {const ov = overlay();const body = document.getElementById('co-body');const synth = document.getElementById('co-synth');const count = document.getElementById('co-count');const audio = document.getElementById('debate-audio');_audio = audio;const cd = resp.council_deliberation || {};const agents = cd.agent_outputs || [];_currentAgents = agents;_agentAudios = (runtime && runtime.per_agent_audio) || [];// No agents → hide overlay + pillif (!agents.length) {ov.classList.remove('show');setTimeout(() => ov.classList.add('hidden'), 400);pill().classList.add('hidden');return;}ov.classList.remove('hidden');requestAnimationFrame(() => ov.classList.add('show'));count.textContent = `+${agents.length}`;document.getElementById('pill-count').textContent = agents.length;// Render each agent as a colored cardbody.innerHTML = agents.map((a, i) => {const c = window.agentColor(a.archetype);const audioInfo = _agentAudios[i] || {};const hasAudio = !!audioInfo.audio_url;return `<div class="agent-card" style="border-color:${c}; --card-glow:${c}33; animation-delay:${i * 80}ms"data-aid="${escapeHtml(a.agent_id)}" data-idx="${i}"><div class="row1"><span class="ad-dot" style="background:${c};color:${c}"></span><span class="name" style="color:${c}">${escapeHtml(a.agent_name || 'Agent')}</span><span class="archetype">${escapeHtml((a.archetype || 'DYNAMIC').replace(/^THE_/, ''))}</span>${a.veto_triggered ? '<span class="veto">VETO</span>' : ''}</div><div class="thinking">${escapeHtml(a.thinking || '')}</div><div class="stance">${escapeHtml(a.tts_speech_text || a.stance || '')}</div><div class="footer-row"><div class="conf">confidence ${(a.confidence ?? 0.8).toFixed(2)}</div>${hasAudio ? `<button class="play-mini" data-aurl="${audioInfo.audio_url}" data-idx="${i}" title="Play this agent's voice">▶</button>` : ''}</div></div>`;}).join('');synth.textContent = cd.final_synthesis || '';// Wire per-agent mini-play buttonsbody.querySelectorAll('.play-mini').forEach(btn => {btn.onclick = (ev) => {ev.stopPropagation();const url = btn.dataset.aurl;const idx = +btn.dataset.idx;if (audio.src.endsWith(url) && !audio.paused) {audio.pause();btn.classList.remove('playing');btn.textContent = '▶';return;}// stop any other mini playingbody.querySelectorAll('.play-mini.playing').forEach(b => {b.classList.remove('playing'); b.textContent = '▶';});audio.src = url;audio.play().catch(() => {});btn.classList.add('playing');btn.textContent = '⏸';highlightAgent(idx);audio.onended = () => {btn.classList.remove('playing'); btn.textContent = '▶';clearHighlight();};};});// Combined audio dramaif (runtime && runtime.audio_url) {audio.style.display = 'block';audio.src = runtime.audio_url;audio.dataset.combined = '1';document.getElementById('co-play').disabled = false;document.getElementById('co-pause').disabled = true;// optional autoplay (best-effort, browsers may block)audio.play().then(() => {document.getElementById('co-play').disabled = true;document.getElementById('co-pause').disabled = false;}).catch(() => {});const cards = body.querySelectorAll('.agent-card');let idx = 0;if (cards[0]) cards[0].classList.add('speaking');audio.ontimeupdate = () => {if (!audio.duration || audio.dataset.combined !== '1') return;const target = Math.min(cards.length - 1,Math.floor((audio.currentTime / audio.duration) * cards.length));if (target !== idx) {cards[idx]?.classList.remove('speaking');cards[target]?.classList.add('speaking');idx = target;}};audio.onended = () => {cards.forEach(c => c.classList.remove('speaking'));document.getElementById('co-play').disabled = false;document.getElementById('co-pause').disabled = true;};} else {audio.style.display = 'none';audio.removeAttribute('src');document.getElementById('co-play').disabled = true;document.getElementById('co-pause').disabled = true;}};function highlightAgent(idx) {const cards = document.querySelectorAll('#co-body .agent-card');cards.forEach(c => c.classList.remove('speaking'));cards[idx]?.classList.add('speaking');}function clearHighlight() {document.querySelectorAll('#co-body .agent-card').forEach(c => c.classList.remove('speaking'));}/* ── Controls ── */document.getElementById('co-close').onclick = () => {overlay().classList.remove('show');setTimeout(() => overlay().classList.add('hidden'), 400);pill().classList.add('hidden');if (_audio) { _audio.pause(); _audio.currentTime = 0; }};document.getElementById('co-min').onclick = () => {overlay().classList.add('minimized');if (_currentAgents.length) pill().classList.remove('hidden');};document.getElementById('council-pill').onclick = () => {overlay().classList.remove('minimized');pill().classList.add('hidden');};document.getElementById('co-play').onclick = () => {if (!_audio || !_audio.src) return;_audio.dataset.combined = '1';_audio.play().then(() => {document.getElementById('co-play').disabled = true;document.getElementById('co-pause').disabled = false;}).catch(() => {});};document.getElementById('co-pause').onclick = () => {if (!_audio) return;_audio.pause();document.getElementById('co-play').disabled = false;document.getElementById('co-pause').disabled = true;};/* ── My-Agent button toggles the overlay ── */document.getElementById('my-agent').onclick = () => {const ov = overlay();if (ov.classList.contains('hidden') || ov.classList.contains('minimized')) {if (!_currentAgents.length) {window.toast?.('No agents yet — ask a complex question to summon the council', 'info');return;}ov.classList.remove('hidden', 'minimized');requestAnimationFrame(() => ov.classList.add('show'));pill().classList.add('hidden');} else {ov.classList.remove('show');setTimeout(() => ov.classList.add('hidden'), 400);}};/* ──────────────────────────────────────────────────────────NODE DETAIL POPOVER — fetches /api/node/:id and renderspayload + type + connections (matches image 4 layout)────────────────────────────────────────────────────────── */window.showNodeDetail = async function (n, sx, sy) {window.elysiumSelect?.(n.node_id);const el = document.getElementById('node-detail');el.style.left = Math.min(innerWidth - 340, Math.max(10, sx + 14)) + 'px';el.style.top = Math.min(innerHeight - 340, Math.max(10, sy - 40)) + 'px';// Initial skeleton so user sees something instantlyel.innerHTML = `<div class="nd-head"><div class="nd-title"><span class="nd-dot" style="background:${n.color};color:${n.color}"></span>${escapeHtml(n.label)}</div><button class="nd-close" onclick="window.hideNodeDetail()">×</button></div><div class="nd-type">${escapeHtml(n.type)}</div><div class="nd-stats"><div class="nd-pill"><b>…</b>links</div><div class="nd-pill"><b>…</b>in</div><div class="nd-pill"><b>…</b>out</div></div><div class="nd-section">DESCRIPTION</div><div class="nd-payload">${escapeHtml(n.embedding_hint || (n.payload?.description) || 'Loading…')}</div>`;el.classList.add('show');// Fetch enriched detailstry {const d = await window.ElysiumAPI.nodeDetail(n.node_id);if (!d) return;const conns = (d.incoming || []).concat(d.outgoing || []);const connsHtml = conns.length? conns.slice(0, 6).map(c => `<div class="nd-conn"><span class="ct">${escapeHtml(c.from_label || c.to_label || c.from || c.to)}</span><span class="cw">${(c.weight ?? 0.5).toFixed(2)}</span></div>`).join(''): '<div class="nd-conn"><span class="ct">No connections yet</span></div>';const payload = d.payload && Object.keys(d.payload).length? Object.entries(d.payload).slice(0, 6).map(([k, v]) =>`${escapeHtml(k)}: ${escapeHtml(typeof v === 'object' ? JSON.stringify(v) : String(v))}`).join('\n'): (d.embedding_hint || 'No payload data');1 unmodified lineel.innerHTML = `<div class="nd-head"><div class="nd-title"><span class="nd-dot" style="background:${n.color};color:${n.color}"></span>${escapeHtml(d.label)}</div><button class="nd-close" onclick="window.hideNodeDetail()">×</button></div><div class="nd-type">${escapeHtml(d.node_type)}</div><div class="nd-stats"><div class="nd-pill"><b>${d.degree}</b>links</div><div class="nd-pill"><b>${(d.incoming || []).length}</b>in</div><div class="nd-pill"><b>${(d.outgoing || []).length}</b>out</div></div>2 unmodified lines<div class="nd-section">CONNECTIONS</div><div class="nd-conns">${connsHtml}</div>`;} catch (e) {// local-only fallback}};window.hideNodeDetail = function () {document.getElementById('node-detail').classList.remove('show');window.ELYSIUM?.nodes.forEach(n => n.selected = false);};// Close popover when clicking elsewhere (but not on canvas — canvas handles its own)document.addEventListener('pointerdown', e => {const nd = document.getElementById('node-detail');if (nd.classList.contains('show') &&!nd.contains(e.target) &&e.target.id !== 'elysium-canvas') {// canvas click closes via its own logic; only outside-of-popover clicks hereif (e.target.closest('#elysium-canvas')) return;window.hideNodeDetail();}});1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673681 unmodified line3703713723733743753763773783793803813823832 unmodified lines386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415/* ============================================================ELYSIUM — council.jsCouncil overlay + Node-detail popover.Implements:• Council slide-in panel with per-agent cards• Combined-track playback (▶ / ⏸)• Per-agent mini play buttons• Speaking-agent highlight synced to audio time• Node-detail popover (Task 3) — fetches /api/node/:id andfalls back to local node payload if backend not reachable• All DOM access is defensive — no "classList of null" crashes============================================================ */(() => {'use strict';const AGENT_COLORS = {THE_BUILDER: '#ff4fa3',THE_GUARDIAN: '#a76bff',THE_ORACLE: '#19d6ff',THE_WEAVER: '#ff80c4',THE_WILDCARD: '#5cffae',DYNAMIC: '#ffb840',};window.agentColor = (a) => AGENT_COLORS[a] || '#a76bff';const $ = (id) => document.getElementById(id);const safe = (fn) => { try { return fn(); } catch (e) { console.warn(e); } };function escapeHtml(s) {return String(s == null ? '' : s).replace(/[&<>"']/g, c => ({'&':'&','<':'<','>':'>','"':'"',"'":'''}[c]));}let _audio = null;let _agentAudios = [];let _currentAgents = [];/* =========================================================RENDER COUNCIL (called from boot.js handleResponse)========================================================= */window.renderCouncil = function (resp, runtime) {const ov = $('council-overlay');const body = $('co-body');const synth = $('co-synth');const count = $('co-count');const audio = $('debate-audio');if (!ov || !body) return;_audio = audio;const cd = (resp && resp.council_deliberation) || {};const agents = Array.isArray(cd.agent_outputs) ? cd.agent_outputs : [];_currentAgents = agents;_agentAudios = (runtime && Array.isArray(runtime.per_agent_audio))? runtime.per_agent_audio : [];// No agents → hide overlay + pillif (!agents.length) {ov.classList.remove('show');setTimeout(() => ov.classList.add('hidden'), 400);const pill = $('council-pill'); if (pill) pill.classList.add('hidden');if (synth) synth.textContent = '';if (audio) { try { audio.pause(); } catch {} audio.removeAttribute('src'); audio.style.display='none'; }if (count) count.textContent = '+0';return;}ov.classList.remove('hidden');requestAnimationFrame(() => ov.classList.add('show'));if (count) count.textContent = `+${agents.length}`;const pillCount = $('pill-count');if (pillCount) pillCount.textContent = agents.length;body.innerHTML = agents.map((a, i) => {if (!a) return '';const c = window.agentColor(a.archetype);const audioInfo = _agentAudios[i] || {};const hasAudio = !!audioInfo.audio_url;const archetype = (a.archetype || 'DYNAMIC').replace(/^THE_/, '');return `<div class="agent-card" style="border-color:${c}; --card-glow:${c}33; animation-delay:${i * 80}ms"data-aid="${escapeHtml(a.agent_id)}" data-idx="${i}"><div class="row1"><span class="ad-dot" style="background:${c};color:${c}"></span><span class="name" style="color:${c}">${escapeHtml(a.agent_name || 'Agent')}</span><span class="archetype">${escapeHtml(archetype)}</span>${a.veto_triggered ? '<span class="veto">VETO</span>' : ''}</div><div class="thinking">${escapeHtml(a.thinking || '')}</div><div class="stance">${escapeHtml(a.tts_speech_text || a.stance || '')}</div><div class="footer-row"><div class="conf">confidence ${(typeof a.confidence === 'number' ? a.confidence : 0.8).toFixed(2)}</div>${hasAudio ? `<button class="play-mini" data-aurl="${audioInfo.audio_url}" data-idx="${i}" title="Play this agent's voice">▶</button>` : ''}</div></div>`;}).join('');if (synth) synth.textContent = cd.final_synthesis || '';// Wire per-agent mini-play buttonsif (audio) {body.querySelectorAll('.play-mini').forEach(btn => {btn.onclick = (ev) => {ev.stopPropagation();const url = btn.dataset.aurl;const idx = +btn.dataset.idx;if (audio.src && audio.src.endsWith(url) && !audio.paused) {audio.pause();btn.classList.remove('playing');btn.textContent = '▶';return;}body.querySelectorAll('.play-mini.playing').forEach(b => {b.classList.remove('playing'); b.textContent = '▶';});audio.dataset.combined = '0';audio.src = url;audio.play().catch(() => {});btn.classList.add('playing');btn.textContent = '⏸';highlightAgent(idx);audio.onended = () => {btn.classList.remove('playing'); btn.textContent = '▶';clearHighlight();};};});// Combined audio drama (if backend produced one)if (runtime && runtime.audio_url) {audio.style.display = 'block';audio.src = runtime.audio_url;audio.dataset.combined = '1';const playBtn = $('co-play');const pauseBtn = $('co-pause');if (playBtn) playBtn.disabled = false;if (pauseBtn) pauseBtn.disabled = true;audio.play().then(() => {if (playBtn) playBtn.disabled = true;if (pauseBtn) pauseBtn.disabled = false;}).catch(() => {});const cards = body.querySelectorAll('.agent-card');let idx = 0;if (cards[0]) cards[0].classList.add('speaking');audio.ontimeupdate = () => {if (!audio.duration || audio.dataset.combined !== '1') return;const target = Math.min(cards.length - 1,Math.floor((audio.currentTime / audio.duration) * cards.length));if (target !== idx) {cards[idx]?.classList.remove('speaking');cards[target]?.classList.add('speaking');idx = target;}};audio.onended = () => {cards.forEach(c => c.classList.remove('speaking'));if (playBtn) playBtn.disabled = false;if (pauseBtn) pauseBtn.disabled = true;};} else {audio.style.display = 'none';audio.removeAttribute('src');const playBtn = $('co-play');const pauseBtn = $('co-pause');if (playBtn) playBtn.disabled = true;if (pauseBtn) pauseBtn.disabled = true;}}};function highlightAgent(idx) {const cards = document.querySelectorAll('#co-body .agent-card');cards.forEach(c => c.classList.remove('speaking'));if (cards[idx]) cards[idx].classList.add('speaking');}function clearHighlight() {document.querySelectorAll('#co-body .agent-card').forEach(c => c.classList.remove('speaking'));}/* =========================================================OVERLAY CONTROLS (defensive — only wire if button exists)========================================================= */const wire = (id, fn) => { const el = $(id); if (el) el.onclick = fn; };wire('co-close', () => {const ov = $('council-overlay');if (ov) {ov.classList.remove('show');setTimeout(() => ov.classList.add('hidden'), 400);}const pill = $('council-pill'); if (pill) pill.classList.add('hidden');if (_audio) { try { _audio.pause(); _audio.currentTime = 0; } catch {} }});wire('co-min', () => {const ov = $('council-overlay'); if (ov) ov.classList.add('minimized');if (_currentAgents.length) { const p = $('council-pill'); if (p) p.classList.remove('hidden'); }});wire('council-pill', () => {const ov = $('council-overlay');if (ov) ov.classList.remove('minimized');const p = $('council-pill'); if (p) p.classList.add('hidden');});wire('co-play', () => {if (!_audio || !_audio.src) return;_audio.dataset.combined = '1';_audio.play().then(() => {const playBtn = $('co-play');const pauseBtn = $('co-pause');if (playBtn) playBtn.disabled = true;if (pauseBtn) pauseBtn.disabled = false;}).catch(() => {});});wire('co-pause', () => {if (!_audio) return;try { _audio.pause(); } catch {}const playBtn = $('co-play');const pauseBtn = $('co-pause');if (playBtn) playBtn.disabled = false;if (pauseBtn) pauseBtn.disabled = true;});// My-Agent button: toggle overlay (and warn if empty)wire('my-agent', () => {const ov = $('council-overlay');if (!ov) return;if (ov.classList.contains('hidden') || ov.classList.contains('minimized')) {if (!_currentAgents.length) {if (window.toast) window.toast('No agents yet — ask a complex question to summon the council', 'info');return;}ov.classList.remove('hidden', 'minimized');requestAnimationFrame(() => ov.classList.add('show'));const p = $('council-pill'); if (p) p.classList.add('hidden');} else {ov.classList.remove('show');setTimeout(() => ov.classList.add('hidden'), 400);}});/* =========================================================NODE DETAIL POPOVER (Task 3)Click any node → fetch enriched detail from /api/node/:id,fall back to local data if offline.========================================================= */window.showNodeDetail = async function (n, sx, sy) {const el = $('node-detail');if (!el || !n) return;if (typeof window.elysiumSelect === 'function') {try { window.elysiumSelect(n.node_id); } catch {}}// Position popover near click but keep on-screenconst W = window.innerWidth, H = window.innerHeight;const left = Math.min(W - 340, Math.max(10, (sx || W/2) + 14));const top = Math.min(H - 360, Math.max(10, (sy || H/2) - 40));el.style.left = left + 'px';el.style.top = top + 'px';// Initial skeleton with locally-known data (instant render)const localPayload = n.payload && Object.keys(n.payload).length? Object.entries(n.payload).slice(0, 6).map(([k, v]) =>`${escapeHtml(k)}: ${escapeHtml(typeof v === 'object' ? JSON.stringify(v) : String(v))}`).join('\n'): (n.embedding_hint || 'Loading details…');el.innerHTML = `<div class="nd-head"><div class="nd-title"><span class="nd-dot" style="background:${n.color};color:${n.color}"></span>${escapeHtml(n.label)}</div><button class="nd-close" aria-label="Close">×</button></div><div class="nd-type">${escapeHtml(n.type)}</div><div class="nd-stats"><div class="nd-pill"><b>…</b>links</div><div class="nd-pill"><b>…</b>in</div><div class="nd-pill"><b>…</b>out</div></div><div class="nd-section">PAYLOAD</div><div class="nd-payload">${escapeHtml(localPayload)}</div><div class="nd-section">CONNECTIONS</div><div class="nd-conns"><div class="nd-conn"><span class="ct">Loading…</span></div></div>`;el.classList.remove('hidden');requestAnimationFrame(() => el.classList.add('show'));// Wire closeconst closeBtn = el.querySelector('.nd-close');if (closeBtn) closeBtn.onclick = (ev) => { ev.stopPropagation(); window.hideNodeDetail(); };// Compute local connections immediately (works even offline)const localConns = [];if (window.ELYSIUM) {window.ELYSIUM.edges.forEach(e => {if (e.src === n.node_id) {const target = window.ELYSIUM.nodes.get(e.dst);localConns.push({ct: target ? target.label : e.dst,type: e.type,weight: e.weight,dir: 'out',});} else if (e.dst === n.node_id) {const source = window.ELYSIUM.nodes.get(e.src);localConns.push({ct: source ? source.label : e.src,type: e.type,weight: e.weight,dir: 'in',});}});}// Render with local data firstrenderDetail(el, {node_id: n.node_id,label: n.label,node_type: n.type,payload: n.payload || {},embedding_hint: n.embedding_hint || '',incoming: localConns.filter(c => c.dir === 'in').map(c => ({from_label: c.ct, edge_type: c.type, weight: c.weight,})),outgoing: localConns.filter(c => c.dir === 'out').map(c => ({to_label: c.ct, edge_type: c.type, weight: c.weight,})),degree: localConns.length,});// Then try to enrich from backend (silent fail)if (window.ElysiumAPI && window.ElysiumAPI.nodeDetail) {try {const d = await window.ElysiumAPI.nodeDetail(n.node_id);if (d) renderDetail(el, d);} catch (e) { /* keep local data */ }}};function renderDetail(el, d) {if (!el || !d) return;const n = window.ELYSIUM ? window.ELYSIUM.nodes.get(d.node_id) : null;const color = (n && n.color) || (window.colorFor ? window.colorFor(d.node_type) : '#a76bff');const conns = (Array.isArray(d.incoming) ? d.incoming : []).concat(Array.isArray(d.outgoing) ? d.outgoing : []);const connsHtml = conns.length? conns.slice(0, 8).map(c => `<div class="nd-conn"><span class="ct">${escapeHtml(c.from_label || c.to_label || c.from || c.to || '?')}</span><span class="cw">${(typeof c.weight === 'number' ? c.weight : 0.5).toFixed(2)}</span></div>`).join(''): '<div class="nd-conn"><span class="ct">No connections yet</span></div>';const payload = d.payload && Object.keys(d.payload).length? Object.entries(d.payload).slice(0, 8).map(([k, v]) =>`${escapeHtml(k)}: ${escapeHtml(typeof v === 'object' ? JSON.stringify(v) : String(v))}`).join('\n'): (d.embedding_hint || 'No payload data');1 unmodified lineel.innerHTML = `<div class="nd-head"><div class="nd-title"><span class="nd-dot" style="background:${color};color:${color}"></span>${escapeHtml(d.label || d.node_id)}</div><button class="nd-close" aria-label="Close">×</button></div><div class="nd-type">${escapeHtml(d.node_type || '')}</div><div class="nd-stats"><div class="nd-pill"><b>${d.degree ?? conns.length}</b>links</div><div class="nd-pill"><b>${(d.incoming || []).length}</b>in</div><div class="nd-pill"><b>${(d.outgoing || []).length}</b>out</div></div>2 unmodified lines<div class="nd-section">CONNECTIONS</div><div class="nd-conns">${connsHtml}</div>`;const closeBtn = el.querySelector('.nd-close');if (closeBtn) closeBtn.onclick = (ev) => { ev.stopPropagation(); window.hideNodeDetail(); };}window.hideNodeDetail = function () {const el = $('node-detail');if (!el) return;el.classList.remove('show');setTimeout(() => el.classList.add('hidden'), 250);if (window.ELYSIUM) window.ELYSIUM.nodes.forEach(n => n.selected = false);};// Click outside popover (and outside canvas) → closedocument.addEventListener('pointerdown', e => {const nd = $('node-detail');if (!nd || nd.classList.contains('hidden')) return;if (nd.contains(e.target)) return; // click inside popoverif (e.target.id === 'elysium-canvas') return; // canvas handles its ownif (e.target.closest && e.target.closest('#minimap-wrap')) return;window.hideNodeDetail();});// Escape closes popoverdocument.addEventListener('keydown', e => {if (e.key === 'Escape') window.hideNodeDetail();});})();
1234567836 unmodified lines45464748495051523 unmodified lines5657585960616248 unmodified lines11111211311411511611711811912012112212312412512613 unmodified lines1401411421431441451465 unmodified lines152153154155156157158159160161162163164165166167168169170171172173174175176177178179109 unmodified lines2892902912922932942954 unmodified lines3003013023033043053063073083093103111 unmodified line3133143153163173183199 unmodified lines3293303313323333343357 unmodified lines34334434534634734834912 unmodified lines3623633643653663673689 unmodified lines3783793803813823833843853863873 unmodified lines391392393394395396397398399400401402403404405406407408409/* ============================================================ELYSIUM — Dark Neon Bioluminescent ThemeHeavily inspired by the reference images:deep teal-black backdrop, magenta/cyan/violet/gold neon nodes,glassy panels with neon hairline borders.============================================================ */:root{--bg-0:#02080c;36 unmodified lines*,*::before,*::after{box-sizing:border-box;-webkit-tap-highlight-color:transparent}html,body{margin:0;padding:0;height:100%;width:100%;overflow:hidden;background:radial-gradient(ellipse 90% 70% at 50% 40%, #0a2434 0%, #03101a 55%, #01060b 100%);color:var(--text);font-family:var(--font-sans);font-size:14px;user-select:none;-webkit-user-select:none}button{font-family:inherit;color:inherit;cursor:pointer}3 unmodified linestouch-action:none;z-index:0}#elysium-canvas.dragging{cursor:grabbing}/* ── GLASS PANELS ─────────────────────────────────────── */.glass{background:linear-gradient(180deg, var(--panel), var(--panel-2));border:1px solid var(--border);48 unmodified linesbox-shadow:inset 0 0 8px rgba(0,229,200,.08)}/* ── MINIMAP ──────────────────────────────────────────── */#minimap-wrap{position:fixed;left:74px;bottom:140px;z-index:15;background:rgba(2,12,18,.85);border:1px solid var(--border);border-radius:12px;padding:6px 6px 4px;box-shadow:var(--shadow);backdrop-filter:blur(10px)}.minimap-label{font-size:9px;letter-spacing:2.2px;color:var(--muted);text-align:center;margin-bottom:4px;font-weight:600}#minimap{display:block;width:170px;height:108px;border-radius:8px;cursor:crosshair;background:rgba(2,16,22,.95)}/* ── ZOOM CTRL ────────────────────────────────────────── */#zoom-ctrl{position:fixed;right:24px;bottom:140px;display:flex;flex-direction:column;gap:6px;z-index:15}#zoom-ctrl button{width:38px;height:38px;background:rgba(6,18,26,.85);border:1px solid var(--border);border-radius:10px;color:var(--teal);13 unmodified lines@keyframes crisisPulse{0%,100%{opacity:.6}50%{opacity:1}}/* ── STATS BAR ────────────────────────────────────────── */#stats{position:fixed;left:58px;right:0;bottom:84px;height:56px;display:flex;align-items:center;padding:0 28px;gap:32px;z-index:18;border-radius:0;border-left:none;border-right:none;border-bottom:none;background:linear-gradient(180deg,rgba(2,12,18,.72),rgba(2,8,12,.92))}5 unmodified lines.stat-value{font-size:22px;font-family:var(--font-disp);color:var(--cyan);font-weight:700;line-height:1;text-shadow:0 0 8px rgba(25,214,255,.45)}/* ── QUERY AREA (preview strip + bar + mode row) ──────── */#query-area{position:fixed;left:58px;right:0;bottom:0;z-index:20;display:flex;flex-direction:column;gap:0}#attach-strip{margin:0 22px 6px;padding:8px 10px;display:flex;gap:8px;flex-wrap:wrap;align-items:center;border-radius:14px 14px 14px 14px;border-bottom:none;max-height:84px;overflow:auto}.preview-tile{display:flex;align-items:center;gap:8px;background:rgba(0,229,200,.06);border:1px solid var(--border-strong);border-radius:10px;padding:4px 8px 4px 4px;font-size:11px;color:var(--text)}.preview-tile img{width:38px;height:38px;border-radius:6px;object-fit:cover;box-shadow:0 0 8px rgba(0,229,200,.3)}.preview-tile .pdf-ico{width:38px;height:38px;border-radius:6px;display:grid;place-items:center;background:linear-gradient(135deg,#3a1a2a,#1a0a14);color:var(--magenta);font-family:var(--font-mono);font-size:11px;font-weight:700;box-shadow:var(--neon-magenta)}.preview-tile .nm{max-width:120px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-family:var(--font-mono)}.preview-tile .x{background:none;border:none;color:var(--muted);font-size:14px;cursor:pointer;padding:0 4px}.preview-tile .x:hover{color:var(--red)}.attach-hint{font-size:11px;color:var(--muted-2);margin-left:6px}#query-bar{margin:0 22px 8px;height:54px;display:flex;align-items:center;padding:0 12px;gap:10px;109 unmodified lines#co-synth:empty{display:none}#debate-audio{width:100%;margin-top:10px;height:32px;display:none}/* COUNCIL PILL (minimized state) */#council-pill{position:fixed;left:22px;top:22px;z-index:24;padding:8px 16px;border-radius:20px;background:rgba(6,18,26,.92);border:1px solid var(--border-strong);color:var(--text);font-size:12px;4 unmodified lines#council-pill .dot-mini{width:8px;height:8px;border-radius:50%;background:var(--magenta);box-shadow:var(--neon-magenta)}/* ── NODE DETAIL POPOVER ──────────────────────────────── */#node-detail{position:fixed;width:320px;padding:18px;z-index:30;opacity:0;transform:translateY(8px);pointer-events:none;transition:opacity .25s,transform .25s;border:1px solid var(--border-strong);box-shadow:var(--neon-teal),var(--shadow)}#node-detail.show{opacity:1;transform:translateY(0);pointer-events:auto}.nd-head{display:flex;justify-content:space-between;align-items:flex-start;margin-bottom:8px;gap:8px}.nd-title{font-size:14px;font-weight:700;display:flex;align-items:center;gap:8px;1 unmodified line.nd-title .nd-dot{width:16px;height:16px;border-radius:50%;flex-shrink:0;box-shadow:0 0 12px currentColor}.nd-close{background:none;border:none;color:var(--muted);font-size:20px;cursor:pointer;padding:0;line-height:1}.nd-close:hover{color:var(--text)}.nd-type{font-size:10px;letter-spacing:1.6px;color:var(--cyan);text-transform:uppercase;margin-bottom:12px;font-family:var(--font-mono);9 unmodified lines.nd-payload{font-size:11px;color:var(--text);background:rgba(0,0,0,.25);padding:8px 10px;border-radius:8px;font-family:var(--font-mono);max-height:90px;overflow:auto;line-height:1.5;border-left:2px solid var(--border-strong)}.nd-conns{font-size:11px;color:var(--muted);max-height:100px;overflow:auto}.nd-conn{display:flex;justify-content:space-between;padding:3px 0;border-bottom:1px solid rgba(0,229,200,.07)}7 unmodified linesborder-left:3px solid var(--teal);padding:10px 18px;border-radius:10px;font-size:12px;color:var(--text);box-shadow:var(--neon-teal),var(--shadow);animation:toastIn .35s ease both,toastOut .4s ease 4.5s both;backdrop-filter:blur(10px)}.toast.warn{border-left-color:var(--gold);box-shadow:var(--neon-gold),var(--shadow)}.toast.error{border-left-color:var(--red);box-shadow:0 0 14px rgba(255,84,105,.5)}.toast.info{border-left-color:var(--violet);box-shadow:var(--neon-violet),var(--shadow)}12 unmodified lines@keyframes hintFloat{0%,100%{opacity:.7;transform:translate(-50%,-50%)}50%{opacity:1;transform:translate(-50%,calc(-50% - 6px))}}/* ── BUSY OVERLAY (blocks input while model thinks) ──── */#busy-overlay{position:fixed;inset:0;z-index:35;pointer-events:none;display:none;place-items:center;background:rgba(2,12,18,0);transition:background .3s}9 unmodified lines/* ── RESPONSIVE ───────────────────────────────────────── */@media (max-width:980px){#legend{width:200px;padding:14px;top:14px;right:14px}#minimap-wrap{padding:5px}#minimap{width:140px;height:90px}#zoom-ctrl{right:14px;bottom:124px}#stats{gap:20px;padding:0 16px}.stat-value{font-size:18px}.stat-label{font-size:9px}#council-overlay{width:300px}3 unmodified lines#legend{width:170px;padding:12px;top:10px;right:10px;font-size:11px}#legend .lbl{display:none}.meta-row{font-size:10px}#minimap-wrap{left:54px;bottom:118px}#minimap{width:120px;height:80px}#stats{gap:14px;padding:0 12px;height:48px;bottom:78px}.stat-value{font-size:15px}.stat-icon{font-size:14px}#query-area{left:44px}.mode-row{padding-right:14px}#council-overlay{left:8px;right:8px;width:auto;top:8px;max-height:calc(100vh - 200px)}#zoom-ctrl{bottom:78px;right:10px}}/* ── HIDE GRADIO if ever shown ─────────────────────────── */.gradio-container,footer,.built-with,gradio-app>.main>.contain{display:none!important}.hidden{display:none!important}1234536 unmodified lines424344454647483 unmodified lines5253545556575848 unmodified lines10710810911011111211311411511611711811912012112213 unmodified lines1361371381391401411425 unmodified lines148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183109 unmodified lines2932942952962972982994 unmodified lines3043053063073083093103113123133143153161 unmodified line3183193203213223233249 unmodified lines3343353363373383393407 unmodified lines34834935035135235335412 unmodified lines3673683693703713723739 unmodified lines3833843853863873883893903913923 unmodified lines396397398399400401402403404405406407408409410411412413414415/* ============================================================ELYSIUM — Dark Neon Bioluminescent Theme============================================================ */:root{--bg-0:#02080c;36 unmodified lines*,*::before,*::after{box-sizing:border-box;-webkit-tap-highlight-color:transparent}html,body{margin:0;padding:0;height:100%;width:100%;overflow:hidden;background:radial-gradient(ellipse 90% 70% at 50% 40%, #0a2434 0%, #03101a 55%, #01060b 100%);color:var(--text);font-family:var(--font-sans);font-size:14px;user-select:none;-webkit-user-select:none}button{font-family:inherit;color:inherit;cursor:pointer}3 unmodified linestouch-action:none;z-index:0}#elysium-canvas.dragging{cursor:grabbing}/* ── GLASS ────────────────────────────────────────────── */.glass{background:linear-gradient(180deg, var(--panel), var(--panel-2));border:1px solid var(--border);48 unmodified linesbox-shadow:inset 0 0 8px rgba(0,229,200,.08)}/* ── MINIMAP ──────────────────────────────────────────── */#minimap-wrap{position:fixed;left:74px;bottom:170px;z-index:15;background:rgba(2,12,18,.85);border:1px solid var(--border);border-radius:12px;padding:6px 6px 4px;box-shadow:var(--shadow);backdrop-filter:blur(10px)}.minimap-label{font-size:9px;letter-spacing:2.2px;color:var(--muted);text-align:center;margin-bottom:4px;font-weight:600}#minimap{display:block;width:170px;height:108px;border-radius:8px;cursor:crosshair;background:rgba(2,16,22,.95);touch-action:none}/* ── ZOOM CTRL ────────────────────────────────────────── */#zoom-ctrl{position:fixed;right:24px;bottom:170px;display:flex;flex-direction:column;gap:6px;z-index:15}#zoom-ctrl button{width:38px;height:38px;background:rgba(6,18,26,.85);border:1px solid var(--border);border-radius:10px;color:var(--teal);13 unmodified lines@keyframes crisisPulse{0%,100%{opacity:.6}50%{opacity:1}}/* ── STATS BAR ────────────────────────────────────────── */#stats{position:fixed;left:58px;right:0;bottom:108px;height:56px;display:flex;align-items:center;padding:0 28px;gap:32px;z-index:18;border-radius:0;border-left:none;border-right:none;border-bottom:none;background:linear-gradient(180deg,rgba(2,12,18,.72),rgba(2,8,12,.92))}5 unmodified lines.stat-value{font-size:22px;font-family:var(--font-disp);color:var(--cyan);font-weight:700;line-height:1;text-shadow:0 0 8px rgba(25,214,255,.45)}/* ── QUERY AREA ───────────────────────────────────────── */#query-area{position:fixed;left:58px;right:0;bottom:0;z-index:20;display:flex;flex-direction:column;gap:0;padding-bottom:8px}/* File preview strip — appears ABOVE input when files attached */#attach-strip{margin:0 22px 6px;padding:8px 10px;display:flex;gap:8px;flex-wrap:wrap;align-items:center;border-radius:14px;max-height:84px;overflow:auto;animation:stripIn .25s ease-out}@keyframes stripIn{from{opacity:0;transform:translateY(8px)}to{opacity:1;transform:translateY(0)}}.preview-tile{display:flex;align-items:center;gap:8px;background:rgba(0,229,200,.06);border:1px solid var(--border-strong);border-radius:10px;padding:4px 8px 4px 4px;font-size:11px;color:var(--text);animation:tileIn .3s ease}@keyframes tileIn{from{opacity:0;transform:scale(.9)}to{opacity:1;transform:scale(1)}}.preview-tile img{width:38px;height:38px;border-radius:6px;object-fit:cover;box-shadow:0 0 8px rgba(0,229,200,.3)}.preview-tile .pdf-ico{width:38px;height:38px;border-radius:6px;display:grid;place-items:center;background:linear-gradient(135deg,#3a1a2a,#1a0a14);color:var(--magenta);font-family:var(--font-mono);font-size:11px;font-weight:700;box-shadow:var(--neon-magenta)}.preview-tile .nm{max-width:140px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-family:var(--font-mono)}.preview-tile .x{background:rgba(255,84,105,.12);border:1px solid rgba(255,84,105,.25);color:#ffb0b0;font-size:14px;font-weight:bold;cursor:pointer;padding:0;width:20px;height:20px;border-radius:50%;display:grid;place-items:center;transition:all .15s;line-height:1}.preview-tile .x:hover{background:var(--red);color:#fff;transform:scale(1.1);box-shadow:0 0 8px rgba(255,84,105,.5)}.attach-hint{font-size:11px;color:var(--muted-2);margin-left:6px;font-style:italic}#query-bar{margin:0 22px 8px;height:54px;display:flex;align-items:center;padding:0 12px;gap:10px;109 unmodified lines#co-synth:empty{display:none}#debate-audio{width:100%;margin-top:10px;height:32px;display:none}/* COUNCIL PILL (minimized) */#council-pill{position:fixed;left:22px;top:22px;z-index:24;padding:8px 16px;border-radius:20px;background:rgba(6,18,26,.92);border:1px solid var(--border-strong);color:var(--text);font-size:12px;4 unmodified lines#council-pill .dot-mini{width:8px;height:8px;border-radius:50%;background:var(--magenta);box-shadow:var(--neon-magenta)}/* ── NODE DETAIL POPOVER (Task 3) ─────────────────────── */#node-detail{position:fixed;width:320px;padding:18px;z-index:30;opacity:0;transform:translateY(8px);pointer-events:none;transition:opacity .25s,transform .25s;border:1px solid var(--border-strong);box-shadow:var(--neon-teal),var(--shadow)}#node-detail.show{opacity:1;transform:translateY(0);pointer-events:auto}#node-detail.hidden{display:none}.nd-head{display:flex;justify-content:space-between;align-items:flex-start;margin-bottom:8px;gap:8px}.nd-title{font-size:14px;font-weight:700;display:flex;align-items:center;gap:8px;1 unmodified line.nd-title .nd-dot{width:16px;height:16px;border-radius:50%;flex-shrink:0;box-shadow:0 0 12px currentColor}.nd-close{background:none;border:none;color:var(--muted);font-size:20px;cursor:pointer;padding:0;line-height:1;width:24px;height:24px}.nd-close:hover{color:var(--text)}.nd-type{font-size:10px;letter-spacing:1.6px;color:var(--cyan);text-transform:uppercase;margin-bottom:12px;font-family:var(--font-mono);9 unmodified lines.nd-payload{font-size:11px;color:var(--text);background:rgba(0,0,0,.25);padding:8px 10px;border-radius:8px;font-family:var(--font-mono);max-height:90px;overflow:auto;line-height:1.5;border-left:2px solid var(--border-strong);white-space:pre-wrap;word-break:break-word}.nd-conns{font-size:11px;color:var(--muted);max-height:100px;overflow:auto}.nd-conn{display:flex;justify-content:space-between;padding:3px 0;border-bottom:1px solid rgba(0,229,200,.07)}7 unmodified linesborder-left:3px solid var(--teal);padding:10px 18px;border-radius:10px;font-size:12px;color:var(--text);box-shadow:var(--neon-teal),var(--shadow);animation:toastIn .35s ease both,toastOut .4s ease 4.5s both;backdrop-filter:blur(10px);max-width:480px}.toast.warn{border-left-color:var(--gold);box-shadow:var(--neon-gold),var(--shadow)}.toast.error{border-left-color:var(--red);box-shadow:0 0 14px rgba(255,84,105,.5)}.toast.info{border-left-color:var(--violet);box-shadow:var(--neon-violet),var(--shadow)}12 unmodified lines@keyframes hintFloat{0%,100%{opacity:.7;transform:translate(-50%,-50%)}50%{opacity:1;transform:translate(-50%,calc(-50% - 6px))}}/* ── BUSY OVERLAY ─────────────────────────────────────── */#busy-overlay{position:fixed;inset:0;z-index:35;pointer-events:none;display:none;place-items:center;background:rgba(2,12,18,0);transition:background .3s}9 unmodified lines/* ── RESPONSIVE ───────────────────────────────────────── */@media (max-width:980px){#legend{width:200px;padding:14px;top:14px;right:14px}#minimap-wrap{padding:5px;bottom:160px}#minimap{width:140px;height:90px}#zoom-ctrl{right:14px;bottom:160px}#stats{gap:20px;padding:0 16px;bottom:100px}.stat-value{font-size:18px}.stat-label{font-size:9px}#council-overlay{width:300px}3 unmodified lines#legend{width:170px;padding:12px;top:10px;right:10px;font-size:11px}#legend .lbl{display:none}.meta-row{font-size:10px}#minimap-wrap{left:54px;bottom:140px}#minimap{width:120px;height:80px}#stats{gap:14px;padding:0 12px;height:48px;bottom:96px}.stat-value{font-size:15px}.stat-icon{font-size:14px}#query-area{left:44px}.mode-row{padding-right:14px}#council-overlay{left:8px;right:8px;width:auto;top:8px;max-height:calc(100vh - 240px)}#zoom-ctrl{bottom:96px;right:10px}#node-detail{width:280px}}/* Hide any default Gradio surface */.gradio-container,footer,.built-with,gradio-app>.main>.contain{display:none!important}.hidden{display:none!important}
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133/* Bioluminescent node rendering — dark-neon theme to match reference images. */const TYPE_COLOR = {CORE: '#ffb840', // golden seedCIVILIZATION: '#ffb840',DOMAIN: '#a76bff', // violetAGENT: '#ff4fa3', // magentaTOOL: '#ff9b3c', // warm orangePROJECT: '#19d6ff', // cyanLIFE_EVENT: '#5cffae', // greenEMOTION: '#ff80c4', // pinkPERSON: '#ff70b8', // pinkVALUE: '#7e5cff', // violetMEMORY: '#00e5c8', // tealFACT: '#19d6ff', // cyanCONCEPT: '#a76bff',QUERY: '#5cffae',};const DEFAULT_COLOR = '#a76bff';function shade(hex, amt) {const c = parseInt(hex.slice(1), 16);let r = (c >> 16) + amt, g = ((c >> 8) & 255) + amt, b = (c & 255) + amt;r = Math.max(0, Math.min(255, r));g = Math.max(0, Math.min(255, g));b = Math.max(0, Math.min(255, b));return '#' + ((r << 16) | (g << 8) | b).toString(16).padStart(6, '0');}window.colorFor = (type) => TYPE_COLOR[type] || DEFAULT_COLOR;window.TYPE_COLOR = TYPE_COLOR;window.drawNode = function (ctx, n, t, zoom) {const ageMs = t - (n.born || t);const age = Math.min(1, ageMs / 700);const k = age;const overshoot = age < 1? 1 + 1.7 * (k - 1) ** 3 + 0.7 * (k - 1) ** 2: 1;const pulse = 1 + 0.06 * Math.sin((t / 1000) * 0.55 + (n.phase || 0));const r = n.radius * pulse * overshoot;const x = n.x, y = n.y;ctx.globalAlpha = age;// outer halo (soft glow)const halo = ctx.createRadialGradient(x, y, r * 0.9, x, y, r * 2.6);halo.addColorStop(0, n.color + 'aa');halo.addColorStop(0.5, n.color + '33');halo.addColorStop(1, n.color + '00');ctx.fillStyle = halo;ctx.beginPath(); ctx.arc(x, y, r * 2.6, 0, Math.PI * 2); ctx.fill();// rotating dashed orbital ring (CORE only)if (n.type === 'CORE' || n.type === 'CIVILIZATION') {ctx.save();ctx.translate(x, y);ctx.rotate(t * 0.0004);ctx.strokeStyle = n.color + '88';ctx.lineWidth = 1.5 / zoom;ctx.setLineDash([6 / zoom, 6 / zoom]);ctx.beginPath(); ctx.arc(0, 0, r * 1.85, 0, Math.PI * 2); ctx.stroke();ctx.setLineDash([]);ctx.restore();}// main sphere — neon gradientconst grad = ctx.createRadialGradient(x - r * 0.35, y - r * 0.35, r * 0.1, x, y, r);grad.addColorStop(0, shade(n.color, 60));grad.addColorStop(0.5, n.color);grad.addColorStop(1, shade(n.color, -70));ctx.shadowColor = n.color;ctx.shadowBlur = 28 * pulse;ctx.fillStyle = grad;ctx.beginPath(); ctx.arc(x, y, r, 0, Math.PI * 2); ctx.fill();ctx.shadowBlur = 0;// specular highlightctx.fillStyle = 'rgba(255,255,255,.5)';ctx.beginPath();ctx.ellipse(x - r * 0.32, y - r * 0.32, r * 0.28, r * 0.17, -0.5, 0, Math.PI * 2);ctx.fill();// selection ringif (n.selected) {ctx.strokeStyle = '#19d6ff';ctx.lineWidth = 2.5 / zoom;ctx.setLineDash([4 / zoom, 4 / zoom]);ctx.beginPath(); ctx.arc(x, y, r + 8 / zoom, 0, Math.PI * 2); ctx.stroke();ctx.setLineDash([]);}// counter badgeif (n.count != null && zoom > 0.5) {const bx = x - r * 1.1, by = y - r * 0.8;ctx.fillStyle = 'rgba(0,0,0,.7)';ctx.strokeStyle = n.color + '88';ctx.lineWidth = 1 / zoom;if (ctx.roundRect) {ctx.beginPath();ctx.roundRect(bx - 12, by - 8, 22, 16, 8);ctx.fill(); ctx.stroke();}ctx.fillStyle = '#fff';ctx.font = `bold ${10}px Space Mono`;ctx.textAlign = 'center'; ctx.textBaseline = 'middle';ctx.fillText(String(n.count), bx - 1, by);}// labelif (zoom > 0.4 && n.label) {const fs = Math.min(13, 11 * Math.max(1, zoom * 0.85));// text shadow for legibilityctx.fillStyle = 'rgba(0,0,0,.6)';ctx.font = `500 ${fs / zoom}px Inter, sans-serif`;ctx.textAlign = 'center'; ctx.textBaseline = 'top';const lbl = n.label.length > 24 ? n.label.slice(0, 22) + '…' : n.label;ctx.fillText(lbl, x + 1 / zoom, y + r + 7 / zoom);ctx.fillStyle = '#d8f6fa';ctx.fillText(lbl, x, y + r + 6 / zoom);}// pulse highlight ring (from UI directive)if (n.pulseUntil && t < n.pulseUntil) {const p = (n.pulseUntil - t) / 1400;ctx.strokeStyle = `rgba(25,214,255,${p})`;ctx.lineWidth = 2.5 / zoom;ctx.beginPath(); ctx.arc(x, y, r + (1 - p) * 36, 0, Math.PI * 2); ctx.stroke();}ctx.globalAlpha = 1;};123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126/* ============================================================ELYSIUM — nodes.jsBioluminescent node renderer (dark-neon theme).Pure draw helpers; safe to call from animation loop.============================================================ */(() => {'use strict';const TYPE_COLOR = {CORE: '#ffb840', // golden seedCIVILIZATION: '#ffb840',DOMAIN: '#a76bff', // violetAGENT: '#ff4fa3', // magentaTOOL: '#ff9b3c', // warm orangePROJECT: '#19d6ff', // cyanLIFE_EVENT: '#5cffae', // greenEMOTION: '#ff80c4', // pinkPERSON: '#ff70b8',VALUE: '#7e5cff',MEMORY: '#00e5c8', // tealFACT: '#19d6ff',CONCEPT: '#a76bff',QUERY: '#5cffae',};const DEFAULT_COLOR = '#a76bff';function shade(hex, amt) {if (typeof hex !== 'string' || hex.length < 7) return hex || DEFAULT_COLOR;const c = parseInt(hex.slice(1), 16);let r = (c >> 16) + amt;let g = ((c >> 8) & 255) + amt;let b = (c & 255) + amt;r = Math.max(0, Math.min(255, r));g = Math.max(0, Math.min(255, g));b = Math.max(0, Math.min(255, b));return '#' + ((r << 16) | (g << 8) | b).toString(16).padStart(6, '0');}window.colorFor = (type) => TYPE_COLOR[type] || DEFAULT_COLOR;window.TYPE_COLOR = TYPE_COLOR;window.drawNode = function (ctx, n, t, zoom) {if (!ctx || !n) return;const ageMs = t - (n.born || t);const age = Math.min(1, ageMs / 700);const k = age;const overshoot = age < 1? 1 + 1.7 * (k - 1) ** 3 + 0.7 * (k - 1) ** 2: 1;const pulse = 1 + 0.06 * Math.sin((t / 1000) * 0.55 + (n.phase || 0));const r = Math.max(2, n.radius * pulse * overshoot);const x = n.x, y = n.y;const color = n.color || DEFAULT_COLOR;ctx.globalAlpha = age;// Outer haloconst halo = ctx.createRadialGradient(x, y, r * 0.9, x, y, r * 2.6);halo.addColorStop(0, color + 'aa');halo.addColorStop(0.5, color + '33');halo.addColorStop(1, color + '00');ctx.fillStyle = halo;ctx.beginPath(); ctx.arc(x, y, r * 2.6, 0, Math.PI * 2); ctx.fill();// Rotating dashed orbital ring (CORE only)if (n.type === 'CORE' || n.type === 'CIVILIZATION') {ctx.save();ctx.translate(x, y);ctx.rotate(t * 0.0004);ctx.strokeStyle = color + '88';ctx.lineWidth = 1.5 / zoom;ctx.setLineDash([6 / zoom, 6 / zoom]);ctx.beginPath(); ctx.arc(0, 0, r * 1.85, 0, Math.PI * 2); ctx.stroke();ctx.setLineDash([]);ctx.restore();}// Main sphereconst grad = ctx.createRadialGradient(x - r * 0.35, y - r * 0.35, r * 0.1, x, y, r);grad.addColorStop(0, shade(color, 60));grad.addColorStop(0.5, color);grad.addColorStop(1, shade(color, -70));ctx.shadowColor = color;ctx.shadowBlur = 28 * pulse;ctx.fillStyle = grad;ctx.beginPath(); ctx.arc(x, y, r, 0, Math.PI * 2); ctx.fill();ctx.shadowBlur = 0;// Specular highlightctx.fillStyle = 'rgba(255,255,255,.5)';ctx.beginPath();ctx.ellipse(x - r * 0.32, y - r * 0.32, r * 0.28, r * 0.17, -0.5, 0, Math.PI * 2);ctx.fill();// Selection ringif (n.selected) {ctx.strokeStyle = '#19d6ff';ctx.lineWidth = 2.5 / zoom;ctx.setLineDash([4 / zoom, 4 / zoom]);ctx.beginPath(); ctx.arc(x, y, r + 8 / zoom, 0, Math.PI * 2); ctx.stroke();ctx.setLineDash([]);}// Labelif (zoom > 0.4 && n.label) {const fs = Math.min(13, 11 * Math.max(1, zoom * 0.85));ctx.fillStyle = 'rgba(0,0,0,.6)';ctx.font = `500 ${fs / zoom}px Inter, sans-serif`;ctx.textAlign = 'center'; ctx.textBaseline = 'top';const lbl = n.label.length > 24 ? n.label.slice(0, 22) + '…' : n.label;ctx.fillText(lbl, x + 1 / zoom, y + r + 7 / zoom);ctx.fillStyle = '#d8f6fa';ctx.fillText(lbl, x, y + r + 6 / zoom);}// Pulse highlight ring (from UI directive)if (n.pulseUntil && t < n.pulseUntil) {const p = (n.pulseUntil - t) / 1400;ctx.strokeStyle = `rgba(25,214,255,${p})`;ctx.lineWidth = 2.5 / zoom;ctx.beginPath(); ctx.arc(x, y, r + (1 - p) * 36, 0, Math.PI * 2); ctx.stroke();}ctx.globalAlpha = 1;};})();
58 unmodified lines5960616263646558 unmodified lines<!-- ALERT SCRIM (overlay tint for alert levels) --><div id="alert-scrim"></div><!-- STATS BAR — REPLACED with meaningful civilization metrics --><section id="stats" class="glass"><div class="stat" title="Total nodes in your civilization mycelium"><div class="stat-icon">🌐</div>58 unmodified lines5960616263646558 unmodified lines<!-- ALERT SCRIM (overlay tint for alert levels) --><div id="alert-scrim"></div><!-- STATS BAR — meaningful civilization metrics --><section id="stats" class="glass"><div class="stat" title="Total nodes in your civilization mycelium"><div class="stat-icon">🌐</div>
frontend/dist/assets/api.js+44-11
frontend/dist/assets/boot.js+306-148
frontend/dist/assets/canvas.js+144-72
frontend/dist/assets/council.js+380-260
frontend/dist/assets/elysium.css+40-34
frontend/dist/assets/nodes.js+112-119
frontend/dist/index.html+1-1