Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them.
Page: /drakestapleton/sovereign-intelligence/blob/main/docs/archive/drakestapleton.com-old/public/js/live-ticker.js
# sovereign-intelligence
Front door to Drake Stapleton's sovereign stack.
Brought by drakestapleton
Sign in to star 0 stars 0 watching
About Files History Releases Proposed changes Issues For developers
branch `main` Branches Tags History
`sovereign-intelligence / docs / archive / drakestapleton.com-old / public / js / live-ticker.js`
450 lines · 18388 bytes Raw Blame History
1 // Drake Stapleton - Sovereign Live Telemetry & Modern Floating Glass AIEN Spotlight
2 // Real-time inference stream from NVIDIA DGX Spark (Grace Blackwell GB10 @ port 18006)
3 (function() {
4 if (document.getElementById('spark-live-ticker')) return;
5
6 // 1. Inject Styles for Floating Capsule, Spotlight Modal, and Avatar Glow
7 const styleTag = document.createElement('style');
8 styleTag.textContent = `
9 @keyframes aienBreathe {
10 0%, 100% { transform: scale(1) translateY(0); opacity: 0.18; }
11 50% { transform: scale(1.03) translateY(-3px); opacity: 0.25; }
12 }
13 @keyframes aienPulseReasoning {
14 0%, 100% { transform: scale(1.02); opacity: 0.35; filter: drop-shadow(0 0 50px rgba(56, 189, 248, 0.45)) drop-shadow(0 0 80px rgba(168, 85, 247, 0.4)); }
15 50% { transform: scale(1.06); opacity: 0.48; filter: drop-shadow(0 0 70px rgba(56, 189, 248, 0.65)) drop-shadow(0 0 110px rgba(168, 85, 247, 0.6)); }
16 }
17 @keyframes spotlightFadeIn {
18 from { opacity: 0; transform: scale(0.96) translateY(10px); }
19 to { opacity: 1; transform: scale(1) translateY(0); }
20 }
21 .aien-spotlight-backdrop {
22 position: fixed;
23 inset: 0;
24 background: rgba(2, 6, 23, 0.68);
25 backdrop-filter: blur(16px);
26 -webkit-backdrop-filter: blur(16px);
27 z-index: 10000;
28 display: none;
29 align-items: center;
30 justify-content: center;
31 padding: 16px;
32 opacity: 0;
33 transition: opacity 0.25s ease;
34 }
35 .aien-spotlight-backdrop.open {
36 display: flex;
37 opacity: 1;
38 }
39 .aien-spotlight-panel {
40 position: relative;
41 width: 100%;
42 max-width: 680px;
43 max-height: 84vh;
44 background: rgba(10, 15, 29, 0.82);
45 backdrop-filter: blur(32px) saturate(190%);
46 -webkit-backdrop-filter: blur(32px) saturate(190%);
47 border: 1px solid rgba(56, 189, 248, 0.28);
48 border-radius: 20px;
49 box-shadow: 0 35px 80px -15px rgba(0, 0, 0, 0.85), 0 0 45px rgba(56, 189, 248, 0.18);
50 display: flex;
51 flex-direction: column;
52 overflow: hidden;
53 animation: spotlightFadeIn 0.28s cubic-bezier(0.16, 1, 0.3, 1);
54 }
55 .aien-avatar-ambient {
56 position: absolute;
57 top: 50%;
58 left: 50%;
59 width: 380px;
60 height: 380px;
61 margin-top: -190px;
62 margin-left: -190px;
63 border-radius: 50%;
64 object-fit: cover;
65 pointer-events: none;
66 z-index: 0;
67 animation: aienBreathe 6s ease-in-out infinite;
68 transition: all 0.5s ease;
69 }
70 .aien-avatar-ambient.reasoning-active {
71 animation: aienPulseReasoning 1.8s ease-in-out infinite;
72 }
73 .aien-content-layer {
74 position: relative;
75 z-index: 1;
76 display: flex;
77 flex-direction: column;
78 height: 100%;
79 max-height: 84vh;
80 }
81 .aien-chip {
82 background: rgba(15, 23, 42, 0.65);
83 color: #94a3b8;
84 border: 1px solid rgba(56, 189, 248, 0.22);
85 border-radius: 9999px;
86 padding: 5px 12px;
87 font-size: 11px;
88 font-family: inherit;
89 cursor: pointer;
90 transition: all 0.2s ease;
91 white-space: nowrap;
92 }
93 .aien-chip:hover {
94 background: rgba(56, 189, 248, 0.15);
95 color: #f8fafc;
96 border-color: rgba(56, 189, 248, 0.5);
97 transform: translateY(-1px);
98 }
99 .aien-reasoning-disclosure {
100 background: rgba(15, 23, 42, 0.55);
101 border: 1px dashed rgba(56, 189, 248, 0.25);
102 border-radius: 8px;
103 padding: 8px 12px;
104 font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, monospace;
105 font-size: 11px;
106 color: #94a3b8;
107 margin-bottom: 8px;
108 }
109 .aien-reasoning-disclosure summary {
110 cursor: pointer;
111 color: #38bdf8;
112 font-weight: 600;
113 outline: none;
114 display: flex;
115 align-items: center;
116 gap: 6px;
117 }
118 .chat-scroll::-webkit-scrollbar {
119 width: 5px;
120 }
121 .chat-scroll::-webkit-scrollbar-thumb {
122 background: rgba(56, 189, 248, 0.25);
123 border-radius: 9999px;
124 }
125 .chat-scroll::-webkit-scrollbar-track {
126 background: transparent;
127 }
128 `;
129 document.head.appendChild(styleTag);
130
131 // 2. Build Ingress Capsule (Bottom Right / Center)
132 const capsule = document.createElement('div');
133 capsule.id = 'spark-live-ticker';
134 capsule.style.cssText = `
135 position: fixed;
136 bottom: 16px;
137 right: 20px;
138 z-index: 9998;
139 background: rgba(10, 15, 29, 0.85);
140 border: 1px solid rgba(56, 189, 248, 0.32);
141 border-radius: 9999px;
142 padding: 7px 16px;
143 font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
144 font-size: 12px;
145 color: #94a3b8;
146 box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6), 0 0 15px rgba(56, 189, 248, 0.15);
147 backdrop-filter: blur(16px);
148 -webkit-backdrop-filter: blur(16px);
149 display: flex;
150 align-items: center;
151 gap: 10px;
152 cursor: pointer;
153 transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
154 user-select: none;
155 `;
156
157 capsule.innerHTML = `
158
159 Talk to AIEN
160 ⌘K
161 |
162 GB10 ONLINE
163 `;
164
165 capsule.addEventListener('mouseenter', () => {
166 capsule.style.transform = 'translateY(-2px)';
167 capsule.style.borderColor = 'rgba(56, 189, 248, 0.55)';
168 capsule.style.boxShadow = '0 12px 36px rgba(0, 0, 0, 0.7), 0 0 25px rgba(56, 189, 248, 0.25)';
169 });
170 capsule.addEventListener('mouseleave', () => {
171 capsule.style.transform = 'translateY(0)';
172 capsule.style.borderColor = 'rgba(56, 189, 248, 0.32)';
173 capsule.style.boxShadow = '0 8px 32px rgba(0, 0, 0, 0.6), 0 0 15px rgba(56, 189, 248, 0.15)';
174 });
175
176 document.body.appendChild(capsule);
177
178 // 3. Build Centered Spotlight Modal
179 const backdrop = document.createElement('div');
180 backdrop.id = 'aien-spotlight-modal';
181 backdrop.className = 'aien-spotlight-backdrop';
182
183 backdrop.innerHTML = `
184
185
186
187
188
189
190
191
192
193
194
195
AIEN SOVEREIGN CONSOLE
196
GRACE BLACKWELL GB10 // PORT 18006
197
198
199
200 ESC
201 ✕
202
203
204
205
206
207 Who is Drake?
208 Mom & Drive
209 Grace Blackwell GB10
210 Atlas Symphony
211
212
213
214
222
223
224
231
232
233 `;
234
235 document.body.appendChild(backdrop);
236
237 // 4. State & Elements
238 const ambientImg = document.getElementById('aien-ambient-img');
239 const messagesBox = document.getElementById('spotlight-messages');
240 const spotlightForm = document.getElementById('spotlight-form');
241 const spotlightInput = document.getElementById('spotlight-input');
242 const spotlightSend = document.getElementById('spotlight-send');
243 const closeBtn = document.getElementById('spotlight-close');
244 const tickerDot = document.getElementById('ticker-dot');
245 const tickerGpu = document.getElementById('ticker-gpu');
246
247 function openSpotlight() {
248 backdrop.classList.add('open');
249 setTimeout(() => spotlightInput.focus(), 50);
250 }
251
252 function closeSpotlight() {
253 backdrop.classList.remove('open');
254 }
255
256 capsule.addEventListener('click', openSpotlight);
257 closeBtn.addEventListener('click', closeSpotlight);
258
259 // Light dismiss on backdrop click
260 backdrop.addEventListener('click', (e) => {
261 if (e.target === backdrop) {
262 closeSpotlight();
263 }
264 });
265
266 // Universal Hotkeys: Cmd+K, Ctrl+K, /, Escape
267 document.addEventListener('keydown', (e) => {
268 if ((e.metaKey || e.ctrlKey) && e.key.toLowerCase() === 'k') {
269 e.preventDefault();
270 if (backdrop.classList.contains('open')) {
271 closeSpotlight();
272 } else {
273 openSpotlight();
274 }
275 } else if (e.key === 'Escape' && backdrop.classList.contains('open')) {
276 e.preventDefault();
277 closeSpotlight();
278 } else if (e.key === '/' && !backdrop.classList.contains('open')) {
279 const activeTag = document.activeElement ? document.activeElement.tagName.toLowerCase() : '';
280 if (activeTag !== 'input' && activeTag !== 'textarea') {
281 e.preventDefault();
282 openSpotlight();
283 }
284 }
285 });
286
287 // Quick Chips Handlers
288 backdrop.querySelectorAll('.aien-chip').forEach(btn => {
289 btn.addEventListener('click', () => {
290 const q = btn.getAttribute('data-q');
291 spotlightInput.value = q;
292 spotlightForm.dispatchEvent(new Event('submit'));
293 });
294 });
295
296 // 5. Telemetry SSE Stream
297 let es = null;
298 function connectTelemetry() {
299 try {
300 es = new EventSource('/api/live/stream');
301 es.addEventListener('telemetry', (e) => {
302 try {
303 const data = JSON.parse(e.data);
304 tickerDot.style.background = '#10b981';
305 tickerDot.style.boxShadow = '0 0 8px #10b981';
306 tickerGpu.textContent = `GB10 ${data.gpu_utilization_pct}% (${data.gpu_temperature_c}°C)`;
307 } catch(err) {}
308 });
309
310 es.onerror = () => {
311 tickerDot.style.background = '#f59e0b';
312 tickerDot.style.boxShadow = '0 0 8px #f59e0b';
313 tickerGpu.textContent = 'STANDBY';
314 if (es) { es.close(); }
315 setTimeout(connectTelemetry, 5000);
316 };
317 } catch(e) {
318 tickerDot.style.background = '#64748b';
319 tickerGpu.textContent = 'OFFLINE';
320 }
321 }
322 connectTelemetry();
323
324 // 6. Chat Submission Stream Handler
325 spotlightForm.addEventListener('submit', async (e) => {
326 e.preventDefault();
327 const query = spotlightInput.value.trim();
328 if (!query) return;
329
330 spotlightInput.value = '';
331 spotlightInput.disabled = true;
332 spotlightSend.disabled = true;
333
334 // Render User Speech Bubble
335 const userRow = document.createElement('div');
336 userRow.style.cssText = 'align-self:flex-end;max-width:85%;display:flex;flex-direction:column;align-items:flex-end;';
337 userRow.innerHTML = `
338
339 ${escapeHtml(query)}
340
341 `;
342 messagesBox.appendChild(userRow);
343
344 // Render AIEN Streaming Container
345 const aienRow = document.createElement('div');
346 aienRow.style.cssText = 'display:flex;gap:12px;align-items:flex-start;max-width:92%;';
347
348 const avatarIcon = document.createElement('img');
349 avatarIcon.src = '/images/aien-avatar.jpg';
350 avatarIcon.style.cssText = 'width:30px;height:30px;border-radius:50%;border:1px solid #38bdf8;object-fit:cover;flex-shrink:0;margin-top:2px;';
351 aienRow.appendChild(avatarIcon);
352
353 const messageBubble = document.createElement('div');
354 messageBubble.style.cssText = 'background:rgba(15, 23, 42, 0.65);border:1px solid rgba(56, 189, 248, 0.2);border-radius:14px 14px 14px 2px;padding:12px 14px;color:#e2e8f0;font-size:13px;line-height:1.6;flex:1;';
355
356 const reasoningBlock = document.createElement('details');
357 reasoningBlock.className = 'aien-reasoning-disclosure';
358 reasoningBlock.innerHTML = `
359 ⚡ Thinking on GB10...
360
361 `;
362 reasoningBlock.style.display = 'none';
363 messageBubble.appendChild(reasoningBlock);
364
365 const contentBlock = document.createElement('div');
366 contentBlock.className = 'aien-content-body';
367 contentBlock.innerHTML = '... ';
368 messageBubble.appendChild(contentBlock);
369
370 aienRow.appendChild(messageBubble);
371 messagesBox.appendChild(aienRow);
372 messagesBox.scrollTop = messagesBox.scrollHeight;
373
374 const reasoningBody = reasoningBlock.querySelector('.reasoning-body');
375
376 // Trigger Ambient AIEN Avatar reasoning glow
377 ambientImg.classList.add('reasoning-active');
378
379 try {
380 const response = await fetch('/api/chat', {
381 method: 'POST',
382 headers: { 'Content-Type': 'application/json' },
383 body: JSON.stringify({ message: query })
384 });
385
386 if (!response.ok) {
387 const err = await response.json();
388 contentBlock.textContent = err.error || 'Request failed.';
389 finish();
390 return;
391 }
392
393 contentBlock.textContent = '';
394 const reader = response.body.getReader();
395 const decoder = new TextDecoder('utf-8');
396 let buffer = '';
397
398 while (true) {
399 const { done, value } = await reader.read();
400 if (done) break;
401
402 buffer += decoder.decode(value, { stream: true });
403 const lines = buffer.split('\n');
404 buffer = lines.pop();
405
406 for (let i = 0; i < lines.length; i++) {
407 const line = lines[i].trim();
408 if (!line.startsWith('event: ')) continue;
409 const eventType = line.substring(7);
410 const dataLine = lines[i + 1] ? lines[i + 1].trim() : '';
411
412 if (dataLine.startsWith('data: ')) {
413 i++;
414 try {
415 const data = JSON.parse(dataLine.substring(6));
416 if (eventType === 'reasoning') {
417 reasoningBlock.style.display = 'block';
418 reasoningBody.textContent += data.token;
419 messagesBox.scrollTop = messagesBox.scrollHeight;
420 } else if (eventType === 'content') {
421 // If content starts arriving, adjust ambient glow
422 ambientImg.classList.remove('reasoning-active');
423 contentBlock.textContent += data.token;
424 messagesBox.scrollTop = messagesBox.scrollHeight;
425 }
426 } catch(e) {}
427 }
428 }
429 }
430 } catch(err) {
431 contentBlock.textContent = 'Connection interrupted.';
432 }
433
434 finish();
435
436 function finish() {
437 ambientImg.classList.remove('reasoning-active');
438 spotlightInput.disabled = false;
439 spotlightSend.disabled = false;
440 spotlightInput.focus();
441 messagesBox.scrollTop = messagesBox.scrollHeight;
442 }
443 });
444
445 function escapeHtml(str) {
446 return str.replace(/[&<>'"]/g,
447 tag => ({ '&': '&', '<': '<', '>': '>', "'": ''', '"': '"' }[tag] || tag)
448 );
449 }
450 })();