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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<!DOCTYPE html>
|
| 2 |
+
<html lang="en">
|
| 3 |
+
<head>
|
| 4 |
+
<meta charset="UTF-8" />
|
| 5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
| 6 |
+
<title>ATLAS — Neural Command Dashboard</title>
|
| 7 |
+
<style>
|
| 8 |
+
:root {
|
| 9 |
+
--bg: #020617;
|
| 10 |
+
--panel: rgba(8, 20, 45, 0.55);
|
| 11 |
+
--border: rgba(34, 211, 238, 0.35);
|
| 12 |
+
--cyan: #22d3ee;
|
| 13 |
+
--amber: #fbbf24;
|
| 14 |
+
--text: #e2e8f0;
|
| 15 |
+
--muted: #94a3b8;
|
| 16 |
+
--red: #f87171;
|
| 17 |
+
--green: #34d399;
|
| 18 |
+
}
|
| 19 |
+
* { box-sizing: border-box; }
|
| 20 |
+
html, body { margin: 0; height: 100%; overflow: hidden; }
|
| 21 |
+
body {
|
| 22 |
+
background: radial-gradient(1200px 800px at 50% 40%, #0a1a3a 0%, #020617 70%);
|
| 23 |
+
color: var(--text);
|
| 24 |
+
font-family: "Segoe UI", "Orbitron", monospace;
|
| 25 |
+
}
|
| 26 |
+
.app { display: flex; flex-direction: column; height: 100vh; padding: 10px 14px; gap: 10px; }
|
| 27 |
+
header {
|
| 28 |
+
display: flex; align-items: center; justify-content: space-between;
|
| 29 |
+
padding: 8px 14px;
|
| 30 |
+
background: var(--panel); border: 1px solid var(--border); border-radius: 12px;
|
| 31 |
+
backdrop-filter: blur(6px);
|
| 32 |
+
box-shadow: 0 0 24px rgba(34,211,238,0.15);
|
| 33 |
+
}
|
| 34 |
+
.title { display: flex; align-items: center; gap: 12px; }
|
| 35 |
+
.title h1 {
|
| 36 |
+
margin: 0; font-size: 28px; letter-spacing: 4px;
|
| 37 |
+
color: var(--cyan); text-shadow: 0 0 18px rgba(34,211,238,0.85);
|
| 38 |
+
}
|
| 39 |
+
.title .sub { font-size: 11px; color: var(--muted); letter-spacing: 1px; }
|
| 40 |
+
.tag { padding: 4px 10px; border: 1px solid var(--amber); color: var(--amber); border-radius: 999px; font-size: 11px; }
|
| 41 |
+
.header-right { display: flex; align-items: center; gap: 14px; font-size: 12px; }
|
| 42 |
+
.clock { font-family: monospace; color: var(--cyan); text-shadow: 0 0 8px rgba(34,211,238,0.6); font-size: 18px; }
|
| 43 |
+
.voice-btn {
|
| 44 |
+
padding: 6px 12px; border: 1px solid var(--cyan); background: transparent; color: var(--cyan);
|
| 45 |
+
border-radius: 8px; cursor: pointer; font-size: 11px; letter-spacing: 1px;
|
| 46 |
+
}
|
| 47 |
+
.voice-btn.on { background: rgba(34,211,238,0.18); }
|
| 48 |
+
.grid { display: grid; grid-template-columns: 22% 56% 22%; gap: 10px; flex: 1; min-height: 0; }
|
| 49 |
+
.col { display: flex; flex-direction: column; gap: 10px; min-height: 0; }
|
| 50 |
+
.panel {
|
| 51 |
+
background: var(--panel); border: 1px solid var(--border); border-radius: 12px;
|
| 52 |
+
padding: 10px; backdrop-filter: blur(6px); box-shadow: 0 0 18px rgba(34,211,238,0.12);
|
| 53 |
+
display: flex; flex-direction: column; min-height: 0; overflow: hidden;
|
| 54 |
+
}
|
| 55 |
+
.panel h3 { margin: 0 0 8px; font-size: 12px; letter-spacing: 3px; color: var(--cyan); text-shadow: 0 0 8px rgba(34,211,238,0.5); }
|
| 56 |
+
/* Reactor */
|
| 57 |
+
.reactor-wrap { display: flex; flex-direction: column; align-items: center; gap: 6px; }
|
| 58 |
+
.reactor-svg { width: 150px; height: 150px; }
|
| 59 |
+
.ring { fill: none; transform-origin: center; }
|
| 60 |
+
.ring.cyan { stroke: var(--cyan); stroke-dasharray: 6 6; }
|
| 61 |
+
.ring.amber { stroke: var(--amber); stroke-dasharray: 4 8; }
|
| 62 |
+
.core { fill: var(--cyan); filter: drop-shadow(0 0 8px var(--cyan)); }
|
| 63 |
+
.status-label { font-size: 13px; letter-spacing: 3px; color: var(--green); text-align: center; font-weight: 700; }
|
| 64 |
+
/* gauges */
|
| 65 |
+
.gauges { display: flex; justify-content: space-around; gap: 6px; }
|
| 66 |
+
.gauge { text-align: center; }
|
| 67 |
+
.gauge svg { width: 78px; height: 78px; }
|
| 68 |
+
.gauge .val { font-family: monospace; font-size: 13px; color: var(--cyan); }
|
| 69 |
+
.gauge .lbl { font-size: 10px; color: var(--muted); letter-spacing: 1px; }
|
| 70 |
+
/* stats */
|
| 71 |
+
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; font-size: 11px; }
|
| 72 |
+
.stat { background: rgba(0,0,0,0.25); border: 1px solid rgba(34,211,238,0.18); border-radius: 6px; padding: 6px; }
|
| 73 |
+
.stat .k { color: var(--muted); font-size: 10px; letter-spacing: 1px; }
|
| 74 |
+
.stat .v { color: var(--cyan); font-family: monospace; font-size: 13px; }
|
| 75 |
+
.spark { height: 44px; border: 1px solid rgba(34,211,238,0.2); border-radius: 6px; }
|
| 76 |
+
/* center */
|
| 77 |
+
.center-panel { position: relative; }
|
| 78 |
+
#neural { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 0; }
|
| 79 |
+
.chat-wrap { position: absolute; left: 0; right: 0; bottom: 0; height: 42%; z-index: 1; padding: 10px; display: flex; flex-direction: column; }
|
| 80 |
+
.chat-fade { position: absolute; top: -40px; left: 0; right: 0; height: 40px; background: linear-gradient(to top, var(--panel), transparent); pointer-events: none; }
|
| 81 |
+
.chat {
|
| 82 |
+
flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 8px;
|
| 83 |
+
background: linear-gradient(to top, rgba(2,6,23,0.85), rgba(2,6,23,0.4));
|
| 84 |
+
border: 1px solid var(--border); border-radius: 10px; padding: 10px; backdrop-filter: blur(4px);
|
| 85 |
+
}
|
| 86 |
+
.msg { max-width: 86%; padding: 8px 12px; border-radius: 8px; font-size: 13px; line-height: 1.45; }
|
| 87 |
+
.msg.user { align-self: flex-end; background: rgba(251,191,36,0.12); border: 1px solid rgba(251,191,36,0.4); color: #fde68a; border-radius: 10px 2px 10px 10px; }
|
| 88 |
+
.msg.atlas { align-self: flex-start; background: rgba(34,211,238,0.08); border-left: 3px solid var(--cyan); }
|
| 89 |
+
.msg .meta { font-size: 10px; color: var(--muted); margin-top: 4px; font-family: monospace; }
|
| 90 |
+
.cursor { display: inline-block; width: 7px; background: var(--cyan); margin-left: 2px; animation: blink 0.9s steps(2) infinite; }
|
| 91 |
+
@keyframes blink { 50% { opacity: 0; } }
|
| 92 |
+
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 6px; }
|
| 93 |
+
.chip { padding: 4px 10px; border: 1px solid rgba(34,211,238,0.3); border-radius: 999px; font-size: 11px; color: var(--cyan); cursor: pointer; background: rgba(34,211,238,0.06); }
|
| 94 |
+
.chip:hover { background: rgba(34,211,238,0.18); }
|
| 95 |
+
.input-row { display: flex; gap: 6px; }
|
| 96 |
+
textarea { flex: 1; background: rgba(0,0,0,0.3); color: var(--text); border: 1px solid var(--border); border-radius: 8px; padding: 8px; font-size: 13px; resize: none; height: 46px; }
|
| 97 |
+
.send { padding: 0 14px; border: 1px solid var(--cyan); background: rgba(34,211,238,0.12); color: var(--cyan); border-radius: 8px; cursor: pointer; }
|
| 98 |
+
.clear { padding: 0 10px; border: 1px solid var(--muted); color: var(--muted); border-radius: 8px; cursor: pointer; background: transparent; }
|
| 99 |
+
/* right event log */
|
| 100 |
+
.filters { display: flex; gap: 6px; margin-bottom: 6px; flex-wrap: wrap; }
|
| 101 |
+
.filter-btn { padding: 3px 9px; border: 1px solid var(--border); border-radius: 6px; font-size: 10px; cursor: pointer; color: var(--muted); background: transparent; }
|
| 102 |
+
.filter-btn.active { color: var(--cyan); border-color: var(--cyan); }
|
| 103 |
+
.log { flex: 1; overflow-y: auto; font-family: monospace; font-size: 11px; padding: 6px; background: rgba(0,0,0,0.3); border-radius: 6px; }
|
| 104 |
+
.log .line { padding: 2px 0; border-bottom: 1px solid rgba(34,211,238,0.06); white-space: pre-wrap; }
|
| 105 |
+
.log .ts { color: #64748b; }
|
| 106 |
+
.log .INFO { color: var(--cyan); }
|
| 107 |
+
.log .WARN { color: var(--amber); }
|
| 108 |
+
.log .ERROR { color: var(--red); }
|
| 109 |
+
.log .DEBUG { color: #a78bfa; }
|
| 110 |
+
.pause-row { display: flex; gap: 6px; margin-bottom: 6px; }
|
| 111 |
+
@media (max-width: 900px) { .grid { grid-template-columns: 1fr; } body { overflow: auto; } }
|
| 112 |
+
</style>
|
| 113 |
+
</head>
|
| 114 |
+
<body>
|
| 115 |
+
<div class="app">
|
| 116 |
+
<header>
|
| 117 |
+
<div class="title">
|
| 118 |
+
<h1>ATLAS</h1>
|
| 119 |
+
<div class="sub">AUTONOMOUS TACTICAL LANGUAGE & ANALYSIS SYSTEM</div>
|
| 120 |
+
</div>
|
| 121 |
+
<div class="tag">atlas-7b-instruct · q4_k_m · 8k ctx</div>
|
| 122 |
+
<div class="header-right">
|
| 123 |
+
<div class="clock" id="clock">00:00:00</div>
|
| 124 |
+
<button class="voice-btn" id="voiceBtn">VOICE OFF</button>
|
| 125 |
+
</div>
|
| 126 |
+
</header>
|
| 127 |
+
<div class="grid">
|
| 128 |
+
<div class="col">
|
| 129 |
+
<div class="panel">
|
| 130 |
+
<h3>REACTOR</h3>
|
| 131 |
+
<div class="reactor-wrap">
|
| 132 |
+
<svg class="reactor-svg" viewBox="0 0 200 200">
|
| 133 |
+
<circle cx="100" cy="100" r="88" class="ring cyan" id="ring1"/>
|
| 134 |
+
<circle cx="100" cy="100" r="70" class="ring amber" id="ring2"/>
|
| 135 |
+
<circle cx="100" cy="100" r="50" class="ring cyan" id="ring3"/>
|
| 136 |
+
<circle cx="100" cy="100" r="12" class="core" id="core"/>
|
| 137 |
+
</svg>
|
| 138 |
+
<div class="status-label" id="statusLabel">ONLINE</div>
|
| 139 |
+
</div>
|
| 140 |
+
</div>
|
| 141 |
+
<div class="panel">
|
| 142 |
+
<h3>GAUGES</h3>
|
| 143 |
+
<div class="gauges">
|
| 144 |
+
<div class="gauge">
|
| 145 |
+
<svg viewBox="0 0 80 80">
|
| 146 |
+
<circle cx="40" cy="40" r="32" stroke="#0f172a" stroke-width="8" fill="none"/>
|
| 147 |
+
<circle cx="40" cy="40" r="32" stroke="#22d3ee" stroke-width="8" fill="none" stroke-linecap="round" id="gpuRing" stroke-dasharray="0 201"/>
|
| 148 |
+
</svg>
|
| 149 |
+
<div class="val" id="gpuVal">0%</div>
|
| 150 |
+
<div class="lbl">GPU</div>
|
| 151 |
+
</div>
|
| 152 |
+
<div class="gauge">
|
| 153 |
+
<svg viewBox="0 0 80 80">
|
| 154 |
+
<circle cx="40" cy="40" r="32" stroke="#0f172a" stroke-width="8" fill="none"/>
|
| 155 |
+
<circle cx="40" cy="40" r="32" stroke="#fbbf24" stroke-width="8" fill="none" stroke-linecap="round" id="vramRing" stroke-dasharray="0 201"/>
|
| 156 |
+
</svg>
|
| 157 |
+
<div class="val" id="vramVal">0/16 GB</div>
|
| 158 |
+
<div class="lbl">VRAM</div>
|
| 159 |
+
</div>
|
| 160 |
+
</div>
|
| 161 |
+
</div>
|
| 162 |
+
<div class="panel">
|
| 163 |
+
<h3>TOKENS / SEC</h3>
|
| 164 |
+
<canvas class="spark" id="spark" width="260" height="44"></canvas>
|
| 165 |
+
<div class="stats" style="margin-top:6px;">
|
| 166 |
+
<div class="stat"><div class="k">TOK/S</div><div class="v" id="toks">0.0</div></div>
|
| 167 |
+
<div class="stat"><div class="k">TTFT</div><div class="v" id="ttft">0 ms</div></div>
|
| 168 |
+
<div class="stat"><div class="k">REQS</div><div class="v" id="reqs">0</div></div>
|
| 169 |
+
<div class="stat"><div class="k">TOKENS OUT</div><div class="v" id="tokOut">0</div></div>
|
| 170 |
+
<div class="stat"><div class="k">QUEUE</div><div class="v" id="queue">0</div></div>
|
| 171 |
+
<div class="stat"><div class="k">ERRORS</div><div class="v" id="errs">0</div></div>
|
| 172 |
+
<div class="stat"><div class="k">GPU TEMP</div><div class="v" id="gputemp">0°C</div></div>
|
| 173 |
+
<div class="stat"><div class="k">STATUS</div><div class="v" id="conn">READY</div></div>
|
| 174 |
+
</div>
|
| 175 |
+
</div>
|
| 176 |
+
</div>
|
| 177 |
+
<div class="col">
|
| 178 |
+
<div class="panel center-panel" style="flex:1;">
|
| 179 |
+
<canvas id="neural"></canvas>
|
| 180 |
+
<div class="chat-wrap">
|
| 181 |
+
<div class="chat-fade"></div>
|
| 182 |
+
<div class="chips" id="chips"></div>
|
| 183 |
+
<div class="chat" id="chat"></div>
|
| 184 |
+
<div class="input-row" style="margin-top:6px;">
|
| 185 |
+
<button class="clear" id="clearBtn">Clear</button>
|
| 186 |
+
<textarea id="input" placeholder="Speak to ATLAS… (Enter to send, Shift+Enter newline)"></textarea>
|
| 187 |
+
<button class="send" id="sendBtn">Send</button>
|
| 188 |
+
</div>
|
| 189 |
+
</div>
|
| 190 |
+
</div>
|
| 191 |
+
</div>
|
| 192 |
+
<div class="col">
|
| 193 |
+
<div class="panel" style="flex:1;">
|
| 194 |
+
<h3>EVENT LOG</h3>
|
| 195 |
+
<div class="filters" id="filters"></div>
|
| 196 |
+
<div class="pause-row">
|
| 197 |
+
<button class="filter-btn" id="pauseBtn">Pause</button>
|
| 198 |
+
</div>
|
| 199 |
+
<div class="log" id="log"></div>
|
| 200 |
+
</div>
|
| 201 |
+
</div>
|
| 202 |
+
</div>
|
| 203 |
+
</div>
|
| 204 |
+
|
| 205 |
+
<script>
|
| 206 |
+
// ---------- state ----------
|
| 207 |
+
const state = {
|
| 208 |
+
status: 'ONLINE', // ONLINE, ANALYZING, RESPONDING
|
| 209 |
+
gpu: 12, vram: 6.8, toks: 0, ttft: 0, reqs: 0, tokOut: 0, queue: 0, errs: 0, gputemp: 54,
|
| 210 |
+
voice: false, spin: 1, pulse: 1,
|
| 211 |
+
pausedLog: false,
|
| 212 |
+
chatBusy: false,
|
| 213 |
+
};
|
| 214 |
+
const filters = { INFO: true, WARN: true, ERROR: true, DEBUG: true };
|
| 215 |
+
|
| 216 |
+
// ---------- uptime clock ----------
|
| 217 |
+
const start = Date.now();
|
| 218 |
+
function fmtTime(ms){ const s=Math.floor(ms/1000); const h=Math.floor(s/3600).toString().padStart(2,'0'); const m=Math.floor((s%3600)/60).toString().padStart(2,'0'); const sec=(s%60).toString().padStart(2,'0'); return `${h}:${m}:${sec}`; }
|
| 219 |
+
setInterval(() => { document.getElementById('clock').textContent = fmtTime(Date.now()-start); }, 1000);
|
| 220 |
+
|
| 221 |
+
// ---------- voice toggle ----------
|
| 222 |
+
const voiceBtn = document.getElementById('voiceBtn');
|
| 223 |
+
voiceBtn.addEventListener('click', () => {
|
| 224 |
+
state.voice = !state.voice;
|
| 225 |
+
voiceBtn.textContent = state.voice ? 'VOICE ON' : 'VOICE OFF';
|
| 226 |
+
voiceBtn.classList.toggle('on', state.voice);
|
| 227 |
+
logEvent('INFO', `Voice ${state.voice ? 'enabled' : 'disabled'}`);
|
| 228 |
+
});
|
| 229 |
+
function speak(text){
|
| 230 |
+
if(!state.voice) return;
|
| 231 |
+
try {
|
| 232 |
+
const u = new SpeechSynthesisUtterance(text);
|
| 233 |
+
u.pitch = 0.8; u.rate = 0.95; u.volume = 1;
|
| 234 |
+
speechSynthesis.speak(u);
|
| 235 |
+
} catch(e){}
|
| 236 |
+
}
|
| 237 |
+
|
| 238 |
+
// ---------- event log ----------
|
| 239 |
+
const logEl = document.getElementById('log');
|
| 240 |
+
let userAtBottom = true;
|
| 241 |
+
logEl.addEventListener('scroll', () => { userAtBottom = (logEl.scrollTop + logEl.clientHeight >= logEl.scrollHeight - 8); });
|
| 242 |
+
const logEntries = [];
|
| 243 |
+
function logEvent(level, msg){
|
| 244 |
+
const now = new Date();
|
| 245 |
+
const ts = now.toTimeString().slice(0,8)+'.'+String(now.getMilliseconds()).padStart(3,'0');
|
| 246 |
+
logEntries.push({ts, level, msg});
|
| 247 |
+
renderLog();
|
| 248 |
+
}
|
| 249 |
+
function renderLog(){
|
| 250 |
+
logEl.innerHTML = '';
|
| 251 |
+
for(const e of logEntries){
|
| 252 |
+
if(!filters[e.level]) continue;
|
| 253 |
+
const div = document.createElement('div');
|
| 254 |
+
div.className = 'line';
|
| 255 |
+
div.innerHTML = `<span class="ts">[${e.ts}]</span> <span class="${e.level}">${e.level}</span> ${escapeHtml(e.msg)}`;
|
| 256 |
+
logEl.appendChild(div);
|
| 257 |
+
}
|
| 258 |
+
if(!state.pausedLog && userAtBottom){ logEl.scrollTop = logEl.scrollHeight; }
|
| 259 |
+
}
|
| 260 |
+
function escapeHtml(s){ return s.replace(/&/g,'&').replace(/</g,'<').replace(/>/g,'>'); }
|
| 261 |
+
|
| 262 |
+
// filters
|
| 263 |
+
const filterWrap = document.getElementById('filters');
|
| 264 |
+
Object.keys(filters).forEach(lv=>{
|
| 265 |
+
const b = document.createElement('button');
|
| 266 |
+
b.className = 'filter-btn active';
|
| 267 |
+
b.textContent = lv;
|
| 268 |
+
b.addEventListener('click', ()=>{ filters[lv]=!filters[lv]; b.classList.toggle('active', filters[lv]); renderLog(); });
|
| 269 |
+
filterWrap.appendChild(b);
|
| 270 |
+
});
|
| 271 |
+
const pauseBtn = document.getElementById('pauseBtn');
|
| 272 |
+
pauseBtn.addEventListener('click', ()=>{ state.pausedLog = !state.pausedLog; pauseBtn.textContent = state.pausedLog ? 'Resume' : 'Pause'; });
|
| 273 |
+
|
| 274 |
+
// boot sequence
|
| 275 |
+
const bootSeq = [
|
| 276 |
+
'INFO: ATLAS boot sequence initialized',
|
| 277 |
+
'DEBUG: loading neural weights (q4_k_m)',
|
| 278 |
+
'INFO: GPU context created (simulated)',
|
| 279 |
+
'INFO: vector store ready',
|
| 280 |
+
'INFO: comms channel established',
|
| 281 |
+
'DEBUG: heartbeat monitor armed',
|
| 282 |
+
];
|
| 283 |
+
let bi = 0;
|
| 284 |
+
const bootTimer = setInterval(() => {
|
| 285 |
+
if(bi >= bootSeq.length){ clearInterval(bootTimer); logEvent('INFO','ATLAS online and ready.'); return; }
|
| 286 |
+
const parts = bootSeq[bi].split(':');
|
| 287 |
+
logEvent(parts[0], parts.slice(1).join(':').trim());
|
| 288 |
+
bi++;
|
| 289 |
+
}, 600);
|
| 290 |
+
|
| 291 |
+
// heartbeat
|
| 292 |
+
setInterval(() => {
|
| 293 |
+
logEvent('DEBUG', `health check ok · gpu ${state.gpu}% · queue ${state.queue}`);
|
| 294 |
+
}, 4500);
|
| 295 |
+
|
| 296 |
+
// ---------- neural network canvas ----------
|
| 297 |
+
const canvas = document.getElementById('neural');
|
| 298 |
+
const ctx = canvas.getContext('2d');
|
| 299 |
+
let W, H;
|
| 300 |
+
function resizeCanvas(){ W = canvas.width = canvas.clientWidth; H = canvas.height = canvas.clientHeight; }
|
| 301 |
+
window.addEventListener('resize', resizeCanvas); resizeCanvas();
|
| 302 |
+
let mx = 0, my = 0;
|
| 303 |
+
canvas.addEventListener('mousemove', e => { const r=canvas.getBoundingClientRect(); mx=(e.clientX-r.left-W/2)/W; my=(e.clientY-r.top-H/2)/H; });
|
| 304 |
+
|
| 305 |
+
const N = 120;
|
| 306 |
+
const nodes = [];
|
| 307 |
+
for(let i=0;i<N;i++){
|
| 308 |
+
const r = 60 + Math.random()*240;
|
| 309 |
+
const inc = Math.random()*Math.PI;
|
| 310 |
+
const plane = Math.random()*Math.PI*2;
|
| 311 |
+
const speed = (0.25+Math.random()*0.6)*(Math.random()<0.5?-1:1);
|
| 312 |
+
const col = Math.random()<0.15 ? '#fbbf24' : '#22d3ee';
|
| 313 |
+
nodes.push({ id:i, r, inc, plane, speed, angle: Math.random()*Math.PI*2, trail:[], color:col, size: 1+Math.random()*1.5, pulse: Math.random()*Math.PI*2 });
|
| 314 |
+
}
|
| 315 |
+
// query arrows
|
| 316 |
+
let queries = [];
|
| 317 |
+
function spawnQueries(){
|
| 318 |
+
const k = 3 + Math.floor(Math.random()*3);
|
| 319 |
+
queries = [];
|
| 320 |
+
for(let i=0;i<k;i++){
|
| 321 |
+
queries.push({ t:0, speed: 0.4+Math.random()*0.4, node: Math.floor(Math.random()*N), trail:[] });
|
| 322 |
+
}
|
| 323 |
+
}
|
| 324 |
+
// rotate cloud yaw
|
| 325 |
+
let yaw = 0;
|
| 326 |
+
const projections = [];
|
| 327 |
+
function stepNodes(dt){
|
| 328 |
+
const workMul = state.status==='RESPONDING' ? 2.2 : state.status==='ANALYZING' ? 1.5 : 1;
|
| 329 |
+
yaw += 0.25*dt*workMul;
|
| 330 |
+
for(const n of nodes){
|
| 331 |
+
n.angle += n.speed*dt*workMul;
|
| 332 |
+
n.pulse += 2*dt*workMul;
|
| 333 |
+
const c = Math.cos(n.angle), s = Math.sin(n.angle);
|
| 334 |
+
let x = n.r*c, y = n.r*s, z = 0;
|
| 335 |
+
// inclination
|
| 336 |
+
const ci = Math.cos(n.inc), si = Math.sin(n.inc);
|
| 337 |
+
const y1 = y*ci - z*si; const z1 = y*si + z*ci; const x1 = x;
|
| 338 |
+
// plane rotation
|
| 339 |
+
const cp = Math.cos(n.plane), sp = Math.sin(n.plane);
|
| 340 |
+
const x2 = x1*cp + z1*sp; const z2 = -x1*sp + z1*cp; const y2 = y1;
|
| 341 |
+
// global yaw + mouse parallax
|
| 342 |
+
const yawTot = yaw + mx*0.6;
|
| 343 |
+
const pitch = my*0.4;
|
| 344 |
+
let X = x2*Math.cos(yawTot) - z2*Math.sin(yawTot);
|
| 345 |
+
let Z = x2*Math.sin(yawTot) + z2*Math.cos(yawTot);
|
| 346 |
+
let Y = y2*Math.cos(pitch) - Z*Math.sin(pitch);
|
| 347 |
+
let Zp = y2*Math.sin(pitch) + Z*Math.cos(pitch);
|
| 348 |
+
const scale = 380/(380+Zp);
|
| 349 |
+
const sx = W/2 + X*scale;
|
| 350 |
+
const sy = H/2 + Y*scale;
|
| 351 |
+
n.trail.push({x:sx,y:sy});
|
| 352 |
+
if(n.trail.length>9) n.trail.shift();
|
| 353 |
+
n.proj = {x:sx,y:sy,scale,z:Zp};
|
| 354 |
+
}
|
| 355 |
+
// queries
|
| 356 |
+
if(state.chatBusy){ if(queries.length===0) spawnQueries(); }
|
| 357 |
+
else { queries = []; }
|
| 358 |
+
for(const q of queries){
|
| 359 |
+
q.t = Math.min(1, q.t + q.speed*dt);
|
| 360 |
+
const target = nodes[q.node].proj;
|
| 361 |
+
const sx = W/2 + (target.x-W/2)*q.t*0.9;
|
| 362 |
+
const sy = H/2 + (target.y-H/2)*q.t*0.9 - 10;
|
| 363 |
+
q.pos = {x:sx,y:sy};
|
| 364 |
+
q.trail.push({x:sx,y:sy}); if(q.trail.length>12) q.trail.shift();
|
| 365 |
+
}
|
| 366 |
+
}
|
| 367 |
+
function drawNetwork(){
|
| 368 |
+
ctx.clearRect(0,0,W,H);
|
| 369 |
+
// connections
|
| 370 |
+
for(let i=0;i<N;i++){
|
| 371 |
+
for(let j=i+1;j<N;j++){
|
| 372 |
+
const a=nodes[i].proj, b=nodes[j].proj;
|
| 373 |
+
const d = Math.hypot(a.x-b.x, a.y-b.y);
|
| 374 |
+
if(d < 150){
|
| 375 |
+
const alpha = (1 - d/150)*0.35;
|
| 376 |
+
ctx.strokeStyle = `rgba(34,211,238,${alpha})`;
|
| 377 |
+
ctx.lineWidth = 0.6;
|
| 378 |
+
ctx.beginPath(); ctx.moveTo(a.x,a.y); ctx.lineTo(b.x,b.y); ctx.stroke();
|
| 379 |
+
}
|
| 380 |
+
}
|
| 381 |
+
}
|
| 382 |
+
// nodes
|
| 383 |
+
for(const n of nodes){
|
| 384 |
+
const p = n.proj;
|
| 385 |
+
const flicker = 0.7+0.3*Math.sin(n.pulse);
|
| 386 |
+
// trail
|
| 387 |
+
for(let t=0;t<n.trail.length-1;t++){
|
| 388 |
+
ctx.strokeStyle = n.color === '#fbbf24' ? `rgba(251,191,36,${ (t/n.trail.length)*0.4 })` : `rgba(34,211,238,${ (t/n.trail.length)*0.4 })`;
|
| 389 |
+
ctx.lineWidth = 0.8;
|
| 390 |
+
ctx.beginPath(); ctx.moveTo(n.trail[t].x, n.trail[t].y); ctx.lineTo(n.trail[t+1].x, n.trail[t+1].y); ctx.stroke();
|
| 391 |
+
}
|
| 392 |
+
const glow = ctx.createRadialGradient(p.x,p.y,0,p.x,p.y,8);
|
| 393 |
+
glow.addColorStop(0, (n.color==='#fbbf24'?'rgba(251,191,36,0.9)':'rgba(103,232,249,0.9)'));
|
| 394 |
+
glow.addColorStop(1, 'rgba(0,0,0,0)');
|
| 395 |
+
ctx.fillStyle = glow; ctx.beginPath(); ctx.arc(p.x,p.y,8,0,Math.PI*2); ctx.fill();
|
| 396 |
+
ctx.fillStyle = n.color; ctx.beginPath(); ctx.arc(p.x,p.y,n.size,0,Math.PI*2); ctx.fill();
|
| 397 |
+
}
|
| 398 |
+
// query arrows
|
| 399 |
+
for(const q of queries){
|
| 400 |
+
const p = q.pos;
|
| 401 |
+
// arrow body
|
| 402 |
+
ctx.strokeStyle = 'rgba(251,191,36,0.9)';
|
| 403 |
+
ctx.lineWidth = 2;
|
| 404 |
+
ctx.beginPath();
|
| 405 |
+
ctx.moveTo(W/2, H/2);
|
| 406 |
+
ctx.lineTo(p.x, p.y);
|
| 407 |
+
ctx.stroke();
|
| 408 |
+
// arrowhead
|
| 409 |
+
const ang = Math.atan2(p.y-H/2, p.x-W/2);
|
| 410 |
+
ctx.fillStyle = 'rgba(251,191,36,0.9)';
|
| 411 |
+
ctx.beginPath();
|
| 412 |
+
ctx.moveTo(p.x, p.y);
|
| 413 |
+
ctx.lineTo(p.x-8*Math.cos(ang-0.35), p.y-8*Math.sin(ang-0.35));
|
| 414 |
+
ctx.lineTo(p.x-8*Math.cos(ang+0.35), p.y-8*Math.sin(ang+0.35));
|
| 415 |
+
ctx.closePath(); ctx.fill();
|
| 416 |
+
// trail
|
| 417 |
+
for(let t=0;t<q.trail.length-1;t++){
|
| 418 |
+
ctx.strokeStyle = `rgba(251,191,36,${(t/q.trail.length)*0.4})`;
|
| 419 |
+
ctx.lineWidth=1.2;
|
| 420 |
+
ctx.beginPath(); ctx.moveTo(q.trail[t].x,q.trail[t].y); ctx.lineTo(q.trail[t+1].x,q.trail[t+1].y); ctx.stroke();
|
| 421 |
+
}
|
| 422 |
+
}
|
| 423 |
+
// core
|
| 424 |
+
const pulse = 0.5+0.5*Math.sin(Date.now()/300);
|
| 425 |
+
const cg = ctx.createRadialGradient(W/2,H/2,0,W/2,H/2,24);
|
| 426 |
+
cg.addColorStop(0, `rgba(34,211,238,${0.6+0.3*pulse})`);
|
| 427 |
+
cg.addColorStop(1, 'rgba(34,211,238,0)');
|
| 428 |
+
ctx.fillStyle=cg; ctx.beginPath(); ctx.arc(W/2,H/2,24,0,Math.PI*2); ctx.fill();
|
| 429 |
+
}
|
| 430 |
+
let last = performance.now();
|
| 431 |
+
function loop(now){
|
| 432 |
+
const dt = Math.min(0.05, (now-last)/1000); last=now;
|
| 433 |
+
stepNodes(dt);
|
| 434 |
+
drawNetwork();
|
| 435 |
+
// reactor rotation
|
| 436 |
+
const mul = state.status==='RESPONDING'?2.2:state.status==='ANALYZING'?1.5:1;
|
| 437 |
+
document.getElementById('ring1').style.transform = `rotate(${(Date.now()/1000*40*mul)%360}deg)`;
|
| 438 |
+
document.getElementById('ring2').style.transform = `rotate(${-(Date.now()/1000*30*mul)%360}deg)`;
|
| 439 |
+
document.getElementById('ring3').style.transform = `rotate(${(Date.now()/1000*50*mul)%360}deg)`;
|
| 440 |
+
const core = document.getElementById('core');
|
| 441 |
+
const cr = 10 + 4*pulseMul(mul);
|
| 442 |
+
core.setAttribute('r', cr);
|
| 443 |
+
requestAnimationFrame(loop);
|
| 444 |
+
}
|
| 445 |
+
function pulseMul(m){ return 0.5+0.5*Math.sin(Date.now()/(300/m)); }
|
| 446 |
+
requestAnimationFrame(loop);
|
| 447 |
+
|
| 448 |
+
// ---------- gauges update ----------
|
| 449 |
+
const C = 2*Math.PI*32;
|
| 450 |
+
function setGauge(idVal, idRing, v, max, suffix){
|
| 451 |
+
document.getElementById(idVal).textContent = suffix ? `${v.toFixed(1)}${suffix}` : v.toFixed(0)+'%';
|
| 452 |
+
document.getElementById(idRing).setAttribute('stroke-dasharray', `${(v/max)*C} ${C}`);
|
| 453 |
+
}
|
| 454 |
+
// sparkline
|
| 455 |
+
const spark = document.getElementById('spark');
|
| 456 |
+
const sctx = spark.getContext('2d');
|
| 457 |
+
const sparkData = new Array(60).fill(0);
|
| 458 |
+
function drawSpark(){
|
| 459 |
+
sctx.clearRect(0,0,spark.width,spark.height);
|
| 460 |
+
sctx.strokeStyle = 'rgba(34,211,238,0.7)';
|
| 461 |
+
sctx.lineWidth = 1.5;
|
| 462 |
+
sctx.beginPath();
|
| 463 |
+
for(let i=0;i<sparkData.length;i++){
|
| 464 |
+
const x = i/(sparkData.length-1)*spark.width;
|
| 465 |
+
const y = spark.height - (sparkData[i]/60)*spark.height;
|
| 466 |
+
if(i===0) sctx.moveTo(x,y); else sctx.lineTo(x,y);
|
| 467 |
+
}
|
| 468 |
+
sctx.stroke();
|
| 469 |
+
}
|
| 470 |
+
drawSpark();
|
| 471 |
+
|
| 472 |
+
// ---------- simulated metrics ----------
|
| 473 |
+
setInterval(() => {
|
| 474 |
+
if(state.status==='RESPONDING'){
|
| 475 |
+
state.gpu = clamp(state.gpu + (Math.random()-0.45)*6, 40, 96);
|
| 476 |
+
state.vram = clamp(state.vram + (Math.random()-0.5)*0.4, 6, 14.5);
|
| 477 |
+
state.toks = 28 + Math.random()*18;
|
| 478 |
+
state.gputemp = 62 + Math.random()*8;
|
| 479 |
+
} else if(state.status==='ANALYZING'){
|
| 480 |
+
state.gpu = clamp(state.gpu + (Math.random()-0.5)*4, 20, 70);
|
| 481 |
+
state.toks = 4 + Math.random()*6;
|
| 482 |
+
state.gputemp = 50 + Math.random()*6;
|
| 483 |
+
} else {
|
| 484 |
+
state.gpu = clamp(state.gpu + (Math.random()-0.5)*3, 8, 35);
|
| 485 |
+
state.vram = clamp(state.vram + (Math.random()-0.5)*0.1, 6, 7.5);
|
| 486 |
+
state.toks = Math.max(0, state.toks*0.85);
|
| 487 |
+
state.gputemp = 42 + Math.random()*4;
|
| 488 |
+
}
|
| 489 |
+
setGauge('gpuVal','gpuRing',state.gpu,100,'');
|
| 490 |
+
setGauge('vramVal','vramRing',state.vram,16,'');
|
| 491 |
+
document.getElementById('toks').textContent = state.toks.toFixed(1);
|
| 492 |
+
document.getElementById('gputemp').textContent = state.gputemp.toFixed(0)+'°C';
|
| 493 |
+
document.getElementById('queue').textContent = state.queue;
|
| 494 |
+
document.getElementById('errs').textContent = state.errs;
|
| 495 |
+
document.getElementById('reqs').textContent = state.reqs;
|
| 496 |
+
document.getElementById('tokOut').textContent = state.tokOut;
|
| 497 |
+
document.getElementById('conn').textContent = state.status;
|
| 498 |
+
document.getElementById('statusLabel').textContent = state.status;
|
| 499 |
+
document.getElementById('statusLabel').style.color = state.status==='RESPONDING'?'#22d3ee':state.status==='ANALYZING'?'#fbbf24':'#34d399';
|
| 500 |
+
sparkData.shift(); sparkData.push(state.toks); drawSpark();
|
| 501 |
+
}, 700);
|
| 502 |
+
function clamp(v,a,b){ return Math.max(a, Math.min(b,v)); }
|
| 503 |
+
|
| 504 |
+
// ---------- chat ----------
|
| 505 |
+
const chat = document.getElementById('chat');
|
| 506 |
+
const input = document.getElementById('input');
|
| 507 |
+
const sendBtn = document.getElementById('sendBtn');
|
| 508 |
+
const clearBtn = document.getElementById('clearBtn');
|
| 509 |
+
const chips = document.getElementById('chips');
|
| 510 |
+
const canned = [
|
| 511 |
+
"ATLAS online. All systems nominal. How may I assist?",
|
| 512 |
+
"Affirmative. I can draft, summarize, index, or simulate. Give me a task.",
|
| 513 |
+
"Query received. Cross-referencing latent knowledge… done. What aspect matters most?",
|
| 514 |
+
"Roger. I'll keep it concise and actionable.",
|
| 515 |
+
"Standing by. I can also run diagnostics or stream events to the log."
|
| 516 |
+
];
|
| 517 |
+
const suggestions = ['Run a diagnostic sweep','Summarize system status','Generate a report','Explain neural canvas','Simulate error handling'];
|
| 518 |
+
suggestions.forEach(s=>{
|
| 519 |
+
const c = document.createElement('span'); c.className='chip'; c.textContent=s;
|
| 520 |
+
c.addEventListener('click', ()=>{ input.value=s; input.focus(); });
|
| 521 |
+
chips.appendChild(c);
|
| 522 |
+
});
|
| 523 |
+
function addMsg(text, role){
|
| 524 |
+
const d = document.createElement('div');
|
| 525 |
+
d.className = 'msg '+role;
|
| 526 |
+
if(role==='atlas') d.innerHTML = `<span></span><div class="meta"></div>`;
|
| 527 |
+
const content = document.createElement('div'); content.className='content';
|
| 528 |
+
content.textContent = text;
|
| 529 |
+
// reorder: meta last
|
| 530 |
+
d.innerHTML=''; d.appendChild(content);
|
| 531 |
+
const meta = document.createElement('div'); meta.className='meta';
|
| 532 |
+
d.appendChild(meta);
|
| 533 |
+
chat.appendChild(d);
|
| 534 |
+
chat.scrollTop = chat.scrollHeight;
|
| 535 |
+
return {d, content, meta};
|
| 536 |
+
}
|
| 537 |
+
function streamReply(prompt){
|
| 538 |
+
if(state.chatBusy) return;
|
| 539 |
+
state.chatBusy = true; state.status='ANALYZING';
|
| 540 |
+
const userMsg = prompt.trim();
|
| 541 |
+
addMsg(userMsg,'user');
|
| 542 |
+
const atlas = addMsg('','atlas');
|
| 543 |
+
const cursor = document.createElement('span'); cursor.className='cursor'; atlas.content.appendChild(cursor);
|
| 544 |
+
const promptTokens = Math.max(1, Math.round(userMsg.split(/\s+/).length * 1.3));
|
| 545 |
+
state.queue = Math.min(8, state.queue+1);
|
| 546 |
+
const t0 = performance.now();
|
| 547 |
+
let ttft = 120 + Math.random()*280;
|
| 548 |
+
logEvent('INFO', `request accepted: prompt_tokens=${promptTokens}`);
|
| 549 |
+
logEvent('DEBUG', `scheduled on worker-0`);
|
| 550 |
+
// pick canned reply extended
|
| 551 |
+
const base = canned[Math.floor(Math.random()*canned.length)] + " " + userMsg.split(' ').slice(0,6).join(' ');
|
| 552 |
+
const words = base.split(' ');
|
| 553 |
+
let i=0;
|
| 554 |
+
setTimeout(() => {
|
| 555 |
+
state.status='RESPONDING'; spawnQueries();
|
| 556 |
+
logEvent('INFO', `first token latency: ${ttft.toFixed(0)}ms`);
|
| 557 |
+
const interval = 45 + Math.random()*35;
|
| 558 |
+
const timer = setInterval(() => {
|
| 559 |
+
if(i >= words.length){
|
| 560 |
+
clearInterval(timer);
|
| 561 |
+
cursor.remove();
|
| 562 |
+
const total = (performance.now()-t0)/1000;
|
| 563 |
+
atlas.meta.textContent = `${words.length+2} tokens · ${total.toFixed(2)} s · ${ttft.toFixed(0)} ms to first token`;
|
| 564 |
+
state.status='ONLINE';
|
| 565 |
+
state.reqs++; state.tokOut += words.length+2; state.queue = Math.max(0, state.queue-1);
|
| 566 |
+
queries = [];
|
| 567 |
+
logEvent('INFO', `done: completion_tokens=${words.length+2} latency=${(total*1000).toFixed(0)}ms`);
|
| 568 |
+
// sometimes warn on long completion
|
| 569 |
+
if(words.length > 12){ logEvent('WARN', `long completion (${words.length+2} tokens) — consider shorter prompt`); }
|
| 570 |
+
// random error occasionally
|
| 571 |
+
if(Math.random() < 0.08){
|
| 572 |
+
state.errs++;
|
| 573 |
+
logEvent('ERROR', 'CUDA OOM during generation — retrying on fallback worker');
|
| 574 |
+
logEvent('INFO', 'retry succeeded');
|
| 575 |
+
}
|
| 576 |
+
state.chatBusy=false;
|
| 577 |
+
state.ttft = ttft;
|
| 578 |
+
document.getElementById('ttft').textContent = ttft.toFixed(0)+' ms';
|
| 579 |
+
if(state.voice) speak(base);
|
| 580 |
+
return;
|
| 581 |
+
}
|
| 582 |
+
atlas.content.insertBefore(document.createTextNode((i===0?'':' ')+words[i]), cursor);
|
| 583 |
+
i++;
|
| 584 |
+
chat.scrollTop = chat.scrollHeight;
|
| 585 |
+
}, interval);
|
| 586 |
+
}, ttft);
|
| 587 |
+
}
|
| 588 |
+
function handleSend(){
|
| 589 |
+
const v = input.value.trim();
|
| 590 |
+
if(!v || state.chatBusy) return;
|
| 591 |
+
input.value='';
|
| 592 |
+
streamReply(v);
|
| 593 |
+
}
|
| 594 |
+
sendBtn.addEventListener('click', handleSend);
|
| 595 |
+
input.addEventListener('keydown', e => { if(e.key==='Enter' && !e.shiftKey){ e.preventDefault(); handleSend(); } });
|
| 596 |
+
clearBtn.addEventListener('click', ()=>{ chat.innerHTML=''; logEvent('INFO','chat cleared'); });
|
| 597 |
+
|
| 598 |
+
// ---------- helpers ----------
|
| 599 |
+
function clamp(v,a,b){ return Math.max(a, Math.min(b,v)); }
|
| 600 |
+
// escape already defined
|
| 601 |
+
</script>
|
| 602 |
+
</body>
|
| 603 |
+
</html>
|