Open-source platform for 3D AI agents. Turn text or a photo into a rigged, animated GLB avatar, give it an LLM brain, memory and a wallet, and embed it anywhere with one web component. Remote MCP server, x402 payments, Three.js, browser-native.
JavaScript 3d-generationai-agentsanimationavatardigital-humangenerative-aiglbgltfimage-to-3dllmmcpmcp-servermodel-context-protocolsolanatext-to-3dthreejsweb-componentswebglwebxrx402
feat(tests): add tests for discover/my-agents rename and routing
nirholasaf549fbb1179
diff --git a/agent-embed.html b/agent-embed.htmlindex 86a811434..398608f92 100644--- a/agent-embed.html+++ b/agent-embed.html@@ -28,9 +28,7 @@}#stage .gui-wrap,#stage .gui-toggle,- #stage .annotation-canvas {- display: none !important;- }+ #stage .annotation-canvas,#stage .model-info {display: none !important;}@@ -62,6 +60,10 @@body.bg-light {background: #f5f5f5;}+ body.bg-light #name-plate {+ color: rgba(0, 0, 0, 0.55);+ text-shadow: none;+ }</style></head><body>@@ -70,11 +72,50 @@<div id="error"></div><script type="module">+ /*+ * ─── Host ↔ agent postMessage bridge — v1 (FROZEN) ───────────────────+ *+ * Wire format. All payloads are JSON-serializable. All messages MUST+ * include `agentId` so a single host page with multiple iframes can+ * route deterministically. Unknown `type` values are ignored.+ *+ * Host → iframe:+ * { type: 'agent:hello', agentId, host? } Handshake. Iframe replies+ * with agent:ready (now or+ * when init completes).+ * { type: 'agent:action', agentId, action } Forward action onto the+ * iframe's protocol bus.+ * See src/agent-protocol.js+ * for action.type vocabulary.+ * { type: 'agent:ping', agentId, id } Liveness probe; iframe+ * replies with agent:pong{id}.+ *+ * Iframe → host:+ * { type: 'agent:ready', agentId, version, capabilities: [string], name }+ * Sent once init succeeds and+ * in response to agent:hello.+ * { type: 'agent:action', agentId, action } Echo of every protocol+ * action the iframe emits.+ * { type: 'agent:resize', agentId, height } Preferred CSS pixel height+ * of the iframe content box.+ * { type: 'agent:pong', agentId, id } Reply to agent:ping.+ * { type: 'agent:blocked', agentId } Embed policy denied this host.+ *+ * Legacy envelope `{ __agent, type: 'action'|'ready'|'blocked' }` is still+ * accepted on input and emitted on output for backwards compatibility with+ * pre-v1 hosts. New consumers SHOULD prefer the v1 envelope above.+ *+ * Future bumps go to v2 — DO NOT change v1 wire shapes in place.+ */+import { Viewer } from './src/viewer.js';import { AgentIdentity } from './src/agent-identity.js';import { AgentAvatar } from './src/agent-avatar.js';import { protocol } from './src/agent-protocol.js';+ const BRIDGE_VERSION = '1';+ const CAPABILITIES = ['speak', 'gesture', 'look-at', 'emote', 'present-model'];+const params = new URL(location.href).searchParams;const bg = params.get('bg') || 'transparent';if (bg === 'dark') document.body.classList.add('bg-dark');@@ -82,8 +123,19 @@const plateOn = params.get('name') !== '0';const preview = params.get('preview') === '1';- const parts = location.pathname.split('/').filter(Boolean);- const agentId = parts[parts.indexOf('agent') + 1];++ // Resolve agentId from either:+ // 1. /agent/{id}/embed (Vercel rewrite + vite middleware)+ // 2. /agent-embed.html?id={id} (direct file access — share snippet legacy form)+ // 3. ?id={id} (any path — explicit override)+ const agentId = (() => {+ const parts = location.pathname.split('/').filter(Boolean);+ const idx = parts.indexOf('agent');+ if (idx !== -1 && parts[idx + 1] && parts[idx + 1] !== 'embed') {+ return parts[idx + 1];+ }+ return params.get('id') || null;+ })();function hostMatches(host, pattern) {if (!host || !pattern) return false;@@ -97,6 +149,10 @@}function embeddingHost() {+ // Prefer ancestorOrigins (Chromium/Safari) for the true top-level+ // origin; fall back to document.referrer which is the cross-browser+ // signal for a first-party iframe's parent. Firefox has no+ // ancestorOrigins today.try {const anc = window.location.ancestorOrigins;if (anc && anc.length) return new URL(anc[0]).hostname;@@ -107,11 +163,11 @@return null;}- // Normalise policy to extended shape; returns null when no policy is set.+ // Normalize legacy { mode, hosts } policy shape to the extended shape.+ // Returns null when the agent has no policy at all.function normalisePolicy(raw) {if (!raw) return null;if (!('version' in raw) && ('mode' in raw || 'hosts' in raw)) {- // Old flat { mode, hosts } shape — only origins were configured.return {version: 1,origins: {@@ -124,31 +180,8 @@return raw;}- function buildCspContent(policy) {- const base = ["'self'", 'https://3dagent.vercel.app'];- if (policy?.origins?.hosts?.length) {- for (const h of policy.origins.hosts) {- const lower = h.toLowerCase();- // CSP wildcard format: *.foo.com → https://*.foo.com- base.push(lower.startsWith('*.') ? `https://${lower}` : `https://${lower}`);- }- }- return `frame-ancestors ${[...new Set(base)].join(' ')}`;- }-- function insertCspMeta(policy) {- const existing = document.querySelector(- 'meta[http-equiv="Content-Security-Policy"]',- );- if (existing) existing.remove();- const meta = document.createElement('meta');- meta.httpEquiv = 'Content-Security-Policy';- meta.content = buildCspContent(policy);- document.head.insertBefore(meta, document.head.querySelector('script'));- }-async function checkPolicy() {- if (preview) return true;+ if (preview) return { ok: true };const sameOrigin =!window.parent ||window.parent === window ||@@ -159,6 +192,7 @@return false;}})();+let rawPolicy = null;try {const r = await fetch(`/api/agents/${agentId}/embed-policy`, {@@ -168,30 +202,26 @@} catch {}const policy = normalisePolicy(rawPolicy);- insertCspMeta(policy);+ if (policy === null) return { ok: true };- if (policy === null) return true;if (sameOrigin) {- // surfaces.iframe gate still runs even for same-origin embeds- if (policy.surfaces && policy.surfaces.iframe === false) return false;- return true;+ if (policy.surfaces && policy.surfaces.iframe === false) {+ return { ok: false, reason: 'iframe-disabled' };+ }+ return { ok: true };}- // Origin check (existing logic, extended shape)const host = embeddingHost();const hosts = policy.origins?.hosts ?? [];const mode = policy.origins?.mode ?? 'allowlist';const matched = host ? hosts.some((p) => hostMatches(host, p)) : false;const originOk = mode === 'allowlist' ? matched : !matched;- if (!originOk) return false;+ if (!originOk) return { ok: false, reason: 'origin-not-allowed' };- // surfaces.iframe gate — fail-closedif (policy.surfaces && policy.surfaces.iframe === false) {- showError("This agent's iframe embed is disabled.");- return false;+ return { ok: false, reason: 'iframe-disabled' };}-- return true;+ return { ok: true };}function showError(msg) {@@ -200,15 +230,91 @@el.style.display = 'flex';}+ // ── Bridge state. The handshake handler is installed *before* main()+ // runs so a host that sends agent:hello early gets a reply once we're+ // ready, even if init takes a few seconds (network + GLB parse).+ let bridgeReady = false;+ let identityName = null;+ const pendingHellos = [];++ function postReady() {+ parent?.postMessage(+ {+ type: 'agent:ready',+ agentId,+ version: BRIDGE_VERSION,+ capabilities: CAPABILITIES,+ name: identityName,+ },+ '*',+ );+ // Legacy envelope for pre-v1 hosts.+ parent?.postMessage(+ { __agent: agentId, type: 'ready', name: identityName },+ '*',+ );+ }++ function postResize(height) {+ parent?.postMessage({ type: 'agent:resize', agentId, height }, '*');+ }++ function handleAction(action) {+ if (!action || typeof action !== 'object') return;+ protocol.emit(action);+ }++ window.addEventListener('message', (ev) => {+ const msg = ev.data;+ if (!msg || typeof msg !== 'object') return;++ // v1 envelope+ if (msg.agentId && msg.agentId === agentId && typeof msg.type === 'string') {+ switch (msg.type) {+ case 'agent:hello':+ if (bridgeReady) postReady();+ else pendingHellos.push(true);+ return;+ case 'agent:action':+ if (bridgeReady) handleAction(msg.action);+ return;+ case 'agent:ping':+ if (bridgeReady)+ parent?.postMessage(+ { type: 'agent:pong', agentId, id: msg.id },+ '*',+ );+ return;+ }+ }++ // Legacy envelope. Kept until all known hosts migrate.+ if (msg.__agent === agentId) {+ if (msg.type === 'action' && msg.action) handleAction(msg.action);+ }+ });+async function main() {- if (!(await checkPolicy())) {- showError('This agent can only be embedded on approved sites.');+ if (!agentId) {+ showError('Missing agent id.');+ return;+ }++ const policyCheck = await checkPolicy();+ if (!policyCheck.ok) {+ const msg =+ policyCheck.reason === 'iframe-disabled'+ ? "This agent's iframe embed is disabled."+ : 'This agent can only be embedded on approved sites.';+ showError(msg);+ parent?.postMessage({ type: 'agent:blocked', agentId }, '*');parent?.postMessage({ __agent: agentId, type: 'blocked' }, '*');return;}const identity = new AgentIdentity({ agentId, autoLoad: false });await identity.load();+ identityName = identity.name;if (plateOn && identity.name) {document.getElementById('name-plate').textContent = identity.name;@@ -232,83 +338,82 @@}await viewer.load(glbUrl, '', new Map());- if (bg !== 'transparent') {+ if (bg === 'dark') {+ // Midnight-blue atmosphere with volumetric clouds.const { Clouds, Cloud } = await import('./src/cloud.js');- // Midnight-blue atmosphere — set three.js scene background to match body- viewer.scene.background.set('#070b18');+ if (viewer.scene.background?.set) viewer.scene.background.set('#070b18');const clouds = new Clouds({ limit: 350 });-- // Deep background sweep — wide, slow, anchors the scene- const back = new Cloud({- seed: 1,- segments: 40,- bounds: [14, 5, 4],- volume: 4,- color: '#7a9ad8',- fade: 32,- opacity: 0.9,- speed: 0.012,- });- back.position.set(0, 1.5, -9);- clouds.add(back);-- // Mid left — cool blue wisps- const left = new Cloud({- seed: 7,- segments: 25,- bounds: [6, 2.5, 2],- volume: 3,- color: '#b8ccff',- fade: 20,- opacity: 0.65,- speed: 0.038,- });- left.position.set(-3.5, 0.8, -5);- clouds.add(left);-- // Mid right — slightly warmer, offset depth- const right = new Cloud({- seed: 13,- segments: 25,- bounds: [6, 2, 2],- volume: 3,- color: '#ccd8ff',- fade: 22,- opacity: 0.6,- speed: 0.05,- });- right.position.set(3.2, 1.2, -6);- clouds.add(right);-- // Foreground haze — etheral and close, fades fast- const fore = new Cloud({- seed: 42,- segments: 15,- bounds: [4, 1.5, 1],- volume: 2,- color: 'white',- fade: 7,- opacity: 0.28,- speed: 0.07,- });- fore.position.set(0, -0.8, -2);- clouds.add(fore);-- // Upper accent — gives vertical depth- const top = new Cloud({- seed: 99,- segments: 18,- bounds: [8, 2, 2],- volume: 3.5,- color: '#a0b8f0',- fade: 25,- opacity: 0.5,- speed: 0.025,- });- top.position.set(-1, 4, -7);- clouds.add(top);-+ clouds.add(+ _makeCloud({+ seed: 1,+ segments: 40,+ bounds: [14, 5, 4],+ volume: 4,+ color: '#7a9ad8',+ fade: 32,+ opacity: 0.9,+ speed: 0.012,+ pos: [0, 1.5, -9],+ Cloud,+ }),+ );+ clouds.add(+ _makeCloud({+ seed: 7,+ segments: 25,+ bounds: [6, 2.5, 2],+ volume: 3,+ color: '#b8ccff',+ fade: 20,+ opacity: 0.65,+ speed: 0.038,+ pos: [-3.5, 0.8, -5],+ Cloud,+ }),+ );+ clouds.add(+ _makeCloud({+ seed: 13,+ segments: 25,+ bounds: [6, 2, 2],+ volume: 3,+ color: '#ccd8ff',+ fade: 22,+ opacity: 0.6,+ speed: 0.05,+ pos: [3.2, 1.2, -6],+ Cloud,+ }),+ );+ clouds.add(+ _makeCloud({+ seed: 42,+ segments: 15,+ bounds: [4, 1.5, 1],+ volume: 2,+ color: 'white',+ fade: 7,+ opacity: 0.28,+ speed: 0.07,+ pos: [0, -0.8, -2],+ Cloud,+ }),+ );+ clouds.add(+ _makeCloud({+ seed: 99,+ segments: 18,+ bounds: [8, 2, 2],+ volume: 3.5,+ color: '#a0b8f0',+ fade: 25,+ opacity: 0.5,+ speed: 0.025,+ pos: [-1, 4, -7],+ Cloud,+ }),+ );viewer.scene.add(clouds);if (!viewer._afterAnimateHooks) viewer._afterAnimateHooks = [];viewer._afterAnimateHooks.push((dt) => clouds.update(viewer.activeCamera, dt));@@ -317,12 +422,43 @@const avatarCtl = new AgentAvatar(viewer, protocol, identity);avatarCtl.attach();- window.addEventListener('message', (ev) => {- const msg = ev.data;- if (!msg || msg.__agent !== agentId) return;- if (msg.type === 'action' && msg.action) protocol.emit(msg.action);+ // Echo every protocol action onto the bridge so hosts can mirror state+ // (chat UIs, telemetry, host-side animation triggers).+ protocol.on('*', (action) => {+ parent?.postMessage({ type: 'agent:action', agentId, action }, '*');});- parent?.postMessage({ __agent: agentId, type: 'ready', name: identity.name }, '*');++ // Report content height to host so embed-sdk can auto-fit the iframe.+ // Coalesce into rAF so a runaway resize observer can't flood the host.+ let pendingPost = false;+ const reportSize = () => {+ if (pendingPost) return;+ pendingPost = true;+ requestAnimationFrame(() => {+ pendingPost = false;+ const h = Math.ceil(+ document.documentElement.scrollHeight || stage.clientHeight || 0,+ );+ if (h > 0) postResize(h);+ });+ };+ if (typeof ResizeObserver !== 'undefined') {+ new ResizeObserver(reportSize).observe(document.documentElement);+ }+ reportSize();++ bridgeReady = true;+ postReady();+ while (pendingHellos.length) {+ pendingHellos.pop();+ postReady();+ }+ }++ function _makeCloud({ pos, Cloud, ...opts }) {+ const c = new Cloud(opts);+ c.position.set(pos[0], pos[1], pos[2]);+ return c;}main().catch((err) => {diff --git a/public/agent/embed.html b/public/agent/embed.htmldeleted file mode 100644index a9b287fc4..000000000--- a/public/agent/embed.html+++ /dev/null@@ -1,322 +0,0 @@-<!doctype html>-<html lang="en">- <head>- <meta charset="utf-8" />- <title>Agent</title>- <meta name="viewport" content="width=device-width, initial-scale=1.0" />- <meta name="description" content="Embedded 3D agent avatar." />- <meta name="robots" content="noindex" />- <style>- html,- body {- margin: 0;- padding: 0;- height: 100%;- width: 100%;- background: transparent;- overflow: hidden;- font-family: system-ui, sans-serif;- }- #stage {- position: absolute;- inset: 0;- }- #stage canvas {- display: block;- width: 100% !important;- height: 100% !important;- }- #stage .gui-wrap,- #stage .gui-toggle,- #stage .annotation-canvas {- display: none !important;- }- #stage .model-info {- display: none !important;- }- #name-plate {- position: absolute;- left: 12px;- bottom: 10px;- z-index: 2;- pointer-events: none;- font-size: 11px;- color: rgba(255, 255, 255, 0.55);- letter-spacing: 0.04em;- text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6);- }- #error {- position: absolute;- inset: 0;- display: none;- align-items: center;- justify-content: center;- color: rgba(255, 255, 255, 0.4);- font-size: 12px;- padding: 1rem;- text-align: center;- }- body.bg-dark {- background: #0b0d10;- }- body.bg-light {- background: #f5f5f5;- }- </style>- </head>- <body>- <div id="stage"></div>- <div id="name-plate"></div>- <div id="error"></div>-- <script type="module">- /*- * ─── Host ↔ agent postMessage bridge — v1 (FROZEN) ───────────────────- *- * Wire format. All payloads are JSON-serializable. All messages MUST- * include `agentId` so a single host page with multiple iframes can- * route deterministically. Unknown `type` values are ignored.- *- * Host → iframe:- * { type: 'agent:hello', agentId, host? } Handshake. Iframe replies- * with agent:ready (now or- * when init completes).- * { type: 'agent:action', agentId, action } Forward action onto the- * iframe's protocol bus.- * See src/agent-protocol.js- * for action.type vocabulary.- * { type: 'agent:ping', agentId, id } Liveness probe; iframe- * replies with agent:pong{id}.- *- * Iframe → host:- * { type: 'agent:ready', agentId, version, capabilities: [string] }- * Sent once init succeeds and- * in response to agent:hello.- * { type: 'agent:action', agentId, action } Echo of every protocol- * action the iframe emits.- * { type: 'agent:resize', agentId, height } Preferred CSS pixel height- * of the iframe content box.- * { type: 'agent:pong', agentId, id } Reply to agent:ping.- *- * Legacy envelope `{ __agent, type: 'action'|'ready'|'blocked' }` is still- * accepted on input and emitted on output for backwards compatibility with- * pre-v1 hosts. New consumers SHOULD prefer the v1 envelope above.- *- * Future bumps go to v2 — DO NOT change v1 wire shapes in place.- */-- import { Viewer } from '/src/viewer.js';- import { AgentIdentity } from '/src/agent-identity.js';- import { AgentAvatar } from '/src/agent-avatar.js';- import { protocol } from '/src/agent-protocol.js';-- const BRIDGE_VERSION = '1';- const CAPABILITIES = ['speak', 'gesture', 'look-at', 'emote', 'present-model'];-- const params = new URL(location.href).searchParams;- const bg = params.get('bg') || 'transparent';- if (bg === 'dark') document.body.classList.add('bg-dark');- if (bg === 'light') document.body.classList.add('bg-light');-- const plateOn = params.get('name') !== '0';- const preview = params.get('preview') === '1';- const parts = location.pathname.split('/').filter(Boolean);- const agentId = parts[parts.indexOf('agent') + 1];-- function hostMatches(host, pattern) {- if (!host || !pattern) return false;- host = host.toLowerCase();- pattern = pattern.toLowerCase();- if (pattern.startsWith('*.')) {- const suffix = pattern.slice(2);- return host === suffix || host.endsWith('.' + suffix);- }- return host === pattern;- }-- function embeddingHost() {- // Prefer ancestorOrigins (Chromium/Safari) for the true top-level origin;- // fall back to document.referrer which is the cross-browser signal for a- // first-party iframe's parent. Firefox has no ancestorOrigins today.- try {- const anc = window.location.ancestorOrigins;- if (anc && anc.length) return new URL(anc[0]).hostname;- } catch {}- try {- if (document.referrer) return new URL(document.referrer).hostname;- } catch {}- return null;- }-- async function checkPolicy() {- if (preview) return true;- // Same-origin (top-level or iframed from ourselves) is always allowed.- const sameOrigin =- !window.parent ||- window.parent === window ||- (() => {- try {- return window.parent.location.origin === location.origin;- } catch {- return false;- }- })();- let policy = null;- try {- const r = await fetch(`/api/agents/${agentId}/embed-policy`, {- credentials: 'omit',- });- if (r.ok) policy = (await r.json()).policy;- } catch {}- if (policy === null || policy === undefined) return true;- if (sameOrigin) return true;- const host = embeddingHost();- const hosts = Array.isArray(policy.hosts) ? policy.hosts : [];- const matched = host ? hosts.some((p) => hostMatches(host, p)) : false;- if (policy.mode === 'allowlist') return matched;- if (policy.mode === 'denylist') return !matched;- return true;- }-- // ── Bridge state. The handshake handler is installed *before* main()- // runs so a host that sends agent:hello early gets a reply once we're- // ready, even if init takes a few seconds (network + GLB parse).- let bridgeReady = false;- let identityName = null;- const pendingHellos = [];-- function postReady() {- parent?.postMessage(- {- type: 'agent:ready',- agentId,- version: BRIDGE_VERSION,- capabilities: CAPABILITIES,- name: identityName,- },- '*',- );- // Legacy envelope for pre-v1 hosts.- parent?.postMessage({ __agent: agentId, type: 'ready', name: identityName }, '*');- }-- function postResize(height) {- parent?.postMessage({ type: 'agent:resize', agentId, height }, '*');- }-- function handleAction(action) {- if (!action || typeof action !== 'object') return;- protocol.emit(action);- }-- // Installed eagerly so the host's hello during boot is captured.- window.addEventListener('message', (ev) => {- const msg = ev.data;- if (!msg || typeof msg !== 'object') return;-- // v1 envelope- if (msg.agentId && msg.agentId === agentId && typeof msg.type === 'string') {- switch (msg.type) {- case 'agent:hello':- if (bridgeReady) postReady();- else pendingHellos.push(true);- return;- case 'agent:action':- if (bridgeReady) handleAction(msg.action);- return;- case 'agent:ping':- if (bridgeReady)- parent?.postMessage(- { type: 'agent:pong', agentId, id: msg.id },- '*',- );- return;- }- }-- // Legacy envelope. Kept until all known hosts migrate.- if (msg.__agent === agentId) {- if (msg.type === 'action' && msg.action) handleAction(msg.action);- }- });-- async function main() {- if (!(await checkPolicy())) {- const el = document.getElementById('error');- el.textContent = 'This agent can only be embedded on approved sites.';- el.style.display = 'flex';- parent?.postMessage({ type: 'agent:blocked', agentId }, '*');- parent?.postMessage({ __agent: agentId, type: 'blocked' }, '*');- return;- }-- const identity = new AgentIdentity({ agentId, autoLoad: false });- await identity.load();- identityName = identity.name;-- if (plateOn && identity.name) {- document.getElementById('name-plate').textContent = identity.name;- }-- if (!identity.avatarId) throw new Error('agent has no avatar body');-- const resp = await fetch(`/api/avatars/${identity.avatarId}`, {- credentials: 'include',- });- if (!resp.ok) throw new Error(`avatar ${resp.status}`);- const { avatar } = await resp.json();- const glbUrl = avatar?.url;- if (!glbUrl) throw new Error('no avatar url');-- const stage = document.getElementById('stage');- const viewer = new Viewer(stage, { kiosk: true });- if (bg === 'transparent') {- viewer.renderer?.setClearAlpha(0);- if (viewer.scene) viewer.scene.background = null;- }- await viewer.load(glbUrl, '', new Map());-- const avatarCtl = new AgentAvatar(viewer, protocol, identity);- avatarCtl.attach();-- // Echo every protocol action onto the bridge so hosts can mirror state- // (chat UIs, telemetry, host-side animation triggers).- protocol.on('*', (action) => {- parent?.postMessage({ type: 'agent:action', agentId, action }, '*');- });-- // Report content height to host so embed-sdk can auto-fit the iframe.- // Coalesce into rAF so a runaway resize observer can't flood the host.- let pendingPost = false;- const reportSize = () => {- if (pendingPost) return;- pendingPost = true;- requestAnimationFrame(() => {- pendingPost = false;- const h = Math.ceil(- document.documentElement.scrollHeight || stage.clientHeight || 0,- );- if (h > 0) postResize(h);- });- };- if (typeof ResizeObserver !== 'undefined') {- new ResizeObserver(reportSize).observe(document.documentElement);- }- reportSize();-- bridgeReady = true;- postReady();- while (pendingHellos.length) {- pendingHellos.pop();- postReady();- }- }-- main().catch((err) => {- const el = document.getElementById('error');- el.textContent = err.message || 'Could not load agent';- el.style.display = 'flex';- });- </script>- </body>-</html>diff --git a/public/my-agents/index.html b/public/my-agents/index.htmlindex 1cf21ab2e..a059363b7 100644--- a/public/my-agents/index.html+++ b/public/my-agents/index.html@@ -3,6 +3,7 @@<head><meta charset="utf-8" /><meta name="viewport" content="width=device-width, initial-scale=1" />+ <meta name="robots" content="noindex" /><title>My Agents · 3D Agent</title><metaname="description"diff --git a/public/sitemap.xml b/public/sitemap.xmlindex 068b429e5..e40ecd85a 100644--- a/public/sitemap.xml+++ b/public/sitemap.xml@@ -2,7 +2,13 @@<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"><url><loc>https://3dagent.vercel.app/</loc>- <lastmod>2026-04-14</lastmod>+ <lastmod>2026-04-27</lastmod><priority>1.0</priority></url>+ <url>+ <loc>https://3dagent.vercel.app/discover</loc>+ <lastmod>2026-04-27</lastmod>+ <changefreq>daily</changefreq>+ <priority>0.8</priority>+ </url></urlset>diff --git a/tests/discover-rename.test.js b/tests/discover-rename.test.jsnew file mode 100644index 000000000..32ac67a68--- /dev/null+++ b/tests/discover-rename.test.js@@ -0,0 +1,77 @@+import { describe, it, expect } from 'vitest';+import { readFileSync, existsSync } from 'node:fs';+import { fileURLToPath } from 'node:url';+import { dirname, resolve } from 'node:path';++const __dirname = dirname(fileURLToPath(import.meta.url));+const repoRoot = resolve(__dirname, '..');+const p = (...parts) => resolve(repoRoot, ...parts);++describe('discover/my-agents rename — static page contents', () => {+ it('/discover serves the community ERC-8004 directory page', () => {+ const path = p('public/discover/index.html');+ expect(existsSync(path)).toBe(true);+ const html = readFileSync(path, 'utf8');+ expect(html).toContain('<title>Discover · 3D Agent</title>');+ expect(html).toContain('ERC-8004 Agent Directory');+ });++ it('/my-agents serves the personal On-chain Agents page', () => {+ const path = p('public/my-agents/index.html');+ expect(existsSync(path)).toBe(true);+ const html = readFileSync(path, 'utf8');+ expect(html).toContain('<title>My Agents · 3D Agent</title>');+ expect(html).toContain('On-chain Agents');+ });++ it('/discover no longer shows the previous personal "On-chain Agents" content', () => {+ const html = readFileSync(p('public/discover/index.html'), 'utf8');+ expect(html).not.toContain('On-chain Agents');+ });++ it('/explore directory has been removed (moved to /discover)', () => {+ expect(existsSync(p('public/explore'))).toBe(false);+ });+});++describe('discover/my-agents rename — vercel.json routing', () => {+ const vercel = JSON.parse(readFileSync(p('vercel.json'), 'utf8'));+ const routes = vercel.routes || [];++ it('redirects /explore → /discover with status 301', () => {+ const r = routes.find((x) => x.src === '/explore');+ expect(r).toBeTruthy();+ expect(r.status).toBe(301);+ expect(r.headers?.Location).toBe('/discover');+ });++ it('redirects /explore/ → /discover with status 301', () => {+ const r = routes.find((x) => x.src === '/explore/');+ expect(r).toBeTruthy();+ expect(r.status).toBe(301);+ expect(r.headers?.Location).toBe('/discover');+ });++ it('serves /discover from public/discover/index.html', () => {+ const r = routes.find((x) => x.src === '/discover');+ expect(r?.dest).toBe('/discover/index.html');+ });++ it('serves /my-agents from public/my-agents/index.html', () => {+ const r = routes.find((x) => x.src === '/my-agents');+ expect(r?.dest).toBe('/my-agents/index.html');+ });++ it('does not redirect /discover → /my-agents (would shadow the page)', () => {+ const bad = routes.find(+ (x) => x.src === '/discover' && x.headers?.Location === '/my-agents',+ );+ expect(bad).toBeFalsy();+ });++ it('places /explore redirects after /discover and /my-agents rewrites', () => {+ const idx = (src) => routes.findIndex((x) => x.src === src);+ expect(idx('/explore')).toBeGreaterThan(idx('/discover'));+ expect(idx('/explore')).toBeGreaterThan(idx('/my-agents'));+ });+});