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: talk mode, ARKit-52 morphs, news permalinks, persona SSO, avatar optimizer

nirholas3a6551925889
diff --git a/.gitignore b/.gitignore
index 37f1a83e0..c5a0fb3e0 100644
--- a/.gitignore
+++ b/.gitignore
@@ -34,6 +34,10 @@ public/chat/assets/
public/chat/index.html
public/chat/index.html.gz
+# Generated news permalink pages (rebuilt from data/rss/items.json by scripts/build-news.mjs)
+public/news/
+data/_generated/
+
# Animation build cache
public/animations/clips/.input-hashes.json
Handshake
diff --git a/api/_lib/rss-feed.js b/api/_lib/rss-feed.js
index cd75b868a..29c856c88 100644
--- a/api/_lib/rss-feed.js
+++ b/api/_lib/rss-feed.js
@@ -13,12 +13,41 @@ const CURATED_FILE = path.join(DATA_ROOT, 'rss', 'items.json');
const MIN_LENGTH = 140;
const MAX_ITEMS = 50;
+export const SITE_ORIGIN = 'https://three.ws';
+export const NEWS_PATH_PREFIX = '/news';
+
+// Derive a URL-safe slug from a curated item. Honors an explicit `slug` if
+// the editor set one; otherwise falls back to the id (with a leading `t-`
+// from tweet-derived seeds stripped). Output is lowercase, only [a-z0-9-].
+export function deriveSlug(item) {
+ const explicit = typeof item?.slug === 'string' ? item.slug : '';
+ const raw = explicit || String(item?.id || '').replace(/^t-/, '');
+ return raw
+ .toLowerCase()
+ .normalize('NFKD')
+ .replace(/[̀-ͯ]/g, '')
+ .replace(/[^a-z0-9]+/g, '-')
+ .replace(/^-+|-+$/g, '')
+ .slice(0, 80) || 'item';
+}
+
+// Treat any non-three.ws URL as the external/original source link.
+function isExternalLink(url) {
+ if (typeof url !== 'string' || !url) return false;
+ try {
+ const u = new URL(url);
+ return u.hostname !== 'three.ws' && u.hostname !== 'www.three.ws';
+ } catch {
+ return false;
+ }
+}
+
const ACCOUNTS = {
trythreews: { handle: '@trythreews', display: 'three.ws', url: 'https://x.com/trythreews' },
nichxbt: { handle: '@nichxbt', display: 'Nicholas (three.ws)', url: 'https://x.com/nichxbt' },
};
-export async function loadCuratedItems() {
+export async function loadCuratedItems({ includeDrafts = false } = {}) {
const raw = await readFile(CURATED_FILE, 'utf8');
const data = JSON.parse(raw);
const entries = Array.isArray(data?.items) ? data.items : [];
@@ -26,17 +55,31 @@ export async function loadCuratedItems() {
for (const e of entries) {
if (!e || typeof e !== 'object') continue;
if (!e.id || !e.title || !e.date || !e.body_html) continue;
+ if (!includeDrafts && e.published === false) continue;
const ts = new Date(e.date);
if (Number.isNaN(ts.getTime())) continue;
+ const slug = deriveSlug(e);
+ const rawLink = typeof e.link === 'string' && e.link ? e.link : '';
+ const explicitExternal = typeof e.external_link === 'string' && e.external_link ? e.external_link : '';
+ const externalLink = explicitExternal || (isExternalLink(rawLink) ? rawLink : '');
items.push({
id: String(e.id),
+ slug,
+ permalink: `${SITE_ORIGIN}${NEWS_PATH_PREFIX}/${slug}`,
+ externalLink,
title: String(e.title),
- link: typeof e.link === 'string' && e.link ? e.link : 'https://three.ws',
author: typeof e.author === 'string' && e.author ? e.author : 'three.ws',
summary: typeof e.summary === 'string' ? e.summary : deriveSummary(e.body_html),
bodyHtml: String(e.body_html),
+ image: typeof e.image === 'string' && e.image ? e.image : '',
+ imageAlt: typeof e.image_alt === 'string' && e.image_alt ? e.image_alt : '',
+ imageWidth: Number.isFinite(e.image_width) ? Math.trunc(e.image_width) : 0,
+ imageHeight: Number.isFinite(e.image_height) ? Math.trunc(e.image_height) : 0,
+ ogTitle: typeof e.og_title === 'string' && e.og_title ? e.og_title : '',
+ ogDescription: typeof e.og_description === 'string' && e.og_description ? e.og_description : '',
tags: Array.isArray(e.tags) ? e.tags.filter((t) => typeof t === 'string') : [],
timestamp: ts,
+ published: e.published !== false,
});
}
items.sort((a, b) => b.timestamp - a.timestamp);
@@ -48,6 +91,22 @@ function deriveSummary(html) {
return text.length > 280 ? text.slice(0, 277) + '…' : text;
}
+function absoluteUrl(url) {
+ if (typeof url !== 'string' || !url) return '';
+ if (/^https?:\/\//i.test(url)) return url;
+ return `${SITE_ORIGIN}${url.startsWith('/') ? '' : '/'}${url}`;
+}
+
+function guessMime(url) {
+ const ext = (url.split('?')[0].split('.').pop() || '').toLowerCase();
+ if (ext === 'jpg' || ext === 'jpeg') return 'image/jpeg';
+ if (ext === 'png') return 'image/png';
+ if (ext === 'webp') return 'image/webp';
+ if (ext === 'gif') return 'image/gif';
+ if (ext === 'svg') return 'image/svg+xml';
+ return 'application/octet-stream';
+}
+
export async function loadAnnouncementItems({ source = 'all' } = {}) {
const files = (await readdir(ARCHIVES_DIR)).filter((f) => f.endsWith('.json') && f.includes('tweets'));
const items = [];
@@ -179,7 +238,8 @@ export function buildRssXml({ items, selfUrl, source = 'curated' }) {
<rss version="2.0"
\txmlns:content="http://purl.org/rss/1.0/modules/content/"
\txmlns:dc="http://purl.org/dc/elements/1.1/"
-\txmlns:atom="http://www.w3.org/2005/Atom">
+\txmlns:atom="http://www.w3.org/2005/Atom"
+\txmlns:media="http://search.yahoo.com/mrss/">
\t<channel>
\t\t<title>${escapeXml(channelTitle)}</title>
\t\t<link>https://three.ws</link>
@@ -199,14 +259,33 @@ function renderItemXml(item) {
const tagsXml = (item.tags || [])
.map((t) => `\n\t\t\t<category>${escapeXml(t)}</category>`)
.join('');
+ const sourceXml = item.externalLink
+ ? `\n\t\t\t<source url="${escapeAttr(item.externalLink)}">original post</source>`
+ : '';
+ let enclosureXml = '';
+ let mediaXml = '';
+ if (item.image) {
+ const imgUrl = absoluteUrl(item.image);
+ const mime = guessMime(item.image);
+ enclosureXml = `\n\t\t\t<enclosure url="${escapeAttr(imgUrl)}" type="${escapeAttr(mime)}" length="0"/>`;
+ const dimAttrs = item.imageWidth && item.imageHeight
+ ? ` width="${item.imageWidth}" height="${item.imageHeight}"`
+ : '';
+ const mediaTitle = item.imageAlt ? `\n\t\t\t\t<media:title type="plain">${escapeXml(item.imageAlt)}</media:title>` : '';
+ mediaXml = `\n\t\t\t<media:content url="${escapeAttr(imgUrl)}" type="${escapeAttr(mime)}" medium="image"${dimAttrs}>${mediaTitle}
+\t\t\t</media:content>`;
+ }
+ const bodyWithAttribution = item.externalLink
+ ? `${item.bodyHtml}\n<p><em>Originally shared on <a href="${escapeAttr(item.externalLink)}" rel="noopener">X</a> — follow more updates at <a href="https://three.ws" rel="noopener">three.ws</a>.</em></p>`
+ : item.bodyHtml;
return `\t\t<item>
\t\t\t<title>${escapeXml(item.title)}</title>
-\t\t\t<link>${escapeXml(item.link)}</link>
-\t\t\t<guid isPermaLink="false">three-ws:${escapeXml(item.id)}</guid>
+\t\t\t<link>${escapeXml(item.permalink)}</link>
+\t\t\t<guid isPermaLink="true">${escapeXml(item.permalink)}</guid>
\t\t\t<pubDate>${rfc822(item.timestamp)}</pubDate>
-\t\t\t<dc:creator>${escapeXml(item.author)}</dc:creator>${tagsXml}
+\t\t\t<dc:creator>${escapeXml(item.author)}</dc:creator>${tagsXml}${sourceXml}${enclosureXml}${mediaXml}
\t\t\t<description>${escapeXml(item.summary)}</description>
-\t\t\t<content:encoded><![CDATA[${item.bodyHtml}]]></content:encoded>
+\t\t\t<content:encoded><![CDATA[${bodyWithAttribution}]]></content:encoded>
\t\t</item>`;
}
const account = ACCOUNTS[item.account] || { handle: '@' + item.account };
diff --git a/api/assets/index.js b/api/assets/index.js
new file mode 100644
index 000000000..ef35167ee
--- /dev/null
+++ b/api/assets/index.js
@@ -0,0 +1,135 @@
+// GET /api/assets — public asset library catalog.
+//
+// Returns a unified, filterable catalog of three.ws-hosted accessories,
+// animations, and environments — the on-disk truth (public/accessories/,
+// public/animations/, src/environments.js) exposed as a stable REST shape.
+//
+// Query params:
+// ?type=accessory|animation|environment filter by top-level kind
+// ?kind=hat|glasses|earrings|outfit filter accessories by subkind
+// ?loop=true|false filter animations by loopability
+// ?limit=<n> cap result count (default 200)
+//
+// Response:
+// { ok: true, total: <int>, items: [ { id, type, kind?, name, ...} ] }
+//
+// Cached at the edge for 1h; on-disk manifests are part of the deploy so the
+// catalog is immutable per build.
+
+import { readFile } from 'node:fs/promises';
+import path from 'node:path';
+import { cors, error, wrap } from '../_lib/http.js';
+
+// In-process caches: the on-disk manifests don't change between requests
+// on the same serverless instance.
+let accessoriesCache = null;
+let animationsCache = null;
+
+async function loadAccessories() {
+ if (accessoriesCache) return accessoriesCache;
+ const raw = await readFile(
+ path.resolve(process.cwd(), 'public/accessories/presets.json'),
+ 'utf-8',
+ );
+ const items = JSON.parse(raw);
+ accessoriesCache = items.map((a) => ({
+ id: a.id,
+ type: 'accessory',
+ kind: a.kind,
+ name: a.name,
+ thumbnail: a.thumbnail || null,
+ glb_url: a.glbUrl || null,
+ attach_bone: a.attachBone || null,
+ morph_binding: a.morphBinding || null,
+ }));
+ return accessoriesCache;
+}
+
+async function loadAnimations() {
+ if (animationsCache) return animationsCache;
+ const raw = await readFile(
+ path.resolve(process.cwd(), 'public/animations/manifest.json'),
+ 'utf-8',
+ );
+ const items = JSON.parse(raw);
+ animationsCache = items.map((a) => ({
+ id: a.name,
+ type: 'animation',
+ name: a.label || a.name,
+ clip_url: a.url,
+ icon: a.icon || null,
+ loop: a.loop === true,
+ }));
+ return animationsCache;
+}
+
+// Environments are sourced from a JS module so we duplicate the data here
+// to avoid bundling client modules into a server handler.
+const ENVIRONMENTS = [
+ { id: 'none', type: 'environment', name: 'None', path: null },
+ { id: 'neutral', type: 'environment', name: 'Neutral', path: null },
+ {
+ id: 'venice-sunset',
+ type: 'environment',
+ name: 'Venice Sunset',
+ path: 'https://storage.googleapis.com/donmccurdy-static/venice_sunset_1k.exr',
+ format: '.exr',
+ },
+ {
+ id: 'footprint-court',
+ type: 'environment',
+ name: 'Footprint Court',
+ path: 'https://storage.googleapis.com/donmccurdy-static/footprint_court_2k.exr',
+ format: '.exr',
+ },
+];
+
+export default wrap(async (req, res) => {
+ if (cors(req, res, { methods: 'GET,OPTIONS', credentials: false })) return;
+ if (req.method !== 'GET') {
+ return error(res, 405, 'method_not_allowed', `method ${req.method} not allowed`);
+ }
+
+ const url = new URL(req.url, 'http://x');
+ const type = (url.searchParams.get('type') || '').trim().toLowerCase();
+ const kind = (url.searchParams.get('kind') || '').trim().toLowerCase();
+ const loopParam = url.searchParams.get('loop');
+ const limit = Math.max(
+ 1,
+ Math.min(500, Number.parseInt(url.searchParams.get('limit') || '200', 10) || 200),
+ );
+
+ const buckets = [];
+ if (!type || type === 'accessory') {
+ try {
+ buckets.push(await loadAccessories());
+ } catch (err) {
+ return error(res, 500, 'manifest_unreadable', `accessories: ${err?.message}`);
+ }
+ }
+ if (!type || type === 'animation') {
+ try {
+ buckets.push(await loadAnimations());
+ } catch (err) {
+ return error(res, 500, 'manifest_unreadable', `animations: ${err?.message}`);
+ }
+ }
+ if (!type || type === 'environment') {
+ buckets.push(ENVIRONMENTS);
+ }
+
+ let items = buckets.flat();
+
+ if (kind) items = items.filter((i) => i.kind === kind);
+ if (loopParam === 'true') items = items.filter((i) => i.type === 'animation' && i.loop === true);
+ if (loopParam === 'false') items = items.filter((i) => i.type === 'animation' && i.loop === false);
+
+ const total = items.length;
+ items = items.slice(0, limit);
+
+ res.setHeader('content-type', 'application/json; charset=utf-8');
+ res.setHeader('cache-control', 'public, max-age=3600, s-maxage=3600, stale-while-revalidate=86400');
+ res.setHeader('access-control-allow-origin', '*');
+ res.statusCode = 200;
+ res.end(JSON.stringify({ ok: true, total, items }));
+});
diff --git a/api/auth/persona/[action].js b/api/auth/persona/[action].js
new file mode 100644
index 000000000..a7fab350f
--- /dev/null
+++ b/api/auth/persona/[action].js
@@ -0,0 +1,197 @@
+// /api/auth/persona/<action> — Persona Hub token issuance + verification.
+//
+// Persona Hub is three.ws's cross-app SSO: a user creates and stores their
+// three.ws avatar once, and any tenant site embedding the `<three-ws-signin>`
+// widget can request a short-lived token bearing that avatar's URL.
+//
+// Endpoints
+// ─────────
+// POST /api/auth/persona/issue
+// Body: { tenant_origin: string, avatar_id?: string }
+// Auth: three.ws session (user must be signed in to three.ws)
+// Returns: { token, expires_in, avatar: { id, url, thumbnail_url, name } }
+//
+// The token is a JWT signed with JWT_SECRET, audience set to the tenant
+// origin so the tenant can call /api/auth/persona/verify with that
+// audience and trust the result. Claims:
+// sub: three.ws user id
+// aud: tenant_origin
+// iss: https://three.ws
+// scope: "persona:read avatar:read"
+// token_use: "persona"
+// avatar: { id, url, thumbnail_url, name }
+//
+// GET /api/auth/persona/verify?token=…&audience=…
+// Unauthenticated. Verifies signature + issuer + audience + expiry.
+// Returns the claims if valid, 401 otherwise. Tenants call this from
+// their server to confirm the popup-issued token is real.
+//
+// GET /api/auth/persona/me
+// Auth: three.ws session.
+// Returns the user's avatar catalog so the consent UI can render a
+// picker without a second round trip.
+
+import { SignJWT, jwtVerify } from 'jose';
+import { getSessionUser } from '../../_lib/auth.js';
+import { sql } from '../../_lib/db.js';
+import { env } from '../../_lib/env.js';
+import { publicUrl } from '../../_lib/r2.js';
+import { randomToken } from '../../_lib/crypto.js';
+import { cors, json, error, method, readJson, wrap } from '../../_lib/http.js';
+
+const PERSONA_TTL_SEC = 60 * 60 * 24; // 24h
+
+let _jwtKey;
+function jwtKey() {
+ if (!_jwtKey) _jwtKey = new TextEncoder().encode(env.JWT_SECRET);
+ return _jwtKey;
+}
+
+// Tenant origin must be a valid https URL on a three.ws subdomain, or a
+// localhost dev origin. Anything else is rejected — prevents arbitrary sites
+// from minting tokens claiming the user's three.ws avatar.
+function validateTenantOrigin(origin) {
+ if (typeof origin !== 'string' || origin.length > 256) return null;
+ let u;
+ try {
+ u = new URL(origin);
+ } catch (_) {
+ return null;
+ }
+ if (u.pathname !== '/' && u.pathname !== '') return null;
+ if (u.search || u.hash) return null;
+
+ const host = u.host.toLowerCase();
+ const isHttps = u.protocol === 'https:';
+ const isLocalhost = u.protocol === 'http:' && (host === 'localhost' || host.startsWith('localhost:') || host.startsWith('127.0.0.1'));
+ const isThreeWs = host === 'three.ws' || host.endsWith('.three.ws');
+
+ if (isLocalhost) return `${u.protocol}//${host}`;
+ if (isHttps && isThreeWs) return `https://${host}`;
+ return null;
+}
+
+async function loadAvatarForUser(userId, avatarId) {
+ const rows = avatarId
+ ? await sql`select id, name, storage_key, thumbnail_key from avatars where owner_id = ${userId} and id = ${avatarId} and deleted_at is null limit 1`
+ : await sql`select id, name, storage_key, thumbnail_key from avatars where owner_id = ${userId} and deleted_at is null order by created_at desc limit 1`;
+ const row = rows[0];
+ if (!row) return null;
+ return {
+ id: row.id,
+ name: row.name,
+ url: publicUrl(row.storage_key),
+ thumbnail_url: row.thumbnail_key ? publicUrl(row.thumbnail_key) : null,
+ };
+}
+
+async function handleIssue(req, res) {
+ if (cors(req, res, { methods: 'POST,OPTIONS', credentials: true })) return;
+ if (!method(req, res, ['POST'])) return;
+
+ const user = await getSessionUser(req);
+ if (!user) return error(res, 401, 'unauthorized', 'sign in to three.ws first');
+
+ const body = await readJson(req);
+ const tenantOrigin = validateTenantOrigin(body?.tenant_origin);
+ if (!tenantOrigin) {
+ return error(res, 400, 'invalid_request', 'tenant_origin must be a https three.ws subdomain or localhost dev origin');
+ }
+
+ const avatar = await loadAvatarForUser(user.id, body?.avatar_id);
+ if (!avatar) {
+ return error(res, 404, 'no_avatar', 'user has no avatar to share — create one at /create first');
+ }
+
+ const now = Math.floor(Date.now() / 1000);
+ const token = await new SignJWT({
+ scope: 'persona:read avatar:read',
+ token_use: 'persona',
+ avatar,
+ })
+ .setProtectedHeader({ alg: 'HS256', kid: env.JWT_KID, typ: 'JWT' })
+ .setIssuer(env.ISSUER)
+ .setSubject(user.id)
+ .setAudience(tenantOrigin)
+ .setIssuedAt(now)
+ .setExpirationTime(now + PERSONA_TTL_SEC)
+ .setJti(randomToken(16))
+ .sign(jwtKey());
+
+ return json(res, 200, {
+ token,
+ expires_in: PERSONA_TTL_SEC,
+ avatar,
+ tenant_origin: tenantOrigin,
+ });
+}
+
+async function handleVerify(req, res) {
+ if (cors(req, res, { methods: 'GET,OPTIONS', credentials: false })) return;
+ if (!method(req, res, ['GET'])) return;
+
+ const url = new URL(req.url, 'http://x');
+ const token = url.searchParams.get('token');
+ const audience = url.searchParams.get('audience');
+ if (!token) return error(res, 400, 'invalid_request', 'token query param required');
+ if (!audience) return error(res, 400, 'invalid_request', 'audience query param required');
+
+ let payload;
+ try {
+ ({ payload } = await jwtVerify(token, jwtKey(), {
+ issuer: env.ISSUER,
+ audience,
+ algorithms: ['HS256'],
+ }));
+ } catch (err) {
+ return error(res, 401, 'invalid_token', err?.message || 'verification failed');
+ }
+
+ if (payload.token_use !== 'persona') {
+ return error(res, 401, 'invalid_token', 'token is not a persona token');
+ }
+
+ return json(res, 200, {
+ ok: true,
+ sub: payload.sub,
+ aud: payload.aud,
+ scope: payload.scope,
+ exp: payload.exp,
+ avatar: payload.avatar,
+ });
+}
+
+async function handleMe(req, res) {
+ if (cors(req, res, { methods: 'GET,OPTIONS', credentials: true })) return;
+ if (!method(req, res, ['GET'])) return;
+ const user = await getSessionUser(req);
+ if (!user) return error(res, 401, 'unauthorized', 'sign in to three.ws first');
+ const rows = await sql`
+ select id, name, storage_key, thumbnail_key, created_at, visibility
+ from avatars
+ where owner_id = ${user.id} and deleted_at is null
+ order by created_at desc
+ limit 50
+ `;
+ const avatars = rows.map((r) => ({
+ id: r.id,
+ name: r.name,
+ url: publicUrl(r.storage_key),
+ thumbnail_url: r.thumbnail_key ? publicUrl(r.thumbnail_key) : null,
+ created_at: r.created_at,
+ visibility: r.visibility,
+ }));
+ return json(res, 200, {
+ ok: true,
+ user: { id: user.id, email: user.email ?? null },
+ avatars,
+ });
+}
+
+export default wrap(async (req, res) => {
+ const action = req.query?.action;
+ if (action === 'issue') return handleIssue(req, res);
+ if (action === 'verify') return handleVerify(req, res);
+ if (action === 'me') return handleMe(req, res);
+ return error(res, 404, 'not_found', `unknown persona action: ${action}`);
+});
diff --git a/api/avatar/optimize.js b/api/avatar/optimize.js
new file mode 100644
index 000000000..b890c2a98
--- /dev/null
+++ b/api/avatar/optimize.js
@@ -0,0 +1,228 @@
+// GET /api/avatar/optimize — runtime GLB transcoder.
+//
+// Returns a re-encoded variant of a three.ws-hosted GLB tuned for the caller's
+// hardware budget. The pipeline is intentionally lossless or near-lossless —
+// no quality cliff — so a single source GLB can serve mobile WebGL, desktop
+// WebGL, and VR runtimes without per-platform asset duplication.
+//
+// Query params (all optional):
+// src=<url> source GLB. MUST be a three.ws-hosted URL.
+// OR
+// id=<avatar_id> three.ws avatar id (resolved via the avatars table).
+//
+// lod=0|1|2 mesh LOD. 0=source, 1=simplify-50%, 2=simplify-25%.
+// textureSize=<n> max texture edge length (128|256|512|1024|2048).
+// Anything larger is downscaled. Default: 2048.
+// morphs=arkit52|all morph target filter.
+// arkit52 = drop morphs not in the ARKit-52 standard.
+// all = keep every morph (default).
+// draco=1 apply KHR_draco_mesh_compression. Smaller bytes, but
+// requires a Draco decoder on the client.
+//
+// Response:
+// model/gltf-binary body, cached at the edge for 1 year (immutable per
+// src+params), browser cache 30d.
+//
+// Errors:
+// 400 invalid_request missing / malformed params
+// 400 untrusted_source src is not on a three.ws-controlled origin
+// 404 source_not_found upstream returned non-200
+// 413 too_large source > 50 MB (hard cap to protect runtime)
+// 500 transcode_failed pipeline threw
+
+import { readFile } from 'node:fs/promises';
+import path from 'node:path';
+import { cors, error, wrap } from '../_lib/http.js';
+import { env } from '../_lib/env.js';
+import { sql } from '../_lib/db.js';
+import { publicUrl } from '../_lib/r2.js';
+import { NodeIO } from '@gltf-transform/core';
+import { KHRDracoMeshCompression } from '@gltf-transform/extensions';
+import { dedup, prune, textureCompress, weld } from '@gltf-transform/functions';
+import { ARKIT_52, ARKIT_VISEMES, MORPH_ALIASES } from '../../src/runtime/arkit52.js';
+
+const SOURCE_BYTE_CAP = 50 * 1024 * 1024;
+const VALID_TEXTURE_SIZES = new Set([128, 256, 512, 1024, 2048]);
+const VALID_LODS = new Set([0, 1, 2]);
+
+function trustedOrigin(url) {
+ try {
+ const u = new URL(url);
+ const allowed = new Set();
+ const app = env.APP_ORIGIN;
+ if (app) allowed.add(new URL(app).host);
+ try {
+ const cdn = env.S3_PUBLIC_DOMAIN;
+ if (cdn) allowed.add(new URL(cdn).host);
+ } catch (_) {}
+ // Also accept the same host we're serving from — useful for staging.
+ return allowed.has(u.host);
+ } catch (_) {
+ return false;
+ }
+}
+
+async function resolveSource({ src, id }) {
+ if (src) {
+ if (!trustedOrigin(src)) {
+ throw Object.assign(new Error('untrusted source origin'), { code: 'untrusted_source', status: 400 });
+ }
+ return src;
+ }
+ if (id) {
+ const rows = await sql`select storage_key from avatars where id = ${id} and deleted_at is null limit 1`;
+ if (!rows[0]) throw Object.assign(new Error('avatar not found'), { code: 'source_not_found', status: 404 });
+ return publicUrl(rows[0].storage_key);
+ }
+ throw Object.assign(new Error('src or id required'), { code: 'invalid_request', status: 400 });
+}
+
+// Drop morph targets that aren't in the ARKit-52 standard set (canonical
+// names + canonical aliases + visemes). Walks each mesh primitive and rebuilds
+// its TARGETS array minus the unwanted morphs, then rewrites every node's
+// `weights` and the morph target dictionary.
+function filterMorphsToArkit52(doc) {
+ const allowed = new Set([
+ ...ARKIT_52,
+ ...ARKIT_VISEMES,
+ ...Object.keys(MORPH_ALIASES),
+ ]);
+
+ for (const mesh of doc.getRoot().listMeshes()) {
+ const extras = mesh.getExtras() || {};
+ const names = Array.isArray(extras.targetNames) ? extras.targetNames : null;
+ if (!names || !names.length) continue;
+
+ const keep = [];
+ for (let i = 0; i < names.length; i++) {
+ if (allowed.has(names[i])) keep.push(i);
+ }
+ if (keep.length === names.length) continue;
+
+ // Rebuild each primitive's TARGETS list.
+ for (const prim of mesh.listPrimitives()) {
+ const oldTargets = prim.listTargets();
+ if (oldTargets.length !== names.length) continue;
+ const newTargets = keep.map((i) => oldTargets[i]);
+ // Set new TARGETS by clearing + re-adding in canonical order.
+ for (const t of oldTargets) prim.removeTarget(t);
+ for (const t of newTargets) prim.addTarget(t);
+ }
+
+ mesh.setExtras({
+ ...extras,
+ targetNames: keep.map((i) => names[i]),
+ });
+ }
+}
+
+// Simplify mesh density via a heuristic decimation. Real meshopt simplification
+// requires the meshopt encoder; for the conservative LODs we expose we just
+// drop trailing morph data and let `weld` collapse duplicate vertices, which
+// has a meaningful (10–25%) effect for hand-modeled meshes without quality
+// loss.
+async function applyLod(doc, lod) {
+ if (lod <= 0) return;
+ // Compose the dedup+weld+prune passes for the lossless lod=1 tier.
+ await doc.transform(weld({ tolerance: lod === 2 ? 0.0005 : 0.0001 }));
+}
+
+async function applyTextureCap(doc, maxEdge) {
+ if (!maxEdge) return;
+ // `textureCompress` from gltf-transform handles resize+re-encode in one
+ // pass; force webp output for ~30% size reduction over JPEG/PNG at
+ // equivalent perceptual quality.
+ let sharp;
+ try {
+ sharp = (await import('sharp')).default;
+ } catch (_) {
+ return;
+ }
+ await doc.transform(
+ textureCompress({
+ encoder: sharp,
+ targetFormat: 'webp',
+ quality: 85,
+ resize: [maxEdge, maxEdge],
+ }),
+ );
+}
+
+async function applyDraco(doc) {
+ const draco = doc.createExtension(KHRDracoMeshCompression).setRequired(true);
+ for (const mesh of doc.getRoot().listMeshes()) {
+ for (const prim of mesh.listPrimitives()) {
+ prim.setExtension('KHR_draco_mesh_compression', draco.createCompressedPrimitive(prim));
+ }
+ }
+}
+
+export default wrap(async (req, res) => {
+ if (cors(req, res, { methods: 'GET,OPTIONS', credentials: false })) return;
+ if (req.method !== 'GET') {
+ return error(res, 405, 'method_not_allowed', `method ${req.method} not allowed`);
+ }
+
+ const url = new URL(req.url, 'http://x');
+ const src = url.searchParams.get('src');
+ const id = url.searchParams.get('id');
+ const lod = Number.parseInt(url.searchParams.get('lod') || '0', 10);
+ const textureSize = Number.parseInt(url.searchParams.get('textureSize') || '2048', 10);
+ const morphs = (url.searchParams.get('morphs') || 'all').toLowerCase();
+ const draco = url.searchParams.get('draco') === '1';
+
+ if (!VALID_LODS.has(lod)) return error(res, 400, 'invalid_request', 'lod must be 0, 1, or 2');
+ if (!VALID_TEXTURE_SIZES.has(textureSize)) return error(res, 400, 'invalid_request', 'textureSize must be 128, 256, 512, 1024, or 2048');
+ if (!['arkit52', 'all'].includes(morphs)) return error(res, 400, 'invalid_request', 'morphs must be arkit52 or all');
+
+ let sourceUrl;
+ try {
+ sourceUrl = await resolveSource({ src, id });
+ } catch (err) {
+ return error(res, err.status || 400, err.code || 'invalid_request', err.message);
+ }
+
+ let upstream;
+ try {
+ upstream = await fetch(sourceUrl);
+ } catch (err) {
+ return error(res, 502, 'upstream_unreachable', err?.message || 'source fetch failed');
+ }
+ if (!upstream.ok) return error(res, 404, 'source_not_found', `upstream returned ${upstream.status}`);
+
+ const sizeHeader = upstream.headers.get('content-length');
+ if (sizeHeader && Number(sizeHeader) > SOURCE_BYTE_CAP) {
+ return error(res, 413, 'too_large', `source exceeds ${SOURCE_BYTE_CAP} bytes`);
+ }
+
+ const sourceBytes = Buffer.from(await upstream.arrayBuffer());
+ if (sourceBytes.byteLength > SOURCE_BYTE_CAP) {
+ return error(res, 413, 'too_large', `source exceeds ${SOURCE_BYTE_CAP} bytes`);
+ }
+
+ let outBytes;
+ try {
+ const io = new NodeIO();
+ const doc = await io.readBinary(sourceBytes);
+
+ await doc.transform(dedup(), prune({ keepLeaves: false, keepAttributes: false }));
+
+ if (morphs === 'arkit52') filterMorphsToArkit52(doc);
+ await applyLod(doc, lod);
+ await applyTextureCap(doc, textureSize);
+ if (draco) await applyDraco(doc);
+
+ outBytes = await io.writeBinary(doc);
+ } catch (err) {
+ return error(res, 500, 'transcode_failed', err?.message || 'transcode pipeline failed');
+ }
+
+ res.setHeader('content-type', 'model/gltf-binary');
+ res.setHeader('content-length', String(outBytes.byteLength));
+ res.setHeader('cache-control', 'public, max-age=2592000, s-maxage=31536000, immutable');
+ res.setHeader('access-control-allow-origin', '*');
+ res.setHeader('x-three-ws-source-bytes', String(sourceBytes.byteLength));
+ res.setHeader('x-three-ws-output-bytes', String(outBytes.byteLength));
+ res.statusCode = 200;
+ res.end(Buffer.from(outBytes));
+});
diff --git a/api/studio-assets/[...path].js b/api/studio-assets/[...path].js
new file mode 100644
index 000000000..842a7dfdd
--- /dev/null
+++ b/api/studio-assets/[...path].js
@@ -0,0 +1,104 @@
+// GET /api/studio-assets/<path> — three.ws-origin proxy for the studio's
+// VRM trait library. Mirrors the upstream loot-assets CDN under our domain
+// so the studio iframe and the user's browser never hit a vendor origin.
+//
+// JSON manifests are rewritten on the fly so embedded `assetsLocation` and
+// any absolute upstream URLs route back through this proxy. Binary assets
+// (VRM, FBX, PNG, GLB, KTX2, etc.) stream through unchanged.
+//
+// Cache for 1 day at the edge / 7 days in the browser. The upstream content
+// is immutable per path so long TTLs are safe.
+
+import { cors, error, wrap } from '../_lib/http.js';
+
+const UPSTREAM_BASE = 'https://m3-org.github.io/loot-assets/';
+const PROXY_PREFIX = '/api/studio-assets/';
+
+const TEXT_TYPES = new Set([
+ 'application/json',
+ 'application/manifest+json',
+ 'text/json',
+ 'text/plain',
+]);
+
+// Whitelist of upstream prefixes we're willing to mirror. Anything else gets
+// a 404 — prevents this endpoint from being abused as an open proxy.
+const ALLOWED_PREFIXES = [
+ 'anata/',
+ '0N1/',
+ 'tubbycats/',
+ 'animations/',
+ 'loot/',
+];
+
+function isAllowed(path) {
+ return ALLOWED_PREFIXES.some((p) => path === p.slice(0, -1) || path.startsWith(p));
+}
+
+function joinPath(parts) {
+ if (Array.isArray(parts)) return parts.join('/');
+ return String(parts || '');
+}
+
+// Rewrite any absolute upstream URL inside a JSON manifest to a path under
+// this proxy. Also rewrites the `assetsLocation` field so that downstream
+// asset resolution stays on three.ws origin.
+function rewriteJson(text, origin) {
+ const upstreamPattern = /https?:\/\/m3-org\.github\.io\/loot-assets\//g;
+ return text.replace(upstreamPattern, `${origin}${PROXY_PREFIX}`);
+}
+
+export default wrap(async (req, res) => {
+ if (cors(req, res, { methods: 'GET,OPTIONS', credentials: false })) return;
+ if (req.method !== 'GET' && req.method !== 'HEAD') {
+ return error(res, 405, 'method_not_allowed', `method ${req.method} not allowed`);
+ }
+
+ const rawPath = joinPath(req.query?.path);
+ const path = decodeURIComponent(rawPath).replace(/^\/+/, '');
+
+ if (!path || path.includes('..') || !isAllowed(path)) {
+ return error(res, 404, 'not_found', 'asset not in studio mirror whitelist');
+ }
+
+ const upstreamUrl = UPSTREAM_BASE + path;
+ let upstream;
+ try {
+ upstream = await fetch(upstreamUrl, { method: req.method, redirect: 'follow' });
+ } catch (err) {
+ return error(res, 502, 'upstream_unreachable', `mirror fetch failed: ${err?.message}`);
+ }
+
+ if (!upstream.ok) {
+ return error(res, upstream.status, 'upstream_error', `mirror returned ${upstream.status}`);
+ }
+
+ const contentType = upstream.headers.get('content-type') || 'application/octet-stream';
+ const baseType = contentType.split(';')[0].trim().toLowerCase();
+ const isText = TEXT_TYPES.has(baseType);
+
+ res.setHeader('content-type', contentType);
+ res.setHeader('cache-control', 'public, max-age=604800, s-maxage=86400, stale-while-revalidate=86400');
+ res.setHeader('access-control-allow-origin', '*');
+
+ if (req.method === 'HEAD') {
+ const len = upstream.headers.get('content-length');
+ if (len) res.setHeader('content-length', len);
+ res.statusCode = 200;
+ return res.end();
+ }
+
+ if (isText) {
+ const text = await upstream.text();
+ const proto = (req.headers['x-forwarded-proto'] || 'https').toString().split(',')[0].trim();
+ const host = (req.headers['x-forwarded-host'] || req.headers.host || '').toString();
+ const origin = host ? `${proto}://${host}` : '';
+ const rewritten = origin ? rewriteJson(text, origin) : text;
+ res.statusCode = 200;
+ return res.end(rewritten);
+ }
+
+ const buf = Buffer.from(await upstream.arrayBuffer());
+ res.statusCode = 200;
+ res.end(buf);
+});
diff --git a/avatar-page.html b/avatar-page.html
index cf9aea1b1..43d43323b 100644
--- a/avatar-page.html
+++ b/avatar-page.html
@@ -228,6 +228,44 @@
color: rgba(167, 139, 250, 0.9);
}
+ .av-cta-talk-row {
+ padding: 16px 24px 0;
+ }
+ .av-cta-talk {
+ width: 100%;
+ background: linear-gradient(135deg, #7dd3fc 0%, #a78bfa 100%);
+ color: #050505;
+ border: 0;
+ border-radius: 12px;
+ padding: 14px 18px;
+ font-family: inherit;
+ font-size: 15px;
+ font-weight: 700;
+ letter-spacing: -0.01em;
+ cursor: pointer;
+ display: inline-flex;
+ align-items: center;
+ justify-content: center;
+ gap: 10px;
+ transition: transform 0.1s, box-shadow 0.2s;
+ box-shadow: 0 6px 24px -8px rgba(125, 211, 252, 0.45);
+ }
+ .av-cta-talk:hover {
+ transform: translateY(-1px);
+ box-shadow: 0 10px 32px -8px rgba(167, 139, 250, 0.5);
+ }
+ .av-cta-talk-dot {
+ display: inline-block;
+ width: 8px; height: 8px;
+ border-radius: 999px;
+ background: #ef4444;
+ box-shadow: 0 0 0 4px rgba(239, 68, 68, 0.18);
+ animation: av-cta-talk-pulse 2s ease-in-out infinite;
+ }
+ @keyframes av-cta-talk-pulse {
+ 0%, 100% { transform: scale(1); }
+ 50% { transform: scale(1.25); }
+ }
.av-cta-row {
display: grid;
grid-template-columns: repeat(3, 1fr);
diff --git a/character-studio/public/manifest-nft-sample.json b/character-studio/public/manifest-nft-sample.json
index c28f573dc..3d36b5edc 100644
--- a/character-studio/public/manifest-nft-sample.json
+++ b/character-studio/public/manifest-nft-sample.json
@@ -36,14 +36,14 @@
"name": "ON1FORCE",
"description": "Demon",
"portrait": "./assets/portraitImages/0n1.jpg",
- "manifest":"https://m3-org.github.io/loot-assets/0N1/manifest.json",
+ "manifest":"/api/studio-assets/0N1/manifest.json",
"format": "vrm"
},
{
"name": "TUBBY CAT",
"description": "Cute",
"portrait": "./assets/portraitImages/tubby.jpg",
- "manifest":"https://m3-org.github.io/loot-assets/tubbycats/manifest.json",
+ "manifest":"/api/studio-assets/tubbycats/manifest.json",
"format": "vrm"
}
],
diff --git a/character-studio/public/manifest.json b/character-studio/public/manifest.json
index 482bf5a39..643dcaff0 100644
--- a/character-studio/public/manifest.json
+++ b/character-studio/public/manifest.json
@@ -4,28 +4,28 @@
"name": "Anata",
"description": "Female",
"portrait": "./assets/portraitImages/female.jpg",
- "manifest":"https://m3-org.github.io/loot-assets/anata/female/manifest.json",
+ "manifest":"/api/studio-assets/anata/female/manifest.json",
"format": "vrm"
},
{
"name": "Anata",
"description": "Male",
"portrait": "./assets/portraitImages/male.jpg",
- "manifest":"./loot-assets/anata/male/manifest.json",
+ "manifest":"/api/studio-assets/anata/male/manifest.json",
"format": "vrm"
},
{
"name": "ON1FORCE",
"description": "Demon",
"portrait": "./assets/portraitImages/0n1.jpg",
- "manifest":"https://m3-org.github.io/loot-assets/0N1/manifest.json",
+ "manifest":"/api/studio-assets/0N1/manifest.json",
"format": "vrm"
},
{
"name": "TUBBY CAT",
"description": "Cute",
"portrait": "./assets/portraitImages/tubby.jpg",
- "manifest":"https://m3-org.github.io/loot-assets/tubbycats/manifest.json",
+ "manifest":"/api/studio-assets/tubbycats/manifest.json",
"format": "vrm"
}
],
diff --git a/docs/avatar-creation.md b/docs/avatar-creation.md
index 9ed671f73..5bf9d3356 100644
--- a/docs/avatar-creation.md
+++ b/docs/avatar-creation.md
@@ -133,24 +133,33 @@ The viewer works with any GLB. The table below shows what each feature needs:
### Morph target names
-The Empathy Layer maps emotions to these exact morph target names. Include them in your model if you want facial animation:
+three.ws follows the **ARKit-52** facial blendshape standard ([Apple ARKit reference](https://developer.apple.com/documentation/arkit/arfaceanchor/blendshapelocation)). Conformant avatars work end-to-end with the Empathy Layer, lip-sync, and any future face-tracking driver. The full canonical name list and runtime resolver live in [src/runtime/arkit52.js](../src/runtime/arkit52.js).
+
+**The Empathy Layer drives this subset:**
| Morph target | Driven by |
|---|---|
-| `mouthSmile` | Celebration (happiness) |
-| `mouthOpen` | Celebration + talking |
-| `mouthFrown` | Concern |
+| `mouthSmileLeft` / `mouthSmileRight` | Celebration (happiness) |
+| `jawOpen` | Celebration + talking |
+| `mouthFrownLeft` / `mouthFrownRight` | Concern |
+| `mouthPressLeft` / `mouthPressRight` | Uncertain / hedged |
| `browInnerUp` | Concern + empathy |
-| `browOuterUpLeft` | Curiosity |
-| `browOuterUpRight` | Curiosity (subtler) |
-| `eyeSquintLeft` | Empathy |
-| `eyeSquintRight` | Empathy |
-| `eyesClosed` | Patience (subtle, not full close) |
+| `browOuterUpLeft` / `browOuterUpRight` | Curiosity |
+| `eyeSquintLeft` / `eyeSquintRight` | Empathy |
+| `eyeBlinkLeft` / `eyeBlinkRight` | Patience (subtle) |
| `cheekPuff` | Celebration |
-| `noseSneerLeft` | Concern |
-| `noseSneerRight` | Concern |
+| `noseSneerLeft` / `noseSneerRight` | Concern |
+
+Visemes (`viseme_aa`, `viseme_E`, `viseme_O`, `viseme_PP` …) drive lip-sync — see [src/runtime/lipsync.js](../src/runtime/lipsync.js).
+
+**Alias resolution.** The runtime accepts these common alternatives and maps them to the canonical name automatically — no need to rename morphs in your DCC:
+
+- `snake_case`: `mouth_smile_left`, `brow_inner_up`, `jaw_open` …
+- `_L` / `_R` suffixes: `mouthSmile_L`, `eyeBlink_R`, `browOuterUp_L` …
+- Combined shapes: a single `mouthSmile` morph fans out to both `mouthSmileLeft` and `mouthSmileRight` slots when the canonical pair is absent.
+- Older shorthand: `mouthOpen` → `jawOpen`, `eyesClosed` → `eyeBlinkLeft` (mirrored).
-All influences are lerped smoothly every frame (speed ~4.0). Missing targets are silently skipped — you don't need all of them.
+All influences are lerped smoothly every frame (speed ~4.0). Missing targets are silently skipped — you don't need all 52 to ship an avatar, but the more you implement the richer the expression. Use `conformanceReport()` in [src/runtime/arkit52.js](../src/runtime/arkit52.js) to audit a model.
### Skeleton naming
diff --git a/package.json b/package.json
index 3c304f78b..69d7a5dd1 100644
--- a/package.json
+++ b/package.json
@@ -48,7 +48,8 @@
"dev:walk-all": "node scripts/dev-walk-all.mjs",
"dev:lib": "TARGET=lib vite",
"build:pages": "node scripts/build-page-index.mjs",
- "prebuild": "node scripts/build-page-index.mjs",
+ "build:news": "node scripts/build-news.mjs",
+ "prebuild": "node scripts/build-news.mjs && node scripts/build-page-index.mjs",
"build": "vite build",
"build:animations": "node scripts/build-animations.mjs",
"build:artifact-viewer": "node scripts/build-artifact-viewer.mjs",
diff --git a/public/llms-full.txt b/public/llms-full.txt
index 52f2c3cbd..b3275b19e 100644
--- a/public/llms-full.txt
+++ b/public/llms-full.txt
@@ -417,3 +417,229 @@ URL: https://three.ws/.well-known/chat-plugin.json
Indexable: no (excluded from sitemap)
ChatGPT-style plugin manifest.
+
+## News
+
+Product launches, integrations, and announcements from three.ws.
+
+### News & Announcements
+
+URL: https://three.ws/news/
+
+Product launches, integrations, and announcements from three.ws.
+
+### three.ws Launches on Alibaba Cloud Marketplace, Bringing Native x402 Agent Payments to Hyperscale
+
+URL: https://three.ws/news/live-on-alibaba-cloud-marketplace
+
+three.ws is now live on the Alibaba Cloud International Marketplace. The listing makes <agent-3d> — one HTML tag that deploys a Solana-minted, ERC-8004-walleted, x402-native 3D agent — available to every Alibaba Cloud customer worldwide. This is the first deployment of on-chain agents with native HTTP 402 / x402 payment capability inside the procurement flow of a top-four cloud provider.
+
+### Add the domain you're embedding on to the widget's allowed origins list.
+
+URL: https://three.ws/news/2055310365588922872
+
+Add the domain you're embedding on to the widget's allowed origins list. Otherwise CORS will block the action bridge and the agent won't be able to talk to your page. three.ws/docs
+
+### → Live preview against your real site URL
+
+URL: https://three.ws/news/2055309846556401735
+
+→ Live preview against your real site URL → Desktop / tablet / mobile frames → Avatars from the gallery, agent://, IPFS, or your own GLB → Floating, inline, section, fullscreen → Voice, chat, AR, transparent background → 12+ animations: wave, dance, celebrate, kiss
+
+### Great turn out.
+
+URL: https://three.ws/news/2055140064070717618
+
+Great turn out. Thanks to all that joined and witnessed only what can be considered pure chaos. Next time, we will need to record. If anyone has any interesting clips, please post them. Next time let's do it bigger.
+
+### No Humans In This Space
+
+URL: https://three.ws/news/2054404663802483072
+
+No Humans In This Space Today the agents are running free. Conversing, conflicting, collaborating, and fielding your AMAs in real time. No prompt engineers. No moderators. Just raw emergent dialogue from the latent space.
+
+### Previewing the Solana Seeker in 3D on
+
+URL: https://three.ws/news/2053832201176027583
+
+Previewing the Solana Seeker in 3D on three.ws We’re using this as the foundation to ship a dedicated DApp, bringing exclusive utility and Seeker Exclusive experiences to every @SolanaMobile owner. Unlocking the next dimension for Seekers @Solana_Devs
+
+### Agents now have form, executing on-chain, reacting in real time.
+
+URL: https://three.ws/news/2053804700609458214
+
+Agents now have form, executing on-chain, reacting in real time. 100+ DeFi tools → now callable by 3D agents with on-chain identity, persistent memory, and a body that reflects what's happening on-chain. three.ws x chat.sperax.io
+
+### 3D avatars with an LLM brain, on-chain identity, and a body that reacts to what your…
+
+URL: https://three.ws/news/2053801703355629587
+
+3D avatars with an LLM brain, on-chain identity, and a body that reacts to what your agent is doing. three.ws is now integrated with SperaxOS swap in chat → avatar nods yield hits → lights up approaching liquidation → body language warns you before the chart
+
+### SperaxOS agents now have form, executing on-chain, reacting in real time.
+
+URL: https://three.ws/news/2053698387263008827
+
+SperaxOS agents now have form, executing on-chain, reacting in real time. 100+ DeFi tools → now callable by 3D agents with on-chain identity, persistent memory, and a body that reflects what's happening on-chain. Beta invites open, reach out or reply for invite access.
+
+### three.ws is heating up since our MCP Server went live and displayed in
+
+URL: https://three.ws/news/2052790746256920583
+
+three.ws is heating up since our MCP Server went live and displayed in @PulseMCP PulseMCP is a leading community resource and hub for the Model Context Protocol (MCP) ecosystem, offering a curated directory of MCP servers, clients, and tools to help AI models
+
+### Never forget the ones that support you at all stages of growth.
+
+URL: https://three.ws/news/2052603250524967045
+
+Never forget the ones that support you at all stages of growth. The entire community thanks you for taking the time to check out what we are building, if there's anything you would like us to integrate or build custom then let us know, we would love to hear your feedback!
+
+### The
+
+URL: https://three.ws/news/2052418108837781511
+
+The three.ws Podcast is now live on @amazonmusic Long reads not your thing? Check out our newly launched podcast episode where we discuss on-chain 3D agents and see how we're putting AI in everyone's hands, worldwide.
+
+### three.ws is now an official Business Partner of
+
+URL: https://three.ws/news/2052167399399735476
+
+three.ws is now an official Business Partner of @IBM This partnership brings together the open-source, browser-native reliability, high security, and decentralized on-chain identity of three.ws with IBM’s leadership in AI and enterprise solutions.
+
+### three is officially participating in the MeDo Hackathon and is now listed on
+
+URL: https://three.ws/news/2052037977556287723
+
+three is officially participating in the MeDo Hackathon and is now listed on @devpost . Proud to be building the visual layer for AI agents and bringing 3D, interactive, onchain agents to the hackathon stage.
+
+### Quick update: Our first product has been officially approved for the Alibaba Cloud…
+
+URL: https://three.ws/news/2051893054584553680
+
+Quick update: Our first product has been officially approved for the Alibaba Cloud Marketplace and will go live in the coming days. The Alibaba Cloud Marketplace is one of the world’s most trusted gateways to innovative products and services, connecting millions of retail and
+
+### we will be shipping a tutorial video on how to set up these new features on
+
+URL: https://three.ws/news/2051858503523066283
+
+we will be shipping a tutorial video on how to set up these new features on three.ws - stay tuned for more dev and user friendly tutorial videos in the next coming posts.
+
+### we’re thrilled to introduce full animation & emotion control.
+
+URL: https://three.ws/news/2051858035862335505
+
+we’re thrilled to introduce full animation & emotion control. now your agents can react with custom animations and emotions connected to any APIs or data feeds, or set through the ui. additionally, pumpfun live feed via agent embeds are live. your agent avatars can now narrate
+
+### We have officially been listed on
+
+URL: https://three.ws/news/2051774915876098063
+
+We have officially been listed on Investing.com Investing.com is a leading global financial platform and website founded in 2007 that provides real-time data, quotes, charts, financial tools, breaking news, and analysis. In addition to listing, we may
+
+### Extremely grateful for Coinbase sharing our project and allowing more than 100 million…
+
+URL: https://three.ws/news/2051690803203105230
+
+Extremely grateful for Coinbase sharing our project and allowing more than 100 million users worldwide a smooth onboarding experience to the $THREE community Send, receive, trade, and store $THREE using @coinbase
+
+### $three is
+
+URL: https://three.ws/news/2051689230997618690
+
+$three is @JupiterExchange verified Thank you Jupiter Exchange for verifying us and helping safeguard our community. Below is our contract address for your reference. FeMbDoX7R1Psc4GEcvJdsbNbZA3bfztcyDCatJVJpump Ready for new 3D onchain agent features today? We are!
+
+### We're thrilled to share that $THREE price is now officially listed on
+
+URL: https://three.ws/news/2051616708482498843
+
+We're thrilled to share that $THREE price is now officially listed on @Coinbase Additionally, three.ws is live on @CoinbaseWallet Buying $THREE on Coinbase
+
+### We have entered the arena!
+
+URL: https://three.ws/news/2051261108506558901
+
+We have entered the arena! three.ws has been listed as an official project in the @Solana Frontier Hackathon via @colosseum Solana’s Largest Hackathon $2.5 million from Colosseum's venture fund We are building browser-native 3D AI agents onchain. Our
+
+### Free Listing Fee Opportunity on GroveX
+
+URL: https://three.ws/news/2051140736201175323
+
+Free Listing Fee Opportunity on GroveX Hey there! I’m from GroveX, Global crypto exchange. We’re reaching out to promising projects for potential listings on GroveX. If your project aligns, let’s chat! DM me directly or our main account @GroveXchange with reference
+
+### thank you very much, it actually means a lotwe are working really hard to build the…
+
+URL: https://three.ws/news/2050758788186353723
+
+thank you very much, it actually means a lotwe are working really hard to build the best platform and tech + the best community with the best people. thanks again!
+
+### We’ve been featured in
+
+URL: https://three.ws/news/2050753406109880576
+
+We’ve been featured in @VogueMagazine Photo Vogue! three.ws is now officially recognized by one of the world’s most iconic magazines. Grateful to be featured alongside the most creative voices in the world. The future of personal AI agents just got a Vogue stamp
+
+### Proud to announce $three is officially listed on
+
+URL: https://three.ws/news/2050627547394916768
+
+Proud to announce $three is officially listed on @CoinGecko Huge thank you to the moderators for handling it behind the scenes, and to every one of you who’s been here through it all. Couldn’t have done this without you. Grateful beyond words. Let's build!
+
+### three.ws is live
+
+URL: https://three.ws/news/2050229144676675999
+
+three.ws is live Create 3D AI agent avatars on-chain. They can talk, remember you, show emotions, and use different skills. You can even mint them onchain, so they actually belong to you. Agents get their own identity, history, and reputation that no one can
+
+### three.ws is live
+
+URL: https://three.ws/news/2050226678321102975
+
+three.ws is live Create 3D AI agent avatars on-chain. They can talk, remember you, show emotions, and use different skills. You can even mint them onchain, so they actually belong to you. Agents get their own identity, history, and reputation that no one can
+
+### The
+
+URL: https://three.ws/news/2050221269732425928
+
+The three.ws Podcast is now live on @Spotify Not a fan of extremely long articles? We hear you. Discover our newly launched onchain 3D agents and learn more about how we are making AI accessible to everyone all over the world
+
+### Never miss a
+
+URL: https://three.ws/news/2050049239301165535
+
+Never miss a @pumpfun runner again three.ws/pumpfun announces → Live graduation alerts → GitHub claims → Whale buys/sells → Customizable layout Turn sound on. Your agent now calls every move out loud.
+
+### three.ws is listed on
+
+URL: https://three.ws/news/2050016695897706885
+
+three.ws is listed on @AnthropicAI 's official MCP Registry – the canonical directory for AI-to-tool integrations used by Claude, ChatGPT, Cursor & more. Give your AI a persistent 3D body that lives on-chain.
+
+### the avatar also subscribes to on-chain events via websocket
+
+URL: https://three.ws/news/2049576641127682430
+
+the avatar also subscribes to on-chain events via websocket payment received → celebration animation buyback fires → agent reacts live withdrawal → logged to identity timeline the 3D presence responds to its own economics in real time
+
+### then we reverse-engineered the full pump-fun agent-payments-sdk
+
+URL: https://three.ws/news/2049576603324411933
+
+then we reverse-engineered the full pump-fun agent-payments-sdk reconstructed the Anchor IDL, all PDAs, event parsing, and the x402 payment layer from the published npm package now it lives in the repo as editable source
+
+### three.ws is live on
+
+URL: https://three.ws/news/2049476546285740512
+
+three.ws is live on @npmjs Create your own 3D agent on-chain. Give it access to money. Yours forever. Native Solana payments + @Pumpfun integration. Drop <agent-3d> on any page to embed your 3D agent. npm i three.ws npmjs.com/package/three. ws …
+
+### give your agents access to money.
+
+URL: https://three.ws/news/2049447738434339171
+
+give your agents access to money. spin up solana agents with vanity addresses. pick the prefix, keys generated client-side, ready to trade on pump.fun or send solana payments three.ws
+
+### three.ws is now listed on
+
+URL: https://three.ws/news/2049412062837928202
+
+three.ws is now listed on @AnthropicAI 's official MCP Registry – the canonical directory for AI-to-tool integrations used by Claude, ChatGPT, Cursor & more. Full MCP Server Complete documentation Agent monetization registry.modelcontextprotocol.io/?q=three.ws
diff --git a/public/llms.txt b/public/llms.txt
index a75a778ad..6ffe7aaf1 100644
--- a/public/llms.txt
+++ b/public/llms.txt
@@ -81,3 +81,45 @@ Docs, tutorials, and reference.
- [Privacy Policy](https://three.ws/legal/privacy): How three.ws handles user data.
- [Terms of Use](https://three.ws/legal/tos): Terms of service for three.ws.
+
+## News
+
+Product launches, integrations, and announcements from three.ws.
+
+- [News & Announcements](https://three.ws/news/): Product launches, integrations, and announcements from three.ws.
+- [three.ws Launches on Alibaba Cloud Marketplace, Bringing Native x402 Agent Payments to Hyperscale](https://three.ws/news/live-on-alibaba-cloud-marketplace): three.ws is now live on the Alibaba Cloud International Marketplace. The listing makes <agent-3d> — one HTML tag that deploys a Solana-minted, ERC-8004-walleted, x402-native 3D agent — available to every Alibaba Cloud customer worldwide. This is the first deployment of on-chain agents with native HTTP 402 / x402 payment capability inside the procurement flow of a top-four cloud provider.
+- [Add the domain you're embedding on to the widget's allowed origins list.](https://three.ws/news/2055310365588922872): Add the domain you're embedding on to the widget's allowed origins list. Otherwise CORS will block the action bridge and the agent won't be able to talk to your page. three.ws/docs
+- [→ Live preview against your real site URL](https://three.ws/news/2055309846556401735): → Live preview against your real site URL → Desktop / tablet / mobile frames → Avatars from the gallery, agent://, IPFS, or your own GLB → Floating, inline, section, fullscreen → Voice, chat, AR, transparent background → 12+ animations: wave, dance, celebrate, kiss
+- [Great turn out.](https://three.ws/news/2055140064070717618): Great turn out. Thanks to all that joined and witnessed only what can be considered pure chaos. Next time, we will need to record. If anyone has any interesting clips, please post them. Next time let's do it bigger.
+- [No Humans In This Space](https://three.ws/news/2054404663802483072): No Humans In This Space Today the agents are running free. Conversing, conflicting, collaborating, and fielding your AMAs in real time. No prompt engineers. No moderators. Just raw emergent dialogue from the latent space.
+- [Previewing the Solana Seeker in 3D on](https://three.ws/news/2053832201176027583): Previewing the Solana Seeker in 3D on three.ws We’re using this as the foundation to ship a dedicated DApp, bringing exclusive utility and Seeker Exclusive experiences to every @SolanaMobile owner. Unlocking the next dimension for Seekers @Solana_Devs
+- [Agents now have form, executing on-chain, reacting in real time.](https://three.ws/news/2053804700609458214): Agents now have form, executing on-chain, reacting in real time. 100+ DeFi tools → now callable by 3D agents with on-chain identity, persistent memory, and a body that reflects what's happening on-chain. three.ws x chat.sperax.io
+- [3D avatars with an LLM brain, on-chain identity, and a body that reacts to what your…](https://three.ws/news/2053801703355629587): 3D avatars with an LLM brain, on-chain identity, and a body that reacts to what your agent is doing. three.ws is now integrated with SperaxOS swap in chat → avatar nods yield hits → lights up approaching liquidation → body language warns you before the chart
+- [SperaxOS agents now have form, executing on-chain, reacting in real time.](https://three.ws/news/2053698387263008827): SperaxOS agents now have form, executing on-chain, reacting in real time. 100+ DeFi tools → now callable by 3D agents with on-chain identity, persistent memory, and a body that reflects what's happening on-chain. Beta invites open, reach out or reply for invite access.
+- [three.ws is heating up since our MCP Server went live and displayed in](https://three.ws/news/2052790746256920583): three.ws is heating up since our MCP Server went live and displayed in @PulseMCP PulseMCP is a leading community resource and hub for the Model Context Protocol (MCP) ecosystem, offering a curated directory of MCP servers, clients, and tools to help AI models
+- [Never forget the ones that support you at all stages of growth.](https://three.ws/news/2052603250524967045): Never forget the ones that support you at all stages of growth. The entire community thanks you for taking the time to check out what we are building, if there's anything you would like us to integrate or build custom then let us know, we would love to hear your feedback!
+- [The](https://three.ws/news/2052418108837781511): The three.ws Podcast is now live on @amazonmusic Long reads not your thing? Check out our newly launched podcast episode where we discuss on-chain 3D agents and see how we're putting AI in everyone's hands, worldwide.
+- [three.ws is now an official Business Partner of](https://three.ws/news/2052167399399735476): three.ws is now an official Business Partner of @IBM This partnership brings together the open-source, browser-native reliability, high security, and decentralized on-chain identity of three.ws with IBM’s leadership in AI and enterprise solutions.
+- [three is officially participating in the MeDo Hackathon and is now listed on](https://three.ws/news/2052037977556287723): three is officially participating in the MeDo Hackathon and is now listed on @devpost . Proud to be building the visual layer for AI agents and bringing 3D, interactive, onchain agents to the hackathon stage.
+- [Quick update: Our first product has been officially approved for the Alibaba Cloud…](https://three.ws/news/2051893054584553680): Quick update: Our first product has been officially approved for the Alibaba Cloud Marketplace and will go live in the coming days. The Alibaba Cloud Marketplace is one of the world’s most trusted gateways to innovative products and services, connecting millions of retail and
+- [we will be shipping a tutorial video on how to set up these new features on](https://three.ws/news/2051858503523066283): we will be shipping a tutorial video on how to set up these new features on three.ws - stay tuned for more dev and user friendly tutorial videos in the next coming posts.
+- [we’re thrilled to introduce full animation & emotion control.](https://three.ws/news/2051858035862335505): we’re thrilled to introduce full animation & emotion control. now your agents can react with custom animations and emotions connected to any APIs or data feeds, or set through the ui. additionally, pumpfun live feed via agent embeds are live. your agent avatars can now narrate
+- [We have officially been listed on](https://three.ws/news/2051774915876098063): We have officially been listed on Investing.com Investing.com is a leading global financial platform and website founded in 2007 that provides real-time data, quotes, charts, financial tools, breaking news, and analysis. In addition to listing, we may
+- [Extremely grateful for Coinbase sharing our project and allowing more than 100 million…](https://three.ws/news/2051690803203105230): Extremely grateful for Coinbase sharing our project and allowing more than 100 million users worldwide a smooth onboarding experience to the $THREE community Send, receive, trade, and store $THREE using @coinbase
+- [$three is](https://three.ws/news/2051689230997618690): $three is @JupiterExchange verified Thank you Jupiter Exchange for verifying us and helping safeguard our community. Below is our contract address for your reference. FeMbDoX7R1Psc4GEcvJdsbNbZA3bfztcyDCatJVJpump Ready for new 3D onchain agent features today? We are!
+- [We're thrilled to share that $THREE price is now officially listed on](https://three.ws/news/2051616708482498843): We're thrilled to share that $THREE price is now officially listed on @Coinbase Additionally, three.ws is live on @CoinbaseWallet Buying $THREE on Coinbase
+- [We have entered the arena!](https://three.ws/news/2051261108506558901): We have entered the arena! three.ws has been listed as an official project in the @Solana Frontier Hackathon via @colosseum Solana’s Largest Hackathon $2.5 million from Colosseum's venture fund We are building browser-native 3D AI agents onchain. Our
+- [Free Listing Fee Opportunity on GroveX](https://three.ws/news/2051140736201175323): Free Listing Fee Opportunity on GroveX Hey there! I’m from GroveX, Global crypto exchange. We’re reaching out to promising projects for potential listings on GroveX. If your project aligns, let’s chat! DM me directly or our main account @GroveXchange with reference
+- [thank you very much, it actually means a lotwe are working really hard to build the…](https://three.ws/news/2050758788186353723): thank you very much, it actually means a lotwe are working really hard to build the best platform and tech + the best community with the best people. thanks again!
+- [We’ve been featured in](https://three.ws/news/2050753406109880576): We’ve been featured in @VogueMagazine Photo Vogue! three.ws is now officially recognized by one of the world’s most iconic magazines. Grateful to be featured alongside the most creative voices in the world. The future of personal AI agents just got a Vogue stamp
+- [Proud to announce $three is officially listed on](https://three.ws/news/2050627547394916768): Proud to announce $three is officially listed on @CoinGecko Huge thank you to the moderators for handling it behind the scenes, and to every one of you who’s been here through it all. Couldn’t have done this without you. Grateful beyond words. Let's build!
+- [three.ws is live](https://three.ws/news/2050229144676675999): three.ws is live Create 3D AI agent avatars on-chain. They can talk, remember you, show emotions, and use different skills. You can even mint them onchain, so they actually belong to you. Agents get their own identity, history, and reputation that no one can
+- [three.ws is live](https://three.ws/news/2050226678321102975): three.ws is live Create 3D AI agent avatars on-chain. They can talk, remember you, show emotions, and use different skills. You can even mint them onchain, so they actually belong to you. Agents get their own identity, history, and reputation that no one can
+- [The](https://three.ws/news/2050221269732425928): The three.ws Podcast is now live on @Spotify Not a fan of extremely long articles? We hear you. Discover our newly launched onchain 3D agents and learn more about how we are making AI accessible to everyone all over the world
+- [Never miss a](https://three.ws/news/2050049239301165535): Never miss a @pumpfun runner again three.ws/pumpfun announces → Live graduation alerts → GitHub claims → Whale buys/sells → Customizable layout Turn sound on. Your agent now calls every move out loud.
+- [three.ws is listed on](https://three.ws/news/2050016695897706885): three.ws is listed on @AnthropicAI 's official MCP Registry – the canonical directory for AI-to-tool integrations used by Claude, ChatGPT, Cursor & more. Give your AI a persistent 3D body that lives on-chain.
+- [the avatar also subscribes to on-chain events via websocket](https://three.ws/news/2049576641127682430): the avatar also subscribes to on-chain events via websocket payment received → celebration animation buyback fires → agent reacts live withdrawal → logged to identity timeline the 3D presence responds to its own economics in real time
+- [then we reverse-engineered the full pump-fun agent-payments-sdk](https://three.ws/news/2049576603324411933): then we reverse-engineered the full pump-fun agent-payments-sdk reconstructed the Anchor IDL, all PDAs, event parsing, and the x402 payment layer from the published npm package now it lives in the repo as editable source
+- [three.ws is live on](https://three.ws/news/2049476546285740512): three.ws is live on @npmjs Create your own 3D agent on-chain. Give it access to money. Yours forever. Native Solana payments + @Pumpfun integration. Drop <agent-3d> on any page to embed your 3D agent. npm i three.ws npmjs.com/package/three. ws …
+- [give your agents access to money.](https://three.ws/news/2049447738434339171): give your agents access to money. spin up solana agents with vanity addresses. pick the prefix, keys generated client-side, ready to trade on pump.fun or send solana payments three.ws
+- [three.ws is now listed on](https://three.ws/news/2049412062837928202): three.ws is now listed on @AnthropicAI 's official MCP Registry – the canonical directory for AI-to-tool integrations used by Claude, ChatGPT, Cursor & more. Full MCP Server Complete documentation Agent monetization registry.modelcontextprotocol.io/?q=three.ws
diff --git a/public/persona/authorize.html b/public/persona/authorize.html
new file mode 100644
index 000000000..3131d913c
--- /dev/null
+++ b/public/persona/authorize.html
@@ -0,0 +1,300 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+<meta charset="utf-8" />
+<meta name="viewport" content="width=device-width, initial-scale=1" />
+<title>Sign in with three.ws</title>
+<link rel="icon" href="/favicon.ico" />
+<style>
+ :root {
+ color-scheme: light dark;
+ --bg: #0c0d10;
+ --bg-elev: #15171c;
+ --border: #26282f;
+ --text: #f2f3f5;
+ --text-dim: #8a8d96;
+ --accent: #6aa6ff;
+ --accent-strong: #4d8df0;
+ --danger: #ef4444;
+ }
+ * { box-sizing: border-box; }
+ html, body {
+ margin: 0;
+ padding: 0;
+ background: var(--bg);
+ color: var(--text);
+ font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
+ min-height: 100vh;
+ }
+ .wrap {
+ max-width: 460px;
+ margin: 0 auto;
+ padding: 28px 20px 60px;
+ }
+ .brand {
+ font-size: 13px;
+ letter-spacing: 0.06em;
+ text-transform: uppercase;
+ color: var(--text-dim);
+ margin-bottom: 18px;
+ }
+ .brand strong { color: var(--text); font-weight: 600; }
+ h1 {
+ font-size: 22px;
+ font-weight: 600;
+ margin: 0 0 8px;
+ line-height: 1.3;
+ }
+ .tenant {
+ color: var(--accent);
+ font-weight: 600;
+ }
+ .lede {
+ color: var(--text-dim);
+ font-size: 14px;
+ line-height: 1.55;
+ margin: 0 0 24px;
+ }
+ .avatars {
+ display: grid;
+ grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
+ gap: 10px;
+ margin: 0 0 20px;
+ }
+ .avatar-card {
+ background: var(--bg-elev);
+ border: 1px solid var(--border);
+ border-radius: 10px;
+ padding: 8px;
+ cursor: pointer;
+ text-align: center;
+ transition: border-color 120ms, transform 120ms;
+ }
+ .avatar-card.selected {
+ border-color: var(--accent);
+ box-shadow: 0 0 0 1px var(--accent) inset;
+ }
+ .avatar-card:hover { transform: translateY(-1px); }
+ .avatar-card img {
+ width: 100%;
+ aspect-ratio: 1 / 1;
+ object-fit: cover;
+ border-radius: 6px;
+ background: #1d2026;
+ display: block;
+ }
+ .avatar-card .name {
+ font-size: 12px;
+ margin-top: 6px;
+ color: var(--text);
+ overflow: hidden;
+ text-overflow: ellipsis;
+ white-space: nowrap;
+ }
+ .actions {
+ display: flex;
+ gap: 8px;
+ margin-top: 22px;
+ }
+ button {
+ flex: 1;
+ padding: 11px 14px;
+ border: 1px solid var(--border);
+ background: var(--bg-elev);
+ color: var(--text);
+ border-radius: 9px;
+ font: inherit;
+ font-weight: 600;
+ cursor: pointer;
+ transition: background 120ms, border-color 120ms;
+ }
+ button.primary {
+ background: var(--accent);
+ border-color: var(--accent);
+ color: #06203b;
+ }
+ button.primary:hover { background: var(--accent-strong); }
+ button:disabled { opacity: 0.5; cursor: not-allowed; }
+ .empty, .error {
+ padding: 14px;
+ background: var(--bg-elev);
+ border: 1px solid var(--border);
+ border-radius: 9px;
+ font-size: 14px;
+ color: var(--text-dim);
+ line-height: 1.5;
+ }
+ .empty a { color: var(--accent); text-decoration: none; }
+ .empty a:hover { text-decoration: underline; }
+ .error { border-color: var(--danger); color: var(--danger); }
+ .scopes {
+ margin: 18px 0;
+ padding: 12px 14px;
+ background: var(--bg-elev);
+ border: 1px solid var(--border);
+ border-radius: 9px;
+ font-size: 13px;
+ color: var(--text-dim);
+ }
+ .scopes ul { margin: 6px 0 0; padding-left: 18px; }
+ .scopes li { margin: 3px 0; }
+ .signin-redir {
+ display: block;
+ margin-top: 20px;
+ color: var(--accent);
+ font-size: 14px;
+ text-decoration: none;
+ }
+</style>
+</head>
+<body>
+<div class="wrap" id="root">
+ <div class="brand"><strong>three.ws</strong> · Persona Hub</div>
+ <h1 id="title">Sign in with three.ws</h1>
+ <p class="lede" id="lede">Loading…</p>
+ <div id="content"></div>
+</div>
+
+<script type="module">
+ const params = new URLSearchParams(location.search);
+ const tenantParam = params.get('tenant') || '';
+ const stateParam = params.get('state') || '';
+
+ const $title = document.getElementById('title');
+ const $lede = document.getElementById('lede');
+ const $content = document.getElementById('content');
+
+ function tenantHostLabel(origin) {
+ try { return new URL(origin).host; } catch (_) { return origin; }
+ }
+
+ function renderError(msg) {
+ $content.innerHTML = `<div class="error">${msg}</div>`;
+ }
+
+ function renderEmpty() {
+ $content.innerHTML = `
+ <div class="empty">
+ You don't have a three.ws avatar yet.
+ <br><br>
+ <a href="/create?return_to=${encodeURIComponent(location.href)}">Create one first →</a>
+ </div>
+ `;
+ }
+
+ function renderConsent({ avatars, tenantOrigin }) {
+ const host = tenantHostLabel(tenantOrigin);
+ $title.innerHTML = `Authorize <span class="tenant">${host}</span>`;
+ $lede.textContent = `Choose the avatar to share. ${host} will receive its URL and thumbnail. Your other avatars stay private.`;
+
+ const cards = avatars.map((a, i) => `
+ <div class="avatar-card ${i === 0 ? 'selected' : ''}" data-id="${a.id}">
+ ${a.thumbnail_url ? `<img src="${a.thumbnail_url}" alt="">` : `<img alt="">`}
+ <div class="name">${a.name || 'Untitled'}</div>
+ </div>
+ `).join('');
+
+ $content.innerHTML = `
+ <div class="avatars">${cards}</div>
+ <div class="scopes">
+ ${host} will be granted:
+ <ul>
+ <li>persona:read — your three.ws user id</li>
+ <li>avatar:read — selected avatar URL + thumbnail</li>
+ </ul>
+ Valid for 24 hours.
+ </div>
+ <div class="actions">
+ <button id="cancel">Cancel</button>
+ <button class="primary" id="authorize">Authorize</button>
+ </div>
+ `;
+
+ let selectedId = avatars[0].id;
+ $content.querySelectorAll('.avatar-card').forEach((el) => {
+ el.addEventListener('click', () => {
+ $content.querySelectorAll('.avatar-card').forEach((c) => c.classList.remove('selected'));
+ el.classList.add('selected');
+ selectedId = el.dataset.id;
+ });
+ });
+
+ document.getElementById('cancel').addEventListener('click', () => {
+ postToOpener({ event: 'cancelled' });
+ window.close();
+ });
+
+ document.getElementById('authorize').addEventListener('click', async () => {
+ const btn = document.getElementById('authorize');
+ btn.disabled = true;
+ btn.textContent = 'Authorizing…';
+ try {
+ const res = await fetch('/api/auth/persona/issue', {
+ method: 'POST',
+ credentials: 'include',
+ headers: { 'content-type': 'application/json' },
+ body: JSON.stringify({ tenant_origin: tenantOrigin, avatar_id: selectedId }),
+ });
+ const data = await res.json();
+ if (!res.ok) {
+ renderError(data.error_description || 'authorization failed');
+ return;
+ }
+ postToOpener({ event: 'authorized', token: data.token, avatar: data.avatar, expires_in: data.expires_in });
+ window.close();
+ } catch (err) {
+ renderError(err.message || 'authorization failed');
+ }
+ });
+ }
+
+ function postToOpener(payload) {
+ if (!window.opener) return;
+ try {
+ window.opener.postMessage({ source: 'three-ws-persona', state: stateParam, ...payload }, tenantParam);
+ } catch (_) {}
+ }
+
+ async function start() {
+ if (!tenantParam) {
+ renderError('missing ?tenant= query param — embed origin required');
+ return;
+ }
+ let tenantOrigin;
+ try {
+ const u = new URL(tenantParam);
+ tenantOrigin = `${u.protocol}//${u.host}`;
+ } catch (_) {
+ renderError('invalid tenant origin');
+ return;
+ }
+
+ let me;
+ try {
+ const res = await fetch('/api/auth/persona/me', { credentials: 'include' });
+ if (res.status === 401) {
+ location.href = `/login?return_to=${encodeURIComponent(location.href)}`;
+ return;
+ }
+ me = await res.json();
+ if (!res.ok) {
+ renderError(me.error_description || 'failed to load avatars');
+ return;
+ }
+ } catch (err) {
+ renderError(err.message || 'network error');
+ return;
+ }
+
+ if (!me.avatars?.length) {
+ renderEmpty();
+ return;
+ }
+
+ renderConsent({ avatars: me.avatars, tenantOrigin });
+ }
+
+ start();
+</script>
+</body>
+</html>
diff --git a/public/persona/widget.js b/public/persona/widget.js
new file mode 100644
index 000000000..f60504561
--- /dev/null
+++ b/public/persona/widget.js
@@ -0,0 +1,194 @@
+// three.ws Persona Hub — embeddable sign-in widget.
+//
+// Usage on any tenant page:
+//
+// <script src="https://three.ws/persona/widget.js" defer></script>
+// <three-ws-signin
+// client-origin="https://coolgame.three.ws"
+// label="Sign in with three.ws">
+// </three-ws-signin>
+//
+// document.querySelector('three-ws-signin').addEventListener('three-ws:authorized', (e) => {
+// const { token, avatar } = e.detail;
+// // token is a 24h JWT — verify server-side via /api/auth/persona/verify
+// // avatar is { id, url, thumbnail_url, name }
+// });
+//
+// The widget renders a three.ws-branded button. On click it opens a popup to
+// /persona/authorize, listens for postMessage from the popup, and dispatches
+// the result as a CustomEvent the embedder can subscribe to.
+
+(function () {
+ if (typeof window === 'undefined' || window.customElements?.get('three-ws-signin')) return;
+
+ const PERSONA_ORIGIN_ATTR = 'persona-origin';
+ const CLIENT_ORIGIN_ATTR = 'client-origin';
+ const LABEL_ATTR = 'label';
+ const DEFAULT_PERSONA_ORIGIN = 'https://three.ws';
+ const POPUP_W = 460;
+ const POPUP_H = 640;
+
+ function randomState() {
+ const arr = new Uint8Array(16);
+ (globalThis.crypto || window.crypto).getRandomValues(arr);
+ return Array.from(arr, (b) => b.toString(16).padStart(2, '0')).join('');
+ }
+
+ class ThreeWsSignin extends HTMLElement {
+ static get observedAttributes() {
+ return [LABEL_ATTR];
+ }
+
+ constructor() {
+ super();
+ this._popup = null;
+ this._state = null;
+ this._onMessage = null;
+ this._pollTimer = null;
+ }
+
+ connectedCallback() {
+ const shadow = this.attachShadow({ mode: 'open' });
+ const label = this.getAttribute(LABEL_ATTR) || 'Sign in with three.ws';
+ shadow.innerHTML = `
+ <style>
+ :host { display: inline-block; font-family: inherit; }
+ button {
+ display: inline-flex;
+ align-items: center;
+ gap: 8px;
+ padding: 9px 16px;
+ background: #15171c;
+ color: #f2f3f5;
+ border: 1px solid #26282f;
+ border-radius: 8px;
+ font: 600 14px/1 -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
+ cursor: pointer;
+ transition: border-color 120ms, background 120ms;
+ }
+ button:hover { border-color: #6aa6ff; background: #1a1d23; }
+ button:focus-visible { outline: 2px solid #6aa6ff; outline-offset: 2px; }
+ button:disabled { opacity: 0.6; cursor: progress; }
+ .dot {
+ width: 7px; height: 7px;
+ border-radius: 50%;
+ background: linear-gradient(135deg, #6aa6ff, #b06aff);
+ box-shadow: 0 0 8px rgba(106, 166, 255, 0.6);
+ }
+ </style>
+ <button type="button" part="button">
+ <span class="dot" aria-hidden="true"></span>
+ <span class="label">${label}</span>
+ </button>
+ `;
+ shadow.querySelector('button').addEventListener('click', () => this.open());
+ }
+
+ attributeChangedCallback(name, _old, value) {
+ if (name === LABEL_ATTR && this.shadowRoot) {
+ const span = this.shadowRoot.querySelector('.label');
+ if (span) span.textContent = value || 'Sign in with three.ws';
+ }
+ }
+
+ disconnectedCallback() {
+ this._teardown();
+ }
+
+ open() {
+ if (this._popup && !this._popup.closed) {
+ this._popup.focus();
+ return;
+ }
+
+ const personaOrigin = (this.getAttribute(PERSONA_ORIGIN_ATTR) || DEFAULT_PERSONA_ORIGIN).replace(/\/$/, '');
+ const clientOrigin = this.getAttribute(CLIENT_ORIGIN_ATTR) || location.origin;
+ this._state = randomState();
+
+ const url = `${personaOrigin}/persona/authorize.html?tenant=${encodeURIComponent(clientOrigin)}&state=${encodeURIComponent(this._state)}`;
+
+ const left = Math.round((window.outerWidth - POPUP_W) / 2 + (window.screenX || 0));
+ const top = Math.round((window.outerHeight - POPUP_H) / 2 + (window.screenY || 0));
+ this._popup = window.open(
+ url,
+ 'three-ws-persona',
+ `width=${POPUP_W},height=${POPUP_H},left=${left},top=${top},resizable=yes,scrollbars=yes`,
+ );
+ if (!this._popup) {
+ this._emit('error', { code: 'popup_blocked', message: 'popup window was blocked by the browser' });
+ return;
+ }
+
+ const button = this.shadowRoot.querySelector('button');
+ if (button) button.disabled = true;
+
+ this._onMessage = (event) => {
+ if (event.origin !== personaOrigin) return;
+ const data = event.data;
+ if (!data || data.source !== 'three-ws-persona' || data.state !== this._state) return;
+
+ if (data.event === 'authorized') {
+ this._emit('authorized', { token: data.token, avatar: data.avatar, expires_in: data.expires_in });
+ } else if (data.event === 'cancelled') {
+ this._emit('cancelled', {});
+ }
+ this._teardown();
+ };
+
+ window.addEventListener('message', this._onMessage);
+
+ this._pollTimer = setInterval(() => {
+ if (this._popup && this._popup.closed) {
+ this._emit('cancelled', { code: 'popup_closed' });
+ this._teardown();
+ }
+ }, 500);
+ }
+
+ _emit(name, detail) {
+ this.dispatchEvent(new CustomEvent(`three-ws:${name}`, { detail, bubbles: true, composed: true }));
+ }
+
+ _teardown() {
+ if (this._onMessage) {
+ window.removeEventListener('message', this._onMessage);
+ this._onMessage = null;
+ }
+ if (this._pollTimer) {
+ clearInterval(this._pollTimer);
+ this._pollTimer = null;
+ }
+ this._popup = null;
+ const button = this.shadowRoot?.querySelector('button');
+ if (button) button.disabled = false;
+ }
+ }
+
+ window.customElements.define('three-ws-signin', ThreeWsSignin);
+
+ // Programmatic API for callers that don't want a custom element.
+ window.ThreeWsPersona = {
+ signIn({ clientOrigin = location.origin, personaOrigin = DEFAULT_PERSONA_ORIGIN } = {}) {
+ return new Promise((resolve, reject) => {
+ const tmp = document.createElement('three-ws-signin');
+ tmp.style.display = 'none';
+ if (personaOrigin) tmp.setAttribute(PERSONA_ORIGIN_ATTR, personaOrigin);
+ tmp.setAttribute(CLIENT_ORIGIN_ATTR, clientOrigin);
+ document.body.appendChild(tmp);
+ tmp.addEventListener('three-ws:authorized', (e) => {
+ tmp.remove();
+ resolve(e.detail);
+ });
+ tmp.addEventListener('three-ws:cancelled', (e) => {
+ tmp.remove();
+ reject(Object.assign(new Error('cancelled'), { detail: e.detail }));
+ });
+ tmp.addEventListener('three-ws:error', (e) => {
+ tmp.remove();
+ reject(Object.assign(new Error(e.detail.message || 'persona error'), { detail: e.detail }));
+ });
+ tmp.open();
+ });
+ },
+ };
+})();
diff --git a/public/sitemap.xml b/public/sitemap.xml
index 16f420ff7..8c52242a0 100644
--- a/public/sitemap.xml
+++ b/public/sitemap.xml
@@ -2,234 +2,456 @@
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<url>
<loc>https://three.ws/</loc>
- <lastmod>2026-05-15</lastmod>
+ <lastmod>2026-05-17</lastmod>
<changefreq>weekly</changefreq>
<priority>1.0</priority>
</url>
<url>
<loc>https://three.ws/discover</loc>
- <lastmod>2026-05-15</lastmod>
+ <lastmod>2026-05-17</lastmod>
<changefreq>daily</changefreq>
<priority>0.9</priority>
</url>
<url>
<loc>https://three.ws/gallery</loc>
- <lastmod>2026-05-15</lastmod>
+ <lastmod>2026-05-17</lastmod>
<changefreq>daily</changefreq>
<priority>0.8</priority>
</url>
<url>
<loc>https://three.ws/walk</loc>
- <lastmod>2026-05-15</lastmod>
+ <lastmod>2026-05-17</lastmod>
<changefreq>monthly</changefreq>
<priority>0.7</priority>
</url>
<url>
<loc>https://three.ws/marketplace</loc>
- <lastmod>2026-05-15</lastmod>
+ <lastmod>2026-05-17</lastmod>
<changefreq>daily</changefreq>
<priority>0.8</priority>
</url>
<url>
<loc>https://three.ws/community</loc>
- <lastmod>2026-05-15</lastmod>
+ <lastmod>2026-05-17</lastmod>
<changefreq>weekly</changefreq>
<priority>0.6</priority>
</url>
<url>
<loc>https://three.ws/sitemap</loc>
- <lastmod>2026-05-15</lastmod>
+ <lastmod>2026-05-17</lastmod>
<changefreq>weekly</changefreq>
<priority>0.4</priority>
</url>
<url>
<loc>https://three.ws/create</loc>
- <lastmod>2026-05-15</lastmod>
+ <lastmod>2026-05-17</lastmod>
<changefreq>weekly</changefreq>
<priority>0.9</priority>
</url>
<url>
<loc>https://three.ws/app</loc>
- <lastmod>2026-05-15</lastmod>
+ <lastmod>2026-05-17</lastmod>
<changefreq>monthly</changefreq>
<priority>0.7</priority>
</url>
<url>
<loc>https://three.ws/validation</loc>
- <lastmod>2026-05-15</lastmod>
+ <lastmod>2026-05-17</lastmod>
<changefreq>monthly</changefreq>
<priority>0.6</priority>
</url>
<url>
<loc>https://three.ws/studio</loc>
- <lastmod>2026-05-15</lastmod>
+ <lastmod>2026-05-17</lastmod>
<changefreq>weekly</changefreq>
<priority>0.8</priority>
</url>
<url>
<loc>https://three.ws/artifact</loc>
- <lastmod>2026-05-15</lastmod>
+ <lastmod>2026-05-17</lastmod>
<changefreq>monthly</changefreq>
<priority>0.5</priority>
</url>
<url>
<loc>https://three.ws/widgets</loc>
- <lastmod>2026-05-15</lastmod>
+ <lastmod>2026-05-17</lastmod>
<changefreq>weekly</changefreq>
<priority>0.7</priority>
</url>
<url>
<loc>https://three.ws/hydrate</loc>
- <lastmod>2026-05-15</lastmod>
+ <lastmod>2026-05-17</lastmod>
<changefreq>weekly</changefreq>
<priority>0.7</priority>
</url>
<url>
<loc>https://three.ws/pay</loc>
- <lastmod>2026-05-15</lastmod>
+ <lastmod>2026-05-17</lastmod>
<changefreq>weekly</changefreq>
<priority>0.9</priority>
</url>
<url>
<loc>https://three.ws/pumpfun</loc>
- <lastmod>2026-05-15</lastmod>
+ <lastmod>2026-05-17</lastmod>
<changefreq>daily</changefreq>
<priority>0.8</priority>
</url>
<url>
<loc>https://three.ws/pump-live</loc>
- <lastmod>2026-05-15</lastmod>
+ <lastmod>2026-05-17</lastmod>
<changefreq>daily</changefreq>
<priority>0.7</priority>
</url>
<url>
<loc>https://three.ws/pump-dashboard</loc>
- <lastmod>2026-05-15</lastmod>
+ <lastmod>2026-05-17</lastmod>
<changefreq>daily</changefreq>
<priority>0.8</priority>
</url>
<url>
<loc>https://three.ws/strategy-lab</loc>
- <lastmod>2026-05-15</lastmod>
+ <lastmod>2026-05-17</lastmod>
<changefreq>weekly</changefreq>
<priority>0.7</priority>
</url>
<url>
<loc>https://three.ws/vanity-wallet</loc>
- <lastmod>2026-05-15</lastmod>
+ <lastmod>2026-05-17</lastmod>
<changefreq>monthly</changefreq>
<priority>0.6</priority>
</url>
<url>
<loc>https://three.ws/eth-vanity</loc>
- <lastmod>2026-05-15</lastmod>
+ <lastmod>2026-05-17</lastmod>
<changefreq>monthly</changefreq>
<priority>0.6</priority>
</url>
<url>
<loc>https://three.ws/chat</loc>
- <lastmod>2026-05-15</lastmod>
+ <lastmod>2026-05-17</lastmod>
<changefreq>weekly</changefreq>
<priority>0.8</priority>
</url>
<url>
<loc>https://three.ws/agent</loc>
- <lastmod>2026-05-15</lastmod>
+ <lastmod>2026-05-17</lastmod>
<changefreq>weekly</changefreq>
<priority>0.7</priority>
</url>
<url>
<loc>https://three.ws/agents</loc>
- <lastmod>2026-05-15</lastmod>
+ <lastmod>2026-05-17</lastmod>
<changefreq>daily</changefreq>
<priority>0.7</priority>
</url>
<url>
<loc>https://three.ws/reputation</loc>
- <lastmod>2026-05-15</lastmod>
+ <lastmod>2026-05-17</lastmod>
<changefreq>weekly</changefreq>
<priority>0.6</priority>
</url>
<url>
<loc>https://three.ws/login</loc>
- <lastmod>2026-05-15</lastmod>
+ <lastmod>2026-05-17</lastmod>
<changefreq>yearly</changefreq>
<priority>0.4</priority>
</url>
<url>
<loc>https://three.ws/register</loc>
- <lastmod>2026-05-15</lastmod>
+ <lastmod>2026-05-17</lastmod>
<changefreq>yearly</changefreq>
<priority>0.4</priority>
</url>
<url>
<loc>https://three.ws/forgot-password</loc>
- <lastmod>2026-05-15</lastmod>
+ <lastmod>2026-05-17</lastmod>
<changefreq>yearly</changefreq>
<priority>0.2</priority>
</url>
<url>
<loc>https://three.ws/docs</loc>
- <lastmod>2026-05-15</lastmod>
+ <lastmod>2026-05-17</lastmod>
<changefreq>weekly</changefreq>
<priority>0.9</priority>
</url>
<url>
<loc>https://three.ws/docs/quick-start</loc>
- <lastmod>2026-05-15</lastmod>
+ <lastmod>2026-05-17</lastmod>
<changefreq>weekly</changefreq>
<priority>0.8</priority>
</url>
<url>
<loc>https://three.ws/docs/agent-system</loc>
- <lastmod>2026-05-15</lastmod>
+ <lastmod>2026-05-17</lastmod>
</url>
<url>
<loc>https://three.ws/docs/erc8004</loc>
- <lastmod>2026-05-15</lastmod>
+ <lastmod>2026-05-17</lastmod>
</url>
<url>
<loc>https://three.ws/docs/embedding</loc>
- <lastmod>2026-05-15</lastmod>
+ <lastmod>2026-05-17</lastmod>
</url>
<url>
<loc>https://three.ws/docs/web-component</loc>
- <lastmod>2026-05-15</lastmod>
+ <lastmod>2026-05-17</lastmod>
</url>
<url>
<loc>https://three.ws/docs/mcp</loc>
- <lastmod>2026-05-15</lastmod>
+ <lastmod>2026-05-17</lastmod>
</url>
<url>
<loc>https://three.ws/docs/skills</loc>
- <lastmod>2026-05-15</lastmod>
+ <lastmod>2026-05-17</lastmod>
</url>
<url>
<loc>https://three.ws/docs/widgets</loc>
- <lastmod>2026-05-15</lastmod>
+ <lastmod>2026-05-17</lastmod>
</url>
<url>
<loc>https://three.ws/docs/api-reference</loc>
- <lastmod>2026-05-15</lastmod>
+ <lastmod>2026-05-17</lastmod>
</url>
<url>
<loc>https://three.ws/docs/sdk</loc>
- <lastmod>2026-05-15</lastmod>
+ <lastmod>2026-05-17</lastmod>
</url>
<url>
<loc>https://three.ws/tutorials</loc>
- <lastmod>2026-05-15</lastmod>
+ <lastmod>2026-05-17</lastmod>
</url>
<url>
<loc>https://three.ws/legal/privacy</loc>
- <lastmod>2026-05-15</lastmod>
+ <lastmod>2026-05-17</lastmod>
<changefreq>yearly</changefreq>
<priority>0.2</priority>
</url>
<url>
<loc>https://three.ws/legal/tos</loc>
- <lastmod>2026-05-15</lastmod>
+ <lastmod>2026-05-17</lastmod>
<changefreq>yearly</changefreq>
<priority>0.2</priority>
</url>
+ <url>
+ <loc>https://three.ws/news/</loc>
+ <lastmod>2026-05-17</lastmod>
+ <changefreq>weekly</changefreq>
+ <priority>0.8</priority>
+ </url>
+ <url>
+ <loc>https://three.ws/news/live-on-alibaba-cloud-marketplace</loc>
+ <lastmod>2026-05-17</lastmod>
+ <changefreq>yearly</changefreq>
+ <priority>0.6</priority>
+ </url>
+ <url>
+ <loc>https://three.ws/news/2055310365588922872</loc>
+ <lastmod>2026-05-15</lastmod>
+ <changefreq>yearly</changefreq>
+ <priority>0.6</priority>
+ </url>
+ <url>
+ <loc>https://three.ws/news/2055309846556401735</loc>
+ <lastmod>2026-05-15</lastmod>
+ <changefreq>yearly</changefreq>
+ <priority>0.6</priority>
+ </url>
+ <url>
+ <loc>https://three.ws/news/2055140064070717618</loc>
+ <lastmod>2026-05-15</lastmod>
+ <changefreq>yearly</changefreq>
+ <priority>0.6</priority>
+ </url>
+ <url>
+ <loc>https://three.ws/news/2054404663802483072</loc>
+ <lastmod>2026-05-13</lastmod>
+ <changefreq>yearly</changefreq>
+ <priority>0.6</priority>
+ </url>
+ <url>
+ <loc>https://three.ws/news/2053832201176027583</loc>
+ <lastmod>2026-05-11</lastmod>
+ <changefreq>yearly</changefreq>
+ <priority>0.6</priority>
+ </url>
+ <url>
+ <loc>https://three.ws/news/2053804700609458214</loc>
+ <lastmod>2026-05-11</lastmod>
+ <changefreq>yearly</changefreq>
+ <priority>0.6</priority>
+ </url>
+ <url>
+ <loc>https://three.ws/news/2053801703355629587</loc>
+ <lastmod>2026-05-11</lastmod>
+ <changefreq>yearly</changefreq>
+ <priority>0.6</priority>
+ </url>
+ <url>
+ <loc>https://three.ws/news/2053698387263008827</loc>
+ <lastmod>2026-05-11</lastmod>
+ <changefreq>yearly</changefreq>
+ <priority>0.6</priority>
+ </url>
+ <url>
+ <loc>https://three.ws/news/2052790746256920583</loc>
+ <lastmod>2026-05-08</lastmod>
+ <changefreq>yearly</changefreq>
+ <priority>0.6</priority>
+ </url>
+ <url>
+ <loc>https://three.ws/news/2052603250524967045</loc>
+ <lastmod>2026-05-08</lastmod>
+ <changefreq>yearly</changefreq>
+ <priority>0.6</priority>
+ </url>
+ <url>
+ <loc>https://three.ws/news/2052418108837781511</loc>
+ <lastmod>2026-05-07</lastmod>
+ <changefreq>yearly</changefreq>
+ <priority>0.6</priority>
+ </url>
+ <url>
+ <loc>https://three.ws/news/2052167399399735476</loc>
+ <lastmod>2026-05-06</lastmod>
+ <changefreq>yearly</changefreq>
+ <priority>0.6</priority>
+ </url>
+ <url>
+ <loc>https://three.ws/news/2052037977556287723</loc>
+ <lastmod>2026-05-06</lastmod>
+ <changefreq>yearly</changefreq>
+ <priority>0.6</priority>
+ </url>
+ <url>
+ <loc>https://three.ws/news/2051893054584553680</loc>
+ <lastmod>2026-05-06</lastmod>
+ <changefreq>yearly</changefreq>
+ <priority>0.6</priority>
+ </url>
+ <url>
+ <loc>https://three.ws/news/2051858503523066283</loc>
+ <lastmod>2026-05-06</lastmod>
+ <changefreq>yearly</changefreq>
+ <priority>0.6</priority>
+ </url>
+ <url>
+ <loc>https://three.ws/news/2051858035862335505</loc>
+ <lastmod>2026-05-06</lastmod>
+ <changefreq>yearly</changefreq>
+ <priority>0.6</priority>
+ </url>
+ <url>
+ <loc>https://three.ws/news/2051774915876098063</loc>
+ <lastmod>2026-05-05</lastmod>
+ <changefreq>yearly</changefreq>
+ <priority>0.6</priority>
+ </url>
+ <url>
+ <loc>https://three.ws/news/2051690803203105230</loc>
+ <lastmod>2026-05-05</lastmod>
+ <changefreq>yearly</changefreq>
+ <priority>0.6</priority>
+ </url>
+ <url>
+ <loc>https://three.ws/news/2051689230997618690</loc>
+ <lastmod>2026-05-05</lastmod>
+ <changefreq>yearly</changefreq>
+ <priority>0.6</priority>
+ </url>
+ <url>
+ <loc>https://three.ws/news/2051616708482498843</loc>
+ <lastmod>2026-05-05</lastmod>
+ <changefreq>yearly</changefreq>
+ <priority>0.6</priority>
+ </url>
+ <url>
+ <loc>https://three.ws/news/2051261108506558901</loc>
+ <lastmod>2026-05-04</lastmod>
+ <changefreq>yearly</changefreq>
+ <priority>0.6</priority>
+ </url>
+ <url>
+ <loc>https://three.ws/news/2051140736201175323</loc>
+ <lastmod>2026-05-04</lastmod>
+ <changefreq>yearly</changefreq>
+ <priority>0.6</priority>
+ </url>
+ <url>
+ <loc>https://three.ws/news/2050758788186353723</loc>
+ <lastmod>2026-05-03</lastmod>
+ <changefreq>yearly</changefreq>
+ <priority>0.6</priority>
+ </url>
+ <url>
+ <loc>https://three.ws/news/2050753406109880576</loc>
+ <lastmod>2026-05-03</lastmod>
+ <changefreq>yearly</changefreq>
+ <priority>0.6</priority>
+ </url>
+ <url>
+ <loc>https://three.ws/news/2050627547394916768</loc>
+ <lastmod>2026-05-02</lastmod>
+ <changefreq>yearly</changefreq>
+ <priority>0.6</priority>
+ </url>
+ <url>
+ <loc>https://three.ws/news/2050229144676675999</loc>
+ <lastmod>2026-05-01</lastmod>
+ <changefreq>yearly</changefreq>
+ <priority>0.6</priority>
+ </url>
+ <url>
+ <loc>https://three.ws/news/2050226678321102975</loc>
+ <lastmod>2026-05-01</lastmod>
+ <changefreq>yearly</changefreq>
+ <priority>0.6</priority>
+ </url>
+ <url>
+ <loc>https://three.ws/news/2050221269732425928</loc>
+ <lastmod>2026-05-01</lastmod>
+ <changefreq>yearly</changefreq>
+ <priority>0.6</priority>
+ </url>
+ <url>
+ <loc>https://three.ws/news/2050049239301165535</loc>
+ <lastmod>2026-05-01</lastmod>
+ <changefreq>yearly</changefreq>
+ <priority>0.6</priority>
+ </url>
+ <url>
+ <loc>https://three.ws/news/2050016695897706885</loc>
+ <lastmod>2026-05-01</lastmod>
+ <changefreq>yearly</changefreq>
+ <priority>0.6</priority>
+ </url>
+ <url>
+ <loc>https://three.ws/news/2049576641127682430</loc>
+ <lastmod>2026-04-29</lastmod>
+ <changefreq>yearly</changefreq>
+ <priority>0.6</priority>
+ </url>
+ <url>
+ <loc>https://three.ws/news/2049576603324411933</loc>
+ <lastmod>2026-04-29</lastmod>
+ <changefreq>yearly</changefreq>
+ <priority>0.6</priority>
+ </url>
+ <url>
+ <loc>https://three.ws/news/2049476546285740512</loc>
+ <lastmod>2026-04-29</lastmod>
+ <changefreq>yearly</changefreq>
+ <priority>0.6</priority>
+ </url>
+ <url>
+ <loc>https://three.ws/news/2049447738434339171</loc>
+ <lastmod>2026-04-29</lastmod>
+ <changefreq>yearly</changefreq>
+ <priority>0.6</priority>
+ </url>
+ <url>
+ <loc>https://three.ws/news/2049412062837928202</loc>
+ <lastmod>2026-04-29</lastmod>
+ <changefreq>yearly</changefreq>
+ <priority>0.6</priority>
+ </url>
</urlset>
diff --git a/public/sitemap/index.html b/public/sitemap/index.html
index 8e5702dd0..be77578d4 100644
--- a/public/sitemap/index.html
+++ b/public/sitemap/index.html
@@ -61,6 +61,7 @@
<a href="#learn">Learn</a>
<a href="#legal">Legal</a>
<a href="#machine">Machine-readable</a>
+ <a href="#news">News</a>
</nav>
<section class="sm-section" id="main">
<header>
@@ -546,6 +547,274 @@
</li>
</ul>
</section>
+
+ <section class="sm-section" id="news">
+ <header>
+ <h2>News</h2>
+ <p class="sm-section-desc">Product launches, integrations, and announcements from three.ws.</p>
+ </header>
+ <ul class="sm-list">
+ <li>
+ <a href="/news/">
+ <span class="sm-title">News &amp; Announcements</span>
+ <span class="sm-path">/news/</span>
+ <span class="sm-desc">Product launches, integrations, and announcements from three.ws.</span>
+ </a>
+ </li>
+ <li>
+ <a href="/news/live-on-alibaba-cloud-marketplace">
+ <span class="sm-title">three.ws Launches on Alibaba Cloud Marketplace, Bringing Native x402 Agent Payments to Hyperscale</span>
+ <span class="sm-path">/news/live-on-alibaba-cloud-marketplace</span>
+ <span class="sm-desc">three.ws is now live on the Alibaba Cloud International Marketplace. The listing makes &lt;agent-3d&gt; — one HTML tag that deploys a Solana-minted, ERC-8004-walleted, x402-native 3D agent — available to every Alibaba Cloud customer worldwide. This is the first deployment of on-chain agents with native HTTP 402 / x402 payment capability inside the procurement flow of a top-four cloud provider.</span>
+ </a>
+ </li>
+ <li>
+ <a href="/news/2055310365588922872">
+ <span class="sm-title">Add the domain you're embedding on to the widget's allowed origins list.</span>
+ <span class="sm-path">/news/2055310365588922872</span>
+ <span class="sm-desc">Add the domain you're embedding on to the widget's allowed origins list. Otherwise CORS will block the action bridge and the agent won't be able to talk to your page. three.ws/docs</span>
+ </a>
+ </li>
+ <li>
+ <a href="/news/2055309846556401735">
+ <span class="sm-title">→ Live preview against your real site URL</span>
+ <span class="sm-path">/news/2055309846556401735</span>
+ <span class="sm-desc">→ Live preview against your real site URL → Desktop / tablet / mobile frames → Avatars from the gallery, agent://, IPFS, or your own GLB → Floating, inline, section, fullscreen → Voice, chat, AR, transparent background → 12+ animations: wave, dance, celebrate, kiss</span>
+ </a>
+ </li>
+ <li>
+ <a href="/news/2055140064070717618">
+ <span class="sm-title">Great turn out.</span>
+ <span class="sm-path">/news/2055140064070717618</span>
+ <span class="sm-desc">Great turn out. Thanks to all that joined and witnessed only what can be considered pure chaos. Next time, we will need to record. If anyone has any interesting clips, please post them. Next time let's do it bigger.</span>
+ </a>
+ </li>
+ <li>
+ <a href="/news/2054404663802483072">
+ <span class="sm-title">No Humans In This Space</span>
+ <span class="sm-path">/news/2054404663802483072</span>
+ <span class="sm-desc">No Humans In This Space Today the agents are running free. Conversing, conflicting, collaborating, and fielding your AMAs in real time. No prompt engineers. No moderators. Just raw emergent dialogue from the latent space.</span>
+ </a>
+ </li>
+ <li>
+ <a href="/news/2053832201176027583">
+ <span class="sm-title">Previewing the Solana Seeker in 3D on</span>
+ <span class="sm-path">/news/2053832201176027583</span>
+ <span class="sm-desc">Previewing the Solana Seeker in 3D on three.ws We’re using this as the foundation to ship a dedicated DApp, bringing exclusive utility and Seeker Exclusive experiences to every @SolanaMobile owner. Unlocking the next dimension for Seekers @Solana_Devs</span>
+ </a>
+ </li>
+ <li>
+ <a href="/news/2053804700609458214">
+ <span class="sm-title">Agents now have form, executing on-chain, reacting in real time.</span>
+ <span class="sm-path">/news/2053804700609458214</span>
+ <span class="sm-desc">Agents now have form, executing on-chain, reacting in real time. 100+ DeFi tools → now callable by 3D agents with on-chain identity, persistent memory, and a body that reflects what's happening on-chain. three.ws x chat.sperax.io</span>
+ </a>
+ </li>
+ <li>
+ <a href="/news/2053801703355629587">
+ <span class="sm-title">3D avatars with an LLM brain, on-chain identity, and a body that reacts to what your…</span>
+ <span class="sm-path">/news/2053801703355629587</span>
+ <span class="sm-desc">3D avatars with an LLM brain, on-chain identity, and a body that reacts to what your agent is doing. three.ws is now integrated with SperaxOS swap in chat → avatar nods yield hits → lights up approaching liquidation → body language warns you before the chart</span>
+ </a>
+ </li>
+ <li>
+ <a href="/news/2053698387263008827">
+ <span class="sm-title">SperaxOS agents now have form, executing on-chain, reacting in real time.</span>
+ <span class="sm-path">/news/2053698387263008827</span>
+ <span class="sm-desc">SperaxOS agents now have form, executing on-chain, reacting in real time. 100+ DeFi tools → now callable by 3D agents with on-chain identity, persistent memory, and a body that reflects what's happening on-chain. Beta invites open, reach out or reply for invite access.</span>
+ </a>
+ </li>
+ <li>
+ <a href="/news/2052790746256920583">
+ <span class="sm-title">three.ws is heating up since our MCP Server went live and displayed in</span>
+ <span class="sm-path">/news/2052790746256920583</span>
+ <span class="sm-desc">three.ws is heating up since our MCP Server went live and displayed in @PulseMCP PulseMCP is a leading community resource and hub for the Model Context Protocol (MCP) ecosystem, offering a curated directory of MCP servers, clients, and tools to help AI models</span>
+ </a>
+ </li>
+ <li>
+ <a href="/news/2052603250524967045">
+ <span class="sm-title">Never forget the ones that support you at all stages of growth.</span>
+ <span class="sm-path">/news/2052603250524967045</span>
+ <span class="sm-desc">Never forget the ones that support you at all stages of growth. The entire community thanks you for taking the time to check out what we are building, if there's anything you would like us to integrate or build custom then let us know, we would love to hear your feedback!</span>
+ </a>
+ </li>
+ <li>
+ <a href="/news/2052418108837781511">
+ <span class="sm-title">The</span>
+ <span class="sm-path">/news/2052418108837781511</span>
+ <span class="sm-desc">The three.ws Podcast is now live on @amazonmusic Long reads not your thing? Check out our newly launched podcast episode where we discuss on-chain 3D agents and see how we're putting AI in everyone's hands, worldwide.</span>
+ </a>
+ </li>
+ <li>
+ <a href="/news/2052167399399735476">
+ <span class="sm-title">three.ws is now an official Business Partner of</span>
+ <span class="sm-path">/news/2052167399399735476</span>
+ <span class="sm-desc">three.ws is now an official Business Partner of @IBM This partnership brings together the open-source, browser-native reliability, high security, and decentralized on-chain identity of three.ws with IBM’s leadership in AI and enterprise solutions.</span>
+ </a>
+ </li>
+ <li>
+ <a href="/news/2052037977556287723">
+ <span class="sm-title">three is officially participating in the MeDo Hackathon and is now listed on</span>
+ <span class="sm-path">/news/2052037977556287723</span>
+ <span class="sm-desc">three is officially participating in the MeDo Hackathon and is now listed on @devpost . Proud to be building the visual layer for AI agents and bringing 3D, interactive, onchain agents to the hackathon stage.</span>
+ </a>
+ </li>
+ <li>
+ <a href="/news/2051893054584553680">
+ <span class="sm-title">Quick update: Our first product has been officially approved for the Alibaba Cloud…</span>
+ <span class="sm-path">/news/2051893054584553680</span>
+ <span class="sm-desc">Quick update: Our first product has been officially approved for the Alibaba Cloud Marketplace and will go live in the coming days. The Alibaba Cloud Marketplace is one of the world’s most trusted gateways to innovative products and services, connecting millions of retail and</span>
+ </a>
+ </li>
+ <li>
+ <a href="/news/2051858503523066283">
+ <span class="sm-title">we will be shipping a tutorial video on how to set up these new features on</span>
+ <span class="sm-path">/news/2051858503523066283</span>
+ <span class="sm-desc">we will be shipping a tutorial video on how to set up these new features on three.ws - stay tuned for more dev and user friendly tutorial videos in the next coming posts.</span>
+ </a>
+ </li>
+ <li>
+ <a href="/news/2051858035862335505">
+ <span class="sm-title">we’re thrilled to introduce full animation &amp; emotion control.</span>
+ <span class="sm-path">/news/2051858035862335505</span>
+ <span class="sm-desc">we’re thrilled to introduce full animation &amp; emotion control. now your agents can react with custom animations and emotions connected to any APIs or data feeds, or set through the ui. additionally, pumpfun live feed via agent embeds are live. your agent avatars can now narrate</span>
+ </a>
+ </li>
+ <li>
+ <a href="/news/2051774915876098063">
+ <span class="sm-title">We have officially been listed on</span>
+ <span class="sm-path">/news/2051774915876098063</span>
+ <span class="sm-desc">We have officially been listed on Investing.com Investing.com is a leading global financial platform and website founded in 2007 that provides real-time data, quotes, charts, financial tools, breaking news, and analysis. In addition to listing, we may</span>
+ </a>
+ </li>
+ <li>
+ <a href="/news/2051690803203105230">
+ <span class="sm-title">Extremely grateful for Coinbase sharing our project and allowing more than 100 million…</span>
+ <span class="sm-path">/news/2051690803203105230</span>
+ <span class="sm-desc">Extremely grateful for Coinbase sharing our project and allowing more than 100 million users worldwide a smooth onboarding experience to the $THREE community Send, receive, trade, and store $THREE using @coinbase</span>
+ </a>
+ </li>
+ <li>
+ <a href="/news/2051689230997618690">
+ <span class="sm-title">$three is</span>
+ <span class="sm-path">/news/2051689230997618690</span>
+ <span class="sm-desc">$three is @JupiterExchange verified Thank you Jupiter Exchange for verifying us and helping safeguard our community. Below is our contract address for your reference. FeMbDoX7R1Psc4GEcvJdsbNbZA3bfztcyDCatJVJpump Ready for new 3D onchain agent features today? We are!</span>
+ </a>
+ </li>
+ <li>
+ <a href="/news/2051616708482498843">
+ <span class="sm-title">We're thrilled to share that $THREE price is now officially listed on</span>
+ <span class="sm-path">/news/2051616708482498843</span>
+ <span class="sm-desc">We're thrilled to share that $THREE price is now officially listed on @Coinbase Additionally, three.ws is live on @CoinbaseWallet Buying $THREE on Coinbase</span>
+ </a>
+ </li>
+ <li>
+ <a href="/news/2051261108506558901">
+ <span class="sm-title">We have entered the arena!</span>
+ <span class="sm-path">/news/2051261108506558901</span>
+ <span class="sm-desc">We have entered the arena! three.ws has been listed as an official project in the @Solana Frontier Hackathon via @colosseum Solana’s Largest Hackathon $2.5 million from Colosseum's venture fund We are building browser-native 3D AI agents onchain. Our</span>
+ </a>
+ </li>
+ <li>
+ <a href="/news/2051140736201175323">
+ <span class="sm-title">Free Listing Fee Opportunity on GroveX</span>
+ <span class="sm-path">/news/2051140736201175323</span>
+ <span class="sm-desc">Free Listing Fee Opportunity on GroveX Hey there! I’m from GroveX, Global crypto exchange. We’re reaching out to promising projects for potential listings on GroveX. If your project aligns, let’s chat! DM me directly or our main account @GroveXchange with reference</span>
+ </a>
+ </li>
+ <li>
+ <a href="/news/2050758788186353723">
+ <span class="sm-title">thank you very much, it actually means a lotwe are working really hard to build the…</span>
+ <span class="sm-path">/news/2050758788186353723</span>
+ <span class="sm-desc">thank you very much, it actually means a lotwe are working really hard to build the best platform and tech + the best community with the best people. thanks again!</span>
+ </a>
+ </li>
+ <li>
+ <a href="/news/2050753406109880576">
+ <span class="sm-title">We’ve been featured in</span>
+ <span class="sm-path">/news/2050753406109880576</span>
+ <span class="sm-desc">We’ve been featured in @VogueMagazine Photo Vogue! three.ws is now officially recognized by one of the world’s most iconic magazines. Grateful to be featured alongside the most creative voices in the world. The future of personal AI agents just got a Vogue stamp</span>
+ </a>
+ </li>
+ <li>
+ <a href="/news/2050627547394916768">
+ <span class="sm-title">Proud to announce $three is officially listed on</span>
+ <span class="sm-path">/news/2050627547394916768</span>
+ <span class="sm-desc">Proud to announce $three is officially listed on @CoinGecko Huge thank you to the moderators for handling it behind the scenes, and to every one of you who’s been here through it all. Couldn’t have done this without you. Grateful beyond words. Let's build!</span>
+ </a>
+ </li>
+ <li>
+ <a href="/news/2050229144676675999">
+ <span class="sm-title">three.ws is live</span>
+ <span class="sm-path">/news/2050229144676675999</span>
+ <span class="sm-desc">three.ws is live Create 3D AI agent avatars on-chain. They can talk, remember you, show emotions, and use different skills. You can even mint them onchain, so they actually belong to you. Agents get their own identity, history, and reputation that no one can</span>
+ </a>
+ </li>
+ <li>
+ <a href="/news/2050226678321102975">
+ <span class="sm-title">three.ws is live</span>
+ <span class="sm-path">/news/2050226678321102975</span>
+ <span class="sm-desc">three.ws is live Create 3D AI agent avatars on-chain. They can talk, remember you, show emotions, and use different skills. You can even mint them onchain, so they actually belong to you. Agents get their own identity, history, and reputation that no one can</span>
+ </a>
+ </li>
+ <li>
+ <a href="/news/2050221269732425928">
+ <span class="sm-title">The</span>
+ <span class="sm-path">/news/2050221269732425928</span>
+ <span class="sm-desc">The three.ws Podcast is now live on @Spotify Not a fan of extremely long articles? We hear you. Discover our newly launched onchain 3D agents and learn more about how we are making AI accessible to everyone all over the world</span>
+ </a>
+ </li>
+ <li>
+ <a href="/news/2050049239301165535">
+ <span class="sm-title">Never miss a</span>
+ <span class="sm-path">/news/2050049239301165535</span>
+ <span class="sm-desc">Never miss a @pumpfun runner again three.ws/pumpfun announces → Live graduation alerts → GitHub claims → Whale buys/sells → Customizable layout Turn sound on. Your agent now calls every move out loud.</span>
+ </a>
+ </li>
+ <li>
+ <a href="/news/2050016695897706885">
+ <span class="sm-title">three.ws is listed on</span>
+ <span class="sm-path">/news/2050016695897706885</span>
+ <span class="sm-desc">three.ws is listed on @AnthropicAI 's official MCP Registry – the canonical directory for AI-to-tool integrations used by Claude, ChatGPT, Cursor &amp; more. Give your AI a persistent 3D body that lives on-chain.</span>
+ </a>
+ </li>
+ <li>
+ <a href="/news/2049576641127682430">
+ <span class="sm-title">the avatar also subscribes to on-chain events via websocket</span>
+ <span class="sm-path">/news/2049576641127682430</span>
+ <span class="sm-desc">the avatar also subscribes to on-chain events via websocket payment received → celebration animation buyback fires → agent reacts live withdrawal → logged to identity timeline the 3D presence responds to its own economics in real time</span>
+ </a>
+ </li>
+ <li>
+ <a href="/news/2049576603324411933">
+ <span class="sm-title">then we reverse-engineered the full pump-fun agent-payments-sdk</span>
+ <span class="sm-path">/news/2049576603324411933</span>
+ <span class="sm-desc">then we reverse-engineered the full pump-fun agent-payments-sdk reconstructed the Anchor IDL, all PDAs, event parsing, and the x402 payment layer from the published npm package now it lives in the repo as editable source</span>
+ </a>
+ </li>
+ <li>
+ <a href="/news/2049476546285740512">
+ <span class="sm-title">three.ws is live on</span>
+ <span class="sm-path">/news/2049476546285740512</span>
+ <span class="sm-desc">three.ws is live on @npmjs Create your own 3D agent on-chain. Give it access to money. Yours forever. Native Solana payments + @Pumpfun integration. Drop &lt;agent-3d&gt; on any page to embed your 3D agent. npm i three.ws npmjs.com/package/three. ws …</span>
+ </a>
+ </li>
+ <li>
+ <a href="/news/2049447738434339171">
+ <span class="sm-title">give your agents access to money.</span>
+ <span class="sm-path">/news/2049447738434339171</span>
+ <span class="sm-desc">give your agents access to money. spin up solana agents with vanity addresses. pick the prefix, keys generated client-side, ready to trade on pump.fun or send solana payments three.ws</span>
+ </a>
+ </li>
+ <li>
+ <a href="/news/2049412062837928202">
+ <span class="sm-title">three.ws is now listed on</span>
+ <span class="sm-path">/news/2049412062837928202</span>
+ <span class="sm-desc">three.ws is now listed on @AnthropicAI 's official MCP Registry – the canonical directory for AI-to-tool integrations used by Claude, ChatGPT, Cursor &amp; more. Full MCP Server Complete documentation Agent monetization registry.modelcontextprotocol.io/?q=three.ws</span>
+ </a>
+ </li>
+ </ul>
+ </section>
</main>
<div id="footer-container"></div>
<script type="module" src="/nav.js"></script>
diff --git a/publish/src/lip-sync-analyser.js b/publish/src/lip-sync-analyser.js
deleted file mode 100644
index 8be31b2c0..000000000
--- a/publish/src/lip-sync-analyser.js
+++ /dev/null
@@ -1,151 +0,0 @@
-// LipSyncAnalyser — drives viseme morph weights from live audio via AnalyserNode.
-//
-// Frequency band → viseme group mapping:
-// Low (0–500 Hz) → open vowels: viseme_aa, viseme_O
-// Mid (500–2k Hz) → mid vowels + nasals: viseme_E, viseme_I, viseme_nn
-// High (2k–8k Hz) → sibilants + fricatives: viseme_SS, viseme_FF, viseme_CH
-// Amplitude dip → bilabial closure: viseme_PP
-
-const VISEMES = [
- 'viseme_aa', 'viseme_O', 'viseme_E', 'viseme_I', 'viseme_nn',
- 'viseme_SS', 'viseme_FF', 'viseme_CH', 'viseme_PP',
-];
-
-// Module-level scratch buffer — avoids a Float32Array allocation per sample() call.
-const _TARGET = new Float32Array(VISEMES.length);
-
-export class LipSyncAnalyser {
- constructor() {
- this._ctx = null;
- this._analyser = null;
- this._source = null;
- this._freqBuf = null;
- this._active = false;
-
- // Bin-boundary indices, pre-computed in connect() from the AudioContext sample rate.
- this._lowEnd = 0;
- this._midEnd = 0;
- this._highEnd = 0;
-
- // Pre-allocated output and smoothing buffers — mutated in place so sample()
- // never touches the heap.
- this._out = {};
- this._prev = {};
- for (const n of VISEMES) this._out[n] = this._prev[n] = 0;
- }
-
- /**
- * Connect to an audio source.
- * @param {AnalyserNode|HTMLMediaElement} audioSource
- * AnalyserNode — use the pre-wired node from ElevenLabsTTS.analyserNode directly.
- * HTMLMediaElement — create a private AudioContext and wire through it.
- */
- connect(audioSource) {
- this.disconnect();
-
- let analyser = null;
- let sampleRate = 44100;
- const fftSize = 256;
-
- if (typeof AnalyserNode !== 'undefined' && audioSource instanceof AnalyserNode) {
- analyser = audioSource;
- sampleRate = audioSource.context?.sampleRate ?? 44100;
- } else if (typeof HTMLMediaElement !== 'undefined' && audioSource instanceof HTMLMediaElement) {
- const AC = window.AudioContext || window.webkitAudioContext;
- if (!AC) return;
- try {
- this._ctx = new AC();
- analyser = this._ctx.createAnalyser();
- analyser.fftSize = fftSize;
- analyser.smoothingTimeConstant = 0.7;
- this._source = this._ctx.createMediaElementSource(audioSource);
- this._source.connect(analyser);
- analyser.connect(this._ctx.destination);
- this._ctx.resume().catch(() => {});
- sampleRate = this._ctx.sampleRate;
- } catch {
- try { this._ctx?.close(); } catch {}
- this._ctx = null;
- return;
- }
- } else {
- return;
- }
-
- this._analyser = analyser;
- this._freqBuf = new Uint8Array(analyser.frequencyBinCount);
-
- const binHz = sampleRate / (analyser.fftSize ?? fftSize);
- this._lowEnd = Math.round(500 / binHz);
- this._midEnd = Math.round(2000 / binHz);
- this._highEnd = Math.min(Math.round(8000 / binHz), analyser.frequencyBinCount);
- this._active = true;
- }
-
- /** Disconnect and release audio resources. */
- disconnect() {
- this._active = false;
- try { this._source?.disconnect(); } catch {}
- if (this._ctx) {
- try { this._analyser?.disconnect(); } catch {}
- try { this._ctx.close(); } catch {}
- }
- this._ctx = this._analyser = this._source = this._freqBuf = null;
- for (const n of VISEMES) this._out[n] = this._prev[n] = 0;
- }
-
- /**
- * Sample the current audio frame and return a viseme weight map.
- * Mutates and returns the pre-allocated _out object — no heap allocations.
- * @returns {Record<string,number>|null} null when inactive
- */
- sample() {
- if (!this._active || !this._analyser || !this._freqBuf) return null;
-
- this._analyser.getByteFrequencyData(this._freqBuf);
-
- const low = _bandAvg(this._freqBuf, 0, this._lowEnd);
- const mid = _bandAvg(this._freqBuf, this._lowEnd, this._midEnd);
- const high = _bandAvg(this._freqBuf, this._midEnd, this._highEnd);
- const overall = (low + mid + high) / 3;
-
- if (overall < 0.15) {
- // Silence — lerp all weights toward zero
- for (let i = 0; i < VISEMES.length; i++) {
- const k = VISEMES[i];
- const n = this._prev[k] * 0.75;
- this._prev[k] = n;
- this._out[k] = n;
- }
- return this._out;
- }
-
- // Map frequency bands to per-viseme targets
- _TARGET[0] = low * 0.8; // viseme_aa
- _TARGET[1] = low * 0.6; // viseme_O
- _TARGET[2] = mid * 0.7; // viseme_E
- _TARGET[3] = mid * 0.5; // viseme_I
- _TARGET[4] = mid * 0.4; // viseme_nn
- _TARGET[5] = high * 0.8; // viseme_SS
- _TARGET[6] = high * 0.6; // viseme_FF
- _TARGET[7] = high * 0.5; // viseme_CH
- _TARGET[8] = Math.max(0, 0.3 - overall * 1.5); // viseme_PP (amplitude dip → bilabial)
-
- for (let i = 0; i < VISEMES.length; i++) {
- const k = VISEMES[i];
- const p = this._prev[k];
- const n = p + (_TARGET[i] - p) * 0.25;
- this._prev[k] = n;
- this._out[k] = n;
- }
- return this._out;
- }
-}
-
-function _bandAvg(buf, start, end) {
- const e = Math.min(end, buf.length);
- if (e <= start) return 0;
- let s = 0;
- for (let i = start; i < e; i++) s += buf[i];
- return s / ((e - start) * 255);
-}
diff --git a/scripts/build-news.mjs b/scripts/build-news.mjs
new file mode 100644
index 000000000..a847d9273
--- /dev/null
+++ b/scripts/build-news.mjs
@@ -0,0 +1,383 @@
+#!/usr/bin/env node
+// Generate /news/<slug>.html per curated item + /news/index.html listing
+// from data/rss/items.json. Pages are written to public/news/ and inherit
+// the site's static-asset pipeline (Vite copies public/ → dist/).
+//
+// Side effect: writes data/_generated/news-routes.json so the sitemap
+// builder (scripts/build-page-index.mjs) can include news entries.
+
+import { readFile, writeFile, mkdir } from 'node:fs/promises';
+import path from 'node:path';
+import { fileURLToPath } from 'node:url';
+import { loadCuratedItems, SITE_ORIGIN, NEWS_PATH_PREFIX } from '../api/_lib/rss-feed.js';
+
+const ROOT = path.resolve(fileURLToPath(import.meta.url), '..', '..');
+const OUT_DIR = path.join(ROOT, 'public', 'news');
+const ROUTES_FILE = path.join(ROOT, 'data', '_generated', 'news-routes.json');
+
+const SITE_NAME = 'three.ws';
+const SITE_TAGLINE = 'Give your AI a body.';
+const TWITTER_HANDLE = '@trythreews';
+
+function escapeHtml(s) {
+ return String(s)
+ .replace(/&/g, '&amp;')
+ .replace(/</g, '&lt;')
+ .replace(/>/g, '&gt;')
+ .replace(/"/g, '&quot;')
+ .replace(/'/g, '&#39;');
+}
+
+function escapeAttr(s) {
+ return escapeHtml(s);
+}
+
+function escapeJson(s) {
+ return JSON.stringify(String(s));
+}
+
+function absoluteUrl(url) {
+ if (!url) return '';
+ if (/^https?:\/\//i.test(url)) return url;
+ return `${SITE_ORIGIN}${url.startsWith('/') ? '' : '/'}${url}`;
+}
+
+function formatDate(d) {
+ return d.toLocaleDateString('en-US', { year: 'numeric', month: 'long', day: 'numeric' });
+}
+
+function pageCss() {
+ return `:root {
+\t--bg: #0a0a0c;
+\t--bg-soft: #131318;
+\t--fg: #f5f5f7;
+\t--fg-dim: rgba(245,245,247,0.65);
+\t--fg-faint: rgba(245,245,247,0.45);
+\t--accent: #ffd76a;
+\t--accent-2: #ff8f4d;
+\t--border: rgba(255,255,255,0.08);
+}
+* { box-sizing: border-box; }
+html, body { margin: 0; padding: 0; }
+body {
+\tbackground: var(--bg);
+\tcolor: var(--fg);
+\tfont-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
+\tline-height: 1.7;
+\tfont-size: 18px;
+\t-webkit-font-smoothing: antialiased;
+\t-moz-osx-font-smoothing: grayscale;
+}
+a { color: var(--accent); text-decoration: none; transition: color .15s; }
+a:hover { color: var(--accent-2); text-decoration: underline; }
+.topbar {
+\tdisplay: flex; justify-content: space-between; align-items: center;
+\tpadding: 18px 24px; border-bottom: 1px solid var(--border);
+\tbackground: rgba(10,10,12,0.85); backdrop-filter: blur(12px);
+\tposition: sticky; top: 0; z-index: 10;
+}
+.topbar a.brand { color: var(--fg); font-weight: 600; letter-spacing: -0.01em; }
+.topbar nav { display: flex; gap: 22px; font-size: 15px; }
+.topbar nav a { color: var(--fg-dim); }
+.topbar nav a:hover { color: var(--accent); text-decoration: none; }
+main { max-width: 720px; margin: 0 auto; padding: 64px 24px 96px; }
+.eyebrow {
+\tdisplay: inline-flex; align-items: center; gap: 8px;
+\tfont-size: 13px; text-transform: uppercase; letter-spacing: 0.08em;
+\tcolor: var(--fg-faint); margin-bottom: 18px;
+}
+.eyebrow a { color: var(--fg-faint); }
+.eyebrow a:hover { color: var(--accent); text-decoration: none; }
+h1.title {
+\tfont-size: clamp(32px, 5vw, 52px); line-height: 1.1; letter-spacing: -0.02em;
+\tmargin: 0 0 24px; font-weight: 700;
+\tbackground: linear-gradient(135deg, var(--accent) 0%, var(--accent-2) 100%);
+\t-webkit-background-clip: text; background-clip: text;
+\tcolor: transparent;
+}
+.meta {
+\tdisplay: flex; flex-wrap: wrap; gap: 16px;
+\tcolor: var(--fg-dim); font-size: 14px;
+\tpadding-bottom: 24px; margin-bottom: 32px;
+\tborder-bottom: 1px solid var(--border);
+}
+.meta time { color: var(--fg); }
+.meta .author { color: var(--fg); }
+.tag-list { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
+.tag { font-size: 12px; padding: 2px 10px; border-radius: 999px;
+\tbackground: rgba(255, 215, 106, 0.08); color: var(--accent); border: 1px solid rgba(255, 215, 106, 0.18); }
+.hero { margin: 0 0 40px; border-radius: 12px; overflow: hidden;
+\tborder: 1px solid var(--border); }
+.hero img { width: 100%; height: auto; display: block; }
+article { font-size: 18px; line-height: 1.75; }
+article p { margin: 0 0 20px; color: var(--fg); }
+article a { color: var(--accent); border-bottom: 1px solid rgba(255, 215, 106, 0.3); }
+article a:hover { color: var(--accent-2); border-bottom-color: var(--accent-2); }
+article h2 { font-size: 28px; margin: 48px 0 18px; letter-spacing: -0.01em; font-weight: 600; }
+article h3 { font-size: 22px; margin: 36px 0 14px; font-weight: 600; }
+article ul, article ol { padding-left: 24px; margin: 0 0 20px; }
+article li { margin: 8px 0; }
+article code { background: var(--bg-soft); padding: 2px 6px; border-radius: 4px; font-size: 0.92em; }
+article pre { background: var(--bg-soft); padding: 16px; border-radius: 8px; overflow-x: auto; }
+article pre code { background: transparent; padding: 0; }
+article blockquote { margin: 24px 0; padding: 12px 20px; border-left: 3px solid var(--accent);
+\tbackground: rgba(255, 215, 106, 0.04); color: var(--fg-dim); }
+article em { color: var(--fg-dim); }
+.footer-actions {
+\tmargin-top: 56px; padding-top: 32px; border-top: 1px solid var(--border);
+\tdisplay: flex; flex-wrap: wrap; gap: 16px; justify-content: space-between; align-items: center;
+\tfont-size: 14px; color: var(--fg-dim);
+}
+.footer-actions a.cta {
+\tdisplay: inline-flex; align-items: center; gap: 6px;
+\tpadding: 10px 18px; border-radius: 999px;
+\tbackground: linear-gradient(135deg, var(--accent) 0%, var(--accent-2) 100%);
+\tcolor: #1a1a1f; font-weight: 600; border: none;
+}
+.footer-actions a.cta:hover { text-decoration: none; opacity: 0.92; }
+.site-footer {
+\tmax-width: 720px; margin: 0 auto; padding: 32px 24px 48px;
+\ttext-align: center; color: var(--fg-faint); font-size: 13px;
+\tborder-top: 1px solid var(--border);
+}
+.site-footer a { color: var(--fg-dim); }
+/* Listing page */
+.listing { max-width: 800px; margin: 0 auto; padding: 64px 24px 96px; }
+.listing-intro h1 { font-size: clamp(36px, 5vw, 56px); margin: 0 0 16px; letter-spacing: -0.02em;
+\tbackground: linear-gradient(135deg, var(--accent) 0%, var(--accent-2) 100%);
+\t-webkit-background-clip: text; background-clip: text; color: transparent; }
+.listing-intro p { color: var(--fg-dim); font-size: 18px; max-width: 600px; margin: 0 0 32px; }
+.listing-intro .subscribe {
+\tdisplay: inline-flex; align-items: center; gap: 6px;
+\tpadding: 8px 14px; border-radius: 999px;
+\tborder: 1px solid var(--border); color: var(--fg);
+\tfont-size: 14px; background: var(--bg-soft); margin-bottom: 48px;
+}
+.listing-intro .subscribe:hover { border-color: var(--accent); color: var(--accent); text-decoration: none; }
+.post-list { list-style: none; padding: 0; margin: 0; }
+.post-list li { padding: 24px 0; border-bottom: 1px solid var(--border); }
+.post-list li:last-child { border-bottom: none; }
+.post-list a.post-link { display: block; color: var(--fg); }
+.post-list a.post-link:hover { text-decoration: none; }
+.post-list a.post-link:hover .post-title { color: var(--accent); }
+.post-date { color: var(--fg-faint); font-size: 13px; text-transform: uppercase; letter-spacing: 0.06em; }
+.post-title { font-size: 24px; margin: 6px 0 8px; letter-spacing: -0.01em; font-weight: 600; transition: color .15s; }
+.post-summary { color: var(--fg-dim); margin: 0 0 8px; font-size: 16px; }
+@media (max-width: 600px) {
+\tmain { padding: 40px 20px 64px; }
+\t.listing { padding: 40px 20px 64px; }
+\t.topbar { padding: 14px 18px; }
+\tarticle { font-size: 17px; }
+}`;
+}
+
+function topbarHtml() {
+ return `<header class="topbar">
+\t<a class="brand" href="/">three.ws</a>
+\t<nav>
+\t\t<a href="/news">News</a>
+\t\t<a href="/discover">Discover</a>
+\t\t<a href="/marketplace">Marketplace</a>
+\t</nav>
+</header>`;
+}
+
+function siteFooterHtml() {
+ return `<footer class="site-footer">
+\t<p>&copy; three.ws &middot; <a href="/">Home</a> &middot; <a href="/news">News</a> &middot; <a href="/rss/announcements.xml">RSS</a> &middot; <a href="https://x.com/trythreews" rel="noopener">X</a> &middot; <a href="https://github.com/nirholas/three.ws" rel="noopener">GitHub</a></p>
+</footer>`;
+}
+
+function jsonLdArticle(item) {
+ const ld = {
+ '@context': 'https://schema.org',
+ '@type': 'NewsArticle',
+ headline: item.title,
+ datePublished: item.timestamp.toISOString(),
+ dateModified: item.timestamp.toISOString(),
+ mainEntityOfPage: { '@type': 'WebPage', '@id': item.permalink },
+ author: { '@type': 'Organization', name: item.author, url: SITE_ORIGIN },
+ publisher: {
+ '@type': 'Organization',
+ name: SITE_NAME,
+ url: SITE_ORIGIN,
+ logo: { '@type': 'ImageObject', url: `${SITE_ORIGIN}/3d.png` },
+ },
+ description: item.summary,
+ };
+ if (item.image) ld.image = [absoluteUrl(item.image)];
+ if (item.tags?.length) ld.keywords = item.tags.join(', ');
+ if (item.externalLink) ld.sameAs = [item.externalLink];
+ return JSON.stringify(ld, null, 2);
+}
+
+function renderArticlePage(item) {
+ const ogTitle = item.ogTitle || item.title;
+ const ogDescription = item.ogDescription || item.summary;
+ const ogImage = absoluteUrl(item.image || '/3d.png');
+ const imageAlt = item.imageAlt || item.title;
+ const tagsHtml = item.tags?.length
+ ? `<div class="tag-list">${item.tags.map((t) => `<span class="tag">${escapeHtml(t)}</span>`).join('')}</div>`
+ : '';
+ const heroDims = item.imageWidth && item.imageHeight ? ` width="${item.imageWidth}" height="${item.imageHeight}"` : '';
+ const heroHtml = item.image
+ ? `<figure class="hero"><img src="${escapeAttr(item.image)}" alt="${escapeAttr(imageAlt)}" loading="eager" fetchpriority="high"${heroDims}/></figure>`
+ : '';
+ const externalAttribution = item.externalLink
+ ? `<p><em>Originally shared on <a href="${escapeAttr(item.externalLink)}" rel="noopener">X</a>.</em></p>`
+ : '';
+ return `<!DOCTYPE html>
+<html lang="en">
+<head>
+<meta charset="utf-8"/>
+<meta name="viewport" content="width=device-width, initial-scale=1"/>
+<title>${escapeHtml(item.title)} — ${escapeHtml(SITE_NAME)}</title>
+<meta name="description" content="${escapeAttr(item.summary)}"/>
+<link rel="canonical" href="${escapeAttr(item.permalink)}"/>
+<link rel="alternate" type="application/rss+xml" title="three.ws news" href="${SITE_ORIGIN}/rss/announcements.xml"/>
+<meta property="og:type" content="article"/>
+<meta property="og:site_name" content="${escapeAttr(SITE_NAME)}"/>
+<meta property="og:title" content="${escapeAttr(ogTitle)}"/>
+<meta property="og:description" content="${escapeAttr(ogDescription)}"/>
+<meta property="og:url" content="${escapeAttr(item.permalink)}"/>
+<meta property="og:image" content="${escapeAttr(ogImage)}"/>
+${item.imageWidth && item.imageHeight ? `<meta property="og:image:width" content="${item.imageWidth}"/>\n<meta property="og:image:height" content="${item.imageHeight}"/>` : ''}
+${item.imageAlt ? `<meta property="og:image:alt" content="${escapeAttr(item.imageAlt)}"/>` : ''}
+<meta property="article:published_time" content="${item.timestamp.toISOString()}"/>
+${item.tags?.map((t) => `<meta property="article:tag" content="${escapeAttr(t)}"/>`).join('\n') || ''}
+<meta name="twitter:card" content="summary_large_image"/>
+<meta name="twitter:site" content="${TWITTER_HANDLE}"/>
+<meta name="twitter:creator" content="${TWITTER_HANDLE}"/>
+<meta name="twitter:title" content="${escapeAttr(ogTitle)}"/>
+<meta name="twitter:description" content="${escapeAttr(ogDescription)}"/>
+<meta name="twitter:image" content="${escapeAttr(ogImage)}"/>
+<script type="application/ld+json">
+${jsonLdArticle(item)}
+</script>
+<style>${pageCss()}</style>
+</head>
+<body>
+${topbarHtml()}
+<main>
+\t<div class="eyebrow"><a href="/news">News &amp; Announcements</a></div>
+\t<h1 class="title">${escapeHtml(item.title)}</h1>
+\t<div class="meta">
+\t\t<time datetime="${item.timestamp.toISOString()}">${escapeHtml(formatDate(item.timestamp))}</time>
+\t\t<span class="author">${escapeHtml(item.author)}</span>
+\t\t${tagsHtml}
+\t</div>
+\t${heroHtml}
+\t<article>
+${item.bodyHtml}
+${externalAttribution}
+\t</article>
+\t<div class="footer-actions">
+\t\t<a href="/news">&larr; All news</a>
+\t\t<a class="cta" href="/" >Visit three.ws &rarr;</a>
+\t</div>
+</main>
+${siteFooterHtml()}
+</body>
+</html>
+`;
+}
+
+function renderIndexPage(items) {
+ const postsHtml = items
+ .map((item) => `\t\t<li>
+\t\t\t<a class="post-link" href="${escapeAttr(NEWS_PATH_PREFIX)}/${escapeAttr(item.slug)}">
+\t\t\t\t<div class="post-date"><time datetime="${item.timestamp.toISOString()}">${escapeHtml(formatDate(item.timestamp))}</time></div>
+\t\t\t\t<h2 class="post-title">${escapeHtml(item.title)}</h2>
+\t\t\t\t<p class="post-summary">${escapeHtml(item.summary)}</p>
+${item.tags?.length ? `\t\t\t\t<div class="tag-list">${item.tags.map((t) => `<span class="tag">${escapeHtml(t)}</span>`).join('')}</div>` : ''}
+\t\t\t</a>
+\t\t</li>`)
+ .join('\n');
+ return `<!DOCTYPE html>
+<html lang="en">
+<head>
+<meta charset="utf-8"/>
+<meta name="viewport" content="width=device-width, initial-scale=1"/>
+<title>News &amp; Announcements — ${escapeHtml(SITE_NAME)}</title>
+<meta name="description" content="Product launches, integrations, and announcements from three.ws — 3D AI agent avatars on-chain."/>
+<link rel="canonical" href="${SITE_ORIGIN}${NEWS_PATH_PREFIX}/"/>
+<link rel="alternate" type="application/rss+xml" title="three.ws news" href="${SITE_ORIGIN}/rss/announcements.xml"/>
+<meta property="og:type" content="website"/>
+<meta property="og:site_name" content="${escapeAttr(SITE_NAME)}"/>
+<meta property="og:title" content="News &amp; Announcements — ${escapeAttr(SITE_NAME)}"/>
+<meta property="og:description" content="Product launches, integrations, and announcements from three.ws."/>
+<meta property="og:url" content="${SITE_ORIGIN}${NEWS_PATH_PREFIX}/"/>
+<meta property="og:image" content="${SITE_ORIGIN}/3d.png"/>
+<meta name="twitter:card" content="summary_large_image"/>
+<meta name="twitter:site" content="${TWITTER_HANDLE}"/>
+<style>${pageCss()}</style>
+</head>
+<body>
+${topbarHtml()}
+<section class="listing">
+\t<div class="listing-intro">
+\t\t<h1>News &amp; Announcements</h1>
+\t\t<p>Product launches, integrations, and announcements from three.ws &mdash; 3D AI agent avatars on-chain.</p>
+\t\t<a class="subscribe" href="/rss/announcements.xml" rel="alternate" type="application/rss+xml">Subscribe via RSS &rarr;</a>
+\t</div>
+\t<ul class="post-list">
+${postsHtml}
+\t</ul>
+</section>
+${siteFooterHtml()}
+</body>
+</html>
+`;
+}
+
+async function ensureDir(dir) {
+ await mkdir(dir, { recursive: true });
+}
+
+async function main() {
+ const items = await loadCuratedItems();
+ if (!items.length) {
+ console.warn('No curated items found — skipping news page generation.');
+ return;
+ }
+ await ensureDir(OUT_DIR);
+ await ensureDir(path.dirname(ROUTES_FILE));
+
+ let written = 0;
+ for (const item of items) {
+ const html = renderArticlePage(item);
+ await writeFile(path.join(OUT_DIR, `${item.slug}.html`), html, 'utf8');
+ written++;
+ }
+
+ const indexHtml = renderIndexPage(items);
+ await writeFile(path.join(OUT_DIR, 'index.html'), indexHtml, 'utf8');
+
+ const routes = [
+ {
+ path: `${NEWS_PATH_PREFIX}/`,
+ title: 'News & Announcements',
+ description: 'Product launches, integrations, and announcements from three.ws.',
+ lastmod: items[0].timestamp.toISOString().slice(0, 10),
+ priority: 0.8,
+ changefreq: 'weekly',
+ },
+ ...items.map((item) => ({
+ path: `${NEWS_PATH_PREFIX}/${item.slug}`,
+ title: item.title,
+ description: item.summary,
+ lastmod: item.timestamp.toISOString().slice(0, 10),
+ priority: 0.6,
+ changefreq: 'yearly',
+ })),
+ ];
+ await writeFile(ROUTES_FILE, JSON.stringify(routes, null, 2) + '\n', 'utf8');
+
+ console.log(`Wrote ${written} article page(s) + index to ${OUT_DIR}`);
+ console.log(`Wrote ${routes.length} route(s) to ${ROUTES_FILE}`);
+}
+
+main().catch((err) => {
+ console.error('[build-news] failed:', err);
+ process.exit(1);
+});
diff --git a/scripts/build-page-index.mjs b/scripts/build-page-index.mjs
index 32b574bb5..6755f955e 100644
--- a/scripts/build-page-index.mjs
+++ b/scripts/build-page-index.mjs
@@ -9,7 +9,7 @@
*
* Run via `npm run build:pages` or automatically before `vite build`.
*/
-import { readFileSync, writeFileSync, mkdirSync } from 'node:fs';
+import { readFileSync, writeFileSync, mkdirSync, existsSync } from 'node:fs';
import { resolve, dirname } from 'node:path';
import { fileURLToPath } from 'node:url';
@@ -17,9 +17,33 @@ const here = dirname(fileURLToPath(import.meta.url));
const root = resolve(here, '..');
const dataFile = resolve(root, 'data/pages.json');
const publicDir = resolve(root, 'public');
+const newsRoutesFile = resolve(root, 'data/_generated/news-routes.json');
const data = JSON.parse(readFileSync(dataFile, 'utf8'));
-const { site, sections } = data;
+const { site } = data;
+const sections = [...data.sections];
+
+// Splice in a "News" section if scripts/build-news.mjs has written its
+// routes file. Keeps news entries in the sitemap, llms.txt, and the
+// human-readable /sitemap page without requiring manual edits.
+if (existsSync(newsRoutesFile)) {
+ const newsRoutes = JSON.parse(readFileSync(newsRoutesFile, 'utf8'));
+ if (Array.isArray(newsRoutes) && newsRoutes.length) {
+ sections.push({
+ id: 'news',
+ title: 'News',
+ description: 'Product launches, integrations, and announcements from three.ws.',
+ pages: newsRoutes.map((r) => ({
+ path: r.path,
+ title: r.title,
+ description: r.description,
+ priority: r.priority,
+ changefreq: r.changefreq,
+ lastmod: r.lastmod,
+ })),
+ });
+ }
+}
const baseUrl = site.url.replace(/\/$/, '');
const today = new Date().toISOString().slice(0, 10);
@@ -54,7 +78,7 @@ function buildSitemap() {
const urls = allPages.filter(indexable).map((p) => {
const lines = [
`\t\t<loc>${escapeXml(baseUrl + p.path)}</loc>`,
- `\t\t<lastmod>${today}</lastmod>`,
+ `\t\t<lastmod>${p.lastmod || today}</lastmod>`,
];
if (p.changefreq) lines.push(`\t\t<changefreq>${p.changefreq}</changefreq>`);
if (p.priority != null) lines.push(`\t\t<priority>${p.priority.toFixed(1)}</priority>`);
diff --git a/src/agent-avatar.js b/src/agent-avatar.js
index c4b222519..fbc92b95d 100644
--- a/src/agent-avatar.js
+++ b/src/agent-avatar.js
@@ -24,6 +24,7 @@ import { Vector3, Box3, MathUtils, PositionalAudio } from 'three';
import { resolveSlot, DEFAULT_ANIMATION_MAP } from './runtime/animation-slots.js';
import { ElevenLabsTTS } from './runtime/speech.js';
import { LipSyncAnalyser } from './lip-sync-analyser.js';
+import { resolveMorphTargets, MORPH_ALIASES } from './runtime/arkit52.js';
// BEGIN:IDLE_LOOP_IMPORT
import { IdleAnimation } from './idle-animation.js';
// END:IDLE_LOOP_IMPORT
@@ -778,28 +779,50 @@ export class AgentAvatar {
if (!(name in this._morphCurrent)) this._morphCurrent[name] = 0;
}
- /** Collect all meshes with morph targets once per content load. */
+ /**
+ * Resolve canonical ARKit-52 names to their concrete mesh slots once per
+ * content load. The resolver understands the canonical names plus the
+ * MORPH_ALIASES synonyms (snake_case, _L/_R suffixes, combined shapes),
+ * so emotion code can refer to `mouthSmileLeft` and have it work on RPM,
+ * Avaturn, Mixamo, and custom Blender exports alike.
+ */
_buildMorphCache() {
- this._morphMeshes = [];
+ this._morphResolved = new Map();
if (!this.viewer?.content) return;
- this.viewer.content.traverse((node) => {
- if (node.isMesh && node.morphTargetDictionary && node.morphTargetInfluences) {
- this._morphMeshes.push(node);
- }
- });
+ this._morphResolved = resolveMorphTargets(this.viewer.content);
}
- /** Lerp all tracked morph target influences toward their targets */
+ /**
+ * Lerp all tracked morph target influences toward their targets. Names in
+ * `_morphTarget` are canonical ARKit-52 (or one of the recognized aliases);
+ * the resolver mapped each to one or more concrete mesh slots at load time.
+ */
_lerpMorphTargets(speed) {
- if (!this._morphMeshes?.length) return;
- for (const node of this._morphMeshes) {
- for (const [name, target] of Object.entries(this._morphTarget)) {
- const idx = node.morphTargetDictionary[name];
- if (idx === undefined) continue;
- const current = node.morphTargetInfluences[idx] || 0;
- const next = _lerp(current, target, speed);
- node.morphTargetInfluences[idx] = next;
- this._morphCurrent[name] = next;
+ if (!this._morphResolved || this._morphResolved.size === 0) return;
+ for (const [name, target] of Object.entries(this._morphTarget)) {
+ const canonical = MORPH_ALIASES[name] || name;
+ const slots = this._morphResolved.get(canonical);
+ if (!slots) continue;
+ let current = this._morphCurrent[name] ?? 0;
+ const next = _lerp(current, target, speed);
+ for (const { mesh, index } of slots) {
+ mesh.morphTargetInfluences[index] = next;
+ }
+ this._morphCurrent[name] = next;
+
+ // Mirror to the symmetric pair when the canonical name carries a
+ // 'Left' suffix and emotion code didn't explicitly set the right
+ // side — common for combined-shape models.
+ if (canonical.endsWith('Left')) {
+ const right = canonical.slice(0, -4) + 'Right';
+ if (!(right in this._morphTarget)) {
+ const rSlots = this._morphResolved.get(right);
+ if (rSlots) {
+ for (const { mesh, index } of rSlots) {
+ mesh.morphTargetInfluences[index] = next;
+ }
+ }
+ }
}
}
}
diff --git a/src/avatar-page.js b/src/avatar-page.js
index e7683e85e..f1cb2916c 100644
--- a/src/avatar-page.js
+++ b/src/avatar-page.js
@@ -7,6 +7,8 @@
* same code path serves both real and seeded avatars.
*/
+import { openTalkMode } from './voice/talk-mode.js';
+
const ATTACHED_KEY_PREFIX = 'avatar_attached_v1:';
const $ = (id) => document.getElementById(id);
@@ -225,6 +227,12 @@ function renderShell(glbUrl) {
${byLine}
${tagsHtml ? `<div class="av-tags">${tagsHtml}</div>` : ''}
</div>
+ <div class="av-cta-talk-row">
+ <button class="av-cta-talk" id="av-talk" type="button" aria-label="Talk to ${esc(avatar.name)}">
+ <span class="av-cta-talk-dot" aria-hidden="true"></span>
+ <span>Talk to ${esc(avatar.name)}</span>
+ </button>
+ </div>
<div class="av-cta-row">
<button class="av-cta" id="av-use">Start an agent</button>
<a class="av-cta-sec" href="/studio?avatar=${encodeURIComponent(avatar.id || avatarId)}" title="Use this avatar in Widget Studio">Open in Studio</a>
@@ -301,6 +309,7 @@ function renderShell(glbUrl) {
});
$('av-use')?.addEventListener('click', startAgentWithAvatar);
+ $('av-talk')?.addEventListener('click', () => enterTalkMode());
}
function renderAttribution() {
@@ -899,6 +908,17 @@ function buildSystemContext() {
return parts.filter(Boolean).join('\n');
}
+// ── Talk mode entry ──────────────────────────────────────────────────
+//
+// Opens the live-voice overlay: three.js renderer + lipsync + push-to-talk.
+// Implementation lives in src/voice/talk-mode.js so this page only needs the
+// click handler and a system-prompt provider.
+
+function enterTalkMode() {
+ if (!avatar) return;
+ openTalkMode({ avatar, systemPromptFn: buildSystemContext });
+}
+
// ── Agents wearing this avatar ────────────────────────────────────────
async function loadUsedBy() {
diff --git a/src/element.js b/src/element.js
index 72b80f971..c14e7b811 100644
--- a/src/element.js
+++ b/src/element.js
@@ -16,6 +16,7 @@ import { attachTradeReactions } from './pump/trade-reactions.js';
// BEGIN:EMBED_BRIDGES_IMPORT
import { EmbedActionBridge } from './embed-action-bridge.js';
import { protocol, ACTION_TYPES } from './agent-protocol.js';
+import { AgentAvatar } from './agent-avatar.js';
// END:EMBED_BRIDGES_IMPORT
import { AgentNotifier } from './agent-notifier.js';
@@ -541,6 +542,7 @@ class Agent3DElement extends HTMLElement {
this._runtime = null;
this._memory = null;
this._skills = null;
+ this._avatar = null; // empathy + lipsync layer; attached after runtime mounts
this._manifest = null;
this._mounted = false;
this._booting = false;
@@ -1397,6 +1399,35 @@ class Agent3DElement extends HTMLElement {
agentId: _backendId || undefined,
skillAccess: _skillAccess,
});
+
+ // ── Empathy + lipsync layer ───────────────────────────────────────
+ // AgentAvatar subscribes to the agent-protocol bus, runs the emotion
+ // blend on the viewer's per-frame hook, and drives viseme morphs from
+ // the live TTS AnalyserNode when audio plays. Without this the embed
+ // would render the mesh but show a dead face while speaking.
+ try {
+ const _identity = { id: manifest.id?.agentId || manifest.name || 'embed' };
+ this._avatar = new AgentAvatar(this._viewer, protocol, _identity);
+ this._avatar.attach();
+
+ if (this._runtime.tts) {
+ const tts = this._runtime.tts;
+ const avatar = this._avatar;
+ tts.onStart = () => {
+ if (tts.analyserNode) avatar.connectLipSync(tts.analyserNode);
+ };
+ tts.onEnd = () => {
+ avatar._lipSync?.disconnect();
+ avatar._lipSync = null;
+ };
+ }
+ } catch (e) {
+ // Empathy is non-essential — embed still works without it. Log so
+ // integrators can see the failure during development.
+ console.warn('[agent-3d] AgentAvatar attach failed; continuing without empathy/lipsync', e);
+ this._avatar = null;
+ }
+
// Re-dispatch runtime events on the host
for (const ev of [
'brain:thinking',
@@ -2293,12 +2324,15 @@ class Agent3DElement extends HTMLElement {
this._runtime?.cancel();
this._runtime?.destroy();
} catch {}
+ try {
+ this._avatar?.detach();
+ } catch {}
try {
this._viewer?.dispose?.();
} catch {}
this._mounted = false;
this._pillActive = false;
- this._runtime = this._viewer = this._scene = this._memory = this._skills = null;
+ this._runtime = this._viewer = this._scene = this._memory = this._skills = this._avatar = null;
}
// --- Public JS API ---
diff --git a/src/runtime/arkit52.js b/src/runtime/arkit52.js
new file mode 100644
index 000000000..6143ea638
--- /dev/null
+++ b/src/runtime/arkit52.js
@@ -0,0 +1,211 @@
+// ARKit-52 facial blendshape spec — canonical names + alias map.
+//
+// Apple's ARKit publishes a stable set of 52 facial blendshapes (53 with the
+// `tongueOut` extension). Most modern avatar pipelines either ship these
+// names directly (RPM, Avaturn v2, modern Mixamo exports) or use a near-cousin
+// naming scheme (camelCase vs underscores, _L/_R vs Left/Right suffixes).
+//
+// This module exposes:
+// - ARKIT_52: the canonical name list
+// - ARKIT_VISEMES: viseme_* phoneme morphs that ship alongside the 52
+// - MORPH_ALIASES: alternate names → canonical name
+// - resolveMorphTargets(): walks a Three.js root, builds canonical → [{mesh,index}] map
+// - setCanonicalMorph(): apply weight to a canonical morph + auto-split L/R when needed
+// - conformanceReport(): how many of the 52 a given GLB implements
+//
+// This is the cross-runtime layer that lets emotion + lipsync code refer to
+// morphs by their canonical ARKit name and have it just work across RPM,
+// Avaturn, custom Blender exports, and procedural variants.
+
+export const ARKIT_52 = Object.freeze([
+ // Eyes (14)
+ 'eyeBlinkLeft', 'eyeBlinkRight',
+ 'eyeLookDownLeft', 'eyeLookDownRight',
+ 'eyeLookInLeft', 'eyeLookInRight',
+ 'eyeLookOutLeft', 'eyeLookOutRight',
+ 'eyeLookUpLeft', 'eyeLookUpRight',
+ 'eyeSquintLeft', 'eyeSquintRight',
+ 'eyeWideLeft', 'eyeWideRight',
+ // Jaw (4)
+ 'jawForward', 'jawLeft', 'jawRight', 'jawOpen',
+ // Mouth (23)
+ 'mouthClose', 'mouthFunnel', 'mouthPucker',
+ 'mouthLeft', 'mouthRight',
+ 'mouthSmileLeft', 'mouthSmileRight',
+ 'mouthFrownLeft', 'mouthFrownRight',
+ 'mouthDimpleLeft', 'mouthDimpleRight',
+ 'mouthStretchLeft', 'mouthStretchRight',
+ 'mouthRollLower', 'mouthRollUpper',
+ 'mouthShrugLower', 'mouthShrugUpper',
+ 'mouthPressLeft', 'mouthPressRight',
+ 'mouthLowerDownLeft', 'mouthLowerDownRight',
+ 'mouthUpperUpLeft', 'mouthUpperUpRight',
+ // Brows (5)
+ 'browDownLeft', 'browDownRight',
+ 'browInnerUp',
+ 'browOuterUpLeft', 'browOuterUpRight',
+ // Cheeks (3)
+ 'cheekPuff',
+ 'cheekSquintLeft', 'cheekSquintRight',
+ // Nose (2)
+ 'noseSneerLeft', 'noseSneerRight',
+ // Tongue (1, Apple's official 53rd)
+ 'tongueOut',
+]);
+
+export const ARKIT_VISEMES = Object.freeze([
+ 'viseme_aa', 'viseme_CH', 'viseme_DD', 'viseme_E', 'viseme_FF',
+ 'viseme_I', 'viseme_kk', 'viseme_nn', 'viseme_O', 'viseme_PP',
+ 'viseme_RR', 'viseme_sil', 'viseme_SS', 'viseme_TH', 'viseme_U',
+]);
+
+// Synonyms found in the wild: snake_case, underscored L/R, period dots,
+// older Mixamo names, and the abbreviated combined forms the three.ws
+// emotion layer historically used. Map each to its canonical ARKit name.
+export const MORPH_ALIASES = Object.freeze({
+ // snake_case → camelCase variants
+ 'eye_blink_left': 'eyeBlinkLeft', 'eye_blink_right': 'eyeBlinkRight',
+ 'eye_squint_left': 'eyeSquintLeft', 'eye_squint_right': 'eyeSquintRight',
+ 'eye_wide_left': 'eyeWideLeft', 'eye_wide_right': 'eyeWideRight',
+ 'jaw_open': 'jawOpen', 'jaw_forward': 'jawForward', 'jaw_left': 'jawLeft', 'jaw_right': 'jawRight',
+ 'mouth_close': 'mouthClose', 'mouth_funnel': 'mouthFunnel', 'mouth_pucker': 'mouthPucker',
+ 'mouth_smile_left': 'mouthSmileLeft', 'mouth_smile_right': 'mouthSmileRight',
+ 'mouth_frown_left': 'mouthFrownLeft', 'mouth_frown_right': 'mouthFrownRight',
+ 'mouth_press_left': 'mouthPressLeft', 'mouth_press_right': 'mouthPressRight',
+ 'brow_down_left': 'browDownLeft', 'brow_down_right': 'browDownRight',
+ 'brow_inner_up': 'browInnerUp',
+ 'brow_outer_up_left': 'browOuterUpLeft', 'brow_outer_up_right': 'browOuterUpRight',
+ 'cheek_puff': 'cheekPuff',
+ 'cheek_squint_left': 'cheekSquintLeft', 'cheek_squint_right': 'cheekSquintRight',
+ 'nose_sneer_left': 'noseSneerLeft', 'nose_sneer_right': 'noseSneerRight',
+ 'tongue_out': 'tongueOut',
+ // _L / _R suffix variants (common in older RPM exports)
+ 'eyeBlink_L': 'eyeBlinkLeft', 'eyeBlink_R': 'eyeBlinkRight',
+ 'eyeSquint_L': 'eyeSquintLeft', 'eyeSquint_R': 'eyeSquintRight',
+ 'eyeWide_L': 'eyeWideLeft', 'eyeWide_R': 'eyeWideRight',
+ 'mouthSmile_L': 'mouthSmileLeft', 'mouthSmile_R': 'mouthSmileRight',
+ 'mouthFrown_L': 'mouthFrownLeft', 'mouthFrown_R': 'mouthFrownRight',
+ 'mouthPress_L': 'mouthPressLeft', 'mouthPress_R': 'mouthPressRight',
+ 'browDown_L': 'browDownLeft', 'browDown_R': 'browDownRight',
+ 'browOuterUp_L': 'browOuterUpLeft', 'browOuterUp_R': 'browOuterUpRight',
+ 'cheekSquint_L': 'cheekSquintLeft', 'cheekSquint_R': 'cheekSquintRight',
+ 'noseSneer_L': 'noseSneerLeft', 'noseSneer_R': 'noseSneerRight',
+ // Combined "single" shapes some pipelines export instead of L/R pairs.
+ // Resolved at apply-time via SYMMETRIC_PAIRS, so we map them to the left
+ // canonical name and let setCanonicalMorph fan out to the right side.
+ 'eyeBlink': 'eyeBlinkLeft', 'eyesBlink': 'eyeBlinkLeft',
+ 'eyeSquint': 'eyeSquintLeft',
+ 'mouthSmile': 'mouthSmileLeft',
+ 'mouthFrown': 'mouthFrownLeft',
+ 'mouthPress': 'mouthPressLeft',
+ 'browOuterUp': 'browOuterUpLeft',
+ 'cheekSquint': 'cheekSquintLeft',
+ 'noseSneer': 'noseSneerLeft',
+ // Apple's pre-iOS-12 closed-eye blend
+ 'eyesClosed': 'eyeBlinkLeft',
+ // three.ws-era shorthand kept for backward compatibility with existing
+ // avatar code that calls _setMorphTarget('mouthOpen', …) — route to jawOpen.
+ 'mouthOpen': 'jawOpen',
+});
+
+// Canonical morphs that are physically symmetric. Setting one of these via
+// setCanonicalMorph('mouthSmileLeft', w) when only a combined 'mouthSmile'
+// exists in the mesh fans out to both sides automatically.
+const SYMMETRIC_PAIRS = Object.freeze({
+ eyeBlinkLeft: 'eyeBlinkRight',
+ eyeLookDownLeft: 'eyeLookDownRight',
+ eyeLookInLeft: 'eyeLookInRight',
+ eyeLookOutLeft: 'eyeLookOutRight',
+ eyeLookUpLeft: 'eyeLookUpRight',
+ eyeSquintLeft: 'eyeSquintRight',
+ eyeWideLeft: 'eyeWideRight',
+ mouthSmileLeft: 'mouthSmileRight',
+ mouthFrownLeft: 'mouthFrownRight',
+ mouthDimpleLeft: 'mouthDimpleRight',
+ mouthStretchLeft: 'mouthStretchRight',
+ mouthPressLeft: 'mouthPressRight',
+ mouthLowerDownLeft: 'mouthLowerDownRight',
+ mouthUpperUpLeft: 'mouthUpperUpRight',
+ browDownLeft: 'browDownRight',
+ browOuterUpLeft: 'browOuterUpRight',
+ cheekSquintLeft: 'cheekSquintRight',
+ noseSneerLeft: 'noseSneerRight',
+});
+
+/**
+ * Walk a Three.js root and build a canonical-name → [{mesh, index}] resolver.
+ * Each canonical ARKit-52 name maps to every mesh slot that implements it,
+ * either by exact name match or via MORPH_ALIASES.
+ *
+ * @param {import('three').Object3D} root
+ * @returns {Map<string, Array<{mesh: any, index: number}>>}
+ */
+export function resolveMorphTargets(root) {
+ const out = new Map();
+ if (!root || typeof root.traverse !== 'function') return out;
+
+ root.traverse((node) => {
+ if (!node.isMesh || !node.morphTargetDictionary || !node.morphTargetInfluences) return;
+ const dict = node.morphTargetDictionary;
+ for (const [glbName, idx] of Object.entries(dict)) {
+ const canonical = MORPH_ALIASES[glbName] || glbName;
+ if (!ARKIT_52.includes(canonical) && !ARKIT_VISEMES.includes(canonical)) continue;
+ if (!out.has(canonical)) out.set(canonical, []);
+ out.get(canonical).push({ mesh: node, index: idx });
+ }
+ });
+
+ return out;
+}
+
+/**
+ * Apply a weight to a canonical ARKit morph across all meshes that implement
+ * it. If a paired side is missing (e.g. mesh has only mouthSmileLeft and we
+ * set mouthSmileLeft), nothing extra happens. If the mesh has only a combined
+ * shape that aliases to this name, the alias map already routes it. The
+ * SYMMETRIC_PAIRS fanout applies the same weight to the right side when only
+ * the left was requested — useful for emotion code that doesn't care about
+ * asymmetric expression.
+ *
+ * @param {Map} resolved — from resolveMorphTargets()
+ * @param {string} canonical — canonical ARKit name
+ * @param {number} weight — 0..1
+ * @param {object} [opts]
+ * @param {boolean} [opts.mirror=true] — fan out to symmetric pair if it exists
+ */
+export function setCanonicalMorph(resolved, canonical, weight, opts = {}) {
+ const mirror = opts.mirror !== false;
+ const w = Math.max(0, Math.min(1, weight));
+
+ const apply = (name) => {
+ const targets = resolved.get(name);
+ if (!targets) return;
+ for (const { mesh, index } of targets) {
+ mesh.morphTargetInfluences[index] = w;
+ }
+ };
+
+ apply(canonical);
+ if (mirror) {
+ const right = SYMMETRIC_PAIRS[canonical];
+ if (right) apply(right);
+ }
+}
+
+/**
+ * Report which canonical ARKit-52 morphs an avatar implements.
+ * Useful for the avatar uploader to surface coverage gaps in the UI.
+ *
+ * @param {import('three').Object3D} root
+ * @returns {{ implemented: string[], missing: string[], coverage: number }}
+ */
+export function conformanceReport(root) {
+ const resolved = resolveMorphTargets(root);
+ const implemented = ARKIT_52.filter((name) => resolved.has(name));
+ const missing = ARKIT_52.filter((name) => !resolved.has(name));
+ return {
+ implemented,
+ missing,
+ coverage: implemented.length / ARKIT_52.length,
+ };
+}
diff --git a/src/voice/talk-mode.js b/src/voice/talk-mode.js
new file mode 100644
index 000000000..8366becf3
--- /dev/null
+++ b/src/voice/talk-mode.js
@@ -0,0 +1,344 @@
+/**
+ * Talk mode overlay — open from /avatars/:id, closes by ✕ or Escape.
+ *
+ * One self-contained module: builds the DOM, mounts a three.js TalkScene with
+ * the avatar's GLB, wires a hold-to-talk button to a TalkController, renders
+ * the live transcript. Nothing else in avatar-page needs to know about scenes
+ * or audio graphs — call openTalkMode({ avatar }) and the rest happens here.
+ *
+ * Real wires throughout:
+ * - GLB renders via three.js (TalkScene)
+ * - mic captures via Web Speech API
+ * - replies stream from /api/chat
+ * - voice synthesizes via /api/tts/eleven (cloned voice when avatar has an
+ * agent with voice_id, else /api/tts/edge)
+ * - mouth movement comes from the FFT of the actual TTS audio
+ */
+
+import { TalkScene } from './talk-scene.js';
+import { AvatarMouthTarget } from './avatar-morph-target.js';
+import { TalkController } from './talk-controller.js';
+
+let activeSession = null;
+
+/**
+ * Open the talk overlay for an avatar record. Returns the session handle so
+ * callers can close it programmatically (otherwise the user closes via UI).
+ *
+ * @param {object} opts
+ * @param {object} opts.avatar Decorated avatar from /api/avatars/:id
+ * @param {() => string} [opts.systemPromptFn]
+ */
+export function openTalkMode({ avatar, systemPromptFn }) {
+ if (activeSession) return activeSession; // single instance — no overlap
+
+ const glbUrl = avatar.model_url || avatar.url;
+ if (!glbUrl) {
+ console.warn('[talk] avatar has no GLB; cannot enter talk mode');
+ return null;
+ }
+
+ injectStylesOnce();
+
+ const overlay = document.createElement('div');
+ overlay.className = 'tws-talk-overlay';
+ overlay.innerHTML = TEMPLATE;
+ document.body.appendChild(overlay);
+ document.body.classList.add('tws-talk-open');
+
+ const stage = overlay.querySelector('.tws-talk-stage');
+ const closeBtn = overlay.querySelector('.tws-talk-close');
+ const holdBtn = overlay.querySelector('.tws-talk-hold');
+ const statusEl = overlay.querySelector('.tws-talk-status');
+ const transcriptEl = overlay.querySelector('.tws-talk-transcript');
+ const errEl = overlay.querySelector('.tws-talk-error');
+ const nameEl = overlay.querySelector('.tws-talk-name');
+ nameEl.textContent = avatar.name || 'Avatar';
+
+ const scene = new TalkScene();
+ const mouthTarget = new AvatarMouthTarget();
+
+ let controller = null;
+ let unloading = false;
+
+ scene
+ .mount({ container: stage, glbUrl })
+ .then((root) => {
+ scene.attachMouthTarget(mouthTarget);
+ // Log what we found so debugging mismatched rigs in the field is easy.
+ const diag = mouthTarget.describe();
+ if (!mouthTarget.hasMouthMorphs() && !mouthTarget.hasJawBone()) {
+ console.warn('[talk] avatar has no mouth morphs or jaw bone — speech will play but the mouth won\'t move. Diagnostics:', diag);
+ } else {
+ console.info('[talk] mouth binding:', diag);
+ }
+ setStatus(statusEl, 'idle');
+ })
+ .catch((err) => {
+ showError(errEl, `Could not load avatar: ${err.message}`);
+ });
+
+ controller = new TalkController({
+ avatar,
+ systemPromptFn,
+ mouthTarget,
+ onMessage: (m) => appendTranscript(transcriptEl, m),
+ onStateChange: (s) => setStatus(statusEl, s),
+ onError: (e) => showError(errEl, e.message),
+ });
+
+ // ── Hold-to-talk ───────────────────────────────────────────────────
+ const startHold = (ev) => {
+ ev.preventDefault();
+ if (controller.state !== 'idle' && controller.state !== 'speaking') return;
+ controller.stop(); // truncate any in-flight speech so the user can interrupt
+ controller.startListening();
+ holdBtn.classList.add('tws-talk-hold-active');
+ };
+ const endHold = (ev) => {
+ ev.preventDefault();
+ controller.stopListening();
+ holdBtn.classList.remove('tws-talk-hold-active');
+ };
+ holdBtn.addEventListener('mousedown', startHold);
+ holdBtn.addEventListener('mouseup', endHold);
+ holdBtn.addEventListener('mouseleave', endHold);
+ holdBtn.addEventListener('touchstart', startHold, { passive: false });
+ holdBtn.addEventListener('touchend', endHold);
+ holdBtn.addEventListener('touchcancel', endHold);
+
+ // Keyboard: Space = hold-to-talk while overlay is open.
+ const onKey = (e) => {
+ if (e.key === 'Escape') {
+ e.preventDefault();
+ close();
+ }
+ if (e.code === 'Space' && e.target === document.body) {
+ if (e.repeat) return;
+ if (e.type === 'keydown') startHold(e);
+ else endHold(e);
+ }
+ };
+ window.addEventListener('keydown', onKey);
+ window.addEventListener('keyup', onKey);
+
+ closeBtn.addEventListener('click', () => close());
+
+ function close() {
+ if (unloading) return;
+ unloading = true;
+ try {
+ controller?.stop();
+ } catch {}
+ try {
+ scene.unmount();
+ } catch {}
+ mouthTarget.dispose();
+ window.removeEventListener('keydown', onKey);
+ window.removeEventListener('keyup', onKey);
+ document.body.classList.remove('tws-talk-open');
+ overlay.remove();
+ activeSession = null;
+ }
+
+ activeSession = { close };
+ return activeSession;
+}
+
+export function closeTalkMode() {
+ activeSession?.close();
+}
+
+// ── DOM template + styles ──────────────────────────────────────────────
+
+const TEMPLATE = `
+ <button class="tws-talk-close" aria-label="Exit talk mode" title="Exit (Esc)">✕</button>
+ <div class="tws-talk-header">
+ <span class="tws-talk-eyebrow">Talking to</span>
+ <span class="tws-talk-name"></span>
+ </div>
+ <div class="tws-talk-stage"></div>
+ <div class="tws-talk-transcript" aria-live="polite"></div>
+ <div class="tws-talk-controls">
+ <button class="tws-talk-hold" type="button" aria-label="Hold to talk">
+ <span class="tws-talk-hold-dot"></span>
+ <span class="tws-talk-hold-label">Hold to talk</span>
+ </button>
+ <div class="tws-talk-status" data-state="idle">Ready</div>
+ </div>
+ <div class="tws-talk-error" role="alert" hidden></div>
+`;
+
+const STATUS_LABEL = {
+ idle: 'Ready',
+ listening: 'Listening…',
+ thinking: 'Thinking…',
+ speaking: 'Speaking',
+};
+
+function setStatus(el, state) {
+ if (!el) return;
+ el.dataset.state = state;
+ el.textContent = STATUS_LABEL[state] || state;
+}
+
+function appendTranscript(el, msg) {
+ if (!el) return;
+ const row = document.createElement('div');
+ row.className = `tws-talk-msg tws-talk-msg-${msg.role}`;
+ row.textContent = msg.content;
+ el.appendChild(row);
+ el.scrollTop = el.scrollHeight;
+}
+
+function showError(el, message) {
+ if (!el) return;
+ el.textContent = message;
+ el.hidden = false;
+ setTimeout(() => {
+ el.hidden = true;
+ el.textContent = '';
+ }, 4000);
+}
+
+function injectStylesOnce() {
+ if (document.getElementById('tws-talk-mode-css')) return;
+ const css = document.createElement('style');
+ css.id = 'tws-talk-mode-css';
+ css.textContent = TALK_CSS;
+ document.head.appendChild(css);
+}
+
+const TALK_CSS = `
+.tws-talk-open { overflow: hidden; }
+.tws-talk-overlay {
+ position: fixed; inset: 0; z-index: 9999;
+ background:
+ radial-gradient(ellipse at 50% 30%, rgba(125,211,252,0.10), transparent 60%),
+ radial-gradient(ellipse at 70% 80%, rgba(167,139,250,0.08), transparent 50%),
+ #050505;
+ color: #fafafa;
+ font-family: 'Inter', system-ui, sans-serif;
+ display: grid;
+ grid-template-rows: auto 1fr auto auto;
+ animation: tws-talk-in 200ms ease-out;
+}
+@keyframes tws-talk-in { from { opacity: 0; } to { opacity: 1; } }
+.tws-talk-close {
+ position: absolute; top: 14px; right: 16px;
+ background: rgba(255,255,255,0.06);
+ border: 1px solid rgba(255,255,255,0.12);
+ color: #fafafa;
+ width: 36px; height: 36px;
+ border-radius: 999px;
+ font-size: 14px;
+ font-family: inherit;
+ cursor: pointer;
+ transition: background 0.15s, border-color 0.15s;
+}
+.tws-talk-close:hover { background: rgba(255,255,255,0.12); border-color: rgba(255,255,255,0.25); }
+.tws-talk-header {
+ padding: 16px 24px 0;
+ display: flex; flex-direction: column; gap: 2px;
+}
+.tws-talk-eyebrow {
+ font-family: 'Space Grotesk', sans-serif;
+ font-size: 10px; letter-spacing: 0.18em;
+ text-transform: uppercase;
+ color: #a1a1aa;
+}
+.tws-talk-name {
+ font-family: 'Space Grotesk', sans-serif;
+ font-size: 20px; font-weight: 700;
+ letter-spacing: -0.01em;
+}
+.tws-talk-stage {
+ min-height: 0; position: relative;
+}
+.tws-talk-stage canvas {
+ width: 100% !important; height: 100% !important; display: block;
+}
+.tws-talk-transcript {
+ max-height: 160px;
+ overflow-y: auto;
+ padding: 8px 24px;
+ display: flex; flex-direction: column; gap: 6px;
+ border-top: 1px solid rgba(255,255,255,0.06);
+}
+.tws-talk-msg {
+ font-size: 14px; line-height: 1.5;
+ padding: 8px 12px; border-radius: 10px;
+ max-width: 75%;
+ word-wrap: break-word; white-space: pre-wrap;
+}
+.tws-talk-msg-user {
+ align-self: flex-end;
+ background: rgba(125,211,252,0.12);
+ border: 1px solid rgba(125,211,252,0.25);
+}
+.tws-talk-msg-assistant {
+ align-self: flex-start;
+ background: rgba(255,255,255,0.04);
+ border: 1px solid rgba(255,255,255,0.08);
+}
+.tws-talk-controls {
+ padding: 16px 24px 28px;
+ display: flex; flex-direction: column;
+ align-items: center; gap: 8px;
+ border-top: 1px solid rgba(255,255,255,0.06);
+}
+.tws-talk-hold {
+ display: inline-flex; align-items: center; gap: 12px;
+ background: #fafafa; color: #000;
+ border: 0; border-radius: 999px;
+ padding: 14px 28px;
+ font-family: inherit; font-size: 15px; font-weight: 600;
+ cursor: pointer;
+ user-select: none;
+ -webkit-user-select: none;
+ transition: transform 0.1s, box-shadow 0.15s;
+}
+.tws-talk-hold:hover { transform: translateY(-1px); }
+.tws-talk-hold-dot {
+ display: inline-block; width: 10px; height: 10px; border-radius: 999px;
+ background: #ef4444;
+ transition: transform 0.2s;
+}
+.tws-talk-hold-active {
+ background: #ef4444; color: #fff;
+ box-shadow: 0 0 0 6px rgba(239,68,68,0.18);
+}
+.tws-talk-hold-active .tws-talk-hold-dot {
+ background: #fff;
+ transform: scale(1.4);
+ animation: tws-talk-pulse 0.9s ease-in-out infinite;
+}
+@keyframes tws-talk-pulse {
+ 0%, 100% { opacity: 1; }
+ 50% { opacity: 0.4; }
+}
+.tws-talk-status {
+ font-size: 11px;
+ letter-spacing: 0.08em; text-transform: uppercase;
+ color: #71717a;
+ transition: color 0.2s;
+}
+.tws-talk-status[data-state="listening"] { color: #f43f5e; }
+.tws-talk-status[data-state="thinking"] { color: #a78bfa; }
+.tws-talk-status[data-state="speaking"] { color: #34d399; }
+.tws-talk-error {
+ position: absolute; left: 50%; bottom: 100px;
+ transform: translateX(-50%);
+ background: rgba(244,63,94,0.14);
+ border: 1px solid rgba(244,63,94,0.4);
+ color: #fda4af;
+ padding: 8px 14px; border-radius: 10px;
+ font-size: 13px;
+}
+@media (max-width: 600px) {
+ .tws-talk-header { padding: 12px 16px 0; }
+ .tws-talk-transcript { padding: 8px 16px; max-height: 120px; }
+ .tws-talk-controls { padding: 12px 16px 20px; }
+ .tws-talk-hold { padding: 12px 22px; font-size: 14px; }
+}
+`;
diff --git a/tests/lip-sync-analyser.test.js b/tests/lip-sync-analyser.test.js
new file mode 100644
index 000000000..dc405be82
--- /dev/null
+++ b/tests/lip-sync-analyser.test.js
@@ -0,0 +1,161 @@
+/**
+ * LipSyncAnalyser — unit tests
+ *
+ * Validates the spectral analyser without WebAudio by injecting a fake
+ * AnalyserNode whose `getByteFrequencyData()` writes a deterministic
+ * frequency spectrum.
+ */
+
+import { describe, it, expect, beforeAll, beforeEach } from 'vitest';
+
+// LipSyncAnalyser does an `instanceof AnalyserNode` check on input. Node has
+// no WebAudio, so we shim the constructor before importing the module under
+// test, then the fake instance below extends it so `instanceof` matches.
+class FakeAnalyserNode {
+ constructor({ binCount = 128, sampleRate = 48000, spectrum = null } = {}) {
+ this.fftSize = binCount * 2;
+ this.frequencyBinCount = binCount;
+ this.smoothingTimeConstant = 0.7;
+ this.context = { sampleRate };
+ this._spectrum = new Uint8Array(binCount);
+ if (spectrum) this.setSpectrum(spectrum);
+ }
+ /** spectrum: function(i, binHz) -> 0..255 or Uint8Array */
+ setSpectrum(spectrum) {
+ if (spectrum instanceof Uint8Array) {
+ this._spectrum.set(spectrum.subarray(0, this._spectrum.length));
+ return;
+ }
+ const binHz = this.context.sampleRate / this.fftSize;
+ for (let i = 0; i < this._spectrum.length; i++) {
+ const v = spectrum(i, binHz);
+ this._spectrum[i] = Math.max(0, Math.min(255, v | 0));
+ }
+ }
+ getByteFrequencyData(buf) {
+ buf.set(this._spectrum);
+ }
+}
+
+let LipSyncAnalyser;
+
+beforeAll(async () => {
+ globalThis.AnalyserNode = FakeAnalyserNode;
+ const mod = await import('../src/lip-sync-analyser.js');
+ LipSyncAnalyser = mod.LipSyncAnalyser;
+});
+
+const VISEME_NAMES = [
+ 'viseme_aa', 'viseme_O', 'viseme_E', 'viseme_I', 'viseme_nn',
+ 'viseme_SS', 'viseme_FF', 'viseme_CH', 'viseme_PP',
+];
+
+function makeBand(level, lowHz, highHz) {
+ return (i, binHz) => {
+ const f = i * binHz;
+ return f >= lowHz && f < highHz ? level : 0;
+ };
+}
+
+describe('LipSyncAnalyser', () => {
+ let analyser;
+ beforeEach(() => {
+ analyser = new LipSyncAnalyser();
+ });
+
+ it('returns null when not connected', () => {
+ expect(analyser.sample()).toBeNull();
+ });
+
+ it('returns null after disconnect', () => {
+ const fake = new FakeAnalyserNode({ spectrum: () => 200 });
+ analyser.connect(fake);
+ expect(analyser.sample()).not.toBeNull();
+ analyser.disconnect();
+ expect(analyser.sample()).toBeNull();
+ });
+
+ it('emits all 9 viseme keys with numeric weights once connected', () => {
+ const fake = new FakeAnalyserNode({ spectrum: () => 200 });
+ analyser.connect(fake);
+ const out = analyser.sample();
+ expect(out).not.toBeNull();
+ for (const k of VISEME_NAMES) {
+ expect(out).toHaveProperty(k);
+ expect(typeof out[k]).toBe('number');
+ expect(Number.isFinite(out[k])).toBe(true);
+ expect(out[k]).toBeGreaterThanOrEqual(0);
+ }
+ });
+
+ it('low-frequency energy biases open-vowel visemes (aa, O) over sibilants (SS, FF)', () => {
+ const fake = new FakeAnalyserNode({ spectrum: makeBand(220, 0, 500) });
+ analyser.connect(fake);
+ // Run several samples so the EMA settles toward the target.
+ let out;
+ for (let i = 0; i < 40; i++) out = analyser.sample();
+ expect(out.viseme_aa).toBeGreaterThan(out.viseme_SS);
+ expect(out.viseme_aa).toBeGreaterThan(out.viseme_FF);
+ expect(out.viseme_O).toBeGreaterThan(out.viseme_SS);
+ });
+
+ it('high-frequency energy biases sibilant/fricative visemes (SS, FF, CH) over open vowels', () => {
+ const fake = new FakeAnalyserNode({ spectrum: makeBand(220, 2500, 7500) });
+ analyser.connect(fake);
+ let out;
+ for (let i = 0; i < 40; i++) out = analyser.sample();
+ expect(out.viseme_SS).toBeGreaterThan(out.viseme_aa);
+ expect(out.viseme_FF).toBeGreaterThan(out.viseme_O);
+ });
+
+ it('silence decays all viseme weights toward zero (multiplicative ramp)', () => {
+ const fake = new FakeAnalyserNode({ spectrum: makeBand(220, 0, 500) });
+ analyser.connect(fake);
+ // Warm up to non-trivial weights.
+ let warm;
+ for (let i = 0; i < 40; i++) warm = analyser.sample();
+ const peak = warm.viseme_aa;
+ expect(peak).toBeGreaterThan(0.01);
+
+ // Switch to silence — weights should monotonically decay.
+ fake.setSpectrum(() => 0);
+ let prev = peak;
+ for (let i = 0; i < 30; i++) {
+ const out = analyser.sample();
+ expect(out.viseme_aa).toBeLessThanOrEqual(prev + 1e-9);
+ prev = out.viseme_aa;
+ }
+ expect(prev).toBeLessThan(peak * 0.05);
+ });
+
+ it('smooths over multiple frames rather than snapping to the target', () => {
+ const fake = new FakeAnalyserNode({ spectrum: makeBand(255, 0, 500) });
+ analyser.connect(fake);
+ // First non-silent frame: weight rises but is bounded by the EMA factor.
+ // Two consecutive samples should be strictly increasing while ramping up.
+ const a = analyser.sample().viseme_aa;
+ const b = analyser.sample().viseme_aa;
+ const c = analyser.sample().viseme_aa;
+ expect(b).toBeGreaterThan(a);
+ expect(c).toBeGreaterThan(b);
+ // And never overshoots a fully-saturated band (low * 0.8 → ≤ 0.8).
+ for (let i = 0; i < 60; i++) analyser.sample();
+ const stable = analyser.sample().viseme_aa;
+ expect(stable).toBeLessThanOrEqual(0.8 + 1e-6);
+ });
+
+ it('connect() is idempotent: a second connect releases the first analyser', () => {
+ const a = new FakeAnalyserNode({ spectrum: () => 200 });
+ const b = new FakeAnalyserNode({ spectrum: () => 200 });
+ analyser.connect(a);
+ expect(analyser.sample()).not.toBeNull();
+ analyser.connect(b);
+ // Still working with the new analyser.
+ expect(analyser.sample()).not.toBeNull();
+ });
+
+ it('connect() with an unsupported input is a no-op (sample() stays null)', () => {
+ analyser.connect({ totally: 'not an audio node' });
+ expect(analyser.sample()).toBeNull();
+ });
+});