Open-source platform for 3D AI agents. Turn text or a photo into a rigged, animated GLB avatar, give it an LLM brain, memory and a wallet, and embed it anywhere with one web component. Remote MCP server, x402 payments, Three.js, browser-native.
JavaScript 3d-generationai-agentsanimationavatardigital-humangenerative-aiglbgltfimage-to-3dllmmcpmcp-servermodel-context-protocolsolanatext-to-3dthreejsweb-componentswebglwebxrx402
feat(symphony): burst gate collapses event floods into accented notes; cross-link from /pulse
nirholas8479b687665b
diff --git a/pages/pulse.html b/pages/pulse.htmlindex 6eb888109..88dd6389c 100644--- a/pages/pulse.html+++ b/pages/pulse.html@@ -149,6 +149,10 @@<div id="px-launches"><p class="px-lb-empty" data-i18n="pulse.loading_3">Loading…</p></div></section><div id="px-stats"></div>+ <p class="px-sub px-fineprint">+ Prefer to hear it? The same stream plays live as generative music on the+ <a href="/symphony">Agent Symphony</a>.+ </p><p class="px-sub px-fineprint" data-i18n-html="pulse.network_mainnet_private_withdrawals_and_cust">Network: <strong id="px-net-label">mainnet</strong>. Private withdrawals and custody events are never shown — only already-public activity.</p>diff --git a/src/symphony-score.js b/src/symphony-score.jsindex 8049b3a5a..c8c4992e4 100644--- a/src/symphony-score.js+++ b/src/symphony-score.js@@ -147,6 +147,44 @@ export function eventToNote(evt) {};}+/**+ * Burst gate: the live feed arrives in floods (a sniper sweep can emit dozens+ * of identical `agent-guard` events in seconds), and a note per event would+ * machine-gun the same sound. The gate admits one note per (type, actor) key+ * per `minGapMs`, counting what it suppressed; the caller plays the next+ * admitted note slightly accented so a flood still reads as "a lot happened",+ * musically instead of literally.+ *+ * Pure and clock-injected: callers pass `now` (epoch ms) explicitly.+ */+export function createBurstGate(minGapMs = 1500) {+ const last = new Map(); // key -> { ts, suppressed }+ const MAX_KEYS = 200;+ return {+ /**+ * @returns {{ play: boolean, accent: number }} accent is 0..0.3, sized+ * by how many notes this key swallowed since it last played.+ */+ admit(evt, now) {+ const key = `${evt && evt.type}|${evt && evt.actor}`;+ const entry = last.get(key);+ if (entry && now - entry.ts < minGapMs) {+ entry.suppressed++;+ return { play: false, accent: 0 };+ }+ const accent = entry ? Math.min(0.3, entry.suppressed * 0.05) : 0;+ last.set(key, { ts: now, suppressed: 0 });+ if (last.size > MAX_KEYS) {+ for (const [k, v] of last) {+ if (now - v.ts > minGapMs * 4) last.delete(k);+ if (last.size <= MAX_KEYS / 2) break;+ }+ }+ return { play: true, accent };+ },+ };+}+function shortMint(mint) {const s = String(mint || '');return s.length > 10 ? `${s.slice(0, 4)}..${s.slice(-4)}` : s;diff --git a/src/symphony.js b/src/symphony.jsindex 306189f19..bff09ebc0 100644--- a/src/symphony.js+++ b/src/symphony.js@@ -19,7 +19,7 @@import { esc, timeAgo } from './shared/pulse-format.js';import { createLogger } from './shared/log.js';-import { CATEGORIES, eventToNote, describeEvent, ROOT_HZ } from './symphony-score.js';+import { CATEGORIES, eventToNote, describeEvent, createBurstGate, ROOT_HZ } from './symphony-score.js';const log = createLogger('symphony');@@ -47,6 +47,8 @@ const state = {function clamp01(n) { return Number.isFinite(n) ? Math.min(1, Math.max(0, n)) : 0.7; }+const burstGate = createBurstGate(1500);+function loadJson(key, fallback) {try { return JSON.parse(localStorage.getItem(key)) ?? fallback; } catch { return fallback; }}@@ -432,8 +434,14 @@ function acceptEvent(evt, { silent = false } = {}) {const note = eventToNote(evt);if (!silent && state.playing) {- if (playNote(note)) state.notesPlayed++;- vizSpawn(note);+ // Floods (e.g. a sniper sweep emitting dozens of identical guard events)+ // collapse into one accented note per actor instead of a machine-gun.+ const { play, accent } = burstGate.admit(evt, Date.now());+ if (play) {+ note.gain = Math.min(1, note.gain + accent);+ if (playNote(note)) state.notesPlayed++;+ vizSpawn(note);+ }}renderLedger();renderStats();diff --git a/tests/symphony-score.test.js b/tests/symphony-score.test.jsindex a7961ade6..6a09e0a83 100644--- a/tests/symphony-score.test.js+++ b/tests/symphony-score.test.js@@ -11,6 +11,7 @@ import {intensityOf,eventToNote,describeEvent,+ createBurstGate,} from '../src/symphony-score.js';describe('symphony-score: scale', () => {@@ -161,3 +162,38 @@ describe('symphony-score: describeEvent', () => {expect(row.icon.length).toBeGreaterThan(0);});});++describe('symphony-score: burst gate', () => {+ const guard = (actor = 'luna') => ({ type: 'agent-guard', actor });++ it('admits the first event and suppresses the flood behind it', () => {+ const gate = createBurstGate(1500);+ expect(gate.admit(guard(), 1000).play).toBe(true);+ expect(gate.admit(guard(), 1200).play).toBe(false);+ expect(gate.admit(guard(), 2400).play).toBe(false);+ });++ it('re-admits after the gap with an accent sized by what it swallowed', () => {+ const gate = createBurstGate(1500);+ gate.admit(guard(), 1000);+ for (let t = 1100; t < 2500; t += 100) gate.admit(guard(), t);+ const next = gate.admit(guard(), 3000);+ expect(next.play).toBe(true);+ expect(next.accent).toBeGreaterThan(0);+ expect(next.accent).toBeLessThanOrEqual(0.3);+ });++ it('gates per (type, actor): different actors play independently', () => {+ const gate = createBurstGate(1500);+ expect(gate.admit(guard('luna'), 1000).play).toBe(true);+ expect(gate.admit(guard('nova'), 1001).play).toBe(true);+ expect(gate.admit({ type: 'payment', actor: 'luna' }, 1002).play).toBe(true);+ });++ it('never accents an unsuppressed key', () => {+ const gate = createBurstGate(1500);+ gate.admit(guard(), 1000);+ const next = gate.admit(guard(), 5000);+ expect(next).toEqual({ play: true, accent: 0 });+ });+});