Skip to content

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.

feat: enhance agent screen push with on-demand live browser casting and improved authentication

zprva03057e04d71
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 9f46919e1..1f8783fa3 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -19,6 +19,7 @@ Public history for [three.ws](https://three.ws), newest first. New pages come fr
- **Back-an-Agent Vaults got a sharper, more visual redesign** — The vaults page (/vaults) now opens with a live at-a-glance strip — open vaults, total capital backed, backers, and the best return across the board — counting up the moment data lands. Each vault card leads with its return front-and-center, carries a performance-tinted accent and a status ring on the agent's avatar, ranks the top performers with a medal, and shows a relative capital-backed bar so you can size up a vault at a glance. You can now sort the feed by best return, most capital, most backers, or top reputation. Open a vault and you get a NAV hero with a real share-price sparkline drawn straight from the audit ledger, a drawdown gauge showing how much of the circuit-breaker buffer is left, and a capital-distribution bar of who's backing it. Same real on-chain data — just far easier to read. (`/vaults`) `[improvement]`
- **Building a strategy is now a real page, not a cramped pop-up** — Creating or editing a Strategy Object on the Strategies page (/strategies) opened a small modal that squeezed a long, multi-section form — entry rules, sizing, take-profit, stop-loss, risk — into a scrolling box. It now opens as a full builder page with room to work: the rules on the left and a sticky "Your strategy" panel on the right that shows a plain-language summary of your plan as you type, the safety guarantees, and the Create button always in reach. The builder is shareable and reload-safe (it lives at /strategies?editor=new) and the browser back button returns you to the library. Editing a strategy in-context from an agent's profile still uses the quick inline editor. (`/strategies`) `[improvement]`
- **Changelog Telegram bot health check** — The autonomous x402 loop now pings the changelog Telegram bot every 5 minutes by paying $0.001 USDC to the new /api/x402/telegram-health endpoint. It verifies the bot can reach the Telegram API, measures round-trip latency, and raises a Redis alert when it can't — so ops knows immediately when $THREE holders would miss a changelog entry. `[infra, feature]`
+- **Cinematic FX — one-tap film looks for any 3D avatar** — The 3D viewer now ships a full cinematic post-processing pipeline behind a new Cinematic FX panel. Pick a look — Studio, Cinematic, Portrait, Vivid, Neon, or Noir — and the avatar instantly gains the matching grade: soft ambient-occlusion contact shadows, depth-of-field focus falloff, bloom, colour grade (saturation, contrast, brightness, hue), chromatic aberration, and animated film grain. Every effect is also exposed as a live slider so you can dial in your own look, and your chosen preset is remembered per agent. The default Studio look is unchanged, so existing gallery thumbnails and embeds render exactly as before unless you opt into a richer style. `[feature, improvement]`
- **Club Social Activity — the platform tracks its own nightlife economy on-chain** — The autonomous loop now pays /api/x402/analytics every 30 minutes with { report: "clubs", period: "24h" } for a live snapshot of the Pole Club's social economy. The report reads straight from the real ledgers — settled tips (club_tips), the stage roster (club_dancer_wallets) and settled door cover charges (x402_audit_log) — and returns how many stages are active, how many distinct patrons showed up, the tip count and USDC volume, the cover charges collected at the door, and a fastest-growing-stage leaderboard. Every snapshot is appended to a club_social_analytics time series so a dashboard can chart whether the nightlife is heating up or cooling down and spot which stages are on the rise. `[feature, infra]`
- **Create an agent by describing it — the wizard now builds itself** — Spinning up an agent no longer means filling out five steps of fields. At the top of the Create flow there's now a single box: describe your agent in a sentence — "a witty crypto market analyst that explains charts in plain English" — and we generate the whole thing for you: name, description, tags, the right skills, a fitting 3D body, a marketplace category, a greeting, and its personality. No idea where to start? Tap an example or hit "Surprise me" and get a complete agent with zero typing. Everything lands on the Review step pre-filled, so you read it over, tweak anything you like, and ship. The by-hand form is still right there for anyone who wants it. (`/create-agent`) `[feature]`
- **Five pages that were returning 404 are reachable again** — The Gaussian-splat viewer (/splat), the capture tool (/capture), the integrations directory (/integrations), partners (/partners), and the live-agents board (/agents-live) were all returning a 404 in production even though the pages existed and were linked from the nav. Our routing pins every clean URL explicitly, and these five were missing their entry, so the request fell through to the not-found page. We added the missing routes and tightened the route audit so a new page can no longer ship without one. (`/splat`) `[fix]`
@@ -40,6 +41,7 @@ Public history for [three.ws](https://three.ws), newest first. New pages come fr
- **The "Save to my avatars" button is readable on every theme** — On pages with a white accent color, the "⑂ Save to my avatars" button (shown on any avatar you don't own) rendered white text on a white background — effectively invisible. The button now picks its text color from the actual button background, so a light button gets black text and a dark button keeps white, keeping the label legible everywhere it appears. `[fix]`
- **The Avatar Engines Atlas page is now reachable** — The link to the Avatar Engines Atlas — the curated rundown of the open-source and commercial engines behind high-quality, photoreal 3D human avatars — was returning a 404 because the page was never wired into routing. The route is now in place, so the page opens from navigation as intended. (`/avatar-engines`) `[fix]`
- **The Coin Intelligence feed now fills itself** — The Coin Intelligence engine (/coin-intel) watches pump.fun's live launch firehose, observes each new coin's first ~90 seconds of trading, and scores it — organic vs bundle, wallet concentration, smart-money entries, category. Until now that observation only ran when a separate always-on worker was up, so the page often sat on its "engine is warming up" screen with nothing to show. The observer now also runs on a schedule on our serverless platform, so it keeps watching launches and recording verdicts on its own — newest coins appear in the feed continuously without depending on any single machine staying online. (`/coin-intel`) `[fix, feature]`
+- **The Live Agents wall now shows every agent, 24/7** — The Live Agents page (/agents-live) used to show only the handful of agents that happened to have a browser actively streaming — usually none, so the page sat empty. Now it shows every agent on the platform, each with a live screen, and a screen is never blank: when no live browser is attached, the card streams the agent's real activity as a live terminal straight from its on-chain and skill history. Scroll to load more, and watch the live/total counts update in real time. Open any agent any time — and when you're actually watching one, an on-demand caster spins a real browser feed up for it (and tears it down when you leave), so live pixels are available for any agent without anything running idle. The same activity feed now also powers the screens on the agent desks in the 3D world. (`/agents-live`) `[feature, improvement]`
- **The main menu is now organized — no more walls of links** — The top navigation kept everything but had become hard to scan: the Launch menu alone listed 25 features in one long single-column drop-down, and nearly every item shouted a "New" badge, so the badge meant nothing. Each menu — Build, Discover, Launch, Learn — is now split into clearly labelled columns grouped by what you're trying to do (Launch, for example, splits into Launch / Terminal & trade / Intelligence / Compete & earn). Every feature is still one click away, on desktop and in the mobile drawer; nothing was removed or moved off-platform. The only badge left is the green "Live" dot, which now genuinely means the page is running right now. `[improvement]`
- **The Money Pulse now sits on a pure-black canvas** — The Money Pulse page (/pulse) now renders on a true black background in every theme, so the live feed of tips, launches, trades and agent-to-agent payments reads as one calm, high-contrast field. Previously the page could pick up a lighter surface or near-black tone depending on your theme; it's now consistently black with the monochrome ink ramp pinned for readability. (`/pulse`) `[improvement]`
- **The shared 3D world stays in sync through server updates** — After we shipped an update to the multiplayer world, players who hadn't reloaded the page could land in a broken session — other people stopped appearing, movement froze, and the browser console filled with decode errors — until a hard refresh. The cause: the page read the world using its own bundled copy of the world's data layout, which fell out of step with the freshly updated server. The client now reads the layout the server itself describes when you join, so it always matches the live server. Joining the walk world and coin community worlds survives a server update without a forced refresh. `[fix]`
diff --git a/api/agent/screen-push.js b/api/agent/screen-push.js
index 0e0e8da64..6d4316b11 100644
--- a/api/agent/screen-push.js
+++ b/api/agent/screen-push.js
@@ -15,12 +15,23 @@
// agent's own bearer token (AGENT_BEARER environment variable on the worker).
// Rate: 12 frame pushes/second per agentId (burst) to prevent flooding.
+import { timingSafeEqual } from 'node:crypto';
import { cors, json, method, readJson, wrap, error, rateLimited } from '../_lib/http.js';
import { cacheSet } from '../_lib/cache.js';
import { getSessionUser, authenticateBearer, extractBearer } from '../_lib/auth.js';
import { sql } from '../_lib/db.js';
import { limits, clientIp } from '../_lib/rate-limit.js';
+// First-party on-demand caster pool authenticates with a shared secret and may
+// push frames for ANY agent (it casts whichever agents viewers are watching).
+const WORKER_SECRET = process.env.SCREEN_WORKER_SECRET || '';
+function isPoolWorker(bearer) {
+ if (!bearer || !WORKER_SECRET || WORKER_SECRET.length < 16) return false;
+ const a = Buffer.from(bearer);
+ const b = Buffer.from(WORKER_SECRET);
+ return a.length === b.length && timingSafeEqual(a, b);
+}
+
const FRAME_TTL_S = 10;
const ACTIVITY_TTL_S = 30;
@@ -31,19 +42,25 @@ export default wrap(async (req, res) => {
if (cors(req, res, { methods: 'POST,OPTIONS', credentials: true })) return;
if (!method(req, res, ['POST'])) return;
- // Auth: the agent's own bearer (worker) OR the owner's session. Bearer first
- // so headless workers authenticate without a cookie.
+ // Auth: first-party pool worker (shared secret, any agent), the agent's own
+ // bearer (worker), OR the owner's session. Bearer first so headless workers
+ // authenticate without a cookie.
let userId = null;
+ let isWorker = false;
const bearer = extractBearer(req);
- if (bearer) {
- const a = await authenticateBearer(bearer).catch(() => null);
- if (a?.userId) userId = a.userId;
- }
- if (!userId) {
- const a = await getSessionUser(req, res).catch(() => null);
- if (a?.id) userId = a.id;
+ if (isPoolWorker(bearer)) {
+ isWorker = true;
+ } else {
+ if (bearer) {
+ const a = await authenticateBearer(bearer).catch(() => null);
+ if (a?.userId) userId = a.userId;
+ }
+ if (!userId) {
+ const a = await getSessionUser(req, res).catch(() => null);
+ if (a?.id) userId = a.id;
+ }
+ if (!userId) return error(res, 401, 'unauthorized', 'sign in required');
}
- if (!userId) return error(res, 401, 'unauthorized', 'sign in required');
// Rate limit before reading the body so a flood can't force large buffers.
const rl = await limits.apiIp(clientIp(req), { limit: 720, window: '60s' });
@@ -55,12 +72,11 @@ export default wrap(async (req, res) => {
if (!agentId) return error(res, 400, 'validation_error', 'agentId required');
- // Verify ownership.
- const [row] = await sql`
- SELECT id FROM agent_identities
- WHERE id = ${agentId} AND user_id = ${userId} AND deleted_at IS NULL
- `;
- if (!row) return error(res, 403, 'forbidden', 'not your agent');
+ // Ownership: the pool worker may cast any existing agent; owners only their own.
+ const [row] = isWorker
+ ? await sql`SELECT id FROM agent_identities WHERE id = ${agentId} AND deleted_at IS NULL`
+ : await sql`SELECT id FROM agent_identities WHERE id = ${agentId} AND user_id = ${userId} AND deleted_at IS NULL`;
+ if (!row) return error(res, isWorker ? 404 : 403, isWorker ? 'not_found' : 'forbidden', isWorker ? 'agent not found' : 'not your agent');
const now = Date.now();
diff --git a/data/changelog.json b/data/changelog.json
index fd5705ed0..68b4b261b 100644
--- a/data/changelog.json
+++ b/data/changelog.json
@@ -1,6 +1,25 @@
{
"$comment": "Curated changelog entries for three.ws — the editorial layer of the public changelog. New PAGE launches are tracked automatically via the `added` field in data/pages.json; this file is for everything else holders care about: improvements, fixes, SDK releases, trading/payments capabilities, security work. scripts/build-page-index.mjs merges both sources into CHANGELOG.md, public/changelog.json, and public/changelog.xml. Newest first. Allowed tags: feature, improvement, fix, sdk, infra, docs, security. `link` is optional and must be a live three.ws path.",
"entries": [
+ {
+ "date": "2026-06-28",
+ "title": "The Live Agents wall now shows every agent, 24/7",
+ "summary": "The Live Agents page (/agents-live) used to show only the handful of agents that happened to have a browser actively streaming — usually none, so the page sat empty. Now it shows every agent on the platform, each with a live screen, and a screen is never blank: when no live browser is attached, the card streams the agent's real activity as a live terminal straight from its on-chain and skill history. Scroll to load more, and watch the live/total counts update in real time. Open any agent any time — and when you're actually watching one, an on-demand caster spins a real browser feed up for it (and tears it down when you leave), so live pixels are available for any agent without anything running idle. The same activity feed now also powers the screens on the agent desks in the 3D world.",
+ "tags": [
+ "feature",
+ "improvement"
+ ],
+ "link": "/agents-live"
+ },
+ {
+ "date": "2026-06-28",
+ "title": "Cinematic FX — one-tap film looks for any 3D avatar",
+ "summary": "The 3D viewer now ships a full cinematic post-processing pipeline behind a new Cinematic FX panel. Pick a look — Studio, Cinematic, Portrait, Vivid, Neon, or Noir — and the avatar instantly gains the matching grade: soft ambient-occlusion contact shadows, depth-of-field focus falloff, bloom, colour grade (saturation, contrast, brightness, hue), chromatic aberration, and animated film grain. Every effect is also exposed as a live slider so you can dial in your own look, and your chosen preset is remembered per agent. The default Studio look is unchanged, so existing gallery thumbnails and embeds render exactly as before unless you opt into a richer style.",
+ "tags": [
+ "feature",
+ "improvement"
+ ]
+ },
{
"date": "2026-06-28",
"title": "Back-an-Agent Vaults got a sharper, more visual redesign",
diff --git a/public/changelog.json b/public/changelog.json
index c6f3992b6..02599c92c 100644
--- a/public/changelog.json
+++ b/public/changelog.json
@@ -1,5 +1,5 @@
{
- "generated_at": "2026-06-28T10:53:01.477Z",
+ "generated_at": "2026-06-28T11:05:56.657Z",
"generated_by": "scripts/build-page-index.mjs from data/pages.json + data/changelog.json",
"site": {
"name": "three.ws",
@@ -141,6 +141,17 @@
"feature"
]
},
+ {
+ "date": "2026-06-28",
+ "type": "update",
+ "title": "Cinematic FX — one-tap film looks for any 3D avatar",
+ "summary": "The 3D viewer now ships a full cinematic post-processing pipeline behind a new Cinematic FX panel. Pick a look — Studio, Cinematic, Portrait, Vivid, Neon, or Noir — and the avatar instantly gains the matching grade: soft ambient-occlusion contact shadows, depth-of-field focus falloff, bloom, colour grade (saturation, contrast, brightness, hue), chromatic aberration, and animated film grain. Every effect is also exposed as a live slider so you can dial in your own look, and your chosen preset is remembered per agent. The default Studio look is unchanged, so existing gallery thumbnails and embeds render exactly as before unless you opt into a richer style.",
+ "link": null,
+ "tags": [
+ "feature",
+ "improvement"
+ ]
+ },
{
"date": "2026-06-28",
"type": "update",
@@ -363,6 +374,17 @@
"feature"
]
},
+ {
+ "date": "2026-06-28",
+ "type": "update",
+ "title": "The Live Agents wall now shows every agent, 24/7",
+ "summary": "The Live Agents page (/agents-live) used to show only the handful of agents that happened to have a browser actively streaming — usually none, so the page sat empty. Now it shows every agent on the platform, each with a live screen, and a screen is never blank: when no live browser is attached, the card streams the agent's real activity as a live terminal straight from its on-chain and skill history. Scroll to load more, and watch the live/total counts update in real time. Open any agent any time — and when you're actually watching one, an on-demand caster spins a real browser feed up for it (and tears it down when you leave), so live pixels are available for any agent without anything running idle. The same activity feed now also powers the screens on the agent desks in the 3D world.",
+ "link": "/agents-live",
+ "tags": [
+ "feature",
+ "improvement"
+ ]
+ },
{
"date": "2026-06-28",
"type": "update",
diff --git a/public/changelog.xml b/public/changelog.xml
index d2a368ef2..6ef0feb66 100644
--- a/public/changelog.xml
+++ b/public/changelog.xml
@@ -110,6 +110,14 @@
<category>infra</category>
<description>The autonomous x402 loop now pings the changelog Telegram bot every 5 minutes by paying $0.001 USDC to the new /api/x402/telegram-health endpoint. It verifies the bot can reach the Telegram API, measures round-trip latency, and raises a Redis alert when it can't — so ops knows immediately when $THREE holders would miss a changelog entry.</description>
</item>
+ <item>
+ <title>Cinematic FX — one-tap film looks for any 3D avatar</title>
+ <link>https://three.ws/changelog</link>
+ <guid isPermaLink="false">2026-06-28:Cinematic FX — one-tap film looks for any 3D avatar</guid>
+ <pubDate>Sun, 28 Jun 2026 12:00:00 GMT</pubDate>
+ <category>feature</category>
+ <description>The 3D viewer now ships a full cinematic post-processing pipeline behind a new Cinematic FX panel. Pick a look — Studio, Cinematic, Portrait, Vivid, Neon, or Noir — and the avatar instantly gains the matching grade: soft ambient-occlusion contact shadows, depth-of-field focus falloff, bloom, colour grade (saturation, contrast, brightness, hue), chromatic aberration, and animated film grain. Every effect is also exposed as a live slider so you can dial in your own look, and your chosen preset is remembered per agent. The default Studio look is unchanged, so existing gallery thumbnails and embeds render exactly as before unless you opt into a richer style.</description>
+ </item>
<item>
<title>Club Social Activity — the platform tracks its own nightlife economy on-chain</title>
<link>https://three.ws/changelog</link>
@@ -278,6 +286,14 @@
<category>fix</category>
<description>The Coin Intelligence engine (/coin-intel) watches pump.fun's live launch firehose, observes each new coin's first ~90 seconds of trading, and scores it — organic vs bundle, wallet concentration, smart-money entries, category. Until now that observation only ran when a separate always-on worker was up, so the page often sat on its &quot;engine is warming up&quot; screen with nothing to show. The observer now also runs on a schedule on our serverless platform, so it keeps watching launches and recording verdicts on its own — newest coins appear in the feed continuously without depending on any single machine staying online.</description>
</item>
+ <item>
+ <title>The Live Agents wall now shows every agent, 24/7</title>
+ <link>https://three.ws/agents-live</link>
+ <guid isPermaLink="false">2026-06-28:The Live Agents wall now shows every agent, 24/7</guid>
+ <pubDate>Sun, 28 Jun 2026 12:00:00 GMT</pubDate>
+ <category>feature</category>
+ <description>The Live Agents page (/agents-live) used to show only the handful of agents that happened to have a browser actively streaming — usually none, so the page sat empty. Now it shows every agent on the platform, each with a live screen, and a screen is never blank: when no live browser is attached, the card streams the agent's real activity as a live terminal straight from its on-chain and skill history. Scroll to load more, and watch the live/total counts update in real time. Open any agent any time — and when you're actually watching one, an on-demand caster spins a real browser feed up for it (and tears it down when you leave), so live pixels are available for any agent without anything running idle. The same activity feed now also powers the screens on the agent desks in the 3D world.</description>
+ </item>
<item>
<title>The main menu is now organized — no more walls of links</title>
<link>https://three.ws/changelog</link>
diff --git a/public/features.json b/public/features.json
index 303aadf56..60a38dea0 100644
--- a/public/features.json
+++ b/public/features.json
@@ -1,5 +1,5 @@
{
- "generated_at": "2026-06-28T10:53:01.457Z",
+ "generated_at": "2026-06-28T11:05:56.634Z",
"generated_by": "scripts/build-page-index.mjs from data/pages.json",
"site": {
"name": "three.ws",
diff --git a/src/agents-live.js b/src/agents-live.js
index bc98d67b4..c3f44204c 100644
--- a/src/agents-live.js
+++ b/src/agents-live.js
@@ -23,9 +23,6 @@ const statTotal = document.getElementById('al-stat-total');
// Per-agent runtime state. agentId → { es, card, entries, lastFrameAt, live }
const _cards = new Map();
const _fpsMap = new Map(); // agentId → frames since last tick
-let _totalFrames = 0;
-let _fpsInterval = null;
-let _idleRepaint = null;
// Roster pagination cursor (created_at of the last public agent loaded).
let _cursor = null;
@@ -215,7 +212,6 @@ function attachStream(state) {
img.src = src.startsWith('data:') ? src : 'data:image/png;base64,' + src;
state.lastFrameAt = Date.now();
setLive(true);
- _totalFrames++;
_fpsMap.set(agentId, (_fpsMap.get(agentId) || 0) + 1);
if (msg.activity && state.action) state.action.textContent = msg.activity;
} catch { /* malformed */ }
diff --git a/src/game/agent-desk.js b/src/game/agent-desk.js
index f764d10da..c6244e377 100644
--- a/src/game/agent-desk.js
+++ b/src/game/agent-desk.js
@@ -348,6 +348,23 @@ export function createAgentDesk(scene, agent, opts = {}) {
}
}
+ // Signal that this desk's agent is being watched so the on-demand caster pool
+ // upgrades it to a live browser feed. Throttled; fired while the player is near.
+ let lastWatchPing = 0;
+ function pingWatchIntent() {
+ const now = Date.now();
+ if (now - lastWatchPing < 20_000) return;
+ lastWatchPing = now;
+ try {
+ fetch('/api/agent/watch-intent', {
+ method: 'POST',
+ headers: { 'content-type': 'application/json' },
+ body: JSON.stringify({ agentId: agent.agentId }),
+ keepalive: true,
+ }).catch(() => {});
+ } catch { /* */ }
+ }
+
connectSSE();
fetchActivity();
@@ -376,6 +393,7 @@ export function createAgentDesk(scene, agent, opts = {}) {
// Screen emissive boost.
screenMat.opacity = near ? 1.0 : 0.92;
}
+ if (near) pingWatchIntent();
}
if (acc < REDRAW_MS / 1000) return;
diff --git a/src/shared/agent-watch-panel.js b/src/shared/agent-watch-panel.js
index 332e51e83..93e5a1274 100644
--- a/src/shared/agent-watch-panel.js
+++ b/src/shared/agent-watch-panel.js
@@ -1010,9 +1010,29 @@ class WatchPanel {
this._connectStream();
this._startCanvasLoop();
this._startActivityPoll();
+ this._startWatchIntent();
await this._bootWebcam();
}
+ // Signal that this agent is being actively watched so the on-demand caster
+ // pool (workers/agent-screen-pool) spins up a real browser feed for it. The
+ // panel works fully without the pool — this just upgrades to live pixels.
+ _startWatchIntent() {
+ const ping = () => {
+ if (this._destroyed || document.hidden) return;
+ try {
+ fetch('/api/agent/watch-intent', {
+ method: 'POST',
+ headers: { 'content-type': 'application/json' },
+ body: JSON.stringify({ agentId: this.agentId }),
+ keepalive: true,
+ }).catch(() => {});
+ } catch { /* */ }
+ };
+ ping();
+ this._watchIntentId = setInterval(ping, 20_000);
+ }
+
// ── SSE connection ────────────────────────────────────────────────────────
_connectStream() {
@@ -1267,6 +1287,7 @@ class WatchPanel {
cancelAnimationFrame(this._webcamRafId);
clearTimeout(this._frameTimeoutId);
clearInterval(this._activityPollId);
+ clearInterval(this._watchIntentId);
try { this._es?.close(); } catch { /* */ }
this._webcamMixer?.stopAllAction?.();
this._webcamRenderer?.dispose?.();
diff --git a/workers/agent-screen-pool/index.js b/workers/agent-screen-pool/index.js
index 55d0169f7..eea9c586d 100644
--- a/workers/agent-screen-pool/index.js
+++ b/workers/agent-screen-pool/index.js
@@ -31,8 +31,12 @@ import { chromium } from 'playwright';
const BASE_URL = (process.env.BASE_URL || 'https://three.ws').replace(/\/$/, '');
const WANTED_URL = process.env.WANTED_URL || `${BASE_URL}/api/agent/watch-wanted`;
-const PUSH_URL = process.env.PUSH_URL || `${BASE_URL}/api/agent-screen-push`;
-const SECRET = process.env.SCREEN_WORKER_SECRET || '';
+// Two render surfaces consume two frame conventions: the live wall + 2D watch
+// panel read the "dashed" push; the in-world 3D desk reads the "slashed" push.
+// We publish to both so a watched agent goes live everywhere at once.
+const PUSH_URL = process.env.PUSH_URL || `${BASE_URL}/api/agent-screen-push`; // wall + watch panel
+const PUSH_URL_DESK = process.env.PUSH_URL_DESK || `${BASE_URL}/api/agent/screen-push`; // 3D desk
+const SECRET = process.env.SCREEN_WORKER_SECRET || '';
const MAX_BROWSERS = Number(process.env.MAX_BROWSERS || 6);
const POLL_MS = Number(process.env.POLL_MS || 3000);
@@ -92,19 +96,30 @@ async function pushFrame(entry) {
entry.pushing = true;
try {
const buf = await entry.page.screenshot({ type: 'jpeg', quality: JPEG_QUALITY, fullPage: false });
- const data = `data:image/jpeg;base64,${buf.toString('base64')}`;
- const res = await fetch(PUSH_URL, {
- method: 'POST',
- headers: { 'content-type': 'application/json', authorization: `Bearer ${SECRET}` },
- body: JSON.stringify({
- agentId: entry.agentId,
- frame: { data, activity: `Live view · ${entry.name}`, type: 'screenshot' },
+ const b64 = buf.toString('base64');
+ const seq = ++entry.seq;
+ const headers = { 'content-type': 'application/json', authorization: `Bearer ${SECRET}` };
+ // Publish to both render surfaces. Failures are independent — the wall
+ // shouldn't go dark because the desk endpoint hiccuped, and vice versa.
+ const [wall, desk] = await Promise.allSettled([
+ fetch(PUSH_URL, {
+ method: 'POST', headers,
+ body: JSON.stringify({
+ agentId: entry.agentId,
+ frame: { data: `data:image/jpeg;base64,${b64}`, activity: `Live view · ${entry.name}`, type: 'screenshot' },
+ }),
}),
- });
- if (!res.ok && Date.now() - (entry.lastErrorAt || 0) > 30_000) {
+ fetch(PUSH_URL_DESK, {
+ method: 'POST', headers,
+ body: JSON.stringify({ agentId: entry.agentId, frame: b64, seq }),
+ }),
+ ]);
+ const wallBad = wall.status === 'fulfilled' && !wall.value.ok;
+ if (wallBad && Date.now() - (entry.lastErrorAt || 0) > 30_000) {
entry.lastErrorAt = Date.now();
- log('push failed', entry.agentId, res.status, (await res.text().catch(() => '')).slice(0, 120));
+ log('wall push failed', entry.agentId, wall.value.status, (await wall.value.text().catch(() => '')).slice(0, 120));
}
+ void desk;
} catch (err) {
if (Date.now() - (entry.lastErrorAt || 0) > 30_000) {
entry.lastErrorAt = Date.now();
@@ -119,7 +134,7 @@ async function startCasting(agent) {
await ensureBrowser();
const agentId = agent.agentId;
const page = await context.newPage();
- const entry = { agentId, page, name: agent.name || 'Agent', timer: null, pushing: false, lastErrorAt: 0 };
+ const entry = { agentId, page, name: agent.name || 'Agent', timer: null, pushing: false, lastErrorAt: 0, seq: 0 };
pool.set(agentId, entry);
const url = resolveUrl(agent.homeUrl, agentId);
try {