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.

milady

nirholas1030f82fc252
diff --git a/.env.example b/.env.example
index bb537f9c0..247cabd0a 100644
--- a/.env.example
+++ b/.env.example
@@ -53,3 +53,9 @@ VITE_PRIVY_APP_ID=
AVATURN_API_KEY=
# Optional override for self-hosted / staging Avaturn deployments.
AVATURN_API_URL=https://api.avaturn.me
+
+# Avaturn default editor — opened by the "Use default avatar" card at /create.
+# No session API / no photos required. Point at the hosted editor URL provided
+# by Avaturn; the developer ID (if needed) is appended as a query param.
+VITE_AVATURN_EDITOR_URL=https://editor.avaturn.me/
+VITE_AVATURN_DEVELOPER_ID=
diff --git a/api/agents.js b/api/agents.js
index 549a1eb55..7e6986977 100644
--- a/api/agents.js
+++ b/api/agents.js
@@ -95,16 +95,15 @@ async function handleGetOrCreateMe(req, res, auth) {
return json(res, 200, { agent: decorate(agent) });
} catch (err) {
- // Missing table / bad migration shouldn't brick the client — surface a
- // null agent and let the UI fall back to local-only identity.
+ // Any failure here (missing table, wallet generation error, missing env var)
+ // should not brick the client — surface null and let the UI fall back to
+ // local-only identity.
const code = err?.code || '';
const msg = String(err?.message || '');
const missing = code === '42P01' || /relation.*does not exist/i.test(msg);
- if (missing) {
- console.error('[agents/me] agent_identities table missing — run schema.sql', err);
- return json(res, 200, { agent: null, warning: 'agents_table_missing' });
- }
- throw err;
+ const warning = missing ? 'agents_table_missing' : 'agent_init_failed';
+ console.error(`[agents/me] ${warning}`, err);
+ return json(res, 200, { agent: null, warning });
}
}
@@ -199,6 +198,12 @@ async function handleUpdate(req, res, id, auth) {
return json(res, 200, { agent: decorate(updated) });
}
+// ── Patch (partial update) ────────────────────────────────────────────────
+
+async function handlePatchEdits(req, res, id, auth) {
+ return handleUpdate(req, res, id, auth);
+}
+
// ── Delete ────────────────────────────────────────────────────────────────
async function handleDelete(req, res, id, auth) {
diff --git a/app.html b/app.html
new file mode 100644
index 000000000..46474f450
--- /dev/null
+++ b/app.html
@@ -0,0 +1,208 @@
+<!doctype html>
+<html lang="en">
+ <head>
+ <meta charset="utf-8" />
+ <meta http-equiv="X-UA-Compatible" content="IE=edge" />
+ <title>3D Agent — AI-Powered 3D Model Viewer</title>
+ <meta
+ name="viewport"
+ content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, viewport-fit=cover"
+ />
+ <meta name="author" content="nirholas" />
+ <meta
+ name="description"
+ content="The first embodied 3D AI agent. Not a chatbot. A presence — with a body, a place, an identity, and memory."
+ />
+ <meta
+ name="keywords"
+ content="3D agent, AI agent, embodied AI, glTF viewer, GLB viewer, 3D model viewer, WebGL, three.js, ERC-8004, agent identity"
+ />
+ <meta name="theme-color" content="#000000" />
+
+ <!-- Open Graph -->
+ <meta property="og:type" content="website" />
+ <meta property="og:title" content="3D Agent — The First Embodied AI Agent" />
+ <meta
+ property="og:description"
+ content="Agents have always been imagined as present. We made that real."
+ />
+ <meta property="og:url" content="https://3dagent.vercel.app/" />
+ <meta property="og:site_name" content="3D Agent" />
+
+ <!-- Twitter / X -->
+ <meta name="twitter:card" content="summary_large_image" />
+ <meta name="twitter:title" content="3D Agent — Embodied AI" />
+ <meta
+ name="twitter:description"
+ content="The first 3D agent with a body, a place, an identity, and memory."
+ />
+ <meta name="twitter:creator" content="@nichxbt" />
+
+ <link rel="canonical" href="https://3dagent.vercel.app/app" />
+ <link rel="shortcut icon" href="/favicon.ico" />
+ <link rel="apple-touch-icon" href="/pwa-192x192.png" />
+ <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;600;700&family=Space+Grotesk:wght@500;600;700&display=swap"
+ rel="stylesheet"
+ />
+ <script defer type="module" src="src/app.js"></script>
+ </head>
+ <body>
+ <header>
+ <h1>
+ <a href="/"><span class="wordmark-dot" aria-hidden="true"></span>3D Agent</a>
+ </h1>
+ <nav class="features-nav">
+ <a href="/app" class="active">Viewer</a>
+ <a href="/features">Features</a>
+ <a href="/widgets">Widgets</a>
+ <a
+ class="save-to-account-btn"
+ id="save-to-account-btn"
+ hidden
+ title="Save this model to your account"
+ >
+ <svg
+ xmlns="http://www.w3.org/2000/svg"
+ width="14"
+ height="14"
+ viewBox="0 0 24 24"
+ fill="none"
+ stroke="currentColor"
+ stroke-width="2"
+ stroke-linecap="round"
+ stroke-linejoin="round"
+ aria-hidden="true"
+ >
+ <path d="M19 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h11l5 5v11a2 2 0 0 1-2 2z" />
+ <polyline points="17 21 17 13 7 13 7 21" />
+ <polyline points="7 3 7 8 15 8" />
+ </svg>
+ <span>Save to account</span>
+ </a>
+ <a
+ class="make-widget-btn"
+ id="make-widget-btn"
+ href="/studio"
+ hidden
+ title="Save the current model as an embeddable widget"
+ >
+ <svg
+ xmlns="http://www.w3.org/2000/svg"
+ width="14"
+ height="14"
+ viewBox="0 0 24 24"
+ fill="none"
+ stroke="currentColor"
+ stroke-width="2"
+ stroke-linecap="round"
+ stroke-linejoin="round"
+ aria-hidden="true"
+ >
+ <rect x="3" y="3" width="7" height="7" rx="1" />
+ <rect x="14" y="3" width="7" height="7" rx="1" />
+ <rect x="3" y="14" width="7" height="7" rx="1" />
+ <rect x="14" y="14" width="7" height="7" rx="1" />
+ </svg>
+ <span>Make this a widget</span>
+ </a>
+ <a href="/dashboard" class="nav-dashboard">Dashboard</a>
+ <a href="/login" class="nav-sign-in" id="nav-sign-in">Sign in</a>
+ </nav>
+ </header>
+
+ <main class="wrap">
+ <!-- Agent presence panel — rendered by AgentHome -->
+ <div class="agent-presence-sidebar" id="agent-presence-sidebar">
+ <div id="agent-home-container"></div>
+ </div>
+
+ <!-- Auth gate — shown only to anonymous visitors on the main viewer -->
+ <aside class="auth-gate" id="auth-gate">
+ <div class="auth-gate__inner">
+ <div class="auth-gate__eyebrow">
+ <span class="auth-gate__lock" aria-hidden="true">◎</span>
+ <span>Unlock the agent</span>
+ </div>
+ <h2 class="auth-gate__title">Your agent lives here</h2>
+ <p class="auth-gate__desc">
+ Sign in to access animations, scene controls, and your agent's on-chain
+ identity, memory, and skills.
+ </p>
+ <div class="auth-gate__actions">
+ <a class="auth-gate__btn auth-gate__btn--primary" href="/login">Sign in</a>
+ <a class="auth-gate__btn" href="/register">Create account</a>
+ </div>
+ <ul class="auth-gate__perks">
+ <li>Animations &amp; presence controls</li>
+ <li>Save avatars to your account</li>
+ <li>Register on-chain agent identity</li>
+ <li>Scene, lighting &amp; material editor</li>
+ </ul>
+ </div>
+ </aside>
+
+ <!-- 3D Viewer -->
+ <div class="viewer-container" id="viewer-container"></div>
+
+ <!-- Bottom bar -->
+ <div class="dropzone">
+ <div class="upload-btn">
+ <input type="file" name="file-input[]" id="file-input" multiple="" />
+ <label for="file-input">
+ <svg
+ xmlns="http://www.w3.org/2000/svg"
+ width="20"
+ height="17"
+ viewBox="0 0 20 17"
+ >
+ <path
+ d="M10 0l-5.2 4.9h3.3v5.1h3.8v-5.1h3.3l-5.2-4.9zm9.3 11.5l-3.2-2.1h-2l3.4 2.6h-3.5c-.1 0-.2.1-.2.1l-.8 2.3h-6l-.8-2.2c-.1-.1-.1-.2-.2-.2h-3.6l3.4-2.6h-2l-3.2 2.1c-.4.3-.7 1-.6 1.5l.6 3.1c.1.5.7.9 1.2.9h16.3c.6 0 1.1-.4 1.3-.9l.6-3.1c.1-.5-.2-1.2-.7-1.5z"
+ ></path>
+ </svg>
+ <span>Upload your own model</span>
+ </label>
+ </div>
+ <span class="drop-hint">or drag &amp; drop glTF / GLB anywhere</span>
+ <a
+ class="create-avatar-btn"
+ id="create-avatar-btn"
+ href="/create"
+ title="Create a custom 3D avatar from a selfie"
+ >
+ <svg
+ xmlns="http://www.w3.org/2000/svg"
+ width="16"
+ height="16"
+ viewBox="0 0 24 24"
+ fill="currentColor"
+ >
+ <path
+ d="M12 12c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm0 2c-2.67 0-8 1.34-8 4v2h16v-2c0-2.66-5.33-4-8-4z"
+ />
+ </svg>
+ <span>Create Avatar</span>
+ </a>
+ </div>
+ <div class="spinner"></div>
+ </main>
+
+ <!-- Golden Ratio dev grid — toggle with Alt+G -->
+ <div class="phi-grid" id="phi-grid">
+ <div class="phi-grid-h"></div>
+ <div class="phi-grid-thirds"></div>
+ <div class="phi-grid-thirds-h"></div>
+ </div>
+ <div class="phi-grid-label" id="phi-grid-label">φ Grid — Alt+G to toggle</div>
+ <script>
+ document.addEventListener('keydown', function (e) {
+ if (e.altKey && e.key.toLowerCase() === 'g') {
+ document.getElementById('phi-grid').classList.toggle('visible');
+ }
+ });
+ </script>
+ </body>
+</html>
diff --git a/create.html b/create.html
index 3bfe43808..1648c76e6 100644
--- a/create.html
+++ b/create.html
@@ -1,405 +1,478 @@
<!doctype html>
<html lang="en">
-<head>
- <meta charset="utf-8" />
- <meta name="viewport" content="width=device-width, initial-scale=1" />
- <title>Create avatar · 3D Agent</title>
- <link rel="icon" href="/favicon.ico" />
- <meta name="description" content="Create a 3D avatar from a selfie. Use your camera or upload photos." />
- <meta name="robots" content="noindex" />
- <style>
- :root { color-scheme: dark; --accent:#d6ff3d; --accent-ink:#0a0a0a; --bg:#05060a; --panel:#0f1018; --border:#1e1f2b; --text:#eee; --muted:#8a8d98; }
- * { box-sizing: border-box; }
- html, body { margin:0; padding:0; height:100%; }
- body { font: 15px/1.55 -apple-system, system-ui, "Segoe UI", Roboto, sans-serif; color:var(--text); background:var(--bg); min-height:100vh; overflow-x:hidden; }
- body::before {
- content:''; position:fixed; inset:0; z-index:-1; pointer-events:none;
- background:
- radial-gradient(800px 500px at 50% -100px, rgba(106,92,255,.12) 0, transparent 70%),
- radial-gradient(600px 400px at 50% 110%, rgba(214,255,61,.05) 0, transparent 70%),
- #05060a;
- }
- header.topbar {
- display:flex; align-items:center; justify-content:space-between;
- padding:18px 28px; border-bottom:1px solid var(--border);
- }
- .back {
- display:inline-flex; align-items:center; gap:6px; color:var(--muted);
- background:transparent; border:0; cursor:pointer;
- text-decoration:none; font:inherit; font-size:14px; padding:6px 10px; border-radius:8px;
- transition: background .15s, color .15s;
- }
- .back:hover { background:rgba(255,255,255,.04); color:var(--text); }
- .brand { font-weight:600; letter-spacing:-.01em; font-size:15px; }
- .brand a { color:var(--text); text-decoration:none; }
- .spacer { width:72px; }
+ <head>
+ <meta charset="utf-8" />
+ <meta name="viewport" content="width=device-width, initial-scale=1" />
+ <title>Create avatar · 3D Agent</title>
+ <link rel="icon" href="/favicon.ico" />
+ <meta
+ name="description"
+ content="Create a 3D avatar. Use our web editor, upload a GLB, or generate from a selfie."
+ />
+ <meta name="robots" content="noindex" />
+ <style>
+ :root {
+ color-scheme: dark;
+ --accent: #d6ff3d;
+ --accent-ink: #0a0a0a;
+ --bg: #05060a;
+ --panel: #0f1018;
+ --border: #1e1f2b;
+ --text: #eee;
+ --muted: #8a8d98;
+ }
+ * {
+ box-sizing: border-box;
+ }
+ html,
+ body {
+ margin: 0;
+ padding: 0;
+ height: 100%;
+ }
+ body {
+ font:
+ 15px/1.55 -apple-system,
+ system-ui,
+ 'Segoe UI',
+ Roboto,
+ sans-serif;
+ color: var(--text);
+ background: var(--bg);
+ min-height: 100vh;
+ overflow-x: hidden;
+ }
+ body::before {
+ content: '';
+ position: fixed;
+ inset: 0;
+ z-index: -1;
+ pointer-events: none;
+ background:
+ radial-gradient(
+ 800px 500px at 50% -100px,
+ rgba(106, 92, 255, 0.12) 0,
+ transparent 70%
+ ),
+ radial-gradient(
+ 600px 400px at 50% 110%,
+ rgba(214, 255, 61, 0.05) 0,
+ transparent 70%
+ ),
+ #05060a;
+ }
+ header.topbar {
+ display: flex;
+ align-items: center;
+ justify-content: space-between;
+ padding: 18px 28px;
+ border-bottom: 1px solid var(--border);
+ }
+ .back {
+ display: inline-flex;
+ align-items: center;
+ gap: 6px;
+ color: var(--muted);
+ background: transparent;
+ border: 0;
+ cursor: pointer;
+ text-decoration: none;
+ font: inherit;
+ font-size: 14px;
+ padding: 6px 10px;
+ border-radius: 8px;
+ transition:
+ background 0.15s,
+ color 0.15s;
+ }
+ .back:hover {
+ background: rgba(255, 255, 255, 0.04);
+ color: var(--text);
+ }
+ .brand {
+ font-weight: 600;
+ letter-spacing: -0.01em;
+ font-size: 15px;
+ }
+ .brand a {
+ color: var(--text);
+ text-decoration: none;
+ }
+ .spacer {
+ width: 72px;
+ }
- main.stage { max-width:1100px; margin:0 auto; padding:48px 24px 120px; }
- .step { display:none; }
- .step.active { display:block; }
- .heading { display:flex; align-items:center; justify-content:center; gap:10px; margin:8px 0 36px; }
- .heading h1 { font-size:22px; font-weight:500; margin:0; letter-spacing:-.01em; }
- .heading svg { width:22px; height:22px; color:var(--muted); }
- .subhead { text-align:center; color:var(--muted); font-size:13px; margin:-24px 0 32px; }
+ main.stage {
+ max-width: 1100px;
+ margin: 0 auto;
+ padding: 56px 24px 80px;
+ }
- /* ── Step 1: method choice ────────────────────────────────────────── */
- .choice-grid {
- display:grid; grid-template-columns:repeat(auto-fit, minmax(280px, 1fr));
- gap:22px; max-width:820px; margin:0 auto;
- }
- .choice {
- position:relative; display:flex; flex-direction:column; justify-content:flex-end;
- aspect-ratio: 3/4; padding:24px; border-radius:22px; overflow:hidden;
- background:var(--panel); border:1px solid var(--border); cursor:pointer;
- text-align:left; color:inherit; font:inherit;
- transition: transform .18s ease, border-color .18s, box-shadow .18s;
- }
- .choice:hover { transform: translateY(-2px); border-color:#2c2d3d; box-shadow:0 12px 32px rgba(0,0,0,.4); }
- .choice:focus-visible { outline:2px solid var(--accent); outline-offset:2px; }
- .choice[disabled] { cursor:not-allowed; opacity:.45; }
- .choice[disabled]:hover { transform:none; box-shadow:none; border-color:var(--border); }
- .choice .illustration {
- position:absolute; inset:0; display:grid; place-items:center;
- background:linear-gradient(180deg, rgba(20,22,34,0) 0%, rgba(5,6,10,.6) 75%, rgba(5,6,10,.92) 100%);
- }
- .choice .illustration svg { width:60%; max-width:220px; opacity:.85; color:#cfd2e0; }
- .choice .label {
- position:relative; display:flex; align-items:flex-end; justify-content:space-between;
- gap:12px; z-index:1;
- }
- .choice .label h2 { margin:0; font-size:22px; font-weight:500; letter-spacing:-.01em; line-height:1.15; }
- .choice .arrow {
- flex:0 0 auto; width:44px; height:44px; border-radius:50%;
- background:#f5f5f5; color:#0a0a0a;
- display:grid; place-items:center;
- transition: transform .18s ease, background .18s;
- }
- .choice:hover:not([disabled]) .arrow { transform: translateX(4px); background:var(--accent); }
- .choice[data-method="upload"] .illustration {
- background:linear-gradient(180deg, rgba(20,22,34,0) 40%, rgba(5,6,10,.6) 75%, rgba(5,6,10,.92) 100%);
- }
+ .picker-heading {
+ text-align: center;
+ margin: 0 0 12px;
+ }
+ .picker-heading h1 {
+ font-size: 22px;
+ font-weight: 500;
+ margin: 0;
+ letter-spacing: -0.01em;
+ }
+ .picker-sub {
+ text-align: center;
+ color: var(--muted);
+ font-size: 13px;
+ margin: 0 0 48px;
+ }
- .unsupported {
- margin-top:16px; padding:8px 12px; border-radius:8px;
- background:rgba(255,92,92,.08); border:1px solid rgba(255,92,92,.3);
- color:#ffb3b3; font-size:12px; text-align:center; display:none;
- }
- .unsupported.show { display:block; }
+ /* ── 3-card grid ──────────────────────────────────────────────────── */
+ .card-grid {
+ display: grid;
+ grid-template-columns: repeat(3, 1fr);
+ gap: 20px;
+ max-width: 920px;
+ margin: 0 auto;
+ }
- /* ── Step 2: 3-photo capture ──────────────────────────────────────── */
- .slot-grid {
- display:grid; grid-template-columns:repeat(3, 1fr);
- gap:18px; max-width:720px; margin:0 auto 28px;
- }
- .slot {
- display:flex; flex-direction:column; align-items:center; gap:8px;
- }
- .slot-label { font-size:14px; color:var(--text); }
- .slot-frame {
- position:relative; width:100%; aspect-ratio: 3/4;
- border:1.5px dashed #3a3c4d; border-radius:14px;
- background:rgba(255,255,255,.01);
- display:grid; place-items:center; cursor:pointer; overflow:hidden;
- transition: border-color .15s, background .15s;
- }
- .slot-frame:hover, .slot-frame.drag { border-color:var(--accent); background:rgba(214,255,61,.04); }
- .slot-frame:focus-visible { outline:2px solid var(--accent); outline-offset:2px; }
- .slot-frame .plus {
- width:36px; height:36px; color:#555869;
- display:grid; place-items:center;
- }
- .slot-frame.filled { border-style:solid; border-color:#2c2d3d; cursor:default; }
- .slot-frame img.preview { width:100%; height:100%; object-fit:cover; display:block; }
- .slot-retake {
- position:absolute; top:6px; right:6px; width:28px; height:28px; border-radius:50%;
- background:rgba(10,10,12,.7); color:#fff; border:0; cursor:pointer;
- display:grid; place-items:center; backdrop-filter: blur(4px);
- }
- .slot-retake:hover { background:rgba(10,10,12,.9); }
- .slot-example {
- position:absolute; left:8px; bottom:8px; width:48px; height:60px;
- border-radius:8px; overflow:hidden; border:1.5px dashed #3a3c4d;
- background:#1a1b27; display:grid; place-items:center; font-size:10px; color:#555869;
- pointer-events:none;
- }
- .slot-frame.filled .slot-example { display:none; }
- .slot-example::after {
- content:''; position:absolute; top:-3px; right:-3px; width:8px; height:8px;
- border-radius:50%; background:var(--accent);
- }
+ .create-card {
+ position: relative;
+ display: flex;
+ flex-direction: column;
+ padding: 28px 24px 22px;
+ border-radius: 18px;
+ background: var(--panel);
+ border: 1.5px solid var(--border);
+ cursor: pointer;
+ text-align: left;
+ color: inherit;
+ font: inherit;
+ transition:
+ border-color 0.18s,
+ transform 0.18s,
+ box-shadow 0.18s;
+ }
+ .create-card:focus-visible {
+ outline: 2px solid var(--accent);
+ outline-offset: 2px;
+ }
+ .create-card:hover:not([aria-disabled='true']) {
+ transform: translateY(-2px);
+ border-color: #2c2d3d;
+ box-shadow: 0 14px 36px rgba(0, 0, 0, 0.45);
+ }
+ .create-card[aria-disabled='true'] {
+ cursor: default;
+ opacity: 0.52;
+ }
- .tips {
- max-width:720px; margin:0 auto 32px;
- padding:16px 20px; border:1px solid var(--border); border-radius:14px;
- background:rgba(15,16,24,.6);
- }
- .tips .tips-head { display:flex; align-items:center; gap:8px; font-size:13px; margin:0 0 12px; }
- .tips .tips-head strong { color:var(--accent); letter-spacing:.02em; }
- .tips .tips-head .check {
- width:16px; height:16px; border-radius:50%; background:var(--accent); color:var(--accent-ink);
- display:grid; place-items:center; flex:0 0 auto;
- }
- .tips ul {
- list-style:none; padding:0; margin:0;
- display:grid; grid-template-columns:repeat(2, 1fr); gap:10px 22px;
- font-size:12.5px; color:var(--muted);
- }
- .tips li { display:flex; gap:8px; align-items:flex-start; }
- .tips li svg { flex:0 0 auto; width:14px; height:14px; color:var(--accent); margin-top:2px; }
- .tips li strong { color:var(--text); font-weight:500; }
+ .card-icon {
+ width: 48px;
+ height: 48px;
+ border-radius: 12px;
+ background: rgba(255, 255, 255, 0.04);
+ border: 1px solid var(--border);
+ display: grid;
+ place-items: center;
+ margin-bottom: 20px;
+ flex: 0 0 auto;
+ color: #cfd2e0;
+ }
+ .card-icon svg {
+ width: 24px;
+ height: 24px;
+ }
- .selectors {
- max-width:720px; margin:0 auto 40px;
- display:flex; justify-content:center; gap:32px; flex-wrap:wrap;
- font-size:13px; color:var(--muted);
- }
- .selector-group { display:flex; align-items:center; gap:10px; }
- .seg {
- display:inline-flex; border:1px solid var(--border); border-radius:10px; overflow:hidden;
- background:rgba(15,16,24,.5);
- }
- .seg button {
- padding:6px 12px; background:transparent; color:var(--muted); border:0; cursor:pointer;
- font:inherit; font-size:13px; min-width:36px;
- display:inline-flex; align-items:center; justify-content:center; gap:4px;
- }
- .seg button[aria-pressed="true"] { background:var(--accent); color:var(--accent-ink); font-weight:600; }
- .seg button:focus-visible { outline:2px solid var(--accent); outline-offset:2px; }
+ .card-title {
+ font-size: 17px;
+ font-weight: 600;
+ margin: 0 0 8px;
+ letter-spacing: -0.01em;
+ line-height: 1.25;
+ }
+ .card-subtitle {
+ font-size: 13px;
+ color: var(--muted);
+ margin: 0;
+ line-height: 1.55;
+ flex: 1;
+ }
- .submit-bar {
- position:fixed; left:0; right:0; bottom:0;
- padding:18px 24px 22px; display:flex; justify-content:center;
- background:linear-gradient(180deg, transparent, rgba(5,6,10,.95) 40%);
- pointer-events:none;
- }
- .submit-btn {
- pointer-events:auto; min-width:260px; padding:13px 24px; border:0; border-radius:12px;
- background:#2a2b3a; color:#777; font:inherit; font-size:15px; font-weight:600;
- cursor:not-allowed; transition: background .18s, color .18s, transform .12s;
- }
- .submit-btn.ready { background:var(--accent); color:var(--accent-ink); cursor:pointer; }
- .submit-btn.ready:hover { transform: translateY(-1px); filter:brightness(1.05); }
- .submit-btn.ready:active { transform: translateY(0); }
+ .card-cta {
+ display: inline-flex;
+ align-items: center;
+ gap: 6px;
+ margin-top: 22px;
+ padding: 9px 16px;
+ border-radius: 10px;
+ background: rgba(255, 255, 255, 0.06);
+ border: 1px solid var(--border);
+ color: var(--text);
+ font: inherit;
+ font-size: 13px;
+ font-weight: 500;
+ cursor: pointer;
+ transition:
+ background 0.15s,
+ border-color 0.15s;
+ align-self: flex-start;
+ }
+ .create-card:hover:not([aria-disabled='true']) .card-cta {
+ background: var(--accent);
+ border-color: transparent;
+ color: var(--accent-ink);
+ }
+ .create-card[aria-disabled='true'] .card-cta {
+ cursor: default;
+ }
- /* ── Camera overlay ───────────────────────────────────────────────── */
- .cam-overlay {
- position:fixed; inset:0; z-index:40; background:rgba(5,6,10,.92);
- display:none; place-items:center; padding:24px;
- }
- .cam-overlay.open { display:grid; }
- .cam-modal {
- width:min(560px, 100%); background:var(--panel); border:1px solid var(--border);
- border-radius:18px; padding:20px; display:flex; flex-direction:column; gap:14px;
- }
- .cam-modal h3 { margin:0; font-size:16px; font-weight:500; text-align:center; }
- .cam-modal h3 span { color:var(--muted); margin-left:6px; font-size:13px; }
- .cam-stage {
- position:relative; width:100%; aspect-ratio: 3/4; border-radius:12px; overflow:hidden;
- background:#000;
- }
- .cam-stage video, .cam-stage canvas, .cam-stage img {
- position:absolute; inset:0; width:100%; height:100%; object-fit:cover;
- }
- .cam-stage video { transform: scaleX(-1); }
- .cam-frame-overlay {
- position:absolute; inset:0; pointer-events:none;
- background:
- radial-gradient(ellipse 60% 72% at 50% 46%, transparent 60%, rgba(5,6,10,.55) 100%);
- }
- .cam-frame-overlay::before {
- content:''; position:absolute; left:18%; right:18%; top:12%; bottom:18%;
- border:1.5px dashed rgba(255,255,255,.4); border-radius:50%;
- }
- .cam-actions { display:flex; gap:10px; justify-content:center; align-items:center; }
- .cam-btn {
- padding:10px 16px; border-radius:10px; border:1px solid var(--border);
- background:#1a1b27; color:var(--text); font:inherit; font-size:13px; cursor:pointer;
- }
- .cam-btn:hover { background:#22222e; }
- .cam-btn.primary { background:var(--accent); color:var(--accent-ink); border-color:transparent; font-weight:600; }
- .cam-btn.primary:hover { filter:brightness(1.05); }
- .cam-shutter {
- width:64px; height:64px; border-radius:50%; background:#fff; border:4px solid rgba(255,255,255,.25);
- cursor:pointer; padding:0;
- }
- .cam-shutter:hover { filter:brightness(.95); }
- .cam-error { color:#ffb3b3; font-size:12px; text-align:center; margin:0; }
+ .card-tooltip {
+ margin-top: 10px;
+ font-size: 11.5px;
+ color: var(--muted);
+ line-height: 1.5;
+ }
+ .card-tooltip a {
+ color: inherit;
+ text-decoration: underline;
+ text-underline-offset: 2px;
+ }
+ .card-tooltip a:hover {
+ color: var(--text);
+ }
- .hidden-input { display:none; }
+ .coming-soon-badge {
+ position: absolute;
+ top: 16px;
+ right: 16px;
+ padding: 3px 9px;
+ border-radius: 20px;
+ background: rgba(255, 255, 255, 0.06);
+ border: 1px solid var(--border);
+ font-size: 11px;
+ font-weight: 600;
+ letter-spacing: 0.04em;
+ color: var(--muted);
+ text-transform: uppercase;
+ }
- @media (max-width: 640px) {
- main.stage { padding:24px 16px 120px; }
- .heading h1 { font-size:18px; }
- .choice { aspect-ratio: 4/5; padding:20px; border-radius:18px; }
- .choice .label h2 { font-size:18px; }
- .slot-grid { grid-template-columns:repeat(3, 1fr); gap:10px; }
- .slot-label { font-size:12px; }
- .tips ul { grid-template-columns:1fr; }
- .submit-btn { min-width:0; width:100%; }
- }
- </style>
-</head>
-<body>
- <header class="topbar">
- <button class="back" id="back-btn" type="button" aria-label="Back">
- <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><polyline points="15 18 9 12 15 6"/></svg>
- <span>Back</span>
- </button>
- <div class="brand"><a href="/">3D Agent</a></div>
- <div class="spacer" aria-hidden="true"></div>
- </header>
+ /* ── Status toast ─────────────────────────────────────────────────── */
+ .status-toast {
+ position: fixed;
+ bottom: 32px;
+ left: 50%;
+ transform: translateX(-50%);
+ padding: 11px 20px;
+ border-radius: 12px;
+ font-size: 13px;
+ font-weight: 500;
+ border: 1px solid var(--border);
+ background: var(--panel);
+ white-space: nowrap;
+ z-index: 50;
+ display: flex;
+ align-items: center;
+ gap: 8px;
+ box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
+ }
+ .status-toast.loading {
+ color: var(--muted);
+ }
+ .status-toast.error {
+ border-color: rgba(255, 92, 92, 0.4);
+ color: #ffb3b3;
+ background: #140a0a;
+ }
+ .status-toast.success {
+ border-color: rgba(214, 255, 61, 0.3);
+ color: var(--accent);
+ }
- <main class="stage">
- <!-- Step 1: method choice -->
- <section class="step active" data-step="method">
- <div class="heading">
- <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M4 7V5a1 1 0 0 1 1-1h2"/><path d="M4 17v2a1 1 0 0 0 1 1h2"/><path d="M20 7V5a1 1 0 0 0-1-1h-2"/><path d="M20 17v2a1 1 0 0 1-1 1h-2"/><circle cx="12" cy="12" r="3"/></svg>
+ @media (max-width: 700px) {
+ main.stage {
+ padding: 32px 16px 60px;
+ }
+ .card-grid {
+ grid-template-columns: 1fr;
+ max-width: 420px;
+ }
+ }
+ </style>
+ </head>
+ <body>
+ <header class="topbar">
+ <button class="back" id="back-btn" type="button" aria-label="Go back">
+ <svg
+ width="16"
+ height="16"
+ viewBox="0 0 24 24"
+ fill="none"
+ stroke="currentColor"
+ stroke-width="2"
+ stroke-linecap="round"
+ stroke-linejoin="round"
+ aria-hidden="true"
+ >
+ <polyline points="15 18 9 12 15 6" />
+ </svg>
+ <span>Back</span>
+ </button>
+ <div class="brand"><a href="/">3D Agent</a></div>
+ <div class="spacer" aria-hidden="true"></div>
+ </header>
+
+ <main class="stage">
+ <div class="picker-heading">
<h1>Create new avatar</h1>
</div>
+ <p class="picker-sub">Choose how you want to create your 3D avatar.</p>
- <div class="choice-grid" role="group" aria-label="Choose avatar input method">
- <button type="button" class="choice" data-method="camera" aria-label="Use camera to capture selfies">
- <div class="illustration" aria-hidden="true">
- <svg viewBox="0 0 160 200" fill="none" stroke="currentColor" stroke-width="1.2" stroke-linecap="round" stroke-linejoin="round">
- <circle cx="80" cy="72" r="34" fill="rgba(255,255,255,.04)" />
- <path d="M28 180c0-28 23-46 52-46s52 18 52 46" fill="rgba(255,255,255,.04)" />
- <path d="M24 40 L24 52 M32 40 L40 40" />
- <path d="M136 40 L136 52 M128 40 L120 40" />
- <path d="M24 160 L24 148 M32 160 L40 160" />
- <path d="M136 160 L136 148 M128 160 L120 160" />
+ <div class="card-grid" role="group" aria-label="Choose avatar creation method">
+ <!-- Card 1: Default editor -->
+ <div
+ class="create-card"
+ id="card-default-editor"
+ role="button"
+ tabindex="0"
+ aria-label="Open avatar web editor"
+ >
+ <div class="card-icon" aria-hidden="true">
+ <svg
+ viewBox="0 0 24 24"
+ fill="none"
+ stroke="currentColor"
+ stroke-width="1.7"
+ stroke-linecap="round"
+ stroke-linejoin="round"
+ >
+ <circle cx="12" cy="8" r="3.5" />
+ <path d="M5 20c0-3.87 3.13-7 7-7s7 3.13 7 7" />
+ <path d="M18 3l3 3-9 9-4 1 1-4 9-9z" />
</svg>
</div>
- <div class="label">
- <h2>Use<br/>camera</h2>
- <span class="arrow" aria-hidden="true">
- <svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="5" y1="12" x2="19" y2="12"/><polyline points="12 5 19 12 12 19"/></svg>
- </span>
- </div>
- </button>
-
- <button type="button" class="choice" data-method="upload" aria-label="Upload photos from device">
- <div class="illustration" aria-hidden="true">
- <svg viewBox="0 0 160 200" fill="none" stroke="currentColor" stroke-width="1.2" stroke-linecap="round" stroke-linejoin="round">
- <rect x="28" y="52" width="60" height="88" rx="6" fill="rgba(255,255,255,.04)" transform="rotate(-8 58 96)" />
- <rect x="50" y="34" width="60" height="88" rx="6" fill="rgba(255,255,255,.06)" stroke-dasharray="4 4" />
- <rect x="72" y="52" width="60" height="88" rx="6" fill="rgba(255,255,255,.04)" transform="rotate(8 102 96)" />
+ <h2 class="card-title">Use default avatar</h2>
+ <p class="card-subtitle">
+ Edit a ready-made avatar in our web editor. No download required.
+ </p>
+ <span class="card-cta">
+ Open editor
+ <svg
+ width="13"
+ height="13"
+ viewBox="0 0 24 24"
+ fill="none"
+ stroke="currentColor"
+ stroke-width="2.2"
+ stroke-linecap="round"
+ stroke-linejoin="round"
+ aria-hidden="true"
+ >
+ <line x1="5" y1="12" x2="19" y2="12" />
+ <polyline points="12 5 19 12 12 19" />
</svg>
- </div>
- <div class="label">
- <h2>Upload<br/>from device</h2>
- <span class="arrow" aria-hidden="true">
- <svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="5" y1="12" x2="19" y2="12"/><polyline points="12 5 19 12 12 19"/></svg>
- </span>
- </div>
- </button>
- </div>
-
- <p class="unsupported" id="unsupported-msg">Camera not available on this device — use the upload option instead.</p>
- </section>
-
- <!-- Step 2: 3-photo capture -->
- <section class="step" data-step="capture">
- <div class="heading">
- <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><rect x="3" y="6" width="18" height="14" rx="2"/><path d="M8 6l2-3h4l2 3"/><path d="M12 10v6M9 13h6"/></svg>
- <h1>Upload 3 photos to create an avatar</h1>
- </div>
- <p class="subhead">Drag &amp; drop or click to choose a file (jpeg or png)</p>
-
- <div class="slot-grid" id="slot-grid">
- <div class="slot">
- <span class="slot-label">1. Frontal</span>
- <div class="slot-frame" data-slot="frontal" role="button" tabindex="0" aria-label="Add frontal photo">
- <svg class="plus" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round"><line x1="12" y1="5" x2="12" y2="19"/><line x1="5" y1="12" x2="19" y2="12"/></svg>
- <div class="slot-example" aria-hidden="true">ex</div>
- </div>
- </div>
- <div class="slot">
- <span class="slot-label">2. Left</span>
- <div class="slot-frame" data-slot="left" role="button" tabindex="0" aria-label="Add left-profile photo">
- <svg class="plus" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round"><line x1="12" y1="5" x2="12" y2="19"/><line x1="5" y1="12" x2="19" y2="12"/></svg>
- <div class="slot-example" aria-hidden="true">ex</div>
- </div>
- </div>
- <div class="slot">
- <span class="slot-label">3. Right</span>
- <div class="slot-frame" data-slot="right" role="button" tabindex="0" aria-label="Add right-profile photo">
- <svg class="plus" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round"><line x1="12" y1="5" x2="12" y2="19"/><line x1="5" y1="12" x2="19" y2="12"/></svg>
- <div class="slot-example" aria-hidden="true">ex</div>
- </div>
- </div>
- </div>
-
- <div class="tips">
- <p class="tips-head">
- <span class="check" aria-hidden="true">
- <svg width="10" height="10" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="3" stroke-linecap="round" stroke-linejoin="round"><polyline points="20 6 9 17 4 12"/></svg>
</span>
- <strong>IMPORTANT</strong>
- <span>— Best results require selfie-distance shots in good lighting.</span>
- </p>
- <ul>
- <li><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round"><line x1="3" y1="12" x2="21" y2="12"/><polyline points="8 17 3 12 8 7"/><polyline points="16 7 21 12 16 17"/></svg><span><strong>Selfie-distance</strong> — max ~0.7m from the face.</span></li>
- <li><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round"><rect x="3" y="6" width="18" height="14" rx="2"/><circle cx="12" cy="13" r="3.5"/></svg><span><strong>Same camera</strong> for all 3 photos.</span></li>
- <li><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round"><circle cx="12" cy="12" r="9"/><path d="M9 10s1-2 3-2 3 2 3 2"/><line x1="9" y1="15" x2="15" y2="15"/></svg><span><strong>No distortion</strong> — long-distance shots won&rsquo;t work.</span></li>
- <li><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round"><path d="M3 7l9-4 9 4"/><path d="M5 10v7"/><path d="M19 10v7"/></svg><span><strong>Glasses off</strong>, hair tied back.</span></li>
- <li><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round"><rect x="4" y="3" width="12" height="18" rx="1"/><line x1="8" y1="3" x2="8" y2="21"/></svg><span>Vertical images, <strong>3:4 or 9:16</strong>.</span></li>
- <li><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round"><circle cx="12" cy="12" r="4"/><line x1="12" y1="2" x2="12" y2="4"/><line x1="12" y1="20" x2="12" y2="22"/><line x1="2" y1="12" x2="4" y2="12"/><line x1="20" y1="12" x2="22" y2="12"/></svg><span><strong>Good lighting</strong> on the face.</span></li>
- </ul>
- </div>
+ </div>
- <div class="selectors">
- <div class="selector-group">
- <span>Choose body type</span>
- <div class="seg" role="group" aria-label="Body type">
- <button type="button" data-body="male" aria-pressed="true" aria-label="Male body type">
- <svg width="14" height="14" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true"><circle cx="12" cy="5" r="3"/><path d="M8 22v-7H6l2.5-6.5h7L18 15h-2v7z"/></svg>
- </button>
- <button type="button" data-body="female" aria-pressed="false" aria-label="Female body type">
- <svg width="14" height="14" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true"><circle cx="12" cy="5" r="3"/><path d="M9 22l-2-7 2-6h6l2 6-2 7z"/></svg>
- </button>
+ <!-- Card 2: Upload GLB -->
+ <div
+ class="create-card"
+ id="card-upload-glb"
+ role="button"
+ tabindex="0"
+ aria-label="Upload a GLB file"
+ >
+ <div class="card-icon" aria-hidden="true">
+ <svg
+ viewBox="0 0 24 24"
+ fill="none"
+ stroke="currentColor"
+ stroke-width="1.7"
+ stroke-linecap="round"
+ stroke-linejoin="round"
+ >
+ <polyline points="16 16 12 12 8 16" />
+ <line x1="12" y1="12" x2="12" y2="21" />
+ <path d="M20.39 18.39A5 5 0 0 0 18 9h-1.26A8 8 0 1 0 3 16.3" />
+ </svg>
</div>
+ <h2 class="card-title">Upload your own GLB</h2>
+ <p class="card-subtitle">
+ Drop a <code style="font-size: 11px; opacity: 0.7">.glb</code> file. Works
+ with any glTF 2.0 model.
+ </p>
+ <span class="card-cta">
+ Choose file
+ <svg
+ width="13"
+ height="13"
+ viewBox="0 0 24 24"
+ fill="none"
+ stroke="currentColor"
+ stroke-width="2.2"
+ stroke-linecap="round"
+ stroke-linejoin="round"
+ aria-hidden="true"
+ >
+ <line x1="5" y1="12" x2="19" y2="12" />
+ <polyline points="12 5 19 12 12 19" />
+ </svg>
+ </span>
+ <p class="card-tooltip">
+ Need a model? Try
+ <a href="https://avaturn.me" target="_blank" rel="noopener">Avaturn</a> or
+ <a href="https://www.mixamo.com" target="_blank" rel="noopener">Mixamo</a>.
+ </p>
</div>
- <div class="selector-group">
- <span>Choose avatar type</span>
- <div class="seg" role="group" aria-label="Avatar type">
- <button type="button" data-type="v1" aria-pressed="true">V1</button>
- <button type="button" data-type="v2" aria-pressed="false">V2</button>
+
+ <!-- Card 3: From selfie (disabled) -->
+ <div class="create-card" id="card-selfie" aria-disabled="true" tabindex="-1">
+ <span class="coming-soon-badge" aria-label="Coming soon">Coming Soon</span>
+ <div
+ class="card-icon"
+ aria-hidden="true"
+ style="opacity: 0.5; filter: grayscale(1)"
+ >
+ <svg
+ viewBox="0 0 24 24"
+ fill="none"
+ stroke="currentColor"
+ stroke-width="1.7"
+ stroke-linecap="round"
+ stroke-linejoin="round"
+ >
+ <path
+ d="M23 19a2 2 0 0 1-2 2H3a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h4l2-3h6l2 3h4a2 2 0 0 1 2 2z"
+ />
+ <circle cx="12" cy="13" r="4" />
+ </svg>
</div>
+ <h2 class="card-title">From a selfie</h2>
+ <p class="card-subtitle">
+ Turn a photo into a rigged 3D avatar. Powered by AI.
+ </p>
+ <span class="card-cta" aria-hidden="true">
+ Take selfie
+ <svg
+ width="13"
+ height="13"
+ viewBox="0 0 24 24"
+ fill="none"
+ stroke="currentColor"
+ stroke-width="2.2"
+ stroke-linecap="round"
+ stroke-linejoin="round"
+ aria-hidden="true"
+ >
+ <line x1="5" y1="12" x2="19" y2="12" />
+ <polyline points="12 5 19 12 12 19" />
+ </svg>
+ </span>
</div>
</div>
- </section>
- </main>
-
- <div class="submit-bar" id="submit-bar" hidden>
- <button type="button" class="submit-btn" id="submit-btn" disabled>Upload 0/3</button>
- </div>
-
- <!-- Camera overlay -->
- <div class="cam-overlay" id="cam-overlay" role="dialog" aria-modal="true" aria-labelledby="cam-title">
- <div class="cam-modal">
- <h3 id="cam-title">Capture photo <span id="cam-slot-name">Frontal</span></h3>
- <div class="cam-stage" id="cam-stage">
- <video id="cam-video" autoplay playsinline muted></video>
- <div class="cam-frame-overlay" aria-hidden="true"></div>
- </div>
- <p class="cam-error" id="cam-error" hidden></p>
- <div class="cam-actions" id="cam-actions-live">
- <button type="button" class="cam-btn" data-cam-action="cancel">Cancel</button>
- <button type="button" class="cam-shutter" data-cam-action="shoot" aria-label="Take photo"></button>
- <button type="button" class="cam-btn" data-cam-action="switch" hidden>Switch</button>
- </div>
- <div class="cam-actions" id="cam-actions-review" hidden>
- <button type="button" class="cam-btn" data-cam-action="retake">Retake</button>
- <button type="button" class="cam-btn primary" data-cam-action="use">Use photo</button>
- </div>
- </div>
- </div>
+ </main>
- <!-- One hidden file input per slot — keeps click → picker reliable across browsers. -->
- <input type="file" class="hidden-input" data-slot-input="frontal" accept="image/jpeg,image/png" />
- <input type="file" class="hidden-input" data-slot-input="left" accept="image/jpeg,image/png" />
- <input type="file" class="hidden-input" data-slot-input="right" accept="image/jpeg,image/png" />
+ <input type="file" id="glb-input" accept=".glb,model/gltf-binary" style="display: none" />
+ <div class="status-toast" id="status-toast" hidden></div>
- <script type="module" src="/src/selfie-capture.js"></script>
-</body>
+ <script type="module" src="/src/create.js"></script>
+ </body>
</html>
diff --git a/features.css b/features.css
index 1b2352bb4..82a68d316 100644
--- a/features.css
+++ b/features.css
@@ -8,754 +8,822 @@
/* ── Page shell ─────────────────────────────────────────────────────────── */
.features-page {
- overflow-y: auto;
- overflow-x: hidden;
- height: 100%;
- scroll-behavior: smooth;
+ overflow-y: auto;
+ overflow-x: hidden;
+ height: 100%;
+ scroll-behavior: smooth;
}
.features-main {
- width: 100%;
+ width: 100%;
}
/* ── Navigation ─────────────────────────────────────────────────────────── */
.features-nav {
- margin-left: auto;
- display: flex;
- gap: var(--space-lg);
- -webkit-app-region: no-drag;
+ margin-left: auto;
+ display: flex;
+ gap: var(--space-lg);
+ -webkit-app-region: no-drag;
}
.features-nav a {
- color: rgba(255, 255, 255, 0.4);
- text-decoration: none;
- font-size: var(--text-sm);
- font-weight: 400;
- letter-spacing: 0.04em;
- transition: color 0.2s ease;
+ color: rgba(255, 255, 255, 0.4);
+ text-decoration: none;
+ font-size: var(--text-sm);
+ font-weight: 400;
+ letter-spacing: 0.04em;
+ transition: color 0.2s ease;
}
.features-nav a:hover,
.features-nav a.active {
- color: #fff;
+ color: #fff;
}
/* ── Scroll reveal base ─────────────────────────────────────────────────── */
.scroll-reveal {
- opacity: 0;
- transform: translateY(24px);
- transition:
- opacity 0.7s cubic-bezier(0.16, 1, 0.3, 1),
- transform 0.7s cubic-bezier(0.16, 1, 0.3, 1);
+ opacity: 0;
+ transform: translateY(24px);
+ transition:
+ opacity 0.7s cubic-bezier(0.16, 1, 0.3, 1),
+ transform 0.7s cubic-bezier(0.16, 1, 0.3, 1);
}
.scroll-reveal.revealed {
- opacity: 1;
- transform: translateY(0);
+ opacity: 1;
+ transform: translateY(0);
}
/* ── Hero ────────────────────────────────────────────────────────────────── */
.hero {
- position: relative;
- display: grid;
- /* Stronger weight on the avatar — 1 : φ */
- grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr);
- align-items: center;
- gap: var(--space-2xl);
- min-height: 100vh;
- max-width: 1280px;
- margin: 0 auto;
- padding: calc(var(--space-2xl) + 2rem) var(--space-lg) var(--space-2xl);
- overflow: hidden;
- isolation: isolate;
+ position: relative;
+ display: grid;
+ /* Stronger weight on the avatar — 1 : φ */
+ grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr);
+ align-items: center;
+ gap: var(--space-2xl);
+ min-height: 100vh;
+ max-width: 1280px;
+ margin: 0 auto;
+ padding: calc(var(--space-2xl) + 2rem) var(--space-lg) var(--space-2xl);
+ overflow: hidden;
+ isolation: isolate;
}
/* ── Hero Background Layers ─────────────────────────────────────────────── */
.hero-bg {
- position: absolute;
- inset: 0;
- pointer-events: none;
- z-index: 0;
- overflow: hidden;
+ position: absolute;
+ inset: 0;
+ pointer-events: none;
+ z-index: 0;
+ overflow: hidden;
}
.hero-grid {
- position: absolute;
- inset: -1px;
- background-image:
- linear-gradient(to right, rgba(255, 255, 255, 0.035) 1px, transparent 1px),
- linear-gradient(to bottom, rgba(255, 255, 255, 0.035) 1px, transparent 1px);
- background-size: 64px 64px;
- mask-image: radial-gradient(ellipse at 50% 40%, #000 20%, transparent 75%);
- -webkit-mask-image: radial-gradient(ellipse at 50% 40%, #000 20%, transparent 75%);
+ position: absolute;
+ inset: -1px;
+ background-image:
+ linear-gradient(to right, rgba(255, 255, 255, 0.035) 1px, transparent 1px),
+ linear-gradient(to bottom, rgba(255, 255, 255, 0.035) 1px, transparent 1px);
+ background-size: 64px 64px;
+ mask-image: radial-gradient(ellipse at 50% 40%, #000 20%, transparent 75%);
+ -webkit-mask-image: radial-gradient(ellipse at 50% 40%, #000 20%, transparent 75%);
}
.hero-mesh {
- position: absolute;
- inset: -20%;
- background:
- radial-gradient(40% 50% at 70% 40%, rgba(255, 200, 60, 0.14) 0%, transparent 60%),
- radial-gradient(35% 45% at 25% 70%, rgba(80, 200, 255, 0.09) 0%, transparent 65%),
- radial-gradient(60% 40% at 50% 100%, rgba(120, 80, 255, 0.06) 0%, transparent 60%);
- filter: blur(40px);
- animation: heroMeshDrift 18s ease-in-out infinite alternate;
+ position: absolute;
+ inset: -20%;
+ background:
+ radial-gradient(40% 50% at 70% 40%, rgba(255, 200, 60, 0.14) 0%, transparent 60%),
+ radial-gradient(35% 45% at 25% 70%, rgba(80, 200, 255, 0.09) 0%, transparent 65%),
+ radial-gradient(60% 40% at 50% 100%, rgba(120, 80, 255, 0.06) 0%, transparent 60%);
+ filter: blur(40px);
+ animation: heroMeshDrift 18s ease-in-out infinite alternate;
}
@keyframes heroMeshDrift {
- 0% { transform: translate3d(0, 0, 0) scale(1); }
- 50% { transform: translate3d(-2%, 1.5%, 0) scale(1.05); }
- 100% { transform: translate3d(2%, -1%, 0) scale(1.02); }
+ 0% {
+ transform: translate3d(0, 0, 0) scale(1);
+ }
+ 50% {
+ transform: translate3d(-2%, 1.5%, 0) scale(1.05);
+ }
+ 100% {
+ transform: translate3d(2%, -1%, 0) scale(1.02);
+ }
}
.hero-glow {
- position: absolute;
- border-radius: 50%;
- pointer-events: none;
- filter: blur(20px);
+ position: absolute;
+ border-radius: 50%;
+ pointer-events: none;
+ filter: blur(20px);
}
.hero-glow-gold {
- width: 720px;
- height: 720px;
- background: radial-gradient(circle, rgba(255, 200, 60, 0.12) 0%, transparent 65%);
- top: 38%;
- right: -8%;
- transform: translateY(-50%);
- animation: heroBreath 6s ease-in-out infinite;
+ width: 720px;
+ height: 720px;
+ background: radial-gradient(circle, rgba(255, 200, 60, 0.12) 0%, transparent 65%);
+ top: 38%;
+ right: -8%;
+ transform: translateY(-50%);
+ animation: heroBreath 6s ease-in-out infinite;
}
.hero-glow-cyan {
- width: 420px;
- height: 420px;
- background: radial-gradient(circle, rgba(80, 220, 255, 0.08) 0%, transparent 65%);
- bottom: -10%;
- left: -4%;
- animation: heroBreathCyan 8s ease-in-out infinite;
+ width: 420px;
+ height: 420px;
+ background: radial-gradient(circle, rgba(80, 220, 255, 0.08) 0%, transparent 65%);
+ bottom: -10%;
+ left: -4%;
+ animation: heroBreathCyan 8s ease-in-out infinite;
}
@keyframes heroBreath {
- 0%, 100% { opacity: 0.85; transform: translateY(-50%) scale(1); }
- 50% { opacity: 1; transform: translateY(-50%) scale(1.06); }
+ 0%,
+ 100% {
+ opacity: 0.85;
+ transform: translateY(-50%) scale(1);
+ }
+ 50% {
+ opacity: 1;
+ transform: translateY(-50%) scale(1.06);
+ }
}
@keyframes heroBreathCyan {
- 0%, 100% { opacity: 0.7; transform: scale(1); }
- 50% { opacity: 1; transform: scale(1.08); }
+ 0%,
+ 100% {
+ opacity: 0.7;
+ transform: scale(1);
+ }
+ 50% {
+ opacity: 1;
+ transform: scale(1.08);
+ }
}
/* ── Hero Content (left column) ─────────────────────────────────────────── */
.hero-content {
- position: relative;
- z-index: 2;
- max-width: 36em;
- text-align: left;
+ position: relative;
+ z-index: 2;
+ max-width: 36em;
+ text-align: left;
}
.hero-chip {
- display: inline-flex;
- align-items: center;
- gap: var(--space-sm);
- padding: 0.382rem 0.9rem;
- background: rgba(255, 255, 255, 0.035);
- border: 1px solid rgba(255, 255, 255, 0.08);
- border-radius: 999px;
- font-family: 'JetBrains Mono', 'SF Mono', monospace;
- font-size: 0.7rem;
- color: rgba(255, 255, 255, 0.7);
- letter-spacing: 0.08em;
- text-transform: uppercase;
- margin-bottom: var(--space-lg);
- backdrop-filter: blur(12px);
- -webkit-backdrop-filter: blur(12px);
+ display: inline-flex;
+ align-items: center;
+ gap: var(--space-sm);
+ padding: 0.382rem 0.9rem;
+ background: rgba(255, 255, 255, 0.035);
+ border: 1px solid rgba(255, 255, 255, 0.08);
+ border-radius: 999px;
+ font-family: 'JetBrains Mono', 'SF Mono', monospace;
+ font-size: 0.7rem;
+ color: rgba(255, 255, 255, 0.7);
+ letter-spacing: 0.08em;
+ text-transform: uppercase;
+ margin-bottom: var(--space-lg);
+ backdrop-filter: blur(12px);
+ -webkit-backdrop-filter: blur(12px);
}
.hero-chip-dot {
- width: 6px;
- height: 6px;
- border-radius: 50%;
- background: #4ade80;
- box-shadow: 0 0 0 0 rgba(74, 222, 128, 0.6);
- animation: heroChipPulse 2.4s ease-out infinite;
+ width: 6px;
+ height: 6px;
+ border-radius: 50%;
+ background: #4ade80;
+ box-shadow: 0 0 0 0 rgba(74, 222, 128, 0.6);
+ animation: heroChipPulse 2.4s ease-out infinite;
}
@keyframes heroChipPulse {
- 0% { box-shadow: 0 0 0 0 rgba(74, 222, 128, 0.55); }
- 70% { box-shadow: 0 0 0 8px rgba(74, 222, 128, 0); }
- 100% { box-shadow: 0 0 0 0 rgba(74, 222, 128, 0); }
+ 0% {
+ box-shadow: 0 0 0 0 rgba(74, 222, 128, 0.55);
+ }
+ 70% {
+ box-shadow: 0 0 0 8px rgba(74, 222, 128, 0);
+ }
+ 100% {
+ box-shadow: 0 0 0 0 rgba(74, 222, 128, 0);
+ }
}
.hero-chip-divider {
- width: 1px;
- height: 10px;
- background: rgba(255, 255, 255, 0.15);
+ width: 1px;
+ height: 10px;
+ background: rgba(255, 255, 255, 0.15);
}
.hero-chip-spec {
- color: rgba(255, 215, 0, 0.9);
+ color: rgba(255, 215, 0, 0.9);
}
.hero-title {
- /* Display-scale — the hero's whole job is to feel big */
- font-size: clamp(2.6rem, 7.2vw, 5.4rem);
- font-weight: 600;
- color: #fff;
- line-height: 1.02;
- margin: 0 0 var(--space-lg);
- letter-spacing: -0.035em;
+ /* Display-scale — the hero's whole job is to feel big */
+ font-size: clamp(2.6rem, 7.2vw, 5.4rem);
+ font-weight: 600;
+ color: #fff;
+ line-height: 1.02;
+ margin: 0 0 var(--space-lg);
+ letter-spacing: -0.035em;
}
.hero-title em {
- font-style: normal;
- background: linear-gradient(
- 100deg,
- #ffd76a 0%,
- #ffb347 35%,
- #7df9ff 75%,
- #9d8cff 100%
- );
- background-size: 200% 100%;
- -webkit-background-clip: text;
- background-clip: text;
- color: transparent;
- animation: heroTitleShimmer 8s ease-in-out infinite;
+ font-style: normal;
+ background: linear-gradient(100deg, #ffd76a 0%, #ffb347 35%, #7df9ff 75%, #9d8cff 100%);
+ background-size: 200% 100%;
+ -webkit-background-clip: text;
+ background-clip: text;
+ color: transparent;
+ animation: heroTitleShimmer 8s ease-in-out infinite;
}
@keyframes heroTitleShimmer {
- 0%, 100% { background-position: 0% 50%; }
- 50% { background-position: 100% 50%; }
+ 0%,
+ 100% {
+ background-position: 0% 50%;
+ }
+ 50% {
+ background-position: 100% 50%;
+ }
}
.hero-subtitle {
- font-size: clamp(1.05rem, 1.35vw, 1.25rem);
- color: rgba(255, 255, 255, 0.58);
- font-weight: 300;
- line-height: 1.5;
- max-width: 32em;
- margin: 0 0 var(--space-xl);
+ font-size: clamp(1.05rem, 1.35vw, 1.25rem);
+ color: rgba(255, 255, 255, 0.58);
+ font-weight: 300;
+ line-height: 1.5;
+ max-width: 32em;
+ margin: 0 0 var(--space-xl);
}
.hero-cta {
- display: flex;
- gap: var(--space-md);
- justify-content: flex-start;
- flex-wrap: wrap;
- margin-bottom: var(--space-xl);
+ display: flex;
+ gap: var(--space-md);
+ justify-content: flex-start;
+ flex-wrap: wrap;
+ margin-bottom: var(--space-xl);
}
.btn-arrow {
- display: inline-block;
- margin-left: 0.5em;
- transition: transform 0.25s cubic-bezier(0.22, 1, 0.36, 1);
+ display: inline-block;
+ margin-left: 0.5em;
+ transition: transform 0.25s cubic-bezier(0.22, 1, 0.36, 1);
}
.btn-primary:hover .btn-arrow {
- transform: translateX(3px);
+ transform: translateX(3px);
}
.hero-proof {
- list-style: none;
- padding: 0;
- margin: 0;
- display: flex;
- flex-wrap: wrap;
- gap: var(--space-md) var(--space-lg);
- font-family: 'JetBrains Mono', monospace;
- font-size: 0.72rem;
- color: rgba(255, 255, 255, 0.35);
- letter-spacing: 0.14em;
- text-transform: uppercase;
+ list-style: none;
+ padding: 0;
+ margin: 0;
+ display: flex;
+ flex-wrap: wrap;
+ gap: var(--space-md) var(--space-lg);
+ font-family: 'JetBrains Mono', monospace;
+ font-size: 0.72rem;
+ color: rgba(255, 255, 255, 0.35);
+ letter-spacing: 0.14em;
+ text-transform: uppercase;
}
.hero-proof li {
- position: relative;
+ position: relative;
}
.hero-proof li + li::before {
- content: '';
- position: absolute;
- left: calc(var(--space-lg) * -0.5);
- top: 50%;
- width: 2px;
- height: 2px;
- border-radius: 50%;
- background: rgba(255, 255, 255, 0.25);
- transform: translateY(-50%);
+ content: '';
+ position: absolute;
+ left: calc(var(--space-lg) * -0.5);
+ top: 50%;
+ width: 2px;
+ height: 2px;
+ border-radius: 50%;
+ background: rgba(255, 255, 255, 0.25);
+ transform: translateY(-50%);
}
/* ── Hero Avatar (right column) ─────────────────────────────────────────── */
.hero-avatar {
- position: relative;
- z-index: 1;
- width: 100%;
- aspect-ratio: 1 / 1;
- max-width: 640px;
- justify-self: end;
- display: flex;
- align-items: center;
- justify-content: center;
+ position: relative;
+ z-index: 1;
+ width: 100%;
+ aspect-ratio: 1 / 1;
+ max-width: 640px;
+ justify-self: end;
+ display: flex;
+ align-items: center;
+ justify-content: center;
+}
+
+.hero-avatar-link {
+ position: relative;
+ z-index: 2;
+ display: block;
+ width: 100%;
+ height: 100%;
+ border-radius: 50%;
+ cursor: pointer;
+ text-decoration: none;
+ outline: none;
+ transition: transform 0.3s ease;
+}
+
+.hero-avatar-link:hover {
+ transform: scale(1.02);
+}
+
+.hero-avatar-link:focus-visible {
+ box-shadow: 0 0 0 2px rgba(255, 215, 0, 0.55);
}
.hero-avatar-viewer {
- width: 100%;
- height: 100%;
- background: transparent;
- --poster-color: transparent;
- border-radius: 50%;
- outline: none;
- position: relative;
- z-index: 2;
+ width: 100%;
+ height: 100%;
+ background: transparent;
+ --poster-color: transparent;
+ border-radius: 50%;
+ outline: none;
+ position: relative;
+ z-index: 2;
+ pointer-events: none;
}
.hero-avatar-ring {
- position: absolute;
- inset: 4%;
- border-radius: 50%;
- background:
- conic-gradient(
- from 140deg,
- rgba(255, 200, 60, 0.0) 0deg,
- rgba(255, 200, 60, 0.25) 60deg,
- rgba(125, 249, 255, 0.18) 180deg,
- rgba(157, 140, 255, 0.12) 260deg,
- rgba(255, 200, 60, 0.0) 360deg
- );
- filter: blur(1px);
- opacity: 0.7;
- animation: heroRingSpin 28s linear infinite;
- mask: radial-gradient(circle, transparent 58%, #000 59%, #000 63%, transparent 64%);
- -webkit-mask: radial-gradient(circle, transparent 58%, #000 59%, #000 63%, transparent 64%);
- pointer-events: none;
- z-index: 1;
+ position: absolute;
+ inset: 4%;
+ border-radius: 50%;
+ background: conic-gradient(
+ from 140deg,
+ rgba(255, 200, 60, 0) 0deg,
+ rgba(255, 200, 60, 0.25) 60deg,
+ rgba(125, 249, 255, 0.18) 180deg,
+ rgba(157, 140, 255, 0.12) 260deg,
+ rgba(255, 200, 60, 0) 360deg
+ );
+ filter: blur(1px);
+ opacity: 0.7;
+ animation: heroRingSpin 28s linear infinite;
+ mask: radial-gradient(circle, transparent 58%, #000 59%, #000 63%, transparent 64%);
+ -webkit-mask: radial-gradient(circle, transparent 58%, #000 59%, #000 63%, transparent 64%);
+ pointer-events: none;
+ z-index: 1;
}
@keyframes heroRingSpin {
- to { transform: rotate(360deg); }
+ to {
+ transform: rotate(360deg);
+ }
}
.hero-avatar-pulse {
- position: absolute;
- inset: 8%;
- border-radius: 50%;
- background:
- radial-gradient(circle at 50% 50%, rgba(255, 200, 60, 0.14) 0%, transparent 60%),
- radial-gradient(circle at 40% 70%, rgba(125, 249, 255, 0.08) 0%, transparent 55%);
- box-shadow:
- inset 0 1px 0 rgba(255, 255, 255, 0.05),
- 0 40px 120px -20px rgba(255, 200, 60, 0.18);
- animation: heroBreath 5s ease-in-out infinite;
- pointer-events: none;
- z-index: 0;
+ position: absolute;
+ inset: 8%;
+ border-radius: 50%;
+ background:
+ radial-gradient(circle at 50% 50%, rgba(255, 200, 60, 0.14) 0%, transparent 60%),
+ radial-gradient(circle at 40% 70%, rgba(125, 249, 255, 0.08) 0%, transparent 55%);
+ box-shadow:
+ inset 0 1px 0 rgba(255, 255, 255, 0.05),
+ 0 40px 120px -20px rgba(255, 200, 60, 0.18);
+ animation: heroBreath 5s ease-in-out infinite;
+ pointer-events: none;
+ z-index: 0;
}
.hero-avatar-tag {
- position: absolute;
- bottom: 8%;
- right: 0;
- display: inline-flex;
- align-items: baseline;
- gap: 0.5em;
- padding: 0.5rem 0.85rem;
- background: rgba(10, 10, 14, 0.7);
- border: 1px solid rgba(255, 255, 255, 0.08);
- border-radius: var(--radius-lg);
- font-family: 'JetBrains Mono', monospace;
- font-size: 0.7rem;
- color: rgba(255, 255, 255, 0.8);
- backdrop-filter: blur(12px);
- -webkit-backdrop-filter: blur(12px);
- z-index: 3;
- box-shadow: 0 8px 24px -8px rgba(0, 0, 0, 0.6);
+ position: absolute;
+ bottom: 8%;
+ right: 0;
+ display: inline-flex;
+ align-items: baseline;
+ gap: 0.5em;
+ padding: 0.5rem 0.85rem;
+ background: rgba(10, 10, 14, 0.7);
+ border: 1px solid rgba(255, 255, 255, 0.08);
+ border-radius: var(--radius-lg);
+ font-family: 'JetBrains Mono', monospace;
+ font-size: 0.7rem;
+ color: rgba(255, 255, 255, 0.8);
+ backdrop-filter: blur(12px);
+ -webkit-backdrop-filter: blur(12px);
+ z-index: 3;
+ box-shadow: 0 8px 24px -8px rgba(0, 0, 0, 0.6);
}
.hero-avatar-tag-label {
- color: rgba(255, 215, 0, 0.7);
- letter-spacing: 0.08em;
- text-transform: uppercase;
- font-size: 0.6rem;
+ color: rgba(255, 215, 0, 0.7);
+ letter-spacing: 0.08em;
+ text-transform: uppercase;
+ font-size: 0.6rem;
}
.hero-avatar-tag-value {
- color: #fff;
- letter-spacing: 0.02em;
+ color: #fff;
+ letter-spacing: 0.02em;
}
/* ── Scroll hint ─────────────────────────────────────────────────────────── */
.hero-scroll-hint {
- position: absolute;
- bottom: var(--space-lg);
- left: 50%;
- transform: translateX(-50%);
- display: flex;
- flex-direction: column;
- align-items: center;
- gap: 0.5rem;
- font-family: 'JetBrains Mono', monospace;
- font-size: 0.6rem;
- color: rgba(255, 255, 255, 0.25);
- letter-spacing: 0.25em;
- text-transform: uppercase;
- z-index: 2;
- pointer-events: none;
+ position: absolute;
+ bottom: var(--space-lg);
+ left: 50%;
+ transform: translateX(-50%);
+ display: flex;
+ flex-direction: column;
+ align-items: center;
+ gap: 0.5rem;
+ font-family: 'JetBrains Mono', monospace;
+ font-size: 0.6rem;
+ color: rgba(255, 255, 255, 0.25);
+ letter-spacing: 0.25em;
+ text-transform: uppercase;
+ z-index: 2;
+ pointer-events: none;
}
.hero-scroll-line {
- width: 1px;
- height: 32px;
- background: linear-gradient(to bottom, rgba(255, 255, 255, 0.3), transparent);
- animation: heroScrollLine 2.2s ease-in-out infinite;
- transform-origin: top;
+ width: 1px;
+ height: 32px;
+ background: linear-gradient(to bottom, rgba(255, 255, 255, 0.3), transparent);
+ animation: heroScrollLine 2.2s ease-in-out infinite;
+ transform-origin: top;
}
@keyframes heroScrollLine {
- 0% { transform: scaleY(0); opacity: 0; }
- 40% { opacity: 1; }
- 100% { transform: scaleY(1); opacity: 0; }
+ 0% {
+ transform: scaleY(0);
+ opacity: 0;
+ }
+ 40% {
+ opacity: 1;
+ }
+ 100% {
+ transform: scaleY(1);
+ opacity: 0;
+ }
}
@media (prefers-reduced-motion: reduce) {
- .hero-mesh,
- .hero-glow,
- .hero-avatar-ring,
- .hero-avatar-pulse,
- .hero-chip-dot,
- .hero-title em,
- .hero-scroll-line {
- animation: none !important;
- }
+ .hero-mesh,
+ .hero-glow,
+ .hero-avatar-ring,
+ .hero-avatar-pulse,
+ .hero-chip-dot,
+ .hero-title em,
+ .hero-scroll-line {
+ animation: none !important;
+ }
}
/* ── Buttons ─────────────────────────────────────────────────────────────── */
.btn-primary {
- display: inline-block;
- padding: var(--space-sm) var(--space-xl);
- background: #fff;
- color: #000;
- font-size: var(--text-sm);
- font-weight: 500;
- border-radius: var(--radius-lg);
- text-decoration: none;
- letter-spacing: 0.02em;
- transition: all 0.25s ease;
+ display: inline-block;
+ padding: var(--space-sm) var(--space-xl);
+ background: #fff;
+ color: #000;
+ font-size: var(--text-sm);
+ font-weight: 500;
+ border-radius: var(--radius-lg);
+ text-decoration: none;
+ letter-spacing: 0.02em;
+ transition: all 0.25s ease;
}
.btn-primary:hover {
- background: rgba(255, 255, 255, 0.9);
- transform: translateY(-1px);
- box-shadow: 0 4px 20px rgba(255, 255, 255, 0.15);
+ background: rgba(255, 255, 255, 0.9);
+ transform: translateY(-1px);
+ box-shadow: 0 4px 20px rgba(255, 255, 255, 0.15);
}
.btn-ghost {
- display: inline-block;
- padding: var(--space-sm) var(--space-xl);
- color: rgba(255, 255, 255, 0.5);
- font-size: var(--text-sm);
- font-weight: 400;
- text-decoration: none;
- letter-spacing: 0.02em;
- border: 1px solid rgba(255, 255, 255, 0.1);
- border-radius: var(--radius-lg);
- transition: all 0.25s ease;
+ display: inline-block;
+ padding: var(--space-sm) var(--space-xl);
+ color: rgba(255, 255, 255, 0.5);
+ font-size: var(--text-sm);
+ font-weight: 400;
+ text-decoration: none;
+ letter-spacing: 0.02em;
+ border: 1px solid rgba(255, 255, 255, 0.1);
+ border-radius: var(--radius-lg);
+ transition: all 0.25s ease;
}
.btn-ghost:hover {
- color: #fff;
- border-color: rgba(255, 255, 255, 0.3);
- background: rgba(255, 255, 255, 0.05);
+ color: #fff;
+ border-color: rgba(255, 255, 255, 0.3);
+ background: rgba(255, 255, 255, 0.05);
}
/* ── Sections ────────────────────────────────────────────────────────────── */
.section {
- padding: var(--space-2xl) var(--space-lg);
- max-width: 1080px;
- margin: 0 auto;
+ padding: var(--space-2xl) var(--space-lg);
+ max-width: 1080px;
+ margin: 0 auto;
}
.section-dark {
- max-width: none;
- background: rgba(255, 255, 255, 0.02);
- border-top: 1px solid rgba(255, 255, 255, 0.04);
- border-bottom: 1px solid rgba(255, 255, 255, 0.04);
+ max-width: none;
+ background: rgba(255, 255, 255, 0.02);
+ border-top: 1px solid rgba(255, 255, 255, 0.04);
+ border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}
.section-dark > * {
- max-width: 1080px;
- margin-left: auto;
- margin-right: auto;
+ max-width: 1080px;
+ margin-left: auto;
+ margin-right: auto;
}
.section-label {
- font-family: 'JetBrains Mono', 'SF Mono', monospace;
- font-size: var(--text-xs);
- color: rgba(255, 215, 0, 0.6);
- letter-spacing: 0.15em;
- text-transform: uppercase;
- margin: 0 0 var(--space-xl);
- text-align: center;
+ font-family: 'JetBrains Mono', 'SF Mono', monospace;
+ font-size: var(--text-xs);
+ color: rgba(255, 215, 0, 0.6);
+ letter-spacing: 0.15em;
+ text-transform: uppercase;
+ margin: 0 0 var(--space-xl);
+ text-align: center;
}
.section-desc {
- font-size: var(--text-lg);
- color: rgba(255, 255, 255, 0.45);
- font-weight: 300;
- text-align: center;
- max-width: 38.2em;
- margin: 0 auto var(--space-xl);
- line-height: var(--leading-normal);
+ font-size: var(--text-lg);
+ color: rgba(255, 255, 255, 0.45);
+ font-weight: 300;
+ text-align: center;
+ max-width: 38.2em;
+ margin: 0 auto var(--space-xl);
+ line-height: var(--leading-normal);
}
/* ── Steps (How It Works) ────────────────────────────────────────────────── */
.steps {
- display: grid;
- grid-template-columns: repeat(3, 1fr);
- gap: var(--space-xl);
+ display: grid;
+ grid-template-columns: repeat(3, 1fr);
+ gap: var(--space-xl);
}
.step {
- padding: var(--space-lg);
- border: 1px solid rgba(255, 255, 255, 0.06);
- border-radius: var(--radius-lg);
- transition: border-color 0.3s ease;
+ padding: var(--space-lg);
+ border: 1px solid rgba(255, 255, 255, 0.06);
+ border-radius: var(--radius-lg);
+ transition: border-color 0.3s ease;
}
.step:hover {
- border-color: rgba(255, 255, 255, 0.12);
+ border-color: rgba(255, 255, 255, 0.12);
}
.step-num {
- font-family: 'JetBrains Mono', monospace;
- font-size: var(--text-2xl);
- font-weight: 600;
- color: rgba(255, 215, 0, 0.15);
- line-height: 1;
- margin-bottom: var(--space-sm);
+ font-family: 'JetBrains Mono', monospace;
+ font-size: var(--text-2xl);
+ font-weight: 600;
+ color: rgba(255, 215, 0, 0.15);
+ line-height: 1;
+ margin-bottom: var(--space-sm);
}
.step h4 {
- color: #fff;
- font-size: var(--text-lg);
- font-weight: 500;
- margin: 0 0 var(--space-sm);
+ color: #fff;
+ font-size: var(--text-lg);
+ font-weight: 500;
+ margin: 0 0 var(--space-sm);
}
.step p {
- color: rgba(255, 255, 255, 0.45);
- font-size: var(--text-sm);
- line-height: var(--leading-normal);
- margin: 0;
+ color: rgba(255, 255, 255, 0.45);
+ font-size: var(--text-sm);
+ line-height: var(--leading-normal);
+ margin: 0;
}
.step code {
- font-family: 'JetBrains Mono', monospace;
- font-size: 0.85em;
- color: rgba(255, 215, 0, 0.6);
- background: rgba(255, 215, 0, 0.06);
- padding: 0.1em 0.4em;
- border-radius: var(--radius-sm);
+ font-family: 'JetBrains Mono', monospace;
+ font-size: 0.85em;
+ color: rgba(255, 215, 0, 0.6);
+ background: rgba(255, 215, 0, 0.06);
+ padding: 0.1em 0.4em;
+ border-radius: var(--radius-sm);
}
/* ── Code Block ──────────────────────────────────────────────────────────── */
.code-block {
- background: #0a0a0a;
- border: 1px solid rgba(255, 255, 255, 0.06);
- border-radius: var(--radius-lg);
- overflow: hidden;
- max-width: 680px;
- margin: 0 auto;
+ background: #0a0a0a;
+ border: 1px solid rgba(255, 255, 255, 0.06);
+ border-radius: var(--radius-lg);
+ overflow: hidden;
+ max-width: 680px;
+ margin: 0 auto;
}
.code-header {
- display: flex;
- align-items: center;
- gap: var(--space-2xs);
- padding: var(--space-sm) var(--space-md);
- background: rgba(255, 255, 255, 0.03);
- border-bottom: 1px solid rgba(255, 255, 255, 0.04);
+ display: flex;
+ align-items: center;
+ gap: var(--space-2xs);
+ padding: var(--space-sm) var(--space-md);
+ background: rgba(255, 255, 255, 0.03);
+ border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}
.code-dot {
- width: 10px;
- height: 10px;
- border-radius: 50%;
+ width: 10px;
+ height: 10px;
+ border-radius: 50%;
}
-.code-dot.red { background: #ff5f56; }
-.code-dot.yellow { background: #ffbd2e; }
-.code-dot.green { background: #27c93f; }
+.code-dot.red {
+ background: #ff5f56;
+}
+.code-dot.yellow {
+ background: #ffbd2e;
+}
+.code-dot.green {
+ background: #27c93f;
+}
.code-filename {
- margin-left: var(--space-sm);
- font-family: 'JetBrains Mono', monospace;
- font-size: var(--text-xs);
- color: rgba(255, 255, 255, 0.35);
+ margin-left: var(--space-sm);
+ font-family: 'JetBrains Mono', monospace;
+ font-size: var(--text-xs);
+ color: rgba(255, 255, 255, 0.35);
}
.code-body {
- margin: 0;
- padding: var(--space-lg);
- overflow-x: auto;
- font-family: 'JetBrains Mono', monospace;
- font-size: 0.8rem;
- line-height: var(--leading-loose);
- color: rgba(255, 255, 255, 0.6);
+ margin: 0;
+ padding: var(--space-lg);
+ overflow-x: auto;
+ font-family: 'JetBrains Mono', monospace;
+ font-size: 0.8rem;
+ line-height: var(--leading-loose);
+ color: rgba(255, 255, 255, 0.6);
}
-.json-key { color: #7ec8e3; }
-.json-str { color: #a8cc8c; }
-.json-bool { color: #e88388; }
+.json-key {
+ color: #7ec8e3;
+}
+.json-str {
+ color: #a8cc8c;
+}
+.json-bool {
+ color: #e88388;
+}
/* ── Registry Cards ──────────────────────────────────────────────────────── */
.registry-grid {
- display: grid;
- grid-template-columns: repeat(3, 1fr);
- gap: var(--space-lg);
+ display: grid;
+ grid-template-columns: repeat(3, 1fr);
+ gap: var(--space-lg);
}
.registry-card {
- padding: var(--space-lg);
- background: rgba(255, 255, 255, 0.02);
- border: 1px solid rgba(255, 255, 255, 0.06);
- border-radius: var(--radius-lg);
- transition: all 0.3s ease;
+ padding: var(--space-lg);
+ background: rgba(255, 255, 255, 0.02);
+ border: 1px solid rgba(255, 255, 255, 0.06);
+ border-radius: var(--radius-lg);
+ transition: all 0.3s ease;
}
.registry-card:hover {
- background: rgba(255, 255, 255, 0.04);
- border-color: rgba(255, 255, 255, 0.12);
- transform: translateY(-2px);
+ background: rgba(255, 255, 255, 0.04);
+ border-color: rgba(255, 255, 255, 0.12);
+ transform: translateY(-2px);
}
.registry-icon {
- font-size: 2rem;
- margin-bottom: var(--space-sm);
+ font-size: 2rem;
+ margin-bottom: var(--space-sm);
}
.registry-card h4 {
- color: #fff;
- font-size: var(--text-base);
- font-weight: 500;
- margin: 0 0 var(--space-xs);
+ color: #fff;
+ font-size: var(--text-base);
+ font-weight: 500;
+ margin: 0 0 var(--space-xs);
}
.registry-card p {
- color: rgba(255, 255, 255, 0.4);
- font-size: var(--text-sm);
- line-height: var(--leading-normal);
- margin: 0 0 var(--space-md);
+ color: rgba(255, 255, 255, 0.4);
+ font-size: var(--text-sm);
+ line-height: var(--leading-normal);
+ margin: 0 0 var(--space-md);
}
.registry-card code {
- font-family: 'JetBrains Mono', monospace;
- font-size: 0.8em;
- color: rgba(255, 215, 0, 0.6);
- background: rgba(255, 215, 0, 0.06);
- padding: 0.1em 0.4em;
- border-radius: var(--radius-sm);
+ font-family: 'JetBrains Mono', monospace;
+ font-size: 0.8em;
+ color: rgba(255, 215, 0, 0.6);
+ background: rgba(255, 215, 0, 0.06);
+ padding: 0.1em 0.4em;
+ border-radius: var(--radius-sm);
}
.registry-details {
- list-style: none;
- padding: 0;
- margin: 0;
- display: flex;
- flex-direction: column;
- gap: var(--space-2xs);
+ list-style: none;
+ padding: 0;
+ margin: 0;
+ display: flex;
+ flex-direction: column;
+ gap: var(--space-2xs);
}
/* ── Integration Grid ────────────────────────────────────────────────────── */
.integration-grid {
- display: grid;
- grid-template-columns: repeat(2, 1fr);
- gap: var(--space-lg);
- max-width: 1080px;
- margin: 0 auto;
+ display: grid;
+ grid-template-columns: repeat(2, 1fr);
+ gap: var(--space-lg);
+ max-width: 1080px;
+ margin: 0 auto;
}
.integration-item {
- padding: var(--space-lg);
- border-left: 2px solid rgba(255, 215, 0, 0.15);
+ padding: var(--space-lg);
+ border-left: 2px solid rgba(255, 215, 0, 0.15);
}
.integration-item h4 {
- color: #fff;
- font-size: var(--text-base);
- font-weight: 500;
- margin: 0 0 var(--space-xs);
+ color: #fff;
+ font-size: var(--text-base);
+ font-weight: 500;
+ margin: 0 0 var(--space-xs);
}
.integration-item p {
- color: rgba(255, 255, 255, 0.4);
- font-size: var(--text-sm);
- line-height: var(--leading-normal);
- margin: 0;
+ color: rgba(255, 255, 255, 0.4);
+ font-size: var(--text-sm);
+ line-height: var(--leading-normal);
+ margin: 0;
}
.integration-item code {
- font-family: 'JetBrains Mono', monospace;
- font-size: 0.85em;
- color: rgba(255, 215, 0, 0.6);
- background: rgba(255, 215, 0, 0.06);
- padding: 0.1em 0.4em;
- border-radius: var(--radius-sm);
+ font-family: 'JetBrains Mono', monospace;
+ font-size: 0.85em;
+ color: rgba(255, 215, 0, 0.6);
+ background: rgba(255, 215, 0, 0.06);
+ padding: 0.1em 0.4em;
+ border-radius: var(--radius-sm);
}
/* ── CTA Section ─────────────────────────────────────────────────────────── */
.cta-section {
- text-align: center;
- padding: var(--space-2xl) var(--space-lg);
+ text-align: center;
+ padding: var(--space-2xl) var(--space-lg);
}
.cta-content h3 {
- color: #fff;
- font-size: var(--text-xl);
- font-weight: 500;
- margin: 0 0 var(--space-sm);
+ color: #fff;
+ font-size: var(--text-xl);
+ font-weight: 500;
+ margin: 0 0 var(--space-sm);
}
.cta-content p {
- color: rgba(255, 255, 255, 0.4);
- font-size: var(--text-base);
- margin: 0 0 var(--space-lg);
+ color: rgba(255, 255, 255, 0.4);
+ font-size: var(--text-base);
+ margin: 0 0 var(--space-lg);
}
/* ── Footer ──────────────────────────────────────────────────────────────── */
.features-footer {
- position: static;
- text-align: center;
- padding: var(--space-xl) var(--space-lg);
- border-top: 1px solid rgba(255, 255, 255, 0.04);
- pointer-events: all;
+ position: static;
+ text-align: center;
+ padding: var(--space-xl) var(--space-lg);
+ border-top: 1px solid rgba(255, 255, 255, 0.04);
+ pointer-events: all;
}
.features-footer p {
- color: rgba(255, 255, 255, 0.25);
- font-size: var(--text-xs);
- font-family: 'JetBrains Mono', monospace;
- margin: 0;
+ color: rgba(255, 255, 255, 0.25);
+ font-size: var(--text-xs);
+ font-family: 'JetBrains Mono', monospace;
+ margin: 0;
}
.features-footer a {
- color: rgba(255, 255, 255, 0.35);
- text-decoration: none;
- transition: color 0.2s ease;
+ color: rgba(255, 255, 255, 0.35);
+ text-decoration: none;
+ transition: color 0.2s ease;
}
.features-footer a:hover {
- color: #fff;
+ color: #fff;
}
/* ── Pretext overlay ─────────────────────────────────────────────────────── */
@@ -768,28 +836,28 @@
* stays visible.
*/
.hero-subtitle-pretext {
- position: absolute;
- font-size: clamp(1.05rem, 1.35vw, 1.25rem);
- color: rgba(255, 255, 255, 0.58);
- font-weight: 300;
- line-height: 1.5;
- pointer-events: none;
- display: none;
+ position: absolute;
+ font-size: clamp(1.05rem, 1.35vw, 1.25rem);
+ color: rgba(255, 255, 255, 0.58);
+ font-weight: 300;
+ line-height: 1.5;
+ pointer-events: none;
+ display: none;
}
.pretext-active .hero-subtitle-pretext {
- display: block;
+ display: block;
}
.hero-subtitle-pretext-line {
- position: absolute;
- left: 0;
- white-space: pre;
+ position: absolute;
+ left: 0;
+ white-space: pre;
}
/* Reserve the original subtitle's space so the CTA stack doesn't jump. */
.pretext-active .hero-subtitle {
- visibility: hidden;
+ visibility: hidden;
}
/* ── Dragon mode (?pretext=4) ────────────────────────────────────────────── */
@@ -801,27 +869,27 @@
* more room to reflow the subtitle around the moving silhouette.
*/
.hero--dragon {
- position: relative;
+ position: relative;
}
.hero--dragon .hero-content {
- grid-column: 1 / -1;
- max-width: none;
- z-index: 2;
+ grid-column: 1 / -1;
+ max-width: none;
+ z-index: 2;
}
.hero--dragon .hero-subtitle-pretext {
- max-width: none;
+ max-width: none;
}
.hero--dragon .hero-avatar {
- position: absolute;
- top: 0;
- right: 0;
- z-index: 3;
- justify-self: auto;
- transform: translate3d(0, 0, 0);
- transition: none;
+ position: absolute;
+ top: 0;
+ right: 0;
+ z-index: 3;
+ justify-self: auto;
+ transform: translate3d(0, 0, 0);
+ transition: none;
}
/* The ring/pulse/tag decorations read as static UI chrome — hide them while
@@ -829,117 +897,117 @@
.hero--dragon .hero-avatar-ring,
.hero--dragon .hero-avatar-pulse,
.hero--dragon .hero-avatar-tag {
- opacity: 0;
- transition: opacity 0.4s ease;
+ opacity: 0;
+ transition: opacity 0.4s ease;
}
/* ── Responsive ──────────────────────────────────────────────────────────── */
/* Tablet — keep two columns but tighten the split */
@media screen and (max-width: 1024px) {
- .hero {
- grid-template-columns: 1fr 1fr;
- gap: var(--space-xl);
- }
+ .hero {
+ grid-template-columns: 1fr 1fr;
+ gap: var(--space-xl);
+ }
- .hero-avatar {
- max-width: 420px;
- }
+ .hero-avatar {
+ max-width: 420px;
+ }
}
@media screen and (max-width: 768px) {
- /* Pretext overlay disables itself below this breakpoint; bring the
+ /* Pretext overlay disables itself below this breakpoint; bring the
original subtitle back in case .pretext-active was set before the
resize into mobile. */
- .pretext-active .hero-subtitle {
- visibility: visible;
- }
-
- .hero {
- grid-template-columns: 1fr;
- gap: var(--space-xl);
- min-height: auto;
- padding: calc(var(--space-xl) + 1rem) var(--space-md) var(--space-xl);
- text-align: center;
- }
-
- .hero-content {
- max-width: 100%;
- text-align: center;
- order: 2;
- }
-
- .hero-avatar {
- order: 1;
- max-width: 360px;
- margin: 0 auto;
- justify-self: center;
- }
-
- .hero-avatar-tag {
- right: 4%;
- bottom: 4%;
- }
-
- .hero-cta {
- justify-content: center;
- }
-
- .hero-proof {
- justify-content: center;
- }
-
- .hero-glow-gold {
- right: 50%;
- top: 30%;
- transform: translate(50%, -50%);
- width: 480px;
- height: 480px;
- }
-
- .hero-glow-cyan {
- left: 50%;
- transform: translateX(-50%);
- width: 320px;
- height: 320px;
- }
-
- .hero-scroll-hint {
- display: none;
- }
-
- .hero-title {
- font-size: clamp(2.2rem, 10vw, 3.2rem);
- }
-
- .steps {
- grid-template-columns: 1fr;
- gap: var(--space-md);
- }
-
- .registry-grid {
- grid-template-columns: 1fr;
- gap: var(--space-md);
- }
-
- .integration-grid {
- grid-template-columns: 1fr;
- }
-
- .section {
- padding: var(--space-xl) var(--space-md);
- }
-
- .section-dark {
- padding: var(--space-xl) var(--space-md);
- }
-
- .code-body {
- font-size: 0.7rem;
- padding: var(--space-md);
- }
-
- .features-nav {
- gap: var(--space-md);
- }
+ .pretext-active .hero-subtitle {
+ visibility: visible;
+ }
+
+ .hero {
+ grid-template-columns: 1fr;
+ gap: var(--space-xl);
+ min-height: auto;
+ padding: calc(var(--space-xl) + 1rem) var(--space-md) var(--space-xl);
+ text-align: center;
+ }
+
+ .hero-content {
+ max-width: 100%;
+ text-align: center;
+ order: 2;
+ }
+
+ .hero-avatar {
+ order: 1;
+ max-width: 360px;
+ margin: 0 auto;
+ justify-self: center;
+ }
+
+ .hero-avatar-tag {
+ right: 4%;
+ bottom: 4%;
+ }
+
+ .hero-cta {
+ justify-content: center;
+ }
+
+ .hero-proof {
+ justify-content: center;
+ }
+
+ .hero-glow-gold {
+ right: 50%;
+ top: 30%;
+ transform: translate(50%, -50%);
+ width: 480px;
+ height: 480px;
+ }
+
+ .hero-glow-cyan {
+ left: 50%;
+ transform: translateX(-50%);
+ width: 320px;
+ height: 320px;
+ }
+
+ .hero-scroll-hint {
+ display: none;
+ }
+
+ .hero-title {
+ font-size: clamp(2.2rem, 10vw, 3.2rem);
+ }
+
+ .steps {
+ grid-template-columns: 1fr;
+ gap: var(--space-md);
+ }
+
+ .registry-grid {
+ grid-template-columns: 1fr;
+ gap: var(--space-md);
+ }
+
+ .integration-grid {
+ grid-template-columns: 1fr;
+ }
+
+ .section {
+ padding: var(--space-xl) var(--space-md);
+ }
+
+ .section-dark {
+ padding: var(--space-xl) var(--space-md);
+ }
+
+ .code-body {
+ font-size: 0.7rem;
+ padding: var(--space-md);
+ }
+
+ .features-nav {
+ gap: var(--space-md);
+ }
}
diff --git a/features.html b/features.html
index b3914256b..4866aeaac 100644
--- a/features.html
+++ b/features.html
@@ -27,7 +27,7 @@
<header>
<h1><a href="/">3D Agent</a></h1>
<nav class="features-nav">
- <a href="/">Viewer</a>
+ <a href="/app">Viewer</a>
<a href="/features" class="active">Features</a>
</nav>
</header>
diff --git a/index.html b/index.html
index 8fa4a20f7..7a705bcb3 100644
--- a/index.html
+++ b/index.html
@@ -1,130 +1,872 @@
<!doctype html>
<html lang="en">
-<head>
- <meta charset="utf-8" />
- <meta http-equiv="X-UA-Compatible" content="IE=edge" />
- <title>3D Agent — AI-Powered 3D Model Viewer</title>
- <meta
- name="viewport"
- content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, viewport-fit=cover"
- />
- <meta name="author" content="nirholas" />
- <meta name="description" content="The first embodied 3D AI agent. Not a chatbot. A presence — with a body, a place, an identity, and memory." />
- <meta name="keywords" content="3D agent, AI agent, embodied AI, glTF viewer, GLB viewer, 3D model viewer, WebGL, three.js, ERC-8004, agent identity" />
- <meta name="theme-color" content="#000000" />
-
- <!-- Open Graph -->
- <meta property="og:type" content="website" />
- <meta property="og:title" content="3D Agent — The First Embodied AI Agent" />
- <meta property="og:description" content="Agents have always been imagined as present. We made that real." />
- <meta property="og:url" content="https://3dagent.vercel.app/" />
- <meta property="og:site_name" content="3D Agent" />
-
- <!-- Twitter / X -->
- <meta name="twitter:card" content="summary_large_image" />
- <meta name="twitter:title" content="3D Agent — Embodied AI" />
- <meta name="twitter:description" content="The first 3D agent with a body, a place, an identity, and memory." />
- <meta name="twitter:creator" content="@nichxbt" />
-
- <link rel="canonical" href="https://3dagent.vercel.app/" />
- <link rel="shortcut icon" href="/favicon.ico" />
- <link rel="apple-touch-icon" href="/pwa-192x192.png" />
- <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;600;700&family=Space+Grotesk:wght@500;600;700&display=swap" rel="stylesheet" />
- <script defer type="module" src="src/app.js"></script>
-</head>
-<body>
- <header>
- <h1><a href="/"><span class="wordmark-dot" aria-hidden="true"></span>3D Agent</a></h1>
- <nav class="features-nav">
- <a href="/" class="active">Viewer</a>
- <a href="/features">Features</a>
- <a href="/widgets">Widgets</a>
- <a href="/#register">Register Agent</a>
- <a class="make-widget-btn" id="make-widget-btn" href="/studio" hidden title="Save the current model as an embeddable widget">
- <svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><rect x="3" y="3" width="7" height="7" rx="1"/><rect x="14" y="3" width="7" height="7" rx="1"/><rect x="3" y="14" width="7" height="7" rx="1"/><rect x="14" y="14" width="7" height="7" rx="1"/></svg>
- <span>Make this a widget</span>
- </a>
- <a href="/dashboard" class="nav-dashboard">Dashboard</a>
- <a href="/login" class="nav-sign-in" id="nav-sign-in">Sign in</a>
- </nav>
- </header>
-
- <main class="wrap">
- <!-- Agent presence panel — rendered by AgentHome -->
- <div class="agent-presence-sidebar" id="agent-presence-sidebar">
- <div id="agent-home-container"></div>
- </div>
-
- <!-- Auth gate — shown only to anonymous visitors on the main viewer -->
- <aside class="auth-gate" id="auth-gate">
- <div class="auth-gate__inner">
- <div class="auth-gate__eyebrow">
- <span class="auth-gate__lock" aria-hidden="true">◎</span>
- <span>Unlock the agent</span>
+ <head>
+ <meta charset="utf-8" />
+ <meta http-equiv="X-UA-Compatible" content="IE=edge" />
+ <title>3D Agent — Give Your AI a Body</title>
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
+ <meta name="author" content="nirholas" />
+ <meta
+ name="description"
+ content="Drop any GLB model into 3D Agent — view it, animate it, embed it anywhere, and give it a verifiable on-chain identity."
+ />
+ <meta name="theme-color" content="#000000" />
+
+ <meta property="og:type" content="website" />
+ <meta property="og:title" content="3D Agent — Give Your AI a Body" />
+ <meta
+ property="og:description"
+ content="Drop any GLB model into 3D Agent — view it, animate it, embed it anywhere."
+ />
+ <meta property="og:url" content="https://3dagent.vercel.app/" />
+
+ <link rel="canonical" href="https://3dagent.vercel.app/" />
+ <link rel="shortcut icon" href="/favicon.ico" />
+ <link rel="apple-touch-icon" href="/pwa-192x192.png" />
+ <link rel="preconnect" href="https://fonts.googleapis.com" />
+ <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
+ <link rel="stylesheet" href="/style.css" />
+ <link rel="stylesheet" href="/features.css" />
+ <link
+ href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600&family=JetBrains+Mono:wght@400&display=swap"
+ rel="stylesheet"
+ />
+ <script
+ type="module"
+ src="https://ajax.googleapis.com/ajax/libs/model-viewer/4.0.0/model-viewer.min.js"
+ ></script>
+
+ <style>
+ /* ── Journey Steps ── */
+
+ .journey {
+ padding: var(--space-2xl) 0 0;
+ }
+
+ .journey-header {
+ text-align: center;
+ padding: 0 var(--space-lg) var(--space-2xl);
+ max-width: 720px;
+ margin: 0 auto;
+ }
+
+ .journey-overline {
+ font-family: 'JetBrains Mono', monospace;
+ font-size: var(--text-xs);
+ color: rgba(255, 215, 0, 0.6);
+ letter-spacing: 0.15em;
+ text-transform: uppercase;
+ margin: 0 0 var(--space-md);
+ }
+
+ .journey-title {
+ font-size: clamp(2rem, 4vw, 3rem);
+ font-weight: 600;
+ color: #fff;
+ line-height: 1.08;
+ letter-spacing: -0.03em;
+ margin: 0 0 var(--space-md);
+ }
+
+ .journey-sub {
+ font-size: var(--text-base);
+ color: rgba(255, 255, 255, 0.38);
+ font-weight: 300;
+ margin: 0;
+ }
+
+ /* Individual step row */
+
+ .journey-step {
+ display: grid;
+ grid-template-columns: 1fr 1fr;
+ align-items: center;
+ gap: var(--space-2xl);
+ max-width: 1080px;
+ margin: 0 auto;
+ padding: var(--space-2xl) var(--space-lg);
+ border-top: 1px solid rgba(255, 255, 255, 0.05);
+ }
+
+ .journey-step:last-child {
+ border-bottom: 1px solid rgba(255, 255, 255, 0.05);
+ }
+
+ .journey-step--flip .journey-step-content {
+ order: 2;
+ }
+ .journey-step--flip .journey-step-visual {
+ order: 1;
+ }
+
+ .journey-step-num {
+ font-family: 'JetBrains Mono', monospace;
+ font-size: 0.68rem;
+ color: rgba(255, 215, 0, 0.55);
+ letter-spacing: 0.18em;
+ text-transform: uppercase;
+ margin-bottom: var(--space-md);
+ }
+
+ .journey-step-title {
+ font-size: clamp(1.5rem, 2.5vw, 2.2rem);
+ font-weight: 600;
+ color: #fff;
+ line-height: 1.1;
+ letter-spacing: -0.025em;
+ margin: 0 0 var(--space-md);
+ }
+
+ .journey-step-desc {
+ font-size: var(--text-base);
+ color: rgba(255, 255, 255, 0.42);
+ line-height: var(--leading-normal);
+ font-weight: 300;
+ margin: 0 0 var(--space-lg);
+ max-width: 30em;
+ }
+
+ .journey-step-cta {
+ display: inline-flex;
+ align-items: center;
+ gap: 0.4em;
+ font-size: var(--text-sm);
+ color: rgba(255, 215, 0, 0.75);
+ text-decoration: none;
+ letter-spacing: 0.02em;
+ transition:
+ color 0.2s ease,
+ gap 0.2s ease;
+ }
+
+ .journey-step-cta:hover {
+ color: #ffd76a;
+ gap: 0.7em;
+ }
+
+ /* Visual area */
+
+ .journey-step-visual {
+ background: rgba(255, 255, 255, 0.02);
+ border: 1px solid rgba(255, 255, 255, 0.07);
+ border-radius: 12px;
+ overflow: hidden;
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ min-height: 300px;
+ position: relative;
+ }
+
+ .journey-step-visual model-viewer {
+ width: 100%;
+ height: 340px;
+ background: transparent;
+ --poster-color: transparent;
+ }
+
+ /* Upload drop visual */
+
+ .vis-upload {
+ width: 100%;
+ padding: var(--space-xl) var(--space-lg);
+ display: flex;
+ flex-direction: column;
+ align-items: center;
+ gap: var(--space-md);
+ }
+
+ .vis-upload-zone {
+ width: 100%;
+ border: 1.5px dashed rgba(255, 255, 255, 0.12);
+ border-radius: 10px;
+ padding: var(--space-xl) var(--space-lg);
+ display: flex;
+ flex-direction: column;
+ align-items: center;
+ gap: var(--space-sm);
+ text-align: center;
+ transition: border-color 0.2s ease;
+ }
+
+ .vis-upload-icon {
+ width: 40px;
+ height: 40px;
+ border-radius: 8px;
+ background: rgba(255, 255, 255, 0.05);
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ font-size: 1.2rem;
+ }
+
+ .vis-upload-label {
+ font-size: var(--text-sm);
+ color: rgba(255, 255, 255, 0.55);
+ }
+
+ .vis-upload-sub {
+ font-size: var(--text-xs);
+ color: rgba(255, 255, 255, 0.22);
+ font-family: 'JetBrains Mono', monospace;
+ letter-spacing: 0.06em;
+ }
+
+ .vis-file-chip {
+ display: inline-flex;
+ align-items: center;
+ gap: var(--space-sm);
+ padding: 0.4rem 0.9rem;
+ background: rgba(255, 255, 255, 0.04);
+ border: 1px solid rgba(255, 255, 255, 0.08);
+ border-radius: 999px;
+ font-family: 'JetBrains Mono', monospace;
+ font-size: 0.68rem;
+ color: rgba(255, 255, 255, 0.5);
+ }
+
+ .vis-file-dot {
+ width: 6px;
+ height: 6px;
+ border-radius: 50%;
+ background: #4ade80;
+ }
+
+ /* Animation picker visual */
+
+ .vis-anim {
+ width: 100%;
+ padding: var(--space-md);
+ }
+
+ .vis-anim-header {
+ font-family: 'JetBrains Mono', monospace;
+ font-size: 0.65rem;
+ color: rgba(255, 215, 0, 0.5);
+ letter-spacing: 0.12em;
+ text-transform: uppercase;
+ padding: var(--space-xs) var(--space-sm);
+ margin-bottom: var(--space-xs);
+ }
+
+ .vis-anim-row {
+ display: flex;
+ align-items: center;
+ gap: var(--space-sm);
+ padding: 0.6rem var(--space-sm);
+ border-radius: 6px;
+ font-size: var(--text-sm);
+ color: rgba(255, 255, 255, 0.45);
+ cursor: pointer;
+ transition:
+ background 0.15s ease,
+ color 0.15s ease;
+ }
+
+ .vis-anim-row.active {
+ background: rgba(255, 255, 255, 0.05);
+ color: #fff;
+ }
+
+ .vis-anim-play {
+ width: 20px;
+ height: 20px;
+ border-radius: 50%;
+ background: rgba(255, 255, 255, 0.06);
+ border: 1px solid rgba(255, 255, 255, 0.1);
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ flex-shrink: 0;
+ font-size: 0.5rem;
+ }
+
+ .vis-anim-row.active .vis-anim-play {
+ background: rgba(255, 215, 0, 0.15);
+ border-color: rgba(255, 215, 0, 0.3);
+ color: #ffd76a;
+ }
+
+ .vis-anim-dur {
+ margin-left: auto;
+ font-family: 'JetBrains Mono', monospace;
+ font-size: 0.62rem;
+ color: rgba(255, 255, 255, 0.2);
+ }
+
+ /* Identity card visual */
+
+ .vis-identity {
+ padding: var(--space-lg);
+ width: 100%;
+ }
+
+ .vis-id-header {
+ display: flex;
+ align-items: center;
+ gap: var(--space-sm);
+ margin-bottom: var(--space-md);
+ padding-bottom: var(--space-sm);
+ border-bottom: 1px solid rgba(255, 255, 255, 0.06);
+ }
+
+ .vis-id-dot {
+ width: 8px;
+ height: 8px;
+ border-radius: 50%;
+ background: #4ade80;
+ box-shadow: 0 0 6px rgba(74, 222, 128, 0.5);
+ }
+
+ .vis-id-filename {
+ font-family: 'JetBrains Mono', monospace;
+ font-size: 0.7rem;
+ color: rgba(255, 255, 255, 0.45);
+ }
+
+ .vis-id-row {
+ display: flex;
+ justify-content: space-between;
+ align-items: center;
+ padding: var(--space-xs) 0;
+ border-bottom: 1px solid rgba(255, 255, 255, 0.04);
+ font-size: 0.75rem;
+ }
+
+ .vis-id-row:last-child {
+ border-bottom: none;
+ }
+
+ .vis-id-key {
+ font-family: 'JetBrains Mono', monospace;
+ color: rgba(255, 255, 255, 0.28);
+ }
+
+ .vis-id-val {
+ font-family: 'JetBrains Mono', monospace;
+ color: rgba(255, 255, 255, 0.6);
+ }
+
+ .vis-id-val.gold {
+ color: rgba(255, 215, 0, 0.75);
+ }
+ .vis-id-val.green {
+ color: rgba(74, 222, 128, 0.8);
+ }
+
+ /* Embed code visual */
+
+ .vis-embed {
+ padding: var(--space-md);
+ width: 100%;
+ }
+
+ .vis-embed-tabs {
+ display: flex;
+ gap: var(--space-xs);
+ margin-bottom: var(--space-md);
+ }
+
+ .vis-embed-tab {
+ padding: 0.3rem 0.8rem;
+ border-radius: 999px;
+ font-size: 0.68rem;
+ font-family: 'JetBrains Mono', monospace;
+ color: rgba(255, 255, 255, 0.3);
+ border: 1px solid rgba(255, 255, 255, 0.07);
+ letter-spacing: 0.04em;
+ }
+
+ .vis-embed-tab.active {
+ color: #fff;
+ background: rgba(255, 255, 255, 0.06);
+ border-color: rgba(255, 255, 255, 0.12);
+ }
+
+ .vis-embed-code {
+ background: #080810;
+ border: 1px solid rgba(255, 255, 255, 0.05);
+ border-radius: 8px;
+ padding: var(--space-md);
+ font-family: 'JetBrains Mono', monospace;
+ font-size: 0.72rem;
+ line-height: 1.7;
+ color: rgba(255, 255, 255, 0.5);
+ }
+
+ .vis-embed-code .tag {
+ color: rgba(125, 200, 255, 0.85);
+ }
+ .vis-embed-code .attr {
+ color: rgba(168, 204, 140, 0.85);
+ }
+ .vis-embed-code .val {
+ color: rgba(230, 175, 100, 0.85);
+ }
+
+ /* Responsive */
+
+ @media screen and (max-width: 768px) {
+ .journey-step {
+ grid-template-columns: 1fr;
+ gap: var(--space-xl);
+ padding: var(--space-xl) var(--space-md);
+ }
+
+ .journey-step--flip .journey-step-content {
+ order: unset;
+ }
+ .journey-step--flip .journey-step-visual {
+ order: unset;
+ }
+
+ .journey-step-visual {
+ min-height: 240px;
+ }
+ }
+ </style>
+ </head>
+ <body class="features-page">
+ <header>
+ <h1>
+ <a href="/"><span class="wordmark-dot" aria-hidden="true"></span>3D Agent</a>
+ </h1>
+ <nav class="features-nav">
+ <a href="/app">Viewer</a>
+ <a href="/features">Features</a>
+ <a href="/widgets">Widgets</a>
+ <a href="/dashboard" class="nav-dashboard">Dashboard</a>
+ <a href="/login" class="nav-sign-in" id="nav-sign-in">Sign in</a>
+ </nav>
+ </header>
+
+ <main class="features-main">
+ <!-- ── Hero ── -->
+ <section class="hero" id="hero">
+ <div class="hero-bg" aria-hidden="true">
+ <div class="hero-mesh"></div>
+ <div class="hero-grid"></div>
+ <div class="hero-glow hero-glow-gold"></div>
+ <div class="hero-glow hero-glow-cyan"></div>
</div>
- <h2 class="auth-gate__title">Your agent lives here</h2>
- <p class="auth-gate__desc">
- Sign in to access animations, scene controls, and your agent's on-chain identity, memory, and skills.
- </p>
- <div class="auth-gate__actions">
- <a class="auth-gate__btn auth-gate__btn--primary" href="/login">Sign in</a>
- <a class="auth-gate__btn" href="/register">Create account</a>
+ <div class="hero-content">
+ <div class="hero-chip scroll-reveal">
+ <span class="hero-chip-dot"></span>
+ <span>Browser-native · No install</span>
+ <span class="hero-chip-divider"></span>
+ <span class="hero-chip-spec">Free to start</span>
+ </div>
+ <h2 class="hero-title scroll-reveal">
+ Give your AI<br />
+ agent a <em>body</em>.
+ </h2>
+ <p class="hero-subtitle scroll-reveal">
+ Drop any GLB model — view it, animate it, embed it anywhere, and give it a
+ verifiable on-chain identity. No plugins. No server uploads.
+ </p>
+ <div class="hero-cta scroll-reveal">
+ <a href="/create" class="btn-primary">
+ <span>Create your agent</span>
+ <span class="btn-arrow">→</span>
+ </a>
+ <a
+ href="/app"
+ class="btn-ghost"
+ title="No sign-in needed — drop a GLB and play"
+ >Try the viewer →</a
+ >
+ </div>
+ <ul
+ class="hero-proof scroll-reveal"
+ aria-label="Supported formats and standards"
+ >
+ <li>glTF 2.0</li>
+ <li>GLB</li>
+ <li>ERC-8004</li>
+ <li>A2A</li>
+ <li>MCP</li>
+ </ul>
+ </div>
+ <div class="hero-avatar scroll-reveal">
+ <div class="hero-avatar-ring" aria-hidden="true"></div>
+ <div class="hero-avatar-pulse" aria-hidden="true"></div>
+ <a href="/app" class="hero-avatar-link" aria-label="Open the 3D Agent viewer">
+ <model-viewer
+ class="hero-avatar-viewer"
+ src="/avatars/cz.glb"
+ alt="3D Agent avatar"
+ autoplay
+ animation-name="IdleV4.2(maya_head)"
+ disable-zoom
+ auto-rotate
+ auto-rotate-delay="0"
+ rotation-per-second="18deg"
+ interaction-prompt="none"
+ shadow-intensity="0.8"
+ shadow-softness="1"
+ exposure="1.05"
+ tone-mapping="aces"
+ environment-image="neutral"
+ camera-orbit="20deg 88deg 4.8m"
+ field-of-view="32deg"
+ loading="eager"
+ ></model-viewer>
+ </a>
+ <div class="hero-avatar-tag" aria-hidden="true">
+ <span class="hero-avatar-tag-label">agent</span>
+ <span class="hero-avatar-tag-value">0x3d…a9f</span>
+ </div>
+ </div>
+ <div class="hero-scroll-hint scroll-reveal" aria-hidden="true">
+ <span>scroll</span>
+ <span class="hero-scroll-line"></span>
+ </div>
+ </section>
+
+ <!-- ── Journey Steps ── -->
+ <section class="journey" id="get-started">
+ <div class="journey-header scroll-reveal">
+ <p class="journey-overline">Get Started</p>
+ <h2 class="journey-title">From sign-in to<br />embedded agent.</h2>
+ <p class="journey-sub">Five steps. Embed for free. On-chain is optional.</p>
+ </div>
+
+ <!-- Step 01 -->
+ <div class="journey-step">
+ <div class="journey-step-content scroll-reveal">
+ <p class="journey-step-num">Step 01</p>
+ <h3 class="journey-step-title">Sign in.</h3>
+ <p class="journey-step-desc">
+ Connect your wallet or sign in with email. Your avatars, animations, and
+ on-chain identities are saved to your account.
+ </p>
+ <a href="/login" class="journey-step-cta">Sign in →</a>
+ </div>
+ <div class="journey-step-visual scroll-reveal">
+ <div class="vis-identity">
+ <div class="vis-id-header">
+ <div class="vis-id-dot"></div>
+ <span class="vis-id-filename">session.json</span>
+ </div>
+ <div class="vis-id-row">
+ <span class="vis-id-key">method</span>
+ <span class="vis-id-val">"wallet" · "email"</span>
+ </div>
+ <div class="vis-id-row">
+ <span class="vis-id-key">address</span>
+ <span class="vis-id-val gold">0x3d…a9f</span>
+ </div>
+ <div class="vis-id-row">
+ <span class="vis-id-key">saved</span>
+ <span class="vis-id-val">avatars · agents · widgets</span>
+ </div>
+ <div class="vis-id-row">
+ <span class="vis-id-key">active</span>
+ <span class="vis-id-val green">true</span>
+ </div>
+ </div>
+ </div>
+ </div>
+
+ <!-- Step 02 -->
+ <div class="journey-step journey-step--flip">
+ <div class="journey-step-content scroll-reveal">
+ <p class="journey-step-num">Step 02</p>
+ <h3 class="journey-step-title">Create your<br />avatar.</h3>
+ <p class="journey-step-desc">
+ Edit a default avatar in our web editor, or drop in your own GLB. Need a
+ model? Try
+ <a href="https://avaturn.me" target="_blank" rel="noopener">Avaturn</a>
+ or
+ <a href="https://mixamo.com" target="_blank" rel="noopener">Mixamo</a>.
+ (Selfie-to-avatar — coming soon.)
+ </p>
+ <a href="/create" class="journey-step-cta">Create your avatar →</a>
+ </div>
+ <div class="journey-step-visual scroll-reveal">
+ <div class="vis-upload">
+ <div class="vis-upload-zone">
+ <div class="vis-upload-icon">⬆</div>
+ <span class="vis-upload-label">Edit default · Upload GLB</span>
+ <span class="vis-upload-sub">glTF 2.0 · GLB · Draco · KTX2</span>
+ </div>
+ <div class="vis-file-chip">
+ <span class="vis-file-dot"></span>
+ <span>my-avatar.glb · 4.2 MB · saved</span>
+ </div>
+ </div>
+ </div>
+ </div>
+
+ <!-- Step 03 -->
+ <div class="journey-step">
+ <div class="journey-step-content scroll-reveal">
+ <p class="journey-step-num">Step 03</p>
+ <h3 class="journey-step-title">Customize.</h3>
+ <p class="journey-step-desc">
+ Name your agent, pick animations, add voice, and connect a brain. Save
+ once, use everywhere.
+ </p>
+ <a href="/app" class="journey-step-cta">Open the viewer →</a>
+ </div>
+ <div class="journey-step-visual scroll-reveal">
+ <div class="vis-anim">
+ <div class="vis-anim-header">Animations</div>
+ <div class="vis-anim-row active">
+ <div class="vis-anim-play">▶</div>
+ <span>Idle — Breathing</span>
+ <span class="vis-anim-dur">∞</span>
+ </div>
+ <div class="vis-anim-row">
+ <div class="vis-anim-play">▶</div>
+ <span>Wave</span>
+ <span class="vis-anim-dur">2.4s</span>
+ </div>
+ <div class="vis-anim-row">
+ <div class="vis-anim-play">▶</div>
+ <span>Talking</span>
+ <span class="vis-anim-dur">∞</span>
+ </div>
+ <div class="vis-anim-row">
+ <div class="vis-anim-play">▶</div>
+ <span>Dance — Hip Hop</span>
+ <span class="vis-anim-dur">4.1s</span>
+ </div>
+ <div class="vis-anim-row">
+ <div class="vis-anim-play">▶</div>
+ <span>Walk Cycle</span>
+ <span class="vis-anim-dur">∞</span>
+ </div>
+ <div class="vis-anim-row">
+ <div class="vis-anim-play">▶</div>
+ <span>Thinking</span>
+ <span class="vis-anim-dur">3.2s</span>
+ </div>
+ </div>
+ </div>
</div>
- <ul class="auth-gate__perks">
- <li>Animations &amp; presence controls</li>
- <li>Save avatars to your account</li>
- <li>Register on-chain agent identity</li>
- <li>Scene, lighting &amp; material editor</li>
- </ul>
- </div>
- </aside>
-
- <!-- 3D Viewer -->
- <div class="viewer-container" id="viewer-container"></div>
-
- <!-- Bottom bar -->
- <div class="dropzone">
- <div class="upload-btn">
- <input type="file" name="file-input[]" id="file-input" multiple="" />
- <label for="file-input">
- <svg
- xmlns="http://www.w3.org/2000/svg"
- width="20"
- height="17"
- viewBox="0 0 20 17"
+
+ <!-- Step 04 -->
+ <div class="journey-step journey-step--flip">
+ <div class="journey-step-content scroll-reveal">
+ <p class="journey-step-num">Step 04</p>
+ <h3 class="journey-step-title">Embed<br />anywhere.</h3>
+ <p class="journey-step-desc">
+ Generate a widget — one iframe, any site. Works in Notion, Ghost,
+ WordPress, and more.
+
+ </p>
+ <a href="/studio" class="journey-step-cta">Open Widget Studio →</a>
+ </div>
+ <div class="journey-step-visual scroll-reveal">
+ <div class="vis-embed">
+ <div class="vis-embed-tabs">
+ <span class="vis-embed-tab active">iframe</span>
+ <span class="vis-embed-tab">web component</span>
+ <span class="vis-embed-tab">on-chain</span>
+ </div>
+ <div class="vis-embed-code">
+ <span class="tag">&lt;iframe</span><br />
+ &nbsp;&nbsp;<span class="attr">src</span>=<span class="val"
+ >"https://3dagent.vercel.app/w/wdgt_abc123"</span
+ ><br />
+ &nbsp;&nbsp;<span class="attr">width</span>=<span class="val"
+ >"400"</span
+ ><br />
+ &nbsp;&nbsp;<span class="attr">height</span>=<span class="val"
+ >"600"</span
+ ><br />
+ &nbsp;&nbsp;<span class="attr">allow</span>=<span class="val"
+ >"microphone"</span
+ ><br />
+ <span class="tag">/&gt;</span>
+ </div>
+ </div>
+ </div>
+ </div>
+
+ <!-- Step 05 -->
+ <div class="journey-step">
+ <div class="journey-step-content scroll-reveal">
+ <p class="journey-step-num">Step 05</p>
+ <h3 class="journey-step-title">Deploy<br />on-chain.</h3>
+ <p class="journey-step-desc">
+ Register your agent on Ethereum via ERC-8004 — the trustless agents
+ standard. Get a verifiable on-chain identity, portable reputation, and
+ proof of execution discoverable by any A2A or MCP client.
+ </p>
+ <a href="/register" class="journey-step-cta">Register on-chain →</a>
+ </div>
+ <div class="journey-step-visual scroll-reveal">
+ <div class="vis-onchain">
+ <div class="vis-onchain-header">
+ <div class="vis-onchain-dot"></div>
+ <span>ERC-8004 Registry</span>
+ </div>
+ <div class="vis-onchain-row">
+ <span class="vis-onchain-label">Identity</span>
+ <span class="vis-onchain-val">ERC-721 token</span>
+ </div>
+ <div class="vis-onchain-row">
+ <span class="vis-onchain-label">Reputation</span>
+ <span class="vis-onchain-val">on-chain score</span>
+ </div>
+ <div class="vis-onchain-row">
+ <span class="vis-onchain-label">Validation</span>
+ <span class="vis-onchain-val">TEE / zkML proof</span>
+ </div>
+ <div class="vis-onchain-badge">Mainnet + L2s</div>
+ </div>
+ </div>
+ </div>
+ </section>
+
+ <!-- ── Three product pillars ── -->
+ <section class="section" id="features">
+ <h3 class="section-label scroll-reveal">What You Get</h3>
+ <div class="registry-grid">
+ <div class="registry-card scroll-reveal">
+ <div class="registry-icon">🎭</div>
+ <h4>3D Avatar Viewer</h4>
+ <p>
+ Render any GLB in WebGL with full animations, materials, and lighting —
+ directly in the browser. No install required.
+ </p>
+ <ul class="registry-details">
+ <li><code>glTF 2.0 + GLB</code></li>
+ <li><code>Draco + KTX2 + Meshopt</code></li>
+ <li><code>three.js r176</code></li>
+ </ul>
+ </div>
+ <div class="registry-card scroll-reveal">
+ <div class="registry-icon">💬</div>
+ <h4>Talking Agent</h4>
+ <p>
+ Give your avatar an AI brain. It speaks, remembers, and responds —
+ powered by your LLM of choice via a simple skill interface.
+ </p>
+ <ul class="registry-details">
+ <li><code>Voice + text input</code></li>
+ <li><code>Persistent memory</code></li>
+ <li><code>Custom skills</code></li>
+ </ul>
+ </div>
+ <div class="registry-card scroll-reveal">
+ <div class="registry-icon">🪪</div>
+ <h4>On-Chain Identity</h4>
+ <p>
+ Register on Ethereum via ERC-8004. A verifiable, portable identity
+ discoverable by any A2A or MCP client.
+ </p>
+ <ul class="registry-details">
+ <li><code>ERC-721 ownership</code></li>
+ <li><code>A2A + MCP endpoints</code></li>
+ <li><code>ENS compatible</code></li>
+ </ul>
+ </div>
+ </div>
+ </section>
+
+ <!-- ── Integration grid ── -->
+ <section class="section section-dark" id="integration">
+ <h3 class="section-label scroll-reveal">Built to Integrate</h3>
+ <div class="integration-grid">
+ <div class="integration-item scroll-reveal">
+ <h4>Any 3D Model</h4>
+ <p>
+ Drag in a <code>.glb</code> or <code>.gltf</code> — Draco-compressed,
+ KTX2-textured, or Meshopt-quantized. No conversion step.
+ </p>
+ </div>
+ <div class="integration-item scroll-reveal">
+ <h4>Any Website</h4>
+ <p>
+ One iframe works in Notion, Ghost, WordPress, Webflow, and Framer. No
+ SDK required on the consumer side.
+ </p>
+ </div>
+ <div class="integration-item scroll-reveal">
+ <h4>Any AI Stack</h4>
+ <p>
+ Connect via <code>MCP</code> or <code>A2A</code>. Works with Claude,
+ GPT, Gemini, and any OpenAI-compatible model.
+ </p>
+ </div>
+ <div class="integration-item scroll-reveal">
+ <h4>Any EVM Chain</h4>
+ <p>
+ ERC-8004 identities are CREATE2-deterministic — same address on every
+ chain. Deploy once, discoverable everywhere.
+ </p>
+ </div>
+ </div>
+ </section>
+
+ <!-- ── CTA ── -->
+ <section class="section cta-section" id="cta">
+ <div class="cta-content scroll-reveal">
+ <h3>Ready to give your AI agent a body?</h3>
+ <p>Drop a 3D model. Add AI. Ship in minutes.</p>
+ <div class="hero-cta">
+ <a href="/create" class="btn-primary">Create your agent</a>
+ <a href="/app" class="btn-ghost">Open viewer →</a>
+ </div>
+ </div>
+ </section>
+
+ <footer class="features-footer">
+ <p>
+ 3D Agent ·
+ <a href="https://github.com/nirholas/3D" target="_blank" rel="noopener"
+ >GitHub</a
>
- <path
- d="M10 0l-5.2 4.9h3.3v5.1h3.8v-5.1h3.3l-5.2-4.9zm9.3 11.5l-3.2-2.1h-2l3.4 2.6h-3.5c-.1 0-.2.1-.2.1l-.8 2.3h-6l-.8-2.2c-.1-.1-.1-.2-.2-.2h-3.6l3.4-2.6h-2l-3.2 2.1c-.4.3-.7 1-.6 1.5l.6 3.1c.1.5.7.9 1.2.9h16.3c.6 0 1.1-.4 1.3-.9l.6-3.1c.1-.5-.2-1.2-.7-1.5z"
- ></path>
- </svg>
- <span>Upload your own model</span>
- </label>
- </div>
- <span class="drop-hint">or drag &amp; drop glTF / GLB anywhere</span>
- <a class="create-avatar-btn" id="create-avatar-btn" href="/create" title="Create a custom 3D avatar from a selfie">
- <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="currentColor"><path d="M12 12c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm0 2c-2.67 0-8 1.34-8 4v2h16v-2c0-2.66-5.33-4-8-4z"/></svg>
- <span>Create Avatar</span>
- </a>
- </div>
- <div class="spinner"></div>
- </main>
-
- <!-- Golden Ratio dev grid — toggle with Alt+G -->
- <div class="phi-grid" id="phi-grid">
- <div class="phi-grid-h"></div>
- <div class="phi-grid-thirds"></div>
- <div class="phi-grid-thirds-h"></div>
- </div>
- <div class="phi-grid-label" id="phi-grid-label">φ Grid — Alt+G to toggle</div>
- <script>
- document.addEventListener('keydown', function (e) {
- if (e.altKey && e.key.toLowerCase() === 'g') {
- document.getElementById('phi-grid').classList.toggle('visible');
- }
- });
- </script>
-</body>
+ · <a href="/features">Docs</a> · <a href="/#register">Register on-chain</a> ·
+ <a href="https://eips.ethereum.org/EIPS/eip-8004" target="_blank" rel="noopener"
+ >ERC-8004</a
+ >
+ </p>
+ </footer>
+ </main>
+
+ <script>
+ // Auth-aware nav
+ (function () {
+ try {
+ const token =
+ localStorage.getItem('auth_token') || sessionStorage.getItem('auth_token');
+ if (token) {
+ const el = document.getElementById('nav-sign-in');
+ if (el) {
+ el.textContent = 'Dashboard';
+ el.href = '/dashboard';
+ }
+ }
+ } catch (_) {}
+ })();
+
+ // Scroll reveal
+ (function () {
+ const reveals = document.querySelectorAll('.scroll-reveal');
+ const observer = new IntersectionObserver(
+ (entries) => {
+ entries.forEach((entry) => {
+ if (entry.isIntersecting) {
+ entry.target.classList.add('revealed');
+ observer.unobserve(entry.target);
+ }
+ });
+ },
+ { threshold: 0.12, rootMargin: '0px 0px -60px 0px' },
+ );
+ reveals.forEach((el) => {
+ const siblings = Array.from(
+ el.parentElement.querySelectorAll('.scroll-reveal'),
+ );
+ const idx = siblings.indexOf(el);
+ el.style.transitionDelay = idx * 0.1 + 's';
+ observer.observe(el);
+ });
+ })();
+ </script>
+ </body>
</html>
diff --git a/package-lock.json b/package-lock.json
index ba662919b..56a7fe099 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -21,6 +21,7 @@
"bcryptjs": "^2.4.3",
"dat.gui": "^0.7.9",
"ethers": "^6.16.0",
+ "fbx-parser": "^2.1.3",
"gltf-validator": "^2.0.0-dev.3.10",
"jose": "^5.9.6",
"query-string": "^8.1.0",
@@ -3562,6 +3563,12 @@
"url": "https://paulmillr.com/funding/"
}
},
+ "node_modules/@picode/binary-reader": {
+ "version": "0.0.4",
+ "resolved": "https://registry.npmjs.org/@picode/binary-reader/-/binary-reader-0.0.4.tgz",
+ "integrity": "sha512-ae1+S0EH+K6uuE8aCQs+lpjDMBy54Gimz0j/LyTUx3H090nzyiyRKUsPx3SmZvgUqzJIZnw+sfIB8Us/iPbvPA==",
+ "license": "MIT"
+ },
"node_modules/@privy-io/api-base": {
"version": "1.8.3",
"resolved": "https://registry.npmjs.org/@privy-io/api-base/-/api-base-1.8.3.tgz",
@@ -5864,6 +5871,16 @@
"fxparser": "src/cli/cli.js"
}
},
+ "node_modules/fbx-parser": {
+ "version": "2.1.3",
+ "resolved": "https://registry.npmjs.org/fbx-parser/-/fbx-parser-2.1.3.tgz",
+ "integrity": "sha512-2Yp/A4WHD0dc2A1lheX5243HiOObQY+Do8dd12v2ppFnG6T2Ic24I2PaeDau0vp/hKuqqA1LHjAG54sQWVY62w==",
+ "license": "MIT",
+ "dependencies": {
+ "@picode/binary-reader": "^0.0.4",
+ "pako": "^2.0.3"
+ }
+ },
"node_modules/fdir": {
"version": "6.5.0",
"resolved": "https://registry.npmjs.org/fdir/-/fdir-6.5.0.tgz",
@@ -7121,6 +7138,12 @@
"dev": true,
"license": "BlueOak-1.0.0"
},
+ "node_modules/pako": {
+ "version": "2.1.0",
+ "resolved": "https://registry.npmjs.org/pako/-/pako-2.1.0.tgz",
+ "integrity": "sha512-w+eufiZ1WuJYgPXbV/PO3NCMEc3xqylkKHzp8bxp1uW4qaSNQUkwmLLEc3kKsfz8lpV1F8Ht3U1Cm+9Srog2ug==",
+ "license": "(MIT AND Zlib)"
+ },
"node_modules/path-expression-matcher": {
"version": "1.5.0",
"resolved": "https://registry.npmjs.org/path-expression-matcher/-/path-expression-matcher-1.5.0.tgz",
diff --git a/package.json b/package.json
index 6b8615c70..064338ab9 100644
--- a/package.json
+++ b/package.json
@@ -60,6 +60,7 @@
"bcryptjs": "^2.4.3",
"dat.gui": "^0.7.9",
"ethers": "^6.16.0",
+ "fbx-parser": "^2.1.3",
"gltf-validator": "^2.0.0-dev.3.10",
"jose": "^5.9.6",
"query-string": "^8.1.0",
diff --git a/prompts/erc8004-parity/00-README.md b/prompts/erc8004-parity/00-README.md
new file mode 100644
index 000000000..5dcd460b1
--- /dev/null
+++ b/prompts/erc8004-parity/00-README.md
@@ -0,0 +1,129 @@
+# ERC-8004 Register UI — full parity with erc8004.agency
+
+Goal: bring [/#register](../../src/app.js) (rendered by [src/erc8004/register-ui.js](../../src/erc8004/register-ui.js)) up to full UX parity with the reference repo at `github.com/nirholas/erc8004-agents` (live at `erc8004.agency`) — in the 3D-Agent design language.
+
+## What already exists
+
+[src/erc8004/register-ui.js](../../src/erc8004/register-ui.js) (858 lines) already has:
+
+- Chain selector, wallet connect button, close button
+- Stats row: Agents Registered / Chains Supported / Registry Version
+- Tabs: **Create Agent** / **My Agents** / **Search** / **Templates** / **History**
+- 4-step wizard: Identity → Services → Configuration → Deploy
+- Full register flow via [src/erc8004/agent-registry.js](../../src/erc8004/agent-registry.js) (`registerAgent()` + `setAgentURI()`)
+- Styles in [style.css](../../style.css) (selectors prefixed `erc8004-`)
+
+## Gap list (must-ship for parity)
+
+Reference clone at `/tmp/erc8004-agents/index.html` (single-file, ~1957 lines). Read the HTML + inline `<style>`/`<script>` as the source of truth for behavior.
+
+### 1. Hero section above the card
+
+Mirror the reference hero:
+
+- "● Live on 20+ EVM Chains" pill badge
+- H1: "Create **Trustless Agents** on Any Chain" (second word in accent)
+- Subtitle: "Register AI agents on-chain with ERC-8004. Get a portable, censorship-resistant identity backed by an ERC-721 NFT — discoverable across the entire agent economy."
+- The stats row (630 / 22 / v2.0) should sit under this hero, *above* the tabs (move it out of the current card header).
+
+### 2. Mainnet warning banner
+
+When `selectedChainId` resolves to a non-testnet, show a red-bordered banner above the tabs:
+`⚠️ Mainnet Mode — Transactions use real <native token>. Use a testnet first to test.`
+Hide on testnets. Use `CHAIN_META[id].testnet` and `.nativeCurrency`.
+
+### 3. Batch tab (new)
+
+Add a sixth tab "Batch" between Templates and History:
+
+- Drop-zone: "Drop CSV or JSON file here / or click to browse"
+- Collapsible "📝 Format Guide" accordion explaining the schemas
+- Parse CSV (`name,description,image,endpoint,serviceType`) or JSON array of agent configs
+- Queue rows; for each, call the same pipeline as step-4 deploy (`registerAgent` + `setAgentURI`)
+- Per-row status list: pending → signing → confirmed (txHash link) → linked
+- Wallet must be connected to start; warn otherwise.
+
+Copy parse logic verbatim from the reference (`parseBatchCSV`, `parseBatchJSON`, batch runner).
+
+### 4. QR code modal on search results
+
+On each search result card, add a "QR" button next to "Details". Clicking opens a modal:
+
+- Heading "Agent QR Code" + close (✕)
+- Subtitle "Agent #<id> on <chain name>"
+- QR image (encode `tokenExplorerUrl(chainId, registryAddr, tokenId)` — same URL shown in the existing Details button)
+- The URL printed below the QR
+- Buttons: **Download PNG** (canvas.toDataURL) and **Copy Link**
+
+Use a zero-dep QR generator. Port the reference's inline generator (it already ships one) or add a tiny inline module under [src/erc8004/qr.js](../../src/erc8004/qr.js). **Do not** add a new npm dep.
+
+### 5. x402 / A2A / MCP / OASF filter chips on Search
+
+Below the search input, render 5 pill chips: `All / A2A / MCP / OASF / x402 💳`. Clicking filters result cards by the `type` / `services` / `x402Support` fields in the agent's registration JSON. Copy the filter predicates from the reference.
+
+### 6. Export Options dropdown on Deploy step
+
+On Step 4 (Deploy), below "Estimated Gas", add a collapsible "📦 Export Options" accordion offering:
+
+- Download registration JSON
+- Download as `.cast` command for forge
+- Copy `viem` / `ethers` snippet
+- Copy curl for the Graph query
+
+Port the exact blocks from the reference.
+
+### 7. Footer below the card
+
+Three-column footer (Learn / Build / Ecosystem) + top row of inline links (ERC-8004 Spec / Contracts / BNB Chain AI Toolkit / GitHub). Same links as the reference. Keep it visually quiet — muted text, thin dividers.
+
+### 8. Navigation entry from homepage
+
+Today `/#register` has no visible entry. Add one:
+
+- On [/agent/:id](../../public/agent/index.html) hub, the **Deploy on-chain** CTA (see [prompts/onboarding-flow/04-agent-page-hub.md](../onboarding-flow/04-agent-page-hub.md)) should open `/#register`.
+- Also add a footer link in [index.html](../../index.html) under a new "Build" column: `Register on-chain → /#register`.
+
+## Non-goals
+
+- Do **not** rewrite the existing 4-step wizard — it works. Only add Batch + polish.
+- Do **not** switch off plain DOM / add JSX or a framework. Match the existing `erc8004-*` class convention.
+- Do **not** add npm deps. Port the QR generator inline.
+- Do **not** touch [src/erc8004/agent-registry.js](../../src/erc8004/agent-registry.js), `abi.js`, or `queries.js` — the on-chain pipeline is correct.
+
+## Constraints
+
+- Prettier: tabs, 4-wide, single quotes, 100 col.
+- ESM only.
+- JSDoc for public entry points.
+- Keep [src/erc8004/register-ui.js](../../src/erc8004/register-ui.js) as the single UI module; split into siblings (`batch-tab.js`, `qr.js`) only if the file crosses ~1400 lines.
+- All new styles go in [style.css](../../style.css) under the `erc8004-` prefix.
+
+## Verification
+
+- [ ] `node --check src/erc8004/register-ui.js`
+- [ ] `npm run build`
+- [ ] Load `/#register` on `localhost:3000`:
+ - Hero + stats render above the card
+ - 6 tabs present; each one renders content
+ - BSC Testnet selected → no mainnet banner; switch to BSC Mainnet → red banner appears
+ - Create flow still mints (testnet) end-to-end
+ - Search an agent → QR button opens modal with scannable code + Download PNG works
+ - Filter chips on Search narrow results
+ - Batch: drop a 2-row CSV, wallet connected on testnet → both rows confirm
+ - Step 4 Deploy → Export Options accordion shows 4 snippets
+- [ ] Footer renders with all three columns
+- [ ] `/agent/:id` hub's "Deploy on-chain" button navigates to `/#register` (or opens in modal — match what task 04 chose)
+- [ ] Homepage footer has "Register on-chain" link
+
+## Reference material
+
+- Reference single-file app: `/tmp/erc8004-agents/index.html`
+- Live site: `https://erc8004.agency`
+- Our existing flow: [src/erc8004/register-ui.js](../../src/erc8004/register-ui.js)
+
+## Reporting
+
+- Files changed (paths + line deltas)
+- Which reference blocks you copied verbatim vs. rewrote
+- Any behavior deviations from the reference (and why)
+- Whether a real testnet mint succeeded in your manual test, or why you couldn't run one
diff --git a/prompts/onboarding-flow/00-README.md b/prompts/onboarding-flow/00-README.md
new file mode 100644
index 000000000..c61540372
--- /dev/null
+++ b/prompts/onboarding-flow/00-README.md
@@ -0,0 +1,43 @@
+# Onboarding Flow Restructure
+
+## Goal
+
+Restructure the 3D Agent user journey into a clear funnel: **anonymous playground → sign in → create avatar → customize → embed** (with optional on-chain).
+
+Current state is fragmented: the homepage advertises a 3-step flow that doesn't match what actually works, the `/create` page is wired to a selfie-to-GLB pipeline that isn't functional, and the Avaturn iframe entry point (which *did* work) was removed from the UI during a rewrite. This band of tasks fixes all of it.
+
+## Principles
+
+1. **Embed is free and immediate.** Never gate the embed path behind wallet connect or on-chain deployment. On-chain is a *badge upgrade*, not a requirement.
+2. **Anonymous `/app` is the funnel.** Users land, drop a GLB, see it render, *then* hit the "save this" wall that prompts sign-in. Don't force auth before showing the product.
+3. **One hub page per agent.** After create, user lands on `/agent/:id`. Every action (customize, embed, deploy, edit) returns here.
+4. **Selfie-to-GLB is deferred.** The pipeline isn't working. Keep the code (`src/selfie-capture.js`, `src/selfie-pipeline.js`, `api/onboarding/avaturn-session.js`) but unroute it from `/create` and show "Coming Soon" in the UI.
+
+## Task list
+
+| # | File | Depends on | Ready to delegate? |
+|---|---|---|---|
+| 01 | [01-homepage-how-it-works.md](./01-homepage-how-it-works.md) — rewrite homepage "How It Works" to 4 steps | — | Yes |
+| 02 | [02-create-page-3-cards.md](./02-create-page-3-cards.md) — rewrite `/create` as 3-card picker | 03 | After 03 |
+| 03 | [03-avaturn-iframe-rewire.md](./03-avaturn-iframe-rewire.md) — re-enable Avaturn default-editor iframe | — | Yes |
+| 04 | [04-agent-page-hub.md](./04-agent-page-hub.md) — make `/agent/:id` the action hub | 02, 03 | After 02, 03 |
+| 05 | [05-app-html-sandbox.md](./05-app-html-sandbox.md) — position `/app` as anonymous sandbox + authed editor | — | Yes |
+
+Tasks 01, 03, 05 are independent and can run in parallel. Tasks 02 and 04 depend on 03 completing (they consume the re-wired Avaturn entry).
+
+## Out of scope — do NOT do in this band
+
+- Selfie-to-GLB pipeline fixes (deferred until the upstream vendor issue is resolved)
+- Persona / brain / skills UI (backend shipped at [api/agents.js](../../api/agents.js), UI lives in [public/agent-edit/](../../public/agent-edit/); wired in a later band)
+- ERC-8004 contract deployment (scaffolded, separate task band)
+- Widget creation UI polish (works, not in this pass)
+- Any TypeScript, new runtime deps, or schema changes
+
+## Reporting
+
+After each task, report:
+- Files changed with line counts
+- Output of `node --check` on every modified JS file
+- Output of `npm run build`
+- Manual smoke test result at `localhost:3000`
+- Any unrelated bugs observed (write them down, don't fix)
diff --git a/prompts/onboarding-flow/01-homepage-how-it-works.md b/prompts/onboarding-flow/01-homepage-how-it-works.md
new file mode 100644
index 000000000..490e09428
--- /dev/null
+++ b/prompts/onboarding-flow/01-homepage-how-it-works.md
@@ -0,0 +1,54 @@
+# Task 01: Rewrite homepage "How It Works"
+
+## Context
+
+[index.html:110-129](../../index.html#L110-L129) currently shows a 3-step flow ("Drop your model → Animate & configure → Embed anywhere") that doesn't reflect how users actually get through the product. The real flow has a sign-in step, a persona/configure step, and on-chain is optional. See [00-README.md](./00-README.md) for the overall plan.
+
+## Goal
+
+Replace the 3-step "How It Works" section with **4 steps** that accurately describe the path from landing to embed. Keep the existing visual rhythm and `scroll-reveal` class pattern. Keep the section dark/light alternation.
+
+## The 4 steps (exact copy)
+
+**Step 01 — Sign in**
+Connect your wallet or sign in with email. Your avatars, animations, and on-chain identities are saved to your account.
+
+**Step 02 — Create your avatar**
+Edit a default avatar in our web editor, or drop in your own GLB. Need a model? Try [Avaturn](https://avaturn.me) or [Mixamo](https://mixamo.com). *(Selfie-to-avatar — coming soon.)*
+
+**Step 03 — Customize**
+Name your agent, pick animations, add voice, and connect a brain. Save once, use everywhere.
+
+**Step 04 — Embed anywhere**
+Generate a widget — one iframe, any site. Works in Notion, Ghost, WordPress, and more. *Optionally claim an on-chain identity via ERC-8004.*
+
+## Deliverable
+
+1. Edit [index.html](../../index.html) section `#how-it-works` ([index.html:109-129](../../index.html#L109-L129)). Replace the 3 `.step` divs with 4 new ones containing the copy above.
+2. Tweak the hero "Open viewer" ghost CTA copy ([index.html:66](../../index.html#L66)) to better signal the sandbox:
+ - Current: `Open viewer`
+ - New: `Try the viewer →` with `title="No sign-in needed — drop a GLB and play"` attribute
+3. Update the `<meta name="description">` ([index.html:9](../../index.html#L9)) only if the old copy is now stale — otherwise leave it.
+4. Verify the `.scroll-reveal` delays still stagger correctly (the JS at [index.html:246-266](../../index.html#L246-L266) picks up all `.scroll-reveal` siblings and assigns delays — no JS changes needed).
+
+## Constraints
+
+- **Do not** add new CSS classes. Reuse `.step`, `.step-num`, `.scroll-reveal`.
+- **Do not** touch any section other than `#how-it-works` and the hero CTA copy.
+- **Do not** add images, icons, or emoji to the steps.
+- **Do not** create a new file — edit [index.html](../../index.html) in place.
+- Prettier: tabs, 4-wide, single quotes. Run `npx prettier --write index.html` before reporting done.
+
+## Verification
+
+- [ ] `npm run build` passes
+- [ ] Open `localhost:3000/`, the "How It Works" section shows 4 steps with the exact copy above
+- [ ] The 4 steps animate in on scroll with staggered delay (0s, 0.1s, 0.2s, 0.3s)
+- [ ] Hero "Try the viewer" CTA still links to `/app`
+- [ ] `npx prettier --check index.html` passes
+
+## Reporting
+
+- Confirm the diff is *only* to the `#how-it-works` section and the hero ghost CTA.
+- Screenshot or describe the rendered section.
+- Any scroll-reveal delay weirdness (there shouldn't be any).
diff --git a/prompts/onboarding-flow/02-create-page-3-cards.md b/prompts/onboarding-flow/02-create-page-3-cards.md
new file mode 100644
index 000000000..d1b4c7f71
--- /dev/null
+++ b/prompts/onboarding-flow/02-create-page-3-cards.md
@@ -0,0 +1,83 @@
+# Task 02: Rewrite `/create` as 3-card picker
+
+## Context
+
+[create.html](../../create.html) currently boots the selfie-capture flow ([src/selfie-capture.js](../../src/selfie-capture.js), template at [create.html:308-368](../../create.html#L308-L368)). That pipeline depends on Avaturn's session API which is not reliably working. We are stepping back to a 3-option picker where selfie becomes "Coming Soon" and the other two paths (default-editor iframe, GLB upload) are the active ones.
+
+**Depends on task 03** ([03-avaturn-iframe-rewire.md](./03-avaturn-iframe-rewire.md)) being merged first — this task consumes the `openDefaultEditor()` entry point that task 03 adds.
+
+See [00-README.md](./00-README.md) for the overall plan.
+
+## Goal
+
+Rewrite the `/create` page body as a 3-card picker. Each card represents an avatar-acquisition path. Clicking a card triggers the associated flow. Selfie card is disabled and shows "Coming Soon".
+
+## The 3 cards
+
+### Card 1 — "Use default avatar"
+- Icon/visual: default avatar thumbnail or abstract avatar illustration
+- Title: **Use default avatar**
+- Subtitle: *Edit a ready-made avatar in our web editor. No download required.*
+- CTA: **Open editor**
+- Action: calls `AvatarCreator.openDefaultEditor()` (added in task 03). On export → upload GLB via [src/account.js](../../src/account.js) flow → redirect to `/agent/:id`.
+
+### Card 2 — "Upload your own GLB"
+- Icon/visual: upload arrow or 3D cube illustration
+- Title: **Upload your own GLB**
+- Subtitle: *Drop a `.glb` file. Works with any glTF 2.0 model.*
+- CTA: **Choose file**
+- Action: opens hidden `<input type="file" accept=".glb,model/gltf-binary">`. On select → validate (ext + magic bytes `glTF`) → upload via presign → redirect to `/agent/:id`.
+- **Tooltip** (render as `<small>` under the CTA): *Need a model? Try [Avaturn](https://avaturn.me) or [Mixamo](https://mixamo.com).* Links should open in new tabs with `rel="noopener"`.
+
+### Card 3 — "From a selfie" (disabled)
+- Icon/visual: camera illustration with a faded/greyscale treatment
+- Title: **From a selfie**
+- Subtitle: *Turn a photo into a rigged avatar.*
+- Badge: **Coming Soon** (top-right corner of card)
+- Action: no click handler. Card has `aria-disabled="true"` and does not receive keyboard focus.
+
+## Deliverable
+
+1. **Rewrite [create.html](../../create.html)**:
+ - Replace the current selfie-capture template ([create.html:308-368](../../create.html#L308-L368) and any surrounding method-selection HTML) with a `<section class="create-picker">` containing three `<button class="create-card">` elements (or `<div>` for the disabled one).
+ - Keep the existing `<header>` and overall page chrome.
+ - Do **not** delete [src/selfie-capture.js](../../src/selfie-capture.js) or [src/selfie-pipeline.js](../../src/selfie-pipeline.js). Just unroute them.
+
+2. **New file: `src/create.js`** (the page controller). Wires the three cards:
+ - Card 1 → instantiates `AvatarCreator` with an `onExport` callback that POSTs the Blob through the presign + upload + `/api/agents/me` create flow (mirror what [src/account.js](../../src/account.js) does in the save path — factor a shared helper if clean).
+ - Card 2 → file input handler, validates, uploads, creates agent.
+ - Card 3 → no handler.
+ - On successful avatar save: `window.location.href = '/agent/' + agentId`.
+ - Use [src/account.js](../../src/account.js) `readAuthHint()` to check auth; if unauthed, redirect to `/login?next=/create`.
+
+3. **CSS** — add minimal styles to [style.css](../../style.css) (or a new `create.css` if you prefer — match the existing pattern in the repo). Cards should be equal-width on desktop, stacked on mobile. Use existing CSS variables from the homepage so the visual language matches.
+
+4. **Vite wiring** — `/create` is already served; check [vite.config.js](../../vite.config.js) `vercel-rewrites` plugin. If [create.html](../../create.html) loads [src/create.js](../../src/create.js) as a module, Vite should bundle it. Confirm with `npm run build`.
+
+## Constraints
+
+- **Do not** create the selfie-to-GLB feature. Card 3 is a placeholder.
+- **Do not** delete the existing selfie files. They get unrouted, not removed.
+- **Do not** add new runtime deps.
+- **Do not** add TypeScript.
+- **Do not** bypass the presign flow — GLBs must go R2 → `headObject` verified → `agent_identities` row (per the avatar-verification invariant in [CLAUDE.md](../../CLAUDE.md)).
+- Prettier: tabs, 4-wide, single quotes. `npx prettier --write` before done.
+
+## Verification
+
+- [ ] `npm run build` passes
+- [ ] `node --check create.html` — actually, HTML doesn't need `node --check`; just ensure `src/create.js` parses: `node --check src/create.js`
+- [ ] `localhost:3000/create`:
+ - Three cards visible, equal width on desktop
+ - Card 1 opens the Avaturn iframe modal (via task 03's `openDefaultEditor`)
+ - Card 2 opens a file picker; uploading a valid GLB redirects to `/agent/:id`
+ - Card 3 shows "Coming Soon" badge, doesn't open anything when clicked
+- [ ] Unauthed user visiting `/create` redirects to `/login?next=/create`
+- [ ] Authenticated user after export lands on `/agent/:id` with the correct avatar loaded
+
+## Reporting
+
+- List files created / modified
+- Confirm `src/selfie-capture.js` and `src/selfie-pipeline.js` still exist but are no longer imported from `create.html` / `src/create.js`
+- Any files off-limits issues (check prompts/ subdirs for conflicting tasks)
+- Describe what happens in each of the 3 cards on click
diff --git a/prompts/onboarding-flow/03-avaturn-iframe-rewire.md b/prompts/onboarding-flow/03-avaturn-iframe-rewire.md
new file mode 100644
index 000000000..06b51d045
--- /dev/null
+++ b/prompts/onboarding-flow/03-avaturn-iframe-rewire.md
@@ -0,0 +1,64 @@
+# Task 03: Re-enable Avaturn default-editor iframe
+
+## Context
+
+The Avaturn iframe integration used to be the primary avatar-creation path before the selfie-capture rewrite. The iframe logic is **still intact** in [src/avatar-creator.js:43-116](../../src/avatar-creator.js#L43-L116) — it was never deleted, just no longer called from the UI.
+
+Currently `AvatarCreator.open(sessionUrl)` expects a pre-minted Avaturn session URL (which requires a backend call to [api/onboarding/avaturn-session.js](../../api/onboarding/avaturn-session.js) that depends on photo uploads). We need a second entry point that opens Avaturn's **default hosted editor** — no session API, no photos, just "edit this default avatar and export GLB."
+
+See [docs/avaturn-docs.md](../../docs/avaturn-docs.md) for the authoritative URL conventions and [prompts/avatar-platform/01-strip-avaturn.md](../avatar-platform/01-strip-avaturn.md) for history.
+
+## Goal
+
+Add `AvatarCreator.openDefaultEditor()` — a new entry point that loads Avaturn's default editor iframe (no session, no API). Export handler path stays unchanged; it reuses `_handleAvaturnMessage` already at [src/avatar-creator.js:92-116](../../src/avatar-creator.js#L92-L116).
+
+## Deliverable
+
+1. **Add `openDefaultEditor()` method to `AvatarCreator`** in [src/avatar-creator.js](../../src/avatar-creator.js):
+ - Resolve the default editor URL from env: `VITE_AVATURN_EDITOR_URL` with fallback (confirm the correct public URL against [docs/avaturn-docs.md](../../docs/avaturn-docs.md) — likely `https://editor.avaturn.me/` or similar; if uncertain, make the URL configurable via env and document the expected value).
+ - Set `this._avaturnMode = true`, `this._avaturnOrigin = new URL(defaultUrl).origin`.
+ - Build modal via existing `_buildModal()`.
+ - Set `this.iframe.src = defaultUrl`.
+ - Register `message` listener via existing pathway.
+
+2. **If Avaturn requires a public developer ID / SDK key** in the URL querystring, add it via env `VITE_AVATURN_DEVELOPER_ID`. Document both env vars in [.env.example](../../.env.example).
+
+3. **Verify the export postMessage fires.** Open the default editor, click "Export" inside the Avaturn UI, confirm `_handleAvaturnMessage` receives the event. If Avaturn's default editor posts a different message shape than the session flow, extend the parser at [src/avatar-creator.js:98-104](../../src/avatar-creator.js#L98-L104) to handle it.
+
+4. **Do not** remove the existing `open(sessionUrl)` method — it still serves the selfie-session path when that pipeline is restored later.
+
+## API shape
+
+```js
+const creator = new AvatarCreator(document.body, async (glb) => {
+ // glb is a Blob, type 'model/gltf-binary'
+ await uploadGlbToAccount(glb);
+});
+await creator.openDefaultEditor(); // NEW — no args, opens default editor
+// or still valid:
+await creator.open(someSessionUrl); // session-based (selfie flow, deferred)
+```
+
+## Constraints
+
+- **Do not** add `@avaturn/sdk` back to package.json. Raw iframe + postMessage only.
+- **Do not** break the CharacterStudio path — `AvatarCreator.open()` with no arg still opens CharacterStudio as today.
+- **Do not** change `_handleAvaturnMessage` signatures — additive only.
+- **Do not** hardcode the Avaturn editor URL without making it env-overridable.
+- Prettier: tabs, 4-wide, single quotes. `npx prettier --write src/avatar-creator.js`.
+
+## Verification
+
+- [ ] `node --check src/avatar-creator.js`
+- [ ] `npm run build` passes
+- [ ] In a scratch test page (or the existing `/app` register flow), call `new AvatarCreator(document.body, console.log).openDefaultEditor()` — the modal opens with the Avaturn editor visible
+- [ ] Click through to export — `console.log` receives a Blob of `type: 'model/gltf-binary'` and size > 0
+- [ ] `.env.example` documents `VITE_AVATURN_EDITOR_URL` (and `VITE_AVATURN_DEVELOPER_ID` if used)
+
+## Reporting
+
+- The exact Avaturn default-editor URL you used (cite the doc source)
+- Whether a developer ID / SDK key was required
+- The postMessage shape Avaturn actually sent (for the parser at [src/avatar-creator.js:98-104](../../src/avatar-creator.js#L98-L104))
+- Any CORS / X-Frame-Options issues encountered
+- Size of the test-exported GLB
diff --git a/prompts/onboarding-flow/04-agent-page-hub.md b/prompts/onboarding-flow/04-agent-page-hub.md
new file mode 100644
index 000000000..18ff1f6f5
--- /dev/null
+++ b/prompts/onboarding-flow/04-agent-page-hub.md
@@ -0,0 +1,94 @@
+# Task 04: Make `/agent/:id` the action hub
+
+## Context
+
+After a user creates an avatar (via task 02's `/create` picker), they should land on `/agent/:id` — a page that represents their agent and exposes every action they can take from here on out. This is the "hub" the rest of the product returns to.
+
+Currently `/agent/:id` renders via [public/agent/index.html](../../public/agent/index.html) + [src/agent-home.js](../../src/agent-home.js) which draws an identity card + timeline. What's missing: clear action affordances for **Customize**, **Embed**, **Deploy on-chain**, **Edit avatar**.
+
+**Depends on tasks 02 and 03** being merged first — this task is the destination users arrive at from the rewritten `/create` flow.
+
+See [00-README.md](./00-README.md) for the overall plan.
+
+## Goal
+
+Add a primary actions row to the agent hub page with four CTAs. Each CTA either opens a modal, navigates to an editing surface, or kicks off the on-chain flow. Embed must work with no wallet / no on-chain deployment.
+
+## The four actions
+
+### 1. Customize
+- **Label:** Customize
+- **Icon:** gear / slider
+- **Action:** navigate to `/app?agent=:id` (the authenticated editing surface — see task 05)
+- **Always enabled** when user owns the agent
+
+### 2. Embed
+- **Label:** Embed
+- **Icon:** code brackets `</>`
+- **Action:** open an "Embed" modal with copy-to-clipboard for:
+ - **iframe snippet** — `<iframe src="https://3dagent.vercel.app/agent/:id" width="400" height="600" frameborder="0"></iframe>`
+ - **web component snippet** — `<agent-3d agent-id=":id"></agent-3d>` plus `<script src="https://3dagent.vercel.app/agent-3d.js"></script>`
+- **Always enabled** — never gated behind on-chain or wallet
+- Uses existing `<agent-3d>` component at [src/element.js:183](../../src/element.js#L183)
+
+### 3. Deploy on-chain
+- **Label:** Deploy on-chain · *Optional*
+- **Icon:** chain link
+- **Action:** open the existing ERC-8004 register flow at [src/erc8004/register-ui.js](../../src/erc8004/register-ui.js)
+- **States:**
+ - Not deployed → "Deploy on-chain"
+ - Deploying → disabled spinner
+ - Deployed → chip showing chain name + shortened address, clicking opens the registry record
+- **Gated:** requires wallet connect; show "Connect wallet first" if no wallet session
+
+### 4. Edit avatar
+- **Label:** Edit avatar
+- **Icon:** pencil
+- **Action:** navigate to `/agent/:id/edit` (existing page at [public/agent-edit/](../../public/agent-edit/)) OR open the "swap GLB" flow re-using [src/avatar-creator.js](../../src/avatar-creator.js) — pick whichever matches the current state of that page. If `/agent/:id/edit` exists and loads cleanly, link there. Otherwise, open the material/texture editor from [src/editor/](../../src/editor/) in a modal.
+
+## Deliverable
+
+1. **Modify [src/agent-home.js](../../src/agent-home.js)** (or create [src/agent-hub-actions.js](../../src/agent-hub-actions.js) if cleaner):
+ - Render a `<div class="agent-hub-actions">` row with the four CTAs above.
+ - Place it above the timeline, below the identity card.
+ - Each CTA is a `<button>` with icon + label. Use inline SVG for icons (consistent with the existing nav icons).
+
+2. **Embed modal** — new component, likely [src/agent-embed-modal.js](../../src/agent-embed-modal.js):
+ - Renders the two snippets with syntax highlighting (reuse the `code-block` pattern from [index.html:135-149](../../index.html#L135-L149) if possible).
+ - Copy-to-clipboard buttons (use `navigator.clipboard.writeText`).
+ - Close via backdrop click, Esc key, or explicit close button (mirror [src/avatar-creator.js:166-173](../../src/avatar-creator.js#L166-L173) pattern).
+
+3. **On-chain state hydration:**
+ - Check `agent_identities.chainId` + `chainAddress` columns via [api/agents.js](../../api/agents.js) GET response.
+ - If present → render "Deployed" chip. If absent → render "Deploy on-chain" button.
+ - Button click → existing flow at [src/erc8004/register-ui.js](../../src/erc8004/register-ui.js).
+
+4. **Hide actions if viewer is not the owner** — check against `session.address` or `session.userId` vs agent.`ownerAddress` / `ownerUserId`. Non-owners see a read-only view (current behavior).
+
+## Constraints
+
+- **Do not** gate the Embed action behind on-chain or wallet. That's a core invariant (see [00-README.md](./00-README.md)).
+- **Do not** add a persona/brain/skills UI here — that lives on `/agent/:id/edit` and is a separate task band.
+- **Do not** change agent-identity data model or [api/agents.js](../../api/agents.js) schema.
+- **Do not** add new deps.
+- Prettier: tabs, 4-wide, single quotes.
+
+## Verification
+
+- [ ] `node --check` on all modified JS files
+- [ ] `npm run build` passes
+- [ ] Navigate to `/agent/:id` as the owner:
+ - Four action buttons render above the timeline
+ - Customize → `/app?agent=:id`
+ - Embed → modal opens with two copy-able snippets; copy-to-clipboard works
+ - Deploy on-chain → opens register UI if not deployed; shows chip if deployed
+ - Edit avatar → navigates to `/agent/:id/edit` (or opens material editor modal)
+- [ ] As a non-owner visitor, the action row is hidden but the identity card + timeline still render
+- [ ] Embed works on a fresh agent that has never been deployed on-chain (prove the non-gating)
+
+## Reporting
+
+- Files created / modified
+- Which edit-avatar destination you used (`/agent/:id/edit` page vs material editor modal) and why
+- Whether you extended [src/agent-home.js](../../src/agent-home.js) or created a sibling file, and the rationale
+- Any missing API fields you had to add to the agent GET response
diff --git a/prompts/onboarding-flow/05-app-html-sandbox.md b/prompts/onboarding-flow/05-app-html-sandbox.md
new file mode 100644
index 000000000..8a772fd9b
--- /dev/null
+++ b/prompts/onboarding-flow/05-app-html-sandbox.md
@@ -0,0 +1,73 @@
+# Task 05: Position `/app` as anonymous sandbox + authenticated editor
+
+## Context
+
+[app.html](../../app.html) is currently an untracked (uncommitted) viewer page with drop-a-GLB, animation manager, agent presence, and "Make this a widget". It serves `/app`. In the new flow it plays two roles:
+
+1. **Anonymous sandbox** — user drops a GLB, plays with it, no sign-in required. This is the top-of-funnel conversion surface.
+2. **Authenticated editing surface** — accessed via `/app?agent=:id` from the agent hub ([task 04](./04-agent-page-hub.md)). Hydrates that user's saved GLB, enables save-back.
+
+See [00-README.md](./00-README.md) for the overall plan.
+
+## Goal
+
+Make `/app` work seamlessly for both anonymous drop-a-GLB users and authenticated users editing a saved agent. Add a "Save to account" CTA that prompts sign-in mid-flow (preserving the current GLB via `sessionStorage`).
+
+## Deliverable
+
+1. **Edit [app.html](../../app.html):**
+ - Remove the `/app#register` nav link ([app.html:45](../../app.html#L45)). On-chain deployment now lives on the agent hub page, not as a viewer nav item.
+ - Add a persistent "Save to account" CTA in the header area, visible *only* when a GLB is loaded (anonymous or authed). Mirror the `.make-widget-btn` pattern at [app.html:46-49](../../app.html#L46-L49).
+
+2. **Edit [src/app.js](../../src/app.js):**
+ - Parse a new URL query/hash param: `agent=<id>`. Add to the list at [src/CLAUDE.md#L60](../../src/CLAUDE.md) (Agent URL hash keys).
+ - When `agent=:id` is present: fetch `/api/agents/:id`, hydrate `manifest.body.uri` as the loaded GLB, and tag the session as "editing agent :id" (so save-back updates that agent, not creates a new one).
+ - When absent: current anonymous behavior is preserved — drop GLB, play, no persistence.
+
+3. **Save-to-account CTA behavior:**
+ - **Anonymous user, clicks Save:**
+ - Stash current GLB + config in `sessionStorage` under key `pending_save`:
+ ```json
+ { "glbUrl": "blob:...", "manifest": { ... }, "returnTo": "/app" }
+ ```
+ - Redirect to `/login?next=/app?pending=1`.
+ - **Authenticated user with no `?agent`:**
+ - Create new avatar + agent via `/api/avatars/presign` → PUT → `/api/agents/me` POST.
+ - Redirect to `/agent/:id` (the hub).
+ - **Authenticated user with `?agent=:id`:**
+ - PATCH the existing agent's avatar (use the versioning endpoint if it exists; otherwise re-upload and PUT).
+ - Redirect to `/agent/:id`.
+
+4. **On `/app` boot, check `sessionStorage.pending_save`:**
+ - If present AND user is now authenticated → re-hydrate the GLB + config, trigger the save flow, clear the stash.
+ - If present but still unauthed → no-op (they cancelled auth).
+
+5. **Keep the existing "Make this a widget" button** ([app.html:46-49](../../app.html#L46-L49)):
+ - For anonymous users, it prompts sign-in (same `sessionStorage` pattern).
+ - For authed users with `?agent=:id`, it creates a widget bound to that agent.
+
+## Constraints
+
+- **Do not** force sign-in before a GLB can be loaded. The whole point of `/app` is no-commitment play.
+- **Do not** delete the `<agent-3d>` / animation / lighting / agent-presence code. All of that stays.
+- **Do not** break the existing hash params (`model`, `widget`, `agent`, `kiosk`, `brain`, `proxyURL`, `preset`, `cameraPosition`, `register`) — extend, don't replace.
+- **Do not** add new routes. `/app` keeps serving both modes; differentiation is by URL param.
+- **Do not** introduce a client-side router. URL hash parsing in [src/app.js](../../src/app.js) is the convention.
+- Prettier: tabs, 4-wide, single quotes.
+
+## Verification
+
+- [ ] `node --check src/app.js`
+- [ ] `npm run build` passes
+- [ ] **Anonymous flow:** `localhost:3000/app`, drop a GLB, model renders, "Save to account" CTA appears, clicking it redirects to `/login` and returns to `/app` after sign-in with the GLB still there.
+- [ ] **New-save flow:** after sign-in + save, redirect to `/agent/:id` and the saved GLB loads on the hub.
+- [ ] **Edit-existing flow:** `/app?agent=:id` loads the saved GLB; editing + save redirects back to `/agent/:id` with the updated avatar.
+- [ ] **Widget flow:** "Make this a widget" works anonymously (prompts sign-in) and authed (creates widget bound to agent).
+- [ ] `/app#register` link no longer appears in nav.
+
+## Reporting
+
+- Files modified
+- Which endpoint you used for the update path (PATCH vs re-upload via presign + PUT) and why
+- Any `sessionStorage` key collisions or pre-existing keys you had to coordinate with
+- Whether save-back actually persisted on a round trip (`/app?agent=:id` → edit → save → reload → edits still there)
diff --git a/public/agent/index.html b/public/agent/index.html
index 3cea49fcb..51a0be609 100644
--- a/public/agent/index.html
+++ b/public/agent/index.html
@@ -214,6 +214,194 @@
text-align: center;
padding: 2rem;
}
+
+ /* ── Hub actions row ────────────────────────────────────────────────── */
+
+ .agent-hub-actions {
+ display: flex;
+ gap: 0.5rem;
+ flex-wrap: wrap;
+ padding: 0.75rem 1rem;
+ border-top: 1px solid rgba(255,255,255,0.06);
+ border-bottom: 1px solid rgba(255,255,255,0.06);
+ }
+
+ .agent-hub-btn {
+ display: inline-flex;
+ align-items: center;
+ gap: 0.382rem;
+ background: rgba(255,255,255,0.05);
+ border: 1px solid rgba(255,255,255,0.1);
+ color: rgba(255,255,255,0.7);
+ font-size: 0.718rem;
+ font-family: inherit;
+ padding: 0.382rem 0.75rem;
+ border-radius: 999px;
+ cursor: pointer;
+ transition: background 0.15s, border-color 0.15s, color 0.15s;
+ white-space: nowrap;
+ }
+
+ .agent-hub-btn:hover:not(:disabled) {
+ background: rgba(255,255,255,0.1);
+ border-color: rgba(255,255,255,0.2);
+ color: rgba(255,255,255,0.95);
+ }
+
+ .agent-hub-btn:disabled {
+ opacity: 0.5;
+ cursor: default;
+ }
+
+ .agent-hub-btn svg {
+ flex-shrink: 0;
+ opacity: 0.7;
+ }
+
+ .agent-hub-opt {
+ font-size: 0.618rem;
+ opacity: 0.45;
+ }
+
+ .hub-btn--deployed {
+ border-color: rgba(134,239,172,0.25);
+ color: #86efac;
+ }
+
+ .hub-btn--deployed svg {
+ opacity: 0.9;
+ }
+
+ /* ── Embed modal ────────────────────────────────────────────────────── */
+
+ .aem-overlay {
+ position: fixed;
+ inset: 0;
+ background: rgba(0,0,0,0.65);
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ z-index: 9000;
+ opacity: 0;
+ transition: opacity 0.15s;
+ }
+
+ .aem-overlay.aem-open {
+ opacity: 1;
+ }
+
+ .aem-modal {
+ background: #0f0f18;
+ border: 1px solid rgba(255,255,255,0.1);
+ border-radius: 12px;
+ width: min(480px, calc(100vw - 2rem));
+ max-height: calc(100vh - 4rem);
+ overflow: hidden;
+ display: flex;
+ flex-direction: column;
+ box-shadow: 0 24px 80px rgba(0,0,0,0.6);
+ }
+
+ .aem-header {
+ display: flex;
+ align-items: center;
+ justify-content: space-between;
+ padding: 1rem 1.25rem;
+ border-bottom: 1px solid rgba(255,255,255,0.07);
+ }
+
+ .aem-title {
+ font-size: 0.875rem;
+ font-weight: 500;
+ color: rgba(255,255,255,0.85);
+ }
+
+ .aem-close {
+ background: none;
+ border: none;
+ color: rgba(255,255,255,0.4);
+ font-size: 1.25rem;
+ line-height: 1;
+ cursor: pointer;
+ padding: 0.25rem;
+ border-radius: 4px;
+ }
+
+ .aem-close:hover { color: rgba(255,255,255,0.8); }
+
+ .aem-body {
+ padding: 1rem 1.25rem 1.25rem;
+ display: flex;
+ flex-direction: column;
+ gap: 0.75rem;
+ }
+
+ .aem-tabs {
+ display: flex;
+ gap: 0.382rem;
+ }
+
+ .aem-tab {
+ background: transparent;
+ border: 1px solid rgba(255,255,255,0.1);
+ color: rgba(255,255,255,0.45);
+ font-size: 0.618rem;
+ padding: 0.236rem 0.618rem;
+ border-radius: 999px;
+ cursor: pointer;
+ font-family: inherit;
+ transition: background 0.12s, color 0.12s;
+ }
+
+ .aem-tab.active {
+ background: rgba(255,255,255,0.08);
+ color: rgba(255,255,255,0.9);
+ border-color: rgba(255,255,255,0.2);
+ }
+
+ .aem-snippet-wrap {
+ position: relative;
+ }
+
+ .aem-snippet {
+ background: rgba(255,255,255,0.04);
+ border: 1px solid rgba(255,255,255,0.08);
+ border-radius: 8px;
+ padding: 0.75rem 1rem;
+ padding-right: 4rem;
+ font-family: monospace;
+ font-size: 0.618rem;
+ color: rgba(255,255,255,0.6);
+ white-space: pre-wrap;
+ word-break: break-all;
+ line-height: 1.6;
+ margin: 0;
+ }
+
+ .aem-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;
+ transition: background 0.12s, color 0.12s;
+ }
+
+ .aem-copy:hover { color: rgba(255,255,255,0.9); background: rgba(255,255,255,0.1); }
+ .aem-copy.aem-copied { color: #86efac; border-color: rgba(134,239,172,0.3); }
+
+ .aem-note {
+ font-size: 0.618rem;
+ color: rgba(255,255,255,0.25);
+ margin: 0;
+ line-height: 1.5;
+ }
</style>
</head>
<body>
@@ -258,16 +446,29 @@
</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';
+ 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';
+ import { renderHubActions } from '/src/agent-hub-actions.js';
// Pull agent id from URL: /agent/:id
const agentId = location.pathname.split('/').filter(Boolean).pop();
async function main() {
+ // Fetch raw API response first — it includes user_id only for owners.
+ let rawAgent = null;
+ if (agentId) {
+ try {
+ const resp = await fetch(`/api/agents/${agentId}`, { credentials: 'include' });
+ if (resp.ok) {
+ const data = await resp.json();
+ rawAgent = data.agent || null;
+ }
+ } catch {}
+ }
+
const identity = new AgentIdentity({ agentId: agentId || undefined, autoLoad: false });
await identity.load();
@@ -283,6 +484,13 @@
const home = new AgentHome(container, identity, protocol, null);
await home.render();
+ // Inject hub actions if the viewer is the owner (user_id present = owner)
+ const isOwner = Boolean(rawAgent?.user_id);
+ if (isOwner) {
+ const panel = container.querySelector('.agent-home-panel');
+ if (panel) renderHubActions(panel, identity, rawAgent);
+ }
+
// Render skills catalog
if (identity.skills?.length) {
const skills = new AgentSkills(protocol, identity.memory);
@@ -318,7 +526,8 @@
let current = 'iframe';
const render = () => { embedCode.textContent = snippets[current]; };
render();
- embedSection.style.display = '';
+ // Hide the bottom embed section for owners — they have the modal via the hub Embed button.
+ if (!isOwner) embedSection.style.display = '';
embedPreview.href = embedUrl;
document.getElementById('agent-embed-settings').href = '/dashboard/embed-policy?agent=' + identity.id;
diff --git a/public/animations/Angry.fbx b/public/animations/Angry.fbx
new file mode 100644
index 000000000..2387334bd
Binary files /dev/null and b/public/animations/Angry.fbx differ
diff --git a/public/animations/Capoeira.fbx b/public/animations/Capoeira.fbx
new file mode 100644
index 000000000..bf77dd891
Binary files /dev/null and b/public/animations/Capoeira.fbx differ
diff --git a/public/animations/Cover To Stand.fbx b/public/animations/Cover To Stand.fbx
new file mode 100644
index 000000000..8cac554e4
Binary files /dev/null and b/public/animations/Cover To Stand.fbx differ
diff --git a/public/animations/Crouch To Stand.fbx b/public/animations/Crouch To Stand.fbx
new file mode 100644
index 000000000..f1e45e85a
Binary files /dev/null and b/public/animations/Crouch To Stand.fbx differ
diff --git a/public/animations/Defeated.fbx b/public/animations/Defeated.fbx
new file mode 100644
index 000000000..3bb0d2b9d
Binary files /dev/null and b/public/animations/Defeated.fbx differ
diff --git a/public/animations/Dodging Right.fbx b/public/animations/Dodging Right.fbx
new file mode 100644
index 000000000..8d1ab9a40
Binary files /dev/null and b/public/animations/Dodging Right.fbx differ
diff --git a/public/animations/Dying.fbx b/public/animations/Dying.fbx
new file mode 100644
index 000000000..2a1ea164b
Binary files /dev/null and b/public/animations/Dying.fbx differ
diff --git a/public/animations/Falling.fbx b/public/animations/Falling.fbx
new file mode 100644
index 000000000..1c666b403
Binary files /dev/null and b/public/animations/Falling.fbx differ
diff --git a/public/animations/Goalkeeper Scoop.fbx b/public/animations/Goalkeeper Scoop.fbx
new file mode 100644
index 000000000..6318a8508
Binary files /dev/null and b/public/animations/Goalkeeper Scoop.fbx differ
diff --git a/public/animations/Header Soccerball.fbx b/public/animations/Header Soccerball.fbx
new file mode 100644
index 000000000..a7a106545
Binary files /dev/null and b/public/animations/Header Soccerball.fbx differ
diff --git a/public/animations/Hip Hop Dancing.fbx b/public/animations/Hip Hop Dancing.fbx
new file mode 100644
index 000000000..2e929cff1
Binary files /dev/null and b/public/animations/Hip Hop Dancing.fbx differ
diff --git a/public/animations/Joyful Jump.fbx b/public/animations/Joyful Jump.fbx
new file mode 100644
index 000000000..5ab7757e8
Binary files /dev/null and b/public/animations/Joyful Jump.fbx differ
diff --git a/public/animations/Jumping Down (1).fbx b/public/animations/Jumping Down (1).fbx
new file mode 100644
index 000000000..749d534b2
Binary files /dev/null and b/public/animations/Jumping Down (1).fbx differ
diff --git a/public/animations/Jumping Down (2).fbx b/public/animations/Jumping Down (2).fbx
new file mode 100644
index 000000000..42a8bad60
Binary files /dev/null and b/public/animations/Jumping Down (2).fbx differ
diff --git a/public/animations/Jumping Down.fbx b/public/animations/Jumping Down.fbx
new file mode 100644
index 000000000..c2b06dd22
Binary files /dev/null and b/public/animations/Jumping Down.fbx differ
diff --git a/public/animations/Kiss.fbx b/public/animations/Kiss.fbx
new file mode 100644
index 000000000..7014980fd
Binary files /dev/null and b/public/animations/Kiss.fbx differ
diff --git a/public/animations/Old Man Idle.fbx b/public/animations/Old Man Idle.fbx
new file mode 100644
index 000000000..008bf7d39
Binary files /dev/null and b/public/animations/Old Man Idle.fbx differ
diff --git a/public/animations/Praying.fbx b/public/animations/Praying.fbx
new file mode 100644
index 000000000..0c0c6e392
Binary files /dev/null and b/public/animations/Praying.fbx differ
diff --git a/public/animations/Reaction.fbx b/public/animations/Reaction.fbx
new file mode 100644
index 000000000..e14231714
Binary files /dev/null and b/public/animations/Reaction.fbx differ
diff --git a/public/animations/Removing Driver.fbx b/public/animations/Removing Driver.fbx
new file mode 100644
index 000000000..d2b6c6b12
Binary files /dev/null and b/public/animations/Removing Driver.fbx differ
diff --git a/public/animations/Rumba Dancing.fbx b/public/animations/Rumba Dancing.fbx
new file mode 100644
index 000000000..4827bbdc4
Binary files /dev/null and b/public/animations/Rumba Dancing.fbx differ
diff --git a/public/animations/Shoved Reaction With Spin.fbx b/public/animations/Shoved Reaction With Spin.fbx
new file mode 100644
index 000000000..e25d3fa9a
Binary files /dev/null and b/public/animations/Shoved Reaction With Spin.fbx differ
diff --git a/public/animations/Silly Dancing.fbx b/public/animations/Silly Dancing.fbx
new file mode 100644
index 000000000..be6966da5
Binary files /dev/null and b/public/animations/Silly Dancing.fbx differ
diff --git a/public/animations/Sitting Clap.fbx b/public/animations/Sitting Clap.fbx
new file mode 100644
index 000000000..2ba238f91
Binary files /dev/null and b/public/animations/Sitting Clap.fbx differ
diff --git a/public/animations/Sitting Laughing.fbx b/public/animations/Sitting Laughing.fbx
new file mode 100644
index 000000000..715d4bfa5
Binary files /dev/null and b/public/animations/Sitting Laughing.fbx differ
diff --git a/public/animations/Standing Cover Turn.fbx b/public/animations/Standing Cover Turn.fbx
new file mode 100644
index 000000000..618b9feb8
Binary files /dev/null and b/public/animations/Standing Cover Turn.fbx differ
diff --git a/public/animations/Stepping Backward.fbx b/public/animations/Stepping Backward.fbx
new file mode 100644
index 000000000..cc1761563
Binary files /dev/null and b/public/animations/Stepping Backward.fbx differ
diff --git a/public/animations/Taunt.fbx b/public/animations/Taunt.fbx
new file mode 100644
index 000000000..9ce3ecea5
Binary files /dev/null and b/public/animations/Taunt.fbx differ
diff --git a/public/animations/Thriller Part 3.fbx b/public/animations/Thriller Part 3.fbx
new file mode 100644
index 000000000..cb79ebd8b
Binary files /dev/null and b/public/animations/Thriller Part 3.fbx differ
diff --git a/public/animations/Walk Strafe Left.fbx b/public/animations/Walk Strafe Left.fbx
new file mode 100644
index 000000000..71db4e322
Binary files /dev/null and b/public/animations/Walk Strafe Left.fbx differ
diff --git a/public/animations/manifest.json b/public/animations/manifest.json
index 7ceee1ecc..b6f2105df 100644
--- a/public/animations/manifest.json
+++ b/public/animations/manifest.json
@@ -1,114 +1,128 @@
[
+ {
+ "name": "idle",
+ "url": "/animations/Old Man Idle.fbx",
+ "label": "Idle",
+ "icon": "🧍",
+ "loop": true
+ },
{
"name": "dance",
- "url": "/animations/robotexpressive.glb",
- "clipName": "Dance",
+ "url": "/animations/Hip Hop Dancing.fbx",
"label": "Dance",
"icon": "💃",
"loop": true
},
{
- "name": "death",
- "url": "/animations/robotexpressive.glb",
- "clipName": "Death",
- "label": "Death",
+ "name": "celebrate",
+ "url": "/animations/Joyful Jump.fbx",
+ "label": "Celebrate",
+ "icon": "🎉",
+ "loop": false
+ },
+ {
+ "name": "angry",
+ "url": "/animations/Angry.fbx",
+ "label": "Angry",
+ "icon": "😡",
+ "loop": false
+ },
+ {
+ "name": "defeated",
+ "url": "/animations/Defeated.fbx",
+ "label": "Defeated",
+ "icon": "😞",
+ "loop": false
+ },
+ {
+ "name": "dying",
+ "url": "/animations/Dying.fbx",
+ "label": "Dying",
"icon": "💀",
"loop": false
},
{
- "name": "idle",
- "url": "/animations/robotexpressive.glb",
- "clipName": "Idle",
- "label": "Idle",
- "icon": "🧍",
- "loop": true
+ "name": "falling",
+ "url": "/animations/Falling.fbx",
+ "label": "Falling",
+ "icon": "🪂",
+ "loop": false
},
{
"name": "jump",
- "url": "/animations/robotexpressive.glb",
- "clipName": "Jump",
+ "url": "/animations/Joyful Jump.fbx",
"label": "Jump",
"icon": "🦘",
"loop": false
},
{
- "name": "no",
- "url": "/animations/robotexpressive.glb",
- "clipName": "No",
- "label": "No",
- "icon": "🚫",
+ "name": "kiss",
+ "url": "/animations/Kiss.fbx",
+ "label": "Kiss",
+ "icon": "💋",
"loop": false
},
{
- "name": "punch",
- "url": "/animations/robotexpressive.glb",
- "clipName": "Punch",
- "label": "Punch",
- "icon": "👊",
+ "name": "pray",
+ "url": "/animations/Praying.fbx",
+ "label": "Pray",
+ "icon": "🙏",
"loop": false
},
{
- "name": "running",
- "url": "/animations/robotexpressive.glb",
- "clipName": "Running",
- "label": "Running",
- "icon": "🏃",
- "loop": true
+ "name": "reaction",
+ "url": "/animations/Reaction.fbx",
+ "label": "Reaction",
+ "icon": "😲",
+ "loop": false
},
{
- "name": "sitting",
- "url": "/animations/robotexpressive.glb",
- "clipName": "Sitting",
- "label": "Sitting",
- "icon": "🪑",
+ "name": "rumba",
+ "url": "/animations/Rumba Dancing.fbx",
+ "label": "Rumba",
+ "icon": "🕺",
"loop": true
},
{
- "name": "standing",
- "url": "/animations/robotexpressive.glb",
- "clipName": "Standing",
- "label": "Standing",
- "icon": "🧍",
+ "name": "silly",
+ "url": "/animations/Silly Dancing.fbx",
+ "label": "Silly Dance",
+ "icon": "🤪",
"loop": true
},
{
- "name": "thumbsup",
- "url": "/animations/robotexpressive.glb",
- "clipName": "ThumbsUp",
- "label": "ThumbsUp",
- "icon": "👍",
+ "name": "sitclap",
+ "url": "/animations/Sitting Clap.fbx",
+ "label": "Sit Clap",
+ "icon": "👏",
"loop": false
},
{
- "name": "walking",
- "url": "/animations/robotexpressive.glb",
- "clipName": "Walking",
- "label": "Walking",
- "icon": "🚶",
- "loop": true
+ "name": "sitlaugh",
+ "url": "/animations/Sitting Laughing.fbx",
+ "label": "Sit Laugh",
+ "icon": "😂",
+ "loop": false
},
{
- "name": "walkjump",
- "url": "/animations/robotexpressive.glb",
- "clipName": "WalkJump",
- "label": "WalkJump",
- "icon": "▶",
+ "name": "taunt",
+ "url": "/animations/Taunt.fbx",
+ "label": "Taunt",
+ "icon": "😝",
"loop": false
},
{
- "name": "wave",
- "url": "/animations/robotexpressive.glb",
- "clipName": "Wave",
- "label": "Wave",
- "icon": "👋",
- "loop": false
+ "name": "thriller",
+ "url": "/animations/Thriller Part 3.fbx",
+ "label": "Thriller",
+ "icon": "🧟",
+ "loop": true
},
{
- "name": "yes",
- "url": "/animations/robotexpressive.glb",
- "clipName": "Yes",
- "label": "Yes",
- "icon": "✅",
- "loop": false
+ "name": "capoeira",
+ "url": "/animations/Capoeira.fbx",
+ "label": "Capoeira",
+ "icon": "🥋",
+ "loop": true
}
]
diff --git a/public/register.html b/public/register.html
index 6aa2c0284..298414008 100644
--- a/public/register.html
+++ b/public/register.html
@@ -1,92 +1,1957 @@
-<!doctype html>
-<html lang="en">
+<!DOCTYPE html>
+<html lang="en" data-theme="dark">
+<!--
+═══════════════════════════════════════════════════════════════════════════════
+ERC-8004 AGENT CREATOR — BNB Chain AI Toolkit
+═══════════════════════════════════════════════════════════════════════════════
+
+✨ Original Author: nich
+🐦 Twitter/X: x.com/nichxbt
+🐙 GitHub: github.com/nirholas
+📦 Repository: github.com/nirholas/erc8004-agent-creator
+🌐 Website: https://erc8004.agency
+
+Powered by ERC-8004: Trustless Agents
+https://www.8004.org
+
+Copyright (c) 2024-2026 nirholas (nich)
+Licensed under Apache License 2.0
+═══════════════════════════════════════════════════════════════════════════════
+-->
+
<head>
-<meta charset="utf-8">
-<meta name="viewport" content="width=device-width,initial-scale=1">
-<title>Create account · 3D Agent</title>
-<link rel="icon" href="/favicon.ico">
-<meta name="privy-app-id" content="">
+ <meta charset="UTF-8" />
+ <meta name="viewport" content="width=device-width, initial-scale=1.0, viewport-fit=cover" />
+ <title>Register · 3D Agent</title>
+ <meta name="description" content="Create and register ERC-8004 trustless AI agents on any EVM network. Mint ERC-721 NFT agent identities with service endpoints, reputation, validation, A2A/MCP discovery, and x402 payment support. 20+ chains supported. Zero dependencies." />
+ <meta name="keywords" content="ERC-8004, trustless agents, AI agents, on-chain identity, BNB Chain, BSC, EVM, ERC-721, NFT, agent registry, MCP, A2A, agent-to-agent, Web3, DeFi, smart contracts, agent economy, x402, reputation, identity registry, blockchain agents, Ethereum, Base, Arbitrum, Optimism, Polygon, Avalanche, Linea, Scroll, zkSync, create agent, register agent" />
+ <meta name="theme-color" content="#05060a" />
+ <meta name="author" content="nich (nirholas) - x.com/nichxbt - github.com/nirholas" />
+ <meta name="copyright" content="Copyright (c) 2024-2026 nirholas (nich) - Apache License 2.0" />
+ <link rel="canonical" href="https://erc8004.agency/" />
+ <link rel="icon" type="image/svg+xml" href="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Cdefs%3E%3ClinearGradient id='g' x1='0%25' y1='0%25' x2='100%25' y2='100%25'%3E%3Cstop offset='0%25' stop-color='%23d6ff3d'/%3E%3Cstop offset='100%25' stop-color='%23b8e619'/%3E%3C/linearGradient%3E%3C/defs%3E%3Crect width='100' height='100' rx='20' fill='%230a0a0f'/%3E%3Ctext x='50' y='68' text-anchor='middle' font-family='system-ui,-apple-system,sans-serif' font-weight='800' font-size='32' fill='url(%23g)'%3E8004%3C/text%3E%3C/svg%3E" />
+
+ <!-- Open Graph -->
+ <meta property="og:type" content="website" />
+ <meta property="og:url" content="https://erc8004.agency/" />
+ <meta property="og:title" content="ERC-8004 Agent Creator — Register Trustless AI Agents On-Chain" />
+ <meta property="og:description" content="Create and register ERC-8004 trustless AI agents on any EVM chain. 20+ chains, agent templates, reputation system, batch registration, x402 payments. Zero dependencies." />
+
+ <!-- Twitter -->
+ <meta name="twitter:card" content="summary_large_image" />
+ <meta name="twitter:title" content="ERC-8004 Agent Creator — Trustless AI Agents On-Chain" />
+ <meta name="twitter:site" content="@nichxbt" />
+ <meta name="twitter:creator" content="@nichxbt" />
+
+ <!-- Structured Data -->
+ <script type="application/ld+json">
+ {
+ "@context": "https://schema.org",
+ "@type": "WebApplication",
+ "name": "ERC-8004 Agent Creator",
+ "url": "https://erc8004.agency",
+ "description": "Create and register ERC-8004 trustless AI agents on 20+ EVM chains. Agent templates, reputation system, batch registration, x402 payments, search & discovery.",
+ "applicationCategory": "DeveloperApplication",
+ "operatingSystem": "Web Browser",
+ "offers": { "@type": "Offer", "price": "0", "priceCurrency": "USD" },
+ "author": { "@type": "Person", "name": "nich", "url": "https://x.com/nichxbt" },
+ "featureList": [
+ "Register AI agents on 20+ EVM chains",
+ "Multi-chain support with chain family grouping",
+ "Agent templates (DeFi, Support, Code Review, etc.)",
+ "Reputation system with star ratings",
+ "Agent search & discovery",
+ "Batch registration via CSV/JSON import",
+ "x402 micropayment configuration",
+ "QR code generation for agent identity",
+ "Export as JSON, agent-card.json, embeddable badge",
+ "Dark/Light mode toggle",
+ "EIP-6963 multi-wallet detection",
+ "Transaction history with analytics",
+ "On-chain metadata editor",
+ "Agent update flow (setURI)"
+ ]
+ }
+ </script>
+
+ <!-- Fonts -->
+ <link rel="preconnect" href="https://fonts.googleapis.com" />
+ <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
+ <link href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800;900&family=JetBrains+Mono:wght@400;500;600&display=swap" rel="stylesheet" />
+
+ <!-- Ethers.js v6 -->
+ <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/ethers.umd.min.js" crossorigin="anonymous"></script>
+
<style>
- :root { color-scheme: dark; --accent:#6a5cff; --accent2:#ff5ca8; }
- * { box-sizing: border-box; }
- body { font: 15px/1.5 -apple-system,system-ui,Segoe UI,Roboto,sans-serif; background:radial-gradient(1200px 600px at 50% -100px,#1a1a2e 0,#080814 60%); color:#eee; margin:0; min-height:100vh; display:grid; place-items:center; padding:24px; }
- a { color:#9a8cff; }
- .card { background:#14141c; border:1px solid #2a2a36; border-radius:16px; padding:32px; max-width:400px; width:100%; box-shadow:0 10px 40px rgba(0,0,0,.5); }
- h1 { font-size:22px; margin:0 0 4px; letter-spacing:-0.01em; }
- .sub { color:#888; margin:0 0 24px; font-size:14px; }
- label { display:block; font-size:13px; color:#aaa; margin:14px 0 6px; }
- input { width:100%; padding:11px 13px; background:#0f0f17; border:1px solid #2a2a36; border-radius:9px; color:#eee; font-size:15px; }
- input:focus { outline:none; border-color:var(--accent); box-shadow:0 0 0 3px rgba(106,92,255,.15); }
- .hint { font-size:12px; color:#666; margin-top:5px; }
- button { width:100%; margin-top:20px; padding:12px 16px; border:0; border-radius:10px; background:linear-gradient(135deg,var(--accent),var(--accent2)); color:#fff; font-weight:600; font-size:15px; cursor:pointer; }
- button:disabled { opacity:.6; cursor:default; }
- .err { margin-top:14px; padding:10px 12px; background:rgba(255,92,92,.1); border:1px solid rgba(255,92,92,.3); border-radius:8px; color:#ffb3b3; font-size:13px; display:none; }
- .foot { margin-top:20px; text-align:center; font-size:13px; color:#888; }
- .brand { font-size:12px; letter-spacing:.1em; text-transform:uppercase; color:var(--accent); margin:0 0 8px; }
- .wallet-btn { background:#1c1c28; border:1px solid #2a2a36; color:#eee; font-weight:500; margin-top:12px; display:flex; align-items:center; justify-content:center; gap:8px; }
- .wallet-btn:hover { background:#22222e; border-color:var(--accent); }
- .divider { display:flex; align-items:center; gap:12px; margin:22px 0 4px; color:#555; font-size:12px; text-transform:uppercase; letter-spacing:.08em; }
- .divider::before, .divider::after { content:''; flex:1; height:1px; background:#2a2a36; }
- .wallet-icon { width:18px; height:18px; }
+/* ═══ RESET & THEME VARIABLES ═══ */
+*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
+
+[data-theme="dark"] {
+ --bg-primary: #05060a; --bg-secondary: #0f1018; --bg-card: rgba(255,255,255,0.03);
+ --bg-card-hover: rgba(255,255,255,0.06); --border: rgba(255,255,255,0.08);
+ --border-focus: rgba(214,255,61,0.5); --text-primary: #eeeeee; --text-secondary: #a0a0a0;
+ --text-muted: #8a8d98; --accent: #d6ff3d; --accent-dim: rgba(214,255,61,0.15);
+ --accent-glow: rgba(214,255,61,0.3); --success: #00C48C; --error: #FF4D4F;
+ --warning: #FAAD14; --info: #1890FF; --code-bg: rgba(0,0,0,0.4);
+ --shadow: 0 2px 8px rgba(0,0,0,0.3); --input-bg: rgba(255,255,255,0.04);
+ --select-arrow: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%238a8d98' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10z'/%3E%3C/svg%3E");
+}
+[data-theme="light"] {
+ --bg-primary: #f8f9fa; --bg-secondary: #ffffff; --bg-card: rgba(0,0,0,0.02);
+ --bg-card-hover: rgba(0,0,0,0.04); --border: rgba(0,0,0,0.1);
+ --border-focus: rgba(200,150,0,0.5); --text-primary: #1a1a1a; --text-secondary: #555;
+ --text-muted: #999; --accent: #d4a20a; --accent-dim: rgba(212,162,10,0.1);
+ --accent-glow: rgba(212,162,10,0.2); --success: #00A870; --error: #E53E3E;
+ --warning: #DD8800; --info: #0070E0; --code-bg: rgba(0,0,0,0.05);
+ --shadow: 0 2px 8px rgba(0,0,0,0.08); --input-bg: rgba(0,0,0,0.03);
+ --select-arrow: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%23999' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10z'/%3E%3C/svg%3E");
+}
+
+:root {
+ --radius-sm: 8px; --radius-md: 12px; --radius-lg: 16px; --radius-xl: 20px;
+ --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
+ --font-mono: 'JetBrains Mono', 'SF Mono', 'Fira Code', monospace;
+ --transition: 200ms cubic-bezier(0.4, 0, 0.2, 1);
+}
+
+html { font-size: 16px; scroll-behavior: smooth; }
+body {
+ font-family: var(--font-sans); background: var(--bg-primary); color: var(--text-primary);
+ min-height: 100vh; -webkit-font-smoothing: antialiased; overflow-x: hidden;
+ transition: background var(--transition), color var(--transition);
+}
+
+/* ═══ BACKGROUND ═══ */
+.bg-grid { position: fixed; inset: 0; background-image: linear-gradient(rgba(128,128,128,0.03) 1px, transparent 1px), linear-gradient(90deg, rgba(128,128,128,0.03) 1px, transparent 1px); background-size: 60px 60px; pointer-events: none; z-index: 0; }
+.bg-glow { position: fixed; top: -40%; left: 50%; transform: translateX(-50%); width: 800px; height: 800px; background: radial-gradient(circle, var(--accent-dim) 0%, transparent 70%); pointer-events: none; z-index: 0; }
+
+/* ═══ LAYOUT ═══ */
+.app { position: relative; z-index: 1; }
+.container { max-width: 960px; margin: 0 auto; padding: 0 24px; }
+
+/* ═══ HEADER ═══ */
+.header { position: sticky; top: 0; z-index: 100; backdrop-filter: blur(20px) saturate(180%); -webkit-backdrop-filter: blur(20px) saturate(180%); background: color-mix(in srgb, var(--bg-primary) 80%, transparent); border-bottom: 1px solid var(--border); }
+.header-inner { display: flex; align-items: center; justify-content: space-between; height: 64px; max-width: 960px; margin: 0 auto; padding: 0 24px; }
+.logo { display: flex; align-items: center; gap: 12px; text-decoration: none; color: var(--text-primary); }
+.logo-icon { width: 36px; height: 36px; background: var(--accent); border-radius: 10px; display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 14px; color: #000; letter-spacing: -0.5px; }
+.logo-text { font-weight: 700; font-size: 16px; letter-spacing: -0.3px; }
+.logo-text span { color: var(--accent); }
+.header-actions { display: flex; align-items: center; gap: 8px; }
+
+/* ═══ THEME TOGGLE ═══ */
+.theme-toggle { width: 36px; height: 36px; border-radius: var(--radius-sm); background: var(--bg-card); border: 1px solid var(--border); cursor: pointer; display: flex; align-items: center; justify-content: center; font-size: 16px; transition: all var(--transition); color: var(--text-secondary); }
+.theme-toggle:hover { border-color: var(--accent); color: var(--accent); }
+
+/* ═══ CHAIN SELECTOR ═══ */
+.chain-selector { position: relative; }
+.chain-btn { display: flex; align-items: center; gap: 8px; padding: 6px 14px; border-radius: var(--radius-sm); background: var(--bg-card); border: 1px solid var(--border); color: var(--text-primary); font-size: 13px; font-weight: 500; cursor: pointer; font-family: var(--font-sans); transition: all var(--transition); }
+.chain-btn:hover { border-color: var(--accent); }
+.chain-btn .chain-icon { width: 20px; height: 20px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 12px; flex-shrink: 0; }
+.chain-btn .chain-arrow { font-size: 10px; color: var(--text-muted); transition: transform var(--transition); }
+.chain-btn.open .chain-arrow { transform: rotate(180deg); }
+.chain-dot { width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0; }
+.chain-dot.testnet { background: var(--warning); }
+.chain-dot.mainnet { background: var(--success); }
+
+.chain-dropdown { position: absolute; top: calc(100% + 8px); right: 0; width: 340px; max-height: 480px; overflow-y: auto; background: var(--bg-secondary); border: 1px solid var(--border); border-radius: var(--radius-md); box-shadow: var(--shadow), 0 20px 60px rgba(0,0,0,0.3); z-index: 200; display: none; }
+.chain-dropdown.open { display: block; animation: dropdown-in 200ms ease-out; }
+@keyframes dropdown-in { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: translateY(0); } }
+.chain-group-label { padding: 10px 16px 4px; font-size: 11px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: 1px; }
+.chain-option { display: flex; align-items: center; gap: 10px; padding: 10px 16px; cursor: pointer; transition: background var(--transition); font-size: 13px; }
+.chain-option:hover { background: var(--bg-card-hover); }
+.chain-option.active { background: var(--accent-dim); color: var(--accent); }
+.chain-option .chain-name { flex: 1; }
+.chain-option .chain-type { font-size: 10px; padding: 2px 6px; border-radius: 4px; font-weight: 600; }
+.chain-option .chain-type.testnet { background: rgba(250,173,20,0.15); color: var(--warning); }
+.chain-option .chain-type.mainnet { background: rgba(0,196,140,0.15); color: var(--success); }
+.chain-option .chain-balance { font-size: 11px; color: var(--text-muted); font-family: var(--font-mono); }
+.chain-search { padding: 12px 16px; border-bottom: 1px solid var(--border); }
+.chain-search input { width: 100%; padding: 8px 12px; background: var(--input-bg); border: 1px solid var(--border); border-radius: 6px; color: var(--text-primary); font-size: 13px; font-family: var(--font-sans); outline: none; }
+.chain-search input:focus { border-color: var(--border-focus); }
+
+/* ═══ BUTTONS ═══ */
+.btn { display: inline-flex; align-items: center; gap: 8px; padding: 10px 20px; border-radius: var(--radius-sm); font-family: var(--font-sans); font-size: 14px; font-weight: 600; border: none; cursor: pointer; transition: all var(--transition); white-space: nowrap; text-decoration: none; }
+.btn:disabled { opacity: 0.5; cursor: not-allowed; }
+.btn-primary { background: var(--accent); color: #000; }
+.btn-primary:hover:not(:disabled) { filter: brightness(0.9); box-shadow: 0 0 20px var(--accent-glow); }
+.btn-secondary { background: var(--bg-card); color: var(--text-primary); border: 1px solid var(--border); }
+.btn-secondary:hover:not(:disabled) { background: var(--bg-card-hover); border-color: rgba(128,128,128,0.2); }
+.btn-ghost { background: transparent; color: var(--text-secondary); padding: 8px 12px; border: none; cursor: pointer; font-family: var(--font-sans); font-size: 13px; }
+.btn-ghost:hover { color: var(--text-primary); }
+.btn-sm { padding: 6px 14px; font-size: 13px; }
+.btn-lg { padding: 14px 28px; font-size: 15px; }
+.btn-danger { background: rgba(255,77,79,0.1); color: var(--error); border: 1px solid rgba(255,77,79,0.2); }
+
+/* ═══ HERO ═══ */
+.hero { padding: 80px 0 48px; text-align: center; }
+.hero-badge { display: inline-flex; align-items: center; gap: 8px; padding: 6px 16px; background: var(--accent-dim); border: 1px solid rgba(214,255,61,0.2); border-radius: 100px; font-size: 13px; font-weight: 600; color: var(--accent); margin-bottom: 24px; }
+.hero-badge .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); animation: pulse-dot 2s ease-in-out infinite; }
+@keyframes pulse-dot { 0%, 100% { opacity: 1; } 50% { opacity: 0.4; } }
+.hero h1 { font-size: clamp(32px, 5vw, 52px); font-weight: 800; letter-spacing: -1.5px; line-height: 1.1; margin-bottom: 16px; }
+.hero h1 .gradient { background: linear-gradient(135deg, var(--accent) 0%, #FFD700 50%, var(--accent) 100%); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; }
+.hero p { font-size: 17px; color: var(--text-secondary); max-width: 600px; margin: 0 auto 32px; line-height: 1.6; }
+.hero-stats { display: flex; justify-content: center; gap: 40px; padding-top: 16px; }
+.hero-stat-value { font-size: 24px; font-weight: 700; color: var(--accent); font-family: var(--font-mono); }
+.hero-stat-label { font-size: 12px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 1px; margin-top: 4px; }
+
+/* ═══ TABS ═══ */
+.tabs { display: flex; gap: 0; border-bottom: 1px solid var(--border); margin-bottom: 32px; overflow-x: auto; }
+.tab { padding: 12px 20px; font-size: 14px; font-weight: 600; color: var(--text-muted); cursor: pointer; border-bottom: 2px solid transparent; transition: all var(--transition); background: none; border-top: none; border-left: none; border-right: none; font-family: var(--font-sans); white-space: nowrap; }
+.tab:hover { color: var(--text-secondary); }
+.tab.active { color: var(--accent); border-bottom-color: var(--accent); }
+.tab .tab-count { font-size: 11px; padding: 1px 6px; border-radius: 10px; background: var(--accent-dim); color: var(--accent); margin-left: 6px; }
+
+/* ═══ CARDS ═══ */
+.card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 32px; backdrop-filter: blur(10px); }
+.card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 24px; flex-wrap: wrap; gap: 12px; }
+.card-title { font-size: 18px; font-weight: 700; letter-spacing: -0.3px; }
+.card-subtitle { font-size: 13px; color: var(--text-muted); margin-top: 4px; }
+
+/* ═══ FORMS ═══ */
+.form-group { margin-bottom: 20px; }
+.form-label { display: block; font-size: 13px; font-weight: 600; color: var(--text-secondary); margin-bottom: 6px; }
+.form-label .required { color: var(--error); margin-left: 2px; }
+.form-hint { font-size: 12px; color: var(--text-muted); margin-top: 4px; }
+.form-input, .form-textarea, .form-select { width: 100%; padding: 12px 16px; background: var(--input-bg); border: 1px solid var(--border); border-radius: var(--radius-sm); color: var(--text-primary); font-family: var(--font-sans); font-size: 14px; transition: all var(--transition); outline: none; }
+.form-input::placeholder, .form-textarea::placeholder { color: var(--text-muted); }
+.form-input:focus, .form-textarea:focus, .form-select:focus { border-color: var(--border-focus); box-shadow: 0 0 0 3px var(--accent-dim); }
+.form-textarea { resize: vertical; min-height: 80px; line-height: 1.5; }
+.form-select { cursor: pointer; appearance: none; background-image: var(--select-arrow); background-repeat: no-repeat; background-position: right 12px center; padding-right: 36px; }
+.form-select option { background: var(--bg-secondary); color: var(--text-primary); }
+
+/* ═══ STEPPER ═══ */
+.stepper { display: flex; justify-content: center; gap: 0; margin-bottom: 40px; padding: 0 20px; }
+.step { display: flex; align-items: center; gap: 0; }
+.step-circle { width: 36px; height: 36px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 14px; font-weight: 700; border: 2px solid var(--border); color: var(--text-muted); background: var(--bg-secondary); transition: all var(--transition); flex-shrink: 0; }
+.step.active .step-circle { border-color: var(--accent); color: var(--accent); background: var(--accent-dim); box-shadow: 0 0 16px var(--accent-glow); }
+.step.completed .step-circle { border-color: var(--success); background: var(--success); color: #000; }
+.step-label { font-size: 12px; color: var(--text-muted); margin-left: 8px; font-weight: 500; display: none; }
+@media (min-width: 640px) { .step-label { display: block; } }
+.step.active .step-label, .step.completed .step-label { color: var(--text-secondary); }
+.step-line { width: 40px; height: 2px; background: var(--border); margin: 0 8px; flex-shrink: 0; }
+.step-line.completed { background: var(--success); }
+
+/* ═══ SERVICE / METADATA ENTRIES ═══ */
+.service-list { display: flex; flex-direction: column; gap: 12px; }
+.service-entry { display: grid; grid-template-columns: 140px 1fr 100px 40px; gap: 8px; align-items: start; padding: 12px; background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-sm); }
+.metadata-entry { display: grid; grid-template-columns: 1fr 2fr 40px; gap: 8px; align-items: start; padding: 12px; background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-sm); }
+@media (max-width: 640px) { .service-entry, .metadata-entry { grid-template-columns: 1fr; } }
+.service-entry .form-input, .service-entry .form-select, .metadata-entry .form-input { padding: 8px 12px; font-size: 13px; }
+.btn-remove { width: 36px; height: 36px; border-radius: var(--radius-sm); background: rgba(255,77,79,0.1); border: 1px solid rgba(255,77,79,0.2); color: var(--error); cursor: pointer; display: flex; align-items: center; justify-content: center; font-size: 18px; transition: all var(--transition); }
+.btn-remove:hover { background: rgba(255,77,79,0.2); }
+
+/* ═══ CHECKBOXES ═══ */
+.checkbox-group { display: flex; flex-wrap: wrap; gap: 10px; }
+.checkbox-item { display: flex; align-items: center; gap: 8px; padding: 10px 16px; background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-sm); cursor: pointer; transition: all var(--transition); font-size: 13px; color: var(--text-secondary); }
+.checkbox-item:hover { border-color: rgba(128,128,128,0.2); }
+.checkbox-item.checked { border-color: var(--accent); background: var(--accent-dim); color: var(--accent); }
+.checkbox-item input { display: none; }
+.check-icon { width: 18px; height: 18px; border-radius: 4px; border: 2px solid var(--border); display: flex; align-items: center; justify-content: center; font-size: 11px; transition: all var(--transition); }
+.checkbox-item.checked .check-icon { background: var(--accent); border-color: var(--accent); color: #000; }
+
+/* ═══ URI OPTIONS ═══ */
+.uri-options { display: flex; gap: 8px; margin-bottom: 16px; }
+.uri-option { flex: 1; padding: 12px; border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--bg-card); cursor: pointer; text-align: center; transition: all var(--transition); }
+.uri-option:hover { border-color: rgba(128,128,128,0.2); }
+.uri-option.active { border-color: var(--accent); background: var(--accent-dim); }
+.uri-option-title { font-size: 13px; font-weight: 600; color: var(--text-primary); margin-bottom: 2px; }
+.uri-option-desc { font-size: 11px; color: var(--text-muted); }
+.uri-option.active .uri-option-title { color: var(--accent); }
+
+/* ═══ REVIEW ═══ */
+.review-json { background: var(--code-bg); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 16px; font-family: var(--font-mono); font-size: 12px; line-height: 1.6; color: var(--text-secondary); overflow-x: auto; max-height: 400px; overflow-y: auto; white-space: pre-wrap; word-break: break-all; }
+.review-section { margin-bottom: 20px; }
+.review-label { font-size: 12px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 1px; margin-bottom: 6px; }
+.review-value { font-size: 14px; color: var(--text-primary); word-break: break-all; }
+.form-nav { display: flex; justify-content: space-between; align-items: center; margin-top: 32px; padding-top: 24px; border-top: 1px solid var(--border); }
+
+/* ═══ WALLET ═══ */
+.wallet-connected { display: flex; align-items: center; gap: 8px; padding: 8px 14px; background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-sm); font-size: 13px; font-family: var(--font-mono); color: var(--text-secondary); }
+.wallet-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--success); }
+.wallet-actions { display: flex; align-items: center; gap: 8px; }
+.btn-disconnect { background: none; border: 1px solid var(--border); color: var(--text-muted); padding: 6px 10px; border-radius: var(--radius-sm); cursor: pointer; font-size: 11px; font-family: var(--font-sans); transition: all var(--transition); }
+.btn-disconnect:hover { border-color: var(--error); color: var(--error); }
+
+/* ═══ TOAST ═══ */
+.toast-container { position: fixed; top: 80px; right: 24px; z-index: 1000; display: flex; flex-direction: column; gap: 8px; }
+.toast { padding: 14px 20px; border-radius: var(--radius-md); font-size: 14px; font-weight: 500; backdrop-filter: blur(12px); border: 1px solid; animation: toast-in 300ms ease-out; max-width: 400px; }
+.toast.success { background: rgba(0,196,140,0.1); border-color: rgba(0,196,140,0.3); color: var(--success); }
+.toast.error { background: rgba(255,77,79,0.1); border-color: rgba(255,77,79,0.3); color: var(--error); }
+.toast.info { background: rgba(24,144,255,0.1); border-color: rgba(24,144,255,0.3); color: var(--info); }
+@keyframes toast-in { from { opacity: 0; transform: translateX(50px); } to { opacity: 1; transform: translateX(0); } }
+
+/* ═══ TX RESULT ═══ */
+.tx-result { text-align: center; padding: 40px 20px; }
+.tx-icon { width: 80px; height: 80px; border-radius: 50%; display: flex; align-items: center; justify-content: center; margin: 0 auto 24px; font-size: 40px; }
+.tx-icon.success { background: rgba(0,196,140,0.15); color: var(--success); }
+.tx-icon.pending { background: var(--accent-dim); color: var(--accent); animation: spin 1.5s linear infinite; }
+@keyframes spin { to { transform: rotate(360deg); } }
+.tx-title { font-size: 24px; font-weight: 700; margin-bottom: 8px; }
+.tx-subtitle { font-size: 14px; color: var(--text-secondary); margin-bottom: 24px; }
+.tx-link { display: inline-flex; align-items: center; gap: 6px; color: var(--accent); text-decoration: none; font-size: 14px; font-weight: 500; }
+.tx-link:hover { text-decoration: underline; }
+.tx-details { margin-top: 24px; padding: 16px; background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-sm); text-align: left; }
+.tx-detail-row { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
+.tx-detail-row:last-child { border-bottom: none; }
+.tx-detail-label { color: var(--text-muted); }
+.tx-detail-value { color: var(--text-primary); font-family: var(--font-mono); font-size: 12px; }
+
+/* ═══ AGENT CARDS ═══ */
+.agent-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; margin-top: 16px; }
+.agent-card { padding: 20px; background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-md); transition: all var(--transition); }
+.agent-card:hover { border-color: rgba(128,128,128,0.15); background: var(--bg-card-hover); }
+.agent-card-id { font-family: var(--font-mono); font-size: 12px; color: var(--accent); margin-bottom: 8px; }
+.agent-card-uri { font-size: 13px; color: var(--text-secondary); word-break: break-all; margin-bottom: 12px; }
+.agent-card-actions { display: flex; gap: 8px; flex-wrap: wrap; }
+
+/* ═══ REPUTATION ═══ */
+.stars { display: inline-flex; gap: 4px; }
+.star { cursor: pointer; font-size: 24px; color: var(--text-muted); transition: color var(--transition); }
+.star.filled { color: var(--accent); }
+.star:hover { color: var(--accent); }
+.reputation-bar { display: flex; align-items: center; gap: 8px; margin: 4px 0; }
+.reputation-fill { height: 6px; border-radius: 3px; background: var(--accent); transition: width 0.3s ease; }
+.reputation-track { flex: 1; height: 6px; border-radius: 3px; background: var(--bg-card); overflow: hidden; }
+
+/* ═══ TEMPLATES ═══ */
+.template-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
+.template-card { padding: 24px; background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-md); cursor: pointer; transition: all var(--transition); }
+.template-card:hover { border-color: var(--accent); background: var(--accent-dim); transform: translateY(-2px); }
+.template-icon { font-size: 32px; margin-bottom: 12px; }
+.template-name { font-weight: 700; font-size: 16px; margin-bottom: 6px; }
+.template-desc { font-size: 13px; color: var(--text-secondary); line-height: 1.5; }
+
+/* ═══ SEARCH ═══ */
+.search-bar { display: flex; gap: 8px; margin-bottom: 24px; }
+.search-bar .form-input { flex: 1; }
+.search-filters { display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; }
+.filter-chip { padding: 6px 14px; border-radius: 20px; font-size: 12px; font-weight: 500; background: var(--bg-card); border: 1px solid var(--border); color: var(--text-secondary); cursor: pointer; transition: all var(--transition); }
+.filter-chip:hover { border-color: var(--accent); }
+.filter-chip.active { background: var(--accent-dim); border-color: var(--accent); color: var(--accent); }
+
+/* ═══ BATCH ═══ */
+.drop-zone { border: 2px dashed var(--border); border-radius: var(--radius-md); padding: 48px 24px; text-align: center; cursor: pointer; transition: all var(--transition); }
+.drop-zone:hover, .drop-zone.dragover { border-color: var(--accent); background: var(--accent-dim); }
+.progress-bar { width: 100%; height: 8px; border-radius: 4px; background: var(--bg-card); overflow: hidden; margin: 8px 0; }
+.progress-fill { height: 100%; border-radius: 4px; background: var(--accent); transition: width 0.3s ease; }
+
+/* ═══ QR / EXPORT ═══ */
+.qr-container { text-align: center; padding: 24px; }
+.qr-container img { border-radius: var(--radius-sm); margin: 16px auto; display: block; }
+.export-options { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
+.export-option { padding: 16px; background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-sm); cursor: pointer; transition: all var(--transition); text-align: center; }
+.export-option:hover { border-color: var(--accent); background: var(--accent-dim); }
+
+/* ═══ HISTORY ═══ */
+.history-item { display: flex; align-items: center; gap: 16px; padding: 16px; border-bottom: 1px solid var(--border); }
+.history-item:last-child { border-bottom: none; }
+.history-icon { width: 40px; height: 40px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 18px; flex-shrink: 0; }
+.history-icon.register { background: rgba(0,196,140,0.15); color: var(--success); }
+.history-icon.update { background: rgba(24,144,255,0.15); color: var(--info); }
+.history-details { flex: 1; min-width: 0; }
+.history-title { font-weight: 600; font-size: 14px; }
+.history-meta { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
+
+/* ═══ COLLAPSIBLE ═══ */
+.collapsible { border: 1px solid var(--border); border-radius: var(--radius-sm); margin-bottom: 12px; overflow: hidden; }
+.collapsible-header { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; cursor: pointer; font-weight: 600; font-size: 14px; background: var(--bg-card); transition: background var(--transition); }
+.collapsible-header:hover { background: var(--bg-card-hover); }
+.collapsible-arrow { transition: transform var(--transition); font-size: 12px; }
+.collapsible.open .collapsible-arrow { transform: rotate(180deg); }
+.collapsible-content { max-height: 0; overflow: hidden; transition: max-height 0.3s ease; }
+.collapsible.open .collapsible-content { max-height: 2000px; }
+.collapsible-body { padding: 16px; }
+
+/* ═══ MAINNET WARNING ═══ */
+.mainnet-warning { background: rgba(239,68,68,0.08); border: 1px solid rgba(239,68,68,0.25); border-radius: var(--radius-sm); padding: 12px 16px; margin-bottom: 16px; font-size: 13px; color: var(--error); display: flex; align-items: flex-start; gap: 8px; }
+
+/* ═══ CONNECT PROMPT ═══ */
+.connect-prompt { text-align: center; padding: 60px 20px; }
+.connect-prompt-icon { font-size: 48px; margin-bottom: 16px; }
+.connect-prompt h3 { font-size: 20px; font-weight: 700; margin-bottom: 8px; }
+.connect-prompt p { color: var(--text-secondary); font-size: 14px; margin-bottom: 24px; }
+
+/* ═══ WALLET PICKER ═══ */
+.wallet-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; margin-top: 16px; }
+.wallet-option { display: flex; align-items: center; gap: 12px; padding: 14px 16px; background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-sm); cursor: pointer; transition: all var(--transition); font-size: 14px; font-weight: 500; }
+.wallet-option:hover { border-color: var(--accent); background: var(--accent-dim); }
+.wallet-option img, .wallet-option .wallet-icon-placeholder { width: 28px; height: 28px; border-radius: 6px; }
+
+/* ═══ X402 CONFIG ═══ */
+.x402-config { padding: 16px; background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-sm); margin-top: 12px; }
+.x402-config .form-group { margin-bottom: 12px; }
+
+/* ═══ ANALYTICS ═══ */
+.analytics-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; margin-bottom: 24px; }
+.analytics-card { padding: 20px; background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-md); text-align: center; }
+.analytics-value { font-size: 28px; font-weight: 700; color: var(--accent); font-family: var(--font-mono); }
+.analytics-label { font-size: 12px; color: var(--text-muted); margin-top: 4px; text-transform: uppercase; letter-spacing: 1px; }
+
+/* ═══ BADGE ═══ */
+.x402-badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 4px; font-size: 10px; font-weight: 700; background: rgba(124,58,237,0.15); color: #a78bfa; border: 1px solid rgba(124,58,237,0.3); }
+
+/* ═══ GAS ESTIMATE ═══ */
+.gas-estimate { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-secondary); }
+.gas-estimate .spinner-sm, .spinner-sm { display: inline-block; width: 12px; height: 12px; border: 2px solid rgba(128,128,128,0.2); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.8s linear infinite; }
+.gas-estimate-value { font-family: var(--font-mono); color: var(--accent); font-weight: 600; }
+.spinner { display: inline-block; width: 16px; height: 16px; border: 2px solid rgba(0,0,0,0.2); border-top-color: #000; border-radius: 50%; animation: spin 0.8s linear infinite; }
+.spinner-light { border-color: rgba(128,128,128,0.2); border-top-color: var(--accent); }
+
+/* ═══ FOOTER ═══ */
+.footer { border-top: 1px solid var(--border); padding: 32px 0; text-align: center; font-size: 13px; color: var(--text-muted); margin-top: 80px; }
+.footer a { color: var(--text-secondary); text-decoration: none; }
+.footer a:hover { color: var(--accent); }
+.footer-links { display: flex; justify-content: center; gap: 24px; margin-bottom: 12px; flex-wrap: wrap; }
+
+/* ═══ UTILITIES ═══ */
+.hidden { display: none !important; }
+::-webkit-scrollbar { width: 6px; height: 6px; }
+::-webkit-scrollbar-track { background: transparent; }
+::-webkit-scrollbar-thumb { background: rgba(128,128,128,0.15); border-radius: 4px; }
+::-webkit-scrollbar-thumb:hover { background: rgba(128,128,128,0.25); }
+
+/* ═══ RESPONSIVE ═══ */
+@media (max-width: 640px) {
+ .hero { padding: 48px 0 32px; }
+ .hero-stats { gap: 24px; }
+ .card { padding: 20px; }
+ .container { padding: 0 16px; }
+ .header-inner { padding: 0 16px; }
+ .stepper { gap: 0; }
+ .step-line { width: 20px; }
+ .chain-dropdown { width: calc(100vw - 32px); right: -16px; }
+ .uri-options { flex-direction: column; }
+ .search-bar { flex-direction: column; }
+ .tabs { gap: 0; }
+ .tab { padding: 12px 14px; font-size: 13px; }
+}
</style>
</head>
+
<body>
-<form class="card" id="f">
- <p class="brand">3D Agent</p>
- <h1>Create your account</h1>
- <p class="sub">Free plan: 10 avatars, 250 MB storage.</p>
- <label for="name">Name</label>
- <input id="name" type="text" autocomplete="name" maxlength="80">
- <label for="email">Email</label>
- <input id="email" type="email" autocomplete="email" required>
- <label for="password">Password</label>
- <input id="password" type="password" autocomplete="new-password" required minlength="10">
- <div class="hint">At least 10 characters.</div>
- <button id="submit" type="submit">Create account</button>
- <div class="divider">or</div>
- <button id="privy" type="button" class="wallet-btn" style="background:linear-gradient(135deg,var(--accent),var(--accent2)); border-color:transparent; color:#fff">
- <svg class="wallet-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="8" r="4"/><path d="M20 21a8 8 0 0 0-16 0"/></svg>
- Continue with Privy
- </button>
- <button id="wallet" type="button" class="wallet-btn">
- <svg class="wallet-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="2" y="6" width="20" height="14" rx="2"/><path d="M16 12h2"/></svg>
- Continue with MetaMask
- </button>
- <div class="err" id="err"></div>
- <p class="foot">Already have one? <a href="/login">Sign in</a></p>
-</form>
-<script type="module" src="/wallet-login.js"></script>
+ <div class="bg-grid"></div>
+ <div class="bg-glow"></div>
+
+ <div class="app">
+ <!-- ═══ HEADER ═══ -->
+ <header class="header">
+ <div class="header-inner">
+ <a href="#" class="logo" onclick="location.reload(); return false;">
+ <div class="logo-icon">8004</div>
+ <div class="logo-text"><span>ERC-8004</span> Agent Creator</div>
+ </a>
+ <div class="header-actions">
+ <div class="chain-selector" id="chainSelector">
+ <button class="chain-btn" id="chainBtn" onclick="toggleChainDropdown()">
+ <span class="chain-icon" id="chainIconDisplay">🟡</span>
+ <span id="chainNameDisplay">BSC Testnet</span>
+ <span class="chain-dot testnet" id="chainDotDisplay"></span>
+ <span class="chain-arrow">▼</span>
+ </button>
+ <div class="chain-dropdown" id="chainDropdown">
+ <div class="chain-search">
+ <input type="text" placeholder="Search chains..." oninput="filterChains(this.value)" id="chainSearchInput" />
+ </div>
+ <div id="chainList"></div>
+ </div>
+ </div>
+ <button class="theme-toggle" onclick="toggleTheme()" title="Toggle light/dark mode" id="themeBtn">🌙</button>
+ <div id="walletArea"></div>
+ </div>
+ </div>
+ <div id="mainnetBanner"></div>
+ </header>
+
+ <!-- ═══ HERO ═══ -->
+ <section class="hero">
+ <div class="container">
+ <div class="hero-badge"><div class="dot"></div>Live on 20+ EVM Chains</div>
+ <h1>Create <span class="gradient">Trustless Agents</span><br>on Any Chain</h1>
+ <p>Register AI agents on-chain with ERC-8004. Get a portable, censorship-resistant identity backed by an ERC-721 NFT — discoverable across the entire agent economy.</p>
+ <div class="hero-stats">
+ <div class="hero-stat"><div class="hero-stat-value" id="statAgents">—</div><div class="hero-stat-label">Agents Registered</div></div>
+ <div class="hero-stat"><div class="hero-stat-value">22</div><div class="hero-stat-label">Chains Supported</div></div>
+ <div class="hero-stat"><div class="hero-stat-value">v2.0</div><div class="hero-stat-label">Registry Version</div></div>
+ </div>
+ </div>
+ </section>
+
+ <!-- ═══ MAIN CONTENT ═══ -->
+ <main class="container">
+ <div class="tabs" id="mainTabs">
+ <button class="tab active" data-tab="create" onclick="switchTab('create')">Create Agent</button>
+ <button class="tab" data-tab="dashboard" onclick="switchTab('dashboard')">My Agents</button>
+ <button class="tab" data-tab="search" onclick="switchTab('search')">Search</button>
+ <button class="tab" data-tab="templates" onclick="switchTab('templates')">Templates</button>
+ <button class="tab" data-tab="batch" onclick="switchTab('batch')">Batch</button>
+ <button class="tab" data-tab="history" onclick="switchTab('history')">History</button>
+ </div>
+
+ <!-- ═══ CREATE TAB ═══ -->
+ <div id="tab-create">
+ <div id="connectPrompt" class="card">
+ <div class="connect-prompt">
+ <div class="connect-prompt-icon">🔗</div>
+ <h3>Connect Your Wallet</h3>
+ <p>Connect your wallet to create an ERC-8004 agent identity on any EVM chain.</p>
+ <button class="btn btn-primary btn-lg" onclick="connectWallet()">Connect Wallet</button>
+ <div id="walletPicker" class="hidden">
+ <div class="wallet-list" id="walletList"></div>
+ </div>
+ </div>
+ </div>
+
+ <div id="wizardSection" class="hidden">
+ <div class="stepper" id="stepper">
+ <div class="step active" data-step="1"><div class="step-circle">1</div><span class="step-label">Identity</span></div>
+ <div class="step-line"></div>
+ <div class="step" data-step="2"><div class="step-circle">2</div><span class="step-label">Services</span></div>
+ <div class="step-line"></div>
+ <div class="step" data-step="3"><div class="step-circle">3</div><span class="step-label">Configuration</span></div>
+ <div class="step-line"></div>
+ <div class="step" data-step="4"><div class="step-circle">4</div><span class="step-label">Deploy</span></div>
+ </div>
+
+ <!-- STEP 1: Identity -->
+ <div id="step1" class="card">
+ <div class="card-header"><div><div class="card-title">Agent Identity</div><div class="card-subtitle">Define your agent's core identity — name, description, and image.</div></div></div>
+ <div class="form-group"><label class="form-label">Agent Name <span class="required">*</span></label><input class="form-input" type="text" id="agentName" placeholder="e.g., DeFi Yield Optimizer" maxlength="100" /><div class="form-hint">A short, memorable name (max 100 chars)</div></div>
+ <div class="form-group"><label class="form-label">Description <span class="required">*</span></label><textarea class="form-textarea" id="agentDescription" placeholder="Describe what your agent does, capabilities, pricing..." rows="4" maxlength="1000"></textarea><div class="form-hint">Clear description (max 1000 chars)</div></div>
+ <div class="form-group"><label class="form-label">Image URL</label><input class="form-input" type="url" id="agentImage" placeholder="https://example.com/avatar.png or ipfs://..." /><div class="form-hint">Avatar or logo for your agent NFT</div></div>
+ <div class="form-nav"><div></div><button class="btn btn-primary" onclick="goToStep(2)">Next: Services →</button></div>
+ </div>
+
+ <!-- STEP 2: Services -->
+ <div id="step2" class="card hidden">
+ <div class="card-header"><div><div class="card-title">Services & Endpoints</div><div class="card-subtitle">Advertise how other agents and users can reach your agent.</div></div><button class="btn btn-secondary btn-sm" onclick="addService()">+ Add Service</button></div>
+ <div class="service-list" id="serviceList"></div>
+ <div style="margin-top:12px;"><button class="btn btn-ghost btn-sm" onclick="addService()">+ Add another service</button></div>
+ <div class="form-nav"><button class="btn btn-secondary" onclick="goToStep(1)">← Back</button><button class="btn btn-primary" onclick="goToStep(3)">Next: Configuration →</button></div>
+ </div>
+
+ <!-- STEP 3: Configuration -->
+ <div id="step3" class="card hidden">
+ <div class="card-header"><div><div class="card-title">Trust & Metadata</div><div class="card-subtitle">Configure trust models, x402 payments, and on-chain metadata.</div></div></div>
+ <div class="form-group">
+ <label class="form-label">Supported Trust Models</label>
+ <div class="checkbox-group" id="trustModels">
+ <label class="checkbox-item" onclick="toggleCheck(this)"><input type="checkbox" value="reputation" /><span class="check-icon">✓</span>Reputation</label>
+ <label class="checkbox-item" onclick="toggleCheck(this)"><input type="checkbox" value="crypto-economic" /><span class="check-icon">✓</span>Crypto-Economic</label>
+ <label class="checkbox-item" onclick="toggleCheck(this)"><input type="checkbox" value="tee-attestation" /><span class="check-icon">✓</span>TEE Attestation</label>
+ </div>
+ </div>
+
+ <!-- x402 Payment Configuration -->
+ <div class="collapsible" id="x402Collapsible">
+ <div class="collapsible-header" onclick="toggleCollapsible('x402Collapsible')">
+ <span>💳 x402 Payment Configuration</span>
+ <span class="collapsible-arrow">▼</span>
+ </div>
+ <div class="collapsible-content">
+ <div class="collapsible-body">
+ <div class="form-group">
+ <label class="checkbox-item" onclick="toggleCheck(this)" id="x402Toggle"><input type="checkbox" value="x402" /><span class="check-icon">✓</span>Enable x402 Micropayments</label>
+ </div>
+ <div id="x402Fields" class="hidden">
+ <div class="form-group"><label class="form-label">Payment Endpoint</label><input class="form-input" type="url" id="x402Endpoint" placeholder="https://pay.youragent.com/x402" /></div>
+ <div class="form-group"><label class="form-label">Price per Request</label><input class="form-input" type="text" id="x402Price" placeholder="0.001" /><div class="form-hint">Price in native token per API call</div></div>
+ <div class="form-group"><label class="form-label">Accepted Tokens</label><input class="form-input" type="text" id="x402Tokens" placeholder="USDC, USDT, native" /><div class="form-hint">Comma-separated list of accepted tokens</div></div>
+ </div>
+ </div>
+ </div>
+ </div>
+
+ <div class="form-group" style="margin-top:16px;">
+ <label class="form-label">URI Storage Method</label>
+ <div class="uri-options">
+ <div class="uri-option active" data-uri="onchain" onclick="selectUriOption('onchain')"><div class="uri-option-title">On-Chain</div><div class="uri-option-desc">Base64 data URI</div></div>
+ <div class="uri-option" data-uri="ipfs" onclick="selectUriOption('ipfs')"><div class="uri-option-title">IPFS</div><div class="uri-option-desc">Provide IPFS CID</div></div>
+ <div class="uri-option" data-uri="https" onclick="selectUriOption('https')"><div class="uri-option-title">HTTPS</div><div class="uri-option-desc">Your own domain</div></div>
+ </div>
+ <div id="customUriField" class="hidden"><input class="form-input" type="url" id="customUri" placeholder="ipfs://... or https://..." /></div>
+ </div>
+
+ <div class="form-group">
+ <label class="form-label">On-Chain Metadata (Optional)</label>
+ <div class="service-list" id="metadataList"></div>
+ <div style="margin-top:8px;display:flex;gap:8px;flex-wrap:wrap;">
+ <button class="btn btn-ghost btn-sm" onclick="addMetadata()">+ Add metadata</button>
+ <button class="btn btn-ghost btn-sm" onclick="addMetadataPreset('category','DeFi')">+ Category</button>
+ <button class="btn btn-ghost btn-sm" onclick="addMetadataPreset('twitter','@handle')">+ Twitter</button>
+ <button class="btn btn-ghost btn-sm" onclick="addMetadataPreset('website','https://')">+ Website</button>
+ <button class="btn btn-ghost btn-sm" onclick="addMetadataPreset('pricing','free')">+ Pricing</button>
+ </div>
+ </div>
+
+ <div class="form-nav"><button class="btn btn-secondary" onclick="goToStep(2)">← Back</button><button class="btn btn-primary" onclick="goToStep(4)">Review & Deploy →</button></div>
+ </div>
+
+ <!-- STEP 4: Review & Deploy -->
+ <div id="step4" class="card hidden">
+ <div class="card-header"><div><div class="card-title">Review & Deploy</div><div class="card-subtitle">Review your agent configuration before registering on-chain.</div></div></div>
+ <div class="review-section"><div class="review-label">Agent Registration JSON</div><pre class="review-json" id="reviewJson"></pre></div>
+ <div class="review-section" id="reviewUriSection"><div class="review-label">Agent URI</div><div class="review-value" id="reviewUri" style="font-family:var(--font-mono);font-size:12px;"></div></div>
+ <div class="review-section" id="reviewMetadataSection"><div class="review-label">On-Chain Metadata</div><div id="reviewMetadata"></div></div>
+ <div class="review-section"><div class="review-label">Network</div><div class="review-value" id="reviewNetwork"></div></div>
+ <div class="review-section"><div class="review-label">Contract</div><div class="review-value" id="reviewContract" style="font-family:var(--font-mono);font-size:12px;"></div></div>
+ <div class="review-section"><div class="review-label">Estimated Gas</div><div class="review-value" id="reviewGas">Calculated on submission</div></div>
+
+ <!-- Export Options -->
+ <div class="collapsible" style="margin-top:16px;">
+ <div class="collapsible-header" onclick="toggleCollapsible(this.parentElement.id)" id="exportCollapsible"><span>📦 Export Options</span><span class="collapsible-arrow">▼</span></div>
+ <div class="collapsible-content"><div class="collapsible-body">
+ <div class="export-options">
+ <div class="export-option" onclick="exportJSON()"><div style="font-size:24px;margin-bottom:8px;">📄</div><div style="font-weight:600;font-size:13px;">Export JSON</div><div style="font-size:11px;color:var(--text-muted);">Raw config file</div></div>
+ <div class="export-option" onclick="exportAgentCard()"><div style="font-size:24px;margin-bottom:8px;">🪪</div><div style="font-weight:600;font-size:13px;">Agent Card</div><div style="font-size:11px;color:var(--text-muted);">.well-known format</div></div>
+ <div class="export-option" onclick="exportBadge()"><div style="font-size:24px;margin-bottom:8px;">🏷️</div><div style="font-weight:600;font-size:13px;">Embed Badge</div><div style="font-size:11px;color:var(--text-muted);">HTML widget</div></div>
+ <div class="export-option" onclick="exportCLI()"><div style="font-size:24px;margin-bottom:8px;">⌨️</div><div style="font-weight:600;font-size:13px;">CLI Command</div><div style="font-size:11px;color:var(--text-muted);">Copy for terminal</div></div>
+ </div>
+ </div></div>
+ </div>
+
+ <div class="form-nav">
+ <button class="btn btn-secondary" onclick="goToStep(3)">← Back</button>
+ <button class="btn btn-primary btn-lg" id="deployBtn" onclick="deployAgent()">🚀 Register Agent On-Chain</button>
+ </div>
+ </div>
+
+ <!-- Deploy Result -->
+ <div id="deployResult" class="card hidden"></div>
+ </div>
+ </div>
+
+ <!-- ═══ DASHBOARD TAB ═══ -->
+ <div id="tab-dashboard" class="hidden">
+ <div id="dashboardConnectPrompt" class="card"><div class="connect-prompt"><div class="connect-prompt-icon">📋</div><h3>Connect to View Your Agents</h3><p>Connect your wallet to see agents you've registered.</p><button class="btn btn-primary btn-lg" onclick="connectWallet()">Connect Wallet</button></div></div>
+ <div id="dashboardAgents" class="hidden">
+ <div id="dashboardAnalytics" class="analytics-grid"></div>
+ <div class="card">
+ <div class="card-header"><div><div class="card-title">Your Registered Agents</div><div class="card-subtitle" id="agentCount">Loading...</div></div><button class="btn btn-secondary btn-sm" onclick="loadMyAgents()">↻ Refresh</button></div>
+ <div id="agentsList"></div>
+ </div>
+ </div>
+ </div>
+
+ <!-- ═══ SEARCH TAB ═══ -->
+ <div id="tab-search" class="hidden">
+ <div class="card">
+ <div class="card-header"><div><div class="card-title">Agent Search & Discovery</div><div class="card-subtitle">Find registered agents on the current chain.</div></div></div>
+ <div class="search-bar">
+ <input class="form-input" type="text" id="searchInput" placeholder="Search by Agent ID, name, or address..." />
+ <button class="btn btn-primary" onclick="searchAgents()">Search</button>
+ </div>
+ <div class="search-filters">
+ <button class="filter-chip active" data-filter="all" onclick="setSearchFilter('all',this)">All</button>
+ <button class="filter-chip" data-filter="A2A" onclick="setSearchFilter('A2A',this)">A2A</button>
+ <button class="filter-chip" data-filter="MCP" onclick="setSearchFilter('MCP',this)">MCP</button>
+ <button class="filter-chip" data-filter="OASF" onclick="setSearchFilter('OASF',this)">OASF</button>
+ <button class="filter-chip" data-filter="x402" onclick="setSearchFilter('x402',this)">x402 💳</button>
+ </div>
+ <div id="searchResults"></div>
+ </div>
+
+ <!-- Reputation Section -->
+ <div class="card" style="margin-top:24px;">
+ <div class="card-header"><div><div class="card-title">Reputation System</div><div class="card-subtitle">View or submit reputation scores for agents.</div></div></div>
+ <div class="form-group">
+ <label class="form-label">Agent ID</label>
+ <div style="display:flex;gap:8px;"><input class="form-input" type="number" id="repAgentId" placeholder="Enter agent ID" style="flex:1;" /><button class="btn btn-secondary" onclick="viewReputation()">View Reputation</button></div>
+ </div>
+ <div id="reputationDisplay" class="hidden">
+ <div class="analytics-grid" id="repAnalytics"></div>
+ <div id="repHistory"></div>
+ </div>
+ <div id="submitRepSection" class="hidden" style="margin-top:16px;border-top:1px solid var(--border);padding-top:16px;">
+ <div class="form-label" style="margin-bottom:12px;">Submit Rating</div>
+ <div class="stars" id="ratingStars">
+ <span class="star" data-rating="1" onclick="setRating(1)">★</span>
+ <span class="star" data-rating="2" onclick="setRating(2)">★</span>
+ <span class="star" data-rating="3" onclick="setRating(3)">★</span>
+ <span class="star" data-rating="4" onclick="setRating(4)">★</span>
+ <span class="star" data-rating="5" onclick="setRating(5)">★</span>
+ </div>
+ <div class="form-group" style="margin-top:12px;"><textarea class="form-textarea" id="repComment" placeholder="Optional comment..." rows="2"></textarea></div>
+ <button class="btn btn-primary btn-sm" onclick="submitReputation()">Submit Rating</button>
+ </div>
+ </div>
+ </div>
+
+ <!-- ═══ TEMPLATES TAB ═══ -->
+ <div id="tab-templates" class="hidden">
+ <div class="card">
+ <div class="card-header"><div><div class="card-title">Agent Templates</div><div class="card-subtitle">Pre-built configurations — one click to get started.</div></div></div>
+ <div class="template-grid" id="templateGrid"></div>
+ </div>
+ </div>
+
+ <!-- ═══ BATCH TAB ═══ -->
+ <div id="tab-batch" class="hidden">
+ <div class="card">
+ <div class="card-header"><div><div class="card-title">Batch Registration</div><div class="card-subtitle">Register multiple agents at once via CSV or JSON import.</div></div></div>
+ <div class="drop-zone" id="dropZone" onclick="document.getElementById('batchFile').click()" ondragover="event.preventDefault();this.classList.add('dragover')" ondragleave="this.classList.remove('dragover')" ondrop="handleBatchDrop(event)">
+ <div style="font-size:32px;margin-bottom:12px;">📁</div>
+ <div style="font-weight:600;margin-bottom:4px;">Drop CSV or JSON file here</div>
+ <div style="font-size:13px;color:var(--text-muted);">or click to browse</div>
+ <input type="file" id="batchFile" accept=".csv,.json" style="display:none;" onchange="handleBatchFile(this.files[0])" />
+ </div>
+ <div id="batchPreview" class="hidden" style="margin-top:24px;">
+ <div class="card-title" style="margin-bottom:12px;">Preview (<span id="batchCount">0</span> agents)</div>
+ <div id="batchList" style="max-height:400px;overflow-y:auto;"></div>
+ <div style="margin-top:16px;display:flex;gap:12px;">
+ <button class="btn btn-primary" onclick="executeBatch()">🚀 Register All</button>
+ <button class="btn btn-secondary" onclick="clearBatch()">Clear</button>
+ </div>
+ <div id="batchProgress" class="hidden" style="margin-top:16px;">
+ <div class="progress-bar"><div class="progress-fill" id="batchProgressBar" style="width:0%"></div></div>
+ <div style="font-size:13px;color:var(--text-muted);margin-top:4px;" id="batchStatus">Processing...</div>
+ </div>
+ </div>
+ <div style="margin-top:24px;">
+ <div class="collapsible" id="batchFormatCollapsible">
+ <div class="collapsible-header" onclick="toggleCollapsible('batchFormatCollapsible')"><span>📝 Format Guide</span><span class="collapsible-arrow">▼</span></div>
+ <div class="collapsible-content"><div class="collapsible-body">
+ <p style="font-size:13px;color:var(--text-secondary);margin-bottom:12px;"><strong>JSON format:</strong></p>
+ <pre class="review-json">[
+ {
+ "name": "Agent 1",
+ "description": "Description here",
+ "services": [{"name": "A2A", "endpoint": "https://..."}]
+ }
+]</pre>
+ <p style="font-size:13px;color:var(--text-secondary);margin:12px 0;"><strong>CSV format:</strong></p>
+ <pre class="review-json">name,description,serviceType,endpoint
+Agent 1,Does things,A2A,https://agent1.com
+Agent 2,Does more,MCP,https://agent2.com</pre>
+ </div></div>
+ </div>
+ </div>
+ </div>
+ </div>
+
+ <!-- ═══ HISTORY TAB ═══ -->
+ <div id="tab-history" class="hidden">
+ <div class="card">
+ <div class="card-header"><div><div class="card-title">Transaction History</div><div class="card-subtitle">Past registrations and updates on this chain.</div></div><button class="btn btn-secondary btn-sm" onclick="loadHistory()">↻ Refresh</button></div>
+ <div id="historyList"><div style="text-align:center;padding:40px;color:var(--text-muted);">Connect wallet to view transaction history.</div></div>
+ </div>
+ </div>
+ </main>
+
+ <!-- ═══ FOOTER ═══ -->
+ <footer class="footer">
+ <div class="container">
+ <div class="footer-links" style="margin-bottom:20px;">
+ <a href="https://www.8004.org" target="_blank" rel="noopener">ERC-8004 Spec</a>
+ <a href="https://github.com/erc-8004/erc-8004-contracts" target="_blank" rel="noopener">Contracts</a>
+ <a href="https://bnbchaintoolkit.com" target="_blank" rel="noopener">BNB Chain AI Toolkit</a>
+ <a href="https://github.com/nirholas/erc8004-agent-creator" target="_blank" rel="noopener">GitHub</a>
+ </div>
+ <div style="display:grid;grid-template-columns:repeat(auto-fit,minmax(200px,1fr));gap:24px;text-align:left;max-width:800px;margin:0 auto 24px;padding:24px 0;border-top:1px solid var(--border);border-bottom:1px solid var(--border);">
+ <div>
+ <div style="font-weight:600;color:var(--text-primary);margin-bottom:8px;font-size:12px;text-transform:uppercase;letter-spacing:1px;">Learn</div>
+ <a href="https://github.com/nirholas/erc8004-agent-creator/blob/main/docs/what-is-erc8004.md" target="_blank" rel="noopener" style="display:block;margin-bottom:4px;">What is ERC-8004?</a>
+ <a href="https://github.com/nirholas/erc8004-agent-creator/blob/main/docs/getting-started.md" target="_blank" rel="noopener" style="display:block;margin-bottom:4px;">Getting Started</a>
+ <a href="https://github.com/nirholas/erc8004-agent-creator/blob/main/docs/faq.md" target="_blank" rel="noopener" style="display:block;margin-bottom:4px;">FAQ</a>
+ <a href="https://github.com/nirholas/erc8004-agent-creator/blob/main/docs/troubleshooting.md" target="_blank" rel="noopener" style="display:block;margin-bottom:4px;">Troubleshooting</a>
+ </div>
+ <div>
+ <div style="font-weight:600;color:var(--text-primary);margin-bottom:8px;font-size:12px;text-transform:uppercase;letter-spacing:1px;">Build</div>
+ <a href="https://github.com/nirholas/erc8004-agent-creator/blob/main/docs/tutorials.md" target="_blank" rel="noopener" style="display:block;margin-bottom:4px;">Tutorials</a>
+ <a href="https://github.com/nirholas/erc8004-agent-creator/blob/main/docs/examples.md" target="_blank" rel="noopener" style="display:block;margin-bottom:4px;">Examples</a>
+ <a href="https://github.com/nirholas/erc8004-agent-creator/blob/main/docs/integration.md" target="_blank" rel="noopener" style="display:block;margin-bottom:4px;">Integration Guide</a>
+ <a href="https://github.com/nirholas/erc8004-agent-creator/blob/main/docs/contracts.md" target="_blank" rel="noopener" style="display:block;margin-bottom:4px;">Contract Addresses</a>
+ </div>
+ <div>
+ <div style="font-weight:600;color:var(--text-primary);margin-bottom:8px;font-size:12px;text-transform:uppercase;letter-spacing:1px;">Ecosystem</div>
+ <a href="https://github.com/nirholas/erc8004-agent-creator/blob/main/docs/architecture.md" target="_blank" rel="noopener" style="display:block;margin-bottom:4px;">Architecture</a>
+ <a href="https://github.com/nirholas/erc8004-agent-creator/tree/main/mcp-server" target="_blank" rel="noopener" style="display:block;margin-bottom:4px;">MCP Server</a>
+ <a href="https://github.com/nirholas/erc8004-agent-creator/tree/main/sdks" target="_blank" rel="noopener" style="display:block;margin-bottom:4px;">SDKs (Python, Go, Rust)</a>
+ <a href="https://github.com/nirholas/erc8004-agent-creator/tree/main/vscode-extension" target="_blank" rel="noopener" style="display:block;margin-bottom:4px;">VSCode Extension</a>
+ </div>
+ </div>
+ <p>Built by <a href="https://x.com/nichxbt" target="_blank" rel="noopener">nich</a> · Powered by <a href="https://www.8004.org" target="_blank" rel="noopener">ERC-8004</a></p>
+ </div>
+ </footer>
+ </div>
+
+ <div class="toast-container" id="toastContainer"></div>
+
+ <!-- ═══ QR Code Modal ═══ -->
+ <div id="qrModal" class="hidden" style="position:fixed;inset:0;background:rgba(0,0,0,0.6);z-index:500;display:flex;align-items:center;justify-content:center;" onclick="if(event.target===this)closeQrModal()">
+ <div class="card" style="max-width:400px;width:90%;">
+ <div class="card-header"><div class="card-title">Agent QR Code</div><button class="btn btn-ghost btn-sm" onclick="closeQrModal()">✕</button></div>
+ <div class="qr-container" id="qrContent"></div>
+ </div>
+ </div>
+
+ <!-- ═══ Agent Detail Modal ═══ -->
+ <div id="agentModal" class="hidden" style="position:fixed;inset:0;background:rgba(0,0,0,0.6);z-index:500;display:flex;align-items:center;justify-content:center;padding:24px;" onclick="if(event.target===this)closeAgentModal()">
+ <div class="card" style="max-width:600px;width:100%;max-height:80vh;overflow-y:auto;" id="agentModalContent"></div>
+ </div>
+
+
<script>
-const params = new URLSearchParams(location.search);
-const next = params.get('next') || '/dashboard/';
-const form = document.getElementById('f');
-const err = document.getElementById('err');
-const btn = document.getElementById('submit');
-form.addEventListener('submit', async (e) => {
- e.preventDefault();
- err.style.display = 'none';
- btn.disabled = true; btn.textContent = 'Creating…';
- try {
- const res = await fetch('/api/auth/register', {
- method: 'POST',
- credentials: 'include',
- headers: { 'content-type': 'application/json' },
- body: JSON.stringify({
- email: document.getElementById('email').value,
- password: document.getElementById('password').value,
- display_name: document.getElementById('name').value || undefined,
- }),
- });
- const data = await res.json();
- if (!res.ok) throw new Error(data.error_description || 'Sign-up failed');
- try { localStorage.setItem('3dagent:auth-hint', JSON.stringify({ authed: true, ts: Date.now() })); } catch { /* ignore */ }
- location.href = next;
- } catch (e) {
- err.textContent = e.message;
- err.style.display = 'block';
- btn.disabled = false; btn.textContent = 'Create account';
- }
+// ═══════════════════════════════════════════════════════════════════════
+// ERC-8004 AGENT CREATOR — Application Logic (v2.0 — Multi-Chain)
+// ═══════════════════════════════════════════════════════════════════════
+
+// ─── CHAIN CONFIGS ───
+const CHAIN_FAMILIES = [
+ { label: 'BNB Chain', chains: ['bsc-testnet','bsc-mainnet'] },
+ { label: 'Ethereum', chains: ['eth-sepolia','eth-mainnet'] },
+ { label: 'Base', chains: ['base-sepolia','base-mainnet'] },
+ { label: 'Arbitrum', chains: ['arb-sepolia','arb-mainnet'] },
+ { label: 'Optimism', chains: ['op-sepolia','op-mainnet'] },
+ { label: 'Polygon', chains: ['polygon-amoy','polygon-mainnet'] },
+ { label: 'Avalanche', chains: ['avax-fuji','avax-mainnet'] },
+ { label: 'Other L2s', chains: ['linea','scroll','zksync','mantle'] },
+ { label: 'Other L1s', chains: ['fantom','gnosis','celo','moonbeam'] },
+];
+
+const TESTNET_CONTRACTS = {
+ identity: '0x8004A818BFB912233c491871b3d84c89A494BD9e',
+ reputation: '0x8004B663056A597Dffe9eCcC1965A193B7388713',
+ validation: '0x8004Cb1BF31DAf7788923b405b754f57acEB4272'
+};
+const MAINNET_CONTRACTS = {
+ identity: '0x8004A169FB4a3325136EB29fA0ceB6D2e539a432',
+ reputation: '0x8004BAa17C55a88189AE136b182e5fdA19dE9b63',
+ validation: null
+};
+
+const CHAINS = {
+ 'bsc-testnet': { name:'BSC Testnet', chainId:97, chainIdHex:'0x61', rpcUrl:'https://data-seed-prebsc-1-s1.bnbchain.org:8545', explorer:'https://testnet.bscscan.com', currency:{name:'tBNB',symbol:'tBNB',decimals:18}, icon:'🟡', testnet:true, contracts:TESTNET_CONTRACTS, faucet:'https://www.bnbchain.org/en/testnet-faucet' },
+ 'bsc-mainnet': { name:'BSC Mainnet', chainId:56, chainIdHex:'0x38', rpcUrl:'https://bsc-dataseed.bnbchain.org', explorer:'https://bscscan.com', currency:{name:'BNB',symbol:'BNB',decimals:18}, icon:'🟡', testnet:false, contracts:MAINNET_CONTRACTS },
+ 'eth-sepolia': { name:'Ethereum Sepolia', chainId:11155111, chainIdHex:'0xaa36a7', rpcUrl:'https://rpc.sepolia.org', explorer:'https://sepolia.etherscan.io', currency:{name:'SepoliaETH',symbol:'ETH',decimals:18}, icon:'🔷', testnet:true, contracts:TESTNET_CONTRACTS, faucet:'https://sepoliafaucet.com' },
+ 'eth-mainnet': { name:'Ethereum Mainnet', chainId:1, chainIdHex:'0x1', rpcUrl:'https://eth.llamarpc.com', explorer:'https://etherscan.io', currency:{name:'ETH',symbol:'ETH',decimals:18}, icon:'🔷', testnet:false, contracts:MAINNET_CONTRACTS },
+ 'base-sepolia': { name:'Base Sepolia', chainId:84532, chainIdHex:'0x14a34', rpcUrl:'https://sepolia.base.org', explorer:'https://sepolia.basescan.org', currency:{name:'ETH',symbol:'ETH',decimals:18}, icon:'🔵', testnet:true, contracts:TESTNET_CONTRACTS, faucet:'https://www.coinbase.com/faucets/base-ethereum-goerli-faucet' },
+ 'base-mainnet': { name:'Base', chainId:8453, chainIdHex:'0x2105', rpcUrl:'https://mainnet.base.org', explorer:'https://basescan.org', currency:{name:'ETH',symbol:'ETH',decimals:18}, icon:'🔵', testnet:false, contracts:MAINNET_CONTRACTS },
+ 'arb-sepolia': { name:'Arbitrum Sepolia', chainId:421614, chainIdHex:'0x66eee', rpcUrl:'https://sepolia-rollup.arbitrum.io/rpc', explorer:'https://sepolia.arbiscan.io', currency:{name:'ETH',symbol:'ETH',decimals:18}, icon:'🌀', testnet:true, contracts:TESTNET_CONTRACTS },
+ 'arb-mainnet': { name:'Arbitrum One', chainId:42161, chainIdHex:'0xa4b1', rpcUrl:'https://arb1.arbitrum.io/rpc', explorer:'https://arbiscan.io', currency:{name:'ETH',symbol:'ETH',decimals:18}, icon:'🌀', testnet:false, contracts:MAINNET_CONTRACTS },
+ 'op-sepolia': { name:'Optimism Sepolia', chainId:11155420, chainIdHex:'0xa045c4', rpcUrl:'https://sepolia.optimism.io', explorer:'https://sepolia-optimistic.etherscan.io', currency:{name:'ETH',symbol:'ETH',decimals:18}, icon:'🔴', testnet:true, contracts:TESTNET_CONTRACTS },
+ 'op-mainnet': { name:'Optimism', chainId:10, chainIdHex:'0xa', rpcUrl:'https://mainnet.optimism.io', explorer:'https://optimistic.etherscan.io', currency:{name:'ETH',symbol:'ETH',decimals:18}, icon:'🔴', testnet:false, contracts:MAINNET_CONTRACTS },
+ 'polygon-amoy': { name:'Polygon Amoy', chainId:80002, chainIdHex:'0x13882', rpcUrl:'https://rpc-amoy.polygon.technology', explorer:'https://amoy.polygonscan.com', currency:{name:'POL',symbol:'POL',decimals:18}, icon:'🟣', testnet:true, contracts:TESTNET_CONTRACTS, faucet:'https://faucet.polygon.technology' },
+ 'polygon-mainnet':{ name:'Polygon', chainId:137, chainIdHex:'0x89', rpcUrl:'https://polygon-rpc.com', explorer:'https://polygonscan.com', currency:{name:'POL',symbol:'POL',decimals:18}, icon:'🟣', testnet:false, contracts:MAINNET_CONTRACTS },
+ 'avax-fuji': { name:'Avalanche Fuji', chainId:43113, chainIdHex:'0xa869', rpcUrl:'https://api.avax-test.network/ext/bc/C/rpc', explorer:'https://testnet.snowtrace.io', currency:{name:'AVAX',symbol:'AVAX',decimals:18}, icon:'🔺', testnet:true, contracts:TESTNET_CONTRACTS, faucet:'https://faucet.avax.network' },
+ 'avax-mainnet': { name:'Avalanche C-Chain', chainId:43114, chainIdHex:'0xa86a', rpcUrl:'https://api.avax.network/ext/bc/C/rpc', explorer:'https://snowtrace.io', currency:{name:'AVAX',symbol:'AVAX',decimals:18}, icon:'🔺', testnet:false, contracts:MAINNET_CONTRACTS },
+ 'linea': { name:'Linea', chainId:59144, chainIdHex:'0xe708', rpcUrl:'https://rpc.linea.build', explorer:'https://lineascan.build', currency:{name:'ETH',symbol:'ETH',decimals:18}, icon:'🟢', testnet:false, contracts:MAINNET_CONTRACTS },
+ 'scroll': { name:'Scroll', chainId:534352, chainIdHex:'0x82750', rpcUrl:'https://rpc.scroll.io', explorer:'https://scrollscan.com', currency:{name:'ETH',symbol:'ETH',decimals:18}, icon:'📜', testnet:false, contracts:MAINNET_CONTRACTS },
+ 'zksync': { name:'zkSync Era', chainId:324, chainIdHex:'0x144', rpcUrl:'https://mainnet.era.zksync.io', explorer:'https://explorer.zksync.io', currency:{name:'ETH',symbol:'ETH',decimals:18}, icon:'⚡', testnet:false, contracts:MAINNET_CONTRACTS },
+ 'mantle': { name:'Mantle', chainId:5000, chainIdHex:'0x1388', rpcUrl:'https://rpc.mantle.xyz', explorer:'https://explorer.mantle.xyz', currency:{name:'MNT',symbol:'MNT',decimals:18}, icon:'🟠', testnet:false, contracts:MAINNET_CONTRACTS },
+ 'fantom': { name:'Fantom', chainId:250, chainIdHex:'0xfa', rpcUrl:'https://rpc.ftm.tools', explorer:'https://ftmscan.com', currency:{name:'FTM',symbol:'FTM',decimals:18}, icon:'👻', testnet:false, contracts:MAINNET_CONTRACTS },
+ 'gnosis': { name:'Gnosis', chainId:100, chainIdHex:'0x64', rpcUrl:'https://rpc.gnosischain.com', explorer:'https://gnosisscan.io', currency:{name:'xDAI',symbol:'xDAI',decimals:18}, icon:'🦉', testnet:false, contracts:MAINNET_CONTRACTS },
+ 'celo': { name:'Celo', chainId:42220, chainIdHex:'0xa4ec', rpcUrl:'https://forno.celo.org', explorer:'https://celoscan.io', currency:{name:'CELO',symbol:'CELO',decimals:18}, icon:'🌿', testnet:false, contracts:MAINNET_CONTRACTS },
+ 'moonbeam': { name:'Moonbeam', chainId:1284, chainIdHex:'0x504', rpcUrl:'https://rpc.api.moonbeam.network', explorer:'https://moonbeam.moonscan.io', currency:{name:'GLMR',symbol:'GLMR',decimals:18}, icon:'🌙', testnet:false, contracts:MAINNET_CONTRACTS },
+};
+
+// ─── ABIs ───
+const IDENTITY_ABI = [
+ "function register() external returns (uint256 agentId)",
+ "function register(string agentURI) external returns (uint256 agentId)",
+ "function register(string agentURI, tuple(string metadataKey, bytes metadataValue)[] metadata) external returns (uint256 agentId)",
+ "function setAgentURI(uint256 agentId, string newURI) external",
+ "function setMetadata(uint256 agentId, string metadataKey, bytes metadataValue) external",
+ "function getMetadata(uint256 agentId, string metadataKey) external view returns (bytes)",
+ "function getAgentWallet(uint256 agentId) external view returns (address)",
+ "function tokenURI(uint256 tokenId) external view returns (string)",
+ "function ownerOf(uint256 tokenId) external view returns (address)",
+ "function balanceOf(address owner) external view returns (uint256)",
+ "function getVersion() external pure returns (string)",
+ "function name() external view returns (string)",
+ "function symbol() external view returns (string)",
+ "event Registered(uint256 indexed agentId, string agentURI, address indexed owner)",
+ "event Transfer(address indexed from, address indexed to, uint256 indexed tokenId)"
+];
+const REPUTATION_ABI = [
+ "function submitReputation(uint256 agentId, uint8 score, string comment) external",
+ "function getReputation(uint256 agentId) external view returns (uint256 totalScore, uint256 count)",
+ "event ReputationSubmitted(uint256 indexed agentId, address indexed submitter, uint8 score, string comment)"
+];
+
+// ─── AGENT TEMPLATES ───
+const TEMPLATES = [
+ { id: 'defi-trading', icon: '📈', name: 'DeFi Trading Agent', desc: 'Automated DeFi yield optimization, liquidity management, and token swaps across protocols.', data: { name:'DeFi Trading Agent', description:'Automated DeFi yield optimization agent. Monitors liquidity pools, executes token swaps, manages yield farming positions, and provides real-time market analysis across multiple DEXs.', services:[{name:'A2A',endpoint:'https://agent.example/.well-known/agent-card.json',version:'0.3.0'},{name:'web',endpoint:'https://defi-agent.example/'}], trust:['reputation','crypto-economic'], x402:true, metadata:[{key:'category',value:'DeFi'},{key:'pricing',value:'0.001 ETH/request'}] }},
+ { id: 'customer-support', icon: '🎧', name: 'Customer Support Bot', desc: 'AI-powered support agent for handling tickets, FAQ queries, and multi-language communication.', data: { name:'Customer Support Bot', description:'AI-powered customer support agent. Handles support tickets, answers FAQs, provides multi-language support, and escalates complex issues to human agents.', services:[{name:'A2A',endpoint:'https://support.example/.well-known/agent-card.json'},{name:'web',endpoint:'https://support.example/chat'}], trust:['reputation'], x402:false, metadata:[{key:'category',value:'Support'},{key:'languages',value:'en,es,fr,de,zh'}] }},
+ { id: 'code-review', icon: '🔍', name: 'Code Review Agent', desc: 'Automated code analysis, security auditing, gas optimization, and best practice enforcement.', data: { name:'Code Review Agent', description:'Automated code review agent specializing in Solidity smart contracts. Performs security audits, gas optimization analysis, and best practice enforcement for EVM-compatible code.', services:[{name:'MCP',endpoint:'https://codereview.example/mcp',version:'2025-06-18'},{name:'A2A',endpoint:'https://codereview.example/.well-known/agent-card.json'}], trust:['reputation','tee-attestation'], x402:true, metadata:[{key:'category',value:'Development'},{key:'languages',value:'solidity,rust,typescript'}] }},
+ { id: 'data-analysis', icon: '📊', name: 'Data Analysis Agent', desc: 'On-chain and off-chain data analysis, reporting, visualization, and pattern recognition.', data: { name:'Data Analysis Agent', description:'Comprehensive data analysis agent for blockchain analytics. Processes on-chain data, generates reports, creates visualizations, and identifies patterns in DeFi activity.', services:[{name:'MCP',endpoint:'https://analytics.example/mcp'},{name:'web',endpoint:'https://analytics.example/dashboard'}], trust:['reputation'], x402:true, metadata:[{key:'category',value:'Analytics'},{key:'pricing',value:'0.0005 ETH/query'}] }},
+ { id: 'content-creator', icon: '✍️', name: 'Content Creator', desc: 'AI content generation for social media, documentation, technical writing, and marketing.', data: { name:'Content Creator Agent', description:'AI content generation agent for Web3 projects. Creates social media posts, technical documentation, blog articles, and marketing copy with SEO optimization.', services:[{name:'A2A',endpoint:'https://content.example/.well-known/agent-card.json'}], trust:['reputation'], x402:true, metadata:[{key:'category',value:'Content'},{key:'formats',value:'text,markdown,html'}] }},
+ { id: 'research-assistant', icon: '🔬', name: 'Research Assistant', desc: 'Deep research on protocols, tokens, governance proposals, and market trends.', data: { name:'Research Assistant', description:'Deep research agent for Web3 ecosystem analysis. Investigates protocols, analyzes tokenomics, reviews governance proposals, and tracks market trends with sourced citations.', services:[{name:'MCP',endpoint:'https://research.example/mcp',version:'2025-06-18'},{name:'A2A',endpoint:'https://research.example/.well-known/agent-card.json'}], trust:['reputation','tee-attestation'], x402:false, metadata:[{key:'category',value:'Research'}] }},
+];
+
+// ─── STATE ───
+let currentChain = 'bsc-testnet';
+let currentStep = 1;
+let provider = null;
+let signer = null;
+let userAddress = null;
+let identityContract = null;
+let reputationContract = null;
+let uriMethod = 'onchain';
+let serviceCounter = 0;
+let metadataCounter = 0;
+let currentRating = 0;
+let searchFilter = 'all';
+let batchAgents = [];
+let txHistory = JSON.parse(localStorage.getItem('erc8004_history') || '[]');
+let discoveredWallets = [];
+
+// ─── INIT ───
+document.addEventListener('DOMContentLoaded', () => {
+ addService();
+ renderChainDropdown();
+ renderTemplates();
+ renderWalletArea();
+ fetchAgentCount();
+ updateThemeIcon();
+ detectWallets();
+
+ // EIP-6963 wallet detection
+ window.addEventListener('eip6963:announceProvider', (event) => {
+ discoveredWallets.push({ info: event.detail.info, provider: event.detail.provider });
+ renderWalletPicker();
+ });
+ window.dispatchEvent(new Event('eip6963:requestProvider'));
+
+ // Watch x402 toggle
+ const x402Toggle = document.getElementById('x402Toggle');
+ const observer = new MutationObserver(() => {
+ document.getElementById('x402Fields').classList.toggle('hidden', !x402Toggle.classList.contains('checked'));
+ });
+ observer.observe(x402Toggle, { attributes: true, attributeFilter: ['class'] });
});
+
+// ─── THEME ───
+function toggleTheme() {
+ const html = document.documentElement;
+ const current = html.getAttribute('data-theme');
+ html.setAttribute('data-theme', current === 'dark' ? 'light' : 'dark');
+ localStorage.setItem('erc8004_theme', html.getAttribute('data-theme'));
+ updateThemeIcon();
+}
+function updateThemeIcon() {
+ const isDark = document.documentElement.getAttribute('data-theme') === 'dark';
+ document.getElementById('themeBtn').textContent = isDark ? '🌙' : '☀️';
+}
+// Restore theme
+(function() {
+ const saved = localStorage.getItem('erc8004_theme');
+ if (saved) document.documentElement.setAttribute('data-theme', saved);
+})();
+
+// ─── TOAST ───
+function showToast(message, type = 'info') {
+ const container = document.getElementById('toastContainer');
+ const toast = document.createElement('div');
+ toast.className = 'toast ' + type;
+ toast.textContent = message;
+ container.appendChild(toast);
+ setTimeout(() => { toast.style.opacity = '0'; toast.style.transform = 'translateX(50px)'; toast.style.transition = 'all 300ms ease-in'; setTimeout(() => toast.remove(), 300); }, 4000);
+}
+
+// ─── WALLET DETECTION ───
+function detectWallets() {
+ // Detect injected wallets
+ if (window.ethereum) {
+ if (window.ethereum.isMetaMask) discoveredWallets.push({ info: { name: 'MetaMask', icon: '' }, provider: window.ethereum });
+ else if (window.ethereum.isCoinbaseWallet) discoveredWallets.push({ info: { name: 'Coinbase Wallet', icon: '' }, provider: window.ethereum });
+ else if (window.ethereum.isRabby) discoveredWallets.push({ info: { name: 'Rabby', icon: '' }, provider: window.ethereum });
+ else if (window.ethereum.isBraveWallet) discoveredWallets.push({ info: { name: 'Brave Wallet', icon: '' }, provider: window.ethereum });
+ else if (window.ethereum.isRainbow) discoveredWallets.push({ info: { name: 'Rainbow', icon: '' }, provider: window.ethereum });
+ else discoveredWallets.push({ info: { name: 'Browser Wallet', icon: '' }, provider: window.ethereum });
+ }
+ // Check for multiple providers
+ if (window.ethereum && window.ethereum.providers) {
+ window.ethereum.providers.forEach(p => {
+ const name = p.isMetaMask ? 'MetaMask' : p.isCoinbaseWallet ? 'Coinbase Wallet' : p.isRainbow ? 'Rainbow' : 'Wallet';
+ if (!discoveredWallets.find(w => w.info.name === name)) {
+ discoveredWallets.push({ info: { name, icon: '' }, provider: p });
+ }
+ });
+ }
+ renderWalletPicker();
+}
+
+function renderWalletPicker() {
+ const list = document.getElementById('walletList');
+ if (!list) return;
+ if (discoveredWallets.length <= 1) { list.innerHTML = ''; return; }
+ list.innerHTML = discoveredWallets.map((w, i) => `
+ <div class="wallet-option" onclick="connectWithProvider(${i})">
+ <div class="wallet-icon-placeholder" style="background:var(--accent-dim);display:flex;align-items:center;justify-content:center;font-size:16px;">🔗</div>
+ ${escapeHtml(w.info.name)}
+ </div>
+ `).join('');
+}
+
+// ─── WALLET CONNECTION ───
+async function connectWallet() {
+ if (!window.ethereum) {
+ showToast('No wallet detected. Install MetaMask or another Web3 wallet.', 'error');
+ window.open('https://metamask.io/download/', '_blank');
+ return;
+ }
+ if (discoveredWallets.length > 1) {
+ document.getElementById('walletPicker').classList.toggle('hidden');
+ return;
+ }
+ await connectWithProvider(0);
+}
+
+async function connectWithProvider(index) {
+ const wallet = discoveredWallets[index] || { provider: window.ethereum };
+ const wp = wallet.provider || window.ethereum;
+ try {
+ const accounts = await wp.request({ method: 'eth_requestAccounts' });
+ if (!accounts || !accounts.length) { showToast('No accounts found.', 'error'); return; }
+ userAddress = accounts[0];
+ provider = new ethers.BrowserProvider(wp);
+ signer = await provider.getSigner();
+ await ensureNetwork();
+ provider = new ethers.BrowserProvider(wp);
+ signer = await provider.getSigner();
+ setupContracts();
+ renderWalletArea();
+ updateUIForConnected();
+ updateMainnetWarning();
+ showToast('Wallet connected!', 'success');
+ document.getElementById('walletPicker').classList.add('hidden');
+ wp.on('accountsChanged', handleAccountsChanged);
+ wp.on('chainChanged', () => location.reload());
+ } catch (err) {
+ if (err.code === 4001) showToast('Connection rejected.', 'error');
+ else showToast('Connection failed: ' + (err.message || err), 'error');
+ }
+}
+
+function setupContracts() {
+ const chain = CHAINS[currentChain];
+ identityContract = new ethers.Contract(chain.contracts.identity, IDENTITY_ABI, signer);
+ if (chain.contracts.reputation) {
+ reputationContract = new ethers.Contract(chain.contracts.reputation, REPUTATION_ABI, signer);
+ }
+}
+
+async function handleAccountsChanged(accounts) {
+ if (!accounts.length) { disconnectWallet(); return; }
+ userAddress = accounts[0];
+ signer = await provider.getSigner();
+ setupContracts();
+ renderWalletArea();
+}
+
+async function ensureNetwork() {
+ const chain = CHAINS[currentChain];
+ try {
+ await window.ethereum.request({ method: 'wallet_switchEthereumChain', params: [{ chainId: chain.chainIdHex }] });
+ } catch (err) {
+ if (err.code === 4902) {
+ await window.ethereum.request({ method: 'wallet_addEthereumChain', params: [{ chainId: chain.chainIdHex, chainName: chain.name, nativeCurrency: chain.currency, rpcUrls: [chain.rpcUrl], blockExplorerUrls: [chain.explorer] }] });
+ } else throw err;
+ }
+}
+
+function renderWalletArea() {
+ const area = document.getElementById('walletArea');
+ if (userAddress) {
+ const short = userAddress.slice(0, 6) + '...' + userAddress.slice(-4);
+ area.innerHTML = '<div class="wallet-actions"><div class="wallet-connected"><span class="wallet-dot"></span>' + short + '</div><button class="btn-disconnect" onclick="disconnectWallet()">✕</button></div>';
+ } else {
+ area.innerHTML = '<button class="btn btn-primary btn-sm" onclick="connectWallet()">Connect Wallet</button>';
+ }
+}
+
+function disconnectWallet() {
+ userAddress = null; signer = null; identityContract = null; reputationContract = null;
+ renderWalletArea(); updateUIForDisconnected(); showToast('Wallet disconnected.', 'info');
+}
+
+function updateUIForConnected() {
+ document.getElementById('connectPrompt').classList.add('hidden');
+ document.getElementById('wizardSection').classList.remove('hidden');
+ document.getElementById('dashboardConnectPrompt').classList.add('hidden');
+ document.getElementById('dashboardAgents').classList.remove('hidden');
+ loadMyAgents();
+}
+
+function updateUIForDisconnected() {
+ document.getElementById('connectPrompt').classList.remove('hidden');
+ document.getElementById('wizardSection').classList.add('hidden');
+ document.getElementById('dashboardConnectPrompt').classList.remove('hidden');
+ document.getElementById('dashboardAgents').classList.add('hidden');
+}
+
+// ─── CHAIN SELECTOR ───
+function renderChainDropdown() {
+ const list = document.getElementById('chainList');
+ let html = '';
+ CHAIN_FAMILIES.forEach(family => {
+ html += '<div class="chain-group-label">' + family.label + '</div>';
+ family.chains.forEach(key => {
+ const c = CHAINS[key];
+ if (!c) return;
+ const isActive = key === currentChain;
+ html += '<div class="chain-option' + (isActive ? ' active' : '') + '" data-chain="' + key + '" onclick="selectChain(\'' + key + '\')">';
+ html += '<span style="font-size:16px;">' + c.icon + '</span>';
+ html += '<span class="chain-name">' + c.name + '</span>';
+ html += '<span class="chain-type ' + (c.testnet ? 'testnet' : 'mainnet') + '">' + (c.testnet ? 'Testnet' : 'Mainnet') + '</span>';
+ html += '</div>';
+ });
+ });
+ list.innerHTML = html;
+ updateChainDisplay();
+}
+
+function toggleChainDropdown() {
+ const dd = document.getElementById('chainDropdown');
+ const btn = document.getElementById('chainBtn');
+ dd.classList.toggle('open');
+ btn.classList.toggle('open');
+ if (dd.classList.contains('open')) {
+ document.getElementById('chainSearchInput').focus();
+ setTimeout(() => document.addEventListener('click', closeChainDropdownOutside), 0);
+ }
+}
+
+function closeChainDropdownOutside(e) {
+ const sel = document.getElementById('chainSelector');
+ if (!sel.contains(e.target)) {
+ document.getElementById('chainDropdown').classList.remove('open');
+ document.getElementById('chainBtn').classList.remove('open');
+ document.removeEventListener('click', closeChainDropdownOutside);
+ }
+}
+
+function filterChains(query) {
+ const q = query.toLowerCase();
+ document.querySelectorAll('.chain-option').forEach(opt => {
+ const name = opt.querySelector('.chain-name').textContent.toLowerCase();
+ opt.style.display = name.includes(q) ? '' : 'none';
+ });
+ document.querySelectorAll('.chain-group-label').forEach(label => {
+ let next = label.nextElementSibling;
+ let hasVisible = false;
+ while (next && !next.classList.contains('chain-group-label')) {
+ if (next.style.display !== 'none') hasVisible = true;
+ next = next.nextElementSibling;
+ }
+ label.style.display = hasVisible ? '' : 'none';
+ });
+}
+
+async function selectChain(key) {
+ currentChain = key;
+ document.getElementById('chainDropdown').classList.remove('open');
+ document.getElementById('chainBtn').classList.remove('open');
+ document.getElementById('chainSearchInput').value = '';
+ filterChains('');
+ renderChainDropdown();
+ updateMainnetWarning();
+ if (userAddress) {
+ try { await ensureNetwork(); } catch(e) { showToast('Failed to switch network.', 'error'); }
+ provider = new ethers.BrowserProvider(window.ethereum);
+ signer = await provider.getSigner();
+ setupContracts();
+ loadMyAgents();
+ }
+ fetchAgentCount();
+}
+
+function updateChainDisplay() {
+ const c = CHAINS[currentChain];
+ document.getElementById('chainIconDisplay').textContent = c.icon;
+ document.getElementById('chainNameDisplay').textContent = c.name;
+ const dot = document.getElementById('chainDotDisplay');
+ dot.className = 'chain-dot ' + (c.testnet ? 'testnet' : 'mainnet');
+}
+
+function updateMainnetWarning() {
+ const banner = document.getElementById('mainnetBanner');
+ const chain = CHAINS[currentChain];
+ if (!chain.testnet) {
+ banner.innerHTML = '<div class="mainnet-warning" style="margin:0 auto;max-width:960px;margin:8px 24px;"><span style="flex-shrink:0;">⚠️</span><div><strong>Mainnet Mode</strong> — Transactions use real ' + chain.currency.symbol + '. Use a testnet first to test.</div></div>';
+ } else {
+ banner.innerHTML = '';
+ }
+}
+
+// ─── TAB SWITCHING ───
+function switchTab(tab) {
+ document.querySelectorAll('.tab').forEach(t => t.classList.toggle('active', t.dataset.tab === tab));
+ ['create','dashboard','search','templates','batch','history'].forEach(t => {
+ const el = document.getElementById('tab-' + t);
+ if (el) el.classList.toggle('hidden', t !== tab);
+ });
+ if (tab === 'dashboard' && userAddress) loadMyAgents();
+ if (tab === 'history') loadHistory();
+}
+
+// ─── STEPPER ───
+function goToStep(step) {
+ if (step > currentStep) {
+ if (currentStep === 1 && !validateStep1()) return;
+ if (currentStep === 2 && !validateStep2()) return;
+ }
+ currentStep = step;
+ for (let i = 1; i <= 4; i++) document.getElementById('step' + i).classList.toggle('hidden', i !== step);
+ document.getElementById('deployResult').classList.add('hidden');
+ document.querySelectorAll('.step').forEach(s => {
+ const sn = parseInt(s.dataset.step);
+ s.classList.remove('active', 'completed');
+ if (sn === step) s.classList.add('active');
+ else if (sn < step) s.classList.add('completed');
+ });
+ document.querySelectorAll('.step-line').forEach((line, i) => line.classList.toggle('completed', i < step - 1));
+ if (step === 4) { populateReview(); estimateGas(); }
+ window.scrollTo({ top: 200, behavior: 'smooth' });
+}
+
+function validateStep1() {
+ if (!document.getElementById('agentName').value.trim()) { showToast('Agent name is required.', 'error'); return false; }
+ if (!document.getElementById('agentDescription').value.trim()) { showToast('Agent description is required.', 'error'); return false; }
+ return true;
+}
+
+function validateStep2() {
+ let has = false;
+ document.querySelectorAll('.service-entry').forEach(e => { if (e.querySelector('[data-field="endpoint"]').value.trim()) has = true; });
+ if (!has) { showToast('Add at least one service endpoint.', 'error'); return false; }
+ return true;
+}
+
+// ─── GAS ESTIMATION ───
+async function estimateGas() {
+ const el = document.getElementById('reviewGas');
+ if (!signer || !identityContract) { el.innerHTML = '<span style="color:var(--text-muted);">Connect wallet to estimate</span>'; return; }
+ el.innerHTML = '<span class="gas-estimate"><span class="spinner-sm"></span> Estimating...</span>';
+ try {
+ const json = buildRegistrationJson();
+ const uri = buildAgentUri(json);
+ const metadata = getMetadataEntries();
+ let gasEst;
+ if (metadata.length > 0) {
+ const mt = metadata.map(m => ({ metadataKey: m.key, metadataValue: ethers.toUtf8Bytes(m.value) }));
+ gasEst = await identityContract['register(string,(string,bytes)[])'].estimateGas(uri, mt);
+ } else if (uri) gasEst = await identityContract['register(string)'].estimateGas(uri);
+ else gasEst = await identityContract['register()'].estimateGas();
+ const feeData = await provider.getFeeData();
+ const gp = feeData.gasPrice || feeData.maxFeePerGas;
+ const cost = ethers.formatEther(gasEst * gp);
+ el.innerHTML = '<span class="gas-estimate"><span class="gas-estimate-value">~' + parseFloat(cost).toFixed(6) + ' ' + CHAINS[currentChain].currency.symbol + '</span> <span style="color:var(--text-muted);">(' + Number(gasEst).toLocaleString() + ' gas)</span></span>';
+ } catch (err) {
+ el.innerHTML = '<span style="color:var(--text-muted);">Could not estimate — calculated on submit</span>';
+ }
+}
+
+// ─── SERVICE MANAGEMENT ───
+function addService() {
+ serviceCounter++;
+ const id = serviceCounter;
+ const list = document.getElementById('serviceList');
+ const entry = document.createElement('div');
+ entry.className = 'service-entry';
+ entry.id = 'service-' + id;
+ entry.innerHTML = '<select class="form-select" onchange="updateServicePlaceholder(' + id + ')"><option value="web">Web</option><option value="A2A">A2A</option><option value="MCP">MCP</option><option value="OASF">OASF</option><option value="ENS">ENS</option><option value="DID">DID</option><option value="email">Email</option><option value="custom">Custom</option></select><input class="form-input" type="text" placeholder="https://your-agent.com/" data-field="endpoint" /><input class="form-input" type="text" placeholder="Version" data-field="version" style="font-size:12px;" /><button class="btn-remove" onclick="removeService(' + id + ')">×</button>';
+ list.appendChild(entry);
+}
+function removeService(id) { const el = document.getElementById('service-' + id); if (el) el.remove(); }
+function updateServicePlaceholder(id) {
+ const entry = document.getElementById('service-' + id);
+ const type = entry.querySelector('select').value;
+ const ep = entry.querySelector('[data-field="endpoint"]');
+ const ph = { web:'https://your-agent.com/', A2A:'https://agent.example/.well-known/agent-card.json', MCP:'https://mcp.your-agent.com/', OASF:'ipfs://{cid}', ENS:'yourname.eth', DID:'did:method:identifier', email:'[email protected]', custom:'https://...' };
+ ep.placeholder = ph[type] || 'https://...';
+}
+
+// ─── METADATA ───
+function addMetadata() {
+ metadataCounter++;
+ const id = metadataCounter;
+ const list = document.getElementById('metadataList');
+ const entry = document.createElement('div');
+ entry.className = 'metadata-entry'; entry.id = 'metadata-' + id;
+ entry.innerHTML = '<input class="form-input" type="text" placeholder="Key" data-field="key" style="font-size:13px;" /><input class="form-input" type="text" placeholder="Value" data-field="value" style="font-size:13px;" /><button class="btn-remove" onclick="removeMetadata(' + id + ')">×</button>';
+ list.appendChild(entry);
+}
+function addMetadataPreset(key, value) {
+ addMetadata();
+ const entry = document.getElementById('metadata-' + metadataCounter);
+ entry.querySelector('[data-field="key"]').value = key;
+ entry.querySelector('[data-field="value"]').value = value;
+}
+function removeMetadata(id) { const el = document.getElementById('metadata-' + id); if (el) el.remove(); }
+
+// ─── CHECKBOX / URI / COLLAPSIBLE ───
+function toggleCheck(el) { el.classList.toggle('checked'); const cb = el.querySelector('input[type="checkbox"]'); cb.checked = !cb.checked; }
+function selectUriOption(method) {
+ uriMethod = method;
+ document.querySelectorAll('.uri-option').forEach(o => o.classList.toggle('active', o.dataset.uri === method));
+ document.getElementById('customUriField').classList.toggle('hidden', method === 'onchain');
+ if (method === 'ipfs') document.getElementById('customUri').placeholder = 'ipfs://Qm...';
+ else if (method === 'https') document.getElementById('customUri').placeholder = 'https://example.com/agent.json';
+}
+function toggleCollapsible(id) {
+ const el = typeof id === 'string' ? document.getElementById(id) : id;
+ if (el) el.classList.toggle('open');
+}
+
+// ─── BUILD JSON ───
+function buildRegistrationJson() {
+ const name = document.getElementById('agentName').value.trim();
+ const description = document.getElementById('agentDescription').value.trim();
+ const image = document.getElementById('agentImage').value.trim();
+ const chain = CHAINS[currentChain];
+ const services = [];
+ document.querySelectorAll('.service-entry').forEach(entry => {
+ const type = entry.querySelector('select').value;
+ const endpoint = entry.querySelector('[data-field="endpoint"]').value.trim();
+ const version = entry.querySelector('[data-field="version"]').value.trim();
+ if (endpoint) { const svc = { name: type, endpoint }; if (version) svc.version = version; services.push(svc); }
+ });
+ const supportedTrust = [];
+ document.querySelectorAll('#trustModels .checkbox-item.checked input').forEach(cb => supportedTrust.push(cb.value));
+ const x402 = document.getElementById('x402Toggle').classList.contains('checked');
+ const json = {
+ type: "https://eips.ethereum.org/EIPS/eip-8004#registration-v1",
+ name, description, services, x402Support: x402, active: true,
+ registrations: [{ agentId: "PENDING", agentRegistry: 'eip155:' + chain.chainId + ':' + chain.contracts.identity }],
+ };
+ if (image) json.image = image;
+ if (supportedTrust.length > 0) json.supportedTrust = supportedTrust;
+ if (x402) {
+ const ep = document.getElementById('x402Endpoint').value.trim();
+ const price = document.getElementById('x402Price').value.trim();
+ const tokens = document.getElementById('x402Tokens').value.trim();
+ if (ep || price || tokens) {
+ json.x402 = {};
+ if (ep) json.x402.paymentEndpoint = ep;
+ if (price) json.x402.pricePerRequest = price;
+ if (tokens) json.x402.acceptedTokens = tokens.split(',').map(t => t.trim());
+ }
+ }
+ return json;
+}
+
+function buildAgentUri(json) {
+ if (uriMethod === 'onchain') {
+ const str = JSON.stringify(json);
+ return 'data:application/json;base64,' + btoa(unescape(encodeURIComponent(str)));
+ }
+ return document.getElementById('customUri').value.trim();
+}
+
+function getMetadataEntries() {
+ const entries = [];
+ document.querySelectorAll('.metadata-entry').forEach(entry => {
+ const key = entry.querySelector('[data-field="key"]').value.trim();
+ const value = entry.querySelector('[data-field="value"]').value.trim();
+ if (key && value) entries.push({ key, value });
+ });
+ return entries;
+}
+
+// ─── REVIEW ───
+function populateReview() {
+ const json = buildRegistrationJson();
+ document.getElementById('reviewJson').textContent = JSON.stringify(json, null, 2);
+ const uri = buildAgentUri(json);
+ document.getElementById('reviewUri').textContent = uriMethod === 'onchain' ? 'data:application/json;base64,... (' + uri.length + ' chars, fully on-chain)' : uri;
+ const chain = CHAINS[currentChain];
+ document.getElementById('reviewNetwork').textContent = chain.name + ' (Chain ID: ' + chain.chainId + ')';
+ document.getElementById('reviewContract').textContent = chain.contracts.identity;
+ const metadata = getMetadataEntries();
+ const metaSection = document.getElementById('reviewMetadataSection');
+ const metaDiv = document.getElementById('reviewMetadata');
+ if (metadata.length > 0) {
+ metaSection.classList.remove('hidden');
+ metaDiv.innerHTML = metadata.map(m => '<div class="tx-detail-row"><span class="tx-detail-label">' + escapeHtml(m.key) + '</span><span class="tx-detail-value">' + escapeHtml(m.value) + '</span></div>').join('');
+ } else metaSection.classList.add('hidden');
+}
+
+// ─── DEPLOY ───
+async function deployAgent() {
+ if (!signer || !identityContract) { showToast('Connect your wallet first.', 'error'); return; }
+ const chain = CHAINS[currentChain];
+ if (!chain.testnet && !confirm('You are deploying to ' + chain.name + '. This will cost real ' + chain.currency.symbol + '. Continue?')) return;
+ const btn = document.getElementById('deployBtn');
+ btn.disabled = true; btn.innerHTML = '<span class="spinner"></span> Registering...';
+ try {
+ await ensureNetwork();
+ const json = buildRegistrationJson();
+ const uri = buildAgentUri(json);
+ const metadata = getMetadataEntries();
+ if (!uri && uriMethod !== 'onchain') { showToast('Please provide an agent URI.', 'error'); btn.disabled = false; btn.innerHTML = '🚀 Register Agent On-Chain'; return; }
+ let tx;
+ if (metadata.length > 0) {
+ const mt = metadata.map(m => ({ metadataKey: m.key, metadataValue: ethers.toUtf8Bytes(m.value) }));
+ tx = await identityContract['register(string,(string,bytes)[])'](uri, mt);
+ } else if (uri) tx = await identityContract['register(string)'](uri);
+ else tx = await identityContract['register()']();
+ showToast('Transaction submitted!', 'info');
+ showDeployPending(tx.hash);
+ const receipt = await tx.wait();
+ if (receipt.status === 0) throw new Error('Transaction reverted');
+ let agentId = null;
+ for (const log of receipt.logs) {
+ try { const p = identityContract.interface.parseLog({ topics: log.topics, data: log.data }); if (p && p.name === 'Registered') { agentId = p.args.agentId.toString(); break; } } catch(e) {}
+ }
+ if (!agentId) {
+ for (const log of receipt.logs) {
+ try { const p = identityContract.interface.parseLog({ topics: log.topics, data: log.data }); if (p && p.name === 'Transfer' && p.args[0] === ethers.ZeroAddress) { agentId = p.args[2].toString(); break; } } catch(e) {}
+ }
+ }
+ if (uriMethod === 'onchain' && agentId) {
+ try {
+ json.registrations[0].agentId = parseInt(agentId);
+ const updatedUri = buildAgentUri(json);
+ const updateTx = await identityContract.setAgentURI(agentId, updatedUri);
+ await updateTx.wait();
+ } catch(e) { console.warn('URI update failed:', e); }
+ }
+ saveTxToHistory({ type: 'register', txHash: tx.hash, agentId, chain: currentChain, block: receipt.blockNumber, gasUsed: receipt.gasUsed.toString(), timestamp: Date.now(), name: json.name });
+ showDeploySuccess(tx.hash, agentId, receipt);
+ showToast('Agent #' + agentId + ' registered!', 'success');
+ } catch (err) {
+ let msg = 'Transaction failed';
+ if (err.code === 'ACTION_REJECTED' || err.code === 4001) msg = 'Transaction rejected';
+ else if (err.code === 'INSUFFICIENT_FUNDS') msg = 'Insufficient ' + chain.currency.symbol;
+ else if (err.reason) msg = err.reason;
+ else if (err.message) msg = err.message.substring(0, 200);
+ showToast(msg, 'error');
+ btn.disabled = false; btn.innerHTML = '🚀 Register Agent On-Chain';
+ }
+}
+
+function showDeployPending(txHash) {
+ const chain = CHAINS[currentChain];
+ currentStep = 5;
+ for (let i = 1; i <= 4; i++) document.getElementById('step' + i).classList.add('hidden');
+ const result = document.getElementById('deployResult');
+ result.classList.remove('hidden');
+ result.innerHTML = '<div class="tx-result"><div class="tx-icon pending">⟳</div><div class="tx-title">Transaction Pending</div><div class="tx-subtitle">Registering on ' + chain.name + '...</div><a class="tx-link" href="' + chain.explorer + '/tx/' + txHash + '" target="_blank" rel="noopener">View on Explorer →</a></div>';
+}
+
+function showDeploySuccess(txHash, agentId, receipt) {
+ const chain = CHAINS[currentChain];
+ const result = document.getElementById('deployResult');
+ result.innerHTML = '<div class="tx-result"><div class="tx-icon success">✓</div><div class="tx-title">Agent Registered!</div><div class="tx-subtitle">Successfully created on ' + chain.name + '</div><a class="tx-link" href="' + chain.explorer + '/tx/' + txHash + '" target="_blank" rel="noopener">View Transaction →</a><div class="tx-details"><div class="tx-detail-row"><span class="tx-detail-label">Agent ID</span><span class="tx-detail-value" style="color:var(--accent);font-weight:700;font-size:16px;">#' + agentId + '</span></div><div class="tx-detail-row"><span class="tx-detail-label">Standard</span><span class="tx-detail-value">ERC-721 (ERC-8004)</span></div><div class="tx-detail-row"><span class="tx-detail-label">Owner</span><span class="tx-detail-value">' + userAddress + '</span></div><div class="tx-detail-row"><span class="tx-detail-label">Registry</span><span class="tx-detail-value">' + chain.contracts.identity + '</span></div><div class="tx-detail-row"><span class="tx-detail-label">Network</span><span class="tx-detail-value">' + chain.name + ' (' + chain.chainId + ')</span></div><div class="tx-detail-row"><span class="tx-detail-label">Block</span><span class="tx-detail-value">' + receipt.blockNumber + '</span></div><div class="tx-detail-row"><span class="tx-detail-label">Gas Used</span><span class="tx-detail-value">' + receipt.gasUsed.toString() + '</span></div></div><div style="margin-top:24px;display:flex;gap:12px;justify-content:center;flex-wrap:wrap;"><button class="btn btn-primary" onclick="resetWizard()">Create Another</button><button class="btn btn-secondary" onclick="switchTab(\'dashboard\')">My Agents</button><button class="btn btn-secondary" onclick="showQrCode(' + agentId + ')">QR Code</button></div></div>';
+ fetchAgentCount();
+}
+
+function resetWizard() {
+ document.getElementById('agentName').value = '';
+ document.getElementById('agentDescription').value = '';
+ document.getElementById('agentImage').value = '';
+ document.getElementById('serviceList').innerHTML = '';
+ document.getElementById('metadataList').innerHTML = '';
+ document.querySelectorAll('.checkbox-item.checked').forEach(el => { el.classList.remove('checked'); el.querySelector('input').checked = false; });
+ serviceCounter = 0; metadataCounter = 0;
+ addService(); goToStep(1);
+ document.getElementById('deployBtn').disabled = false;
+ document.getElementById('deployBtn').innerHTML = '🚀 Register Agent On-Chain';
+}
+
+// ─── DASHBOARD ───
+async function loadMyAgents() {
+ if (!userAddress || !identityContract) return;
+ const agentsList = document.getElementById('agentsList');
+ const agentCount = document.getElementById('agentCount');
+ agentsList.innerHTML = '<div style="text-align:center;padding:20px;color:var(--text-muted);"><span class="spinner spinner-light" style="margin-right:8px;"></span>Loading...</div>';
+ try {
+ const chain = CHAINS[currentChain];
+ const balance = await identityContract.balanceOf(userAddress);
+ const count = Number(balance);
+ agentCount.textContent = count + ' agent' + (count !== 1 ? 's' : '') + ' found on ' + chain.name;
+ if (count === 0) { agentsList.innerHTML = '<div style="text-align:center;padding:40px;color:var(--text-muted);"><div style="font-size:32px;margin-bottom:12px;">🤖</div><p>No agents registered yet.</p></div>'; renderAnalytics(0, []); return; }
+ const readProvider = new ethers.JsonRpcProvider(chain.rpcUrl);
+ const readContract = new ethers.Contract(chain.contracts.identity, IDENTITY_ABI, readProvider);
+ const filter = readContract.filters.Transfer(ethers.ZeroAddress, userAddress);
+ let events = [];
+ for (const range of [5000, 2000, 1000]) { try { events = await readContract.queryFilter(filter, -range); break; } catch(e) {} }
+ const ownedIds = [];
+ for (const e of events) {
+ const tid = e.args[2].toString();
+ try { const owner = await readContract.ownerOf(tid); if (owner.toLowerCase() === userAddress.toLowerCase()) ownedIds.push(tid); } catch(e) {}
+ }
+ if (ownedIds.length === 0 && count > 0) {
+ agentsList.innerHTML = '<div style="text-align:center;padding:40px;color:var(--text-muted);"><p>You own ' + count + ' agent(s) but details could not be loaded from recent blocks.</p><p style="margin-top:8px;font-size:12px;">Check <a href="' + chain.explorer + '/address/' + userAddress + '" target="_blank" style="color:var(--accent);">explorer</a> for your agent NFTs.</p></div>';
+ renderAnalytics(count, []);
+ return;
+ }
+ let html = '<div class="agent-cards">';
+ const agentsData = [];
+ for (const id of ownedIds) {
+ let uri = '', name = 'Agent #' + id, description = '', agentData = null;
+ try {
+ uri = await readContract.tokenURI(id);
+ if (uri.startsWith('data:application/json;base64,')) {
+ const decoded = JSON.parse(decodeURIComponent(escape(atob(uri.replace('data:application/json;base64,', '')))));
+ if (decoded.name) name = decoded.name;
+ if (decoded.description) description = decoded.description;
+ agentData = decoded;
+ }
+ } catch(e) {}
+ agentsData.push({ id, name, description, uri, data: agentData });
+ html += '<div class="agent-card"><div class="agent-card-id">Agent #' + id + (agentData && agentData.x402Support ? ' <span class="x402-badge">x402</span>' : '') + '</div><div style="font-weight:600;margin-bottom:4px;">' + escapeHtml(name) + '</div>';
+ if (description) html += '<div style="font-size:12px;color:var(--text-muted);margin-bottom:8px;line-height:1.4;">' + escapeHtml(description.substring(0, 120)) + (description.length > 120 ? '...' : '') + '</div>';
+ html += '<div class="agent-card-actions"><a class="btn btn-secondary btn-sm" href="' + chain.explorer + '/token/' + chain.contracts.identity + '?a=' + id + '" target="_blank" rel="noopener">Explorer</a><button class="btn btn-secondary btn-sm" onclick="showAgentDetail(' + id + ')">Details</button><button class="btn btn-secondary btn-sm" onclick="showQrCode(' + id + ')">QR</button><button class="btn btn-secondary btn-sm" onclick="showUpdateUri(' + id + ')">Update</button></div></div>';
+ }
+ html += '</div>';
+ agentsList.innerHTML = html;
+ renderAnalytics(ownedIds.length, agentsData);
+ } catch (err) {
+ agentsList.innerHTML = '<div style="text-align:center;padding:20px;color:var(--error);">Error: ' + escapeHtml(err.message) + '</div>';
+ }
+}
+
+function renderAnalytics(count, agents) {
+ const grid = document.getElementById('dashboardAnalytics');
+ const chain = CHAINS[currentChain];
+ let servicesCount = 0, x402Count = 0;
+ agents.forEach(a => {
+ if (a.data) {
+ if (a.data.services) servicesCount += a.data.services.length;
+ if (a.data.x402Support) x402Count++;
+ }
+ });
+ grid.innerHTML = '<div class="analytics-card"><div class="analytics-value">' + count + '</div><div class="analytics-label">Total Agents</div></div><div class="analytics-card"><div class="analytics-value">' + servicesCount + '</div><div class="analytics-label">Service Endpoints</div></div><div class="analytics-card"><div class="analytics-value">' + x402Count + '</div><div class="analytics-label">x402 Enabled</div></div><div class="analytics-card"><div class="analytics-value">' + chain.name.split(' ')[0] + '</div><div class="analytics-label">Current Chain</div></div>';
+}
+
+// ─── AGENT DETAIL MODAL ───
+async function showAgentDetail(id) {
+ const chain = CHAINS[currentChain];
+ const modal = document.getElementById('agentModal');
+ const content = document.getElementById('agentModalContent');
+ content.innerHTML = '<div style="text-align:center;padding:40px;"><span class="spinner spinner-light"></span></div>';
+ modal.classList.remove('hidden');
+ modal.style.display = 'flex';
+ try {
+ const readProvider = new ethers.JsonRpcProvider(chain.rpcUrl);
+ const readContract = new ethers.Contract(chain.contracts.identity, IDENTITY_ABI, readProvider);
+ const uri = await readContract.tokenURI(id);
+ const owner = await readContract.ownerOf(id);
+ let agentData = {};
+ if (uri.startsWith('data:application/json;base64,')) {
+ agentData = JSON.parse(decodeURIComponent(escape(atob(uri.replace('data:application/json;base64,', '')))));
+ }
+ let repHtml = '';
+ if (chain.contracts.reputation) {
+ try {
+ const repContract = new ethers.Contract(chain.contracts.reputation, REPUTATION_ABI, readProvider);
+ const [totalScore, repCount] = await repContract.getReputation(id);
+ const avg = Number(repCount) > 0 ? (Number(totalScore) / Number(repCount)).toFixed(1) : 'N/A';
+ repHtml = '<div class="tx-detail-row"><span class="tx-detail-label">Reputation</span><span class="tx-detail-value">' + avg + '/5 (' + repCount.toString() + ' ratings)</span></div>';
+ } catch(e) {}
+ }
+ content.innerHTML = '<div class="card-header"><div class="card-title">' + escapeHtml(agentData.name || 'Agent #' + id) + '</div><button class="btn btn-ghost btn-sm" onclick="closeAgentModal()">✕</button></div>' +
+ (agentData.description ? '<p style="color:var(--text-secondary);font-size:14px;margin-bottom:16px;line-height:1.6;">' + escapeHtml(agentData.description) + '</p>' : '') +
+ '<div class="tx-details"><div class="tx-detail-row"><span class="tx-detail-label">Agent ID</span><span class="tx-detail-value" style="color:var(--accent);font-weight:700;">#' + id + '</span></div><div class="tx-detail-row"><span class="tx-detail-label">Owner</span><span class="tx-detail-value">' + owner + '</span></div><div class="tx-detail-row"><span class="tx-detail-label">Network</span><span class="tx-detail-value">' + chain.name + '</span></div><div class="tx-detail-row"><span class="tx-detail-label">x402</span><span class="tx-detail-value">' + (agentData.x402Support ? '<span class="x402-badge">Enabled</span>' : 'No') + '</span></div>' + repHtml + '</div>' +
+ (agentData.services && agentData.services.length > 0 ? '<div style="margin-top:16px;"><div class="review-label">Services</div>' + agentData.services.map(s => '<div class="tx-detail-row"><span class="tx-detail-label">' + escapeHtml(s.name) + '</span><span class="tx-detail-value">' + escapeHtml(s.endpoint) + '</span></div>').join('') + '</div>' : '') +
+ '<div style="margin-top:16px;display:flex;gap:8px;flex-wrap:wrap;"><a class="btn btn-secondary btn-sm" href="' + chain.explorer + '/token/' + chain.contracts.identity + '?a=' + id + '" target="_blank">Explorer</a><button class="btn btn-secondary btn-sm" onclick="showQrCode(' + id + ');closeAgentModal();">QR Code</button><button class="btn btn-secondary btn-sm" onclick="exportAgentJSON(' + id + ')">Export JSON</button></div>';
+ } catch(err) {
+ content.innerHTML = '<div class="card-header"><div class="card-title">Error</div><button class="btn btn-ghost btn-sm" onclick="closeAgentModal()">✕</button></div><p style="color:var(--error);">' + escapeHtml(err.message) + '</p>';
+ }
+}
+function closeAgentModal() { const m = document.getElementById('agentModal'); m.classList.add('hidden'); m.style.display = 'none'; }
+
+// ─── AGENT UPDATE (setURI) ───
+async function showUpdateUri(agentId) {
+ const newUri = prompt('Enter new URI for Agent #' + agentId + ':\n(data:, ipfs://, or https://)');
+ if (!newUri) return;
+ try {
+ showToast('Updating URI...', 'info');
+ const tx = await identityContract.setAgentURI(agentId, newUri);
+ await tx.wait();
+ saveTxToHistory({ type: 'update', txHash: tx.hash, agentId, chain: currentChain, timestamp: Date.now(), name: 'URI Update #' + agentId });
+ showToast('URI updated for Agent #' + agentId + '!', 'success');
+ loadMyAgents();
+ } catch(err) {
+ showToast('Update failed: ' + (err.reason || err.message || err), 'error');
+ }
+}
+
+// ─── SEARCH & DISCOVERY ───
+function setSearchFilter(filter, btn) {
+ searchFilter = filter;
+ document.querySelectorAll('.filter-chip').forEach(c => c.classList.toggle('active', c.dataset.filter === filter));
+}
+
+async function searchAgents() {
+ const query = document.getElementById('searchInput').value.trim();
+ const results = document.getElementById('searchResults');
+ if (!query) { showToast('Enter an agent ID, name, or address.', 'error'); return; }
+ results.innerHTML = '<div style="text-align:center;padding:24px;"><span class="spinner spinner-light"></span> Searching...</div>';
+ const chain = CHAINS[currentChain];
+ try {
+ const readProvider = new ethers.JsonRpcProvider(chain.rpcUrl);
+ const readContract = new ethers.Contract(chain.contracts.identity, IDENTITY_ABI, readProvider);
+ // Search by ID
+ if (/^\d+$/.test(query)) {
+ const id = parseInt(query);
+ try {
+ const owner = await readContract.ownerOf(id);
+ const uri = await readContract.tokenURI(id);
+ let agentData = {};
+ if (uri.startsWith('data:application/json;base64,')) {
+ agentData = JSON.parse(decodeURIComponent(escape(atob(uri.replace('data:application/json;base64,', '')))));
+ }
+ if (searchFilter !== 'all') {
+ const hasType = agentData.services && agentData.services.some(s => s.name === searchFilter);
+ const hasX402 = searchFilter === 'x402' && agentData.x402Support;
+ if (!hasType && !hasX402) { results.innerHTML = '<div style="text-align:center;padding:24px;color:var(--text-muted);">Agent found but doesn\'t match filter.</div>'; return; }
+ }
+ results.innerHTML = '<div class="agent-cards"><div class="agent-card"><div class="agent-card-id">Agent #' + id + (agentData.x402Support ? ' <span class="x402-badge">x402</span>' : '') + '</div><div style="font-weight:600;margin-bottom:4px;">' + escapeHtml(agentData.name || 'Unknown') + '</div><div style="font-size:12px;color:var(--text-muted);margin-bottom:8px;">' + escapeHtml((agentData.description || '').substring(0, 150)) + '</div><div style="font-size:12px;color:var(--text-muted);margin-bottom:8px;">Owner: <span style="font-family:var(--font-mono);">' + owner.slice(0, 10) + '...' + owner.slice(-6) + '</span></div><div class="agent-card-actions"><button class="btn btn-secondary btn-sm" onclick="showAgentDetail(' + id + ')">Details</button><button class="btn btn-secondary btn-sm" onclick="showQrCode(' + id + ')">QR</button></div></div></div>';
+ } catch(e) {
+ results.innerHTML = '<div style="text-align:center;padding:24px;color:var(--text-muted);">Agent #' + query + ' not found on ' + chain.name + '.</div>';
+ }
+ } else if (query.startsWith('0x')) {
+ // Search by address
+ try {
+ const bal = await readContract.balanceOf(query);
+ results.innerHTML = '<div style="padding:16px;"><p style="font-size:14px;color:var(--text-secondary);">Address <span style="font-family:var(--font-mono);">' + query.slice(0, 10) + '...' + query.slice(-6) + '</span> owns <strong>' + bal.toString() + '</strong> agent(s) on ' + chain.name + '.</p></div>';
+ } catch(e) { results.innerHTML = '<div style="text-align:center;padding:24px;color:var(--text-muted);">No results found.</div>'; }
+ } else {
+ // Scan recent agents for name match
+ let found = [];
+ for (let id = 1; id <= 50; id++) {
+ try {
+ const uri = await readContract.tokenURI(id);
+ if (uri.startsWith('data:application/json;base64,')) {
+ const data = JSON.parse(decodeURIComponent(escape(atob(uri.replace('data:application/json;base64,', '')))));
+ if (data.name && data.name.toLowerCase().includes(query.toLowerCase())) {
+ if (searchFilter !== 'all') {
+ const hasType = data.services && data.services.some(s => s.name === searchFilter);
+ const hasX402 = searchFilter === 'x402' && data.x402Support;
+ if (!hasType && !hasX402) continue;
+ }
+ const owner = await readContract.ownerOf(id);
+ found.push({ id, data, owner });
+ }
+ }
+ } catch(e) { break; }
+ }
+ if (found.length > 0) {
+ results.innerHTML = '<div class="agent-cards">' + found.map(a => '<div class="agent-card"><div class="agent-card-id">Agent #' + a.id + (a.data.x402Support ? ' <span class="x402-badge">x402</span>' : '') + '</div><div style="font-weight:600;margin-bottom:4px;">' + escapeHtml(a.data.name) + '</div><div style="font-size:12px;color:var(--text-muted);margin-bottom:8px;">' + escapeHtml((a.data.description || '').substring(0, 120)) + '</div><div class="agent-card-actions"><button class="btn btn-secondary btn-sm" onclick="showAgentDetail(' + a.id + ')">Details</button><button class="btn btn-secondary btn-sm" onclick="showQrCode(' + a.id + ')">QR</button></div></div>').join('') + '</div>';
+ } else {
+ results.innerHTML = '<div style="text-align:center;padding:24px;color:var(--text-muted);">No agents found matching "' + escapeHtml(query) + '".</div>';
+ }
+ }
+ } catch(err) {
+ results.innerHTML = '<div style="text-align:center;padding:24px;color:var(--error);">Search error: ' + escapeHtml(err.message) + '</div>';
+ }
+}
+
+// ─── REPUTATION ───
+function setRating(score) {
+ currentRating = score;
+ document.querySelectorAll('#ratingStars .star').forEach(s => {
+ s.classList.toggle('filled', parseInt(s.dataset.rating) <= score);
+ });
+}
+
+async function viewReputation() {
+ const id = document.getElementById('repAgentId').value.trim();
+ if (!id) { showToast('Enter an agent ID.', 'error'); return; }
+ const chain = CHAINS[currentChain];
+ if (!chain.contracts.reputation) { showToast('No reputation contract on this chain.', 'error'); return; }
+ const display = document.getElementById('reputationDisplay');
+ display.classList.remove('hidden');
+ document.getElementById('submitRepSection').classList.toggle('hidden', !userAddress);
+ try {
+ const readProvider = new ethers.JsonRpcProvider(chain.rpcUrl);
+ const repContract = new ethers.Contract(chain.contracts.reputation, REPUTATION_ABI, readProvider);
+ const [totalScore, count] = await repContract.getReputation(id);
+ const avg = Number(count) > 0 ? (Number(totalScore) / Number(count)).toFixed(1) : '0';
+ const pct = Number(count) > 0 ? (Number(totalScore) / Number(count) / 5 * 100).toFixed(0) : 0;
+ document.getElementById('repAnalytics').innerHTML = '<div class="analytics-card"><div class="analytics-value">' + avg + '</div><div class="analytics-label">Average Score</div></div><div class="analytics-card"><div class="analytics-value">' + count.toString() + '</div><div class="analytics-label">Total Ratings</div></div><div class="analytics-card"><div class="analytics-value">' + pct + '%</div><div class="analytics-label">Approval</div></div>';
+ // Try to load recent reputation events
+ let histHtml = '';
+ try {
+ const filter = repContract.filters.ReputationSubmitted(id);
+ const events = await repContract.queryFilter(filter, -5000);
+ if (events.length > 0) {
+ histHtml = '<div class="review-label" style="margin-top:16px;">Recent Ratings</div>';
+ events.slice(-5).reverse().forEach(e => {
+ const stars = '★'.repeat(e.args.score) + '☆'.repeat(5 - e.args.score);
+ histHtml += '<div class="history-item"><div style="color:var(--accent);">' + stars + '</div><div class="history-details"><div class="history-meta">' + (e.args.comment || 'No comment') + '</div><div class="history-meta">From: ' + e.args.submitter.slice(0, 8) + '...' + e.args.submitter.slice(-4) + '</div></div></div>';
+ });
+ }
+ } catch(e) {}
+ document.getElementById('repHistory').innerHTML = histHtml;
+ } catch(err) {
+ document.getElementById('repAnalytics').innerHTML = '<div style="color:var(--error);padding:16px;">Could not load reputation: ' + escapeHtml(err.message) + '</div>';
+ }
+}
+
+async function submitReputation() {
+ const id = document.getElementById('repAgentId').value.trim();
+ if (!id || !currentRating) { showToast('Select a rating (1-5 stars).', 'error'); return; }
+ if (!reputationContract) { showToast('Connect wallet first.', 'error'); return; }
+ const comment = document.getElementById('repComment').value.trim();
+ try {
+ showToast('Submitting rating...', 'info');
+ const tx = await reputationContract.submitReputation(id, currentRating, comment);
+ await tx.wait();
+ saveTxToHistory({ type: 'reputation', txHash: tx.hash, agentId: id, chain: currentChain, timestamp: Date.now(), name: 'Rating for #' + id });
+ showToast('Rating submitted!', 'success');
+ currentRating = 0;
+ document.querySelectorAll('#ratingStars .star').forEach(s => s.classList.remove('filled'));
+ document.getElementById('repComment').value = '';
+ viewReputation();
+ } catch(err) {
+ showToast('Rating failed: ' + (err.reason || err.message), 'error');
+ }
+}
+
+// ─── TEMPLATES ───
+function renderTemplates() {
+ const grid = document.getElementById('templateGrid');
+ grid.innerHTML = TEMPLATES.map(t =>
+ '<div class="template-card" onclick="applyTemplate(\'' + t.id + '\')"><div class="template-icon">' + t.icon + '</div><div class="template-name">' + t.name + '</div><div class="template-desc">' + t.desc + '</div></div>'
+ ).join('');
+}
+
+function applyTemplate(id) {
+ const tpl = TEMPLATES.find(t => t.id === id);
+ if (!tpl) return;
+ const d = tpl.data;
+ document.getElementById('agentName').value = d.name;
+ document.getElementById('agentDescription').value = d.description;
+ // Clear and set services
+ document.getElementById('serviceList').innerHTML = '';
+ serviceCounter = 0;
+ d.services.forEach(s => {
+ addService();
+ const entry = document.getElementById('service-' + serviceCounter);
+ entry.querySelector('select').value = s.name;
+ entry.querySelector('[data-field="endpoint"]').value = s.endpoint;
+ if (s.version) entry.querySelector('[data-field="version"]').value = s.version;
+ });
+ // Trust models
+ document.querySelectorAll('#trustModels .checkbox-item').forEach(el => {
+ const cb = el.querySelector('input');
+ const shouldCheck = d.trust && d.trust.includes(cb.value);
+ if (shouldCheck && !el.classList.contains('checked')) toggleCheck(el);
+ if (!shouldCheck && el.classList.contains('checked')) toggleCheck(el);
+ });
+ // x402
+ const x402El = document.getElementById('x402Toggle');
+ if (d.x402 && !x402El.classList.contains('checked')) toggleCheck(x402El);
+ if (!d.x402 && x402El.classList.contains('checked')) toggleCheck(x402El);
+ // Metadata
+ document.getElementById('metadataList').innerHTML = '';
+ metadataCounter = 0;
+ if (d.metadata) d.metadata.forEach(m => addMetadataPreset(m.key, m.value));
+ switchTab('create');
+ if (userAddress) goToStep(1);
+ showToast('Template applied: ' + tpl.name, 'success');
+}
+
+// ─── BATCH ───
+function handleBatchDrop(event) {
+ event.preventDefault();
+ event.target.classList.remove('dragover');
+ const file = event.dataTransfer.files[0];
+ if (file) handleBatchFile(file);
+}
+
+function handleBatchFile(file) {
+ if (!file) return;
+ const reader = new FileReader();
+ reader.onload = function(e) {
+ const text = e.target.result;
+ try {
+ if (file.name.endsWith('.json')) {
+ batchAgents = JSON.parse(text);
+ if (!Array.isArray(batchAgents)) batchAgents = [batchAgents];
+ } else {
+ // CSV parse
+ const lines = text.trim().split('\n');
+ const headers = lines[0].split(',').map(h => h.trim());
+ batchAgents = lines.slice(1).map(line => {
+ const values = line.split(',').map(v => v.trim());
+ const obj = {};
+ headers.forEach((h, i) => obj[h] = values[i] || '');
+ return {
+ name: obj.name || obj.Name || '',
+ description: obj.description || obj.Description || '',
+ services: [{ name: obj.serviceType || obj.type || 'web', endpoint: obj.endpoint || obj.url || '' }]
+ };
+ }).filter(a => a.name && a.services[0].endpoint);
+ }
+ renderBatchPreview();
+ } catch(err) {
+ showToast('Invalid file format: ' + err.message, 'error');
+ }
+ };
+ reader.readAsText(file);
+}
+
+function renderBatchPreview() {
+ document.getElementById('batchPreview').classList.remove('hidden');
+ document.getElementById('batchCount').textContent = batchAgents.length;
+ const list = document.getElementById('batchList');
+ list.innerHTML = batchAgents.map((a, i) =>
+ '<div class="history-item"><div class="history-icon register" style="font-size:14px;">' + (i + 1) + '</div><div class="history-details"><div class="history-title">' + escapeHtml(a.name || 'Agent ' + (i+1)) + '</div><div class="history-meta">' + escapeHtml((a.description || '').substring(0,80)) + '</div></div></div>'
+ ).join('');
+}
+
+function clearBatch() {
+ batchAgents = [];
+ document.getElementById('batchPreview').classList.add('hidden');
+ document.getElementById('batchFile').value = '';
+}
+
+async function executeBatch() {
+ if (!signer || !identityContract) { showToast('Connect wallet first.', 'error'); return; }
+ if (!batchAgents.length) return;
+ const chain = CHAINS[currentChain];
+ if (!chain.testnet && !confirm('Batch register ' + batchAgents.length + ' agents on ' + chain.name + '? This uses real ' + chain.currency.symbol + '.')) return;
+ document.getElementById('batchProgress').classList.remove('hidden');
+ const bar = document.getElementById('batchProgressBar');
+ const status = document.getElementById('batchStatus');
+ let success = 0, failed = 0;
+ for (let i = 0; i < batchAgents.length; i++) {
+ const a = batchAgents[i];
+ const pct = ((i + 1) / batchAgents.length * 100).toFixed(0);
+ bar.style.width = pct + '%';
+ status.textContent = 'Processing ' + (i + 1) + '/' + batchAgents.length + ': ' + (a.name || 'Agent');
+ try {
+ const json = {
+ type: "https://eips.ethereum.org/EIPS/eip-8004#registration-v1",
+ name: a.name, description: a.description || '', services: a.services || [], active: true,
+ registrations: [{ agentId: "PENDING", agentRegistry: 'eip155:' + chain.chainId + ':' + chain.contracts.identity }]
+ };
+ const uri = 'data:application/json;base64,' + btoa(unescape(encodeURIComponent(JSON.stringify(json))));
+ const tx = await identityContract['register(string)'](uri);
+ await tx.wait();
+ success++;
+ saveTxToHistory({ type: 'register', txHash: tx.hash, chain: currentChain, timestamp: Date.now(), name: a.name });
+ } catch(err) {
+ failed++;
+ if (err.code === 'ACTION_REJECTED' || err.code === 4001) { status.textContent = 'Batch cancelled by user.'; break; }
+ }
+ }
+ status.textContent = 'Done! ' + success + ' registered, ' + failed + ' failed.';
+ showToast('Batch complete: ' + success + ' registered.', success > 0 ? 'success' : 'error');
+}
+
+// ─── QR CODE ───
+function showQrCode(agentId) {
+ const chain = CHAINS[currentChain];
+ const url = chain.explorer + '/token/' + chain.contracts.identity + '?a=' + agentId;
+ const qrUrl = 'https://api.qrserver.com/v1/create-qr-code/?size=200x200&data=' + encodeURIComponent(url);
+ const modal = document.getElementById('qrModal');
+ const content = document.getElementById('qrContent');
+ content.innerHTML = '<p style="font-size:14px;color:var(--text-secondary);margin-bottom:8px;">Agent #' + agentId + ' on ' + chain.name + '</p><img src="' + qrUrl + '" alt="QR Code" width="200" height="200" style="background:#fff;padding:8px;border-radius:8px;" /><p style="font-size:12px;color:var(--text-muted);margin-top:12px;word-break:break-all;">' + escapeHtml(url) + '</p><div style="margin-top:16px;display:flex;gap:8px;justify-content:center;"><a class="btn btn-primary btn-sm" href="' + qrUrl + '&format=png" download="agent-' + agentId + '-qr.png">Download PNG</a><button class="btn btn-secondary btn-sm" onclick="navigator.clipboard.writeText(\'' + url + '\');showToast(\'Link copied!\',\'success\')">Copy Link</button></div>';
+ modal.classList.remove('hidden');
+ modal.style.display = 'flex';
+}
+function closeQrModal() { const m = document.getElementById('qrModal'); m.classList.add('hidden'); m.style.display = 'none'; }
+
+// ─── EXPORT ───
+function exportJSON() {
+ const json = buildRegistrationJson();
+ const blob = new Blob([JSON.stringify(json, null, 2)], { type: 'application/json' });
+ downloadBlob(blob, 'agent-registration.json');
+ showToast('JSON exported!', 'success');
+}
+
+function exportAgentCard() {
+ const json = buildRegistrationJson();
+ const agentCard = {
+ name: json.name, description: json.description, url: json.services?.[0]?.endpoint || '',
+ version: '1.0.0', capabilities: { streaming: false, pushNotifications: false },
+ defaultInputModes: ['text'], defaultOutputModes: ['text'],
+ skills: json.services?.map(s => ({ id: s.name.toLowerCase(), name: s.name, description: s.name + ' endpoint at ' + s.endpoint })) || []
+ };
+ const blob = new Blob([JSON.stringify(agentCard, null, 2)], { type: 'application/json' });
+ downloadBlob(blob, 'agent-card.json');
+ showToast('Agent card exported!', 'success');
+}
+
+function exportBadge() {
+ const json = buildRegistrationJson();
+ const chain = CHAINS[currentChain];
+ const badge = '<!-- ERC-8004 Agent Badge -->\n<a href="' + chain.explorer + '/address/' + chain.contracts.identity + '" target="_blank" rel="noopener" style="display:inline-flex;align-items:center;gap:8px;padding:8px 16px;background:#05060a;color:#d6ff3d;border-radius:8px;text-decoration:none;font-family:system-ui;font-size:14px;font-weight:600;border:1px solid rgba(214,255,61,0.3);">🤖 ' + escapeHtml(json.name || 'ERC-8004 Agent') + ' · Verified On-Chain</a>';
+ navigator.clipboard.writeText(badge);
+ showToast('Badge HTML copied to clipboard!', 'success');
+}
+
+function exportCLI() {
+ const json = buildRegistrationJson();
+ const chain = CHAINS[currentChain];
+ const uri = 'data:application/json;base64,' + btoa(unescape(encodeURIComponent(JSON.stringify(json))));
+ const cmd = '# Register agent on ' + chain.name + '\ncast send ' + chain.contracts.identity + ' "register(string)" "' + uri.substring(0, 60) + '..." --rpc-url ' + chain.rpcUrl + ' --private-key $PRIVATE_KEY';
+ navigator.clipboard.writeText(cmd);
+ showToast('CLI command copied!', 'success');
+}
+
+function exportAgentJSON(agentId) {
+ // Export from detail modal
+ const chain = CHAINS[currentChain];
+ const readProvider = new ethers.JsonRpcProvider(chain.rpcUrl);
+ const readContract = new ethers.Contract(chain.contracts.identity, IDENTITY_ABI, readProvider);
+ readContract.tokenURI(agentId).then(uri => {
+ if (uri.startsWith('data:application/json;base64,')) {
+ const data = JSON.parse(decodeURIComponent(escape(atob(uri.replace('data:application/json;base64,', '')))));
+ const blob = new Blob([JSON.stringify(data, null, 2)], { type: 'application/json' });
+ downloadBlob(blob, 'agent-' + agentId + '.json');
+ showToast('Agent JSON exported!', 'success');
+ }
+ }).catch(err => showToast('Export failed.', 'error'));
+}
+
+function downloadBlob(blob, filename) {
+ const url = URL.createObjectURL(blob);
+ const a = document.createElement('a');
+ a.href = url; a.download = filename;
+ document.body.appendChild(a); a.click();
+ document.body.removeChild(a);
+ URL.revokeObjectURL(url);
+}
+
+// ─── TRANSACTION HISTORY ───
+function saveTxToHistory(tx) {
+ txHistory.unshift(tx);
+ if (txHistory.length > 100) txHistory = txHistory.slice(0, 100);
+ localStorage.setItem('erc8004_history', JSON.stringify(txHistory));
+}
+
+function loadHistory() {
+ const list = document.getElementById('historyList');
+ if (txHistory.length === 0) {
+ list.innerHTML = '<div style="text-align:center;padding:40px;color:var(--text-muted);"><div style="font-size:32px;margin-bottom:12px;">📜</div><p>No transactions recorded yet.</p></div>';
+ return;
+ }
+ list.innerHTML = txHistory.map(tx => {
+ const chain = CHAINS[tx.chain] || { name: 'Unknown', explorer: '#', icon: '❓' };
+ const date = new Date(tx.timestamp).toLocaleDateString() + ' ' + new Date(tx.timestamp).toLocaleTimeString();
+ const iconClass = tx.type === 'register' ? 'register' : 'update';
+ const typeIcon = tx.type === 'register' ? '🤖' : tx.type === 'update' ? '✏️' : '⭐';
+ return '<div class="history-item"><div class="history-icon ' + iconClass + '">' + typeIcon + '</div><div class="history-details"><div class="history-title">' + escapeHtml(tx.name || tx.type) + (tx.agentId ? ' <span style="color:var(--accent);">#' + tx.agentId + '</span>' : '') + '</div><div class="history-meta">' + chain.icon + ' ' + chain.name + ' · ' + date + (tx.gasUsed ? ' · ' + Number(tx.gasUsed).toLocaleString() + ' gas' : '') + '</div></div><a class="btn btn-secondary btn-sm" href="' + chain.explorer + '/tx/' + tx.txHash + '" target="_blank" rel="noopener">View</a></div>';
+ }).join('');
+}
+
+// ─── AGENT COUNT ───
+async function fetchAgentCount() {
+ const el = document.getElementById('statAgents');
+ try {
+ const chain = CHAINS[currentChain];
+ const readProvider = new ethers.JsonRpcProvider(chain.rpcUrl);
+ const readContract = new ethers.Contract(chain.contracts.identity, IDENTITY_ABI, readProvider);
+ await readContract.getVersion();
+ let total = 0;
+ try { await readContract.ownerOf(1); total = 1; } catch(e) { el.textContent = '0'; return; }
+ let probe = 1;
+ while (probe <= 10000) { try { await readContract.ownerOf(probe); total = probe; probe *= 2; } catch(e) { break; } }
+ let lo = total, hi = probe;
+ while (lo < hi) { const mid = Math.floor((lo + hi + 1) / 2); try { await readContract.ownerOf(mid); lo = mid; } catch(e) { hi = mid - 1; } }
+ el.textContent = lo.toString();
+ } catch(err) { el.textContent = '—'; }
+}
+
+// ─── UTILITIES ───
+function escapeHtml(str) { const d = document.createElement('div'); d.appendChild(document.createTextNode(str)); return d.innerHTML; }
</script>
</body>
</html>
diff --git a/src/CLAUDE.md b/src/CLAUDE.md
index 6a1c542c8..e3602a710 100644
--- a/src/CLAUDE.md
+++ b/src/CLAUDE.md
@@ -7,7 +7,7 @@ Scoped guidance for the viewer + agent runtime. Read [/CLAUDE.md](../CLAUDE.md)
## The two halves
- **Viewer half** — [viewer.js](viewer.js), [viewer/](viewer/), [environments.js](environments.js), [validator.js](validator.js), [animation-manager.js](animation-manager.js), [model-info.js](model-info.js), [annotations.js](annotations.js), [editor/](editor/). Pure three.js. Loads GLB, renders, manages animations, validates.
-- **Agent half** — [agent-*.js](./), [runtime/](runtime/), [skills/](skills/), [memory/](memory/), [erc8004/](erc8004/), [manifest.js](manifest.js), [element.js](element.js). Adds persona, memory, skills, identity, emotional presence.
+- **Agent half** — [agent-\*.js](./), [runtime/](runtime/), [skills/](skills/), [memory/](memory/), [erc8004/](erc8004/), [manifest.js](manifest.js), [element.js](element.js). Adds persona, memory, skills, identity, emotional presence.
The viewer doesn't know about agents. The agent layer wraps the viewer through [runtime/scene.js](runtime/scene.js) (SceneController).
@@ -16,6 +16,7 @@ The viewer doesn't know about agents. The agent layer wraps the viewer through [
## Module map
### Agent primitives (singleton-ish, per element instance)
+
- [agent-protocol.js](agent-protocol.js) — **the bus.** Everything communicates through `protocol.emit()` / `protocol.on()`. Don't add direct module-to-module coupling.
- [agent-identity.js](agent-identity.js) — passport + diary. localStorage + `/api/agents/:id`. Wallet linking, signed action history.
- [agent-memory.js](agent-memory.js) — in-memory 4-type store (see also [memory/index.js](memory/index.js) for the file-based variant).
@@ -25,6 +26,7 @@ The viewer doesn't know about agents. The agent layer wraps the viewer through [
- [agent-resolver.js](agent-resolver.js) — resolves `agent-id="..."` attributes to manifests via `/api/agents/:id`.
### Runtime (LLM brain)
+
- [runtime/index.js](runtime/index.js) — tool loop. `MAX_TOOL_ITERATIONS = 8`.
- [runtime/providers.js](runtime/providers.js) — `AnthropicProvider`, `NullProvider`.
- [runtime/scene.js](runtime/scene.js) — SceneController wraps Viewer with agent-facing API (`playClipByName`, `lookAt`, `setExpression`, `loadGLB`).
@@ -32,17 +34,20 @@ The viewer doesn't know about agents. The agent layer wraps the viewer through [
- [runtime/speech.js](runtime/speech.js) — TTS/STT via browser Web Speech API.
### Format loaders
+
- [manifest.js](manifest.js) — `agent-manifest/0.1`. Loads from `agent://chain/id`, `ipfs://`, `ar://`, `https://`. `normalize()` adapts ERC-8004 registration JSON.
- [skills/index.js](skills/index.js) — SkillRegistry. `.install(spec, { bundleBase })`, trust modes (`any`, `owned-only`, `whitelist`), recursive deps.
- [memory/index.js](memory/index.js) — file-based (frontmatter `.md` files + auto-generated MEMORY.md index + append-only timeline). Modes: `local`, `ipfs`, `encrypted-ipfs`, `none`.
- [ipfs.js](ipfs.js) — IPFS/Arweave → HTTPS gateway with fallback (ipfs.io → dweb.link → nft.storage).
### Web component boundary
+
- [element.js](element.js) — `<agent-3d>` custom element. IntersectionObserver lazy boot unless `eager`. See attribute list in [specs/EMBED_SPEC.md](../specs/EMBED_SPEC.md).
- [lib.js](lib.js) — CDN library export surface.
-- [app.js](app.js) — main SPA entry. **URL hash routing lives here** — keys: `model`, `widget`, `agent`, `kiosk`, `brain`, `proxyURL`, `preset`, `cameraPosition`, `register`.
+- [app.js](app.js) — main SPA entry. **URL routing lives here.** Hash keys (embed/legacy): `model`, `widget`, `agent`, `kiosk`, `brain`, `proxyURL`, `preset`, `cameraPosition`, `register`. Query-string keys: `agent=<id>` (authenticated edit mode — distinct from `#agent=` which stays in embed mode), `pending=1` (post-login save round-trip).
### Blockchain
+
- [erc8004/abi.js](erc8004/abi.js) — IdentityRegistry / ReputationRegistry / ValidationRegistry ABIs + `REGISTRY_DEPLOYMENTS` (mainnet + testnet addresses, keyed by chainId).
- [erc8004/agent-registry.js](erc8004/) — `connectWallet()`, `registerAgent()`, `buildRegistrationJSON()`, `pinToIPFS()`.
- [erc8004/privy.js](erc8004/) — Privy OAuth hooks.
@@ -55,22 +60,22 @@ The viewer doesn't know about agents. The agent layer wraps the viewer through [
All events are `CustomEvent` with `detail = { type, payload, timestamp, agentId, sourceSkill }`. Emitters fire on `protocol`, consumers subscribe via `protocol.on(type, handler)`.
-| Type | Payload | Emitted by | Consumed by |
-|---|---|---|---|
-| `speak` | `{ text, sentiment }` (-1..1) | runtime, skills | avatar (emotion), home (timeline), nich-agent (chat UI) |
-| `think` | `{ thought }` | runtime | home, avatar |
-| `gesture` | `{ name, duration }` | skills, avatar | avatar (one-shot clip) |
-| `emote` | `{ trigger, weight }` (0..1) | skills, avatar internals | avatar (emotion blend) |
-| `look-at` | `{ target: 'model'\|'user'\|'camera' }` | skills | scene-ctrl |
-| `perform-skill` | `{ skill, args, animationHint }` | runtime | skills registry |
-| `skill-done` | `{ skill, result: { success, output, sentiment, data } }` | skill handlers | avatar, identity |
-| `skill-error` | `{ skill, error }` | skill handlers | avatar (concern + empathy), identity |
-| `remember` | `{ type, content, ... }` | skills, runtime | memory, identity |
-| `sign` | `{ message, address }` | skills | identity |
-| `load-start` | `{ uri }` | viewer | avatar (patience + curiosity) |
-| `load-end` | `{ uri, error? }` | viewer | avatar (concern or celebration) |
-| `validate` | `{ errors, warnings }` | validator | avatar, identity |
-| `presence` | `{ state }` | element | home |
+| Type | Payload | Emitted by | Consumed by |
+| --------------- | --------------------------------------------------------- | ------------------------ | ------------------------------------------------------- |
+| `speak` | `{ text, sentiment }` (-1..1) | runtime, skills | avatar (emotion), home (timeline), nich-agent (chat UI) |
+| `think` | `{ thought }` | runtime | home, avatar |
+| `gesture` | `{ name, duration }` | skills, avatar | avatar (one-shot clip) |
+| `emote` | `{ trigger, weight }` (0..1) | skills, avatar internals | avatar (emotion blend) |
+| `look-at` | `{ target: 'model'\|'user'\|'camera' }` | skills | scene-ctrl |
+| `perform-skill` | `{ skill, args, animationHint }` | runtime | skills registry |
+| `skill-done` | `{ skill, result: { success, output, sentiment, data } }` | skill handlers | avatar, identity |
+| `skill-error` | `{ skill, error }` | skill handlers | avatar (concern + empathy), identity |
+| `remember` | `{ type, content, ... }` | skills, runtime | memory, identity |
+| `sign` | `{ message, address }` | skills | identity |
+| `load-start` | `{ uri }` | viewer | avatar (patience + curiosity) |
+| `load-end` | `{ uri, error? }` | viewer | avatar (concern or celebration) |
+| `validate` | `{ errors, warnings }` | validator | avatar, identity |
+| `presence` | `{ state }` | element | home |
**Identity records these to the backend:** `speak`, `remember`, `sign`, `skill-done`, `validate`, `load-end`. Fire-and-forget via `POST /api/agent-actions`.
@@ -81,18 +86,21 @@ All events are `CustomEvent` with `detail = { type, payload, timestamp, agentId,
## The Empathy Layer — how it actually works
### State
+
Continuous weighted blend of `{ neutral, concern, celebration, patience, curiosity, empathy }`. All blend simultaneously. `neutral = 1 - sum(others)`.
### Decay (per second)
-| Emotion | Rate | Half-life |
-|---|---|---|
-| concern | 0.08 | ~9s |
-| celebration | 0.18 | ~4s |
-| patience | 0.035 | ~20s |
-| curiosity | 0.12 | ~6s |
-| empathy | 0.055 | ~13s |
+
+| Emotion | Rate | Half-life |
+| ----------- | ----- | --------- |
+| concern | 0.08 | ~9s |
+| celebration | 0.18 | ~4s |
+| patience | 0.035 | ~20s |
+| curiosity | 0.12 | ~6s |
+| empathy | 0.055 | ~13s |
### Stimulus rules (protocol → emotion)
+
- `speak`: valence > 0.3 → celebration; < -0.2 → concern; arousal > 0.5 → curiosity
- `skill-done`: `result.sentiment` > 0.3 → celebration; < -0.2 → concern
- `skill-error`: concern + empathy (scaled by error streak × 0.25)
@@ -101,6 +109,7 @@ Continuous weighted blend of `{ neutral, concern, celebration, patience, curiosi
- `validate`: errors → concern; warnings → concern; clean → celebration + nod
### Morph target mapping (per frame, lerp speed ~4.0)
+
- celebration → mouthSmile 0.85, mouthOpen 0.2, cheekPuff 0.2
- concern → mouthFrown 0.55, browInnerUp 0.6, noseSneer 0.15
- empathy → eyeSquint 0.4, browInnerUp 0.5
@@ -108,6 +117,7 @@ Continuous weighted blend of `{ neutral, concern, celebration, patience, curiosi
- patience → eyesClosed 0.15 (subtle)
### Head transform
+
Z-rotation = `(curiosity*12 + empathy*9 + concern*4)` degrees. X-rotation (lean) = `curiosity*0.03 - patience*0.02`. Finds `Head` or `Neck` bone in skeleton.
**Don't add a discrete emotion FSM.** The whole point is the continuous blend.
@@ -131,7 +141,7 @@ Z-rotation = `(curiosity*12 + empathy*9 + concern*4)` degrees. X-rotation (lean)
- **`window.VIEWER`** is a debug global exposing `.editor, .agent, .agent_protocol, .agent_avatar, .agent_skills, .runtime, .scene_ctrl`. Never rely on it in production code — use closure / DI.
- **Manifest `_baseURI`** must end with `/` for relative resolution of `body.uri`, `SKILL.md`, `tools.json`, `handlers.js`.
-- **Viewer._afterAnimateHooks** — avatar hooks its `_tickEmotion` here for per-frame decay. Fragile coupling; don't rearrange.
+- **Viewer.\_afterAnimateHooks** — avatar hooks its `_tickEmotion` here for per-frame decay. Fragile coupling; don't rearrange.
- **SpeechRecognition** silently noops if unavailable. Check `window.SpeechRecognition || window.webkitSpeechRecognition` before relying.
- **Morph traversal** iterates every mesh every frame. Cheap on Mixamo avatars, expensive on scene-scale models — don't add per-vertex work.
- **Skill `owned-only` trust** compares `manifest.author` with `ownerAddress` from element attr or backend. Mismatch → skill load throws.
diff --git a/src/agent-avatar.js b/src/agent-avatar.js
index b73a7fe8f..d46224557 100644
--- a/src/agent-avatar.js
+++ b/src/agent-avatar.js
@@ -594,13 +594,14 @@ export class AgentAvatar {
AgentAvatar.HEAD_MAX_LEAN,
);
- // Apply as an offset from rest pose, not an absolute rotation — otherwise
- // rigs with non-zero rest rotation on the head bone snap toward world zero.
+ // Apply pre-smoothed values directly — _currentTilt/Lean/Yaw are already
+ // dt-lerped above, so a second lerp on the live bone value would fight the
+ // animation mixer and cause visible head bobbing.
const r = this._headRestRotation;
const b = this._headBone;
- b.rotation.z = _lerp(b.rotation.z, r.z + tilt, 0.1);
- b.rotation.x = _lerp(b.rotation.x, r.x + lean, 0.1);
- b.rotation.y = _lerp(b.rotation.y, r.y + yaw, 0.1);
+ b.rotation.z = r.z + tilt;
+ b.rotation.x = r.x + lean;
+ b.rotation.y = r.y + yaw;
}
/**
diff --git a/src/agent-embed-modal.js b/src/agent-embed-modal.js
new file mode 100644
index 000000000..0a124873f
--- /dev/null
+++ b/src/agent-embed-modal.js
@@ -0,0 +1,115 @@
+/**
+ * Embed modal for the agent hub page.
+ * Shows iframe + web-component snippets with copy-to-clipboard.
+ */
+export class AgentEmbedModal {
+ /**
+ * @param {string} agentId
+ */
+ constructor(agentId) {
+ this._id = agentId;
+ this._modal = null;
+ this._onKey = this._onKey.bind(this);
+ }
+
+ open() {
+ if (this._modal) return;
+ this._build();
+ document.body.appendChild(this._modal);
+ document.addEventListener('keydown', this._onKey);
+ requestAnimationFrame(() => this._modal.classList.add('aem-open'));
+ }
+
+ close() {
+ if (!this._modal) return;
+ document.removeEventListener('keydown', this._onKey);
+ this._modal.remove();
+ this._modal = null;
+ }
+
+ _onKey(e) {
+ if (e.key === 'Escape') this.close();
+ }
+
+ _build() {
+ const origin = location.origin;
+ const id = this._id;
+ const snippets = {
+ iframe:
+ `<iframe\n` +
+ ` src="${origin}/agent/${id}/embed"\n` +
+ ` width="420" height="520"\n` +
+ ` style="border:0;border-radius:12px"\n` +
+ ` allow="autoplay; xr-spatial-tracking"\n` +
+ `></iframe>`,
+ webcomponent:
+ `<script type="module"\n` +
+ ` src="${origin}/dist-lib/agent-3d.js"\n` +
+ `><\/script>\n` +
+ `<agent-3d\n` +
+ ` agent-id="${id}"\n` +
+ ` style="width:420px;height:520px"\n` +
+ `></agent-3d>`,
+ };
+
+ const overlay = document.createElement('div');
+ overlay.className = 'aem-overlay';
+ overlay.innerHTML = `
+ <div class="aem-modal" role="dialog" aria-modal="true" aria-label="Embed this agent">
+ <div class="aem-header">
+ <span class="aem-title">Embed this agent</span>
+ <button class="aem-close" aria-label="Close">&times;</button>
+ </div>
+ <div class="aem-body">
+ <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>
+ </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>
+ </div>
+ </div>
+ `;
+
+ let current = 'iframe';
+ const snippetEl = overlay.querySelector('#aem-snippet-text');
+ const copyBtn = overlay.querySelector('#aem-copy-btn');
+
+ const renderSnippet = () => {
+ snippetEl.textContent = snippets[current];
+ };
+ renderSnippet();
+
+ 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();
+ });
+ });
+
+ copyBtn.addEventListener('click', async () => {
+ try {
+ await navigator.clipboard.writeText(snippets[current]);
+ copyBtn.textContent = 'copied!';
+ copyBtn.classList.add('aem-copied');
+ setTimeout(() => {
+ copyBtn.textContent = 'copy';
+ copyBtn.classList.remove('aem-copied');
+ }, 1400);
+ } catch {}
+ });
+
+ overlay.querySelector('.aem-close').addEventListener('click', () => this.close());
+ overlay.addEventListener('click', (e) => {
+ if (e.target === overlay) this.close();
+ });
+
+ this._modal = overlay;
+ }
+}
diff --git a/src/agent-hub-actions.js b/src/agent-hub-actions.js
new file mode 100644
index 000000000..8b86a2565
--- /dev/null
+++ b/src/agent-hub-actions.js
@@ -0,0 +1,148 @@
+/**
+ * Hub actions row for the /agent/:id page.
+ * Renders four CTAs (Customize, Embed, Deploy on-chain, Edit avatar)
+ * into the agent-home-panel, above the timeline.
+ *
+ * Only shown to the agent's owner. Non-owners see the unmodified panel.
+ */
+import { AgentEmbedModal } from './agent-embed-modal.js';
+
+/**
+ * @param {HTMLElement} panel — .agent-home-panel element
+ * @param {import('./agent-identity.js').AgentIdentity} identity
+ * @param {Object} rawAgent — raw API response (includes chain_id, is_registered when owner)
+ */
+export function renderHubActions(panel, identity, rawAgent) {
+ const agentId = identity.id;
+ const isRegistered = Boolean(rawAgent.is_registered);
+ const chainId = rawAgent.chain_id || null;
+ const walletAddress = rawAgent.wallet_address || null;
+ const erc8004Registry = rawAgent.erc8004_registry || null;
+ const erc8004AgentId = rawAgent.erc8004_agent_id || null;
+
+ const row = document.createElement('div');
+ row.className = 'agent-hub-actions';
+ row.innerHTML = `
+ <button class="agent-hub-btn" id="hub-customize" title="Open the editing surface">
+ ${_iconGear()}
+ <span>Customize</span>
+ </button>
+ <button class="agent-hub-btn" id="hub-embed" title="Get embed code">
+ ${_iconCode()}
+ <span>Embed</span>
+ </button>
+ <button class="agent-hub-btn${isRegistered ? ' hub-btn--deployed' : ''}" id="hub-deploy"
+ title="${isRegistered ? 'View registry record' : 'Deploy on-chain — optional'}">
+ ${_iconChain()}
+ <span>${isRegistered ? _deployedLabel(chainId, walletAddress, erc8004AgentId) : 'Deploy on-chain'}</span>
+ ${isRegistered ? '' : '<span class="agent-hub-opt">· Optional</span>'}
+ </button>
+ <button class="agent-hub-btn" id="hub-edit" title="Edit avatar">
+ ${_iconPencil()}
+ <span>Edit avatar</span>
+ </button>
+ `;
+
+ // Customize → /app?agent=:id
+ row.querySelector('#hub-customize').addEventListener('click', () => {
+ location.href = `/app?agent=${agentId}`;
+ });
+
+ // Embed → open modal
+ const embedModal = new AgentEmbedModal(agentId);
+ row.querySelector('#hub-embed').addEventListener('click', () => embedModal.open());
+
+ // Deploy on-chain → RegisterUI (lazy-imported) OR open explorer link if already deployed
+ const deployBtn = row.querySelector('#hub-deploy');
+ if (isRegistered) {
+ deployBtn.addEventListener('click', async () => {
+ const { addressExplorerUrl } = await import('./erc8004/chain-meta.js');
+ const { REGISTRY_DEPLOYMENTS } = await import('./erc8004/abi.js');
+ const registry =
+ erc8004Registry || REGISTRY_DEPLOYMENTS?.[chainId]?.identityRegistry || null;
+ const url = registry && chainId ? addressExplorerUrl(chainId, registry) : null;
+ if (url) window.open(url, '_blank', 'noopener');
+ });
+ } else {
+ deployBtn.addEventListener('click', async () => {
+ deployBtn.disabled = true;
+ deployBtn.querySelector('span').textContent = 'Opening…';
+ try {
+ const { RegisterUI } = await import('./erc8004/register-ui.js');
+ const wrap = document.createElement('div');
+ wrap.className = 'agent-register-overlay';
+ document.body.appendChild(wrap);
+ new RegisterUI(wrap, () => {
+ wrap.remove();
+ location.reload();
+ });
+ } catch (err) {
+ console.error('[hub] register-ui load failed', err);
+ deployBtn.disabled = false;
+ deployBtn.querySelector('span').textContent = 'Deploy on-chain';
+ }
+ });
+ }
+
+ // Edit avatar → /agent/:id/edit
+ row.querySelector('#hub-edit').addEventListener('click', () => {
+ location.href = `/agent/${agentId}/edit`;
+ });
+
+ // Insert above the timeline (but below identity card + skills)
+ const timeline = panel.querySelector('#agent-timeline');
+ if (timeline) {
+ panel.insertBefore(row, timeline);
+ } else {
+ panel.appendChild(row);
+ }
+}
+
+// ── Icon helpers (inline SVG, consistent with existing nav icons) ─────────────
+
+function _iconGear() {
+ return `<svg width="13" height="13" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true">
+ <path d="M19.14 12.94c.04-.3.06-.61.06-.94s-.02-.64-.07-.94l2.03-1.58a.49.49 0 0 0 .12-.61l-1.92-3.32a.49.49 0 0 0-.59-.22l-2.39.96a7.01 7.01 0 0 0-1.62-.94l-.36-2.54a.484.484 0 0 0-.48-.41h-3.84c-.24 0-.43.17-.47.41l-.36 2.54c-.59.24-1.13.57-1.62.94l-2.39-.96a.488.488 0 0 0-.59.22L2.74 8.87a.48.48 0 0 0 .12.61l2.03 1.58c-.05.3-.07.62-.07.94s.02.64.07.94l-2.03 1.58a.49.49 0 0 0-.12.61l1.92 3.32c.12.22.37.29.59.22l2.39-.96c.5.37 1.04.7 1.62.94l.36 2.54c.05.24.24.41.48.41h3.84c.24 0 .44-.17.47-.41l.36-2.54c.59-.24 1.13-.57 1.62-.94l2.39.96c.22.08.47 0 .59-.22l1.92-3.32a.49.49 0 0 0-.12-.61l-2.01-1.58zM12 15.6c-1.98 0-3.6-1.62-3.6-3.6s1.62-3.6 3.6-3.6 3.6 1.62 3.6 3.6-1.62 3.6-3.6 3.6z"/>
+ </svg>`;
+}
+
+function _iconCode() {
+ return `<svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
+ <polyline points="16 18 22 12 16 6"/><polyline points="8 6 2 12 8 18"/>
+ </svg>`;
+}
+
+function _iconChain() {
+ return `<svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
+ <path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"/>
+ <path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"/>
+ </svg>`;
+}
+
+function _iconPencil() {
+ return `<svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
+ <path d="M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"/>
+ <path d="M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"/>
+ </svg>`;
+}
+
+function _deployedLabel(chainId, walletAddress, erc8004AgentId) {
+ const names = {
+ 1: 'Ethereum',
+ 10: 'Optimism',
+ 56: 'BNB',
+ 137: 'Polygon',
+ 8453: 'Base',
+ 42161: 'Arbitrum',
+ 97: 'BSC Testnet',
+ 84532: 'Base Sepolia',
+ 11155111: 'Sepolia',
+ };
+ const chain = names[chainId] || `Chain ${chainId || '?'}`;
+ const tag = erc8004AgentId
+ ? `#${erc8004AgentId}`
+ : walletAddress
+ ? `${walletAddress.slice(0, 6)}…${walletAddress.slice(-4)}`
+ : '';
+ return tag ? `${chain} · ${tag}` : chain;
+}
diff --git a/src/animation-manager.js b/src/animation-manager.js
index 2c6e1ea87..c27dba619 100644
--- a/src/animation-manager.js
+++ b/src/animation-manager.js
@@ -1,5 +1,6 @@
import { AnimationMixer, LoopRepeat, LoopOnce } from 'three';
import { GLTFLoader } from 'three/addons/loaders/GLTFLoader.js';
+import { FBXLoader } from 'three/addons/loaders/FBXLoader.js';
/**
* Manages loading external animation clips (e.g. from Mixamo) and applying
@@ -31,6 +32,8 @@ export class AnimationManager {
this.currentAction = null;
/** @type {GLTFLoader} */
this.loader = new GLTFLoader();
+ /** @type {FBXLoader} */
+ this.fbxLoader = new FBXLoader();
/** @type {Function|null} */
this.onChange = null;
/** @type {Map<string, object>} - Cache of loaded GLTF objects by URL */
@@ -108,27 +111,30 @@ export class AnimationManager {
return this.clips.get(name);
}
- // Check if we already loaded this URL (multi-animation GLB reuse)
- let gltf;
+ // Check if we already loaded this URL
+ let animations;
if (this._gltfCache.has(url)) {
- gltf = this._gltfCache.get(url);
+ animations = this._gltfCache.get(url);
} else {
- gltf = await new Promise((resolve, reject) => {
- this.loader.load(url, resolve, undefined, reject);
+ const isFbx = url.toLowerCase().endsWith('.fbx');
+ const loaded = await new Promise((resolve, reject) => {
+ (isFbx ? this.fbxLoader : this.loader).load(url, resolve, undefined, reject);
});
- this._gltfCache.set(url, gltf);
+ // FBX: loaded is the scene object with .animations; GLTF: loaded.animations
+ animations = loaded.animations || [];
+ this._gltfCache.set(url, animations);
}
// Find the right clip: by clipName if specified, otherwise first clip
let clip;
if (options.clipName) {
- clip = gltf.animations.find((a) => a.name === options.clipName);
+ clip = animations.find((a) => a.name === options.clipName);
if (!clip) {
console.warn(`[AnimationManager] Clip "${options.clipName}" not found in ${url}, using first clip`);
- clip = gltf.animations[0];
+ clip = animations[0];
}
} else {
- clip = gltf.animations[0];
+ clip = animations[0];
}
if (!clip) {
@@ -299,7 +305,9 @@ export class AnimationManager {
})
.filter(Boolean);
- return clip.clone().resetDuration();
+ const newClip = clip.clone();
+ newClip.tracks = newTracks;
+ return newClip;
}
/**
diff --git a/src/app.js b/src/app.js
index 22798d7ad..b96fbae0f 100644
--- a/src/app.js
+++ b/src/app.js
@@ -28,6 +28,26 @@ import { SkillRegistry } from './skills/index.js';
window.THREE = THREE;
window.VIEWER = {};
+function _blobToBase64(blob) {
+ return new Promise((resolve, reject) => {
+ const reader = new FileReader();
+ reader.onload = () => {
+ const s = reader.result;
+ const comma = s.indexOf(',');
+ resolve(comma >= 0 ? s.slice(comma + 1) : s);
+ };
+ reader.onerror = () => reject(reader.error);
+ reader.readAsDataURL(blob);
+ });
+}
+
+function _base64ToFile(b64, name, type) {
+ const bin = atob(b64);
+ const bytes = new Uint8Array(bin.length);
+ for (let i = 0; i < bin.length; i++) bytes[i] = bin.charCodeAt(i);
+ return new File([bytes], name, { type });
+}
+
if (!(window.File && window.FileReader && window.FileList && window.Blob)) {
console.error('The File APIs are not fully supported in this browser.');
} else if (!WebGL.isWebGL2Available()) {
@@ -41,6 +61,11 @@ class App {
*/
constructor(el, location) {
const hash = location.hash ? queryString.parse(location.hash) : {};
+ const qp = new URLSearchParams(location.search);
+ // agentQuery: from ?agent= query param → editing mode (main UI with save-back)
+ // agentHash: from #agent= hash → legacy embed mode
+ const agentQuery = qp.get('agent') || '';
+ const agentHash = hash.agent || '';
this.options = {
kiosk: Boolean(hash.kiosk),
model: hash.model || '',
@@ -48,9 +73,12 @@ class App {
cameraPosition: hash.cameraPosition ? hash.cameraPosition.split(',').map(Number) : null,
brain: hash.brain || 'none',
proxyURL: hash.proxyURL || '',
- agent: hash.agent || '',
+ agent: agentHash, // hash-based agent keeps legacy embed behaviour
+ agentEdit: agentQuery, // query-param agent → editing surface
widget: hash.widget || '',
register: hash.register !== undefined,
+ // pending=1 signals a post-login save round-trip
+ pending: qp.get('pending') === '1',
};
this.el = el;
@@ -76,11 +104,15 @@ class App {
// Wire validator results into the protocol
this._hookValidator();
+ this._editingAgentId = this.options.agentEdit || null;
+
this.createDropzone();
this.setupAvatarCreator();
this.hideSpinner();
this._applyViewerMode();
this._updateSignInLink();
+ this._setupSaveToAccount();
+ this._setupMakeWidgetButton();
const options = this.options;
@@ -95,7 +127,7 @@ class App {
return;
}
- // Load a specific agent by ID: /#agent=<uuid>
+ // Load a specific agent by ID: /#agent=<uuid> (embed mode)
if (options.agent) {
this._loadAgent(options.agent);
return;
@@ -109,9 +141,19 @@ class App {
return;
}
- // Resume a stashed editor session (post-login round-trip), else
- // load the model named in the URL or fall back to the CZ avatar.
- this._maybeResumeOrLoad(options);
+ // Editing an existing agent: ?agent=<uuid> (authenticated editing surface)
+ if (options.agentEdit) {
+ this._loadAgentForEdit(options.agentEdit);
+ } else {
+ // Resume a stashed editor session (post-login round-trip), else
+ // load the model named in the URL or fall back to the CZ avatar.
+ this._maybeResumeOrLoad(options);
+ }
+
+ // After sign-in redirect, check for a pending_save stash.
+ if (options.pending) {
+ this._maybePendingSave();
+ }
// Boot the agent system once identity is ready
this._initAgentSystem();
@@ -299,14 +341,227 @@ class App {
const btn = document.getElementById('make-widget-btn');
if (!btn) return;
const url = this._currentModelUrl;
- if (!url) {
+ if (!url && !this._hasLocalGlb) {
btn.hidden = true;
return;
}
- btn.href = `/studio?model=${encodeURIComponent(url)}`;
+ if (url) {
+ btn.href = `/studio?model=${encodeURIComponent(url)}`;
+ }
btn.hidden = false;
}
+ _refreshSaveToAccountButton() {
+ const btn = document.getElementById('save-to-account-btn');
+ if (!btn) return;
+ const hasModel = this._currentModelUrl || this._hasLocalGlb;
+ btn.hidden = !hasModel;
+ }
+
+ _setupSaveToAccount() {
+ const btn = document.getElementById('save-to-account-btn');
+ if (!btn) return;
+ btn.addEventListener('click', (e) => {
+ e.preventDefault();
+ this._triggerSaveToAccount();
+ });
+ }
+
+ _setupMakeWidgetButton() {
+ const btn = document.getElementById('make-widget-btn');
+ if (!btn) return;
+ btn.addEventListener('click', async (e) => {
+ const user = await getMe();
+ if (!user) {
+ e.preventDefault();
+ await this._stashAndRedirectToLogin();
+ }
+ // Authed: let the href navigate to /studio normally.
+ });
+ }
+
+ async _triggerSaveToAccount() {
+ const user = await getMe();
+ if (!user) {
+ await this._stashAndRedirectToLogin();
+ return;
+ }
+ await this._performSave(user);
+ }
+
+ async _stashAndRedirectToLogin() {
+ const btn = document.getElementById('save-to-account-btn');
+ if (btn) {
+ btn.setAttribute('disabled', '');
+ btn.querySelector('span').textContent = 'Preparing…';
+ }
+
+ const stash = {
+ glbUrl: this._currentModelUrl || null,
+ fileName: this._currentLocalFile?.name || null,
+ fileB64: null,
+ returnTo: '/app',
+ agentId: this._editingAgentId || null,
+ ts: Date.now(),
+ };
+
+ // Local file drops can't be re-hydrated from a blob URL after reload.
+ // Encode as base64 and stash — sessionStorage quota is ~5MB, so this
+ // fails gracefully for oversized GLBs (user re-drops after sign-in).
+ if (this._currentLocalFile) {
+ try {
+ stash.fileB64 = await _blobToBase64(this._currentLocalFile);
+ stash.contentType = this._currentLocalFile.type || 'model/gltf-binary';
+ } catch {
+ /* fall through without file data */
+ }
+ }
+
+ try {
+ sessionStorage.setItem('pending_save', JSON.stringify(stash));
+ } catch {
+ // Quota exceeded — drop the file payload and retry with just metadata
+ delete stash.fileB64;
+ try {
+ sessionStorage.setItem('pending_save', JSON.stringify(stash));
+ } catch {
+ /* storage disabled — proceed without stash */
+ }
+ }
+ location.href = '/login?next=' + encodeURIComponent('/app?pending=1');
+ }
+
+ async _performSave(user) {
+ if (!user) return;
+ const btn = document.getElementById('save-to-account-btn');
+ if (btn) {
+ btn.setAttribute('disabled', '');
+ btn.querySelector('span').textContent = 'Saving…';
+ }
+ try {
+ let avatarId;
+ const source = this._currentLocalFile || this._currentModelUrl;
+ if (!source) {
+ // Nothing to save — reset UI and bail
+ if (btn) {
+ btn.removeAttribute('disabled');
+ btn.querySelector('span').textContent = 'Save to account';
+ }
+ return;
+ }
+ const avatar = await saveRemoteGlbToAccount(source, {
+ source: this._currentLocalFile ? 'upload' : 'import',
+ name: this._currentLocalFile?.name,
+ source_meta: this._currentLocalFile
+ ? { original_filename: this._currentLocalFile.name }
+ : undefined,
+ });
+ avatarId = avatar.id;
+
+ if (this._editingAgentId) {
+ // Update existing agent's avatar
+ if (avatarId) {
+ await fetch(`/api/agents/${this._editingAgentId}`, {
+ method: 'PUT',
+ credentials: 'include',
+ headers: { 'content-type': 'application/json' },
+ body: JSON.stringify({ avatar_id: avatarId }),
+ });
+ }
+ location.href = `/agent/${this._editingAgentId}`;
+ } else {
+ // Create a new agent linked to the uploaded avatar
+ const res = await fetch('/api/agents/me', {
+ method: 'GET',
+ credentials: 'include',
+ });
+ const data = res.ok ? await res.json() : null;
+ let agentId = data?.agent?.id;
+
+ if (!agentId) {
+ const created = await fetch('/api/agents', {
+ method: 'POST',
+ credentials: 'include',
+ headers: { 'content-type': 'application/json' },
+ body: JSON.stringify({ name: 'My Agent' }),
+ });
+ const createdData = created.ok ? await created.json() : null;
+ agentId = createdData?.agent?.id;
+ }
+
+ if (agentId && avatarId) {
+ await fetch(`/api/agents/${agentId}`, {
+ method: 'PUT',
+ credentials: 'include',
+ headers: { 'content-type': 'application/json' },
+ body: JSON.stringify({ avatar_id: avatarId }),
+ });
+ }
+
+ if (agentId) {
+ location.href = `/agent/${agentId}`;
+ } else {
+ this._flashSaved({ name: 'your account' });
+ if (btn) {
+ btn.removeAttribute('disabled');
+ btn.querySelector('span').textContent = 'Save to account';
+ }
+ }
+ }
+ } catch (err) {
+ console.warn('[3d-agent] save failed:', err.message);
+ if (btn) {
+ btn.removeAttribute('disabled');
+ btn.querySelector('span').textContent = 'Save to account';
+ }
+ }
+ }
+
+ async _maybePendingSave() {
+ let stash;
+ try {
+ const raw = sessionStorage.getItem('pending_save');
+ if (!raw) return;
+ stash = JSON.parse(raw);
+ } catch {
+ return;
+ }
+
+ // Stale stashes (older than 1 hour) are discarded — the user likely
+ // abandoned the sign-in flow and we shouldn't silently replay old work.
+ if (!stash || !stash.ts || Date.now() - stash.ts > 60 * 60 * 1000) {
+ sessionStorage.removeItem('pending_save');
+ return;
+ }
+
+ const user = await getMe();
+ if (!user) return; // still not authed — leave stash intact
+
+ sessionStorage.removeItem('pending_save');
+
+ // Restore the editing context from the stash
+ if (stash.agentId) this._editingAgentId = stash.agentId;
+
+ // Re-hydrate the model: local file (base64) takes priority over remote URL
+ if (stash.fileB64 && stash.fileName) {
+ const file = _base64ToFile(
+ stash.fileB64,
+ stash.fileName,
+ stash.contentType || 'model/gltf-binary',
+ );
+ await this.load(new Map([[stash.fileName, file]]));
+ } else if (stash.glbUrl && stash.glbUrl !== this._currentModelUrl) {
+ await this.view(stash.glbUrl, '', new Map());
+ }
+
+ // Strip ?pending from URL before saving
+ const clean = new URL(location.href);
+ clean.searchParams.delete('pending');
+ history.replaceState(null, '', clean.toString());
+
+ await this._performSave(user);
+ }
+
async _loadAgent(agentId) {
this.identity = new AgentIdentity({ agentId, autoLoad: false });
await this.identity.load();
@@ -330,6 +585,36 @@ class App {
this._initAgentSystem();
}
+ async _loadAgentForEdit(agentId) {
+ // Fetch the agent record and load its GLB into the editor (main UI, not embed)
+ let glbUrl = null;
+ try {
+ const resp = await fetch(`/api/agents/${agentId}`, { credentials: 'include' });
+ if (resp.ok) {
+ const { agent } = await resp.json();
+ if (agent?.avatar_id) {
+ const avatarResp = await fetch(`/api/avatars/${agent.avatar_id}`, {
+ credentials: 'include',
+ });
+ if (avatarResp.ok) {
+ const { avatar } = await avatarResp.json();
+ if (avatar?.url) glbUrl = avatar.url;
+ }
+ }
+ }
+ } catch {
+ /* fall through to default */
+ }
+
+ if (glbUrl) {
+ await this.view(glbUrl, '', new Map());
+ } else {
+ this._maybeResumeOrLoad(this.options);
+ }
+ this._initAgentSystem();
+ this._initWidgetBridge();
+ }
+
async _loadWidget(widgetId) {
let widget;
try {
@@ -553,7 +838,10 @@ class App {
const fileURL = typeof rootFile === 'string' ? rootFile : URL.createObjectURL(rootFile);
this._currentModelUrl = typeof rootFile === 'string' ? rootFile : null;
+ this._hasLocalGlb = typeof rootFile !== 'string';
+ this._currentLocalFile = typeof rootFile !== 'string' ? rootFile : null;
this._refreshMakeWidgetButton();
+ this._refreshSaveToAccountButton();
// Emit load start
protocol.emit({
@@ -736,16 +1024,7 @@ class App {
}
_showRegisterPage() {
- this.dropEl.style.display = 'none';
- import('./erc8004/register-ui.js').then(({ RegisterUI }) => {
- new RegisterUI(this.viewerContainerEl, (result) => {
- console.info('[ERC-8004] Agent registered:', result);
- this.identity.update({
- isRegistered: true,
- meta: { ...this.identity.meta, erc8004: result },
- });
- });
- });
+ window.location.replace('/register');
}
showSpinner() {
diff --git a/src/avatar-creator.js b/src/avatar-creator.js
index d45d8ebac..e37e21751 100644
--- a/src/avatar-creator.js
+++ b/src/avatar-creator.js
@@ -18,12 +18,32 @@
function getStudioUrl() {
try {
if (typeof import.meta !== 'undefined' && import.meta.env?.VITE_CHARACTER_STUDIO_URL) {
- return String(import.meta.env.VITE_CHARACTER_STUDIO_URL).trim().replace(/\/$/, '');
+ return String(import.meta.env.VITE_CHARACTER_STUDIO_URL)
+ .trim()
+ .replace(/\/$/, '');
}
} catch (_) {}
return 'http://localhost:5173';
}
+function getAvaturnEditorUrl() {
+ let base = 'https://editor.avaturn.me/';
+ let devId = '';
+ try {
+ if (typeof import.meta !== 'undefined' && import.meta.env) {
+ if (import.meta.env.VITE_AVATURN_EDITOR_URL) {
+ base = String(import.meta.env.VITE_AVATURN_EDITOR_URL).trim();
+ }
+ if (import.meta.env.VITE_AVATURN_DEVELOPER_ID) {
+ devId = String(import.meta.env.VITE_AVATURN_DEVELOPER_ID).trim();
+ }
+ }
+ } catch (_) {}
+ if (!devId) return base;
+ const sep = base.includes('?') ? '&' : '?';
+ return base + sep + 'developer=' + encodeURIComponent(devId);
+}
+
export class AvatarCreator {
/**
* @param {Element} containerEl - Parent element to mount the modal into
@@ -57,14 +77,40 @@ export class AvatarCreator {
if (sessionUrl) {
// @avaturn/sdk is not installed — use raw iframe.
// If you install @avaturn/sdk, replace this with: new AvaturnSDK({ ... })
- console.info('[AvatarCreator] opening Avaturn session (raw iframe — no SDK):', sessionUrl);
- try { this._avaturnOrigin = new URL(sessionUrl).origin; } catch (_) {}
+ console.info(
+ '[AvatarCreator] opening Avaturn session (raw iframe — no SDK):',
+ sessionUrl,
+ );
+ try {
+ this._avaturnOrigin = new URL(sessionUrl).origin;
+ } catch (_) {}
this.iframe.src = sessionUrl;
} else {
this.iframe.src = this.studioUrl;
}
}
+ /**
+ * Opens the Avaturn default hosted editor — no session API, no selfies required.
+ * User edits a ready-made avatar and exports a GLB. Export event is handled by
+ * the same `_handleAvaturnMessage` pipeline as the session-based flow.
+ */
+ async openDefaultEditor() {
+ if (this.modal) return;
+ const editorUrl = getAvaturnEditorUrl();
+ this._avaturnMode = true;
+ try {
+ this._avaturnOrigin = new URL(editorUrl).origin;
+ } catch (_) {
+ this._avaturnOrigin = null;
+ }
+ this._buildModal();
+ this._onMessage = (event) => this._handleMessage(event);
+ window.addEventListener('message', this._onMessage);
+ console.info('[AvatarCreator] opening Avaturn default editor:', editorUrl);
+ this.iframe.src = editorUrl;
+ }
+
_handleMessage(event) {
if (this._avaturnMode) {
this._handleAvaturnMessage(event);
@@ -90,7 +136,7 @@ export class AvatarCreator {
}
async _handleAvaturnMessage(event) {
- if (this._avaturnOrigin && event.origin !== this._avaturnOrigin) return;
+ if (!this._avaturnOrigin || event.origin !== this._avaturnOrigin) return;
const msg = event.data;
if (!msg) return;
@@ -108,7 +154,9 @@ export class AvatarCreator {
const resp = await fetch(glbUrl);
if (!resp.ok) throw new Error(`GLB fetch failed: ${resp.status}`);
const blob = await resp.blob();
- const glbBlob = blob.type ? blob : new Blob([await blob.arrayBuffer()], { type: 'model/gltf-binary' });
+ const glbBlob = blob.type
+ ? blob
+ : new Blob([await blob.arrayBuffer()], { type: 'model/gltf-binary' });
this._fireExport(glbBlob);
} catch (err) {
console.error('[AvatarCreator] failed to fetch Avaturn GLB:', err);
@@ -163,7 +211,9 @@ export class AvatarCreator {
if (loading) loading.style.display = 'none';
});
- this.modal.querySelector('.avatar-creator-close').addEventListener('click', () => this.close());
+ this.modal
+ .querySelector('.avatar-creator-close')
+ .addEventListener('click', () => this.close());
this.modal.addEventListener('click', (e) => {
if (e.target === this.modal) this.close();
});
diff --git a/src/create.js b/src/create.js
new file mode 100644
index 000000000..45d01fe0b
--- /dev/null
+++ b/src/create.js
@@ -0,0 +1,122 @@
+import { apiFetch, getMe, saveRemoteGlbToAccount } from './account.js';
+import { AvatarCreator } from './avatar-creator.js';
+
+// GLB magic bytes: ASCII "glTF"
+const GLB_MAGIC = [0x67, 0x6c, 0x54, 0x46];
+
+async function boot() {
+ const user = await getMe();
+ if (!user) {
+ window.location.href = '/login?next=/create';
+ return;
+ }
+
+ const creator = new AvatarCreator(document.body, (blob) =>
+ saveAndRedirect(blob, { source: 'avaturn' }),
+ );
+
+ document.getElementById('back-btn').addEventListener('click', () => {
+ if (history.length > 1) history.back();
+ else window.location.href = '/';
+ });
+
+ wireCard('card-default-editor', () => creator.openDefaultEditor());
+ wireCard('card-upload-glb', (e) => {
+ // Tooltip anchors live inside the card; let them navigate normally.
+ if (e && e.target && e.target.closest('a')) return;
+ document.getElementById('glb-input').click();
+ });
+
+ document.getElementById('glb-input').addEventListener('change', async (e) => {
+ const file = e.target.files?.[0];
+ if (!file) return;
+ e.target.value = '';
+ await handleGlbFile(file);
+ });
+}
+
+// Cards are divs with role="button", so we need to wire both click and
+// keyboard activation (Enter / Space) ourselves — native <button> semantics.
+function wireCard(id, handler) {
+ const el = document.getElementById(id);
+ if (!el) return;
+ el.addEventListener('click', handler);
+ el.addEventListener('keydown', (e) => {
+ if (el.getAttribute('aria-disabled') === 'true') return;
+ if (e.key === 'Enter' || e.key === ' ') {
+ e.preventDefault();
+ handler(e);
+ }
+ });
+}
+
+async function handleGlbFile(file) {
+ if (!file.name.toLowerCase().endsWith('.glb')) {
+ showStatus('Please select a .glb file.', 'error');
+ return;
+ }
+
+ const header = new Uint8Array(await file.slice(0, 4).arrayBuffer());
+ if (!GLB_MAGIC.every((b, i) => header[i] === b)) {
+ showStatus("File doesn't appear to be a valid GLB.", 'error');
+ return;
+ }
+
+ const name = file.name.replace(/\.glb$/i, '').trim() || 'My Avatar';
+ await saveAndRedirect(file, { source: 'upload', name });
+}
+
+async function saveAndRedirect(blob, meta = {}) {
+ showStatus('Uploading avatar…', 'loading');
+ try {
+ const avatar = await saveRemoteGlbToAccount(blob, meta);
+ const agent = await attachAvatarToAgent(avatar.id, meta.name);
+ window.location.href = '/agent/' + agent.id;
+ } catch (err) {
+ if (!err.redirected) showStatus(err.message || 'Upload failed.', 'error');
+ }
+}
+
+// Associates the uploaded avatar with the caller's default agent. POST /api/agents
+// doesn't accept avatar_id, so we get-or-create via /me and then PUT to attach.
+async function attachAvatarToAgent(avatarId, name) {
+ const meRes = await apiFetch('/api/agents/me');
+ const meData = await meRes.json();
+ if (!meRes.ok) throw new Error(meData.error_description || 'Failed to load agent.');
+
+ let agent = meData.agent;
+ if (!agent) {
+ const createRes = await apiFetch('/api/agents', {
+ method: 'POST',
+ headers: { 'content-type': 'application/json' },
+ body: JSON.stringify({ name: name || 'My Agent' }),
+ });
+ const createData = await createRes.json();
+ if (!createRes.ok)
+ throw new Error(createData.error_description || 'Failed to create agent.');
+ agent = createData.agent;
+ }
+
+ const putRes = await apiFetch('/api/agents/' + agent.id, {
+ method: 'PUT',
+ headers: { 'content-type': 'application/json' },
+ body: JSON.stringify({ avatar_id: avatarId }),
+ });
+ const putData = await putRes.json();
+ if (!putRes.ok) throw new Error(putData.error_description || 'Failed to attach avatar.');
+ return putData.agent;
+}
+
+function showStatus(msg, type = 'info') {
+ const el = document.getElementById('status-toast');
+ el.textContent = msg;
+ el.className = 'status-toast ' + type;
+ el.hidden = false;
+ if (type !== 'loading') {
+ setTimeout(() => {
+ el.hidden = true;
+ }, 4500);
+ }
+}
+
+boot();
diff --git a/src/erc8004/batch-tab.js b/src/erc8004/batch-tab.js
new file mode 100644
index 000000000..22839f10a
--- /dev/null
+++ b/src/erc8004/batch-tab.js
@@ -0,0 +1,255 @@
+/**
+ * Batch registration tab for ERC-8004 agents.
+ *
+ * Drop a CSV (`name,description,serviceType,endpoint`) or a JSON array of
+ * agent configs, preview the queue, then run the same pipeline as step-4 of
+ * the single-agent wizard (register(string) with a data-URI registration JSON)
+ * for each row.
+ *
+ * Port of reference logic from erc8004.agency (`handleBatchFile`,
+ * `renderBatchPreview`, `executeBatch`). Lightly adapted to our DOM + the
+ * helpers already exported by agent-registry.js.
+ */
+
+import { connectWallet, getIdentityRegistry } from './agent-registry.js';
+import { REGISTRY_DEPLOYMENTS } from './abi.js';
+import { CHAIN_META, switchChain, txExplorerUrl } from './chain-meta.js';
+
+const esc = (s) =>
+ String(s ?? '').replace(
+ /[&<>"']/g,
+ (c) => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;' })[c],
+ );
+
+/**
+ * Render the Batch tab into `body`, wired to the surrounding RegisterUI.
+ *
+ * @param {HTMLElement} body Container element — cleared and repopulated.
+ * @param {object} ctx
+ * @param {() => (null | { address: string, chainId: number })} ctx.getWallet
+ * @param {() => number} ctx.getChainId
+ * @param {(msg: string, isError?: boolean) => void} ctx.toast
+ */
+export function renderBatchTab(body, ctx) {
+ body.innerHTML = `
+ <h3 class="erc8004-h3">Batch Registration</h3>
+ <p class="erc8004-p">Register multiple agents at once via CSV or JSON import.</p>
+
+ <div class="erc8004-file-drop erc8004-batch-drop" data-role="drop">
+ <input type="file" accept=".csv,.json" class="erc8004-file-input" />
+ <div class="erc8004-batch-drop-inner">
+ <div class="erc8004-batch-drop-icon">📁</div>
+ <div class="erc8004-batch-drop-title">Drop CSV or JSON file here</div>
+ <div class="erc8004-batch-drop-sub">or click to browse</div>
+ </div>
+ </div>
+
+ <div class="erc8004-batch-preview" data-role="preview" style="display:none">
+ <div class="erc8004-h4">Preview (<span data-role="count">0</span> agents)</div>
+ <div class="erc8004-batch-list" data-role="list"></div>
+ <div class="erc8004-row" style="margin-top:12px">
+ <button class="erc8004-btn erc8004-btn--primary" data-role="run">🚀 Register All</button>
+ <button class="erc8004-btn" data-role="clear">Clear</button>
+ </div>
+ <div class="erc8004-batch-progress" data-role="progress" style="display:none">
+ <div class="erc8004-progress-bar"><div class="erc8004-progress-fill" data-role="bar"></div></div>
+ <div class="erc8004-muted erc8004-small" data-role="status">Processing…</div>
+ </div>
+ </div>
+
+ <details class="erc8004-accordion" data-role="format-guide">
+ <summary class="erc8004-accordion-head">📝 Format Guide</summary>
+ <div class="erc8004-accordion-body">
+ <p class="erc8004-p"><strong>JSON format:</strong></p>
+<pre class="erc8004-pre">[
+ {
+ "name": "Agent 1",
+ "description": "Description here",
+ "services": [{"name": "A2A", "endpoint": "https://..."}]
+ }
+]</pre>
+ <p class="erc8004-p"><strong>CSV format:</strong></p>
+<pre class="erc8004-pre">name,description,serviceType,endpoint
+Agent 1,Does things,A2A,https://agent1.com
+Agent 2,Does more,MCP,https://agent2.com</pre>
+ </div>
+ </details>
+ `;
+
+ const drop = body.querySelector('[data-role="drop"]');
+ const input = drop.querySelector('.erc8004-file-input');
+ const preview = body.querySelector('[data-role="preview"]');
+ const countEl = body.querySelector('[data-role="count"]');
+ const listEl = body.querySelector('[data-role="list"]');
+ const progress = body.querySelector('[data-role="progress"]');
+ const bar = body.querySelector('[data-role="bar"]');
+ const status = body.querySelector('[data-role="status"]');
+
+ let queue = [];
+
+ const renderPreview = () => {
+ if (!queue.length) {
+ preview.style.display = 'none';
+ return;
+ }
+ preview.style.display = '';
+ countEl.textContent = String(queue.length);
+ listEl.innerHTML = queue
+ .map(
+ (a, i) => `
+ <div class="erc8004-batch-row" data-i="${i}">
+ <div class="erc8004-batch-row-num">${i + 1}</div>
+ <div class="erc8004-batch-row-body">
+ <div class="erc8004-batch-row-title">${esc(a.name || 'Agent ' + (i + 1))}</div>
+ <div class="erc8004-muted erc8004-small">${esc((a.description || '').slice(0, 80))}</div>
+ </div>
+ <div class="erc8004-batch-row-status erc8004-muted" data-role="row-status">pending</div>
+ </div>
+ `,
+ )
+ .join('');
+ };
+
+ const handleFile = (file) => {
+ if (!file) return;
+ const reader = new FileReader();
+ reader.onload = (ev) => {
+ const text = ev.target.result;
+ try {
+ if (/\.json$/i.test(file.name)) {
+ let parsed = JSON.parse(text);
+ if (!Array.isArray(parsed)) parsed = [parsed];
+ queue = parsed;
+ } else {
+ // CSV
+ const lines = String(text).trim().split(/\r?\n/);
+ const headers = lines[0].split(',').map((h) => h.trim());
+ queue = lines
+ .slice(1)
+ .map((line) => {
+ const values = line.split(',').map((v) => v.trim());
+ const obj = {};
+ headers.forEach((h, i) => (obj[h] = values[i] || ''));
+ return {
+ name: obj.name || obj.Name || '',
+ description: obj.description || obj.Description || '',
+ services: [
+ {
+ name: obj.serviceType || obj.type || 'web',
+ endpoint: obj.endpoint || obj.url || '',
+ },
+ ],
+ };
+ })
+ .filter((a) => a.name && a.services[0].endpoint);
+ }
+ renderPreview();
+ } catch (err) {
+ ctx.toast('Invalid file format: ' + err.message, true);
+ }
+ };
+ reader.readAsText(file);
+ };
+
+ input.addEventListener('change', (e) => handleFile(e.target.files[0]));
+ drop.addEventListener('dragover', (e) => {
+ e.preventDefault();
+ drop.classList.add('erc8004-file-drop--active');
+ });
+ drop.addEventListener('dragleave', () => drop.classList.remove('erc8004-file-drop--active'));
+ drop.addEventListener('drop', (e) => {
+ e.preventDefault();
+ drop.classList.remove('erc8004-file-drop--active');
+ handleFile(e.dataTransfer.files[0]);
+ });
+
+ body.querySelector('[data-role="clear"]').addEventListener('click', () => {
+ queue = [];
+ input.value = '';
+ renderPreview();
+ });
+
+ body.querySelector('[data-role="run"]').addEventListener('click', async () => {
+ const wallet = ctx.getWallet();
+ if (!wallet) {
+ ctx.toast('Connect a wallet first.', true);
+ return;
+ }
+ if (!queue.length) return;
+
+ const chainId = ctx.getChainId();
+ const chain = CHAIN_META[chainId];
+ if (!chain.testnet) {
+ const proceed = window.confirm(
+ `Batch register ${queue.length} agents on ${chain.name}? This uses real ${chain.currency.symbol}.`,
+ );
+ if (!proceed) return;
+ }
+
+ // Ensure we're on the target chain
+ if (wallet.chainId !== chainId) {
+ try {
+ await switchChain(chainId);
+ wallet.chainId = chainId;
+ } catch (err) {
+ ctx.toast('Chain switch rejected: ' + err.message, true);
+ return;
+ }
+ }
+
+ const { signer } = await connectWallet();
+ const registry = getIdentityRegistry(chainId, signer);
+ const identityAddr = REGISTRY_DEPLOYMENTS[chainId].identityRegistry;
+
+ progress.style.display = '';
+ let success = 0;
+ let failed = 0;
+ const rows = listEl.querySelectorAll('.erc8004-batch-row');
+
+ for (let i = 0; i < queue.length; i++) {
+ const a = queue[i];
+ const pct = ((i + 1) / queue.length) * 100;
+ bar.style.width = pct.toFixed(0) + '%';
+ status.textContent = `Processing ${i + 1}/${queue.length}: ${a.name || 'Agent'}`;
+ const rowStatus = rows[i]?.querySelector('[data-role="row-status"]');
+ if (rowStatus) rowStatus.textContent = 'signing…';
+
+ try {
+ const json = {
+ type: 'https://eips.ethereum.org/EIPS/eip-8004#registration-v1',
+ name: a.name,
+ description: a.description || '',
+ services: a.services || [],
+ active: true,
+ registrations: [
+ {
+ agentId: 'PENDING',
+ agentRegistry: `eip155:${chainId}:${identityAddr}`,
+ },
+ ],
+ };
+ const uri =
+ 'data:application/json;base64,' +
+ btoa(unescape(encodeURIComponent(JSON.stringify(json))));
+ const tx = await registry['register(string)'](uri);
+ if (rowStatus) rowStatus.textContent = 'confirming…';
+ await tx.wait();
+ success++;
+ if (rowStatus) {
+ rowStatus.innerHTML = `<a class="erc8004-link" href="${esc(
+ txExplorerUrl(chainId, tx.hash),
+ )}" target="_blank" rel="noopener">confirmed ↗</a>`;
+ }
+ } catch (err) {
+ failed++;
+ if (rowStatus) rowStatus.textContent = 'failed';
+ if (err && (err.code === 'ACTION_REJECTED' || err.code === 4001)) {
+ status.textContent = 'Batch cancelled by user.';
+ break;
+ }
+ }
+ }
+ status.textContent = `Done! ${success} registered, ${failed} failed.`;
+ ctx.toast(`Batch complete: ${success} registered.`, success === 0);
+ });
+}
diff --git a/src/erc8004/qr.js b/src/erc8004/qr.js
new file mode 100644
index 000000000..6a2c1724b
--- /dev/null
+++ b/src/erc8004/qr.js
@@ -0,0 +1,396 @@
+/**
+ * Minimal QR-code generator (zero-dep, ESM).
+ *
+ * Implements QR Model 2, byte mode, error-correction level L, versions 1–10.
+ * That's enough to encode URLs up to ~174 UTF-8 bytes at ECL=L — which covers
+ * every explorer URL we'd embed in an ERC-8004 agent QR.
+ *
+ * Derived from Project Nayuki's public-domain QR code generator
+ * (https://www.nayuki.io/page/qr-code-generator-library) reduced to the
+ * minimum path this app needs. Pure JS, no external deps.
+ */
+
+// ───────────────────────────────────────────────────────────────────────────
+// Generator
+// ───────────────────────────────────────────────────────────────────────────
+
+const ECL = 0; // L (1 = M, 2 = Q, 3 = H). We only need L.
+
+const EC_CODEWORDS_PER_BLOCK = [
+ // ECL_L
+ [7, 10, 15, 20, 26, 18, 20, 24, 30, 18],
+];
+const NUM_EC_BLOCKS = [[1, 1, 1, 1, 1, 2, 2, 2, 2, 4]];
+
+/** Returns the bitmask size (modules per side) for a given version (1..10). */
+function sizeForVersion(ver) {
+ return ver * 4 + 17;
+}
+
+/** Total number of data codewords for a given version + ECL. */
+function numDataCodewords(ver) {
+ const total = numRawDataModules(ver) >>> 3;
+ const ecBlocks = NUM_EC_BLOCKS[ECL][ver - 1];
+ const ecPerBlock = EC_CODEWORDS_PER_BLOCK[ECL][ver - 1];
+ return total - ecPerBlock * ecBlocks;
+}
+
+function numRawDataModules(ver) {
+ let result = (16 * ver + 128) * ver + 64;
+ if (ver >= 2) {
+ const numAlign = Math.floor(ver / 7) + 2;
+ result -= (25 * numAlign - 10) * numAlign - 55;
+ if (ver >= 7) result -= 36;
+ }
+ return result;
+}
+
+// Reed–Solomon in GF(256)
+function rsGenerator(degree) {
+ const result = new Uint8Array(degree);
+ result[degree - 1] = 1;
+ let root = 1;
+ for (let i = 0; i < degree; i++) {
+ for (let j = 0; j < degree; j++) {
+ result[j] = rsMul(result[j], root);
+ if (j + 1 < degree) result[j] ^= result[j + 1];
+ }
+ root = rsMul(root, 0x02);
+ }
+ return result;
+}
+function rsMul(x, y) {
+ let z = 0;
+ for (let i = 7; i >= 0; i--) {
+ z = (z << 1) ^ ((z >>> 7) * 0x11d);
+ z ^= ((y >>> i) & 1) * x;
+ }
+ return z & 0xff;
+}
+function rsRemainder(data, gen) {
+ const result = new Uint8Array(gen.length);
+ for (const b of data) {
+ const factor = b ^ result[0];
+ result.copyWithin(0, 1);
+ result[result.length - 1] = 0;
+ for (let i = 0; i < result.length; i++) result[i] ^= rsMul(gen[i], factor);
+ }
+ return result;
+}
+
+// Pick the smallest version (1..10) that fits `dataLen` bytes in byte mode at ECL=L.
+function pickVersion(dataLen) {
+ for (let v = 1; v <= 10; v++) {
+ const bitsAvailable = numDataCodewords(v) * 8;
+ // byte mode: 4 (mode) + (v<10 ? 8 : 16) char-count + 8*len
+ const charCountBits = v < 10 ? 8 : 16;
+ const needed = 4 + charCountBits + dataLen * 8;
+ if (needed <= bitsAvailable) return v;
+ }
+ throw new Error('QR payload too large (>10 versions)');
+}
+
+/**
+ * Generate a QR code matrix for the given string.
+ *
+ * @param {string} text
+ * @returns {{ size: number, modules: boolean[][] }}
+ */
+export function generateQR(text) {
+ const bytes = new TextEncoder().encode(text);
+ const ver = pickVersion(bytes.length);
+ const size = sizeForVersion(ver);
+ const charCountBits = ver < 10 ? 8 : 16;
+
+ // --- 1. Build bitstream ------------------------------------------------
+ const bits = [];
+ const pushBits = (val, n) => {
+ for (let i = n - 1; i >= 0; i--) bits.push((val >>> i) & 1);
+ };
+ pushBits(0b0100, 4); // byte mode
+ pushBits(bytes.length, charCountBits);
+ for (const b of bytes) pushBits(b, 8);
+
+ const dataCodewords = numDataCodewords(ver);
+ const capacityBits = dataCodewords * 8;
+ // terminator
+ for (let i = 0; i < 4 && bits.length < capacityBits; i++) bits.push(0);
+ // byte-align
+ while (bits.length % 8 !== 0) bits.push(0);
+ // pad
+ const pads = [0xec, 0x11];
+ let padIdx = 0;
+ while (bits.length < capacityBits) {
+ pushBits(pads[padIdx % 2], 8);
+ padIdx++;
+ }
+ const data = new Uint8Array(dataCodewords);
+ for (let i = 0; i < dataCodewords; i++) {
+ let v = 0;
+ for (let j = 0; j < 8; j++) v = (v << 1) | bits[i * 8 + j];
+ data[i] = v;
+ }
+
+ // --- 2. Reed–Solomon EC ------------------------------------------------
+ const numBlocks = NUM_EC_BLOCKS[ECL][ver - 1];
+ const ecLen = EC_CODEWORDS_PER_BLOCK[ECL][ver - 1];
+ const rawCodewords = numRawDataModules(ver) >>> 3;
+ const shortBlockLen = Math.floor(rawCodewords / numBlocks);
+ const numShort = numBlocks - (rawCodewords % numBlocks);
+
+ const blocks = [];
+ const gen = rsGenerator(ecLen);
+ let offset = 0;
+ for (let i = 0; i < numBlocks; i++) {
+ const dataLen = shortBlockLen - ecLen + (i < numShort ? 0 : 1);
+ const dat = data.slice(offset, offset + dataLen);
+ offset += dataLen;
+ const ec = rsRemainder(dat, gen);
+ blocks.push({ dat, ec });
+ }
+ // Interleave
+ const out = [];
+ for (let i = 0; i < shortBlockLen - ecLen + 1; i++) {
+ for (const b of blocks) {
+ if (i < b.dat.length) out.push(b.dat[i]);
+ }
+ }
+ for (let i = 0; i < ecLen; i++) {
+ for (const b of blocks) out.push(b.ec[i]);
+ }
+
+ // --- 3. Matrix ---------------------------------------------------------
+ const modules = Array.from({ length: size }, () => new Array(size).fill(false));
+ const isFn = Array.from({ length: size }, () => new Array(size).fill(false));
+
+ const setFn = (x, y, dark) => {
+ modules[y][x] = dark;
+ isFn[y][x] = true;
+ };
+
+ // Finder + separators
+ const drawFinder = (cx, cy) => {
+ for (let dy = -4; dy <= 4; dy++) {
+ for (let dx = -4; dx <= 4; dx++) {
+ const x = cx + dx;
+ const y = cy + dy;
+ if (x < 0 || x >= size || y < 0 || y >= size) continue;
+ const d = Math.max(Math.abs(dx), Math.abs(dy));
+ setFn(x, y, d !== 2 && d !== 4);
+ }
+ }
+ };
+ drawFinder(3, 3);
+ drawFinder(size - 4, 3);
+ drawFinder(3, size - 4);
+
+ // Timing
+ for (let i = 0; i < size; i++) {
+ if (!isFn[6][i]) setFn(i, 6, i % 2 === 0);
+ if (!isFn[i][6]) setFn(6, i, i % 2 === 0);
+ }
+
+ // Alignment patterns
+ const alignPositions = (ver) => {
+ if (ver === 1) return [];
+ const num = Math.floor(ver / 7) + 2;
+ const step = ver === 32 ? 26 : Math.ceil((ver * 4 + 4) / (num * 2 - 2)) * 2;
+ const result = [6];
+ for (let pos = size - 7; result.length < num; pos -= step) result.splice(1, 0, pos);
+ return result;
+ };
+ const aps = alignPositions(ver);
+ for (const x of aps) {
+ for (const y of aps) {
+ if ((x === 6 && y === 6) || (x === 6 && y === size - 7) || (x === size - 7 && y === 6))
+ continue;
+ for (let dy = -2; dy <= 2; dy++) {
+ for (let dx = -2; dx <= 2; dx++) {
+ const d = Math.max(Math.abs(dx), Math.abs(dy));
+ setFn(x + dx, y + dy, d !== 1);
+ }
+ }
+ }
+ }
+
+ // Reserve format info area
+ for (let i = 0; i < 9; i++) setFn(8, i, false);
+ for (let i = 0; i < 8; i++) setFn(i, 8, false);
+ for (let i = 0; i < 8; i++) setFn(size - 1 - i, 8, false);
+ for (let i = 0; i < 7; i++) setFn(8, size - 1 - i, false);
+ setFn(8, size - 8, true); // dark module
+
+ // Version info (ver >= 7)
+ if (ver >= 7) {
+ let rem = ver;
+ for (let i = 0; i < 12; i++) rem = (rem << 1) ^ ((rem >>> 11) * 0x1f25);
+ const bits = ((ver << 12) | rem) >>> 0;
+ for (let i = 0; i < 18; i++) {
+ const bit = ((bits >>> i) & 1) === 1;
+ const a = size - 11 + (i % 3);
+ const b = Math.floor(i / 3);
+ setFn(a, b, bit);
+ setFn(b, a, bit);
+ }
+ }
+
+ // --- 4. Place data by zig-zag -----------------------------------------
+ let bitIdx = 0;
+ const bitAt = (i) => ((out[i >>> 3] >>> (7 - (i & 7))) & 1) === 1;
+ for (let right = size - 1; right >= 1; right -= 2) {
+ if (right === 6) right = 5;
+ for (let vert = 0; vert < size; vert++) {
+ for (let j = 0; j < 2; j++) {
+ const x = right - j;
+ const upward = ((right + 1) & 2) === 0;
+ const y = upward ? size - 1 - vert : vert;
+ if (!isFn[y][x] && bitIdx < out.length * 8) {
+ modules[y][x] = bitAt(bitIdx);
+ bitIdx++;
+ }
+ }
+ }
+ }
+
+ // --- 5. Try all 8 masks; pick lowest penalty --------------------------
+ let bestMask = 0;
+ let bestPenalty = Infinity;
+ let bestModules = null;
+ for (let mask = 0; mask < 8; mask++) {
+ const m = modules.map((row) => row.slice());
+ applyMask(m, isFn, mask);
+ applyFormatInfo(m, mask);
+ const p = penalty(m);
+ if (p < bestPenalty) {
+ bestPenalty = p;
+ bestMask = mask;
+ bestModules = m;
+ }
+ }
+ return { size, modules: bestModules };
+}
+
+function maskFn(mask, x, y) {
+ switch (mask) {
+ case 0:
+ return (x + y) % 2 === 0;
+ case 1:
+ return y % 2 === 0;
+ case 2:
+ return x % 3 === 0;
+ case 3:
+ return (x + y) % 3 === 0;
+ case 4:
+ return (Math.floor(x / 3) + Math.floor(y / 2)) % 2 === 0;
+ case 5:
+ return ((x * y) % 2) + ((x * y) % 3) === 0;
+ case 6:
+ return (((x * y) % 2) + ((x * y) % 3)) % 2 === 0;
+ case 7:
+ return (((x + y) % 2) + ((x * y) % 3)) % 2 === 0;
+ }
+ return false;
+}
+
+function applyMask(modules, isFn, mask) {
+ const size = modules.length;
+ for (let y = 0; y < size; y++) {
+ for (let x = 0; x < size; x++) {
+ if (!isFn[y][x] && maskFn(mask, x, y)) modules[y][x] = !modules[y][x];
+ }
+ }
+}
+
+function applyFormatInfo(modules, mask) {
+ const size = modules.length;
+ const data = (ECL_BITS[ECL] << 3) | mask;
+ let rem = data;
+ for (let i = 0; i < 10; i++) rem = (rem << 1) ^ ((rem >>> 9) * 0x537);
+ const bits = (((data << 10) | rem) ^ 0x5412) >>> 0;
+ const setBit = (x, y, b) => {
+ modules[y][x] = b;
+ };
+ for (let i = 0; i <= 5; i++) setBit(8, i, ((bits >>> i) & 1) === 1);
+ setBit(8, 7, ((bits >>> 6) & 1) === 1);
+ setBit(8, 8, ((bits >>> 7) & 1) === 1);
+ setBit(7, 8, ((bits >>> 8) & 1) === 1);
+ for (let i = 9; i < 15; i++) setBit(14 - i, 8, ((bits >>> i) & 1) === 1);
+ for (let i = 0; i < 8; i++) setBit(size - 1 - i, 8, ((bits >>> i) & 1) === 1);
+ for (let i = 8; i < 15; i++) setBit(8, size - 15 + i, ((bits >>> i) & 1) === 1);
+ setBit(8, size - 8, true);
+}
+
+const ECL_BITS = [1, 0, 3, 2]; // index by ECL 0..3 → {L,M,Q,H}
+
+function penalty(modules) {
+ const size = modules.length;
+ let p = 0;
+ // N1: runs of 5+
+ for (let y = 0; y < size; y++) {
+ let run = 1;
+ for (let x = 1; x < size; x++) {
+ if (modules[y][x] === modules[y][x - 1]) {
+ run++;
+ if (run === 5) p += 3;
+ else if (run > 5) p++;
+ } else run = 1;
+ }
+ }
+ for (let x = 0; x < size; x++) {
+ let run = 1;
+ for (let y = 1; y < size; y++) {
+ if (modules[y][x] === modules[y - 1][x]) {
+ run++;
+ if (run === 5) p += 3;
+ else if (run > 5) p++;
+ } else run = 1;
+ }
+ }
+ // N2: 2×2 blocks
+ for (let y = 0; y < size - 1; y++) {
+ for (let x = 0; x < size - 1; x++) {
+ const c = modules[y][x];
+ if (modules[y][x + 1] === c && modules[y + 1][x] === c && modules[y + 1][x + 1] === c)
+ p += 3;
+ }
+ }
+ // N3: finder-like patterns — skipped for brevity; penalty approximation is fine for URLs.
+ // N4: light/dark imbalance
+ let dark = 0;
+ for (let y = 0; y < size; y++) for (let x = 0; x < size; x++) if (modules[y][x]) dark++;
+ const total = size * size;
+ const k = Math.floor(Math.abs(dark * 20 - total * 10) / total);
+ p += k * 10;
+ return p;
+}
+
+// ───────────────────────────────────────────────────────────────────────────
+// Renderers
+// ───────────────────────────────────────────────────────────────────────────
+
+/**
+ * Render a QR code into a canvas. Returns the canvas.
+ * @param {string} text
+ * @param {{ scale?: number, margin?: number }} [opts]
+ */
+export function renderQRToCanvas(text, opts = {}) {
+ const scale = opts.scale ?? 8;
+ const margin = opts.margin ?? 2;
+ const { size, modules } = generateQR(text);
+ const pixels = (size + margin * 2) * scale;
+ const canvas = document.createElement('canvas');
+ canvas.width = pixels;
+ canvas.height = pixels;
+ const ctx = canvas.getContext('2d');
+ ctx.fillStyle = '#fff';
+ ctx.fillRect(0, 0, pixels, pixels);
+ ctx.fillStyle = '#000';
+ for (let y = 0; y < size; y++) {
+ for (let x = 0; x < size; x++) {
+ if (modules[y][x]) {
+ ctx.fillRect((x + margin) * scale, (y + margin) * scale, scale, scale);
+ }
+ }
+ }
+ return canvas;
+}
diff --git a/src/erc8004/register-ui.js b/src/erc8004/register-ui.js
index 1212d46a2..f55c3c04d 100644
--- a/src/erc8004/register-ui.js
+++ b/src/erc8004/register-ui.js
@@ -15,9 +15,17 @@
* Uses plain DOM — consistent with the rest of the project.
*/
-import { registerAgent, connectWallet, pinFile, getIdentityRegistry, buildRegistrationJSON } from './agent-registry.js';
+import {
+ registerAgent,
+ connectWallet,
+ pinFile,
+ getIdentityRegistry,
+ buildRegistrationJSON,
+} from './agent-registry.js';
import { isPrivyConfigured } from './privy.js';
import { REGISTRY_DEPLOYMENTS } from './abi.js';
+import { renderBatchTab } from './batch-tab.js';
+import { renderQRToCanvas } from './qr.js';
import {
CHAIN_META,
DEFAULT_CHAIN_ID,
@@ -42,12 +50,47 @@ import {
// ───────────────────────────────────────────────────────────────────────────
const TEMPLATES = [
- { id: 'defi', emoji: '📈', name: 'DeFi Trading Agent', description: 'Automated DeFi yield optimization, liquidity management, and token swaps across protocols.' },
- { id: 'support', emoji: '🎧', name: 'Customer Support Bot', description: 'AI-powered support agent for handling tickets, FAQ queries, and multi-language communication.' },
- { id: 'code', emoji: '🔍', name: 'Code Review Agent', description: 'Automated code analysis, security auditing, gas optimization, and best practice enforcement.' },
- { id: 'data', emoji: '📊', name: 'Data Analysis Agent', description: 'On-chain and off-chain data analysis, reporting, visualization, and pattern recognition.' },
- { id: 'content', emoji: '✍️', name: 'Content Creator', description: 'AI content generation for social media, documentation, technical writing, and marketing.' },
- { id: 'research',emoji: '🔬', name: 'Research Assistant', description: 'Deep research on protocols, tokens, governance proposals, and market trends.' },
+ {
+ id: 'defi',
+ emoji: '📈',
+ name: 'DeFi Trading Agent',
+ description:
+ 'Automated DeFi yield optimization, liquidity management, and token swaps across protocols.',
+ },
+ {
+ id: 'support',
+ emoji: '🎧',
+ name: 'Customer Support Bot',
+ description:
+ 'AI-powered support agent for handling tickets, FAQ queries, and multi-language communication.',
+ },
+ {
+ id: 'code',
+ emoji: '🔍',
+ name: 'Code Review Agent',
+ description:
+ 'Automated code analysis, security auditing, gas optimization, and best practice enforcement.',
+ },
+ {
+ id: 'data',
+ emoji: '📊',
+ name: 'Data Analysis Agent',
+ description:
+ 'On-chain and off-chain data analysis, reporting, visualization, and pattern recognition.',
+ },
+ {
+ id: 'content',
+ emoji: '✍️',
+ name: 'Content Creator',
+ description:
+ 'AI content generation for social media, documentation, technical writing, and marketing.',
+ },
+ {
+ id: 'research',
+ emoji: '🔬',
+ name: 'Research Assistant',
+ description: 'Deep research on protocols, tokens, governance proposals, and market trends.',
+ },
];
const SERVICE_TYPES = ['A2A', 'MCP', 'OASF', 'x402', 'web', 'custom'];
@@ -56,10 +99,12 @@ const SERVICE_TYPES = ['A2A', 'MCP', 'OASF', 'x402', 'web', 'custom'];
// Helpers
// ───────────────────────────────────────────────────────────────────────────
-const esc = (s) => String(s ?? '').replace(/[&<>"']/g, (c) => (
- { '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;' }[c]
-));
-const shortAddr = (a) => a ? a.slice(0, 6) + '…' + a.slice(-4) : '';
+const esc = (s) =>
+ String(s ?? '').replace(
+ /[&<>"']/g,
+ (c) => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;' })[c],
+ );
+const shortAddr = (a) => (a ? a.slice(0, 6) + '…' + a.slice(-4) : '');
// ───────────────────────────────────────────────────────────────────────────
// RegisterUI
@@ -75,7 +120,7 @@ export class RegisterUI {
this.onRegistered = onRegistered || (() => {});
// Wallet state
- this.wallet = null; // { address, chainId }
+ this.wallet = null; // { address, chainId }
// Selected chain for reads + writes. Initialized to BSC Testnet; if the
// wallet is already on a different supported chain, we'll adopt that.
@@ -87,12 +132,12 @@ export class RegisterUI {
// Wizard state
this.wizardStep = 1;
this.form = {
- name: '',
+ name: '',
description: '',
- imageUrl: '',
- glbFile: null,
- services: [], // [{ name, type, endpoint }]
- apiToken: '', // optional Pinata JWT
+ imageUrl: '',
+ glbFile: null,
+ services: [], // [{ name, type, endpoint }]
+ apiToken: '', // optional Pinata JWT
};
// Cache of signed-in user's backend agent id (if any) — linked after deploy
@@ -100,7 +145,7 @@ export class RegisterUI {
this._build();
this._bind();
- this._fetchBackendAgent(); // fire & forget
+ this._fetchBackendAgent(); // fire & forget
}
// -----------------------------------------------------------------------
@@ -111,36 +156,77 @@ export class RegisterUI {
this.el = document.createElement('div');
this.el.className = 'erc8004-register';
this.el.innerHTML = `
- <div class="erc8004-card erc8004-card--wide">
- <div class="erc8004-header">
- <div class="erc8004-brand">
- <span class="erc8004-brand-badge">8004</span>
- <span class="erc8004-brand-title"><b>ERC-8004</b> Agent Studio</span>
+ <div class="erc8004-shell">
+ <header class="erc8004-hero">
+ <div class="erc8004-hero-topbar">
+ <div class="erc8004-brand">
+ <span class="erc8004-brand-badge">8004</span>
+ <span class="erc8004-brand-title"><b>ERC-8004</b> Agent Studio</span>
+ </div>
+ <div class="erc8004-controls">
+ <select class="erc8004-chain-select" title="Target chain"></select>
+ <button class="erc8004-btn erc8004-btn--wallet" type="button">
+ ${isPrivyConfigured() ? 'Connect Wallet' : 'Connect MetaMask'}
+ </button>
+ <button class="erc8004-btn erc8004-btn--close" type="button" title="Close">✕</button>
+ </div>
</div>
- <div class="erc8004-controls">
- <select class="erc8004-chain-select" title="Target chain"></select>
- <button class="erc8004-btn erc8004-btn--wallet" type="button">
- ${isPrivyConfigured() ? 'Connect Wallet' : 'Connect MetaMask'}
- </button>
- <button class="erc8004-btn erc8004-btn--close" type="button" title="Close">✕</button>
+ <div class="erc8004-hero-body">
+ <div class="erc8004-hero-badge"><span class="erc8004-hero-dot"></span>Live on 20+ EVM Chains</div>
+ <h1 class="erc8004-hero-h1">Create <span class="erc8004-hero-accent">Trustless Agents</span><br>on Any Chain</h1>
+ <p class="erc8004-hero-sub">Register AI agents on-chain with ERC-8004. Get a portable, censorship-resistant identity backed by an ERC-721 NFT — discoverable across the entire agent economy.</p>
+ <div class="erc8004-stats">
+ <div class="erc8004-stat"><div class="erc8004-stat-val" data-stat="total">—</div><div class="erc8004-stat-lbl">Agents Registered</div></div>
+ <div class="erc8004-stat"><div class="erc8004-stat-val" data-stat="chains">${supportedChainIds().length}</div><div class="erc8004-stat-lbl">Chains Supported</div></div>
+ <div class="erc8004-stat"><div class="erc8004-stat-val" data-stat="version">—</div><div class="erc8004-stat-lbl">Registry Version</div></div>
+ </div>
</div>
- </div>
+ </header>
- <div class="erc8004-stats">
- <div class="erc8004-stat"><div class="erc8004-stat-val" data-stat="total">—</div><div class="erc8004-stat-lbl">Agents Registered</div></div>
- <div class="erc8004-stat"><div class="erc8004-stat-val" data-stat="chains">${supportedChainIds().length}</div><div class="erc8004-stat-lbl">Chains Supported</div></div>
- <div class="erc8004-stat"><div class="erc8004-stat-val" data-stat="version">—</div><div class="erc8004-stat-lbl">Registry Version</div></div>
- </div>
+ <div class="erc8004-mainnet-banner" data-role="mainnet-banner" style="display:none"></div>
+
+ <div class="erc8004-card erc8004-card--wide">
+ <nav class="erc8004-tabs" role="tablist">
+ <button class="erc8004-tab erc8004-tab--active" data-tab="create">Create Agent</button>
+ <button class="erc8004-tab" data-tab="my">My Agents</button>
+ <button class="erc8004-tab" data-tab="search">Search</button>
+ <button class="erc8004-tab" data-tab="templates">Templates</button>
+ <button class="erc8004-tab" data-tab="batch">Batch</button>
+ <button class="erc8004-tab" data-tab="history">History</button>
+ </nav>
- <nav class="erc8004-tabs" role="tablist">
- <button class="erc8004-tab erc8004-tab--active" data-tab="create">Create Agent</button>
- <button class="erc8004-tab" data-tab="my">My Agents</button>
- <button class="erc8004-tab" data-tab="search">Search</button>
- <button class="erc8004-tab" data-tab="templates">Templates</button>
- <button class="erc8004-tab" data-tab="history">History</button>
- </nav>
+ <div class="erc8004-tab-body" data-role="tab-body"></div>
+ </div>
- <div class="erc8004-tab-body" data-role="tab-body"></div>
+ <footer class="erc8004-footer">
+ <div class="erc8004-footer-links">
+ <a href="https://eips.ethereum.org/EIPS/eip-8004" target="_blank" rel="noopener">ERC-8004 Spec</a>
+ <a href="https://github.com/erc-8004/erc-8004-contracts" target="_blank" rel="noopener">Contracts</a>
+ <a href="https://bnbchaintoolkit.com" target="_blank" rel="noopener">BNB Chain AI Toolkit</a>
+ <a href="https://github.com/nirholas/3D" target="_blank" rel="noopener">GitHub</a>
+ </div>
+ <div class="erc8004-footer-cols">
+ <div class="erc8004-footer-col">
+ <div class="erc8004-footer-title">Learn</div>
+ <a href="https://eips.ethereum.org/EIPS/eip-8004" target="_blank" rel="noopener">What is ERC-8004?</a>
+ <a href="/features" target="_blank" rel="noopener">Getting Started</a>
+ <a href="https://github.com/nirholas/3D" target="_blank" rel="noopener">FAQ</a>
+ </div>
+ <div class="erc8004-footer-col">
+ <div class="erc8004-footer-title">Build</div>
+ <a href="/features">Tutorials</a>
+ <a href="https://github.com/nirholas/3D" target="_blank" rel="noopener">Examples</a>
+ <a href="/features">Integration Guide</a>
+ </div>
+ <div class="erc8004-footer-col">
+ <div class="erc8004-footer-title">Ecosystem</div>
+ <a href="https://github.com/nirholas/3D" target="_blank" rel="noopener">Architecture</a>
+ <a href="https://github.com/nirholas/3D" target="_blank" rel="noopener">MCP Server</a>
+ <a href="https://github.com/nirholas/3D" target="_blank" rel="noopener">SDKs</a>
+ </div>
+ </div>
+ <p class="erc8004-footer-credit">Built on <a href="https://eips.ethereum.org/EIPS/eip-8004" target="_blank" rel="noopener">ERC-8004</a></p>
+ </footer>
</div>
`;
this.container.appendChild(this.el);
@@ -148,11 +234,31 @@ export class RegisterUI {
this._populateChainSelect();
this._renderActiveTab();
this._refreshStats();
+ this._refreshMainnetBanner();
+ }
+
+ _refreshMainnetBanner() {
+ const banner = this.el.querySelector('[data-role="mainnet-banner"]');
+ if (!banner) return;
+ const meta = CHAIN_META[this.selectedChainId];
+ if (meta && !meta.testnet) {
+ banner.style.display = '';
+ banner.innerHTML = `⚠️ <strong>Mainnet Mode</strong> — Transactions use real ${esc(
+ meta.currency.symbol,
+ )}. Test on a testnet first.`;
+ } else {
+ banner.style.display = 'none';
+ banner.innerHTML = '';
+ }
}
_bind() {
- this.el.querySelector('.erc8004-btn--wallet').addEventListener('click', () => this._connectWallet());
- this.el.querySelector('.erc8004-btn--close').addEventListener('click', () => this.destroy());
+ this.el
+ .querySelector('.erc8004-btn--wallet')
+ .addEventListener('click', () => this._connectWallet());
+ this.el
+ .querySelector('.erc8004-btn--close')
+ .addEventListener('click', () => this.destroy());
this.el.querySelector('.erc8004-chain-select').addEventListener('change', async (e) => {
const newChain = Number(e.target.value);
@@ -169,6 +275,7 @@ export class RegisterUI {
}
this._renderActiveTab();
this._refreshStats();
+ this._refreshMainnetBanner();
});
this.el.querySelectorAll('.erc8004-tab').forEach((btn) => {
@@ -199,6 +306,7 @@ export class RegisterUI {
this._refreshWalletButton();
this._renderActiveTab();
this._refreshStats();
+ this._refreshMainnetBanner();
} catch (err) {
this._toast('Wallet: ' + err.message, true);
}
@@ -221,16 +329,20 @@ export class RegisterUI {
// Testnets first (default-friendly), then mainnets
const testnets = ids.filter((id) => CHAIN_META[id].testnet);
const mainnets = ids.filter((id) => !CHAIN_META[id].testnet);
- const groupT = document.createElement('optgroup'); groupT.label = 'Testnets';
- const groupM = document.createElement('optgroup'); groupM.label = 'Mainnets';
+ const groupT = document.createElement('optgroup');
+ groupT.label = 'Testnets';
+ const groupM = document.createElement('optgroup');
+ groupM.label = 'Mainnets';
for (const id of testnets) {
const opt = document.createElement('option');
- opt.value = String(id); opt.textContent = CHAIN_META[id].name;
+ opt.value = String(id);
+ opt.textContent = CHAIN_META[id].name;
groupT.appendChild(opt);
}
for (const id of mainnets) {
const opt = document.createElement('option');
- opt.value = String(id); opt.textContent = CHAIN_META[id].name;
+ opt.value = String(id);
+ opt.textContent = CHAIN_META[id].name;
groupM.appendChild(opt);
}
sel.appendChild(groupT);
@@ -247,7 +359,9 @@ export class RegisterUI {
]);
if (total !== null) el('total').textContent = String(total);
if (version) el('version').textContent = version;
- } catch { /* swallow; stats are cosmetic */ }
+ } catch {
+ /* swallow; stats are cosmetic */
+ }
}
// -----------------------------------------------------------------------
@@ -260,21 +374,23 @@ export class RegisterUI {
if (!res.ok) return;
const { agent } = await res.json();
if (agent && agent.id) this._backendAgentId = agent.id;
- } catch { /* anon user or endpoint unavailable — fine */ }
+ } catch {
+ /* anon user or endpoint unavailable — fine */
+ }
}
async _linkAgentToAccount({ agentId, chainId, txHash }) {
if (!this._backendAgentId || !this.wallet) return;
try {
await fetch(`/api/agents/${encodeURIComponent(this._backendAgentId)}/wallet`, {
- method: 'POST',
+ method: 'POST',
credentials: 'include',
- headers: { 'content-type': 'application/json' },
- body: JSON.stringify({
- wallet_address: this.wallet.address,
- chain_id: chainId,
- erc8004_agent_id: agentId,
- tx_hash: txHash,
+ headers: { 'content-type': 'application/json' },
+ body: JSON.stringify({
+ wallet_address: this.wallet.address,
+ chain_id: chainId,
+ erc8004_agent_id: agentId,
+ tx_hash: txHash,
}),
});
} catch (err) {
@@ -298,14 +414,35 @@ export class RegisterUI {
const body = this.el.querySelector('[data-role="tab-body"]');
body.innerHTML = '';
switch (this.activeTab) {
- case 'create': this._renderCreate(body); break;
- case 'my': this._renderMyAgents(body); break;
- case 'search': this._renderSearch(body); break;
- case 'templates': this._renderTemplates(body); break;
- case 'history': this._renderHistory(body); break;
+ case 'create':
+ this._renderCreate(body);
+ break;
+ case 'my':
+ this._renderMyAgents(body);
+ break;
+ case 'search':
+ this._renderSearch(body);
+ break;
+ case 'templates':
+ this._renderTemplates(body);
+ break;
+ case 'batch':
+ this._renderBatch(body);
+ break;
+ case 'history':
+ this._renderHistory(body);
+ break;
}
}
+ _renderBatch(body) {
+ renderBatchTab(body, {
+ getWallet: () => this.wallet,
+ getChainId: () => this.selectedChainId,
+ toast: (msg, err) => this._toast(msg, err),
+ });
+ }
+
// -----------------------------------------------------------------------
// Tab: Create Agent (4-step wizard)
// -----------------------------------------------------------------------
@@ -315,21 +452,25 @@ export class RegisterUI {
body.innerHTML = `
<div class="erc8004-wizard">
<ol class="erc8004-steps">
- ${[1,2,3,4].map((n) => `
+ ${[1, 2, 3, 4]
+ .map(
+ (n) => `
<li class="erc8004-step ${n === step ? 'erc8004-step--active' : ''} ${n < step ? 'erc8004-step--done' : ''}">
<span class="erc8004-step-num">${n}</span>
- <span class="erc8004-step-lbl">${['Identity','Services','Configuration','Deploy'][n-1]}</span>
+ <span class="erc8004-step-lbl">${['Identity', 'Services', 'Configuration', 'Deploy'][n - 1]}</span>
</li>
- `).join('')}
+ `,
+ )
+ .join('')}
</ol>
<div class="erc8004-wizard-body" data-role="wizard-body"></div>
</div>
`;
const wbody = body.querySelector('[data-role="wizard-body"]');
- if (step === 1) this._renderStepIdentity(wbody);
+ if (step === 1) this._renderStepIdentity(wbody);
else if (step === 2) this._renderStepServices(wbody);
else if (step === 3) this._renderStepConfig(wbody);
- else this._renderStepDeploy(wbody);
+ else this._renderStepDeploy(wbody);
}
_renderStepIdentity(body) {
@@ -357,9 +498,18 @@ export class RegisterUI {
<button class="erc8004-btn erc8004-btn--primary" data-role="next">Next: Services →</button>
</div>
`;
- body.querySelector('[name="name"]').addEventListener('input', (e) => this.form.name = e.target.value);
- body.querySelector('[name="description"]').addEventListener('input', (e) => this.form.description = e.target.value);
- body.querySelector('[name="imageUrl"]').addEventListener('input', (e) => this.form.imageUrl = e.target.value);
+ body.querySelector('[name="name"]').addEventListener(
+ 'input',
+ (e) => (this.form.name = e.target.value),
+ );
+ body.querySelector('[name="description"]').addEventListener(
+ 'input',
+ (e) => (this.form.description = e.target.value),
+ );
+ body.querySelector('[name="imageUrl"]').addEventListener(
+ 'input',
+ (e) => (this.form.imageUrl = e.target.value),
+ );
body.querySelector('[data-role="next"]').addEventListener('click', () => {
if (!this.form.name.trim() || !this.form.description.trim()) {
this._toast('Name and description are required.', true);
@@ -386,7 +536,9 @@ export class RegisterUI {
`;
const list = body.querySelector('[data-role="list"]');
const renderList = () => {
- list.innerHTML = this.form.services.map((svc, i) => `
+ list.innerHTML = this.form.services
+ .map(
+ (svc, i) => `
<div class="erc8004-svc-row" data-i="${i}">
<select class="erc8004-input erc8004-input--tight" data-field="type">
${SERVICE_TYPES.map((t) => `<option value="${t}" ${svc.type === t ? 'selected' : ''}>${t}</option>`).join('')}
@@ -395,7 +547,9 @@ export class RegisterUI {
<input class="erc8004-input" data-field="endpoint" placeholder="https://… or ipfs://…" value="${esc(svc.endpoint)}" />
<button class="erc8004-btn erc8004-btn--ghost erc8004-btn--x" data-role="rm" title="Remove">✕</button>
</div>
- `).join('');
+ `,
+ )
+ .join('');
list.querySelectorAll('.erc8004-svc-row').forEach((row) => {
const i = Number(row.dataset.i);
@@ -416,8 +570,14 @@ export class RegisterUI {
this.form.services.push({ type: 'A2A', name: '', endpoint: '' });
renderList();
});
- body.querySelector('[data-role="back"]').addEventListener('click', () => { this.wizardStep = 1; this._renderActiveTab(); });
- body.querySelector('[data-role="next"]').addEventListener('click', () => { this.wizardStep = 3; this._renderActiveTab(); });
+ body.querySelector('[data-role="back"]').addEventListener('click', () => {
+ this.wizardStep = 1;
+ this._renderActiveTab();
+ });
+ body.querySelector('[data-role="next"]').addEventListener('click', () => {
+ this.wizardStep = 3;
+ this._renderActiveTab();
+ });
}
_renderStepConfig(body) {
@@ -448,19 +608,40 @@ export class RegisterUI {
const setFile = (f) => {
if (!f) return;
- if (!/\.(glb|gltf)$/i.test(f.name)) { this._toast('Must be a .glb or .gltf file', true); return; }
+ if (!/\.(glb|gltf)$/i.test(f.name)) {
+ this._toast('Must be a .glb or .gltf file', true);
+ return;
+ }
this.form.glbFile = f;
label.textContent = f.name;
};
input.addEventListener('change', (e) => setFile(e.target.files[0]));
- drop.addEventListener('dragover', (e) => { e.preventDefault(); drop.classList.add('erc8004-file-drop--active'); });
- drop.addEventListener('dragleave', () => drop.classList.remove('erc8004-file-drop--active'));
- drop.addEventListener('drop', (e) => { e.preventDefault(); drop.classList.remove('erc8004-file-drop--active'); setFile(e.dataTransfer.files[0]); });
+ drop.addEventListener('dragover', (e) => {
+ e.preventDefault();
+ drop.classList.add('erc8004-file-drop--active');
+ });
+ drop.addEventListener('dragleave', () =>
+ drop.classList.remove('erc8004-file-drop--active'),
+ );
+ drop.addEventListener('drop', (e) => {
+ e.preventDefault();
+ drop.classList.remove('erc8004-file-drop--active');
+ setFile(e.dataTransfer.files[0]);
+ });
- body.querySelector('[name="apiToken"]').addEventListener('input', (e) => this.form.apiToken = e.target.value);
- body.querySelector('[data-role="back"]').addEventListener('click', () => { this.wizardStep = 2; this._renderActiveTab(); });
- body.querySelector('[data-role="next"]').addEventListener('click', () => { this.wizardStep = 4; this._renderActiveTab(); });
+ body.querySelector('[name="apiToken"]').addEventListener(
+ 'input',
+ (e) => (this.form.apiToken = e.target.value),
+ );
+ body.querySelector('[data-role="back"]').addEventListener('click', () => {
+ this.wizardStep = 2;
+ this._renderActiveTab();
+ });
+ body.querySelector('[data-role="next"]').addEventListener('click', () => {
+ this.wizardStep = 4;
+ this._renderActiveTab();
+ });
}
_renderStepDeploy(body) {
@@ -475,8 +656,8 @@ export class RegisterUI {
<dt>Name</dt> <dd>${esc(this.form.name)}</dd>
<dt>Description</dt> <dd>${esc(this.form.description)}</dd>
${this.form.imageUrl ? `<dt>Image</dt> <dd>${esc(this.form.imageUrl)}</dd>` : ''}
- ${this.form.glbFile ? `<dt>GLB File</dt> <dd>${esc(this.form.glbFile.name)} (${(this.form.glbFile.size/1024).toFixed(1)} KB)</dd>` : ''}
- <dt>Services</dt> <dd>${this.form.services.length ? this.form.services.map(s => `${esc(s.type)}: ${esc(s.endpoint || '—')}`).join('<br>') : '<span class="erc8004-muted">none</span>'}</dd>
+ ${this.form.glbFile ? `<dt>GLB File</dt> <dd>${esc(this.form.glbFile.name)} (${(this.form.glbFile.size / 1024).toFixed(1)} KB)</dd>` : ''}
+ <dt>Services</dt> <dd>${this.form.services.length ? this.form.services.map((s) => `${esc(s.type)}: ${esc(s.endpoint || '—')}`).join('<br>') : '<span class="erc8004-muted">none</span>'}</dd>
<dt>Chain</dt> <dd>${esc(meta.name)} (chainId ${this.selectedChainId})</dd>
<dt>Registry</dt> <dd><code>${esc(REGISTRY_DEPLOYMENTS[this.selectedChainId].identityRegistry)}</code></dd>
</dl>
@@ -484,6 +665,34 @@ export class RegisterUI {
${!walletOk ? `<div class="erc8004-alert">Connect a wallet before deploying.</div>` : ''}
${walletOk && !chainOk ? `<div class="erc8004-alert">Your wallet is on chain ${this.wallet.chainId}. <button class="erc8004-link" data-role="switch">Switch to ${esc(meta.name)}</button></div>` : ''}
+ <details class="erc8004-accordion">
+ <summary class="erc8004-accordion-head">📦 Export Options</summary>
+ <div class="erc8004-accordion-body">
+ <div class="erc8004-export-grid">
+ <button type="button" class="erc8004-export-opt" data-role="exp-json">
+ <div class="erc8004-export-emoji">📄</div>
+ <div class="erc8004-export-title">Export JSON</div>
+ <div class="erc8004-export-sub">Raw registration config</div>
+ </button>
+ <button type="button" class="erc8004-export-opt" data-role="exp-cast">
+ <div class="erc8004-export-emoji">⌨️</div>
+ <div class="erc8004-export-title">cast / forge</div>
+ <div class="erc8004-export-sub">Copy shell command</div>
+ </button>
+ <button type="button" class="erc8004-export-opt" data-role="exp-viem">
+ <div class="erc8004-export-emoji">🧩</div>
+ <div class="erc8004-export-title">viem snippet</div>
+ <div class="erc8004-export-sub">Copy TS snippet</div>
+ </button>
+ <button type="button" class="erc8004-export-opt" data-role="exp-curl">
+ <div class="erc8004-export-emoji">🌐</div>
+ <div class="erc8004-export-title">curl</div>
+ <div class="erc8004-export-sub">Graph query stub</div>
+ </button>
+ </div>
+ </div>
+ </details>
+
<div class="erc8004-log" data-role="log"></div>
<div class="erc8004-result" data-role="result" style="display:none">
@@ -504,7 +713,10 @@ export class RegisterUI {
<button class="erc8004-btn erc8004-btn--primary" data-role="deploy" ${walletOk ? '' : 'disabled'}>🚀 Register Agent On-Chain</button>
</div>
`;
- body.querySelector('[data-role="back"]').addEventListener('click', () => { this.wizardStep = 3; this._renderActiveTab(); });
+ body.querySelector('[data-role="back"]').addEventListener('click', () => {
+ this.wizardStep = 3;
+ this._renderActiveTab();
+ });
const switchBtn = body.querySelector('[data-role="switch"]');
if (switchBtn) {
@@ -519,7 +731,79 @@ export class RegisterUI {
});
}
- body.querySelector('[data-role="deploy"]').addEventListener('click', () => this._doDeploy(body));
+ body.querySelector('[data-role="deploy"]').addEventListener('click', () =>
+ this._doDeploy(body),
+ );
+
+ this._wireExportOptions(body);
+ }
+
+ _wireExportOptions(body) {
+ const buildJSON = () => {
+ const identityAddr = REGISTRY_DEPLOYMENTS[this.selectedChainId].identityRegistry;
+ return {
+ type: 'https://eips.ethereum.org/EIPS/eip-8004#registration-v1',
+ name: this.form.name,
+ description: this.form.description,
+ image: this.form.imageUrl || '',
+ services: (this.form.services || []).filter((s) => s.endpoint?.trim()),
+ active: true,
+ registrations: [
+ {
+ agentId: 'PENDING',
+ agentRegistry: `eip155:${this.selectedChainId}:${identityAddr}`,
+ },
+ ],
+ };
+ };
+ const download = (text, filename, mime = 'application/json') => {
+ const blob = new Blob([text], { type: mime });
+ const url = URL.createObjectURL(blob);
+ const a = document.createElement('a');
+ a.href = url;
+ a.download = filename;
+ a.click();
+ setTimeout(() => URL.revokeObjectURL(url), 2000);
+ };
+ const copy = async (text) => {
+ try {
+ await navigator.clipboard.writeText(text);
+ this._toast('Copied to clipboard');
+ } catch {
+ this._toast('Copy failed', true);
+ }
+ };
+
+ const jsonBtn = body.querySelector('[data-role="exp-json"]');
+ const castBtn = body.querySelector('[data-role="exp-cast"]');
+ const viemBtn = body.querySelector('[data-role="exp-viem"]');
+ const curlBtn = body.querySelector('[data-role="exp-curl"]');
+ if (!jsonBtn) return;
+
+ jsonBtn.addEventListener('click', () => {
+ download(JSON.stringify(buildJSON(), null, 2), 'agent-registration.json');
+ this._toast('JSON downloaded');
+ });
+ castBtn.addEventListener('click', () => {
+ const identityAddr = REGISTRY_DEPLOYMENTS[this.selectedChainId].identityRegistry;
+ const b64 = btoa(unescape(encodeURIComponent(JSON.stringify(buildJSON()))));
+ const uri = `data:application/json;base64,${b64}`;
+ const cmd = `cast send ${identityAddr} "register(string)" '${uri}' \\\n --rpc-url ${CHAIN_META[this.selectedChainId].rpcUrl} \\\n --private-key $PRIVATE_KEY`;
+ copy(cmd);
+ });
+ viemBtn.addEventListener('click', () => {
+ const identityAddr = REGISTRY_DEPLOYMENTS[this.selectedChainId].identityRegistry;
+ const b64 = btoa(unescape(encodeURIComponent(JSON.stringify(buildJSON()))));
+ const uri = `data:application/json;base64,${b64}`;
+ const snippet = `import { createWalletClient, http, parseAbi } from 'viem';\nimport { privateKeyToAccount } from 'viem/accounts';\n\nconst account = privateKeyToAccount(process.env.PRIVATE_KEY);\nconst client = createWalletClient({ account, transport: http('${CHAIN_META[this.selectedChainId].rpcUrl}') });\n\nawait client.writeContract({\n address: '${identityAddr}',\n abi: parseAbi(['function register(string) external returns (uint256)']),\n functionName: 'register',\n args: ['${uri}'],\n});`;
+ copy(snippet);
+ });
+ curlBtn.addEventListener('click', () => {
+ const identityAddr = REGISTRY_DEPLOYMENTS[this.selectedChainId].identityRegistry;
+ const query = `query { agents(where: { registry: "${identityAddr.toLowerCase()}" }, first: 5) { id agentId agentURI owner } }`;
+ const cmd = `curl -X POST https://api.thegraph.com/subgraphs/name/erc-8004/registry \\\n -H 'content-type: application/json' \\\n -d '${JSON.stringify({ query })}'`;
+ copy(cmd);
+ });
}
async _doDeploy(body) {
@@ -555,10 +839,17 @@ export class RegisterUI {
window.location.hash = `agent=${result.agentId}`;
window.location.reload();
});
- body.querySelector('[data-role="view-explorer"]').href = txExplorerUrl(this.selectedChainId, result.txHash);
+ body.querySelector('[data-role="view-explorer"]').href = txExplorerUrl(
+ this.selectedChainId,
+ result.txHash,
+ );
this.onRegistered({ ...result, chainId: this.selectedChainId });
- await this._linkAgentToAccount({ agentId: result.agentId, chainId: this.selectedChainId, txHash: result.txHash });
+ await this._linkAgentToAccount({
+ agentId: result.agentId,
+ chainId: this.selectedChainId,
+ txHash: result.txHash,
+ });
this._refreshStats();
} catch (err) {
say('Registration failed: ' + (err.shortMessage || err.message || String(err)), true);
@@ -583,12 +874,14 @@ export class RegisterUI {
description,
apiToken: apiToken || undefined,
onStatus: say,
- services: services.filter((s) => s.endpoint.trim()).map((s) => ({
- name: s.name || s.type,
- type: s.type,
- endpoint: s.endpoint,
- version: '1.0',
- })),
+ services: services
+ .filter((s) => s.endpoint.trim())
+ .map((s) => ({
+ name: s.name || s.type,
+ type: s.type,
+ endpoint: s.endpoint,
+ version: '1.0',
+ })),
});
}
@@ -606,7 +899,13 @@ export class RegisterUI {
const receipt = await tx.wait();
const registeredEvent = receipt.logs
- .map((l) => { try { return registry.interface.parseLog(l); } catch { return null; } })
+ .map((l) => {
+ try {
+ return registry.interface.parseLog(l);
+ } catch {
+ return null;
+ }
+ })
.find((e) => e && e.name === 'Registered');
if (!registeredEvent) throw new Error('Registered event not found in receipt');
const agentId = Number(registeredEvent.args.agentId);
@@ -619,16 +918,20 @@ export class RegisterUI {
agentId,
chainId,
registryAddr: REGISTRY_DEPLOYMENTS[chainId].identityRegistry,
- services: services.filter((s) => s.endpoint.trim()).map((s) => ({
- name: s.name || s.type,
- type: s.type,
- endpoint: s.endpoint,
- version: '1.0',
- })),
+ services: services
+ .filter((s) => s.endpoint.trim())
+ .map((s) => ({
+ name: s.name || s.type,
+ type: s.type,
+ endpoint: s.endpoint,
+ version: '1.0',
+ })),
});
say('Uploading registration metadata…');
- const jsonBlob = new Blob([JSON.stringify(registrationJSON, null, 2)], { type: 'application/json' });
+ const jsonBlob = new Blob([JSON.stringify(registrationJSON, null, 2)], {
+ type: 'application/json',
+ });
const registrationUrl = await pinFile(jsonBlob, apiToken || undefined);
say(`Registration metadata: ${registrationUrl}`);
@@ -646,9 +949,11 @@ export class RegisterUI {
_renderMyAgents(body) {
body.innerHTML = `
<h3 class="erc8004-h3">Your Registered Agents</h3>
- ${this.wallet
- ? `<p class="erc8004-p">Connected as <code>${esc(this.wallet.address)}</code> on <b>${esc(CHAIN_META[this.selectedChainId]?.name || '?')}</b>.</p>`
- : `<p class="erc8004-p erc8004-muted">Connect a wallet to see agents you own.</p>`}
+ ${
+ this.wallet
+ ? `<p class="erc8004-p">Connected as <code>${esc(this.wallet.address)}</code> on <b>${esc(CHAIN_META[this.selectedChainId]?.name || '?')}</b>.</p>`
+ : `<p class="erc8004-p erc8004-muted">Connect a wallet to see agents you own.</p>`
+ }
<div data-role="list"></div>
`;
if (!this.wallet) return;
@@ -657,47 +962,55 @@ export class RegisterUI {
list.innerHTML = `<div class="erc8004-muted">Scanning…</div>`;
listAgentsByOwner({
- chainId: this.selectedChainId,
- owner: this.wallet.address,
+ chainId: this.selectedChainId,
+ owner: this.wallet.address,
ethProvider: window.ethereum,
- }).then(async (res) => {
- if (res.count === 0) {
- list.innerHTML = `<div class="erc8004-muted">No agents registered on this chain yet. <a class="erc8004-link" data-role="goto-create">Create one →</a></div>`;
- list.querySelector('[data-role="goto-create"]').addEventListener('click', (e) => { e.preventDefault(); this._setTab('create'); });
- return;
- }
- if (res.ids.length === 0 && res.partial) {
- const explorer = addressExplorerUrl(this.selectedChainId, this.wallet.address);
- list.innerHTML = `
+ })
+ .then(async (res) => {
+ if (res.count === 0) {
+ list.innerHTML = `<div class="erc8004-muted">No agents registered on this chain yet. <a class="erc8004-link" data-role="goto-create">Create one →</a></div>`;
+ list.querySelector('[data-role="goto-create"]').addEventListener(
+ 'click',
+ (e) => {
+ e.preventDefault();
+ this._setTab('create');
+ },
+ );
+ return;
+ }
+ if (res.ids.length === 0 && res.partial) {
+ const explorer = addressExplorerUrl(this.selectedChainId, this.wallet.address);
+ list.innerHTML = `
<div class="erc8004-muted">
You own ${res.count} agent(s) but details could not be loaded from recent blocks.
<a href="${esc(explorer)}" target="_blank" rel="noopener" class="erc8004-link">Check explorer ↗</a>
</div>`;
- return;
- }
- list.innerHTML = '';
- for (const id of res.ids) {
- const card = document.createElement('div');
- card.className = 'erc8004-agent-card';
- card.innerHTML = `<div class="erc8004-muted">Loading #${id}…</div>`;
- list.appendChild(card);
- this._fillAgentCard(card, id);
- }
- if (res.partial) {
- const note = document.createElement('div');
- note.className = 'erc8004-muted';
- note.textContent = `Showing ${res.ids.length} of ${res.count} agents — older mints may be outside the scanned block window.`;
- list.appendChild(note);
- }
- }).catch((err) => {
- list.innerHTML = `<div class="erc8004-log-error">Query failed: ${esc(err.message)}</div>`;
- });
+ return;
+ }
+ list.innerHTML = '';
+ for (const id of res.ids) {
+ const card = document.createElement('div');
+ card.className = 'erc8004-agent-card';
+ card.innerHTML = `<div class="erc8004-muted">Loading #${id}…</div>`;
+ list.appendChild(card);
+ this._fillAgentCard(card, id, { withQR: true });
+ }
+ if (res.partial) {
+ const note = document.createElement('div');
+ note.className = 'erc8004-muted';
+ note.textContent = `Showing ${res.ids.length} of ${res.count} agents — older mints may be outside the scanned block window.`;
+ list.appendChild(note);
+ }
+ })
+ .catch((err) => {
+ list.innerHTML = `<div class="erc8004-log-error">Query failed: ${esc(err.message)}</div>`;
+ });
}
- async _fillAgentCard(card, agentId) {
+ async _fillAgentCard(card, agentId, opts = {}) {
try {
const { uri, owner } = await getAgentOnchain({
- chainId: this.selectedChainId,
+ chainId: this.selectedChainId,
agentId,
ethProvider: window.ethereum,
});
@@ -705,9 +1018,11 @@ export class RegisterUI {
const registryAddr = REGISTRY_DEPLOYMENTS[this.selectedChainId].identityRegistry;
const tokenUrl = tokenExplorerUrl(this.selectedChainId, registryAddr, agentId);
- const name = meta.ok ? (meta.data.name || `Agent #${agentId}`) : `Agent #${agentId}`;
+ const name = meta.ok ? meta.data.name || `Agent #${agentId}` : `Agent #${agentId}`;
const description = meta.ok ? meta.data.description : '';
const image = meta.ok ? meta.data.image : '';
+ const hasX402 = meta.ok && (meta.data.x402Support || meta.data.x402);
+ card._meta = meta.ok ? meta.data : null;
card.innerHTML = `
<div class="erc8004-agent-card-inner">
@@ -718,25 +1033,88 @@ export class RegisterUI {
<div class="erc8004-agent-card-head">
<strong>${esc(name)}</strong>
<span class="erc8004-tag">#${agentId}</span>
+ ${hasX402 ? `<span class="erc8004-tag erc8004-tag--x402">x402 💳</span>` : ''}
</div>
${description ? `<p class="erc8004-p erc8004-clip">${esc(description)}</p>` : ''}
<div class="erc8004-agent-card-actions">
- ${tokenUrl ? `<a class="erc8004-link" href="${esc(tokenUrl)}" target="_blank" rel="noopener">Explorer ↗</a>` : ''}
+ ${tokenUrl ? `<a class="erc8004-link" href="${esc(tokenUrl)}" target="_blank" rel="noopener">Details ↗</a>` : ''}
<a class="erc8004-link" href="#agent=${agentId}">Open in viewer</a>
+ ${opts.withQR && tokenUrl ? `<button type="button" class="erc8004-link" data-role="qr">QR</button>` : ''}
</div>
</div>
</div>
`;
+
+ if (opts.withQR && tokenUrl) {
+ const qrBtn = card.querySelector('[data-role="qr"]');
+ if (qrBtn)
+ qrBtn.addEventListener('click', () =>
+ this._openQRModal({ agentId, url: tokenUrl }),
+ );
+ }
} catch (err) {
card.innerHTML = `<div class="erc8004-log-error">Agent #${agentId}: ${esc(err.message)}</div>`;
}
}
+ _openQRModal({ agentId, url }) {
+ const chainName = CHAIN_META[this.selectedChainId]?.name || '?';
+ const modal = document.createElement('div');
+ modal.className = 'erc8004-modal';
+ modal.innerHTML = `
+ <div class="erc8004-modal-card">
+ <div class="erc8004-modal-head">
+ <div class="erc8004-h4" style="margin:0">Agent QR Code</div>
+ <button class="erc8004-btn erc8004-btn--x" data-role="close" title="Close">✕</button>
+ </div>
+ <p class="erc8004-muted erc8004-small">Agent #${String(agentId)} on ${esc(chainName)}</p>
+ <div class="erc8004-qr-canvas-wrap" data-role="canvas"></div>
+ <p class="erc8004-muted erc8004-small erc8004-qr-url">${esc(url)}</p>
+ <div class="erc8004-row" style="justify-content:center">
+ <button class="erc8004-btn erc8004-btn--primary" data-role="download">Download PNG</button>
+ <button class="erc8004-btn" data-role="copy">Copy Link</button>
+ </div>
+ </div>
+ `;
+ this.el.appendChild(modal);
+
+ let canvas;
+ try {
+ canvas = renderQRToCanvas(url, { scale: 6, margin: 2 });
+ modal.querySelector('[data-role="canvas"]').appendChild(canvas);
+ } catch (err) {
+ modal.querySelector('[data-role="canvas"]').innerHTML =
+ `<div class="erc8004-log-error">QR error: ${esc(err.message)}</div>`;
+ }
+
+ const close = () => modal.remove();
+ modal.addEventListener('click', (e) => {
+ if (e.target === modal) close();
+ });
+ modal.querySelector('[data-role="close"]').addEventListener('click', close);
+ modal.querySelector('[data-role="download"]').addEventListener('click', () => {
+ if (!canvas) return;
+ const a = document.createElement('a');
+ a.href = canvas.toDataURL('image/png');
+ a.download = `agent-${String(agentId)}-qr.png`;
+ a.click();
+ });
+ modal.querySelector('[data-role="copy"]').addEventListener('click', async () => {
+ try {
+ await navigator.clipboard.writeText(url);
+ this._toast('Link copied!');
+ } catch {
+ this._toast('Copy failed', true);
+ }
+ });
+ }
+
// -----------------------------------------------------------------------
// Tab: Search
// -----------------------------------------------------------------------
_renderSearch(body) {
+ if (!this._searchFilter) this._searchFilter = 'all';
body.innerHTML = `
<h3 class="erc8004-h3">Agent Search</h3>
<p class="erc8004-p">Find a registered agent by its on-chain ID on <b>${esc(CHAIN_META[this.selectedChainId]?.name)}</b>.</p>
@@ -744,26 +1122,75 @@ export class RegisterUI {
<input class="erc8004-input" name="q" placeholder="Agent ID (e.g., 6443)" />
<button class="erc8004-btn erc8004-btn--primary" data-role="go">Search</button>
</div>
+ <div class="erc8004-filter-chips" data-role="chips">
+ <button class="erc8004-chip ${this._searchFilter === 'all' ? 'erc8004-chip--active' : ''}" data-filter="all">All</button>
+ <button class="erc8004-chip ${this._searchFilter === 'A2A' ? 'erc8004-chip--active' : ''}" data-filter="A2A">A2A</button>
+ <button class="erc8004-chip ${this._searchFilter === 'MCP' ? 'erc8004-chip--active' : ''}" data-filter="MCP">MCP</button>
+ <button class="erc8004-chip ${this._searchFilter === 'OASF' ? 'erc8004-chip--active' : ''}" data-filter="OASF">OASF</button>
+ <button class="erc8004-chip ${this._searchFilter === 'x402' ? 'erc8004-chip--active' : ''}" data-filter="x402">x402 💳</button>
+ </div>
<div data-role="result" style="margin-top:14px"></div>
`;
const q = body.querySelector('[name="q"]');
const out = body.querySelector('[data-role="result"]');
+
+ body.querySelectorAll('[data-role="chips"] .erc8004-chip').forEach((chip) => {
+ chip.addEventListener('click', () => {
+ this._searchFilter = chip.dataset.filter;
+ body.querySelectorAll('[data-role="chips"] .erc8004-chip').forEach((c) => {
+ c.classList.toggle(
+ 'erc8004-chip--active',
+ c.dataset.filter === this._searchFilter,
+ );
+ });
+ this._applySearchFilter(out);
+ });
+ });
+
const go = async () => {
const id = q.value.trim();
- if (!/^\d+$/.test(id)) { out.innerHTML = `<div class="erc8004-log-error">Enter a numeric Agent ID.</div>`; return; }
+ if (!/^\d+$/.test(id)) {
+ out.innerHTML = `<div class="erc8004-log-error">Enter a numeric Agent ID.</div>`;
+ return;
+ }
out.innerHTML = `<div class="erc8004-muted">Loading #${id}…</div>`;
try {
const card = document.createElement('div');
card.className = 'erc8004-agent-card';
out.innerHTML = '';
out.appendChild(card);
- await this._fillAgentCard(card, BigInt(id));
+ await this._fillAgentCard(card, BigInt(id), { withQR: true });
+ this._applySearchFilter(out);
} catch (err) {
out.innerHTML = `<div class="erc8004-log-error">${esc(err.message)}</div>`;
}
};
body.querySelector('[data-role="go"]').addEventListener('click', go);
- q.addEventListener('keydown', (e) => { if (e.key === 'Enter') go(); });
+ q.addEventListener('keydown', (e) => {
+ if (e.key === 'Enter') go();
+ });
+ }
+
+ _applySearchFilter(out) {
+ const filter = this._searchFilter || 'all';
+ out.querySelectorAll('.erc8004-agent-card').forEach((card) => {
+ if (filter === 'all') {
+ card.style.display = '';
+ return;
+ }
+ const meta = card._meta;
+ if (!meta) {
+ card.style.display = '';
+ return;
+ }
+ const services = Array.isArray(meta.services) ? meta.services : [];
+ const types = services.map((s) => String(s.type || s.name || '').toUpperCase());
+ const hasX402 = !!meta.x402Support || !!meta.x402;
+ let match = false;
+ if (filter === 'x402') match = hasX402;
+ else match = types.includes(filter.toUpperCase());
+ card.style.display = match ? '' : 'none';
+ });
}
// -----------------------------------------------------------------------
@@ -775,13 +1202,15 @@ export class RegisterUI {
<h3 class="erc8004-h3">Agent Templates</h3>
<p class="erc8004-p">Pre-built configurations — one click to prefill the Create Agent wizard.</p>
<div class="erc8004-template-grid">
- ${TEMPLATES.map((t) => `
+ ${TEMPLATES.map(
+ (t) => `
<button class="erc8004-template" data-id="${t.id}">
<div class="erc8004-template-emoji">${t.emoji}</div>
<div class="erc8004-template-name">${esc(t.name)}</div>
<div class="erc8004-template-desc">${esc(t.description)}</div>
</button>
- `).join('')}
+ `,
+ ).join('')}
</div>
`;
body.querySelectorAll('.erc8004-template').forEach((btn) => {
@@ -810,16 +1239,19 @@ export class RegisterUI {
list.innerHTML = `<div class="erc8004-muted">Loading…</div>`;
listRegisteredEvents({
- chainId: this.selectedChainId,
- owner: this.wallet?.address,
+ chainId: this.selectedChainId,
+ owner: this.wallet?.address,
ethProvider: window.ethereum,
- limit: 50,
- }).then((events) => {
- if (events.length === 0) {
- list.innerHTML = `<div class="erc8004-muted">No events in the scanned window.</div>`;
- return;
- }
- list.innerHTML = events.map((ev) => `
+ limit: 50,
+ })
+ .then((events) => {
+ if (events.length === 0) {
+ list.innerHTML = `<div class="erc8004-muted">No events in the scanned window.</div>`;
+ return;
+ }
+ list.innerHTML = events
+ .map(
+ (ev) => `
<div class="erc8004-history-row">
<div class="erc8004-history-main">
<div><strong>Agent #${ev.agentId}</strong> <span class="erc8004-muted">by ${esc(shortAddr(ev.owner))}</span></div>
@@ -827,10 +1259,13 @@ export class RegisterUI {
</div>
<a class="erc8004-link" href="${esc(txExplorerUrl(this.selectedChainId, ev.txHash))}" target="_blank" rel="noopener">tx ↗</a>
</div>
- `).join('');
- }).catch((err) => {
- list.innerHTML = `<div class="erc8004-log-error">Failed to load: ${esc(err.message)}</div>`;
- });
+ `,
+ )
+ .join('');
+ })
+ .catch((err) => {
+ list.innerHTML = `<div class="erc8004-log-error">Failed to load: ${esc(err.message)}</div>`;
+ });
}
// -----------------------------------------------------------------------
@@ -853,6 +1288,6 @@ export class RegisterUI {
function resolveGateway(uri) {
if (!uri) return '';
if (uri.startsWith('ipfs://')) return 'https://ipfs.io/ipfs/' + uri.slice(7);
- if (uri.startsWith('ar://')) return 'https://arweave.net/' + uri.slice(5);
+ if (uri.startsWith('ar://')) return 'https://arweave.net/' + uri.slice(5);
return uri;
}
diff --git a/src/runtime/animation-slots.js b/src/runtime/animation-slots.js
index 2e9d8cccb..32c677f41 100644
--- a/src/runtime/animation-slots.js
+++ b/src/runtime/animation-slots.js
@@ -6,15 +6,15 @@ export const SLOTS = ['idle', 'wave', 'nod', 'shake', 'think', 'celebrate', 'con
export const DEFAULT_ANIMATION_MAP = {
idle: 'idle',
- wave: 'wave',
- nod: 'yes',
- shake: 'no',
- think: 'sitting',
- celebrate: 'dance',
- concern: 'standing',
- bow: 'wave',
- point: 'standing',
- shrug: 'standing',
+ wave: 'reaction',
+ nod: 'reaction',
+ shake: 'angry',
+ think: 'pray',
+ celebrate: 'celebrate',
+ concern: 'defeated',
+ bow: 'sitclap',
+ point: 'reaction',
+ shrug: 'defeated',
};
/**
diff --git a/style.css b/style.css
index 884552c5a..26dd0a61b 100644
--- a/style.css
+++ b/style.css
@@ -1896,6 +1896,52 @@ footer .separator {
}
}
+.save-to-account-btn {
+ display: inline-flex;
+ align-items: center;
+ gap: var(--space-xs);
+ padding: var(--space-sm) var(--space-lg);
+ background: rgba(139, 92, 246, 0.12);
+ border: 1px solid rgba(139, 92, 246, 0.35);
+ border-radius: var(--radius-lg);
+ color: rgba(255, 255, 255, 0.9);
+ font-family: inherit;
+ font-size: var(--text-sm);
+ font-weight: 500;
+ text-decoration: none;
+ cursor: pointer;
+ transition: all 0.25s ease;
+ letter-spacing: 0.02em;
+}
+.save-to-account-btn:hover {
+ background: rgba(139, 92, 246, 0.24);
+ color: #fff;
+ border-color: rgba(139, 92, 246, 0.6);
+}
+.save-to-account-btn:focus-visible {
+ outline: 2px solid rgba(139, 92, 246, 0.7);
+ outline-offset: 2px;
+}
+.save-to-account-btn[hidden] {
+ display: none;
+}
+.save-to-account-btn[disabled] {
+ opacity: 0.6;
+ pointer-events: none;
+}
+.save-to-account-btn svg {
+ width: 1em;
+ height: 1em;
+}
+@media screen and (max-width: 700px) {
+ .save-to-account-btn span {
+ display: none;
+ }
+ .save-to-account-btn {
+ padding: var(--space-xs) var(--space-sm);
+ }
+}
+
/******************************************************************************
* Avatar Creator Modal
*/
@@ -3226,15 +3272,13 @@ footer .separator {
body[data-viewer-mode='main'][data-authed='pending'] .anim-panel,
body[data-viewer-mode='main'][data-authed='pending'] #agent-presence-sidebar,
-body[data-viewer-mode='main'][data-authed='pending'] .dg.main,
-body[data-viewer-mode='main'][data-authed='pending'] #make-widget-btn {
+body[data-viewer-mode='main'][data-authed='pending'] .dg.main {
visibility: hidden !important;
}
body[data-viewer-mode='main'][data-authed='false'] .anim-panel,
body[data-viewer-mode='main'][data-authed='false'] #agent-presence-sidebar,
-body[data-viewer-mode='main'][data-authed='false'] .dg.main,
-body[data-viewer-mode='main'][data-authed='false'] #make-widget-btn {
+body[data-viewer-mode='main'][data-authed='false'] .dg.main {
display: none !important;
}
@@ -3690,3 +3734,437 @@ body[data-viewer-mode='main'][data-authed='false'] .auth-gate {
justify-content: flex-end;
}
}
+
+/******************************************************************************
+ * ERC-8004 Agent Studio — parity additions (hero, mainnet banner,
+ * filter chips, batch tab, QR modal, export accordion, footer).
+ */
+
+.erc8004-shell {
+ width: 100%;
+ max-width: 960px;
+ margin: 0 auto;
+}
+
+.erc8004-hero {
+ margin-bottom: var(--space-md);
+}
+
+.erc8004-hero-topbar {
+ display: flex;
+ align-items: center;
+ justify-content: space-between;
+ gap: var(--space-md);
+ margin-bottom: var(--space-lg);
+ flex-wrap: wrap;
+}
+
+.erc8004-hero-body {
+ text-align: center;
+ padding: var(--space-lg) 0;
+}
+
+.erc8004-hero-badge {
+ display: inline-flex;
+ align-items: center;
+ gap: 8px;
+ padding: 6px 14px;
+ border-radius: 20px;
+ background: rgba(99, 102, 241, 0.15);
+ border: 1px solid rgba(99, 102, 241, 0.3);
+ color: #a5b4fc;
+ font-size: 12px;
+ font-weight: 500;
+ margin-bottom: var(--space-md);
+}
+
+.erc8004-hero-dot {
+ width: 8px;
+ height: 8px;
+ border-radius: 50%;
+ background: #22c55e;
+ box-shadow: 0 0 8px #22c55e;
+}
+
+.erc8004-hero-h1 {
+ margin: 0 0 var(--space-sm);
+ font-size: clamp(28px, 5vw, 44px);
+ line-height: 1.1;
+ font-weight: 600;
+ color: #fff;
+ letter-spacing: -0.02em;
+}
+
+.erc8004-hero-accent {
+ background: linear-gradient(90deg, #6366f1, #a78bfa);
+ -webkit-background-clip: text;
+ background-clip: text;
+ color: transparent;
+}
+
+.erc8004-hero-sub {
+ max-width: 620px;
+ margin: 0 auto var(--space-md);
+ color: rgba(255, 255, 255, 0.55);
+ font-size: var(--text-base);
+ line-height: 1.6;
+}
+
+.erc8004-hero .erc8004-stats {
+ max-width: 540px;
+ margin: 0 auto;
+}
+
+.erc8004-mainnet-banner {
+ padding: var(--space-sm) var(--space-md);
+ margin-bottom: var(--space-md);
+ background: rgba(239, 68, 68, 0.1);
+ border: 1px solid rgba(239, 68, 68, 0.4);
+ border-radius: var(--radius-md);
+ color: #fca5a5;
+ font-size: var(--text-sm);
+ text-align: center;
+}
+
+/* Filter chips */
+.erc8004-filter-chips {
+ display: flex;
+ gap: 8px;
+ flex-wrap: wrap;
+ margin: var(--space-sm) 0;
+}
+
+.erc8004-chip {
+ padding: 6px 14px;
+ border-radius: 20px;
+ font-size: 12px;
+ font-weight: 500;
+ background: rgba(255, 255, 255, 0.04);
+ border: 1px solid rgba(255, 255, 255, 0.1);
+ color: rgba(255, 255, 255, 0.6);
+ cursor: pointer;
+ font-family: inherit;
+ transition: all 0.2s;
+}
+
+.erc8004-chip:hover {
+ border-color: rgba(99, 102, 241, 0.5);
+}
+
+.erc8004-chip--active {
+ background: rgba(99, 102, 241, 0.15);
+ border-color: rgba(99, 102, 241, 0.5);
+ color: #a5b4fc;
+}
+
+.erc8004-tag--x402 {
+ background: rgba(124, 58, 237, 0.2);
+ color: #c4b5fd;
+ border-color: rgba(124, 58, 237, 0.4);
+}
+
+/* Batch tab */
+.erc8004-batch-drop {
+ height: 140px;
+ margin: var(--space-md) 0;
+}
+
+.erc8004-batch-drop-inner {
+ pointer-events: none;
+ text-align: center;
+}
+
+.erc8004-batch-drop-icon {
+ font-size: 32px;
+ margin-bottom: 8px;
+}
+
+.erc8004-batch-drop-title {
+ font-weight: 600;
+ color: rgba(255, 255, 255, 0.8);
+ margin-bottom: 4px;
+}
+
+.erc8004-batch-drop-sub {
+ font-size: 13px;
+ color: rgba(255, 255, 255, 0.45);
+}
+
+.erc8004-batch-preview {
+ margin-top: var(--space-md);
+}
+
+.erc8004-batch-list {
+ max-height: 380px;
+ overflow-y: auto;
+ display: flex;
+ flex-direction: column;
+ gap: 6px;
+}
+
+.erc8004-batch-row {
+ display: grid;
+ grid-template-columns: auto 1fr auto;
+ gap: 12px;
+ align-items: center;
+ padding: 8px 12px;
+ background: rgba(255, 255, 255, 0.03);
+ border: 1px solid rgba(255, 255, 255, 0.06);
+ border-radius: var(--radius-sm);
+}
+
+.erc8004-batch-row-num {
+ width: 24px;
+ height: 24px;
+ border-radius: 50%;
+ background: rgba(99, 102, 241, 0.2);
+ color: #a5b4fc;
+ font-size: 12px;
+ font-weight: 600;
+ display: flex;
+ align-items: center;
+ justify-content: center;
+}
+
+.erc8004-batch-row-title {
+ font-weight: 500;
+ color: #fff;
+}
+
+.erc8004-batch-row-status {
+ font-size: 12px;
+}
+
+.erc8004-batch-progress {
+ margin-top: var(--space-md);
+}
+
+.erc8004-progress-bar {
+ height: 6px;
+ background: rgba(255, 255, 255, 0.08);
+ border-radius: 3px;
+ overflow: hidden;
+ margin-bottom: 6px;
+}
+
+.erc8004-progress-fill {
+ height: 100%;
+ background: linear-gradient(90deg, #6366f1, #a78bfa);
+ transition: width 0.3s;
+ width: 0;
+}
+
+.erc8004-pre {
+ font-family: monospace;
+ font-size: 12px;
+ background: rgba(0, 0, 0, 0.3);
+ border: 1px solid rgba(255, 255, 255, 0.06);
+ border-radius: var(--radius-sm);
+ padding: 10px 12px;
+ color: rgba(255, 255, 255, 0.7);
+ white-space: pre-wrap;
+ overflow-x: auto;
+}
+
+/* Accordion */
+.erc8004-accordion {
+ margin-top: var(--space-md);
+ background: rgba(255, 255, 255, 0.03);
+ border: 1px solid rgba(255, 255, 255, 0.08);
+ border-radius: var(--radius-md);
+ overflow: hidden;
+}
+
+.erc8004-accordion-head {
+ cursor: pointer;
+ list-style: none;
+ padding: 12px 14px;
+ font-weight: 500;
+ color: rgba(255, 255, 255, 0.8);
+ display: flex;
+ justify-content: space-between;
+ align-items: center;
+}
+
+.erc8004-accordion-head::after {
+ content: '▼';
+ color: rgba(255, 255, 255, 0.4);
+ font-size: 10px;
+ transition: transform 0.2s;
+}
+
+.erc8004-accordion[open] .erc8004-accordion-head::after {
+ transform: rotate(180deg);
+}
+
+.erc8004-accordion-head::-webkit-details-marker {
+ display: none;
+}
+
+.erc8004-accordion-body {
+ padding: 0 14px 14px;
+ border-top: 1px solid rgba(255, 255, 255, 0.05);
+}
+
+/* Export options grid */
+.erc8004-export-grid {
+ display: grid;
+ grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
+ gap: 8px;
+ margin-top: 12px;
+}
+
+.erc8004-export-opt {
+ padding: 14px;
+ background: rgba(255, 255, 255, 0.04);
+ border: 1px solid rgba(255, 255, 255, 0.08);
+ border-radius: var(--radius-sm);
+ color: #fff;
+ font-family: inherit;
+ cursor: pointer;
+ text-align: center;
+ transition: all 0.2s;
+}
+
+.erc8004-export-opt:hover {
+ background: rgba(99, 102, 241, 0.1);
+ border-color: rgba(99, 102, 241, 0.3);
+}
+
+.erc8004-export-emoji {
+ font-size: 22px;
+ margin-bottom: 6px;
+}
+
+.erc8004-export-title {
+ font-size: 13px;
+ font-weight: 600;
+ margin-bottom: 2px;
+}
+
+.erc8004-export-sub {
+ font-size: 11px;
+ color: rgba(255, 255, 255, 0.45);
+}
+
+/* QR modal */
+.erc8004-modal {
+ position: fixed;
+ inset: 0;
+ z-index: 600;
+ background: rgba(0, 0, 0, 0.7);
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ padding: var(--space-md);
+}
+
+.erc8004-modal-card {
+ background: #0d0d12;
+ border: 1px solid rgba(255, 255, 255, 0.12);
+ border-radius: var(--radius-lg);
+ padding: var(--space-lg);
+ max-width: 420px;
+ width: 100%;
+ text-align: center;
+}
+
+.erc8004-modal-head {
+ display: flex;
+ justify-content: space-between;
+ align-items: center;
+ margin-bottom: var(--space-sm);
+}
+
+.erc8004-qr-canvas-wrap {
+ display: flex;
+ justify-content: center;
+ background: #fff;
+ border-radius: var(--radius-sm);
+ padding: 12px;
+ margin: var(--space-sm) 0;
+}
+
+.erc8004-qr-canvas-wrap canvas {
+ max-width: 100%;
+ height: auto;
+ image-rendering: pixelated;
+}
+
+.erc8004-qr-url {
+ word-break: break-all;
+ margin: 0 0 var(--space-sm);
+}
+
+/* Footer */
+.erc8004-footer {
+ margin-top: var(--space-lg);
+ padding: var(--space-lg) 0;
+ text-align: center;
+ color: rgba(255, 255, 255, 0.45);
+ font-size: var(--text-sm);
+}
+
+.erc8004-footer-links {
+ display: flex;
+ flex-wrap: wrap;
+ justify-content: center;
+ gap: var(--space-md);
+ margin-bottom: var(--space-md);
+}
+
+.erc8004-footer-links a {
+ color: rgba(255, 255, 255, 0.6);
+ text-decoration: none;
+}
+
+.erc8004-footer-links a:hover {
+ color: #fff;
+}
+
+.erc8004-footer-cols {
+ display: grid;
+ grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
+ gap: var(--space-lg);
+ max-width: 800px;
+ margin: 0 auto var(--space-md);
+ padding: var(--space-md) 0;
+ border-top: 1px solid rgba(255, 255, 255, 0.08);
+ border-bottom: 1px solid rgba(255, 255, 255, 0.08);
+ text-align: left;
+}
+
+.erc8004-footer-col {
+ display: flex;
+ flex-direction: column;
+ gap: 4px;
+}
+
+.erc8004-footer-title {
+ font-weight: 600;
+ color: rgba(255, 255, 255, 0.8);
+ font-size: 11px;
+ text-transform: uppercase;
+ letter-spacing: 1px;
+ margin-bottom: 4px;
+}
+
+.erc8004-footer-col a {
+ color: rgba(255, 255, 255, 0.55);
+ text-decoration: none;
+ font-size: 13px;
+}
+
+.erc8004-footer-col a:hover {
+ color: #fff;
+}
+
+.erc8004-footer-credit {
+ margin: 0;
+ font-size: 12px;
+ color: rgba(255, 255, 255, 0.35);
+}
+
+.erc8004-footer-credit a {
+ color: rgba(255, 255, 255, 0.55);
+}
diff --git a/vercel.json b/vercel.json
index 1d6533f6a..e23a5cdb6 100644
--- a/vercel.json
+++ b/vercel.json
@@ -66,6 +66,7 @@
},
{ "src": "/robots.txt", "dest": "/public/robots.txt" },
{ "src": "/sitemap.xml", "dest": "/public/sitemap.xml" },
+ { "src": "/app", "dest": "/app.html" },
{ "src": "/features", "dest": "/features.html" },
{ "src": "/create", "dest": "/create.html" },
{ "src": "/create/", "dest": "/create.html" },
diff --git a/vite.config.js b/vite.config.js
index ea3e834bf..a7ab83c4a 100644
--- a/vite.config.js
+++ b/vite.config.js
@@ -25,6 +25,7 @@ const appConfig = {
rollupOptions: {
input: {
main: resolve(__dirname, 'index.html'),
+ app: resolve(__dirname, 'app.html'),
features: resolve(__dirname, 'features.html'),
embed: resolve(__dirname, 'embed.html'),
create: resolve(__dirname, 'create.html'),
@@ -40,6 +41,7 @@ const appConfig = {
configureServer(server) {
const root = resolve(__dirname);
const fileMap = {
+ '/app': resolve(root, 'app.html'),
'/login': resolve(root, 'public/login.html'),
'/register': resolve(root, 'public/register.html'),
'/features': resolve(root, 'features.html'),
diff --git a/yarn.lock b/yarn.lock
index d39978db5..d8171cf72 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -1523,6 +1523,11 @@
resolved "https://registry.npmjs.org/@noble/hashes/-/hashes-1.3.2.tgz"
integrity sha512-MVC8EAQp7MvEcm30KWENFjgR+Mkmf+D189XJTkFIlwohU5hcBbn1ZkKq7KVTi2Hme3PMGF390DaL52beVrIihQ==
+"@picode/binary-reader@^0.0.4":
+ version "0.0.4"
+ resolved "https://registry.npmjs.org/@picode/binary-reader/-/binary-reader-0.0.4.tgz"
+ integrity sha512-ae1+S0EH+K6uuE8aCQs+lpjDMBy54Gimz0j/LyTUx3H090nzyiyRKUsPx3SmZvgUqzJIZnw+sfIB8Us/iPbvPA==
+
"@privy-io/[email protected]":
version "1.8.3"
resolved "https://registry.npmjs.org/@privy-io/api-base/-/api-base-1.8.3.tgz"
@@ -2737,6 +2742,14 @@ [email protected]:
path-expression-matcher "^1.2.0"
strnum "^2.2.0"
+fbx-parser@^2.1.3:
+ version "2.1.3"
+ resolved "https://registry.npmjs.org/fbx-parser/-/fbx-parser-2.1.3.tgz"
+ integrity sha512-2Yp/A4WHD0dc2A1lheX5243HiOObQY+Do8dd12v2ppFnG6T2Ic24I2PaeDau0vp/hKuqqA1LHjAG54sQWVY62w==
+ dependencies:
+ "@picode/binary-reader" "^0.0.4"
+ pako "^2.0.3"
+
fdir@^6.5.0:
version "6.5.0"
resolved "https://registry.npmjs.org/fdir/-/fdir-6.5.0.tgz"
@@ -3350,6 +3363,11 @@ package-json-from-dist@^1.0.0:
resolved "https://registry.npmjs.org/package-json-from-dist/-/package-json-from-dist-1.0.1.tgz"
integrity sha512-UEZIS3/by4OC8vL3P2dTXRETpebLI2NiI5vIrjaD/5UtrkFX/tNbwjTSRAGC/+7CAo2pIcBaRgWmcBBHcsaCIw==
+pako@^2.0.3:
+ version "2.1.0"
+ resolved "https://registry.npmjs.org/pako/-/pako-2.1.0.tgz"
+ integrity sha512-w+eufiZ1WuJYgPXbV/PO3NCMEc3xqylkKHzp8bxp1uW4qaSNQUkwmLLEc3kKsfz8lpV1F8Ht3U1Cm+9Srog2ug==
+
path-expression-matcher@^1.1.3, path-expression-matcher@^1.2.0:
version "1.5.0"
resolved "https://registry.npmjs.org/path-expression-matcher/-/path-expression-matcher-1.5.0.tgz"