interplane.Get Omega
Read in your language

aienos.com

Source of www.aienos.com, served from my own hardware

Brought by drakestapleton

branch main Branches Tags History

aienos.com / om / hive-page / hive-js.om

71 lines · 18861 bytes Raw Blame History
1note Edge-board client. Omega owns every feed text node; browser owns interaction state.
2text js0 "/* Generated by om/hive-page/hive-js.om. Never edit this artifact.\n * Only same-origin edge-rendered HTML enters DOMParser; never render JSON here. */\n(() => {\n 'use strict';\n const page = document.getElementById('~9~');\n if (!page) return;\n const get = id => document.getElementById(id);\n const tree = get('~20~'), chat = get('~36~'), search = get('~17~');\n const store = get('~64~'), panel = get('~23~');\n let selected = new URLSearchParams(location.hash.slice(1)).get('agent');\n let scope = 'all', query = '', board = null, connected = false, regressed = false;\n let advancedAt = 0, sourceAge = 0, trusted = false, active = false;\n let searchOpen = null;\n const say = (id, value) => { const node = get(id); if (node && node.textContent !== value) node.textContent = value; };\n\n // Patch in place. Id-keyed nodes survive reordering; unkeyed structure is paired\n // positionally. A stack avoids recursion through deeply nested mission trees.\n"
3text js1 " function morph(target, source) {\n const work = [[target, source]];\n while (work.length) {\n const [old, fresh] = work.pop();\n if (old.isEqualNode(fresh)) continue;\n if (old.nodeType !== fresh.nodeType || old.nodeName !== fresh.nodeName) { old.replaceWith(fresh.cloneNode(true)); continue; }\n if (old.nodeType !== Node.ELEMENT_NODE) { old.nodeValue = fresh.nodeValue; continue; }\n const preserve = name => (old.tagName === 'DETAILS' && name === 'open') || name === 'hidden' || name === 'data-selected';\n for (const attr of [...old.attributes]) if (!preserve(attr.name) && !fresh.hasAttribute(attr.name)) old.removeAttribute(attr.name);\n for (const attr of fresh.attributes) if (!preserve(attr.name) && old.getAttribute(attr.name) !== attr.value) old.setAttribute(attr.name, attr.value);\n const keyed = new Map([...old.childNodes].filter(node => node.id).map(node => [node.id, node]));\n const wanted = new Set();\n let at = old.firstChild;\n for (const child of fresh.childNodes) {\n let node = child.id ? keyed.get(child.id) : at && !at.id && at.nodeName === child.nodeName ? at : null;\n if (!node) node = child.cloneNode(true);\n if (node !== at) old.insertBefore(node, at);\n wanted.add(node);\n work.push([node, child]);\n at = node.nextSibling;\n }\n for (const child of [...old.childNodes]) if (!wanted.has(child)) child.remove();\n }\n }\n\n"
4text js2 " function filters() {\n const visible = new Set();\n let hits = 0;\n for (const row of tree.querySelectorAll('.hive-node')) {\n const id = row.id.slice(5), card = get('manifest-' + id);\n const matches = !query || (row.querySelector('summary')?.textContent + ' ' + card?.textContent).toLowerCase().includes(query);\n if (matches) {\n hits += 1;\n for (let up = row; up && up !== tree; up = up.parentElement) {\n if (up.matches('.hive-node')) visible.add(up);\n if (query && up.tagName === 'DETAILS') up.open = true;\n }\n }\n }\n for (const row of tree.querySelectorAll('.hive-node')) row.hidden = !visible.has(row);\n say('~18~', query ? `${hits} matching agents` : '');\n for (const item of chat.children) item.hidden = scope === 'selected' && item.dataset.agent !== selected;\n get('~32~').setAttribute('aria-pressed', String(scope === 'all'));\n get('~33~').setAttribute('aria-pressed', String(scope === 'selected'));\n }\n\n"
5text js3 " function choose(id, fragment = true, reveal = true) {\n if (panel.firstElementChild) store.append(panel.firstElementChild);\n const card = get('manifest-' + id), row = get('node-' + id);\n selected = id;\n panel.hidden = !card;\n get('~22~').hidden = Boolean(card);\n if (card) { card.open = true; panel.append(card); }\n for (const item of tree.querySelectorAll('.hive-node')) item.dataset.selected = String(item === row);\n if (row && reveal) for (let up = row.parentElement; up && up !== tree; up = up.parentElement) if (up.tagName === 'DETAILS') up.open = true;\n if (fragment && row) { try { history.replaceState(null, '', '#agent=' + encodeURIComponent(id)); } catch (_) {} }\n filters();\n }\n\n"
6text js4 " function freshness() {\n if (!board) { page.dataset.fresh = 'false'; return; }\n const elapsed = Math.max(0, performance.now() - advancedAt);\n const state = window.hiveFresh(sourceAge + elapsed, 0, regressed ? 1 : 0, Number(board.dataset.staleAfter), connected);\n const stale = state === 1;\n page.dataset.fresh = String(connected && !stale && trusted);\n say('~12~', !connected ? regressed ? 'Snapshot timestamp moved backwards; last observation retained' : 'Connection interrupted; last snapshot retained' : stale ? 'Source stale; last observation retained' : !trusted ? 'Connected; source age not verified' : 'Receiving source observations');\n say('~13~', `${Math.floor(elapsed / 1000)}s since the source timestamp advanced. Last observation retained on interruption.`);\n }\n\n"
7text js5 " function ingest(markup, serverDate) {\n const document = new DOMParser().parseFromString(markup, 'text/html');\n const incoming = document.getElementById('~63~');\n const generated = Date.parse(incoming?.dataset.generated || '');\n if (!incoming || !Number.isFinite(generated) || incoming.dataset.staleAfter !== '~65~' || !/^s-[0-9a-f]{0,256}$/.test(incoming.dataset.sequence || '')) throw new Error('Invalid edge board');\n if (board && window.hiveFresh(generated, generated, Date.parse(board.dataset.generated), Number(incoming.dataset.staleAfter), true) === 2) { regressed = true; throw new Error('Snapshot moved backwards'); }\n for (const id of ['~20~', '~36~', '~64~', '~10~', '~14~', '~15~']) if (!incoming.querySelector('#' + id)) throw new Error('Incomplete edge board');\n if (!board || generated > Date.parse(board.dataset.generated)) {\n advancedAt = performance.now();\n const server = Date.parse(serverDate || '');\n trusted = Number.isFinite(server) && generated <= server + ~61~;\n sourceAge = trusted ? Math.max(0, server - generated) : 0;\n }\n regressed = false;\n const focused = window.document.activeElement;\n const scroll = [chat.scrollTop, tree.parentElement.scrollTop, panel.parentElement.scrollTop];\n if (panel.firstElementChild) store.append(panel.firstElementChild);\n for (const id of ['~20~', '~36~', '~64~', '~10~', '~14~', '~15~']) morph(get(id), incoming.querySelector('#' + id));\n board = incoming;\n for (const name of ['generated', 'sequence', 'staleAfter']) page.dataset[name] = incoming.dataset[name];\n connected = true;\n get('~19~').hidden = tree.children.length > 0;\n get('~35~').hidden = chat.children.length > 0;\n say('~11~', new Date().toISOString());\n choose(selected, false, false);\n [chat.scrollTop, tree.parentElement.scrollTop, panel.parentElement.scrollTop] = scroll;\n if (focused?.isConnected && window.document.activeElement !== focused) focused.focus({ preventScroll: true });\n freshness();\n }\n\n"
8text js6 " async function poll() {\n if (active) return;\n active = true;\n const controller = new AbortController();\n const timeout = setTimeout(() => controller.abort(), ~62~);\n try {\n const response = await fetch('~66~', { cache: 'no-store', credentials: 'omit', signal: controller.signal, headers: { Accept: 'text/html' } });\n if (!response.ok || !response.headers.get('content-type')?.toLowerCase().includes('text/html')) throw new Error('Board unavailable');\n ingest(await response.text(), response.headers.get('date'));\n } catch (_) {\n connected = false;\n if (!board) say('~12~', 'Telemetry unavailable; no source observation received');\n freshness();\n } finally { clearTimeout(timeout); active = false; }\n }\n\n"
9text js7 " search.addEventListener('input', () => {\n query = search.value.trim().toLowerCase();\n if (query && !searchOpen) searchOpen = new Map([...tree.querySelectorAll('details[id]')].map(node => [node.id, node.open]));\n if (!query && searchOpen) { for (const [id, open] of searchOpen) { const node = get(id); if (node) node.open = open; } searchOpen = null; }\n filters();\n });\n tree.addEventListener('click', event => { const link = event.target.closest('a[data-agent]'); if (link) { event.preventDefault(); choose(link.dataset.agent); } });\n get('~32~').addEventListener('click', () => { scope = 'all'; filters(); });\n get('~33~').addEventListener('click', () => { scope = 'selected'; filters(); });\n addEventListener('hashchange', () => choose(new URLSearchParams(location.hash.slice(1)).get('agent'), false));\n setInterval(freshness, ~59~);\n setInterval(poll, ~59~);\n poll();\n})();\n"
10text js8 "/* Hive universe: every observed agent as a world, read from the edge-rendered tree. */\n(() => {\n 'use strict';\n const tree = document.getElementById('hive-tree');\n const anchor = document.getElementById('hive-tree-section');\n if (!tree || !anchor || !window.SVGElement) return;\n const NS = 'http://www.w3.org/2000/svg';\n const section = document.createElement('section');\n section.id = 'hive-universe-section';\n section.className = 'hive-section hive-section-full hive-panel hive-universe';\n section.setAttribute('aria-labelledby', 'hive-universe-title');\n section.innerHTML = `<div class=\"hive-panel-head\"><p class=\"hive-eyebrow\">Universe</p><h2 id=\"hive-universe-title\">Every agent, as a world</h2><p class=\"hive-note\">Each coding session is a star and the workers it started orbit it. Hold Ctrl and scroll, pinch, or use the buttons to zoom; drag to move, select a world to open it. A solid amber ring means the agent is idle because its provider's usage limit was reached; a dashed one means the provider was at capacity.</p></div><div class=\"hive-universe-tools\" role=\"group\" aria-label=\"Universe zoom\"><button type=\"button\" data-zoom=\"in\" aria-label=\"Zoom in\">+</button><button type=\"button\" data-zoom=\"out\" aria-label=\"Zoom out\">&#8722;</button><button type=\"button\" data-zoom=\"fit\">Show all</button><span class=\"hive-universe-count\" aria-live=\"polite\"></span></div>`;\n const sky = document.createElementNS(NS, 'svg');\n sky.setAttribute('class', 'hive-universe-sky');\n sky.setAttribute('role', 'group');\n sky.setAttribute('aria-label', 'Agent universe');\n sky.setAttribute('height', '560');\n sky.setAttribute('preserveAspectRatio', 'xMidYMid meet');\n section.append(sky);\n anchor.before(section);\n const count = section.querySelector('.hive-universe-count');\n let last = '';\n let view = null, bounds = { x: -200, y: -200, w: 400, h: 400 }, fitted = true;\n\n function read() {\n const all = new Map(), roots = [];\n for (const li of tree.querySelectorAll('li.hive-node')) {\n const s = li.querySelector('summary');\n if (!s) continue;\n const pick = c => (s.querySelector(c) || {}).textContent || '';\n const node = { id: li.id.slice(5), name: pick('.hive-select'), status: pick('.hive-pill').trim().toLowerCase(), activity: pick('.hive-activity'), kids: [] };\n all.set(li, node);\n const up = li.parentElement && li.parentElement.closest('li.hive-node');\n (up && all.get(up) ? all.get(up).kids : roots).push(node);\n }\n return { roots, total: all.size };\n }\n function cls(n) {\n let c = 'hive-world st-' + (n.status.replace(/[^a-z]/g, '') || 'unknown');\n if (n.activity.startsWith('Idle: provider usage limit')) c += ' is-limited';\n else if (n.activity.startsWith('Idle: provider at capacity')) c += ' is-capacity';\n return c;\n }\n function el(name, attrs, parent) {\n const e = document.createElementNS(NS, name);\n for (const k in attrs) e.setAttribute(k, attrs[k]);\n if (parent) parent.append(e);\n return e;\n }\n function world(n, x, y, r, parent) {\n const a = el('a', { href: '#agent=' + encodeURIComponent(n.id), class: cls(n) }, parent);\n el('title', {}, a).textContent = [n.name, n.status, n.activity].filter(Boolean).join(' | ');\n el('circle', { cx: x.toFixed(1), cy: y.toFixed(1), r: r.toFixed(1) }, a);\n return a;\n }\n function radius(n, depth) {\n const own = depth ? Math.max(3, 9 - depth * 3) : 16;\n if (!n.kids.length) return own;\n const ring = own + 12 + n.kids.length * (depth ? 2 : 4);\n return ring + Math.max(...n.kids.map(k => radius(k, depth + 1)));\n }\n function system(n, x, y, depth, parent) {\n const own = depth ? Math.max(3, 9 - depth * 3) : 16;\n if (n.kids.length) {\n const ring = own + 12 + n.kids.length * (depth ? 2 : 4);\n el('circle', { cx: x.toFixed(1), cy: y.toFixed(1), r: ring.toFixed(1), class: 'hive-orbit-path' }, parent);\n const g = el('g', { class: 'hive-orbit' }, parent);\n n.kids.forEach((k, i) => {\n const t = 2 * Math.PI * i / n.kids.length;\n system(k, x + ring * Math.cos(t), y + ring * Math.sin(t), depth + 1, g);\n });\n }\n world(n, x, y, own, parent);\n }\n function draw() {\n const { roots, total } = read();\n const sig = JSON.stringify(roots);\n if (sig === last) return;\n last = sig;\n const held = sky.contains(document.activeElement) ? document.activeElement.getAttribute('href') : null;\n sky.replaceChildren();\n count.textContent = total === 1 ? '1 agent' : total + ' agents';\n if (!roots.length) { bounds = { x: -200, y: -200, w: 400, h: 400 }; apply(); return; }\n const step = 2.4 * Math.max(...roots.map(r => radius(r, 0)));\n let lo = [Infinity, Infinity], hi = [-Infinity, -Infinity];\n roots.forEach((r, i) => {\n const d = i ? step * Math.sqrt(i) : 0, t = i * 2.39996;\n const x = d * Math.cos(t), y = d * Math.sin(t), m = radius(r, 0) + 24;\n const g = el('g', { class: 'hive-system' }, sky);\n system(r, x, y, 0, g);\n const label = el('text', { x: x.toFixed(1), y: (y + 30).toFixed(1), class: 'hive-world-label' }, g);\n label.textContent = r.name.length > 28 ? r.name.slice(0, 27) + '...' : r.name;\n lo = [Math.min(lo[0], x - m), Math.min(lo[1], y - m)];\n hi = [Math.max(hi[0], x + m), Math.max(hi[1], y + m)];\n });\n bounds = { x: lo[0], y: lo[1], w: hi[0] - lo[0], h: hi[1] - lo[1] };\n apply();\n if (held) { const again = [...sky.querySelectorAll('a')].find(a => a.getAttribute('href') === held); if (again) again.focus({ preventScroll: true }); }\n }\n function apply() {\n const r = sky.getBoundingClientRect();\n const aspect = r.width > 0 && r.height > 0 ? r.height / r.width : 1;\n if (fitted || !view) {\n const w = Math.max(bounds.w, bounds.h / aspect);\n view = { x: bounds.x + bounds.w / 2 - w / 2, y: bounds.y + bounds.h / 2 - w * aspect / 2, w, h: w * aspect };\n } else view.h = view.w * aspect;\n sky.setAttribute('viewBox', [view.x, view.y, view.w, view.h].map(v => v.toFixed(1)).join(' '));\n }\n function zoom(f, cx, cy) {\n if (!view) return;\n const w = Math.min(Math.max(view.w * f, 20), Math.max(bounds.w, bounds.h) * 4);\n const k = w / view.w;\n if (cx === undefined) { cx = view.x + view.w / 2; cy = view.y + view.h / 2; }\n view = { x: cx - (cx - view.x) * k, y: cy - (cy - view.y) * k, w, h: view.h * k };\n fitted = false; apply();\n }\n function point(e) {\n const r = sky.getBoundingClientRect();\n if (!(r.width > 0 && r.height > 0)) return [view.x + view.w / 2, view.y + view.h / 2];\n return [view.x + (e.clientX - r.left) / r.width * view.w, view.y + (e.clientY - r.top) / r.height * view.h];\n }\n section.querySelector('.hive-universe-tools').addEventListener('click', e => {\n const b = e.target.closest('button');\n if (!b) return;\n if (b.dataset.zoom === 'fit') { fitted = true; apply(); }\n else zoom(b.dataset.zoom === 'in' ? 0.7 : 1 / 0.7);\n });\n sky.addEventListener('wheel', e => { if (!e.ctrlKey && !e.metaKey) return; e.preventDefault(); const [x, y] = point(e); zoom(e.deltaY < 0 ? 0.85 : 1 / 0.85, x, y); }, { passive: false });\n sky.addEventListener('dblclick', e => { const [x, y] = point(e); zoom(0.5, x, y); });\n const down = new Map();\n let pinch = 0, moved = false;\n sky.addEventListener('pointerdown', e => { down.set(e.pointerId, [e.clientX, e.clientY]); moved = false; });\n sky.addEventListener('pointermove', e => {\n const last = down.get(e.pointerId);\n if (!last || !view) return;\n const r = sky.getBoundingClientRect();\n if (!(r.width > 0 && r.height > 0)) return;\n if (down.size === 1) {\n const dx = e.clientX - last[0], dy = e.clientY - last[1];\n if (!moved && Math.hypot(dx, dy) < 4) return;\n if (!moved) sky.setPointerCapture(e.pointerId);\n moved = true;\n view.x -= dx / r.width * view.w; view.y -= dy / r.height * view.h; fitted = false; apply();\n }\n down.set(e.pointerId, [e.clientX, e.clientY]);\n if (down.size === 2) {\n const [p, q] = [...down.values()], d = Math.hypot(p[0] - q[0], p[1] - q[1]);\n if (pinch) zoom(pinch / d);\n pinch = d; moved = true;\n }\n });\n const up = e => { down.delete(e.pointerId); if (down.size < 2) pinch = 0; };\n sky.addEventListener('pointerup', up);\n sky.addEventListener('pointercancel', up);\n sky.addEventListener('click', e => { if (moved) { e.preventDefault(); moved = false; } }, true);\n let queued = false;\n new MutationObserver(() => { if (!queued) { queued = true; requestAnimationFrame(() => { queued = false; draw(); }); } })\n .observe(tree, { childList: true, subtree: true, characterData: true });\n // Refit only when the element's box really changed: the viewBox never feeds back into its size.\n let box = '';\n if (window.ResizeObserver) new ResizeObserver(() => { const r = sky.getBoundingClientRect(); const now = Math.round(r.width) + 'x' + Math.round(r.height); if (now !== box) { box = now; apply(); } }).observe(sky);\n draw();\n})();\n"
11fn javascript to void
12flush
13put target 0 3
14freshjs
15jsfunc0
16jsfunc1
17jsfunc2
18jsfunc3
19jsfunc4
20jsfunc5
21jsfunc6
22jsfunc7
23jsfunc8
24flush
25put target 0 1
26end
27fn jsfunc0 to void
28for i ulong len js0
29byteput get js0 i
30end
31end
32fn jsfunc1 to void
33for i ulong len js1
34byteput get js1 i
35end
36end
37fn jsfunc2 to void
38for i ulong len js2
39byteput get js2 i
40end
41end
42fn jsfunc3 to void
43for i ulong len js3
44byteput get js3 i
45end
46end
47fn jsfunc4 to void
48for i ulong len js4
49byteput get js4 i
50end
51end
52fn jsfunc5 to void
53for i ulong len js5
54byteput get js5 i
55end
56end
57fn jsfunc6 to void
58for i ulong len js6
59byteput get js6 i
60end
61end
62fn jsfunc7 to void
63for i ulong len js7
64byteput get js7 i
65end
66end
67fn jsfunc8 to void
68for i ulong len js8
69byteput get js8 i
70end
71end