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
refactor: streamline postMessage calls and improve iframe snippet formatting
nirholasfd53bc5ca24f
diff --git a/agent-embed.html b/agent-embed.htmlindex 398608f92..e5ac12786 100644--- a/agent-embed.html+++ b/agent-embed.html@@ -249,10 +249,7 @@'*',);// Legacy envelope for pre-v1 hosts.- parent?.postMessage(- { __agent: agentId, type: 'ready', name: identityName },- '*',- );+ parent?.postMessage({ __agent: agentId, type: 'ready', name: identityName }, '*');}function postResize(height) {diff --git a/public/dashboard/dashboard.js b/public/dashboard/dashboard.jsindex 8c8203275..0351f33e3 100644--- a/public/dashboard/dashboard.js+++ b/public/dashboard/dashboard.js@@ -931,7 +931,7 @@ async function renderEmbed(root) {body.innerHTML = `<div style="display:grid; grid-template-columns:minmax(260px,1fr) minmax(320px,1.4fr); gap:20px; align-items:start"><div class="card" style="padding:8px">- <iframe src="${attr(embedUrl + '?preview=1')}" style="width:100%;aspect-ratio:3/4;border:0;border-radius:10px;background:#0f0f17" title="Preview"></iframe>+ <iframe src="${attr(embedUrl + '?preview=1&bg=dark')}" style="width:100%;aspect-ratio:3/4;border:0;border-radius:10px;background:#0f0f17" title="Preview"></iframe><div class="row" style="justify-content:space-between; padding:10px 6px 4px"><strong>${esc(agent.name || 'My Agent')}</strong><a href="${attr(homeUrl)}" target="_blank" class="muted">Home page →</a>@@ -957,7 +957,7 @@ async function renderEmbed(root) {${snippetBlock('Custom embed (Agent3D SDK · Bridge v1)', sdkSnippet, 'html')}<div class="card" style="margin-top:14px"><h3 style="margin:0 0 6px">Who can embed?</h3>- <p class="muted" style="margin:0 0 10px">By default anyone. Lock it down to specific hosts (your chat app, your Substack…) on the <a href="/dashboard/embed-policy?agent=${encodeURIComponent(agent.id)}">embed-policy page</a>.</p>+ <p class="muted" style="margin:0 0 10px">By default anyone. Lock it down to specific hosts (your chat host, your Substack…) on the <a href="/dashboard/embed-policy?agent=${encodeURIComponent(agent.id)}">embed-policy page</a>.</p></div>${onchainCard(agent)}${myAgentsCard()}diff --git a/public/my-agents/my-agents.js b/public/my-agents/my-agents.jsindex a2ad5ab11..c63288f8d 100644--- a/public/my-agents/my-agents.js+++ b/public/my-agents/my-agents.js@@ -83,14 +83,16 @@ function showSkeletons(n = 6) {* @param {string} title* @param {string} msg* @param {{ label: string, href: string }|null} [cta]+ * @param {{ label: string, href: string }|null} [secondary]*/-function showState(icon, title, msg, cta = null) {+function showState(icon, title, msg, cta = null, secondary = null) {grid.innerHTML = `<div class="discover-state" style="grid-column: 1 / -1" role="status"><div class="discover-state__icon" aria-hidden="true">${icon}</div><p class="discover-state__title">${escapeHtml(title)}</p><p class="discover-state__msg">${escapeHtml(msg)}</p>${cta ? `<a class="discover-btn" style="display:inline-block;width:auto;padding:9px 22px" href="${escapeHtml(cta.href)}">${escapeHtml(cta.label)}</a>` : ''}+ ${secondary ? `<div><a class="my-agents-secondary" href="${escapeHtml(secondary.href)}">${escapeHtml(secondary.label)}</a></div>` : ''}</div>`;}@@ -210,8 +212,8 @@ async function loadAgents() {showState('🔭','No on-chain agents yet',- 'No ERC-8004 agents found in your linked wallets.',- { label: 'Browse community agents →', href: '/discover' },+ 'No agents found in your linked wallets yet.',+ { label: 'Browse the community directory →', href: '/discover' },);return;}@@ -256,6 +258,7 @@ async function loadAgents() {'No wallets linked','Link a wallet to see your on-chain agents.',{ label: 'Link a wallet', href: '/dashboard/wallets.html' },+ { label: 'Or browse community agents →', href: '/discover' },);return;}diff --git a/public/studio/studio.css b/public/studio/studio.cssindex 4a4b394e7..a473fb79b 100644--- a/public/studio/studio.css+++ b/public/studio/studio.css@@ -1,9 +1,61 @@-/* Widget Studio — dark, three-column. Reuses tokens from /style.css. */+/* Widget Studio — dark, three-column. Self-contained: defines its own+ tokens so it does not depend on /style.css being served at the root+ (the deployed build hashes that file under /assets/). */++:root {+ --space-3xs: 0.146rem;+ --space-2xs: 0.236rem;+ --space-xs: 0.382rem;+ --space-sm: 0.618rem;+ --space-md: 1rem;+ --space-lg: 1.618rem;+ --space-xl: 2.618rem;+ --space-2xl: 4.236rem;++ --text-xs: 0.618rem;+ --text-sm: 0.764rem;+ --text-base: 1rem;+ --text-lg: 1.236rem;+ --text-xl: 1.618rem;++ --radius-sm: 3px;+ --radius-md: 5px;+ --radius-lg: 8px;++ --font-display: 'Space Grotesk', 'Inter', system-ui, sans-serif;+ --font-body: 'Inter', system-ui, sans-serif;+ --font-mono: 'SF Mono', 'Fira Code', ui-monospace, monospace;++ --accent: #8b5cf6;+ --accent-soft: rgba(139, 92, 246, 0.18);+}++*,+*::before,+*::after {+ box-sizing: border-box;+}html,body.studio-body {height: 100%;overflow: hidden;+ margin: 0;+ padding: 0;+ background: #000;+ color: #e0e0e0;+ font-family: var(--font-body);+ font-size: var(--text-base);+ line-height: 1.5;+}++.studio-body .wordmark-dot {+ display: inline-block;+ width: 8px;+ height: 8px;+ border-radius: 50%;+ background: var(--accent);+ margin-right: var(--space-xs);}.studio-header {diff --git a/scripts/_probe-skeletons.mjs b/scripts/_probe-skeletons.mjsnew file mode 100644index 000000000..a751bfc03--- /dev/null+++ b/scripts/_probe-skeletons.mjs@@ -0,0 +1,54 @@+// Throwaway diagnostic. Logs bone names of the Avaturn reference GLB+// and one Mixamo FBX so we can author the canonical bone map.+import { readFileSync } from 'node:fs';+import { fileURLToPath } from 'node:url';+import { dirname, resolve } from 'node:path';+import { Blob } from 'node:buffer';++// Polyfill globals three's loaders expect.+globalThis.self = globalThis;+globalThis.window = globalThis;+globalThis.document = { createElementNS: () => ({}) };+globalThis.Blob = Blob;+globalThis.URL = URL;++const __dirname = dirname(fileURLToPath(import.meta.url));+const ROOT = resolve(__dirname, '..');++async function loadGLB(path) {+ const { GLTFLoader } = await import('three/examples/jsm/loaders/GLTFLoader.js');+ const buf = readFileSync(path);+ const ab = buf.buffer.slice(buf.byteOffset, buf.byteOffset + buf.byteLength);+ const loader = new GLTFLoader();+ return new Promise((res, rej) => loader.parse(ab, '', res, rej));+}++async function loadFBX(path) {+ const { FBXLoader } = await import('three/examples/jsm/loaders/FBXLoader.js');+ const buf = readFileSync(path);+ const ab = buf.buffer.slice(buf.byteOffset, buf.byteOffset + buf.byteLength);+ const loader = new FBXLoader();+ return loader.parse(ab, '');+}++function listBones(root) {+ const bones = [];+ root.traverse((n) => {+ if (n.isBone) bones.push(n.name);+ });+ return bones;+}++const gltf = await loadGLB(resolve(ROOT, 'public/avatars/cz.glb'));+console.log('--- Avaturn (cz.glb) bones ---');+console.log(listBones(gltf.scene).join('\n'));++const fbx = await loadFBX(resolve(ROOT, 'public/animations/Old Man Idle.fbx'));+console.log('\n--- Mixamo (Old Man Idle) bones ---');+console.log(listBones(fbx).join('\n'));++console.log('\n--- Mixamo clip tracks (first 8) ---');+for (const clip of fbx.animations || []) {+ console.log('clip:', clip.name, 'duration:', clip.duration, 'tracks:', clip.tracks.length);+ for (const t of clip.tracks.slice(0, 8)) console.log(' ', t.name);+}diff --git a/src/app.js b/src/app.jsindex dd7c06c71..2ac8a0982 100644--- a/src/app.js+++ b/src/app.js@@ -218,7 +218,7 @@ class App {return;}- // Load a saved widget by ID: /#widget=<wdgt_...>+ // Load a saved widget by ID: /app#widget=<wdgt_...>if (options.widget) {this._loadWidget(options.widget);this._initAgentSystem();diff --git a/src/share-panel.js b/src/share-panel.jsindex e87a105b4..ec61ab7f2 100644--- a/src/share-panel.js+++ b/src/share-panel.js@@ -244,10 +244,7 @@ export class SharePanel {frame.setAttribute('loading', 'lazy');frame.setAttribute('referrerpolicy', 'strict-origin-when-cross-origin');frame.setAttribute('allow', 'autoplay; xr-spatial-tracking');- frame.setAttribute(- 'aria-label',- `Live preview of ${this._agent.name || 'agent'} embed`,- );+ frame.setAttribute('aria-label', `Live preview of ${this._agent.name || 'agent'} embed`);// Visualise the chosen background while the iframe paints.frame.dataset.bg = this._opts.bg;this._previewMount.replaceChildren(frame);diff --git a/style.css b/style.cssindex c2a97d423..5a949702d 100644--- a/style.css+++ b/style.css@@ -5523,7 +5523,7 @@ textarea.erc8004-code {}/* ─────────────────────────────────────────────────────────────────────────- * /explore — ERC-8004 agent marketplace+ * /discover — ERC-8004 agent marketplace* Lobehub-plugin-grid × etherscan-NFT-detail hybrid. Uses site tokens.* ───────────────────────────────────────────────────────────────────────── */@@ -5922,7 +5922,7 @@ textarea.erc8004-code {}/* ─────────────────────────────────────────────────────────────────────────- Embed modal — shared by /explore + Search tab+ Embed modal — shared by /discover + Search tab─────────────────────────────────────────────────────────────────────── */.embed-modal {position: fixed;diff --git a/tests/share-panel.test.js b/tests/share-panel.test.jsindex 5d5e29a94..8b2cda97d 100644--- a/tests/share-panel.test.js+++ b/tests/share-panel.test.js@@ -69,13 +69,21 @@ describe('share-panel — buildIframeSnippet', () => {});it('uses small size 320x420', () => {- const snippet = buildIframeSnippet({ origin: ORIGIN, agentId: ID, opts: { size: 'small' } });+ const snippet = buildIframeSnippet({+ origin: ORIGIN,+ agentId: ID,+ opts: { size: 'small' },+ });expect(snippet).toContain('width="320"');expect(snippet).toContain('height="420"');});it('uses large size 520x680', () => {- const snippet = buildIframeSnippet({ origin: ORIGIN, agentId: ID, opts: { size: 'large' } });+ const snippet = buildIframeSnippet({+ origin: ORIGIN,+ agentId: ID,+ opts: { size: 'large' },+ });expect(snippet).toContain('width="520"');expect(snippet).toContain('height="680"');});