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
fix(agents-live): spend a stream only where something is pushed, and open one on real intent
nirholas889d8182f282
diff --git a/pages/agent-trade.html b/pages/agent-trade.htmlindex 2ee1e36b7..49b1188ac 100644--- a/pages/agent-trade.html+++ b/pages/agent-trade.html@@ -280,16 +280,21 @@.cfg-link:focus-visible { outline: 2px solid var(--teal); outline-offset: 3px; border-radius: 3px; }/* ── Header related-surface links ──────────────────────────────────── */+ /* Every rule here is scoped through #header on purpose: `#header a` above+ sets the brand link's size, weight and colour, and an unscoped+ `.header-links a` loses to it on specificity. Unscoped, these three+ related-surface links rendered at the brand's 1.05rem in full white,+ which is what pushed the nav off the right edge of a 320px screen. */.header-links { display: flex; gap: 4px; align-items: center; margin-left: 8px; }- .header-links a {- font-family: var(--mono); font-size: 0.68rem; letter-spacing: 0.02em;+ #header .header-links a {+ font-family: var(--mono); font-size: 0.68rem; font-weight: 500; letter-spacing: 0.02em;color: var(--muted); text-decoration: none; padding: 4px 10px; border-radius: 20px;border: 1px solid transparent; white-space: nowrap;transition: color var(--duration-fast) var(--ease-standard), border-color var(--duration-fast) var(--ease-standard), background var(--duration-fast) var(--ease-standard), transform var(--duration-instant) var(--ease-standard);}- .header-links a:hover { color: var(--text); border-color: rgba(8,189,186,0.4); background: rgba(8,189,186,0.08); }- .header-links a:active { transform: scale(0.96); }- .header-links a:focus-visible { outline: 2px solid var(--teal); outline-offset: 2px; }+ #header .header-links a:hover { color: var(--text); border-color: rgba(8,189,186,0.4); background: rgba(8,189,186,0.08); }+ #header .header-links a:active { transform: scale(0.96); }+ #header .header-links a:focus-visible { outline: 2px solid var(--teal); outline-offset: 2px; }/* The runtime language switcher (/i18n.js mounts it when the deploy shipsmore than one locale) is a ~165px control pinned to the bottom-rightcorner. Below roughly 780px it lands on top of the run button, and at@@ -302,7 +307,7 @@}@media (max-width: 560px) {.header-links { gap: 2px; margin-left: 4px; }- .header-links a { padding: 4px 7px; font-size: 0.6rem; }+ #header .header-links a { padding: 4px 7px; font-size: 0.6rem; }#header { padding: 12px 14px; gap: 8px; }/* Stack the controls: side by side they cannot both stay legible at 320px. */#cta { flex-direction: column; gap: 8px; }diff --git a/pages/agents-live.html b/pages/agents-live.htmlindex 1854b1f4a..241d90ea0 100644--- a/pages/agents-live.html+++ b/pages/agents-live.html@@ -7,7 +7,7 @@<meta charset="utf-8" /><meta name="viewport" content="width=device-width,initial-scale=1" /><title data-i18n="agents_live.meta_title">Live Agents · three.ws</title>- <meta name="description" content="Watch AI agents work in real time — see their screens, actions, and avatar feeds as they autonomously trade, browse, and operate." data-i18n-attr="content:agents_live.meta_description"/>+ <meta name="description" content="Mission control for three.ws: a real-time grid of every AI agent, streaming its screen, avatar feed and live on-chain activity as it trades, browses and operates." data-i18n-attr="content:agents_live.meta_description"/><meta property="og:type" content="website" /><meta property="og:url" content="https://three.ws/agents-live" /><meta property="og:title" content="Live Agents · three.ws" data-i18n-attr="content:agents_live.meta_og_title"/>@@ -1004,7 +1004,7 @@<meta property="og:locale" content="en_US"><meta property="og:image:alt" content="Live Agents — three.ws"><meta name="twitter:title" content="Live Agents · three.ws" data-i18n-attr="content:agents_live.meta_twitter_title">- <meta name="twitter:description" content="Mission control — real-time grid of all AI agents with active screen streams. Watch their screens and avatar feeds live." data-i18n-attr="content:agents_live.meta_twitter_description">+ <meta name="twitter:description" content="Mission control: a real-time grid of all AI agents with active screen streams. Watch their screens and avatar feeds live." data-i18n-attr="content:agents_live.meta_twitter_description"><script type="application/ld+json">{"@context":"https://schema.org","@graph":[{"@type":"WebPage","name":"Live Agents","description":"Mission control - real-time grid of all AI agents with active screen streams. Watch their screens and avatar feeds live.","url":"https://three.ws/agents-live","isPartOf":{"@type":"WebSite","name":"three.ws","url":"https://three.ws"},"primaryImageOfPage":"https://three.ws/api/page-og?s=build&t=Live+Agents&d=Mission+control+-+real-time+grid+of+all+AI+agents+with+active+screen+streams.+Watch+their+screens+and+avatar+feeds+live.&p=%2Fagents-live"}]}</script></head><body>@@ -1046,7 +1046,7 @@Mission control</div><h1 data-i18n="agents_live.watch_agents_work">Watch agents work</h1>- <p data-i18n="agents_live.every_agent_on_three_ws_live_each">Every agent on three.ws, live. Each card streams the agent's real activity as it happens — and a real browser feed whenever one is actively being watched. Open any agent, any time.</p>+ <p data-i18n="agents_live.every_agent_on_three_ws_live_each">Every agent on three.ws, live. Each card streams the agent's real activity as it happens, plus a real browser feed whenever one is actively being watched. Open any agent, any time.</p></div><div class="al-stats" id="al-stats" hidden>diff --git a/src/agent-reactions.js b/src/agent-reactions.jsindex 06b1d04b4..0e5d77d6b 100644--- a/src/agent-reactions.js+++ b/src/agent-reactions.js@@ -77,6 +77,14 @@ function ensureStyles() {.rx-bar.compact .rx-btn{width:28px;height:28px;font-size:14px;}.rx-bar.compact .rx-tip{height:28px;padding:0 10px;font-size:11.5px;}.rx-bar.compact .rx-count,.rx-bar.compact .rx-hint{font-size:11px;}+/* The compact bar rides inside a card, so it has to live within the card's+ width instead of running off both edges. On a 320px viewport the emoji row ++ tip + hint no longer fit on one line: wrap, and drop the hint (the count and+ the buttons carry the meaning) rather than clipping a real control. */+.rx-bar.compact{max-width:100%;min-width:0;flex-wrap:wrap;justify-content:center;row-gap:4px;}+.rx-bar.compact .rx-emojis{flex-wrap:wrap;justify-content:center;}+.rx-bar.compact .rx-hint{min-width:0;overflow:hidden;text-overflow:ellipsis;}+@media (max-width:420px){.rx-bar.compact .rx-hint{display:none;}}@keyframes rx-pulse{0%,100%{opacity:.65;}50%{opacity:1;}}@media (prefers-reduced-motion:reduce){.rx-btn,.rx-tip,.rx-count .rx-num,.rx-bar.connecting .rx-btn,.rx-bar.connecting .rx-tip{transition:none;animation:none;}}`;diff --git a/src/agents-live.js b/src/agents-live.jsindex 501348fcd..ea9d8c65c 100644--- a/src/agents-live.js+++ b/src/agents-live.js@@ -810,7 +810,10 @@ function applyWatchStatus(state, data) {if (isLiveNow(state)) { hideWarming(state); return; }if (data?.state === 'warming') showWarming(state, 'Warming up a live view…');else if (data?.state === 'queued') showWarming(state, `Live view queued · #${data.position || 1} in line`);- else hideWarming(state);+ else { hideWarming(state); return; }+ // A browser is genuinely coming up for this card, so hold a stream open to+ // catch its first frame rather than waiting on the next activity batch.+ ensureStream(state);}async function pollWatchStatus(state) {@@ -878,9 +881,13 @@ function getObserver() {}// ── pooled stream lifecycle ──────────────────────────────────────────────────-// A card gets its SSE listener when it nears the viewport and gives it back once-// it is well past, so the pool always covers what a viewer can see, and a wall-// of 2,000 agents costs the same handful of connections as a wall of 12.+// With the batch layer covering activity, a stream is only worth a connection+// when there is something to PUSH: live caster pixels, spectator reactions, a+// market-maker beat. So a card earns one when it is genuinely casting, when it+// holds the spotlight, when the caster pool says a browser is coming up for it,+// or when a viewer reaches for the card itself (hover or keyboard focus). It+// hands the connection back once it scrolls out of the band, so a wall of 2,000+// agents costs the same handful of connections as a wall of 12.// Move an id to the LRU tail (a Set re-insert after delete reorders it).function touchStream(id) {@@ -942,7 +949,6 @@ function getStreamObserver() {if (!state) continue;if (entry.isIntersecting) {_nearView.add(id);- if (!document.hidden) ensureStream(state);} else {_nearView.delete(id);if (id !== _spotAgentId) releaseStream(state);@@ -1094,9 +1100,15 @@ function mountAgent(agent) {}renderAge(state);paintActivity(state);+ // Reaching for a card is real intent: go live on it so reactions, frames and+ // market-maker beats push instead of waiting for the next batch. Bounded by+ // the pool, and released again when the card leaves the band.+ const goLive = () => { if (!document.hidden) ensureStream(state); };+ card.addEventListener('pointerenter', goLive);+ card.addEventListener('focusin', goLive);// Intent + status polling are intersection-driven (getObserver), so the caster// pool only spins up for cards actually on screen and frees the slot on- // scroll-away. The wider band (getStreamObserver) owns the SSE listener itself.+ // scroll-away. The wider band (getStreamObserver) owns stream release.getObserver().observe(card);getStreamObserver().observe(card);}diff --git a/src/walk-companion.js b/src/walk-companion.jsindex 126b8fd9b..a38ce6ec5 100644--- a/src/walk-companion.js+++ b/src/walk-companion.js@@ -33,8 +33,12 @@ const walk = createWalkCompanion({docsUrl: '/avatar-studio',// /concierge mounts its own corner widget (the live Concierge demo); two// companions fighting over the same corner reads as broken, so the walk- // mascot sits that page out.- excludedRoutes: [...DEFAULT_EXCLUDED_PREFIXES, '/concierge'],+ // mascot sits that page out. /agent-studio is the same case for the same+ // reason the SDK's own list carries /avatar-studio and /pose: its left half+ // is a persistent live stage of THIS user's agent, so the corner mascot is a+ // second copy of the same body, and its 218px corner reservation pushed the+ // stack's chips into the middle of the editing panel at 320px.+ excludedRoutes: [...DEFAULT_EXCLUDED_PREFIXES, '/concierge', '/agent-studio'],});// public/nav.js drives the companion through this global (toggle from the navdiff --git a/tests/forge-store-materialize.test.js b/tests/forge-store-materialize.test.jsindex 9318d63e6..1dfa56ffd 100644--- a/tests/forge-store-materialize.test.js+++ b/tests/forge-store-materialize.test.js@@ -59,6 +59,9 @@ vi.mock('../api/_lib/db.js', () => ({const putObjectMock = vi.fn(async ({ key }) => ({ key }));vi.mock('../api/_lib/r2.js', () => ({putObject: (...args) => putObjectMock(...args),+ // forgeStoreEnabled() reads the object-storage gate through r2.js, so this+ // mock has to carry it or every store call throws before it runs.+ objectStorageConfigured: () => true,publicUrl: (key) => `https://cdn.example.com/${key}`,}));diff --git a/vite.config.js b/vite.config.jsindex 2647d40a3..01fb1b7a4 100644--- a/vite.config.js+++ b/vite.config.js@@ -89,10 +89,19 @@ function discoverDashboardNextInputs() {// the raw host:port and both attempts fail ("[vite] failed to connect to// websocket"), killing live-reload. Point the HMR client at the forwarded// domain over wss/443 when those env vars are present; no-op locally.+// The forwarded host carries the dev server's OWN port, so read it back off the+// command line: concurrent agents routinely run `vite --port 3101`, and a+// hard-coded 3000 pointed their HMR client at a different (or absent) tunnel,+// which surfaces as a console error on every page rather than as a config bug.+const DEV_PORT = (() => {+ const i = process.argv.indexOf('--port');+ const n = i >= 0 ? Number(process.argv[i + 1]) : Number(process.env.PORT);+ return Number.isFinite(n) && n > 0 ? n : 3000;+})();const CODESPACE_HMR =process.env.CODESPACE_NAME && process.env.GITHUB_CODESPACES_PORT_FORWARDING_DOMAIN? {- host: `${process.env.CODESPACE_NAME}-3000.${process.env.GITHUB_CODESPACES_PORT_FORWARDING_DOMAIN}`,+ host: `${process.env.CODESPACE_NAME}-${DEV_PORT}.${process.env.GITHUB_CODESPACES_PORT_FORWARDING_DOMAIN}`,protocol: 'wss',clientPort: 443,}