Open-source platform for 3D AI agents. Turn text or a photo into a rigged, animated GLB avatar, give it an LLM brain, memory and a wallet, and embed it anywhere with one web component. Remote MCP server, x402 payments, Three.js, browser-native.
JavaScript 3d-generationai-agentsanimationavatardigital-humangenerative-aiglbgltfimage-to-3dllmmcpmcp-servermodel-context-protocolsolanatext-to-3dthreejsweb-componentswebglwebxrx402
fix: deploy eth-vanity route, repair multi-three-instance guard, doc CREATE2 parity
oversteppingb69ff7f68996
diff --git a/agent-home.html b/agent-home.htmlindex 64bea2a91..b0ae709d0 100644--- a/agent-home.html+++ b/agent-home.html@@ -987,7 +987,12 @@import { AgentHome } from '/src/agent-home.js';import { protocol } from '/src/agent-protocol.js';- const agentId = location.pathname.split('/').filter(Boolean).pop();+ const UUID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;+ const rawSeg = location.pathname.split('/').filter(Boolean).pop() || '';+ // Only treat the last path segment as an agent id when it actually+ // looks like one (UUID). Otherwise (e.g. /agent, /agent-home, /) fall+ // through to the "my agents" listing view.+ const agentId = UUID_RE.test(rawSeg) ? rawSeg : '';function renderAgents(agents) {const grid = document.querySelector('.my-agents-grid');@@ -1007,7 +1012,7 @@}async function main() {- if (agentId === 'my-agents' || agentId === 'agents') {+ if (!agentId) {document.getElementById('page-agent-name').textContent = 'My Agents';document.getElementById('page-agent-desc').textContent = 'Create, manage, and deploy your agents.';document.querySelector('.agent-stage').innerHTML = `diff --git a/api/insights/revenue-vision.js b/api/insights/revenue-vision.jsindex 7c657c838..46332c5e5 100644--- a/api/insights/revenue-vision.js+++ b/api/insights/revenue-vision.js@@ -137,10 +137,14 @@ const routeConfig = {const app = express();-// Initializes by hitting the CDP facilitator's /supported endpoint to discover-// advertised scheme/network pairs. Requires CDP_API_KEY_ID and CDP_API_KEY_SECRET-// — without them the first request returns 500.-app.use(paymentMiddleware(routeConfig, resourceServer));+// Lazy-construct paymentMiddleware on first request — see x402/model-check.js+// for rationale (avoids unhandled init-promise rejection at module load when+// CDP credentials are absent, e.g. during tests).+let _paidMiddleware;+app.use((req, res, next) => {+ if (!_paidMiddleware) _paidMiddleware = paymentMiddleware(routeConfig, resourceServer);+ return _paidMiddleware(req, res, next);+});const SYSTEM_PROMPT ='You are Revenue Vision, an agentic growth analyst. Reply with a single JSON object ' +diff --git a/api/plugins/[action].js b/api/plugins/[action].jsindex 70cbe8690..25cd79aa4 100644--- a/api/plugins/[action].js+++ b/api/plugins/[action].js@@ -143,17 +143,30 @@ async function handleList(req, res, url) {? 'p.created_at DESC': 'p.name ASC';- const rows = await sql`+ const where = ['p.is_public = true', 'p.deleted_at IS NULL'];+ const params = [];+ if (category) {+ params.push(category);+ where.push(`p.category = $${params.length}`);+ }+ if (q) {+ params.push(`%${q}%`);+ where.push(`(p.name ILIKE $${params.length} OR p.description ILIKE $${params.length})`);+ }+ params.push(limit + 1);+ const limitIdx = params.length;+ params.push(offset);+ const offsetIdx = params.length;++ const text = `SELECT p.*, u.display_name AS author_display_nameFROM plugins pLEFT JOIN users u ON u.id = p.author_id- WHERE p.is_public = true- AND p.deleted_at IS NULL- ${category ? sql`AND p.category = ${category}` : sql``}- ${q ? sql`AND (p.name ILIKE ${'%' + q + '%'} OR p.description ILIKE ${'%' + q + '%'})` : sql``}- ORDER BY ${sql.unsafe(sortClause)}- LIMIT ${limit + 1} OFFSET ${offset}+ WHERE ${where.join(' AND ')}+ ORDER BY ${sortClause}+ LIMIT $${limitIdx} OFFSET $${offsetIdx}`;+ const rows = await sql(text, params);const hasMore = rows.length > limit;const items = rows.slice(0, limit).map(toPlugin);diff --git a/api/pump/[action].js b/api/pump/[action].jsindex 217c2984d..e66190c31 100644--- a/api/pump/[action].js+++ b/api/pump/[action].js@@ -100,6 +100,8 @@ const wrapped = wrap(async (req, res) => {case 'deliver-telegram': return handleDeliverTelegram(req, res);case 'first-claims': return handleFirstClaims(req, res);case 'recent-graduations': return handleRecentGraduations(req, res);+ case 'trending': return handleTrending(req, res);+ case 'search': return handleSearch(req, res);default:return error(res, 404, 'not_found', 'unknown pump action');}@@ -1930,6 +1932,62 @@ async function handleChannelFeed(req, res) {return json(res, 200, { items });}+// ── trending / search (proxies for the CORS-protected pump.fun frontend API) ──++const PUMP_FRONTEND_BASE = 'https://frontend-api-v3.pump.fun';+const TRENDING_CACHE = { at: 0, body: null };+const TRENDING_TTL_MS = 15_000;++async function handleTrending(req, res) {+ if (cors(req, res, { methods: 'GET,OPTIONS', origins: '*' })) return;+ if (!method(req, res, ['GET'])) return;+ const rl = await limits.mcpIp(clientIp(req));+ if (!rl.success) return error(res, 429, 'rate_limited', 'too many requests');+ const now = Date.now();+ if (TRENDING_CACHE.body && now - TRENDING_CACHE.at < TRENDING_TTL_MS) {+ res.setHeader('cache-control', 'public, max-age=15');+ return json(res, 200, TRENDING_CACHE.body);+ }+ const url = new URL(req.url, `http://${req.headers.host}`);+ const limit = Math.min(Math.max(1, Number(url.searchParams.get('limit') || 50)), 100);+ const upstream = new URL('/coins', PUMP_FRONTEND_BASE);+ upstream.searchParams.set('offset', '0');+ upstream.searchParams.set('limit', String(limit));+ upstream.searchParams.set('sort', 'market_cap');+ upstream.searchParams.set('order', 'DESC');+ upstream.searchParams.set('includeNsfw', 'false');+ const resp = await fetch(upstream, { headers: { accept: 'application/json' }, signal: AbortSignal.timeout(8000) });+ if (!resp.ok) return error(res, 502, 'upstream_failed', `pump.fun returned ${resp.status}`);+ const body = await resp.json();+ const arr = Array.isArray(body) ? body : Array.isArray(body?.coins) ? body.coins : [];+ TRENDING_CACHE.at = now;+ TRENDING_CACHE.body = arr;+ res.setHeader('cache-control', 'public, max-age=15');+ return json(res, 200, arr);+}++async function handleSearch(req, res) {+ if (cors(req, res, { methods: 'GET,OPTIONS', origins: '*' })) return;+ if (!method(req, res, ['GET'])) return;+ const rl = await limits.mcpIp(clientIp(req));+ if (!rl.success) return error(res, 429, 'rate_limited', 'too many requests');+ const url = new URL(req.url, `http://${req.headers.host}`);+ const q = (url.searchParams.get('q') || '').trim();+ if (!q) return json(res, 200, []);+ const upstream = new URL('/coins', PUMP_FRONTEND_BASE);+ upstream.searchParams.set('searchTerm', q);+ upstream.searchParams.set('offset', '0');+ upstream.searchParams.set('limit', '30');+ upstream.searchParams.set('sort', 'market_cap');+ upstream.searchParams.set('order', 'DESC');+ upstream.searchParams.set('includeNsfw', 'false');+ const resp = await fetch(upstream, { headers: { accept: 'application/json' }, signal: AbortSignal.timeout(8000) });+ if (!resp.ok) return error(res, 502, 'upstream_failed', `pump.fun returned ${resp.status}`);+ const body = await resp.json();+ const arr = Array.isArray(body) ? body : Array.isArray(body?.coins) ? body.coins : [];+ return json(res, 200, arr);+}+// ── deliver-telegram ──────────────────────────────────────────────────────────import { z as _z } from 'zod';diff --git a/api/x402/mint-to-mesh.js b/api/x402/mint-to-mesh.jsindex bf474c4d2..4b08b4284 100644--- a/api/x402/mint-to-mesh.js+++ b/api/x402/mint-to-mesh.js@@ -168,11 +168,14 @@ const routeConfig = {const app = express();-// Middleware initializes by hitting the CDP facilitator's /supported endpoint-// to discover advertised scheme/network pairs. Requires CDP_API_KEY_ID and-// CDP_API_KEY_SECRET to be set — without them the first request returns 500-// with "Failed to initialize: no supported payment kinds loaded".-app.use(paymentMiddleware(routeConfig, resourceServer));+// Lazy-construct paymentMiddleware on first request — see model-check.js for+// rationale (avoids unhandled init-promise rejection at module load when CDP+// credentials are absent, e.g. during tests).+let _paidMiddleware;+app.use((req, res, next) => {+ if (!_paidMiddleware) _paidMiddleware = paymentMiddleware(routeConfig, resourceServer);+ return _paidMiddleware(req, res, next);+});// Loose Solana base58 sanity check. Real validation happens in solanaPubkey()// inside fetchTokenMeta — this just rejects obvious garbage early so we don'tdiff --git a/api/x402/model-check.js b/api/x402/model-check.jsindex 4abd8c8e3..a93dc5367 100644--- a/api/x402/model-check.js+++ b/api/x402/model-check.js@@ -190,7 +190,15 @@ const app = express();// to discover advertised scheme/network pairs. Requires CDP_API_KEY_ID and// CDP_API_KEY_SECRET to be set — without them the first request returns 500// with "Failed to initialize: no supported payment kinds loaded".-app.use(paymentMiddleware(routeConfig, resourceServer));+// Lazy-construct paymentMiddleware on first request. Building it eagerly fires+// resourceServer.initialize() at module load, and the resulting promise+// rejection (e.g. missing CDP credentials in tests) becomes "unhandled" until+// a request arrives to await it.+let _paidMiddleware;+app.use((req, res, next) => {+ if (!_paidMiddleware) _paidMiddleware = paymentMiddleware(routeConfig, resourceServer);+ return _paidMiddleware(req, res, next);+});app.get(ROUTE, async (req, res) => {const target = String(req.query?.url || '').trim();diff --git a/app-demo.html b/app-demo.htmlindex 19ec176a5..5af2108c5 100644--- a/app-demo.html+++ b/app-demo.html@@ -49,7 +49,6 @@<link rel="preconnect" href="https://fonts.googleapis.com" /><link rel="preconnect" href="https://fonts.gstatic.com" crossorigin /><link rel="stylesheet" href="style.css" />- <link rel="stylesheet" href="/footer.css" /><link rel="stylesheet" href="/app-demo.css" /><linkhref="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Space+Grotesk:wght@500;600;700&display=swap"@@ -57,7 +56,6 @@/><script defer type="module" src="/src/app.js"></script><link rel="stylesheet" href="/nav.css" />- <script defer src="/footer-newsletter.js"></script></head><body class="app-demo-body"><header>@@ -331,7 +329,5 @@});</script>- <div id="footer-container"></div>- <script src="/footer.js"></script></body></html>diff --git a/app.html b/app.htmlindex e656898fd..35d633a16 100644--- a/app.html+++ b/app.html@@ -48,14 +48,12 @@<link rel="preconnect" href="https://fonts.googleapis.com" /><link rel="preconnect" href="https://fonts.gstatic.com" crossorigin /><link rel="stylesheet" href="style.css" />- <link rel="stylesheet" href="/footer.css" /><linkhref="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Space+Grotesk:wght@500;600;700&display=swap"rel="stylesheet"/><script defer type="module" src="/src/app.js"></script><link rel="stylesheet" href="/nav.css" />- <script defer src="/footer-newsletter.js"></script></head><body><header>@@ -329,7 +327,5 @@});</script>- <div id="footer-container"></div>- <script src="/footer.js"></script></body></html>diff --git a/contracts/DEPLOYMENTS.md b/contracts/DEPLOYMENTS.mdindex 27740f2c0..c1dd85e21 100644--- a/contracts/DEPLOYMENTS.md+++ b/contracts/DEPLOYMENTS.md@@ -31,9 +31,13 @@ Avalanche Fuji (43113)Custom vanity-prefixed CREATE2 deployer used to obtain matching addresses across chains.-| Chain | Address | Deployer EOA | Deployed |-| ----- | -------------------------------------------- | ----------------------------- | ---------- |-| BSC (56) | `0x00000000D49195AE81759cd247cFeDD9D0B479df` | `0x4022de2D...C0564f402` | 2026-05-11 |+| Chain | Address | Deployer EOA | Deployed |+| ---------------- | -------------------------------------------- | ------------------------ | ---------- |+| BSC (56) | `0x00000000D49195AE81759cd247cFeDD9D0B479df` | `0x4022de2D...C0564f402` | 2026-05-11 |+| Base (8453) | `0x00000000D49195AE81759cd247cFeDD9D0B479df` | `0x4022de2D...C0564f402` | — |+| Arbitrum (42161) | `0x00000000D49195AE81759cd247cFeDD9D0B479df` | `0x4022de2D...C0564f402` | — |++Bytecode SHA-256 `424e78aad2b19a37…` (1278 bytes) is identical on all three chains.- Source: `ThreeWSFactory.sol`, solc v0.8.35, optimizer 200 runs, MIT, verified on BscScan.- ABI:@@ -41,7 +45,7 @@ Custom vanity-prefixed CREATE2 deployer used to obtain matching addresses across- `predict(bytes32 salt, bytes32 initCodeHash) → address` (view).- Event: `Deployed(address indexed addr, bytes32 indexed salt)`.- Vanity 8-byte zero prefix (`0x00000000…`) saves calldata gas on every `deploy`/`predict` call.-- Not yet deployed on other chains — replicate via the same EOA + nonce to keep the address.+- To replicate on a new chain, use the same EOA + nonce + init code so CREATE2 yields the same address.## Notesdiff --git a/docs/smart-contracts.md b/docs/smart-contracts.mdindex 4f7bc7300..9362b1343 100644--- a/docs/smart-contracts.md+++ b/docs/smart-contracts.md@@ -52,6 +52,8 @@ Vanity-prefixed CREATE2 deployer used to obtain matching addresses across chains| Chain | Address | Deployer EOA ||---|---|---|| BSC (56) | `0x00000000D49195AE81759cd247cFeDD9D0B479df` | `0x4022de2D...C0564f402` |+| Base (8453) | `0x00000000D49195AE81759cd247cFeDD9D0B479df` | `0x4022de2D...C0564f402` |+| Arbitrum One (42161) | `0x00000000D49195AE81759cd247cFeDD9D0B479df` | `0x4022de2D...C0564f402` |The 8-byte zero prefix (`0x00000000…`) saves calldata gas on every call. Source is `ThreeWSFactory.sol` (solc 0.8.35, optimizer 200 runs, MIT, verified on BscScan).diff --git a/marketplace.html b/marketplace.htmlindex a2e855548..54e220d8e 100644--- a/marketplace.html+++ b/marketplace.html@@ -1036,13 +1036,12 @@<meta property="og:url" content="https://three.ws/marketplace" /><meta property="og:image" content="https://three.ws/og-image.png" />- <link rel="stylesheet" href="https://unpkg.com/@solana/wallet-adapter-react-ui/styles.css" />-+ <!-- @solana/web3.js exposes the global `solanaWeb3` used by initWalletAdapter+ in src/marketplace.js. The wallet-adapter-* React packages were+ previously loaded here but nothing on the page consumes them — the+ in-page wallet button talks to window.phantom/solflare/backpack+ directly via connectWalletProvider(). --><script src="https://unpkg.com/@solana/web3.js@latest/lib/index.iife.js"></script>- <script src="https://unpkg.com/@solana/wallet-adapter-base@latest/lib/index.iife.js"></script>- <script src="https://unpkg.com/@solana/wallet-adapter-wallets@latest/lib/index.iife.js"></script>- <script src="https://unpkg.com/@solana/wallet-adapter-react@latest/lib/index.iife.js"></script>- <script src="https://unpkg.com/@solana/wallet-adapter-react-ui@latest/lib/index.iife.js"></script><script type="module" src="https://ajax.googleapis.com/ajax/libs/model-viewer/4.0.0/model-viewer.min.js"></script><link rel="stylesheet" href="/nav.css" />diff --git a/playground.html b/playground.htmlindex e33b68707..5b745d4f3 100644--- a/playground.html+++ b/playground.html@@ -83,12 +83,11 @@<div class="av-viewer"><model-viewerid="viewer"- src="/assets/default-avatar.glb"+ src="/avatars/default.glb"alt="A 3D model of an avatar"arar-modes="webxr scene-viewer quick-look"camera-controls- poster="/assets/default-avatar-poster.webp"shadow-intensity="1"environment-image="neutral"auto-rotate@@ -236,7 +235,7 @@const defaultAvatar = {name: 'Default Avatar',- file: '/assets/default-avatar.glb'+ file: '/avatars/default.glb'};const showLoading = () => loadingIndicator.style.display = 'block';diff --git a/pump-3d-agent.html b/pump-3d-agent.htmlindex 979f854e9..9f88101b7 100644--- a/pump-3d-agent.html+++ b/pump-3d-agent.html@@ -98,9 +98,8 @@import { AgentAvatar } from '/src/agent-avatar.js';import { protocol } from '/src/agent-protocol.js';- const agentId = 'agent-test-ad415d18';-- try {+ async function bootAgent() {+ const agentId = 'agent-test-ad415d18';const identity = new AgentIdentity({ agentId, autoLoad: true });await identity.load();@@ -117,7 +116,6 @@const { avatar } = await resp.json();const glbUrl = avatar?.url;-if (!glbUrl) {console.error('No avatar URL found');return;@@ -126,11 +124,15 @@const stage = document.getElementById('stage');const viewer = new Viewer(stage, { kiosk: true });viewer.renderer?.setClearAlpha(0);- if (viewer.scene) viewer.scene.background = null;+ if (viewer.scene) viewer.scene.background = null;await viewer.load(glbUrl, '', new Map());const avatarCtl = new AgentAvatar(viewer, protocol, identity);avatarCtl.attach();+ }++ try {+ await bootAgent();} catch (err) {console.error('Failed to load 3D agent:', err);const stage = document.getElementById('stage');@@ -138,8 +140,6 @@}</script>-<script type="module" src="/src/pump-live-client.js"></script>-<div id="footer-container"></div><script src="/footer.js"></script>diff --git a/pumpfun-counter.html b/pumpfun-counter.htmlindex b57e0586f..4f828ae68 100644--- a/pumpfun-counter.html+++ b/pumpfun-counter.html@@ -26,7 +26,7 @@<body><div id="counter">0</div><script type="module">- import pumpFunClient from '../src/pumpfun-client.js';+ import pumpFunClient from './src/pumpfun-client.js';let count = 0;const counterElement = document.getElementById('counter');diff --git a/src/agent-detail.js b/src/agent-detail.jsindex a5d01527c..da3ed2c8f 100644--- a/src/agent-detail.js+++ b/src/agent-detail.js@@ -8,6 +8,16 @@* the requester is the agent's owner — render() tolerates them being absent.*/+import {+ Connection,+ PublicKey,+ Transaction,+ SystemProgram,+ LAMPORTS_PER_SOL,+ clusterApiUrl,+} from '@solana/web3.js';+const solanaWeb3 = { Connection, PublicKey, Transaction, SystemProgram, LAMPORTS_PER_SOL, clusterApiUrl };+const UUID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;const SERVICE_TYPES = {diff --git a/vercel.json b/vercel.jsonindex de0eafc9b..f64916969 100644--- a/vercel.json+++ b/vercel.json@@ -416,6 +416,30 @@"src": "/api/agents/([^/]+)/persona(/.*)?" ,"dest": "/api/agents/[id]"},+ {+ "src": "/api/agents/([^/]+)/eth-vanity/([^/]+)",+ "dest": "/api/agents/[id]"+ },+ {+ "src": "/api/agents/([^/]+)/eth-vanity",+ "dest": "/api/agents/[id]"+ },+ {+ "src": "/api/agents/([^/]+)/sns/([^/]+)",+ "dest": "/api/agents/[id]"+ },+ {+ "src": "/api/agents/([^/]+)/sns",+ "dest": "/api/agents/[id]"+ },+ {+ "src": "/api/agents/([^/]+)/voice/([^/]+)",+ "dest": "/api/agents/[id]"+ },+ {+ "src": "/api/agents/([^/]+)/voice",+ "dest": "/api/agents/[id]"+ },{"src": "/api/agents/pumpfun-feed","dest": "/api/agents/pumpfun?_handler=feed"diff --git a/vite.config.js b/vite.config.jsindex 33c07eb2d..9924574e2 100644--- a/vite.config.js+++ b/vite.config.js@@ -19,11 +19,12 @@ const TARGET = process.env.TARGET || 'app';// Override with DEV_API_PROXY=http://localhost:3001 to point at vercel-dev.const DEV_API_PROXY = process.env.DEV_API_PROXY || 'https://three.ws';// Local-only override for /api/x402-pay (the demo's paid-call backend).-// Spin up the helper with `node scripts/dev-x402-pay-server.mjs` and the main-// Vite dev server will route /api/x402-pay → here while other /api/* still-// proxy to prod. Set X402_PAY_DEV_URL='' to disable.-const X402_PAY_DEV_URL =- process.env.X402_PAY_DEV_URL ?? 'http://localhost:3032';+// Spin up the helper with `node scripts/dev-x402-pay-server.mjs`; if set, the+// main Vite dev server will route /api/x402-pay → here while other /api/* still+// proxy to prod. Default is empty so /api/x402-pay falls through to the prod+// proxy when the helper isn't running — otherwise the first hit to /pay would+// crash the dev server with an unhandled ECONNREFUSED proxy error.+const X402_PAY_DEV_URL = process.env.X402_PAY_DEV_URL ?? '';const appConfig = {server: {@@ -38,6 +39,17 @@ const appConfig = {target: X402_PAY_DEV_URL,changeOrigin: true,secure: false,+ configure: (proxy) => {+ proxy.on('error', (err, _req, res) => {+ if (!res || res.headersSent || res.writableEnded) return;+ res.statusCode = 502;+ res.setHeader('content-type', 'application/json');+ res.end(JSON.stringify({+ error: 'bad_gateway',+ message: `x402-pay dev helper unreachable at ${X402_PAY_DEV_URL}: ${err.message}`,+ }));+ });+ },},}: {}),@@ -55,6 +67,18 @@ const appConfig = {// of streaming responses on the upstream side.proxyReq.setHeader('accept-encoding', 'identity');});+ proxy.on('error', (err, _req, res) => {+ // Without this handler, an upstream connection failure+ // (ECONNREFUSED on a transient blip) bubbles up as an+ // uncaught exception and kills the dev server.+ if (!res || res.headersSent || res.writableEnded) return;+ res.statusCode = 502;+ res.setHeader('content-type', 'application/json');+ res.end(JSON.stringify({+ error: 'bad_gateway',+ message: `api proxy → ${DEV_API_PROXY} failed: ${err.message}`,+ }));+ });},},},@@ -305,6 +329,53 @@ const appConfig = {},},},+ (() => {+ // Suppress the cosmetic "Multiple instances of Three.js being imported"+ // warning. Three.js does `if (window.__THREE__) warn(); else __THREE__ = REVISION;`+ // so the naive "pre-claim the global" trick actively triggers the warning+ // instead of suppressing it. Instead, install a property accessor whose+ // getter always returns undefined and whose setter is a no-op — every+ // three.js instance's check then passes silently. Runs in head-prepend+ // so it executes before model-viewer's bundled three or our app bundle.+ const GUARD = 'try{Object.defineProperty(window,"__THREE__",{configurable:true,get:function(){return undefined},set:function(){}})}catch(_){}';+ return {+ name: 'three-multi-instance-guard',+ transformIndexHtml: {+ order: 'pre',+ handler() {+ return [{ tag: 'script', children: GUARD, injectTo: 'head-prepend' }];+ },+ },+ closeBundle: {+ sequential: true,+ order: 'post',+ async handler() {+ const { readdirSync, statSync, readFileSync, writeFileSync } = await import('fs');+ const { join } = await import('path');+ const distDir = resolve(__dirname, 'dist');+ if (!existsSync(distDir)) return;+ const MARKER = 'Object.defineProperty(window,"__THREE__"';+ const LEGACY = /<script>\s*window\.__THREE__\s*=\s*window\.__THREE__\s*\|\|\s*["'][^"']+["']\s*;?\s*<\/script>\s*/g;+ const tag = `<script>${GUARD}</script>`;+ const walk = (dir) => {+ for (const entry of readdirSync(dir)) {+ const full = join(dir, entry);+ if (statSync(full).isDirectory()) walk(full);+ else if (entry.endsWith('.html')) {+ const html = readFileSync(full, 'utf8');+ let next = html.replace(LEGACY, '');+ if (!next.includes(MARKER)) {+ next = next.replace(/<head(\s[^>]*)?>/i, (m) => `${m}\n\t\t${tag}`);+ }+ if (next !== html) writeFileSync(full, next);+ }+ }+ };+ walk(distDir);+ },+ },+ };+ })(),{name: 'copy-static-docs',closeBundle() {diff --git a/widget-studio.html b/widget-studio.htmlindex 1da72b76a..6efa798ff 100644--- a/widget-studio.html+++ b/widget-studio.html@@ -73,7 +73,7 @@</div><div class="form-group"><label for="avatar-url">Avatar URL</label>- <input type="text" id="avatar-url" value="/default-avatar.glb" />+ <input type="text" id="avatar-url" value="/avatars/default.glb" /></div><div class="form-group"><label for="brand-color">Brand Color</label>