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: walking avatar on profile, dashboard topbar, and agent embed generator

miniaturization4bd84b4570cc
diff --git a/pages/profile.html b/pages/profile.html
index 0726bbd2f..876fcd21f 100644
--- a/pages/profile.html
+++ b/pages/profile.html
@@ -1099,6 +1099,7 @@
import { mountUserProfile } from '/src/erc8004/user-profile.js';
import { onchainBadgeHTML } from '/src/shared/onchain-badge.js';
import { apiFetch } from '/src/api.js';
+ import { mountProfileWalkHero } from '/src/profile-walk-hero.js';
const esc = (s) =>
String(s ?? '').replace(
@@ -1526,6 +1527,7 @@
</div>
</div>
</div>
+ <div id="up-walk-hero"></div>
<div class="up-stats">${statsHtml}</div>
${tabBar}
<section class="up-section" data-section="avatars"${defaultTab === 'avatars' ? '' : ' hidden'}>
@@ -1611,6 +1613,18 @@
openFollowsModal(user.username, btn.dataset.follows, viewer),
);
});
+
+ // Live walking-avatar hero — embodies the owner's primary avatar
+ // in a /walk-embed iframe with "Say hi" (real chat) + "Walk with me".
+ const walkHeroSlot = rootEl.querySelector('#up-walk-hero');
+ if (walkHeroSlot) {
+ mountProfileWalkHero(walkHeroSlot, {
+ user,
+ avatars,
+ agents,
+ isOwner,
+ });
+ }
}
// ── Edit profile modal ──────────────────────────────────────────────
diff --git a/public/changelog.json b/public/changelog.json
index 458aed713..ec41efa48 100644
--- a/public/changelog.json
+++ b/public/changelog.json
@@ -1,5 +1,5 @@
{
- "generated_at": "2026-06-21T07:11:53.313Z",
+ "generated_at": "2026-06-21T07:22:29.113Z",
"generated_by": "scripts/build-page-index.mjs from data/pages.json + data/changelog.json",
"site": {
"name": "three.ws",
diff --git a/public/features.json b/public/features.json
index 9759bcef7..5d8dccae9 100644
--- a/public/features.json
+++ b/public/features.json
@@ -1,5 +1,5 @@
{
- "generated_at": "2026-06-21T07:11:53.291Z",
+ "generated_at": "2026-06-21T07:22:29.085Z",
"generated_by": "scripts/build-page-index.mjs from data/pages.json",
"site": {
"name": "three.ws",
diff --git a/src/agent-embed-modal.js b/src/agent-embed-modal.js
index 16351d043..6079ca00d 100644
--- a/src/agent-embed-modal.js
+++ b/src/agent-embed-modal.js
@@ -2,9 +2,184 @@ import { track, trackError, ANALYTICS_EVENTS } from './analytics.js';
/**
* Embed modal for the agent hub page.
- * Shows iframe, web-component, and SDK snippets with copy-to-clipboard.
- * Size controls let the developer customise width × height before copying.
+ *
+ * Offers four embed kinds, all generating real, copy-pasteable snippets:
+ * • iframe — chat-style embed (/agent/:id/embed)
+ * • <agent-3d> — web component wrapper
+ * • SDK — iframe + Agent3D bridge for programmatic control
+ * • walking — a live, walking 3D avatar of THIS agent
+ * (/walk-embed?agent=:id) with joystick/keyboard controls,
+ * a selectable environment, autoplay, and a background.
+ *
+ * The walking kind renders a LIVE preview iframe that re-loads as the developer
+ * tweaks options, so they see exactly what their visitors will get before they
+ * copy. Size controls drive width × height for every kind.
*/
+
+// Scene presets surfaced to the developer. These ids are the real keys the
+// /walk-embed runtime understands (src/walk-embed.js → ENVIRONMENTS); the
+// labels are just friendlier copy. Keep this list in sync with that map.
+const WALK_ENVIRONMENTS = [
+ { id: 'studio', label: 'Studio' },
+ { id: 'void', label: 'Void' },
+ { id: 'beach', label: 'Beach' },
+ { id: 'sunset', label: 'Sunset' },
+ { id: 'night', label: 'Night' },
+ { id: 'grid', label: 'Grid' },
+];
+
+// Control schemes the /walk-embed page accepts via ?controls=.
+const WALK_CONTROLS = [
+ { id: 'joystick', label: 'Joystick' },
+ { id: 'keyboard', label: 'Keyboard' },
+ { id: 'none', label: 'View only' },
+];
+
+const WALK_DEFAULTS = {
+ controls: 'joystick',
+ env: 'studio',
+ autoplay: true,
+ bg: 'transparent',
+};
+
+const STYLE_ID = 'aem-walking-styles';
+
+// Walking-mode styling is injected here (idempotent) rather than the shared
+// page stylesheet so the modal is fully self-contained. It reuses the same
+// design tokens (golden-ratio sizes, low-alpha whites) as the existing aem-*
+// rules so the two surfaces read as one.
+const WALKING_STYLES = `
+.aem-walk-options {
+ display: grid;
+ grid-template-columns: 1fr 1fr;
+ gap: 0.618rem;
+}
+.aem-field {
+ display: flex;
+ flex-direction: column;
+ gap: 0.236rem;
+}
+.aem-field-label {
+ font-size: 0.618rem;
+ color: rgba(255, 255, 255, 0.4);
+ letter-spacing: 0.02em;
+}
+.aem-select {
+ background: rgba(255, 255, 255, 0.06);
+ border: 1px solid rgba(255, 255, 255, 0.12);
+ border-radius: 6px;
+ color: rgba(255, 255, 255, 0.85);
+ font-size: 0.764rem;
+ font-family: inherit;
+ padding: 0.3rem 0.45rem;
+ cursor: pointer;
+ transition: border-color 0.12s;
+}
+.aem-select:hover {
+ border-color: rgba(255, 255, 255, 0.2);
+}
+.aem-select:focus-visible {
+ outline: none;
+ border-color: rgba(255, 255, 255, 0.45);
+ box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.12);
+}
+.aem-swatch-row {
+ display: flex;
+ align-items: center;
+ gap: 0.382rem;
+}
+.aem-swatch {
+ -webkit-appearance: none;
+ appearance: none;
+ width: 28px;
+ height: 28px;
+ padding: 0;
+ border: 1px solid rgba(255, 255, 255, 0.18);
+ border-radius: 6px;
+ background: none;
+ cursor: pointer;
+}
+.aem-swatch::-webkit-color-swatch-wrapper { padding: 2px; }
+.aem-swatch::-webkit-color-swatch { border: none; border-radius: 4px; }
+.aem-swatch:focus-visible {
+ outline: none;
+ border-color: rgba(255, 255, 255, 0.45);
+ box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.12);
+}
+.aem-swatch:disabled { opacity: 0.35; cursor: not-allowed; }
+.aem-toggle {
+ display: inline-flex;
+ align-items: center;
+ gap: 0.382rem;
+ font-size: 0.618rem;
+ color: rgba(255, 255, 255, 0.55);
+ cursor: pointer;
+ user-select: none;
+}
+.aem-toggle input { accent-color: #86efac; cursor: pointer; }
+.aem-transparent-toggle {
+ font-size: 0.55rem;
+ color: rgba(255, 255, 255, 0.35);
+}
+.aem-transparent-toggle input { accent-color: rgba(255, 255, 255, 0.6); }
+.aem-preview {
+ position: relative;
+ border: 1px solid rgba(255, 255, 255, 0.08);
+ border-radius: 8px;
+ overflow: hidden;
+ background:
+ linear-gradient(45deg, rgba(255,255,255,0.03) 25%, transparent 25%) 0 0/16px 16px,
+ linear-gradient(-45deg, rgba(255,255,255,0.03) 25%, transparent 25%) 0 8px/16px 16px,
+ linear-gradient(45deg, transparent 75%, rgba(255,255,255,0.03) 75%) 8px -8px/16px 16px,
+ linear-gradient(-45deg, transparent 75%, rgba(255,255,255,0.03) 75%) -8px 0/16px 16px,
+ #0a0a0a;
+ aspect-ratio: 4 / 3;
+ max-height: 220px;
+}
+.aem-preview iframe {
+ position: absolute;
+ inset: 0;
+ width: 100%;
+ height: 100%;
+ border: 0;
+ display: block;
+}
+.aem-preview-label {
+ position: absolute;
+ top: 0.382rem;
+ left: 0.5rem;
+ font-size: 0.55rem;
+ letter-spacing: 0.06em;
+ text-transform: uppercase;
+ color: rgba(255, 255, 255, 0.4);
+ background: rgba(0, 0, 0, 0.45);
+ padding: 0.1rem 0.4rem;
+ border-radius: 4px;
+ pointer-events: none;
+ z-index: 2;
+}
+.aem-preview-empty {
+ position: absolute;
+ inset: 0;
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ text-align: center;
+ padding: 1rem;
+ font-size: 0.618rem;
+ color: rgba(255, 255, 255, 0.3);
+ line-height: 1.5;
+}
+`;
+
+function ensureWalkingStyles() {
+ if (document.getElementById(STYLE_ID)) return;
+ const el = document.createElement('style');
+ el.id = STYLE_ID;
+ el.textContent = WALKING_STYLES;
+ document.head.appendChild(el);
+}
+
export class AgentEmbedModal {
/**
* @param {string} agentId
@@ -18,10 +193,13 @@ export class AgentEmbedModal {
// Which snippet kinds we've already reported for this agent — instance-level
// so closing and reopening the modal doesn't re-fire EMBED_GENERATED.
this._embeddedKinds = new Set();
+ // Walking-mode options, mutated live by the option controls.
+ this._walk = { ...WALK_DEFAULTS };
}
open() {
if (this._modal) return;
+ ensureWalkingStyles();
this._build();
document.body.appendChild(this._modal);
document.addEventListener('keydown', this._onKey);
@@ -39,6 +217,20 @@ export class AgentEmbedModal {
if (e.key === 'Escape') this.close();
}
+ // Build the /walk-embed query string from the current walking options. Only
+ // non-default-ish params are dropped where the embed already defaults to them,
+ // keeping the emitted URL readable; agent + autoplay + controls are always
+ // explicit because they are the load-bearing intent of this snippet.
+ _walkSrc(origin, id) {
+ const q = new URLSearchParams();
+ q.set('agent', id);
+ q.set('controls', this._walk.controls);
+ if (this._walk.autoplay) q.set('autoplay', 'true');
+ if (this._walk.env && this._walk.env !== 'studio') q.set('env', this._walk.env);
+ if (this._walk.bg && this._walk.bg !== 'transparent') q.set('bg', this._walk.bg);
+ return `${origin}/walk-embed?${q.toString()}`;
+ }
+
_snippets(origin, id, w, h) {
return {
iframe:
@@ -85,6 +277,16 @@ export class AgentEmbedModal {
` bridge.send({ type: 'speak', payload: { text: 'Hello!' } });\n` +
`});\n` +
`<\/script>`,
+ walking:
+ `<iframe\n` +
+ ` src="${this._walkSrc(origin, id)}"\n` +
+ ` width="${w}" height="${h}"\n` +
+ ` title="three.ws walking avatar"\n` +
+ ` style="border:0;border-radius:12px"\n` +
+ ` allow="autoplay; xr-spatial-tracking"\n` +
+ ` sandbox="allow-scripts allow-same-origin allow-popups"\n` +
+ ` loading="lazy"\n` +
+ `></iframe>`,
};
}
@@ -113,16 +315,70 @@ export class AgentEmbedModal {
</label>
<span class="aem-size-unit">px</span>
</div>
- <div class="aem-tabs" role="tablist">
- <button class="aem-tab active" data-tab="iframe">iframe</button>
- <button class="aem-tab" data-tab="webcomponent">&lt;agent-3d&gt;</button>
- <button class="aem-tab" data-tab="sdk">SDK</button>
+ <div class="aem-tabs" role="tablist" aria-label="Embed type">
+ <button class="aem-tab active" role="tab" aria-selected="true" data-tab="iframe">iframe</button>
+ <button class="aem-tab" role="tab" aria-selected="false" data-tab="webcomponent">&lt;agent-3d&gt;</button>
+ <button class="aem-tab" role="tab" aria-selected="false" data-tab="sdk">SDK</button>
+ <button class="aem-tab" role="tab" aria-selected="false" data-tab="walking">walking avatar</button>
+ </div>
+ <div class="aem-walk-panel" id="aem-walk-panel" hidden>
+ <div class="aem-walk-options">
+ <label class="aem-field">
+ <span class="aem-field-label">Controls</span>
+ <select class="aem-select" id="aem-walk-controls">
+ ${WALK_CONTROLS.map(
+ (c) =>
+ `<option value="${c.id}"${
+ c.id === this._walk.controls ? ' selected' : ''
+ }>${c.label}</option>`,
+ ).join('')}
+ </select>
+ </label>
+ <label class="aem-field">
+ <span class="aem-field-label">Environment</span>
+ <select class="aem-select" id="aem-walk-env">
+ ${WALK_ENVIRONMENTS.map(
+ (e) =>
+ `<option value="${e.id}"${
+ e.id === this._walk.env ? ' selected' : ''
+ }>${e.label}</option>`,
+ ).join('')}
+ </select>
+ </label>
+ <div class="aem-field">
+ <span class="aem-field-label">Background</span>
+ <div class="aem-swatch-row">
+ <input class="aem-swatch" id="aem-walk-bg" type="color" value="#101820"
+ aria-label="Background color"${
+ this._walk.bg === 'transparent' ? ' disabled' : ''
+ } />
+ <label class="aem-toggle aem-transparent-toggle">
+ <input type="checkbox" id="aem-walk-transparent"${
+ this._walk.bg === 'transparent' ? ' checked' : ''
+ } />
+ transparent
+ </label>
+ </div>
+ </div>
+ <div class="aem-field">
+ <span class="aem-field-label">Behavior</span>
+ <label class="aem-toggle">
+ <input type="checkbox" id="aem-walk-autoplay"${
+ this._walk.autoplay ? ' checked' : ''
+ } />
+ auto-walk on load
+ </label>
+ </div>
+ </div>
+ <div class="aem-preview" id="aem-walk-preview">
+ <span class="aem-preview-label">Live preview</span>
+ </div>
</div>
<div class="aem-snippet-wrap">
<pre class="aem-snippet" id="aem-snippet-text"></pre>
<button class="aem-copy" id="aem-copy-btn">copy</button>
</div>
- <p class="aem-note">Free to embed — no wallet or on-chain deployment required.</p>
+ <p class="aem-note" id="aem-note">Free to embed — no wallet or on-chain deployment required.</p>
</div>
</div>
`;
@@ -132,10 +388,61 @@ export class AgentEmbedModal {
const copyBtn = overlay.querySelector('#aem-copy-btn');
const widthInput = overlay.querySelector('#aem-width');
const heightInput = overlay.querySelector('#aem-height');
+ const walkPanel = overlay.querySelector('#aem-walk-panel');
+ const previewWrap = overlay.querySelector('#aem-walk-preview');
+ const noteEl = overlay.querySelector('#aem-note');
+
+ const controlsSel = overlay.querySelector('#aem-walk-controls');
+ const envSel = overlay.querySelector('#aem-walk-env');
+ const bgSwatch = overlay.querySelector('#aem-walk-bg');
+ const transparentChk = overlay.querySelector('#aem-walk-transparent');
+ const autoplayChk = overlay.querySelector('#aem-walk-autoplay');
+
+ // The live preview iframe is created once on first switch to the walking
+ // tab and reused; only its src changes as options update, so each tweak is
+ // a cheap navigation rather than a teardown/rebuild.
+ let previewFrame = null;
+ const renderPreview = () => {
+ if (current !== 'walking') return;
+ if (!previewFrame) {
+ previewFrame = document.createElement('iframe');
+ previewFrame.title = 'three.ws walking avatar preview';
+ previewFrame.setAttribute('allow', 'autoplay; xr-spatial-tracking');
+ previewFrame.setAttribute(
+ 'sandbox',
+ 'allow-scripts allow-same-origin allow-popups',
+ );
+ previewFrame.setAttribute('loading', 'eager');
+ previewWrap.appendChild(previewFrame);
+ }
+ const next = this._walkSrc(origin, id);
+ if (previewFrame.src !== next) previewFrame.src = next;
+ };
const renderSnippet = () => {
snippetEl.textContent = this._snippets(origin, id, this._w, this._h)[current];
};
+
+ const renderNote = () => {
+ noteEl.textContent =
+ current === 'walking'
+ ? 'Drops a live, walking 3D avatar of this agent on any site. Free to embed.'
+ : 'Free to embed — no wallet or on-chain deployment required.';
+ };
+
+ const setActiveTab = (kind) => {
+ current = kind;
+ overlay.querySelectorAll('.aem-tab').forEach((b) => {
+ const on = b.dataset.tab === kind;
+ b.classList.toggle('active', on);
+ b.setAttribute('aria-selected', on ? 'true' : 'false');
+ });
+ walkPanel.hidden = kind !== 'walking';
+ renderSnippet();
+ renderNote();
+ renderPreview();
+ };
+
renderSnippet();
const onSizeChange = () => {
@@ -148,14 +455,43 @@ export class AgentEmbedModal {
widthInput.addEventListener('input', onSizeChange);
heightInput.addEventListener('input', onSizeChange);
+ // Walking-option handlers: each mutates state, then re-renders both the
+ // snippet and the live preview so the two never drift apart.
+ const onWalkChange = () => {
+ renderSnippet();
+ renderPreview();
+ };
+ controlsSel.addEventListener('change', () => {
+ this._walk.controls = controlsSel.value;
+ onWalkChange();
+ });
+ envSel.addEventListener('change', () => {
+ this._walk.env = envSel.value;
+ onWalkChange();
+ });
+ bgSwatch.addEventListener('input', () => {
+ if (!transparentChk.checked) {
+ this._walk.bg = bgSwatch.value;
+ onWalkChange();
+ }
+ });
+ transparentChk.addEventListener('change', () => {
+ if (transparentChk.checked) {
+ this._walk.bg = 'transparent';
+ bgSwatch.disabled = true;
+ } else {
+ this._walk.bg = bgSwatch.value;
+ bgSwatch.disabled = false;
+ }
+ onWalkChange();
+ });
+ autoplayChk.addEventListener('change', () => {
+ this._walk.autoplay = autoplayChk.checked;
+ onWalkChange();
+ });
+
overlay.querySelectorAll('.aem-tab').forEach((btn) => {
- btn.addEventListener('click', () => {
- current = btn.dataset.tab;
- overlay
- .querySelectorAll('.aem-tab')
- .forEach((b) => b.classList.toggle('active', b === btn));
- renderSnippet();
- });
+ btn.addEventListener('click', () => setActiveTab(btn.dataset.tab));
});
copyBtn.addEventListener('click', async () => {
diff --git a/src/dashboard-next/components/topbar.js b/src/dashboard-next/components/topbar.js
index 7649a5f00..490594f9c 100644
--- a/src/dashboard-next/components/topbar.js
+++ b/src/dashboard-next/components/topbar.js
@@ -40,6 +40,13 @@ export function renderTopbar(pathname) {
<button type="button" class="dn-topbar-btn" data-action="toggle-drawer" aria-label="Toggle activity drawer" aria-pressed="false">
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"><circle cx="8" cy="8" r="3"/><path d="M8 1v2M8 13v2M1 8h2M13 8h2M3.2 3.2l1.4 1.4M11.4 11.4l1.4 1.4M3.2 12.8l1.4-1.4M11.4 4.6l1.4-1.4"/></svg>
</button>
+ <div class="dn-walk-avatar" data-component="walk-avatar" data-state="loading">
+ <button type="button" class="dn-walk-avatar-btn" data-action="toggle-walk-menu" aria-haspopup="menu" aria-expanded="false" aria-label="Your walking avatar">
+ <span class="dn-walk-avatar-stage" data-slot="walk-stage" aria-hidden="true">
+ <span class="dn-walk-avatar-skel"></span>
+ </span>
+ </button>
+ </div>
<button type="button" class="dn-topbar-user" data-action="toggle-user-menu" data-component="topbar-user" aria-haspopup="menu" aria-expanded="false" aria-label="Account menu">
<span class="dn-topbar-user-avatar" data-slot="initials" aria-hidden="true">··</span>
<span data-slot="label">Loading…</span>
@@ -78,6 +85,11 @@ export function mountTopbarBehavior(shellEl) {
toggleUserMenu(chip);
return;
}
+ if (e.target.closest?.('[data-action="toggle-walk-menu"]')) {
+ const btn = e.target.closest('[data-action="toggle-walk-menu"]');
+ toggleWalkMenu(btn);
+ return;
+ }
});
window.addEventListener('keydown', (e) => {
@@ -87,6 +99,8 @@ export function mountTopbarBehavior(shellEl) {
}
});
+ injectTopbarStyles();
+
// Fill the user chip and load notification count from /api/auth/me.
getMe().then((me) => {
const chip = shellEl.querySelector('[data-component="topbar-user"]');
@@ -99,6 +113,9 @@ export function mountTopbarBehavior(shellEl) {
const ret = encodeURIComponent(location.pathname + location.search);
location.href = `/login?return=${ret}`;
};
+ // No session → hide the walking avatar entirely; it's account-bound.
+ const walk = shellEl.querySelector('[data-component="walk-avatar"]');
+ if (walk) walk.style.display = 'none';
return;
}
chip.querySelector('[data-slot="initials"]').textContent = initialsOf(me);
@@ -114,18 +131,29 @@ export function mountTopbarBehavior(shellEl) {
// Load unread notification count in background — only once we know the
// visitor is signed in, so anonymous sessions don't collect 401s.
+ // The real endpoint (api/notifications/index.js) returns `unread_count`.
fetch('/api/notifications?limit=1', { credentials: 'include' })
.then((r) => r.ok ? r.json() : null)
.then((data) => {
- const unread = data?.unread ?? 0;
+ const unread = data?.unread_count ?? 0;
const badge = shellEl.querySelector('[data-slot="notif-badge"]');
- if (!badge) return;
- if (unread > 0) {
- badge.style.display = 'block';
- badge.textContent = unread > 9 ? '9+' : String(unread);
+ if (badge) {
+ if (unread > 0) {
+ badge.style.display = 'block';
+ badge.textContent = unread > 9 ? '9+' : String(unread);
+ } else {
+ badge.style.display = 'none';
+ badge.textContent = '';
+ }
}
+ // A fresh notification makes the topbar avatar wave so the user
+ // notices without watching the bell.
+ if (unread > 0) signalWalkAvatar(shellEl, 'wave');
})
.catch(() => { /* notifications unavailable */ });
+
+ // Bring the user's own avatar to life in the topbar.
+ mountWalkAvatar(shellEl);
}).catch(() => { /* network blip — chip stays "Loading…" */ });
}
@@ -313,6 +341,301 @@ function closeUserMenu(menu, chip, onOutside, onKey) {
if (onKey) document.removeEventListener('keydown', onKey, true);
}
+// ── Walking avatar (topbar live status) ────────────────────────────────────
+//
+// A compact (~64×80) live walking avatar driven by the signed-in user's own
+// avatar. We render it through the chrome-less /walk-embed route in an iframe
+// (controls=none, autoplay, transparent bg, no orbit). The iframe is only
+// created once the avatar scrolls/exists in the viewport (lazy) so it never
+// taxes a dashboard the user can't see. States: loading → walking | empty |
+// error. A fresh notification makes it wave.
+
+let _walkAvatar = null; // { id, name, handle } once resolved
+
+function mountWalkAvatar(shellEl) {
+ const host = shellEl.querySelector('[data-component="walk-avatar"]');
+ if (!host || host.dataset.mounted === '1') return;
+ host.dataset.mounted = '1';
+
+ // Real data: the caller's own avatars. The first (most recent) is their
+ // primary; the picker endpoint already returns them newest-first.
+ fetch('/api/avatars/mine?limit=1', { credentials: 'include' })
+ .then((r) => (r.ok ? r.json() : null))
+ .then((data) => {
+ const av = data?.avatars?.[0];
+ if (!av) {
+ renderWalkEmptyState(host);
+ return;
+ }
+ _walkAvatar = {
+ id: av.id,
+ name: av.name || 'Your avatar',
+ handle: av.slug || null,
+ };
+ renderWalkLiveState(host, _walkAvatar);
+ })
+ .catch(() => renderWalkErrorState(host));
+}
+
+// Empty: the user hasn't made an avatar yet. A subtle, inviting affordance that
+// links straight into the avatar creator — not a broken frame.
+function renderWalkEmptyState(host) {
+ host.dataset.state = 'empty';
+ const stage = host.querySelector('[data-slot="walk-stage"]');
+ if (stage) stage.innerHTML = '';
+ const btn = host.querySelector('[data-action="toggle-walk-menu"]');
+ if (!btn) return;
+ btn.dataset.action = 'create-avatar';
+ btn.setAttribute('aria-label', 'Create your avatar');
+ btn.setAttribute('title', 'Create your avatar');
+ btn.removeAttribute('aria-haspopup');
+ btn.removeAttribute('aria-expanded');
+ host.querySelector('[data-slot="walk-stage"]').innerHTML = `
+ <svg viewBox="0 0 24 24" width="22" height="22" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
+ <circle cx="12" cy="8" r="3.2"/>
+ <path d="M5.5 20a6.5 6.5 0 0113 0"/>
+ <path d="M19 4v4M21 6h-4"/>
+ </svg>`;
+ btn.onclick = () => { location.href = '/avatar-edit'; };
+}
+
+// Error: avatar lookup failed (network). Offer a retry rather than a dead frame.
+function renderWalkErrorState(host) {
+ host.dataset.state = 'error';
+ const btn = host.querySelector('[data-action="toggle-walk-menu"]');
+ if (!btn) return;
+ btn.dataset.action = 'retry-walk';
+ btn.setAttribute('aria-label', 'Avatar failed to load — retry');
+ btn.setAttribute('title', 'Retry');
+ btn.removeAttribute('aria-haspopup');
+ btn.removeAttribute('aria-expanded');
+ host.querySelector('[data-slot="walk-stage"]').innerHTML = `
+ <svg viewBox="0 0 24 24" width="20" height="20" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
+ <path d="M20 11A8 8 0 105 5.5"/><path d="M4 4v4h4"/>
+ </svg>`;
+ btn.onclick = () => {
+ host.dataset.state = 'loading';
+ host.dataset.mounted = '0';
+ btn.onclick = null;
+ btn.dataset.action = 'toggle-walk-menu';
+ host.querySelector('[data-slot="walk-stage"]').innerHTML = '<span class="dn-walk-avatar-skel"></span>';
+ const shellEl = host.closest('.dn-shell') || document;
+ mountWalkAvatar(shellEl);
+ };
+}
+
+// Live: lazily mount the /walk-embed iframe of the user's avatar, walking.
+function renderWalkLiveState(host, avatar) {
+ host.dataset.state = 'live';
+ const btn = host.querySelector('[data-action="toggle-walk-menu"]');
+ if (btn) {
+ btn.setAttribute('aria-label', `${avatar.name} — open avatar menu`);
+ btn.setAttribute('title', avatar.name);
+ btn.setAttribute('aria-haspopup', 'menu');
+ btn.setAttribute('aria-expanded', 'false');
+ }
+
+ const mountFrame = () => {
+ if (host.dataset.framed === '1') return;
+ host.dataset.framed = '1';
+ const stage = host.querySelector('[data-slot="walk-stage"]');
+ if (!stage) return;
+ const qs = new URLSearchParams({
+ avatar: avatar.id,
+ controls: 'none',
+ autoplay: 'true',
+ bg: 'transparent',
+ orbit: 'false',
+ ground: 'false',
+ });
+ const frame = document.createElement('iframe');
+ frame.className = 'dn-walk-avatar-frame';
+ frame.title = `${avatar.name}, walking`;
+ frame.setAttribute('aria-hidden', 'true');
+ frame.setAttribute('tabindex', '-1');
+ frame.loading = 'lazy';
+ frame.allowTransparency = 'true';
+ frame.src = `/walk-embed?${qs.toString()}`;
+ // Reveal only once the avatar is actually loaded — avoids a flash of
+ // the (transparent) empty scene before the GLB resolves.
+ frame.addEventListener('load', () => {
+ host.dataset.ready = '1';
+ const skel = stage.querySelector('.dn-walk-avatar-skel');
+ if (skel) skel.remove();
+ });
+ stage.appendChild(frame);
+ };
+
+ // Lazy: only build the iframe when the topbar avatar is on-screen. The
+ // dashboard topbar is essentially always visible, but this keeps the
+ // embed off the critical path and respects reduced-data scenarios.
+ if ('IntersectionObserver' in window) {
+ const io = new IntersectionObserver((entries, obs) => {
+ if (entries.some((e) => e.isIntersecting)) {
+ obs.disconnect();
+ mountFrame();
+ }
+ }, { rootMargin: '120px' });
+ io.observe(host);
+ } else {
+ mountFrame();
+ }
+}
+
+// Tell the embedded avatar to play a one-shot gesture (e.g. wave on a fresh
+// notification). Waits for the iframe to exist; the embed ignores commands it
+// can't honor, so this is safe to fire optimistically.
+function signalWalkAvatar(shellEl, gesture) {
+ const host = shellEl.querySelector('[data-component="walk-avatar"]');
+ const frame = host?.querySelector('iframe.dn-walk-avatar-frame');
+ if (!frame?.contentWindow) {
+ // Frame not built yet — retry shortly, but give up after a few tries
+ // so we never leave a dangling timer.
+ let tries = 0;
+ const t = setInterval(() => {
+ tries += 1;
+ const f = shellEl.querySelector('iframe.dn-walk-avatar-frame');
+ if (f?.contentWindow) {
+ clearInterval(t);
+ f.contentWindow.postMessage({ type: 'walk:gesture', gesture }, '*');
+ } else if (tries >= 10) {
+ clearInterval(t);
+ }
+ }, 600);
+ return;
+ }
+ frame.contentWindow.postMessage({ type: 'walk:gesture', gesture }, '*');
+}
+
+// Dropdown: name + handle, Open Walk, Edit Avatar.
+function toggleWalkMenu(btn) {
+ const existing = document.querySelector('[data-topbar-walk-menu]');
+ if (existing) { closeWalkMenu(existing, btn); return; }
+ if (!_walkAvatar) return;
+
+ const rect = btn.getBoundingClientRect();
+ btn.setAttribute('aria-expanded', 'true');
+ const menu = document.createElement('div');
+ menu.setAttribute('data-topbar-walk-menu', '');
+ menu.setAttribute('role', 'menu');
+ menu.setAttribute('aria-label', 'Avatar menu');
+ menu.style.cssText = `
+ position:fixed;top:${rect.bottom + 8}px;right:${window.innerWidth - rect.right}px;
+ min-width:220px;
+ background:rgba(18,20,28,0.97);border:1px solid var(--nxt-stroke-strong);
+ border-radius:12px;box-shadow:0 16px 48px rgba(0,0,0,0.6);
+ backdrop-filter:blur(20px);z-index:2000;overflow:hidden;
+ `;
+ const handle = _walkAvatar.handle ? `@${_walkAvatar.handle}` : '';
+ menu.innerHTML = `
+ <div style="padding:14px 16px;border-bottom:1px solid var(--nxt-stroke)">
+ <div style="font-size:14px;font-weight:600;color:var(--nxt-ink)">${esc(_walkAvatar.name)}</div>
+ ${handle ? `<div style="font-size:12px;color:var(--nxt-ink-dim);margin-top:2px">${esc(handle)}</div>` : ''}
+ </div>
+ <div style="padding:6px 0">
+ <a href="/walk/app?avatar=${encodeURIComponent(_walkAvatar.id)}" class="dn-user-menu-item" role="menuitem">Open Walk</a>
+ <a href="/avatar-edit?id=${encodeURIComponent(_walkAvatar.id)}" class="dn-user-menu-item" role="menuitem">Edit Avatar</a>
+ </div>
+ `;
+
+ injectMenuStyles();
+ document.body.appendChild(menu);
+ requestAnimationFrame(() => menu.querySelector('[role="menuitem"]')?.focus());
+
+ const closeOnOutside = (e) => {
+ if (!menu.contains(e.target) && !btn.contains(e.target)) {
+ closeWalkMenu(menu, btn, closeOnOutside, onKey);
+ }
+ };
+ const onKey = (e) => {
+ const items = [...menu.querySelectorAll('[role="menuitem"]')];
+ if (e.key === 'Escape') {
+ e.stopPropagation();
+ closeWalkMenu(menu, btn, closeOnOutside, onKey);
+ btn.focus();
+ } else if (e.key === 'ArrowDown' || e.key === 'ArrowUp') {
+ e.preventDefault();
+ const idx = items.indexOf(document.activeElement);
+ const next = e.key === 'ArrowDown'
+ ? (idx + 1) % items.length
+ : (idx - 1 + items.length) % items.length;
+ items[next]?.focus();
+ }
+ };
+ setTimeout(() => {
+ document.addEventListener('click', closeOnOutside, true);
+ document.addEventListener('keydown', onKey, true);
+ }, 0);
+}
+
+function closeWalkMenu(menu, btn, onOutside, onKey) {
+ menu.remove();
+ if (btn) btn.setAttribute('aria-expanded', 'false');
+ if (onOutside) document.removeEventListener('click', onOutside, true);
+ if (onKey) document.removeEventListener('keydown', onKey, true);
+}
+
+let _topbarStylesInjected = false;
+function injectTopbarStyles() {
+ if (_topbarStylesInjected) return;
+ _topbarStylesInjected = true;
+ const style = document.createElement('style');
+ style.textContent = `
+ .dn-walk-avatar { display:flex; align-items:center; }
+ .dn-walk-avatar-btn {
+ display:inline-flex; align-items:center; justify-content:center;
+ width:64px; height:80px; padding:0; margin:0;
+ background:var(--nxt-surface-1, rgba(255,255,255,0.03));
+ border:1px solid var(--nxt-stroke); border-radius:14px;
+ color:var(--nxt-ink-dim); cursor:pointer;
+ overflow:hidden; position:relative;
+ transition:border-color 140ms ease, background 140ms ease, transform 120ms ease;
+ }
+ .dn-walk-avatar-btn:hover { border-color:var(--nxt-stroke-strong); background:rgba(255,255,255,0.05); color:var(--nxt-ink); }
+ .dn-walk-avatar-btn:active { transform:scale(0.97); }
+ .dn-walk-avatar-btn:focus-visible {
+ outline:2px solid var(--nxt-accent, #fff); outline-offset:2px;
+ }
+ .dn-walk-avatar-stage {
+ display:flex; align-items:center; justify-content:center;
+ width:100%; height:100%; position:relative;
+ }
+ .dn-walk-avatar-frame {
+ width:100%; height:100%; border:0; display:block;
+ background:transparent; pointer-events:none;
+ }
+ .dn-walk-avatar-skel {
+ position:absolute; inset:8px; border-radius:10px;
+ background:linear-gradient(100deg,
+ rgba(255,255,255,0.04) 30%,
+ rgba(255,255,255,0.09) 50%,
+ rgba(255,255,255,0.04) 70%);
+ background-size:200% 100%;
+ animation:dn-walk-skel 1.3s ease-in-out infinite;
+ }
+ .dn-walk-avatar[data-state="empty"] .dn-walk-avatar-btn,
+ .dn-walk-avatar[data-state="error"] .dn-walk-avatar-btn {
+ border-style:dashed;
+ }
+ @keyframes dn-walk-skel {
+ 0% { background-position:200% 0; }
+ 100% { background-position:-200% 0; }
+ }
+ /* Narrow viewports: shrink, then hide before the topbar crowds. */
+ @media (max-width: 860px) {
+ .dn-walk-avatar-btn { width:52px; height:64px; }
+ }
+ @media (max-width: 640px) {
+ .dn-walk-avatar { display:none; }
+ }
+ @media (prefers-reduced-motion: reduce) {
+ .dn-walk-avatar-skel { animation:none; }
+ .dn-walk-avatar-btn:active { transform:none; }
+ }
+ `;
+ document.head.appendChild(style);
+}
+
// ── Helpers ────────────────────────────────────────────────────────────────
function timeAgo(iso) {
diff --git a/src/profile-walk-hero.js b/src/profile-walk-hero.js
new file mode 100644
index 000000000..8325305de
--- /dev/null
+++ b/src/profile-walk-hero.js
@@ -0,0 +1,502 @@
+// Profile walking-avatar hero — the live, embodied header for a user profile.
+//
+// Renders the profile owner's primary avatar as a live walking body inside an
+// iframe pointed at /walk-embed (the chrome-less embed runtime in
+// src/walk-embed.js). The embed autoplays a slow idle wander; the joystick lets
+// a visitor take the controls right in the hero. Two CTAs sit beside it:
+//
+// • "Say hi" → opens the owner's REAL chat surface. We never invent an
+// endpoint: the avatar page (/avatars/:id?view=chat) hosts a
+// live LLM chat tab, and the agent detail page (/agent/:id)
+// hosts the live "try it" chat preview. We prefer the avatar
+// chat (it's the thing rendered in the hero), then fall back
+// to the agent chat.
+// • "Walk with me"→ opens the full walk experience at /walk/app for the same
+// body, carrying ?handle so the destination can place the
+// visitor alongside the owner.
+//
+// Every state is designed: a loading skeleton until the embed posts walk:ready,
+// an error state if it reports a failed avatar load, and a no-avatar empty state
+// with a real affordance (create an avatar / view agents) when the owner has no
+// embodied body to render. Honors prefers-reduced-motion by not autoplaying the
+// wander, and is keyboard- and screen-reader-accessible throughout.
+
+const esc = (s) =>
+ String(s ?? '').replace(
+ /[&<>"']/g,
+ (c) => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;' })[c],
+ );
+const attr = (s) => esc(s).replace(/"/g, '&quot;');
+
+let stylesInjected = false;
+
+function injectStyles() {
+ if (stylesInjected) return;
+ stylesInjected = true;
+ const style = document.createElement('style');
+ style.id = 'profile-walk-hero-css';
+ style.textContent = `
+ .pwh {
+ --pwh-accent: var(--accent, #ffd700);
+ position: relative;
+ display: grid;
+ grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr);
+ gap: 1.5rem;
+ align-items: stretch;
+ margin: 0 0 2rem;
+ border: 1px solid rgba(255, 255, 255, 0.07);
+ border-radius: 18px;
+ overflow: hidden;
+ background:
+ radial-gradient(ellipse at 20% 0%, color-mix(in srgb, var(--pwh-accent) 9%, transparent) 0%, transparent 60%),
+ rgba(255, 255, 255, 0.015);
+ }
+
+ .pwh-stage {
+ position: relative;
+ min-height: 380px;
+ border-right: 1px solid rgba(255, 255, 255, 0.05);
+ background:
+ radial-gradient(ellipse at 50% 120%, color-mix(in srgb, var(--pwh-accent) 14%, transparent) 0%, transparent 55%),
+ linear-gradient(180deg, rgba(255, 255, 255, 0.02) 0%, transparent 100%);
+ overflow: hidden;
+ }
+
+ .pwh-frame {
+ position: absolute;
+ inset: 0;
+ width: 100%;
+ height: 100%;
+ border: 0;
+ opacity: 0;
+ transition: opacity 0.5s ease;
+ }
+ .pwh-frame.is-ready { opacity: 1; }
+
+ /* Loading skeleton — a shimmer plinth + a pulsing body silhouette. */
+ .pwh-skeleton {
+ position: absolute;
+ inset: 0;
+ display: flex;
+ flex-direction: column;
+ align-items: center;
+ justify-content: flex-end;
+ padding-bottom: 18%;
+ gap: 1rem;
+ z-index: 2;
+ }
+ .pwh-skeleton[hidden] { display: none; }
+ .pwh-skel-body {
+ width: 64px;
+ height: 150px;
+ border-radius: 32px 32px 18px 18px;
+ background: linear-gradient(
+ 180deg,
+ rgba(255, 255, 255, 0.07) 0%,
+ rgba(255, 255, 255, 0.03) 100%
+ );
+ animation: pwh-pulse 1.6s ease-in-out infinite;
+ }
+ .pwh-skel-disc {
+ width: 180px;
+ height: 26px;
+ border-radius: 50%;
+ background: radial-gradient(ellipse at center, rgba(255, 255, 255, 0.06), transparent 70%);
+ }
+ .pwh-skel-label {
+ font-size: 0.7rem;
+ letter-spacing: 0.04em;
+ color: rgba(255, 255, 255, 0.35);
+ }
+ @keyframes pwh-pulse {
+ 0%, 100% { opacity: 0.5; transform: translateY(0); }
+ 50% { opacity: 0.85; transform: translateY(-4px); }
+ }
+
+ /* Empty (no embodied avatar) + error states share the centered layout. */
+ .pwh-state {
+ position: absolute;
+ inset: 0;
+ display: flex;
+ flex-direction: column;
+ align-items: center;
+ justify-content: center;
+ text-align: center;
+ gap: 0.75rem;
+ padding: 2rem;
+ z-index: 3;
+ }
+ .pwh-state[hidden] { display: none; }
+ .pwh-state-glyph {
+ font-size: 2.6rem;
+ color: color-mix(in srgb, var(--pwh-accent) 45%, transparent);
+ line-height: 1;
+ }
+ .pwh-state-title {
+ font-size: 1rem;
+ font-weight: 500;
+ color: rgba(255, 255, 255, 0.85);
+ margin: 0;
+ }
+ .pwh-state-text {
+ font-size: 0.8rem;
+ color: rgba(255, 255, 255, 0.45);
+ margin: 0;
+ max-width: 30ch;
+ line-height: 1.55;
+ }
+ .pwh-state-cta {
+ display: inline-flex;
+ align-items: center;
+ gap: 0.4rem;
+ margin-top: 0.4rem;
+ font-size: 0.8rem;
+ font-weight: 500;
+ padding: 0.5rem 1rem;
+ border-radius: 999px;
+ border: 1px solid color-mix(in srgb, var(--pwh-accent) 35%, transparent);
+ color: color-mix(in srgb, var(--pwh-accent) 90%, white 10%);
+ text-decoration: none;
+ transition: border-color 0.15s ease, background 0.15s ease;
+ }
+ .pwh-state-cta:hover {
+ border-color: color-mix(in srgb, var(--pwh-accent) 60%, transparent);
+ background: color-mix(in srgb, var(--pwh-accent) 10%, transparent);
+ }
+ .pwh-state-cta:focus-visible {
+ outline: 2px solid var(--pwh-accent);
+ outline-offset: 2px;
+ }
+
+ /* Live pill — sits over the stage once the body is walking. */
+ .pwh-live {
+ position: absolute;
+ top: 0.75rem;
+ left: 0.75rem;
+ z-index: 4;
+ display: inline-flex;
+ align-items: center;
+ gap: 0.4rem;
+ font-size: 0.6rem;
+ text-transform: uppercase;
+ letter-spacing: 0.12em;
+ color: rgba(255, 255, 255, 0.7);
+ background: rgba(0, 0, 0, 0.4);
+ border: 1px solid rgba(255, 255, 255, 0.1);
+ padding: 0.25rem 0.6rem;
+ border-radius: 999px;
+ backdrop-filter: blur(8px);
+ opacity: 0;
+ transition: opacity 0.4s ease;
+ pointer-events: none;
+ }
+ .pwh-live.is-ready { opacity: 1; }
+ .pwh-live-dot {
+ width: 6px;
+ height: 6px;
+ border-radius: 50%;
+ background: #4ade80;
+ box-shadow: 0 0 6px rgba(74, 222, 128, 0.9);
+ animation: pwh-blink 2s ease-in-out infinite;
+ }
+ @keyframes pwh-blink {
+ 0%, 100% { opacity: 1; }
+ 50% { opacity: 0.35; }
+ }
+
+ /* Side panel — title + CTAs. */
+ .pwh-side {
+ display: flex;
+ flex-direction: column;
+ justify-content: center;
+ gap: 0.75rem;
+ padding: 1.75rem 1.75rem 1.75rem 0.5rem;
+ }
+ .pwh-eyebrow {
+ font-size: 0.6rem;
+ text-transform: uppercase;
+ letter-spacing: 0.16em;
+ color: color-mix(in srgb, var(--pwh-accent) 75%, transparent);
+ margin: 0;
+ }
+ .pwh-title {
+ font-size: 1.35rem;
+ font-weight: 300;
+ letter-spacing: -0.02em;
+ color: #f5f5f5;
+ margin: 0;
+ line-height: 1.2;
+ }
+ .pwh-sub {
+ font-size: 0.82rem;
+ color: rgba(255, 255, 255, 0.45);
+ margin: 0;
+ line-height: 1.55;
+ }
+ .pwh-actions {
+ display: flex;
+ flex-wrap: wrap;
+ gap: 0.5rem;
+ margin-top: 0.4rem;
+ }
+ .pwh-btn {
+ display: inline-flex;
+ align-items: center;
+ gap: 0.45rem;
+ font-family: inherit;
+ font-size: 0.85rem;
+ font-weight: 500;
+ padding: 0.55rem 1.15rem;
+ border-radius: 999px;
+ cursor: pointer;
+ text-decoration: none;
+ border: 1px solid rgba(255, 255, 255, 0.18);
+ background: transparent;
+ color: rgba(255, 255, 255, 0.9);
+ transition: background 0.15s ease, border-color 0.15s ease, opacity 0.15s ease, transform 0.1s ease;
+ }
+ .pwh-btn:hover { border-color: rgba(255, 255, 255, 0.4); }
+ .pwh-btn:active { transform: translateY(1px); }
+ .pwh-btn:focus-visible {
+ outline: 2px solid var(--pwh-accent);
+ outline-offset: 2px;
+ }
+ .pwh-btn--primary {
+ background: var(--pwh-accent);
+ color: #111;
+ border-color: var(--pwh-accent);
+ }
+ .pwh-btn--primary:hover { opacity: 0.88; }
+ .pwh-btn svg { width: 15px; height: 15px; }
+
+ @media (max-width: 860px) {
+ .pwh {
+ grid-template-columns: 1fr;
+ }
+ .pwh-stage {
+ border-right: 0;
+ border-bottom: 1px solid rgba(255, 255, 255, 0.05);
+ min-height: 340px;
+ }
+ .pwh-side {
+ padding: 1.5rem;
+ text-align: center;
+ align-items: center;
+ }
+ .pwh-actions { justify-content: center; }
+ }
+
+ @media (max-width: 360px) {
+ .pwh-stage { min-height: 300px; }
+ .pwh-actions { width: 100%; }
+ .pwh-btn { flex: 1 1 auto; justify-content: center; }
+ }
+
+ @media (prefers-reduced-motion: reduce) {
+ .pwh-frame { transition: none; }
+ .pwh-skel-body { animation: none; }
+ .pwh-live-dot { animation: none; }
+ }
+ `;
+ document.head.appendChild(style);
+}
+
+const prefersReducedMotion = () =>
+ typeof window.matchMedia === 'function' &&
+ window.matchMedia('(prefers-reduced-motion: reduce)').matches;
+
+// Resolve the body to embody. Prefer a real avatar GLB (the owner's primary),
+// then an agent (its resolved avatar), so the hero always shows the most
+// representative body the owner actually has.
+function resolveEmbodiment({ avatars = [], agents = [] }) {
+ const avatar = avatars.find((a) => a.model_url) || avatars.find((a) => a.id) || null;
+ const agent = agents.find((a) => a.id) || null;
+ if (avatar) return { kind: 'avatar', id: avatar.id, name: avatar.name };
+ if (agent) return { kind: 'agent', id: agent.id, name: agent.name };
+ return null;
+}
+
+// The REAL chat surface for this owner. Avatars carry a live LLM chat tab at
+// /avatars/:id?view=chat; agents carry the live chat preview at /agent/:id.
+function chatHref(embodiment) {
+ if (embodiment.kind === 'avatar')
+ return `/avatars/${encodeURIComponent(embodiment.id)}?view=chat`;
+ return `/agent/${encodeURIComponent(embodiment.id)}#chat`;
+}
+
+// The full walk experience for this same body. /walk/app accepts ?avatar= or
+// ?agent=; ?handle carries the owner so the destination can co-locate visitors.
+function walkHref(embodiment, handle) {
+ const key = embodiment.kind === 'avatar' ? 'avatar' : 'agent';
+ const params = new URLSearchParams({ [key]: embodiment.id });
+ if (handle) params.set('handle', handle);
+ return `/walk/app?${params.toString()}`;
+}
+
+// Build the chrome-less embed URL for the hero stage. controls=joystick lets a
+// visitor drive; autoplay wanders idly — disabled under reduced-motion so the
+// body simply stands rather than pacing on its own.
+function embedSrc(embodiment) {
+ const key = embodiment.kind === 'avatar' ? 'avatar' : 'agent';
+ const params = new URLSearchParams({
+ [key]: embodiment.id,
+ controls: 'joystick',
+ env: 'studio',
+ ground: 'true',
+ });
+ params.set('autoplay', prefersReducedMotion() ? 'false' : 'true');
+ return `/walk-embed?${params.toString()}`;
+}
+
+const ICON_CHAT =
+ '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"/></svg>';
+const ICON_WALK =
+ '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><circle cx="13" cy="4" r="2"/><path d="m9 21 2-5 2 2 1 4"/><path d="m5 13 3-3 3 1 2 3"/><path d="M15 11l3 1 1 3"/></svg>';
+
+// Render the no-avatar empty state. Owners get a "create an avatar" affordance;
+// visitors get a softer "no body yet" with a link to the owner's agents tab.
+function emptyStateHtml({ isOwner, displayName }) {
+ if (isOwner) {
+ return `
+ <div class="pwh-state-glyph" aria-hidden="true">◎</div>
+ <p class="pwh-state-title">Give yourself a body</p>
+ <p class="pwh-state-text">Upload or generate an avatar to walk live on your profile and across three.ws.</p>
+ <a class="pwh-state-cta" href="/create">Create an avatar →</a>`;
+ }
+ return `
+ <div class="pwh-state-glyph" aria-hidden="true">◎</div>
+ <p class="pwh-state-title">${esc(displayName)} has no walking body yet</p>
+ <p class="pwh-state-text">When they add an avatar, it’ll walk live right here.</p>
+ <a class="pwh-state-cta" href="/discover">Explore avatars →</a>`;
+}
+
+/**
+ * Mount the walking-avatar hero.
+ *
+ * @param {HTMLElement} mountEl container the hero replaces its contents into
+ * @param {object} ctx
+ * @param {object} ctx.user the profile owner (display_name, username)
+ * @param {Array} ctx.avatars owner's public avatars
+ * @param {Array} ctx.agents owner's public agents
+ * @param {boolean} ctx.isOwner viewer owns this profile
+ * @param {string} [ctx.accent] accent color token for the gradient
+ */
+export function mountProfileWalkHero(mountEl, ctx) {
+ if (!mountEl) return;
+ injectStyles();
+
+ const { user, avatars = [], agents = [], isOwner = false, accent } = ctx;
+ const displayName = user?.display_name || user?.username || 'This builder';
+ const handle = user?.username || '';
+ const embodiment = resolveEmbodiment({ avatars, agents });
+
+ const hero = document.createElement('section');
+ hero.className = 'pwh';
+ hero.setAttribute('aria-label', `${displayName}'s live avatar`);
+ if (accent) hero.style.setProperty('--pwh-accent', accent);
+
+ // No embodied body → render the empty state and a single "browse" affordance
+ // in the side panel; no iframe, no CTAs that would dead-end.
+ if (!embodiment) {
+ hero.innerHTML = `
+ <div class="pwh-stage">
+ <div class="pwh-state">${emptyStateHtml({ isOwner, displayName })}</div>
+ </div>
+ <div class="pwh-side">
+ <p class="pwh-eyebrow">Live avatar</p>
+ <h2 class="pwh-title">Nobody’s home… yet</h2>
+ <p class="pwh-sub">${
+ isOwner
+ ? 'Add an avatar and it will greet every visitor by walking around right here.'
+ : `${esc(displayName)} hasn’t added a walking avatar to their profile.`
+ }</p>
+ </div>`;
+ mountEl.replaceChildren(hero);
+ return;
+ }
+
+ const chat = chatHref(embodiment);
+ const walk = walkHref(embodiment, handle);
+ const src = embedSrc(embodiment);
+ const bodyName = embodiment.name ? esc(embodiment.name) : esc(displayName);
+
+ hero.innerHTML = `
+ <div class="pwh-stage">
+ <span class="pwh-live" aria-hidden="true"><span class="pwh-live-dot"></span>Live</span>
+ <div class="pwh-skeleton" aria-hidden="true">
+ <div class="pwh-skel-body"></div>
+ <div class="pwh-skel-disc"></div>
+ <div class="pwh-skel-label">Waking up ${bodyName}…</div>
+ </div>
+ <div class="pwh-state" hidden role="alert">
+ <div class="pwh-state-glyph" aria-hidden="true">⚠</div>
+ <p class="pwh-state-title">Couldn’t load the avatar</p>
+ <p class="pwh-state-text">The 3D body failed to load. You can still chat or open the full walk.</p>
+ <a class="pwh-state-cta" href="${attr(walk)}">Open full walk →</a>
+ </div>
+ <iframe
+ class="pwh-frame"
+ title="${attr(displayName)}’s avatar walking live — drag to look around, use the joystick to move"
+ loading="lazy"
+ allow="accelerometer; gyroscope"
+ referrerpolicy="no-referrer-when-downgrade"
+ ></iframe>
+ </div>
+ <div class="pwh-side">
+ <p class="pwh-eyebrow">Live avatar</p>
+ <h2 class="pwh-title">Meet ${esc(displayName)}</h2>
+ <p class="pwh-sub">${bodyName} is walking live. Drive it with the joystick, say hi, or step into the world together.</p>
+ <div class="pwh-actions">
+ <a class="pwh-btn pwh-btn--primary" href="${attr(chat)}">${ICON_CHAT}Say hi</a>
+ <a class="pwh-btn" href="${attr(walk)}">${ICON_WALK}Walk with me</a>
+ </div>
+ </div>`;
+
+ mountEl.replaceChildren(hero);
+
+ const frame = hero.querySelector('.pwh-frame');
+ const skeleton = hero.querySelector('.pwh-skeleton');
+ const livePill = hero.querySelector('.pwh-live');
+ const errorState = hero.querySelector('.pwh-state');
+
+ let settled = false;
+ let watchdog = 0;
+ const teardown = () => {
+ clearTimeout(watchdog);
+ window.removeEventListener('message', onMessage);
+ };
+ const showError = () => {
+ if (settled) return;
+ settled = true;
+ teardown();
+ skeleton.hidden = true;
+ frame.classList.remove('is-ready');
+ errorState.hidden = false;
+ };
+ const showReady = () => {
+ if (settled) return;
+ settled = true;
+ teardown();
+ skeleton.hidden = true;
+ frame.classList.add('is-ready');
+ livePill.classList.add('is-ready');
+ };
+
+ // The embed posts walk:ready when the body is loaded and walk:error if the
+ // avatar fails. We listen for both; a watchdog covers a silent failure so the
+ // skeleton never spins forever.
+ function onMessage(e) {
+ if (e.source !== frame.contentWindow) return;
+ const type = e.data?.type;
+ if (type === 'walk:ready') showReady();
+ else if (type === 'walk:error') showError();
+ }
+ window.addEventListener('message', onMessage);
+
+ // If the iframe loaded but never handshook, assume it's up rather than
+ // stranding the visitor on the skeleton — the embed always renders a body.
+ watchdog = setTimeout(showReady, 12000);
+
+ frame.addEventListener('error', showError, { once: true });
+ frame.src = src;
+}
diff --git a/tasks/CLEANUP-MANIFEST.md b/tasks/CLEANUP-MANIFEST.md
index 8ab584398..965b20a30 100644
--- a/tasks/CLEANUP-MANIFEST.md
+++ b/tasks/CLEANUP-MANIFEST.md
@@ -170,3 +170,11 @@ Retired (feature verified shipped):
|---|---|---|
| tasks/walk/36-walk-path-visualization.md | DELETE | Built: src/walk-trails.js (footprints/glow/line, 3D decals+points & 2D DOM/canvas/SVG, 60-cap, accent color, 5s fade) wired into src/walk.js + src/walk-companion.js with persisted style toggle. |
| tasks/walk/23-agent-detail-walk-mode.md | DELETE | Built: ?agent=/?avatar= resolution in src/walk-embed.js + "Walk with this agent" CTA & live preview card in pages/agent-detail.html/src/agent-detail.js. |
+
+## 2026-06-21 built-and-shipped (walk batch 4)
+
+| spec file | decision | evidence |
+|---|---|---|
+| tasks/walk/24-agent-embed-walking-mode.md | DELETE | Built: "Walking avatar" mode in src/agent-embed-modal.js (options, live preview, copy snippet → /walk-embed?agent=). |
+| tasks/walk/27-dashboard-topbar-walking-avatar.md | DELETE | Built: 64x80 live walking avatar in src/dashboard-next/components/topbar.js from /api/avatars/mine + unread badge (fixed unread_count) + wave-on-notification. |
+| tasks/walk/28-profile-page-walking-avatar.md | DELETE | Built: src/profile-walk-hero.js walking hero in pages/profile.html with Say hi (real chat surface) + Walk with me, all states. |
diff --git a/tasks/walk/24-agent-embed-walking-mode.md b/tasks/walk/24-agent-embed-walking-mode.md
deleted file mode 100644
index aaca32f3c..000000000
--- a/tasks/walk/24-agent-embed-walking-mode.md
+++ /dev/null
@@ -1,42 +0,0 @@
-# Task 24 — Agent Embed: Walking Avatar Mode for Embedded Agents
-
-## Priority: HIGH
-
-## Objective
-Extend `pages/agent-embed.html` (the embeddable agent widget) so the agent appears as a walking avatar — not just a chat box. Customers embedding an agent on their site get a live, walking, conversational character instead of a flat chat bubble.
-
-## Scope
-- Files: `pages/agent-embed.html`, `src/agent-embed-modal.js`
-- Add a `mode=walking` query param to the embed page
-- When `mode=walking`:
- - Render the walking avatar canvas (reuses `src/walk.js` core)
- - Render a chat input below the avatar (single-line, expands on focus)
- - User types → send to existing agent chat API → response → `walk.say(reply, { voice: true })` (task 15)
- - Avatar plays `talking` gesture during reply
- - Idle behavior: wanders subtly within a 2m radius (uses NPC wander AI from task 19, scoped)
-- Custom domain support: if embedded under a customer's domain via the agent embed allowlist, keep working (no CORS issues — verify with real cross-origin test)
-- Backward compatible: existing embeds without `mode=walking` continue to work as before
-
-## Definition of Done
-- `<iframe src="https://three.ws/agent-embed?agent=<id>&mode=walking">` renders a walking avatar with chat
-- Type a message → avatar responds in voice + bubble + talking gesture
-- Idle wander does not feel jittery
-- Works on a foreign origin (test with a static HTML file served from a different localhost port)
-- No console errors
-
-## Rules
-Complete 100%. No stubs. No fake data. Real chat backend, real TTS, real avatar. Wire end-to-end.
-
-<!-- AUTO:self-delete-on-complete -->
-
----
-
-## ✅ On completion — delete this file
-
-This file is a unit of work, not a permanent doc. The moment every item above is **built, wired, verified, and committed** to the "Definition of done" in the repo-root `CLAUDE.md`, remove it in the same change:
-
-```bash
-git rm "tasks/walk/24-agent-embed-walking-mode.md"
-```
-
-Stage the deletion alongside your implementation and include it in the completion commit. This directory is the backlog: a file that still exists is unfinished work; a file that is gone has shipped. Do not delete early, and never leave a completed prompt behind.
diff --git a/tasks/walk/27-dashboard-topbar-walking-avatar.md b/tasks/walk/27-dashboard-topbar-walking-avatar.md
deleted file mode 100644
index 04068da0a..000000000
--- a/tasks/walk/27-dashboard-topbar-walking-avatar.md
+++ /dev/null
@@ -1,45 +0,0 @@
-# Task 27 — Dashboard: Walking Avatar in Topbar / Sidebar
-
-## Priority: MEDIUM
-
-## Objective
-Show the signed-in user's primary avatar walking inside a small embedded canvas in the dashboard topbar. The avatar is a live status indicator: idle when no notifications, walks/waves when there's something new.
-
-## Scope
-- Files: `public/dashboard-classic/index.html`, `public/dashboard/`, `src/dashboard/dashboard.js`, `public/dashboard-next/`
-- Add a 64×80px walking avatar canvas in the topbar (right side, before user menu)
-- Uses real `/api/avatars/mine?primary=true` to get the user's primary avatar
-- State driven by real data:
- - Default: avatar idles
- - New notification (poll `/api/notifications/unread-count` every 30s or via existing SSE/WS): avatar plays `wave` gesture
- - User receives a tip / payment: avatar plays `cheer` gesture
- - Long inactivity (10 min): avatar sits down
-- Click the avatar → opens a dropdown with:
- - Avatar's name + handle
- - "Open Walk" → `/walk?avatar=<id>`
- - "Edit Avatar" → `/avatar-edit?id=<id>`
-- Render with low-cost settings: 30 FPS, antialias off, no shadows — keeps dashboard snappy
-
-## Definition of Done
-- Sign in, open dashboard → avatar walks/idles in topbar
-- Trigger a real notification → avatar waves within 30s
-- Click avatar → dropdown opens with working links
-- No measurable impact on dashboard render performance (verify with DevTools Performance tab)
-- No console errors
-
-## Rules
-Complete 100%. No stubs. No fake data. Real avatar fetch, real notification source, real interactions. Wire end-to-end.
-
-<!-- AUTO:self-delete-on-complete -->
-
----
-
-## ✅ On completion — delete this file
-
-This file is a unit of work, not a permanent doc. The moment every item above is **built, wired, verified, and committed** to the "Definition of done" in the repo-root `CLAUDE.md`, remove it in the same change:
-
-```bash
-git rm "tasks/walk/27-dashboard-topbar-walking-avatar.md"
-```
-
-Stage the deletion alongside your implementation and include it in the completion commit. This directory is the backlog: a file that still exists is unfinished work; a file that is gone has shipped. Do not delete early, and never leave a completed prompt behind.
diff --git a/tasks/walk/28-profile-page-walking-avatar.md b/tasks/walk/28-profile-page-walking-avatar.md
deleted file mode 100644
index e4c88971d..000000000
--- a/tasks/walk/28-profile-page-walking-avatar.md
+++ /dev/null
@@ -1,43 +0,0 @@
-# Task 28 — Profile Page: Walking Avatar Hero
-
-## Priority: MEDIUM
-
-## Objective
-Replace the static avatar image on user profile pages (`pages/profile.html`, `pages/handle.html`) with a live walking avatar canvas in a stage area. Avatar walks idly when no visitor interacts; reacts when a visitor clicks.
-
-## Scope
-- Files: `pages/profile.html`, `pages/handle.html`
-- Hero section gets a 480×600 canvas (responsive: full-width on mobile)
-- Avatar: the profile owner's primary avatar
-- Background: gradient based on profile's accent color (read from `profile.theme.accent`)
-- Default behavior: avatar wanders within stage area
-- Visitor interactions:
- - Click stage → avatar walks to click point, plays `wave`
- - Hover stage → avatar turns to face cursor
- - "Say hi" button → visitor records a short voice clip → sent to profile owner's inbox (real `/api/messages`); avatar plays `agree` gesture and shows bubble "Got it!"
-- Stats overlay (top-right of stage): follower count, agent count, joined date — real values from `/api/profiles/<handle>`
-- "Walk with me" CTA → opens full `/walk?avatar=<id>&handle=<handle>` (multiplayer-aware: drops visitor into same room if profile owner is currently online)
-
-## Definition of Done
-- Visit a profile → avatar walks live in hero stage
-- Click stage → avatar reacts as specified
-- "Say hi" sends a real message and the owner sees it in their inbox
-- Profile stats are real values
-- No console errors
-
-## Rules
-Complete 100%. No stubs. No fake data. Real avatar, real profile data, real messaging. Wire end-to-end.
-
-<!-- AUTO:self-delete-on-complete -->
-
----
-
-## ✅ On completion — delete this file
-
-This file is a unit of work, not a permanent doc. The moment every item above is **built, wired, verified, and committed** to the "Definition of done" in the repo-root `CLAUDE.md`, remove it in the same change:
-
-```bash
-git rm "tasks/walk/28-profile-page-walking-avatar.md"
-```
-
-Stage the deletion alongside your implementation and include it in the completion commit. This directory is the backlog: a file that still exists is unfinished work; a file that is gone has shipped. Do not delete early, and never leave a completed prompt behind.