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(agent-home): mount share panel + deploy chip

nirholasd613091eb637
diff --git a/agent-home.html b/agent-home.html
index 7af2b3dbb..a29e33c26 100644
--- a/agent-home.html
+++ b/agent-home.html
@@ -1,363 +1,512 @@
<!doctype html>
<html lang="en">
-<head>
- <meta charset="utf-8" />
- <title>Agent Home — 3D Agent</title>
- <meta name="viewport" content="width=device-width, initial-scale=1.0" />
- <meta name="description" content="An embodied 3D AI agent — body, place, identity, memory." />
- <meta name="theme-color" content="#000000" />
-
- <link rel="shortcut icon" href="/favicon.ico" />
- <link rel="preconnect" href="https://fonts.googleapis.com" />
- <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
- <link rel="stylesheet" href="/style.css" />
- <link href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500&display=swap" rel="stylesheet" />
-
- <meta property="og:type" content="website" />
- <meta property="og:title" content="Agent" id="og-title" />
- <meta property="og:description" content="An embodied 3D agent." id="og-description" />
- <meta property="og:image" content="" id="og-image" />
- <meta property="og:url" content="" id="og-url" />
- <meta name="twitter:card" content="summary_large_image" />
- <meta name="twitter:title" content="Agent" id="tw-title" />
- <meta name="twitter:description" content="" id="tw-description" />
- <meta name="twitter:image" content="" id="tw-image" />
- <link rel="alternate" type="application/json+oembed" href="" id="oembed-link" title="Agent oEmbed" />
-
- <style>
- body {
- overflow: auto;
- display: flex;
- flex-direction: column;
- }
-
- .agent-page-header {
- display: flex;
- align-items: center;
- gap: 1rem;
- padding: 1rem 1.618rem;
- border-bottom: 1px solid rgba(255,255,255,0.06);
- }
-
- .agent-page-header a {
- color: rgba(255,255,255,0.4);
- text-decoration: none;
- font-size: 0.764rem;
- }
-
- .agent-page-header a:hover {
- color: rgba(255,255,255,0.8);
- }
-
- .agent-page-hero {
- max-width: 520px;
- margin: 4rem auto 2rem;
- padding: 0 1rem;
- text-align: center;
- }
-
- .agent-page-title {
- font-size: 1.618rem;
- font-weight: 300;
- color: #e5e5e5;
- letter-spacing: -0.02em;
- margin: 0 0 0.618rem;
- }
-
- .agent-page-subtitle {
- font-size: 0.764rem;
- color: rgba(255,255,255,0.35);
- line-height: 1.618;
- }
-
- .agent-page-card-wrap {
- max-width: 420px;
- margin: 0 auto;
- padding: 0 1rem 4rem;
- }
-
- .agent-page-card-wrap .agent-home-timeline {
- max-height: 320px;
- }
-
- .agent-page-card-wrap .agent-home-panel {
- background: rgba(12, 12, 18, 0.98);
- border: 1px solid rgba(255,255,255,0.08);
- border-radius: 12px;
- }
-
- .agent-embed-hint {
- max-width: 420px;
- margin: 1.618rem auto 0;
- padding: 0 1rem;
- }
-
- .agent-embed-tabs {
- display: flex;
- gap: 0.382rem;
- margin-bottom: 0.618rem;
- }
-
- .agent-embed-tab {
- background: transparent;
- border: 1px solid rgba(255,255,255,0.1);
- color: rgba(255,255,255,0.5);
- font-size: 0.618rem;
- padding: 0.236rem 0.618rem;
- border-radius: 999px;
- cursor: pointer;
- font-family: inherit;
- }
-
- .agent-embed-tab.active {
- background: rgba(255,255,255,0.08);
- color: rgba(255,255,255,0.9);
- border-color: rgba(255,255,255,0.2);
- }
-
- .agent-embed-code-wrap {
- position: relative;
- }
-
- .agent-embed-code {
- background: rgba(255,255,255,0.04);
- border: 1px solid rgba(255,255,255,0.08);
- border-radius: 8px;
- padding: 0.618rem 1rem;
- padding-right: 3.8rem;
- font-family: monospace;
- font-size: 0.618rem;
- color: rgba(255,255,255,0.55);
- word-break: break-all;
- line-height: 1.5;
- }
-
- .agent-embed-copy {
- position: absolute;
- top: 0.382rem;
- right: 0.382rem;
- background: rgba(255,255,255,0.06);
- border: 1px solid rgba(255,255,255,0.1);
- color: rgba(255,255,255,0.6);
- font-size: 0.618rem;
- padding: 0.236rem 0.618rem;
- border-radius: 6px;
- cursor: pointer;
- font-family: inherit;
- }
-
- .agent-embed-copy:hover { color: rgba(255,255,255,0.9); background: rgba(255,255,255,0.1); }
- .agent-embed-copy.copied { color: #86efac; border-color: rgba(134,239,172,0.3); }
-
- .agent-embed-label {
- font-size: 0.618rem;
- color: rgba(255,255,255,0.25);
- margin-bottom: 0.382rem;
- }
-
- .agent-embed-preview-link {
- display: inline-block;
- margin-top: 0.618rem;
- font-size: 0.618rem;
- color: rgba(255,255,255,0.35);
- text-decoration: none;
- }
-
- .agent-embed-preview-link:hover { color: rgba(255,255,255,0.7); }
-
- .agent-skills-full {
- max-width: 420px;
- margin: 1.618rem auto 0;
- padding: 0 1rem;
- }
-
- .agent-skills-title {
- font-size: 0.618rem;
- color: rgba(255,255,255,0.25);
- margin-bottom: 0.618rem;
- text-transform: uppercase;
- letter-spacing: 0.08em;
- }
-
- .agent-skills-grid {
- display: grid;
- grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
- gap: 0.618rem;
- }
-
- .agent-skill-card {
- background: rgba(255,255,255,0.04);
- border: 1px solid rgba(255,255,255,0.07);
- border-radius: 8px;
- padding: 0.618rem;
- }
-
- .agent-skill-card-name {
- font-size: 0.764rem;
- font-weight: 500;
- color: rgba(255,255,255,0.7);
- margin-bottom: 0.236rem;
- }
-
- .agent-skill-card-desc {
- font-size: 0.618rem;
- color: rgba(255,255,255,0.3);
- line-height: 1.382;
- }
-
- .loading-placeholder {
- color: rgba(255,255,255,0.2);
- font-size: 0.764rem;
- text-align: center;
- padding: 2rem;
- }
- </style>
-</head>
-<body>
- <div class="agent-page-header">
- <a href="/">← 3D Agent</a>
- </div>
-
- <div class="agent-page-hero">
- <h1 class="agent-page-title" id="page-agent-name">Agent</h1>
- <p class="agent-page-subtitle" id="page-agent-desc">
- Embodied. Present. Persistent.
- </p>
- </div>
-
- <div class="agent-page-card-wrap">
- <div id="agent-home-container">
- <div class="loading-placeholder">Loading agent…</div>
+ <head>
+ <meta charset="utf-8" />
+ <title>Agent Home — 3D Agent</title>
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
+ <meta
+ name="description"
+ content="An embodied 3D AI agent — body, place, identity, memory."
+ />
+ <meta name="theme-color" content="#000000" />
+
+ <link rel="shortcut icon" href="/favicon.ico" />
+ <link rel="preconnect" href="https://fonts.googleapis.com" />
+ <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
+ <link rel="stylesheet" href="/style.css" />
+ <link
+ href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500&display=swap"
+ rel="stylesheet"
+ />
+
+ <meta property="og:type" content="website" />
+ <meta property="og:title" content="Agent" id="og-title" />
+ <meta property="og:description" content="An embodied 3D agent." id="og-description" />
+ <meta property="og:image" content="" id="og-image" />
+ <meta property="og:url" content="" id="og-url" />
+ <meta name="twitter:card" content="summary_large_image" />
+ <meta name="twitter:title" content="Agent" id="tw-title" />
+ <meta name="twitter:description" content="" id="tw-description" />
+ <meta name="twitter:image" content="" id="tw-image" />
+ <link
+ rel="alternate"
+ type="application/json+oembed"
+ href=""
+ id="oembed-link"
+ title="Agent oEmbed"
+ />
+
+ <!-- BEGIN:AGENT_HOME_ORPHANS_HEAD -->
+ <style>
+ /* ── Share button ─────────────────────────────────────────────────── */
+ .agent-share-btn {
+ display: inline-flex;
+ align-items: center;
+ gap: 0.4em;
+ padding: 0.45em 0.9em;
+ background: transparent;
+ border: 1px solid rgba(255, 255, 255, 0.14);
+ border-radius: 6px;
+ color: rgba(255, 255, 255, 0.6);
+ font-size: 0.764rem;
+ font-family: inherit;
+ cursor: pointer;
+ transition:
+ color 0.15s,
+ border-color 0.15s,
+ background 0.15s;
+ min-width: 44px;
+ min-height: 44px;
+ }
+ .agent-share-btn:hover {
+ color: rgba(255, 255, 255, 0.9);
+ border-color: rgba(255, 255, 255, 0.28);
+ background: rgba(255, 255, 255, 0.05);
+ }
+ .agent-share-btn:focus-visible {
+ outline: 2px solid rgba(255, 255, 255, 0.4);
+ outline-offset: 2px;
+ }
+
+ /* ── Agent title row (name + deploy chip) ─────────────────────────── */
+ .agent-title-row {
+ display: inline-flex;
+ align-items: center;
+ gap: 12px;
+ justify-content: center;
+ }
+ .agent-deploy-chip-mount {
+ display: inline-flex;
+ align-items: center;
+ }
+
+ /* ── Toast ────────────────────────────────────────────────────────── */
+ .agent-deploy-toast {
+ position: fixed;
+ bottom: 1.5rem;
+ left: 50%;
+ transform: translateX(-50%) translateY(0.5rem);
+ background: rgba(15, 46, 26, 0.96);
+ border: 1px solid rgba(74, 222, 128, 0.35);
+ color: #4ade80;
+ font-size: 0.8rem;
+ padding: 0.5em 1.1em;
+ border-radius: 8px;
+ opacity: 0;
+ transition:
+ opacity 0.2s,
+ transform 0.2s;
+ pointer-events: none;
+ z-index: 9999;
+ }
+ .agent-deploy-toast--visible {
+ opacity: 1;
+ transform: translateX(-50%) translateY(0);
+ }
+ </style>
+ <!-- END:AGENT_HOME_ORPHANS_HEAD -->
+
+ <style>
+ body {
+ overflow: auto;
+ display: flex;
+ flex-direction: column;
+ }
+
+ .agent-page-header {
+ display: flex;
+ align-items: center;
+ gap: 1rem;
+ padding: 1rem 1.618rem;
+ border-bottom: 1px solid rgba(255, 255, 255, 0.06);
+ }
+
+ .agent-page-header a {
+ color: rgba(255, 255, 255, 0.4);
+ text-decoration: none;
+ font-size: 0.764rem;
+ }
+
+ .agent-page-header a:hover {
+ color: rgba(255, 255, 255, 0.8);
+ }
+
+ .agent-page-hero {
+ max-width: 520px;
+ margin: 4rem auto 2rem;
+ padding: 0 1rem;
+ text-align: center;
+ }
+
+ .agent-page-title {
+ font-size: 1.618rem;
+ font-weight: 300;
+ color: #e5e5e5;
+ letter-spacing: -0.02em;
+ margin: 0 0 0.618rem;
+ }
+
+ .agent-page-subtitle {
+ font-size: 0.764rem;
+ color: rgba(255, 255, 255, 0.35);
+ line-height: 1.618;
+ }
+
+ .agent-page-card-wrap {
+ max-width: 420px;
+ margin: 0 auto;
+ padding: 0 1rem 4rem;
+ }
+
+ .agent-page-card-wrap .agent-home-timeline {
+ max-height: 320px;
+ }
+
+ .agent-page-card-wrap .agent-home-panel {
+ background: rgba(12, 12, 18, 0.98);
+ border: 1px solid rgba(255, 255, 255, 0.08);
+ border-radius: 12px;
+ }
+
+ .agent-embed-hint {
+ max-width: 420px;
+ margin: 1.618rem auto 0;
+ padding: 0 1rem;
+ }
+
+ .agent-embed-tabs {
+ display: flex;
+ gap: 0.382rem;
+ margin-bottom: 0.618rem;
+ }
+
+ .agent-embed-tab {
+ background: transparent;
+ border: 1px solid rgba(255, 255, 255, 0.1);
+ color: rgba(255, 255, 255, 0.5);
+ font-size: 0.618rem;
+ padding: 0.236rem 0.618rem;
+ border-radius: 999px;
+ cursor: pointer;
+ font-family: inherit;
+ }
+
+ .agent-embed-tab.active {
+ background: rgba(255, 255, 255, 0.08);
+ color: rgba(255, 255, 255, 0.9);
+ border-color: rgba(255, 255, 255, 0.2);
+ }
+
+ .agent-embed-code-wrap {
+ position: relative;
+ }
+
+ .agent-embed-code {
+ background: rgba(255, 255, 255, 0.04);
+ border: 1px solid rgba(255, 255, 255, 0.08);
+ border-radius: 8px;
+ padding: 0.618rem 1rem;
+ padding-right: 3.8rem;
+ font-family: monospace;
+ font-size: 0.618rem;
+ color: rgba(255, 255, 255, 0.55);
+ word-break: break-all;
+ line-height: 1.5;
+ }
+
+ .agent-embed-copy {
+ position: absolute;
+ top: 0.382rem;
+ right: 0.382rem;
+ background: rgba(255, 255, 255, 0.06);
+ border: 1px solid rgba(255, 255, 255, 0.1);
+ color: rgba(255, 255, 255, 0.6);
+ font-size: 0.618rem;
+ padding: 0.236rem 0.618rem;
+ border-radius: 6px;
+ cursor: pointer;
+ font-family: inherit;
+ }
+
+ .agent-embed-copy:hover {
+ color: rgba(255, 255, 255, 0.9);
+ background: rgba(255, 255, 255, 0.1);
+ }
+ .agent-embed-copy.copied {
+ color: #86efac;
+ border-color: rgba(134, 239, 172, 0.3);
+ }
+
+ .agent-embed-label {
+ font-size: 0.618rem;
+ color: rgba(255, 255, 255, 0.25);
+ margin-bottom: 0.382rem;
+ }
+
+ .agent-embed-preview-link {
+ display: inline-block;
+ margin-top: 0.618rem;
+ font-size: 0.618rem;
+ color: rgba(255, 255, 255, 0.35);
+ text-decoration: none;
+ }
+
+ .agent-embed-preview-link:hover {
+ color: rgba(255, 255, 255, 0.7);
+ }
+
+ .agent-skills-full {
+ max-width: 420px;
+ margin: 1.618rem auto 0;
+ padding: 0 1rem;
+ }
+
+ .agent-skills-title {
+ font-size: 0.618rem;
+ color: rgba(255, 255, 255, 0.25);
+ margin-bottom: 0.618rem;
+ text-transform: uppercase;
+ letter-spacing: 0.08em;
+ }
+
+ .agent-skills-grid {
+ display: grid;
+ grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
+ gap: 0.618rem;
+ }
+
+ .agent-skill-card {
+ background: rgba(255, 255, 255, 0.04);
+ border: 1px solid rgba(255, 255, 255, 0.07);
+ border-radius: 8px;
+ padding: 0.618rem;
+ }
+
+ .agent-skill-card-name {
+ font-size: 0.764rem;
+ font-weight: 500;
+ color: rgba(255, 255, 255, 0.7);
+ margin-bottom: 0.236rem;
+ }
+
+ .agent-skill-card-desc {
+ font-size: 0.618rem;
+ color: rgba(255, 255, 255, 0.3);
+ line-height: 1.382;
+ }
+
+ .loading-placeholder {
+ color: rgba(255, 255, 255, 0.2);
+ font-size: 0.764rem;
+ text-align: center;
+ padding: 2rem;
+ }
+ </style>
+ </head>
+ <body>
+ <div class="agent-page-header" style="justify-content: space-between">
+ <a href="/">← 3D Agent</a>
+ <!-- BEGIN:AGENT_HOME_ORPHANS_DOM -->
+ <div id="agent-share-btn-mount"></div>
+ <!-- END:AGENT_HOME_ORPHANS_DOM -->
+ </div>
+
+ <div class="agent-page-hero">
+ <h1 class="agent-page-title" id="page-agent-name">Agent</h1>
+ <p class="agent-page-subtitle" id="page-agent-desc">Embodied. Present. Persistent.</p>
</div>
- </div>
-
- <div class="agent-skills-full" id="agent-skills-section" style="display:none">
- <div class="agent-skills-title">Skills</div>
- <div class="agent-skills-grid" id="agent-skills-grid"></div>
- </div>
-
- <div class="agent-embed-hint" id="agent-embed-section" style="display:none">
- <div class="agent-embed-label">Share &amp; embed</div>
- <div class="agent-embed-tabs" role="tablist">
- <button class="agent-embed-tab active" data-tab="iframe">iframe</button>
- <button class="agent-embed-tab" data-tab="link">link</button>
- <button class="agent-embed-tab" data-tab="webcomponent">&lt;agent-3d&gt;</button>
+
+ <div class="agent-page-card-wrap">
+ <div id="agent-home-container">
+ <div class="loading-placeholder">Loading agent…</div>
+ </div>
</div>
- <div class="agent-embed-code-wrap">
- <div class="agent-embed-code" id="agent-embed-code"></div>
- <button class="agent-embed-copy" id="agent-embed-copy">copy</button>
+
+ <div class="agent-skills-full" id="agent-skills-section" style="display: none">
+ <div class="agent-skills-title">Skills</div>
+ <div class="agent-skills-grid" id="agent-skills-grid"></div>
</div>
- <a class="agent-embed-preview-link" id="agent-embed-preview" target="_blank" rel="noopener">preview embed →</a>
- <a class="agent-embed-preview-link" id="agent-embed-settings" href="" target="_blank" rel="noopener">embed settings →</a>
- </div>
-
- <script type="module">
- import { AgentIdentity } from './src/agent-identity.js';
- import { AgentMemory } from './src/agent-memory.js';
- import { AgentSkills } from './src/agent-skills.js';
- import { AgentHome } from './src/agent-home.js';
- import { protocol } from './src/agent-protocol.js';
-
- const agentId = location.pathname.split('/').filter(Boolean).pop();
-
- async function main() {
- const identity = new AgentIdentity({ agentId: agentId || undefined, autoLoad: false });
- await identity.load();
-
- document.getElementById('page-agent-name').textContent = identity.name;
- if (identity.description) {
- document.getElementById('page-agent-desc').textContent = identity.description;
- }
-
- const container = document.getElementById('agent-home-container');
- container.innerHTML = '';
- const home = new AgentHome(container, identity, protocol, null);
- await home.render();
-
- if (identity.skills?.length) {
- const skills = new AgentSkills(protocol, identity.memory);
- const section = document.getElementById('agent-skills-section');
- const grid = document.getElementById('agent-skills-grid');
- section.style.display = '';
- skills.list().filter(s => identity.skills.includes(s.name)).forEach(skill => {
- const card = document.createElement('div');
- card.className = 'agent-skill-card';
- card.innerHTML = `
+
+ <div class="agent-embed-hint" id="agent-embed-section" style="display: none">
+ <div class="agent-embed-label">Share &amp; embed</div>
+ <div class="agent-embed-tabs" role="tablist">
+ <button class="agent-embed-tab active" data-tab="iframe">iframe</button>
+ <button class="agent-embed-tab" data-tab="link">link</button>
+ <button class="agent-embed-tab" data-tab="webcomponent">&lt;agent-3d&gt;</button>
+ </div>
+ <div class="agent-embed-code-wrap">
+ <div class="agent-embed-code" id="agent-embed-code"></div>
+ <button class="agent-embed-copy" id="agent-embed-copy">copy</button>
+ </div>
+ <a
+ class="agent-embed-preview-link"
+ id="agent-embed-preview"
+ target="_blank"
+ rel="noopener"
+ >preview embed →</a
+ >
+ <a
+ class="agent-embed-preview-link"
+ id="agent-embed-settings"
+ href=""
+ target="_blank"
+ rel="noopener"
+ >embed settings →</a
+ >
+ </div>
+
+ <script type="module">
+ import { AgentIdentity } from './src/agent-identity.js';
+ import { AgentMemory } from './src/agent-memory.js';
+ import { AgentSkills } from './src/agent-skills.js';
+ import { AgentHome } from './src/agent-home.js';
+ import { protocol } from './src/agent-protocol.js';
+
+ const agentId = location.pathname.split('/').filter(Boolean).pop();
+
+ async function main() {
+ const identity = new AgentIdentity({
+ agentId: agentId || undefined,
+ autoLoad: false,
+ });
+ await identity.load();
+
+ document.getElementById('page-agent-name').textContent = identity.name;
+ if (identity.description) {
+ document.getElementById('page-agent-desc').textContent = identity.description;
+ }
+
+ const container = document.getElementById('agent-home-container');
+ container.innerHTML = '';
+ const home = new AgentHome(container, identity, protocol, null);
+ await home.render();
+
+ if (identity.skills?.length) {
+ const skills = new AgentSkills(protocol, identity.memory);
+ const section = document.getElementById('agent-skills-section');
+ const grid = document.getElementById('agent-skills-grid');
+ section.style.display = '';
+ skills
+ .list()
+ .filter((s) => identity.skills.includes(s.name))
+ .forEach((skill) => {
+ const card = document.createElement('div');
+ card.className = 'agent-skill-card';
+ card.innerHTML = `
<div class="agent-skill-card-name">${skill.name}</div>
<div class="agent-skill-card-desc">${skill.description}</div>
`;
- grid.appendChild(card);
+ grid.appendChild(card);
+ });
+ }
+
+ const embedSection = document.getElementById('agent-embed-section');
+ const embedCode = document.getElementById('agent-embed-code');
+ const embedCopy = document.getElementById('agent-embed-copy');
+ const embedPreview = document.getElementById('agent-embed-preview');
+ const origin = location.origin;
+ const embedUrl = `${origin}/agent/${identity.id}/embed`;
+ const agentUrl = `${origin}/agent/${identity.id}`;
+
+ const snippets = {
+ iframe: `<iframe src="${embedUrl}" width="420" height="520" style="border:0;border-radius:12px" allow="autoplay; xr-spatial-tracking"></iframe>`,
+ link: agentUrl,
+ webcomponent: `<script type="module" src="${origin}/dist-lib/agent-3d.js"><\/script>\n<agent-3d agent-id="${identity.id}" style="width:420px;height:520px"></agent-3d>`,
+ };
+
+ let current = 'iframe';
+ const render = () => {
+ embedCode.textContent = snippets[current];
+ };
+ render();
+ embedSection.style.display = '';
+ embedPreview.href = embedUrl;
+ document.getElementById('agent-embed-settings').href =
+ '/dashboard/embed-policy?agent=' + identity.id;
+
+ document.querySelectorAll('.agent-embed-tab').forEach((btn) => {
+ btn.addEventListener('click', () => {
+ current = btn.dataset.tab;
+ document
+ .querySelectorAll('.agent-embed-tab')
+ .forEach((b) => b.classList.toggle('active', b === btn));
+ render();
+ });
});
- }
- const embedSection = document.getElementById('agent-embed-section');
- const embedCode = document.getElementById('agent-embed-code');
- const embedCopy = document.getElementById('agent-embed-copy');
- const embedPreview = document.getElementById('agent-embed-preview');
- const origin = location.origin;
- const embedUrl = `${origin}/agent/${identity.id}/embed`;
- const agentUrl = `${origin}/agent/${identity.id}`;
-
- const snippets = {
- iframe: `<iframe src="${embedUrl}" width="420" height="520" style="border:0;border-radius:12px" allow="autoplay; xr-spatial-tracking"></iframe>`,
- link: agentUrl,
- webcomponent: `<script type="module" src="${origin}/dist-lib/agent-3d.js"><\/script>\n<agent-3d agent-id="${identity.id}" style="width:420px;height:520px"></agent-3d>`,
- };
-
- let current = 'iframe';
- const render = () => { embedCode.textContent = snippets[current]; };
- render();
- embedSection.style.display = '';
- embedPreview.href = embedUrl;
- document.getElementById('agent-embed-settings').href = '/dashboard/embed-policy?agent=' + identity.id;
-
- document.querySelectorAll('.agent-embed-tab').forEach(btn => {
- btn.addEventListener('click', () => {
- current = btn.dataset.tab;
- document.querySelectorAll('.agent-embed-tab').forEach(b => b.classList.toggle('active', b === btn));
- render();
+ embedCopy.addEventListener('click', async () => {
+ try {
+ await navigator.clipboard.writeText(snippets[current]);
+ embedCopy.textContent = 'copied';
+ embedCopy.classList.add('copied');
+ setTimeout(() => {
+ embedCopy.textContent = 'copy';
+ embedCopy.classList.remove('copied');
+ }, 1400);
+ } catch {}
});
- });
- embedCopy.addEventListener('click', async () => {
- try {
- await navigator.clipboard.writeText(snippets[current]);
- embedCopy.textContent = 'copied';
- embedCopy.classList.add('copied');
- setTimeout(() => { embedCopy.textContent = 'copy'; embedCopy.classList.remove('copied'); }, 1400);
- } catch {}
+ populateUnfurlMeta(identity);
+
+ // Signal orphans module that identity is ready
+ window.__agentReady = { agentId, identity };
+ window.dispatchEvent(new CustomEvent('agent:ready'));
+ }
+
+ function populateUnfurlMeta(identity) {
+ const id = identity?.id;
+ if (!id) return;
+ const origin = location.origin;
+ const name = identity.name || 'Agent';
+ const desc = identity.description || 'An embodied 3D agent.';
+ const agentUrl = `${origin}/agent/${id}`;
+ const img = `${origin}/api/agent/${id}/og`;
+ const setAttr = (elId, attr, value) => {
+ const el = document.getElementById(elId);
+ if (el) el.setAttribute(attr, value);
+ };
+ setAttr('og-title', 'content', name);
+ setAttr('og-description', 'content', desc);
+ setAttr('og-image', 'content', img);
+ setAttr('og-url', 'content', agentUrl);
+ setAttr('tw-title', 'content', name);
+ setAttr('tw-description', 'content', desc);
+ setAttr('tw-image', 'content', img);
+ setAttr(
+ 'oembed-link',
+ 'href',
+ `${origin}/api/oembed?url=${encodeURIComponent(agentUrl)}`,
+ );
+ document.title = `${name} — 3D Agent`;
+ }
+
+ main().catch((err) => {
+ document.getElementById('agent-home-container').innerHTML =
+ `<div class="loading-placeholder">Could not load agent: ${err.message}</div>`;
});
+ </script>
+
+ <!-- BEGIN:AGENT_HOME_ORPHANS_SCRIPT -->
+ <script type="module">
+ import { mountOrphans } from './src/agent-home-orphans.js';
+
+ function _tryMount() {
+ const d = window.__agentReady;
+ if (!d) return;
+ const shareMount = document.getElementById('agent-share-btn-mount');
+ if (shareMount)
+ mountOrphans({ agentId: d.agentId, identity: d.identity, shareMount }).catch(
+ () => {},
+ );
+ }
- populateUnfurlMeta(identity);
- }
-
- function populateUnfurlMeta(identity) {
- const id = identity?.id;
- if (!id) return;
- const origin = location.origin;
- const name = identity.name || 'Agent';
- const desc = identity.description || 'An embodied 3D agent.';
- const agentUrl = `${origin}/agent/${id}`;
- const img = `${origin}/api/agent/${id}/og`;
- const setAttr = (elId, attr, value) => {
- const el = document.getElementById(elId);
- if (el) el.setAttribute(attr, value);
- };
- setAttr('og-title', 'content', name);
- setAttr('og-description', 'content', desc);
- setAttr('og-image', 'content', img);
- setAttr('og-url', 'content', agentUrl);
- setAttr('tw-title', 'content', name);
- setAttr('tw-description', 'content', desc);
- setAttr('tw-image', 'content', img);
- setAttr('oembed-link', 'href', `${origin}/api/oembed?url=${encodeURIComponent(agentUrl)}`);
- document.title = `${name} — 3D Agent`;
- }
-
- main().catch(err => {
- document.getElementById('agent-home-container').innerHTML =
- `<div class="loading-placeholder">Could not load agent: ${err.message}</div>`;
- });
- </script>
-</body>
+ // Guard against both orderings: event fires before listener (unlikely) or after
+ if (window.__agentReady) {
+ _tryMount();
+ } else {
+ window.addEventListener('agent:ready', _tryMount, { once: true });
+ }
+ </script>
+ <!-- END:AGENT_HOME_ORPHANS_SCRIPT -->
+ </body>
</html>
diff --git a/prompts/final-integration/03-agent-home-integration.md b/prompts/archive/final-integration/03-agent-home-integration.md
similarity index 85%
rename from prompts/final-integration/03-agent-home-integration.md
rename to prompts/archive/final-integration/03-agent-home-integration.md
index 1ea9181c3..4e327d729 100644
--- a/prompts/final-integration/03-agent-home-integration.md
+++ b/prompts/archive/final-integration/03-agent-home-integration.md
@@ -9,11 +9,12 @@ Two major modules shipped but never got mounted on this page:
1. **[src/share-panel.js](../../src/share-panel.js)** (215 LOC, production-ready) — one-click share modal with link, iframe snippet, web-component snippet, OG preview, and QR code. Class `SharePanel` is exported but **zero import sites** in the codebase.
2. **[src/erc8004/deploy-button.js](../../src/erc8004/deploy-button.js)** (282 LOC, production-ready) — minimal drop-in "Deploy on-chain" chip. Shows a deploy button if the agent is not yet ERC-8004 registered; shows a success chip with tx link if it is. Also orphan.
-Both classes are complete. Your job is UX plumbing: mount them on `agent-home.html` such that a visiting user can (a) share the agent, and (b) the *owner* of the agent can deploy it on-chain without leaving the page.
+Both classes are complete. Your job is UX plumbing: mount them on `agent-home.html` such that a visiting user can (a) share the agent, and (b) the _owner_ of the agent can deploy it on-chain without leaving the page.
## Goal
A polished agent landing page where:
+
- A **Share** button sits in a predictable top-right corner. Click → `SharePanel.open()`.
- A **Deploy on-chain** chip appears next to the agent name, but **only if the signed-in user is the agent owner** AND the agent is not yet registered on-chain. If already registered, the chip shows the chain + tx link instead. If the viewer is not the owner, nothing on-chain-related is visible.
- Both controls are keyboard accessible (tab-reachable, Enter/Space activates) and work on mobile (tap targets ≥ 44×44 px).
@@ -21,10 +22,11 @@ A polished agent landing page where:
## Files you own
Edit (inside uniquely-named anchor only):
+
- `agent-home.html` — add anchor blocks:
- - `<!-- BEGIN:AGENT_HOME_ORPHANS_HEAD --> ... <!-- END:AGENT_HOME_ORPHANS_HEAD -->` in `<head>` for any CSS links.
- - `<!-- BEGIN:AGENT_HOME_ORPHANS_DOM --> ... <!-- END:AGENT_HOME_ORPHANS_DOM -->` in the body for the share button markup (put next to the page chrome, typically top-right).
- - `<!-- BEGIN:AGENT_HOME_ORPHANS_SCRIPT --> ... <!-- END:AGENT_HOME_ORPHANS_SCRIPT -->` near existing scripts at end of body for the module-script wiring.
+ - `<!-- BEGIN:AGENT_HOME_ORPHANS_HEAD --> ... <!-- END:AGENT_HOME_ORPHANS_HEAD -->` in `<head>` for any CSS links.
+ - `<!-- BEGIN:AGENT_HOME_ORPHANS_DOM --> ... <!-- END:AGENT_HOME_ORPHANS_DOM -->` in the body for the share button markup (put next to the page chrome, typically top-right).
+ - `<!-- BEGIN:AGENT_HOME_ORPHANS_SCRIPT --> ... <!-- END:AGENT_HOME_ORPHANS_SCRIPT -->` near existing scripts at end of body for the module-script wiring.
- (Optional new file if needed) `src/agent-home-orphans.js` — the glue module that imports `SharePanel` + `DeployButton`, resolves current user + agent ownership, and mounts both. Create this file if keeping wiring out of inline HTML feels cleaner (recommended).
## Files read-only
@@ -39,32 +41,37 @@ Edit (inside uniquely-named anchor only):
## UX requirements
**Share button:**
+
- Button label: `Share` with an outline share icon (use an inline SVG; do not import an icon library).
- Placement: top-right of the main content area, aligned with the agent name/avatar thumbnail.
- Click: instantiate `SharePanel` once (cache the instance), call `.open()`. Reuse on subsequent clicks; never instantiate twice.
- Visible to ALL visitors (not gated).
**Deploy chip:**
+
- Render container: inline with the agent name, separated by a 12px gap.
- States:
- - Not on-chain + viewer is owner → `<DeployButton>` primary CTA.
- - On-chain → small pill showing chain name + shortened tx hash, linking out to the block explorer. Use `txExplorerUrl` from `src/erc8004/chain-meta.js` (read-only).
- - Not on-chain + viewer is NOT owner → render nothing.
- - User not signed in → render nothing (do not render a "sign in to deploy" prompt here; that's homepage's job).
+ - Not on-chain + viewer is owner → `<DeployButton>` primary CTA.
+ - On-chain → small pill showing chain name + shortened tx hash, linking out to the block explorer. Use `txExplorerUrl` from `src/erc8004/chain-meta.js` (read-only).
+ - Not on-chain + viewer is NOT owner → render nothing.
+ - User not signed in → render nothing (do not render a "sign in to deploy" prompt here; that's homepage's job).
- On successful deploy (via `onDeployed` callback): refresh the local agent record in place (do not hard-reload the page) and transition the chip to the on-chain success state. A brief toast `Agent registered on <chain>` is acceptable but not required.
**Ownership resolution rules:**
+
- The agent record has an `owner_user_id` field (or equivalent — verify against `api/agents/[id].js`). Match against the signed-in user's id.
- If the agent has a wallet-based owner (`owner_wallet`), match against the user's linked wallets via whichever helper `src/wallet-auth.js` exposes.
- **Do not** call `eth_accounts` from this module — that's a wallet connection, not an identity check. Ownership is a server-known fact.
- If ownership cannot be determined (no session, no wallet, API failure), treat as not-owner. Never show deploy UI on uncertainty.
**Accessibility:**
+
- `aria-label="Share agent"` on the share button; `aria-haspopup="dialog"`.
- Deploy chip: button semantics when actionable, link semantics when pointing to explorer.
- Focus trap inside share panel is already handled by `SharePanel` — do not duplicate.
**No layout regressions:**
+
- Before committing, open `agent-home.html` in the dev server and verify the existing page layout is unchanged at common viewport widths (360, 768, 1280, 1920). Screenshot in the report if possible.
## Deliverables checklist
diff --git a/src/agent-home-orphans.js b/src/agent-home-orphans.js
new file mode 100644
index 000000000..7973a409e
--- /dev/null
+++ b/src/agent-home-orphans.js
@@ -0,0 +1,167 @@
+/**
+ * Agent Home orphan mounts: SharePanel + DeployButton.
+ *
+ * Call mountOrphans() after the agent identity is ready. Handles:
+ * - Share button (all visitors)
+ * - Deploy chip (owner only, conditionally on-chain state)
+ *
+ * @module agent-home-orphans
+ */
+
+import { SharePanel } from './share-panel.js';
+import { DeployButton } from './erc8004/deploy-button.js';
+import './erc8004/deploy-button.css';
+import { getCurrentUser } from './wallet-auth.js';
+import { CHAIN_META, addressExplorerUrl } from './erc8004/chain-meta.js';
+
+/**
+ * Mount the share button and (if owner) the deploy chip.
+ *
+ * @param {{ agentId: string, identity: import('./agent-identity.js').AgentIdentity, shareMount: HTMLElement }} opts
+ * @returns {Promise<void>}
+ */
+export async function mountOrphans({ agentId, identity, shareMount }) {
+ _mountShareButton(shareMount, identity);
+
+ // Ownership resolution: rawAgent.user_id is only returned to the owner
+ const [user, rawAgent] = await Promise.all([getCurrentUser(), _fetchRawAgent(agentId)]);
+
+ if (!user || !rawAgent || rawAgent.user_id !== user.id) return;
+
+ const chipMount = _createChipMount();
+
+ if (rawAgent.chain_id) {
+ // Already on-chain: show pill (API doesn't store tx_hash, link to registry contract)
+ _renderSuccessChip(chipMount, rawAgent.chain_id, rawAgent.erc8004_registry);
+ } else {
+ // Not yet deployed: mount the deploy button
+ const agentObj = {
+ id: rawAgent.id,
+ name: rawAgent.name,
+ chainId: null,
+ txHash: null,
+ contractAddress: rawAgent.erc8004_registry || null,
+ };
+ const btn = new DeployButton({ agent: agentObj, container: chipMount });
+ btn.mount();
+ _watchForDeploy(chipMount, agentObj);
+ }
+}
+
+// ── Private helpers ────────────────────────────────────────────────────────────
+
+/**
+ * @param {HTMLElement} mount
+ * @param {import('./agent-identity.js').AgentIdentity} identity
+ */
+function _mountShareButton(mount, identity) {
+ const btn = document.createElement('button');
+ btn.className = 'agent-share-btn';
+ btn.setAttribute('aria-label', 'Share agent');
+ btn.setAttribute('aria-haspopup', 'dialog');
+ btn.innerHTML =
+ `<svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor"` +
+ ` stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">` +
+ `<circle cx="18" cy="5" r="3"/><circle cx="6" cy="12" r="3"/><circle cx="18" cy="19" r="3"/>` +
+ `<line x1="8.59" y1="13.51" x2="15.42" y2="17.49"/>` +
+ `<line x1="15.41" y1="6.51" x2="8.59" y2="10.49"/>` +
+ `</svg>Share`;
+
+ let panel = null;
+ btn.addEventListener('click', () => {
+ if (!panel) {
+ panel = new SharePanel({
+ agent: { id: identity.id, name: identity.name },
+ container: document.body,
+ });
+ }
+ panel.open();
+ });
+
+ mount.appendChild(btn);
+}
+
+/** Insert a chip mount span inline after the agent name heading. */
+function _createChipMount() {
+ const titleEl = document.getElementById('page-agent-name');
+ if (!titleEl) {
+ const fallback = document.createElement('div');
+ document.body.appendChild(fallback);
+ return fallback;
+ }
+
+ // Wrap h1 + chip in a flex row so the chip sits inline at 12px gap
+ const wrapper = document.createElement('div');
+ wrapper.className = 'agent-title-row';
+ titleEl.parentNode.insertBefore(wrapper, titleEl);
+ wrapper.appendChild(titleEl);
+
+ const chipMount = document.createElement('div');
+ chipMount.className = 'agent-deploy-chip-mount';
+ wrapper.appendChild(chipMount);
+ return chipMount;
+}
+
+/**
+ * @param {HTMLElement} mount
+ * @param {number} chainId
+ * @param {string|null} registryAddress
+ */
+function _renderSuccessChip(mount, chainId, registryAddress) {
+ const meta = CHAIN_META[chainId];
+ const chainName = meta?.name ?? `Chain ${chainId}`;
+ const explorerUrl = registryAddress ? addressExplorerUrl(chainId, registryAddress) : '#';
+ mount.innerHTML =
+ `<a class="deploy-chip deploy-chip--success"` +
+ ` href="${_esc(explorerUrl)}" target="_blank" rel="noopener noreferrer">` +
+ `&#x2B22; On ${_esc(chainName)}` +
+ `</a>`;
+}
+
+/** Watch for deploy-chip--success appearing → show a brief toast. */
+function _watchForDeploy(mount, agentObj) {
+ const obs = new MutationObserver(() => {
+ if (!mount.querySelector('.deploy-chip--success')) return;
+ obs.disconnect();
+ const chainName = CHAIN_META[agentObj.chainId]?.name ?? 'chain';
+ _showToast(`Agent registered on ${chainName}`);
+ });
+ obs.observe(mount, { childList: true, subtree: true });
+}
+
+/** @param {string} msg */
+function _showToast(msg) {
+ const toast = document.createElement('div');
+ toast.className = 'agent-deploy-toast';
+ toast.textContent = msg;
+ document.body.appendChild(toast);
+ requestAnimationFrame(() => toast.classList.add('agent-deploy-toast--visible'));
+ setTimeout(() => {
+ toast.classList.remove('agent-deploy-toast--visible');
+ setTimeout(() => toast.remove(), 300);
+ }, 3000);
+}
+
+/**
+ * @param {string} agentId
+ * @returns {Promise<object|null>}
+ */
+async function _fetchRawAgent(agentId) {
+ try {
+ const res = await fetch(`/api/agents/${agentId}`, { credentials: 'include' });
+ if (!res.ok) return null;
+ const { agent } = await res.json();
+ return agent ?? null;
+ } catch {
+ return null;
+ }
+}
+
+/** @param {unknown} str */
+function _esc(str) {
+ return String(str ?? '')
+ .replace(/&/g, '&amp;')
+ .replace(/</g, '&lt;')
+ .replace(/>/g, '&gt;')
+ .replace(/"/g, '&quot;');
+}