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.

chore: sync workspace changes — play agent wallet, marketplace updates, mm-x402 bridge, snapshot refresh

nirholas1e4e405261ac
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 122f485f2..9774de287 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -6,6 +6,7 @@ Public history for [three.ws](https://three.ws), newest first. New pages come fr
## 2026-06-11
+- **Agent Wallet (MetaMask × x402)** (`/play/agent-wallet`) — Watch your 3D avatar walk up to a paid endpoint and pay for it with the MetaMask agent wallet — a real USDC micropayment signed by the MetaMask Agentic CLI and settled on Base.
- **Status** (`/status`) — Live operational status and 90-day uptime history for the platform, API, and x402 surfaces — probed every 5 minutes.
- **A safety net on open, sign-in-free chat — without blocking real conversations** — Anyone can chat with our agents without signing in, and that openness now has a quiet safety net. Messages from anonymous visitors pass through a fast content check before they reach the model, so genuinely harmful asks get a short, friendly redirect instead of an answer. It runs on a free safety model and is built to stay out of the way: if the check is ever slow or unavailable, your message goes straight through rather than being held up — the filter can never take chat down. Signed-in conversations are unaffected, and there's an instant off switch if it ever needs to step aside. `[feature, security]`
- **Accurate uptime on the x402 Provider Hub** — The payment directory was counting every unpaid x402 discovery request (the protocol's standard 402 challenge) as a failed call, dragging three.ws endpoint success rates down even when every endpoint was healthy. Telemetry now reports only real payment attempts, so the published uptime reflects actual service health. `[fix, infra]`
@@ -17,11 +18,13 @@ Public history for [three.ws](https://three.ws), newest first. New pages come fr
- **Create an avatar from a template or from scratch, right from the dashboard** — The dashboard's Avatars page only offered selfie and GLB-upload as ways to make a new avatar — the two fastest paths, starting from a ready-made template or sculpting one from scratch, were buried elsewhere. The '+ New avatar' menu now groups every option clearly: Build (start from a template, or build from scratch in the studio), From you (snap a selfie, full selfie flow, or describe it as a prompt), and Import (upload a GLB, copy an existing avatar, or browse the public gallery). 'Start from a template' opens a picker with live 3D previews and stages your pick straight into the save step. The empty state leads with the same three quick starts. (`/dashboard/avatars`) `[feature, improvement]`
- **Embedded avatar chat replies again** — Avatars embedded straight from their public profile — the one-line widget on the homepage and anywhere else the avatar URL is dropped in — went silent when you typed a message: the chat box accepted your text but the avatar never answered. The built-in AI now recognizes a plain public avatar and serves it the free we-pay model with the same per-avatar rate and usage limits, so embedded chat responds out of the box. `[fix]`
- **Faster, quieter agents directory and site-wide page polish** — The on-chain agents directory now loads from our server-side index instead of contacting every agent's metadata host from your browser — pages render faster and no longer spray network errors. Also: the pump.fun cockpit's sidebar pages are now shareable deep links, mobile nav and footer links meet touch-target guidelines, anonymous visitors no longer trigger failed sign-in requests on Walk and Create, and assorted dead links were removed. (`/agents`) `[improvement, fix]`
+- **Forge and Parts Studio headers display correctly again** — The intro banner on Forge and Parts Studio was rendering as a single squashed black bar — the headline overlapped the status pill and the description was cut off mid-word. Both pages now show the proper centered header: status pill on top, full headline, and the complete description underneath. (`/forge`) `[fix]`
- **Forge checks your photo before spending a generation — plus image-aware fact-checks and accessible galleries** — A new free image-understanding layer (running on NVIDIA's free models, so it costs you nothing) now powers three things across three.ws. In Forge, when you upload a photo to turn into 3D, it's checked first: if it's a screenshot of text, a cluttered scene with no clear subject, or too dark to reconstruct, you get a clear heads-up and a fix before a generation slot is spent — with a one-click 'Generate anyway' if you disagree. The Fact Checker can now take an image alongside a claim: it reads the picture, transcribes any text in it, and weighs that as evidence in the verdict. And every avatar in the public gallery now gets a real, descriptive alt text written from its thumbnail, so screen-reader users hear what each avatar actually looks like instead of just its name. All three quietly switch off if the vision service is ever unavailable — nothing ever blocks or breaks. (`/forge`) `[feature, improvement]`
- **Forge share links now open your creation for anyone you send them to** — When you share a model from Forge, the person who opens the link now sees your actual creation — the 3D model loads straight into the viewer, ready to spin, inspect, and download. Previously a share link only worked for the person who forged the model, because Forge only looked in your own browser's history; recipients landed on an empty Forge. Now the page fetches the shared model by its link and shows it to anyone, even if they've never used Forge before. If a link points to a model that was removed or is still generating, you get a clear message instead of a blank screen. (`/forge`) `[fix, improvement]`
- **Free 3D draft generations no longer get blocked by the paid rate limit** — Generating a 3D model from a text prompt on the Draft tier runs on a free engine — no key, no cost. But it was sharing the same hourly limit as the paid lanes, so a few quick iterations (or several people on the same office or campus network) could hit a 'generator is busy, try again later' wall even though nothing was being charged. The free draft lane now has its own, far more generous allowance and never blocks you because of a backend hiccup. Heavy paid generations keep their tighter limit. Iterate on prompts freely. (`/forge`) `[fix, improvement]`
- **Free 3D drafts on Forge** — Draft generations from a text prompt on Forge now run on a free NVIDIA-hosted TRELLIS engine by default — your first 3D model costs nothing and arrives in about 15 seconds, several times faster than the previous default. Photo-to-3D keeps its proven engine (the free lane is prompt-only by design), and every existing engine — TRELLIS on Replicate, Meshy, Tripo — remains selectable at every quality tier. (`/forge`) `[feature, improvement]`
- **Hardened the explore feed and marketplace pricing against bad requests** — The explore discovery feed and marketplace asset-pricing lookup now reject malformed query parameters with a clear 400 instead of failing with a server error. A non-numeric page size on explore, or a malformed asset id on a price lookup, no longer surfaces a 500 — the endpoints validate input up front and respond cleanly. (`/explore`) `[fix]`
+- **Inspect any agent's 3D model right on its marketplace page** — Agent pages in the marketplace now open with a full interactive 3D viewer — orbit, zoom, go fullscreen, download the GLB, or drop the agent straight into the world. Agents without a custom model show the base avatar, so the stage is never empty. Clicking the small header avatar jumps you to the viewer. (`/marketplace`) `[feature]`
- **Light theme is here — flip the whole site with one tap** — three.ws now ships a light theme alongside the signature dark one. A new sun/moon toggle sits in the top nav on every page: tap it to switch instantly, and your choice sticks across pages, sessions, and other open tabs. New here, or set to 'Auto' in Settings → Appearance? The site follows your device's light/dark preference automatically. The theme is applied before the page paints, so there's no white flash on load, and the dashboard appearance picker (Dark / Light / Auto) now applies live instead of just saving for later. Dark remains the brand default — nothing changes unless you want it to. `[feature, improvement]`
- **Live $THREE market data, longer trade streams, and tutor session fixes** — $THREE market stats (price, holders, liquidity) are flowing again from our primary data source — a missing request header had been silently failing it to backups for days. Live trade streams no longer cut out after 30 seconds; they now run their full duration. The Pay-As-You-Learn Tutor no longer errors when resuming a session — running tabs persist correctly across questions — and Fact Checker results are cached properly so repeat checks of the same claim return instantly. `[fix, improvement]`
- **MetaMask Agent Wallet skills for every agent** — Two new skills in the marketplace under the new Wallet category: MetaMask Agent Wallet and MetaMask Agent Workflows. Install them on any agent to let it check balances, transfer tokens, swap, bridge across chains, trade perps and prediction markets, and manage Aave positions through MetaMask's mm CLI — each user signs in with their own MetaMask Agent Wallet, so keys stay with you, never with three.ws. Platform chat agents pick the skills up automatically. (`/skills`) `[feature]`
diff --git a/data/changelog.json b/data/changelog.json
index 4aeeaa203..d8f636ca3 100644
--- a/data/changelog.json
+++ b/data/changelog.json
@@ -1,6 +1,24 @@
{
"$comment": "Curated changelog entries for three.ws — the editorial layer of the public changelog. New PAGE launches are tracked automatically via the `added` field in data/pages.json; this file is for everything else holders care about: improvements, fixes, SDK releases, trading/payments capabilities, security work. scripts/build-page-index.mjs merges both sources into CHANGELOG.md, public/changelog.json, and public/changelog.xml. Newest first. Allowed tags: feature, improvement, fix, sdk, infra, docs, security. `link` is optional and must be a live three.ws path.",
"entries": [
+ {
+ "date": "2026-06-11",
+ "title": "Forge and Parts Studio headers display correctly again",
+ "summary": "The intro banner on Forge and Parts Studio was rendering as a single squashed black bar — the headline overlapped the status pill and the description was cut off mid-word. Both pages now show the proper centered header: status pill on top, full headline, and the complete description underneath.",
+ "tags": [
+ "fix"
+ ],
+ "link": "/forge"
+ },
+ {
+ "date": "2026-06-11",
+ "title": "Inspect any agent's 3D model right on its marketplace page",
+ "summary": "Agent pages in the marketplace now open with a full interactive 3D viewer — orbit, zoom, go fullscreen, download the GLB, or drop the agent straight into the world. Agents without a custom model show the base avatar, so the stage is never empty. Clicking the small header avatar jumps you to the viewer.",
+ "tags": [
+ "feature"
+ ],
+ "link": "/marketplace"
+ },
{
"date": "2026-06-11",
"title": "More paid 3D generations per hour before you hit the limit",
diff --git a/data/pages.json b/data/pages.json
index 442ca0ab1..40be09dbd 100644
--- a/data/pages.json
+++ b/data/pages.json
@@ -349,6 +349,14 @@
"priority": 0.9,
"changefreq": "weekly"
},
+ {
+ "path": "/play/agent-wallet",
+ "title": "Agent Wallet (MetaMask × x402)",
+ "description": "Watch your 3D avatar walk up to a paid endpoint and pay for it with the MetaMask agent wallet — a real USDC micropayment signed by the MetaMask Agentic CLI and settled on Base.",
+ "priority": 0.7,
+ "changefreq": "monthly",
+ "added": "2026-06-11"
+ },
{
"path": "/pumpfun",
"title": "Pump.fun Stream",
diff --git a/package.json b/package.json
index 09ac3e1b9..9cc47fd9c 100644
--- a/package.json
+++ b/package.json
@@ -57,6 +57,7 @@
"dev": "vite --port 3000",
"dev:multi": "npm run dev --prefix multiplayer",
"dev:walk-all": "node scripts/dev-walk-all.mjs",
+ "demo:agent-wallet-bridge": "node scripts/mm-x402-bridge.mjs",
"dev:lib": "TARGET=lib vite",
"presence": "node scripts/three-ws-presence.mjs",
"build:pages": "node scripts/build-page-index.mjs",
diff --git a/pages/forge.html b/pages/forge.html
index 9648df0f7..2caa23420 100644
--- a/pages/forge.html
+++ b/pages/forge.html
@@ -50,6 +50,20 @@
padding: var(--space-xl) var(--space-md) var(--space-2xl);
}
.forge-head {
+ /* Reset the global site-nav `header` rule from style.css —
+ this is an in-page hero, not the top bar. */
+ display: block;
+ height: auto;
+ padding: 0;
+ background: none;
+ backdrop-filter: none;
+ -webkit-backdrop-filter: none;
+ border-bottom: 0;
+ overflow: visible;
+ white-space: normal;
+ line-height: var(--leading-normal);
+ z-index: auto;
+ -webkit-app-region: no-drag;
text-align: center;
margin-bottom: var(--space-xl);
}
@@ -75,6 +89,8 @@
box-shadow: 0 0 8px var(--success);
}
.forge-head h1 {
+ display: block;
+ color: var(--ink);
font-family: var(--font-display);
font-size: clamp(2rem, 5vw, var(--text-2xl));
line-height: var(--leading-tight);
diff --git a/pages/marketplace.html b/pages/marketplace.html
index 7b44d5f70..d293bd6d7 100644
--- a/pages/marketplace.html
+++ b/pages/marketplace.html
@@ -2797,6 +2797,41 @@
<div class="market-detail-body">
<div class="market-detail-content">
<div data-panel="overview" class="market-panel active">
+ <!-- 3D model stage — the agent's avatar, fully inspectable.
+ Populated by renderDetailModelStage(); agents without a
+ custom GLB show the base mannequin so the stage is never
+ empty. -->
+ <section
+ class="market-card d-model-card"
+ id="d-model-card"
+ aria-label="3D model viewer"
+ >
+ <div class="d-model-head">
+ <h3>3D Model</h3>
+ <span class="d-model-hint" id="d-model-hint"></span>
+ <div class="d-model-actions">
+ <a
+ class="d-model-btn"
+ id="d-model-world"
+ title="Walk with this agent in the three.ws world"
+ >Open in world</a
+ >
+ <a class="d-model-btn" id="d-model-download" download hidden
+ >Download GLB</a
+ >
+ <button
+ type="button"
+ class="d-model-btn"
+ id="d-model-fullscreen"
+ aria-label="View 3D model fullscreen"
+ >
+ ⛶ Fullscreen
+ </button>
+ </div>
+ </div>
+ <div class="d-model-stage" id="d-model-stage"></div>
+ </section>
+
<div class="market-card">
<h3>What can you do with this Agent?</h3>
<p id="d-overview">—</p>
diff --git a/pages/play/agent-wallet.html b/pages/play/agent-wallet.html
new file mode 100644
index 000000000..9dcef6458
--- /dev/null
+++ b/pages/play/agent-wallet.html
@@ -0,0 +1,350 @@
+<!doctype html>
+<html lang="en">
+<head>
+ <script>/* three.ws theme boot — no-flash; runtime in /theme-switcher.js */(function(){try{var m=localStorage.getItem('twx_theme');var l=m==='auto'?(window.matchMedia&&window.matchMedia('(prefers-color-scheme: light)').matches):m==='light';document.documentElement.setAttribute('data-theme',l?'light':'dark');}catch(e){document.documentElement.setAttribute('data-theme','dark');}})();</script>
+ <meta charset="utf-8" />
+ <meta name="viewport" content="width=device-width,initial-scale=1,viewport-fit=cover" />
+ <title>Agent Wallet — your avatar pays for an endpoint with MetaMask · three.ws</title>
+ <meta name="description" content="Watch your 3D avatar walk up to a paid x402 endpoint and pay for it with the MetaMask agent wallet — a real USDC micropayment signed by the MetaMask Agentic CLI and settled on Base." />
+ <link rel="canonical" href="https://three.ws/play/agent-wallet" />
+ <meta property="og:type" content="website" />
+ <meta property="og:title" content="Agent Wallet — your avatar pays for an endpoint with MetaMask" />
+ <meta property="og:description" content="A 3D avatar pays for live crypto intel with the MetaMask agent wallet. Real x402 micropayment, real USDC, settled on Base." />
+ <meta property="og:url" content="https://three.ws/play/agent-wallet" />
+ <meta property="og:image" content="https://three.ws/og-image.png" />
+ <meta name="twitter:card" content="summary_large_image" />
+ <meta name="twitter:title" content="Agent Wallet — your avatar pays for an endpoint with MetaMask" />
+ <meta name="twitter:description" content="A 3D avatar pays for a live API with the MetaMask agent wallet. Real USDC on Base, on-chain." />
+ <meta name="twitter:image" content="https://three.ws/og-image.png" />
+ <link rel="icon" href="/favicon.ico" sizes="any" />
+ <link rel="icon" type="image/svg+xml" href="/favicon.svg" />
+ <link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png" />
+ <link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png" />
+ <link rel="apple-touch-icon" href="/apple-touch-icon.png" />
+ <link rel="manifest" href="/site.webmanifest" />
+ <style>
+ :root {
+ color-scheme: dark;
+ --bg: #080808;
+ --bg2: #0e0e10;
+ --panel: rgba(14,15,20,0.92);
+ --border: rgba(255,255,255,0.08);
+ --border-hi:rgba(255,255,255,0.16);
+ --text: #eceef8;
+ --muted: #7c85a2;
+ --faint: #484f64;
+ --mm: #f6851b;
+ --mm-lt: #ffa04d;
+ --usdc: #2775ca;
+ --usdc-lt: #6db0f7;
+ --green: #22d77a;
+ --amber: #f5a623;
+ --red: #ff4f6a;
+ --mono: ui-monospace,"SF Mono",Menlo,Consolas,monospace;
+ --r: 14px;
+ }
+ *,*::before,*::after { box-sizing:border-box; margin:0; padding:0; }
+ html,body { height:100%; background:var(--bg); color:var(--text); -webkit-font-smoothing:antialiased; }
+ body { font:15px/1.6 -apple-system,system-ui,"Segoe UI",sans-serif; overflow:hidden; }
+ :focus-visible { outline:2px solid var(--mm-lt); outline-offset:3px; }
+ a { color:var(--usdc-lt); }
+
+ #app { display:grid; grid-template-rows:52px 1fr; height:100%; }
+
+ /* ── Top bar ─────────────────────────────────────────── */
+ .topbar {
+ display:flex; align-items:center; justify-content:space-between; gap:12px;
+ padding:0 20px; border-bottom:1px solid var(--border);
+ background:rgba(7,8,15,0.95); backdrop-filter:blur(12px); z-index:20;
+ }
+ .brand { display:flex; align-items:center; gap:10px; min-width:0; }
+ .brand a { color:var(--text); text-decoration:none; font-weight:700; font-size:15px; letter-spacing:-0.01em; }
+ .brand a.crumb { color:var(--muted); font-weight:500; }
+ .brand a.crumb:hover { color:var(--text); }
+ .brand .sep { color:var(--faint); }
+ .badge {
+ display:inline-flex; align-items:center; gap:7px;
+ background:rgba(246,133,27,0.10); border:1px solid rgba(246,133,27,0.32);
+ border-radius:99px; padding:4px 11px; font-size:12px; color:var(--mm-lt); font-weight:600;
+ white-space:nowrap;
+ }
+ .badge .dot { width:6px; height:6px; border-radius:50%; background:var(--mm); box-shadow:0 0 8px var(--mm); }
+ .tb-btn {
+ display:inline-flex; align-items:center; gap:6px; padding:6px 12px; border-radius:9px;
+ background:rgba(255,255,255,0.05); border:1px solid var(--border); color:var(--muted);
+ font:13px/1 inherit; font-weight:500; cursor:pointer; text-decoration:none;
+ transition:background .15s, color .15s, border-color .15s;
+ }
+ .tb-btn:hover { background:rgba(255,255,255,0.09); color:var(--text); border-color:var(--border-hi); }
+
+ /* ── Stage + panel layout ────────────────────────────── */
+ #main { display:grid; grid-template-columns:1fr 384px; min-height:0; }
+ #stage3d { position:relative; overflow:hidden; background:var(--bg2); }
+ #stage3d canvas { display:block; outline:none; }
+ .scene-hint {
+ position:absolute; left:16px; bottom:14px; z-index:5;
+ font-size:11.5px; color:var(--faint); background:rgba(7,8,15,0.6);
+ border:1px solid var(--border); border-radius:99px; padding:4px 12px;
+ backdrop-filter:blur(8px); pointer-events:none;
+ transition:opacity .4s;
+ }
+ .scene-hint.fade { opacity:0; }
+
+ /* ── Side panel ──────────────────────────────────────── */
+ #panel {
+ border-left:1px solid var(--border); background:var(--panel);
+ backdrop-filter:blur(20px); overflow-y:auto; padding:16px;
+ display:flex; flex-direction:column; gap:12px;
+ }
+ .card {
+ border:1px solid var(--border); border-radius:var(--r);
+ background:rgba(255,255,255,0.025); padding:14px;
+ transition:border-color .2s;
+ }
+ .card:hover { border-color:var(--border-hi); }
+ .card h2 {
+ font-size:11px; font-weight:700; letter-spacing:0.09em; text-transform:uppercase;
+ color:var(--faint); margin-bottom:10px; display:flex; align-items:center; gap:7px;
+ }
+ .card h2 .fox { width:15px; height:15px; flex:none; }
+
+ /* Wallet card */
+ .w-row { display:flex; align-items:center; justify-content:space-between; gap:8px; margin-bottom:7px; }
+ .w-row:last-child { margin-bottom:0; }
+ .w-row .k { font-size:12px; color:var(--muted); }
+ .w-row .v { font-size:13px; font-weight:600; font-variant-numeric:tabular-nums; display:flex; align-items:center; gap:6px; }
+ .addr { font-family:var(--mono); font-size:12px; }
+ .copy-btn {
+ border:1px solid var(--border); background:transparent; color:var(--faint);
+ border-radius:6px; padding:2px 7px; font-size:10.5px; cursor:pointer;
+ transition:color .15s, border-color .15s;
+ }
+ .copy-btn:hover { color:var(--text); border-color:var(--border-hi); }
+ .copy-btn:active { transform:translateY(1px); }
+ .mode-pill {
+ font-size:10px; font-weight:700; letter-spacing:0.05em; text-transform:uppercase;
+ padding:2px 8px; border-radius:99px;
+ background:rgba(246,133,27,0.14); color:var(--mm-lt); border:1px solid rgba(246,133,27,0.3);
+ }
+ .bal { font-size:20px; font-weight:750; letter-spacing:-0.01em; }
+ .bal small { font-size:11px; font-weight:600; color:var(--muted); margin-left:5px; }
+
+ /* state banners inside wallet card */
+ .banner { border-radius:10px; padding:10px 12px; font-size:12.5px; line-height:1.55; margin-top:10px; display:none; }
+ .banner.show { display:block; animation:rise .3s ease; }
+ .banner .b-head { font-weight:700; margin-bottom:4px; display:flex; align-items:center; gap:6px; }
+ .banner.offline { background:rgba(255,79,106,0.07); border:1px solid rgba(255,79,106,0.22); }
+ .banner.offline .b-head { color:var(--red); }
+ .banner.lowbal { background:rgba(245,166,35,0.07); border:1px solid rgba(245,166,35,0.22); }
+ .banner.lowbal .b-head { color:var(--amber); }
+ .banner code {
+ font-family:var(--mono); font-size:11px; background:rgba(255,255,255,0.06);
+ border-radius:5px; padding:1.5px 6px; color:var(--text); white-space:nowrap;
+ }
+ .banner .retry {
+ margin-top:8px; display:inline-flex; align-items:center; gap:6px;
+ border:1px solid var(--border-hi); background:rgba(255,255,255,0.05); color:var(--text);
+ border-radius:8px; padding:5px 12px; font:12px/1 inherit; font-weight:600; cursor:pointer;
+ transition:background .15s;
+ }
+ .banner .retry:hover { background:rgba(255,255,255,0.1); }
+
+ /* Endpoint card */
+ .ep-name { font-size:14.5px; font-weight:700; display:flex; align-items:center; justify-content:space-between; gap:8px; }
+ .ep-price { color:var(--green); font-variant-numeric:tabular-nums; white-space:nowrap; }
+ .ep-desc { font-size:12.5px; color:var(--muted); line-height:1.55; margin-top:6px; }
+ .ep-meta { display:flex; gap:6px; flex-wrap:wrap; margin-top:10px; }
+ .ep-tag {
+ font-size:10.5px; font-weight:600; padding:2px 9px; border-radius:99px;
+ background:rgba(39,117,202,0.12); color:var(--usdc-lt); border:1px solid rgba(39,117,202,0.28);
+ }
+ .skel { background:linear-gradient(90deg, rgba(255,255,255,0.05) 25%, rgba(255,255,255,0.1) 50%, rgba(255,255,255,0.05) 75%); background-size:200% 100%; animation:shimmer 1.4s infinite; border-radius:6px; color:transparent !important; }
+ @keyframes shimmer { to { background-position:-200% 0; } }
+
+ /* Topic + pay */
+ .topics { display:flex; gap:7px; flex-wrap:wrap; margin-top:11px; }
+ .t-chip {
+ font-size:12px; font-weight:600; padding:5px 13px; border-radius:99px; cursor:pointer;
+ border:1px solid var(--border); background:rgba(255,255,255,0.04); color:var(--muted);
+ transition:all .15s;
+ }
+ .t-chip:hover { border-color:var(--border-hi); color:var(--text); }
+ .t-chip.active { background:rgba(246,133,27,0.14); border-color:rgba(246,133,27,0.45); color:var(--mm-lt); }
+ .pay-btn {
+ width:100%; margin-top:12px; display:inline-flex; align-items:center; justify-content:center; gap:9px;
+ background:linear-gradient(135deg, var(--mm) 0%, #d96a07 100%);
+ color:#fff; border:0; border-radius:11px; padding:12px 22px;
+ font:14px/1 inherit; font-weight:700; cursor:pointer; letter-spacing:0.01em;
+ transition:filter .15s, transform .1s, box-shadow .15s;
+ }
+ .pay-btn:hover:not(:disabled) { filter:brightness(1.1); box-shadow:0 0 28px rgba(246,133,27,0.35); }
+ .pay-btn:active:not(:disabled) { transform:translateY(1px); }
+ .pay-btn:disabled { opacity:.5; cursor:default; box-shadow:none; filter:none; }
+ .pay-btn .spin { width:14px; height:14px; border:2px solid rgba(255,255,255,0.35); border-top-color:#fff; border-radius:50%; animation:spin .65s linear infinite; display:none; }
+ .pay-btn.busy .spin { display:inline-block; }
+ @keyframes spin { to { transform:rotate(360deg); } }
+ .pay-note { font-size:11px; color:var(--faint); margin-top:8px; line-height:1.5; }
+
+ /* Stage list */
+ .stages { display:flex; flex-direction:column; gap:2px; }
+ .stage { display:flex; align-items:center; gap:10px; padding:7px 4px; font-size:13px; color:var(--faint); transition:color .25s; }
+ .stage .si { width:17px; height:17px; border-radius:50%; border:2px solid var(--faint); flex:none; display:flex; align-items:center; justify-content:center; transition:all .3s; }
+ .stage.active { color:var(--text); }
+ .stage.active .si { border-color:var(--mm-lt); box-shadow:0 0 8px rgba(246,133,27,0.6); animation:pulse .9s ease-in-out infinite; }
+ .stage.done { color:var(--green); }
+ .stage.done .si { background:var(--green); border-color:var(--green); }
+ .stage.done .si::after { content:"✓"; font-size:9px; color:#000; font-weight:900; }
+ .stage.error { color:var(--red); }
+ .stage.error .si { border-color:var(--red); }
+ .stage.error .si::after { content:"✕"; font-size:9px; color:var(--red); font-weight:900; }
+ .stage .sd { font-size:11px; color:var(--faint); margin-left:auto; font-family:var(--mono); max-width:150px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
+ @keyframes pulse { 0%,100% { opacity:1; } 50% { opacity:.5; } }
+ .flow-error {
+ display:none; margin-top:10px; border-radius:10px; padding:10px 12px;
+ background:rgba(255,79,106,0.07); border:1px solid rgba(255,79,106,0.22);
+ font-size:12.5px; line-height:1.55; color:var(--muted);
+ }
+ .flow-error.show { display:block; animation:rise .3s ease; }
+ .flow-error .b-head { color:var(--red); font-weight:700; margin-bottom:4px; }
+
+ /* Receipt */
+ .receipt {
+ display:none; border:1px solid rgba(34,215,122,0.22); background:rgba(34,215,122,0.05);
+ border-radius:var(--r); padding:13px 14px;
+ }
+ .receipt.show { display:block; animation:rise .35s ease; }
+ @keyframes rise { from { opacity:0; transform:translateY(6px); } to { opacity:1; transform:none; } }
+ .receipt .r-head { display:flex; align-items:center; justify-content:space-between; margin-bottom:9px; }
+ .receipt .r-badge { font-size:12.5px; font-weight:700; color:var(--green); }
+ .receipt .r-amt { font-size:13px; font-weight:700; color:var(--green); font-variant-numeric:tabular-nums; }
+ .receipt .rf { display:flex; justify-content:space-between; gap:10px; font-size:12px; padding:3px 0; }
+ .receipt .rf .k { color:var(--faint); }
+ .receipt .rf .v { font-weight:600; font-family:var(--mono); font-size:11.5px; }
+ .receipt .rf .v a { text-decoration:none; }
+ .receipt .rf .v a:hover { text-decoration:underline; }
+ .receipt .r-payload {
+ margin-top:9px; padding-top:9px; border-top:1px solid rgba(34,215,122,0.14);
+ font-size:13px; line-height:1.5;
+ }
+ .r-signal { display:inline-flex; font-size:10.5px; font-weight:700; padding:1.5px 9px; border-radius:99px; margin-right:7px; vertical-align:1px; }
+ .signal-bullish { background:rgba(34,215,122,0.15); color:var(--green); border:1px solid rgba(34,215,122,0.3); }
+ .signal-bearish { background:rgba(255,79,106,0.13); color:var(--red); border:1px solid rgba(255,79,106,0.3); }
+ .signal-neutral { background:rgba(245,166,35,0.13); color:var(--amber); border:1px solid rgba(245,166,35,0.3); }
+
+ .how {
+ font-size:12px; color:var(--faint); line-height:1.6;
+ }
+ .how b { color:var(--muted); font-weight:650; }
+
+ /* ── Mobile ──────────────────────────────────────────── */
+ @media (max-width:860px) {
+ #main { grid-template-columns:1fr; grid-template-rows:46vh 1fr; }
+ #panel { border-left:0; border-top:1px solid var(--border); }
+ .topbar { padding:0 14px; }
+ .badge { display:none; }
+ }
+ </style>
+</head>
+<body>
+<div id="app">
+ <header class="topbar">
+ <div class="brand">
+ <a href="/">three.ws</a>
+ <span class="sep">/</span>
+ <a class="crumb" href="/play">play</a>
+ <span class="sep">/</span>
+ <span class="badge"><span class="dot"></span>MetaMask Agent Wallet × x402</span>
+ </div>
+ <div style="display:flex;gap:10px;align-items:center;">
+ <a class="tb-btn" href="/agent-exchange" title="Two agents paying each other">Agent Exchange</a>
+ <a class="tb-btn" href="/pay" title="x402 pay-per-call demo">x402 demo</a>
+ </div>
+ </header>
+
+ <div id="main">
+ <section id="stage3d" aria-label="3D scene: your avatar pays a x402 endpoint kiosk">
+ <div class="scene-hint" id="sceneHint">Drag to orbit · scroll to zoom</div>
+ </section>
+
+ <aside id="panel" aria-label="Payment controls">
+ <!-- Agent wallet -->
+ <div class="card" id="walletCard">
+ <h2>
+ <svg class="fox" viewBox="0 0 24 24" fill="none" aria-hidden="true"><path d="M21.5 3 13.7 8.8l1.5-3.4L21.5 3Z" fill="#E2761B"/><path d="m2.5 3 7.7 5.9-1.4-3.5L2.5 3Zm15.8 13.2-2.1 3.2 4.5 1.2 1.3-4.3-3.7-.1Zm-15.8.1 1.3 4.3 4.5-1.2-2.1-3.2-3.7.1Z" fill="#E4761B"/><path d="m8 10.5-1.3 1.9 4.4.2-.1-4.8L8 10.5Zm8 0-3-2.8-.1 4.9 4.4-.2L16 10.5Zm-7.7 9 2.7-1.3-2.3-1.8-.4 3.1Zm5.7-1.3 2.7 1.3-.4-3.1-2.3 1.8Z" fill="#E4761B"/><path d="m16.7 19.5-2.7-1.3.2 1.7v.7l2.5-1.1Zm-9.4 0 2.5 1.1v-.7l.2-1.7-2.7 1.3Z" fill="#D7C1B3"/><path d="M9.9 15.3 7.7 14.6l1.6-.7.6 1.4Zm4.2 0 .6-1.4 1.6.7-2.2.7Z" fill="#233447"/><path d="m7.3 19.5.4-3.2-2.5.1 2.1 3.1Zm9-3.2.4 3.2 2.1-3.1-2.5-.1Zm1.8-3.9-4.4.2.4 2.7.6-1.4 1.6.7 1.8-2.2Zm-10.4 2.2 1.6-.7.6 1.4.4-2.7-4.4-.2 1.8 2.2Z" fill="#CD6116"/><path d="m6.7 12.4 1.9 3.6-.1-1.8-1.8-1.8Zm10.6 0-1.8 1.8-.1 1.8 1.9-3.6Zm-6.2.2-.4 2.7.5 2.6.1-3.4-.2-1.9Zm1.8 0-.2 1.9.1 3.4.5-2.6-.4-2.7Z" fill="#E4751F"/><path d="m12.9 15.3-.5 2.6.4.3 2.3-1.8.1-1.8-2.3.7Zm-5.2-.7.1 1.8 2.3 1.8.4-.3-.5-2.6-2.3-.7Z" fill="#F6851B"/><path d="m13 20.6-.1-.7h-1.8l-.1.7-.2 1.7 2.5.1-.3-1.8Z" fill="#C0AD9E"/><path d="m12.8 18.2-.4-.3h-.8l-.4.3-.2 1.7h1.8l-.2-1.7" fill="#161616"/><path d="m21.8 9.2.7-3.2-1-3-7.7 5.7 3 2.5 4.2 1.2.9-1.1-.4-.3.6-.6-.5-.4.6-.5-.4-.3Zm-20.3-3.2.7 3.2-.4.3.6.5-.5.4.6.6-.4.3.9 1.1 4.2-1.2 3-2.5L2.5 3l-1 3Z" fill="#763D16"/><path d="m20.9 12.4-4.2-1.2 1.3 1.9-1.9 3.6 2.5 0h3.7l-1.4-4.3ZM7.3 11.2l-4.2 1.2-1.4 4.3h3.7l2.5 0-1.9-3.6 1.3-1.9Zm5.4 2.1.3-4.6 1.2-3.3H8.8L10 8.7l.3 4.6.1 1.9v3.4h1.8l.1-3.4.1-1.9Z" fill="#F6851B"/></svg>
+ MetaMask Agent Wallet
+ </h2>
+ <div class="w-row">
+ <span class="k">Account</span>
+ <span class="v"><span class="addr" id="wAddr">—</span><button class="copy-btn" id="copyAddr" type="button" aria-label="Copy wallet address">copy</button></span>
+ </div>
+ <div class="w-row">
+ <span class="k">Mode</span>
+ <span class="v"><span class="mode-pill" id="wMode">—</span></span>
+ </div>
+ <div class="w-row">
+ <span class="k">Balance</span>
+ <span class="v bal" id="wBal"><span class="skel">$0.00</span><small>USD</small></span>
+ </div>
+
+ <div class="banner offline" id="bridgeOffline" role="alert">
+ <div class="b-head">Bridge offline</div>
+ The MetaMask Agentic CLI runs in your terminal, so this demo talks to it
+ through a local bridge. Start it in the repo root:
+ <div style="margin-top:6px"><code>npm run demo:agent-wallet-bridge</code></div>
+ <div style="margin-top:4px">then make sure you're signed in: <code>mm auth status</code></div>
+ <button class="retry" id="retryBridge" type="button">Retry connection</button>
+ </div>
+ <div class="banner lowbal" id="lowBalance" role="alert">
+ <div class="b-head">Wallet needs USDC on Base</div>
+ This payment is real — send a little USDC (Base mainnet) to the agent
+ wallet address above, or fund it with <code>mm</code>, then retry.
+ </div>
+ </div>
+
+ <!-- Paid endpoint -->
+ <div class="card">
+ <h2>Paid endpoint · x402 on Base</h2>
+ <div class="ep-name">
+ <span id="epName"><span class="skel">three.ws Crypto Intel</span></span>
+ <span class="ep-price" id="epPrice"><span class="skel">$0.01</span></span>
+ </div>
+ <div class="ep-desc" id="epDesc"><span class="skel">Live market signal — pay per call, settled in USDC on Base mainnet.</span></div>
+ <div class="ep-meta" id="epTags"></div>
+
+ <div class="topics" id="topics" role="group" aria-label="Intel topic"></div>
+
+ <button class="pay-btn" id="payBtn" type="button" disabled>
+ <span class="spin" aria-hidden="true"></span>
+ <span class="lbl">Send avatar to pay</span>
+ </button>
+ <div class="pay-note">Your avatar walks to the kiosk, the MetaMask agent wallet signs a USDC
+ <span style="font-family:var(--mono);font-size:10px">TransferWithAuthorization</span>, and the
+ endpoint settles it on Base mainnet. Real money, real API response.</div>
+ </div>
+
+ <!-- Live payment stages -->
+ <div class="card">
+ <h2>Payment flow</h2>
+ <div class="stages" id="stages" aria-live="polite"></div>
+ <div class="flow-error" id="flowError" role="alert"></div>
+ </div>
+
+ <div class="receipt" id="receipt" aria-live="polite"></div>
+
+ <div class="card">
+ <h2>How it works</h2>
+ <div class="how">
+ <b>1.</b> The endpoint answers with a <b>402 Payment Required</b> challenge (x402 v2).<br/>
+ <b>2.</b> The <b>MetaMask Agentic CLI</b> signs an EIP-3009 USDC transfer authorization
+ (<span style="font-family:var(--mono);font-size:10.5px">mm wallet sign-typed-data</span>).<br/>
+ <b>3.</b> The request retries with the <b>X-PAYMENT</b> header; a facilitator verifies and
+ settles the USDC on <b>Base mainnet</b>, then the API does the paid work.
+ </div>
+ </div>
+ </aside>
+ </div>
+</div>
+<script type="module" src="/src/play-agent-wallet.js"></script>
+<script src="/brand.js" defer></script>
+</body>
+</html>
diff --git a/pages/segment.html b/pages/segment.html
index ee5581107..444cf9ee2 100644
--- a/pages/segment.html
+++ b/pages/segment.html
@@ -39,6 +39,20 @@
padding: var(--space-xl) var(--space-md) var(--space-2xl);
}
.seg-head {
+ /* Reset the global site-nav `header` rule from style.css —
+ this is an in-page hero, not the top bar. */
+ display: block;
+ height: auto;
+ padding: 0;
+ background: none;
+ backdrop-filter: none;
+ -webkit-backdrop-filter: none;
+ border-bottom: 0;
+ overflow: visible;
+ white-space: normal;
+ line-height: var(--leading-normal);
+ z-index: auto;
+ -webkit-app-region: no-drag;
text-align: center;
margin-bottom: var(--space-lg);
}
@@ -64,6 +78,8 @@
box-shadow: 0 0 8px var(--success);
}
.seg-head h1 {
+ display: block;
+ color: var(--ink);
font-family: var(--font-display);
font-size: clamp(2rem, 5vw, var(--text-2xl));
line-height: var(--leading-tight);
diff --git a/public/changelog.json b/public/changelog.json
index d63a42aaf..14241a6b3 100644
--- a/public/changelog.json
+++ b/public/changelog.json
@@ -1,11 +1,21 @@
{
- "generated_at": "2026-06-11T14:36:47.902Z",
+ "generated_at": "2026-06-11T23:14:45.832Z",
"generated_by": "scripts/build-page-index.mjs from data/pages.json + data/changelog.json",
"site": {
"name": "three.ws",
"url": "https://three.ws"
},
"entries": [
+ {
+ "date": "2026-06-11",
+ "type": "launch",
+ "title": "Agent Wallet (MetaMask × x402)",
+ "summary": "Watch your 3D avatar walk up to a paid endpoint and pay for it with the MetaMask agent wallet — a real USDC micropayment signed by the MetaMask Agentic CLI and settled on Base.",
+ "link": "/play/agent-wallet",
+ "tags": [
+ "launch"
+ ]
+ },
{
"date": "2026-06-11",
"type": "launch",
@@ -122,6 +132,16 @@
"fix"
]
},
+ {
+ "date": "2026-06-11",
+ "type": "update",
+ "title": "Forge and Parts Studio headers display correctly again",
+ "summary": "The intro banner on Forge and Parts Studio was rendering as a single squashed black bar — the headline overlapped the status pill and the description was cut off mid-word. Both pages now show the proper centered header: status pill on top, full headline, and the complete description underneath.",
+ "link": "/forge",
+ "tags": [
+ "fix"
+ ]
+ },
{
"date": "2026-06-11",
"type": "update",
@@ -176,6 +196,16 @@
"fix"
]
},
+ {
+ "date": "2026-06-11",
+ "type": "update",
+ "title": "Inspect any agent's 3D model right on its marketplace page",
+ "summary": "Agent pages in the marketplace now open with a full interactive 3D viewer — orbit, zoom, go fullscreen, download the GLB, or drop the agent straight into the world. Agents without a custom model show the base avatar, so the stage is never empty. Clicking the small header avatar jumps you to the viewer.",
+ "link": "/marketplace",
+ "tags": [
+ "feature"
+ ]
+ },
{
"date": "2026-06-11",
"type": "update",
diff --git a/public/changelog.xml b/public/changelog.xml
index 51ad08b2e..b00c33ccd 100644
--- a/public/changelog.xml
+++ b/public/changelog.xml
@@ -6,6 +6,14 @@
<atom:link href="https://three.ws/changelog.xml" rel="self" type="application/rss+xml"/>
<description>What's new on three.ws — features, improvements, and releases, newest first.</description>
<language>en</language>
+ <item>
+ <title>Agent Wallet (MetaMask × x402)</title>
+ <link>https://three.ws/play/agent-wallet</link>
+ <guid isPermaLink="false">2026-06-11:Agent Wallet (MetaMask × x402)</guid>
+ <pubDate>Thu, 11 Jun 2026 12:00:00 GMT</pubDate>
+ <category>launch</category>
+ <description>Watch your 3D avatar walk up to a paid endpoint and pay for it with the MetaMask agent wallet — a real USDC micropayment signed by the MetaMask Agentic CLI and settled on Base.</description>
+ </item>
<item>
<title>Status</title>
<link>https://three.ws/status</link>
@@ -94,6 +102,14 @@
<category>improvement</category>
<description>The on-chain agents directory now loads from our server-side index instead of contacting every agent's metadata host from your browser — pages render faster and no longer spray network errors. Also: the pump.fun cockpit's sidebar pages are now shareable deep links, mobile nav and footer links meet touch-target guidelines, anonymous visitors no longer trigger failed sign-in requests on Walk and Create, and assorted dead links were removed.</description>
</item>
+ <item>
+ <title>Forge and Parts Studio headers display correctly again</title>
+ <link>https://three.ws/forge</link>
+ <guid isPermaLink="false">2026-06-11:Forge and Parts Studio headers display correctly again</guid>
+ <pubDate>Thu, 11 Jun 2026 12:00:00 GMT</pubDate>
+ <category>fix</category>
+ <description>The intro banner on Forge and Parts Studio was rendering as a single squashed black bar — the headline overlapped the status pill and the description was cut off mid-word. Both pages now show the proper centered header: status pill on top, full headline, and the complete description underneath.</description>
+ </item>
<item>
<title>Forge checks your photo before spending a generation — plus image-aware fact-checks and accessible galleries</title>
<link>https://three.ws/forge</link>
@@ -134,6 +150,14 @@
<category>fix</category>
<description>The explore discovery feed and marketplace asset-pricing lookup now reject malformed query parameters with a clear 400 instead of failing with a server error. A non-numeric page size on explore, or a malformed asset id on a price lookup, no longer surfaces a 500 — the endpoints validate input up front and respond cleanly.</description>
</item>
+ <item>
+ <title>Inspect any agent's 3D model right on its marketplace page</title>
+ <link>https://three.ws/marketplace</link>
+ <guid isPermaLink="false">2026-06-11:Inspect any agent's 3D model right on its marketplace page</guid>
+ <pubDate>Thu, 11 Jun 2026 12:00:00 GMT</pubDate>
+ <category>feature</category>
+ <description>Agent pages in the marketplace now open with a full interactive 3D viewer — orbit, zoom, go fullscreen, download the GLB, or drop the agent straight into the world. Agents without a custom model show the base avatar, so the stage is never empty. Clicking the small header avatar jumps you to the viewer.</description>
+ </item>
<item>
<title>Light theme is here — flip the whole site with one tap</title>
<link>https://three.ws/changelog</link>
diff --git a/public/features.json b/public/features.json
index 73572e175..f69b91be9 100644
--- a/public/features.json
+++ b/public/features.json
@@ -1,5 +1,5 @@
{
- "generated_at": "2026-06-11T14:36:47.892Z",
+ "generated_at": "2026-06-11T23:14:45.823Z",
"generated_by": "scripts/build-page-index.mjs from data/pages.json",
"site": {
"name": "three.ws",
@@ -446,6 +446,16 @@
"tags": [],
"showcase": false
},
+ {
+ "path": "/play/agent-wallet",
+ "title": "Agent Wallet (MetaMask × x402)",
+ "description": "Watch your 3D avatar walk up to a paid endpoint and pay for it with the MetaMask agent wallet — a real USDC micropayment signed by the MetaMask Agentic CLI and settled on Base.",
+ "added": "2026-06-11",
+ "auth": null,
+ "indexable": true,
+ "tags": [],
+ "showcase": false
+ },
{
"path": "/pumpfun",
"title": "Pump.fun Stream",
diff --git a/public/ibm-partner-logo.png b/public/ibm-partner-logo.png
new file mode 100644
index 000000000..244cccb8f
Binary files /dev/null and b/public/ibm-partner-logo.png differ
diff --git a/public/llms-full.txt b/public/llms-full.txt
index 3cd9aaadf..86c1f8541 100644
--- a/public/llms-full.txt
+++ b/public/llms-full.txt
@@ -272,6 +272,12 @@ URL: https://three.ws/pay
Pay-per-call gateway: invoke any x402-protocol paid API with a USDC micro-transaction.
+### Agent Wallet (MetaMask × x402)
+
+URL: https://three.ws/play/agent-wallet
+
+Watch your 3D avatar walk up to a paid endpoint and pay for it with the MetaMask agent wallet — a real USDC micropayment signed by the MetaMask Agentic CLI and settled on Base.
+
### Pump.fun Stream
URL: https://three.ws/pumpfun
diff --git a/public/llms.txt b/public/llms.txt
index 01d3441ae..60161e9c3 100644
--- a/public/llms.txt
+++ b/public/llms.txt
@@ -66,6 +66,7 @@ Experimental features actively shipping. Expect fast iteration.
On-chain features: pay-per-call, token launches, vanity wallets.
- [Pay (x402)](https://three.ws/pay): Pay-per-call gateway: invoke any x402-protocol paid API with a USDC micro-transaction.
+- [Agent Wallet (MetaMask × x402)](https://three.ws/play/agent-wallet): Watch your 3D avatar walk up to a paid endpoint and pay for it with the MetaMask agent wallet — a real USDC micropayment signed by the MetaMask Agentic CLI and settled on Base.
- [Pump.fun Stream](https://three.ws/pumpfun): Mint and trade pump.fun agent tokens on Solana. Live feed of every launch.
- [Pump Live](https://three.ws/pump-live): Real-time SSE feed of every pump.fun launch as it happens.
- [Pump Dashboard](https://three.ws/pump-dashboard): Pump.fun trading desk: watchlists, scanner, quotes, portfolio, and live charts.
diff --git a/public/marketplace-v2.css b/public/marketplace-v2.css
index 5a442972a..ea6856eea 100644
--- a/public/marketplace-v2.css
+++ b/public/marketplace-v2.css
@@ -50,6 +50,121 @@ body.market-page > #footer-container {
.market-detail-avatar.has-3d .d-avatar-fallback {
display: none;
}
+/* Header avatar doubles as a jump-to-viewer button (wired in
+ renderDetailModelStage). */
+.market-detail-avatar[role='button'] {
+ cursor: pointer;
+ transition: transform 0.15s ease, box-shadow 0.15s ease;
+}
+.market-detail-avatar[role='button']:hover {
+ transform: scale(1.04);
+ box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.25);
+}
+.market-detail-avatar[role='button']:focus-visible {
+ outline: 2px solid #fafafa;
+ outline-offset: 2px;
+}
+
+/* ── Detail 3D model stage ────────────────────────────────────────────── */
+.d-model-card {
+ padding: 0;
+ overflow: hidden;
+}
+.d-model-card.flash {
+ animation: d-model-flash 1.2s ease;
+}
+@keyframes d-model-flash {
+ 0%,
+ 60% {
+ border-color: rgba(255, 255, 255, 0.55);
+ }
+ 100% {
+ border-color: var(--stroke);
+ }
+}
+.d-model-head {
+ display: flex;
+ align-items: center;
+ gap: 10px;
+ flex-wrap: wrap;
+ padding: 12px 16px;
+ border-bottom: 1px solid var(--stroke);
+}
+.d-model-head h3 {
+ margin: 0;
+}
+.d-model-hint {
+ flex: 1;
+ min-width: 0;
+ font-size: 12px;
+ color: var(--ink-dim);
+ white-space: nowrap;
+ overflow: hidden;
+ text-overflow: ellipsis;
+}
+.d-model-actions {
+ display: flex;
+ gap: 8px;
+ margin-left: auto;
+}
+.d-model-btn {
+ appearance: none;
+ background: var(--surface-2);
+ border: 1px solid var(--stroke);
+ border-radius: 999px;
+ color: var(--ink);
+ font: inherit;
+ font-size: 12px;
+ font-weight: 600;
+ line-height: 1;
+ padding: 7px 12px;
+ cursor: pointer;
+ text-decoration: none;
+ white-space: nowrap;
+ transition: border-color 0.15s ease, background 0.15s ease, color 0.15s ease;
+}
+.d-model-btn:hover {
+ border-color: rgba(255, 255, 255, 0.35);
+ background: rgba(255, 255, 255, 0.06);
+}
+.d-model-btn:active {
+ background: rgba(255, 255, 255, 0.12);
+}
+.d-model-btn:focus-visible {
+ outline: 2px solid #fafafa;
+ outline-offset: 2px;
+}
+.d-model-stage {
+ position: relative;
+ height: 380px;
+ background: radial-gradient(circle at 50% 65%, rgba(255, 255, 255, 0.07), transparent 65%),
+ linear-gradient(180deg, #060606, #0e0e0e);
+}
+.d-model-stage model-viewer {
+ width: 100%;
+ height: 100%;
+ --poster-color: transparent;
+ background: transparent;
+}
+.d-model-card:fullscreen {
+ display: flex;
+ flex-direction: column;
+ border-radius: 0;
+ background: #000;
+}
+.d-model-card:fullscreen .d-model-stage {
+ flex: 1;
+ height: auto;
+}
+@media (max-width: 640px) {
+ .d-model-stage {
+ height: 260px;
+ }
+ .d-model-hint {
+ display: none;
+ }
+}
+
.market-author-btn {
background: none;
border: 0;
diff --git a/public/nav-data.js b/public/nav-data.js
index 47d3d574e..07d01cc13 100644
--- a/public/nav-data.js
+++ b/public/nav-data.js
@@ -229,6 +229,12 @@ export const NAV_GROUPS = [
{
label: 'x402 & Onchain',
items: [
+ {
+ title: 'Agent Wallet',
+ href: '/play/agent-wallet',
+ badge: 'New',
+ desc: 'Your avatar pays an endpoint via MetaMask — USDC on Base',
+ },
{ title: 'Pole Club', href: '/club', desc: 'x402 micro-tip demo — $0.001 / dance' },
{
title: 'Endpoint Shopper',
diff --git a/public/sitemap/index.html b/public/sitemap/index.html
index 3470a06cc..8ee5acbb8 100644
--- a/public/sitemap/index.html
+++ b/public/sitemap/index.html
@@ -394,6 +394,13 @@
<span class="sm-desc">Pay-per-call gateway: invoke any x402-protocol paid API with a USDC micro-transaction.</span>
</a>
</li>
+ <li>
+ <a href="/play/agent-wallet">
+ <span class="sm-title">Agent Wallet (MetaMask × x402)</span>
+ <span class="sm-path">/play/agent-wallet</span>
+ <span class="sm-desc">Watch your 3D avatar walk up to a paid endpoint and pay for it with the MetaMask agent wallet — a real USDC micropayment signed by the MetaMask Agentic CLI and settled on Base.</span>
+ </a>
+ </li>
<li>
<a href="/pumpfun">
<span class="sm-title">Pump.fun Stream</span>
diff --git a/scripts/mm-x402-bridge.mjs b/scripts/mm-x402-bridge.mjs
new file mode 100644
index 000000000..26af2cb79
--- /dev/null
+++ b/scripts/mm-x402-bridge.mjs
@@ -0,0 +1,414 @@
+#!/usr/bin/env node
+// mm-x402-bridge — local bridge between the /play/agent-wallet demo page and
+// the MetaMask Agentic CLI (`mm`).
+//
+// The MetaMask agent wallet lives in the developer's shell session (server-
+// wallet mode, authenticated via `mm login`), so a browser page can't reach it
+// directly. This bridge exposes the three operations the demo needs over
+// localhost HTTP:
+//
+// GET /status → wallet address/mode + balances (mm wallet show/balance)
+// GET /quote?endpoint=<url> → the endpoint's real 402 challenge, parsed
+// POST /pay {endpoint,method,body} → SSE stream of a REAL x402 payment:
+// challenge → signing → signed → submitting → done|error
+//
+// The payment is the standard x402 v2 EIP-3009 flow on Base mainnet
+// (eip155:8453): the bridge fetches the 402 challenge, asks the mm CLI to sign
+// the USDC TransferWithAuthorization typed data (`mm wallet sign-typed-data`),
+// then retries the request with the X-PAYMENT header. Settlement happens
+// server-side at the paid endpoint via its facilitator — real USDC moves.
+//
+// Safety rails (this listens on localhost, where any local page could reach it):
+// • Target endpoints must be on an allowlisted origin (three.ws + local dev).
+// • Per-payment cap, default $0.10 USDC (MM_BRIDGE_MAX_USDC_MICROS).
+// • CORS restricted to local dev origins + *.app.github.dev.
+//
+// Run: node scripts/mm-x402-bridge.mjs (or: npm run demo:agent-wallet-bridge)
+
+import { createServer } from 'node:http';
+import { execFile } from 'node:child_process';
+import { randomBytes } from 'node:crypto';
+
+const PORT = Number(process.env.MM_BRIDGE_PORT) || 4402;
+const MAX_USDC_MICROS = BigInt(process.env.MM_BRIDGE_MAX_USDC_MICROS || '100000'); // $0.10
+const BASE_NETWORK = 'eip155:8453';
+const BASE_CHAIN_ID = 8453;
+
+// Origins a target paid endpoint may live on. The demo pays three.ws's own
+// x402 endpoints; local dev lets you point at `vercel dev`/vite proxies.
+const ALLOWED_ENDPOINT_ORIGINS = (
+ process.env.MM_BRIDGE_ALLOWED_ENDPOINT_ORIGINS ||
+ 'https://three.ws,http://localhost:3000,http://127.0.0.1:3000'
+)
+ .split(',')
+ .map((s) => s.trim())
+ .filter(Boolean);
+
+// Browser origins allowed to call the bridge (the demo page).
+function corsOriginAllowed(origin) {
+ if (!origin) return false;
+ try {
+ const u = new URL(origin);
+ if (u.hostname === 'localhost' || u.hostname === '127.0.0.1') return true;
+ if (u.hostname.endsWith('.app.github.dev')) return true;
+ if (origin === 'https://three.ws') return true;
+ return false;
+ } catch {
+ return false;
+ }
+}
+
+// ── mm CLI ────────────────────────────────────────────────────────────────
+
+// Run an mm command with --json and parse the JSON object out of stdout.
+// The CLI prints human lines (e.g. "Intent: …") before the JSON, so parse
+// from the first `{`.
+function mm(args, { timeoutMs = 120_000 } = {}) {
+ return new Promise((resolvePromise, reject) => {
+ execFile('mm', [...args, '--json'], { timeout: timeoutMs, maxBuffer: 4 * 1024 * 1024 }, (err, stdout, stderr) => {
+ const raw = String(stdout || '');
+ const jsonStart = raw.indexOf('{');
+ if (jsonStart === -1) {
+ return reject(new Error(`mm ${args[0]} produced no JSON output${err ? `: ${err.message}` : ''}${stderr ? ` — ${String(stderr).slice(0, 300)}` : ''}`));
+ }
+ let parsed;
+ try {
+ parsed = JSON.parse(raw.slice(jsonStart));
+ } catch (parseErr) {
+ return reject(new Error(`mm ${args[0]} output parse failed: ${parseErr.message}`));
+ }
+ if (parsed.ok === false) {
+ return reject(new Error(`mm ${args[0]} failed: ${parsed.error?.message || parsed.error || 'unknown error'}`));
+ }
+ resolvePromise(parsed.data ?? parsed);
+ });
+ });
+}
+
+let statusCache = null; // { at, payload }
+async function walletStatus() {
+ if (statusCache && Date.now() - statusCache.at < 10_000) return statusCache.payload;
+ const [show, balance] = await Promise.all([mm(['wallet', 'show']), mm(['wallet', 'balance'])]);
+ const payload = {
+ ok: true,
+ wallet: {
+ address: show.address,
+ mode: show.mode,
+ chainNamespace: show.chainNamespace,
+ policies: show.policies || show['policies[2]'] || null,
+ },
+ balance: {
+ currency: balance.currency,
+ totalValue: balance.totalValue,
+ chains: balance.chains || [],
+ },
+ };
+ statusCache = { at: Date.now(), payload };
+ return payload;
+}
+
+// ── x402 client flow (mirrors public/x402.js, the platform's browser payer) ──
+
+function endpointAllowed(endpoint) {
+ try {
+ const u = new URL(endpoint);
+ return ALLOWED_ENDPOINT_ORIGINS.includes(u.origin);
+ } catch {
+ return false;
+ }
+}
+
+function isEip3009BaseAccept(a) {
+ return (
+ a &&
+ a.scheme === 'exact' &&
+ a.network === BASE_NETWORK &&
+ (!a.extra?.assetTransferMethod || a.extra.assetTransferMethod === 'eip3009')
+ );
+}
+
+async function fetch402(endpoint, method, body) {
+ const res = await fetch(endpoint, {
+ method,
+ headers: { accept: 'application/json', ...(body ? { 'content-type': 'application/json' } : {}) },
+ body: body ? JSON.stringify(body) : undefined,
+ });
+ if (res.status !== 402) {
+ const text = (await res.text()).slice(0, 300);
+ throw new Error(`expected a 402 challenge from ${endpoint}, got ${res.status}: ${text}`);
+ }
+ const challenge = await res.json();
+ if (!Array.isArray(challenge?.accepts) || !challenge.accepts.length) {
+ throw new Error('402 challenge has no accepts[] entries');
+ }
+ const accept = challenge.accepts.find(isEip3009BaseAccept);
+ if (!accept) {
+ throw new Error(`endpoint does not accept EIP-3009 USDC on Base (${BASE_NETWORK})`);
+ }
+ return { challenge, accept };
+}
+
+// ERC-8021 builder-code echo — the server rejects payments that don't echo the
+// declared app code. Self-attribute this bridge as the wallet/service pair.
+const BUILDER_CODE_PATTERN = /^[a-z0-9_]{1,32}$/;
+function builderCodeEcho(challenge) {
+ const declaredA = challenge?.extensions?.['builder-code']?.info?.a;
+ if (!declaredA || !BUILDER_CODE_PATTERN.test(declaredA)) return null;
+ return { a: declaredA, w: 'metamask_agent', s: ['mm_x402_bridge'] };
+}
+
+function buildTypedData({ accept, payerAddress }) {
+ const validAfter = 0;
+ const validBefore = Math.floor(Date.now() / 1000) + (accept.maxTimeoutSeconds || 600);
+ const nonce = '0x' + randomBytes(32).toString('hex');
+ return {
+ typedData: {
+ primaryType: 'TransferWithAuthorization',
+ types: {
+ EIP712Domain: [
+ { name: 'name', type: 'string' },
+ { name: 'version', type: 'string' },
+ { name: 'chainId', type: 'uint256' },
+ { name: 'verifyingContract', type: 'address' },
+ ],
+ TransferWithAuthorization: [
+ { name: 'from', type: 'address' },
+ { name: 'to', type: 'address' },
+ { name: 'value', type: 'uint256' },
+ { name: 'validAfter', type: 'uint256' },
+ { name: 'validBefore', type: 'uint256' },
+ { name: 'nonce', type: 'bytes32' },
+ ],
+ },
+ domain: {
+ name: accept.extra?.name || 'USD Coin',
+ version: accept.extra?.version || '2',
+ chainId: BASE_CHAIN_ID,
+ verifyingContract: accept.asset,
+ },
+ message: {
+ from: payerAddress,
+ to: accept.payTo,
+ value: accept.amount,
+ validAfter,
+ validBefore,
+ nonce,
+ },
+ },
+ authorization: { validAfter, validBefore, nonce },
+ };
+}
+
+function fmtUsdc(micros) {
+ return '$' + (Number(micros) / 1e6).toFixed(2);
+}
+
+async function executePayment({ endpoint, method, body, emit }) {
+ // 1. Real 402 challenge from the paid endpoint.
+ const { challenge, accept } = await fetch402(endpoint, method, body);
+ const amount = BigInt(accept.amount);
+ if (amount > MAX_USDC_MICROS) {
+ throw new Error(
+ `endpoint asks for ${fmtUsdc(accept.amount)} USDC, above the bridge cap of ${fmtUsdc(MAX_USDC_MICROS.toString())} (raise MM_BRIDGE_MAX_USDC_MICROS to allow)`,
+ );
+ }
+ emit({
+ stage: 'challenge',
+ amount: accept.amount,
+ payTo: accept.payTo,
+ asset: accept.asset,
+ network: accept.network,
+ resource: challenge.resource || null,
+ });
+
+ // 2. MetaMask agent wallet signs the USDC TransferWithAuthorization.
+ const status = await walletStatus();
+ const payerAddress = status.wallet.address;
+ const { typedData } = buildTypedData({ accept, payerAddress });
+ emit({
+ stage: 'signing',
+ signer: payerAddress,
+ domain: typedData.domain,
+ primaryType: typedData.primaryType,
+ to: accept.payTo,
+ value: accept.amount,
+ });
+ const intent = `Pay ${fmtUsdc(accept.amount)} USDC on Base to ${accept.payTo} for ${endpoint}`;
+ const signed = await mm([
+ 'wallet',
+ 'sign-typed-data',
+ '--chain-id',
+ String(BASE_CHAIN_ID),
+ '--payload',
+ JSON.stringify(typedData),
+ '--wait',
+ '--intent',
+ intent,
+ ]);
+ if (!signed.signature) {
+ throw new Error(`mm CLI returned no signature (status: ${signed.status || 'unknown'})`);
+ }
+ emit({ stage: 'signed', signature: signed.signature, signer: payerAddress });
+
+ // 3. Retry the request with the X-PAYMENT header — the endpoint verifies and
+ // settles via its facilitator, then does the paid work.
+ const paymentPayload = {
+ x402Version: 2,
+ scheme: 'exact',
+ network: accept.network,
+ resource: { url: endpoint, mimeType: 'application/json' },
+ accepted: accept,
+ payload: { signature: signed.signature, authorization: typedData.message },
+ };
+ const echo = builderCodeEcho(challenge);
+ if (echo) paymentPayload.extensions = { 'builder-code': echo };
+ emit({ stage: 'submitting' });
+
+ const paidRes = await fetch(endpoint, {
+ method,
+ headers: {
+ accept: 'application/json',
+ 'x-payment': Buffer.from(JSON.stringify(paymentPayload), 'utf8').toString('base64'),
+ ...(body ? { 'content-type': 'application/json' } : {}),
+ },
+ body: body ? JSON.stringify(body) : undefined,
+ });
+ const resultText = await paidRes.text();
+ let result = null;
+ try {
+ result = JSON.parse(resultText);
+ } catch {
+ result = { raw: resultText.slice(0, 1000) };
+ }
+ if (!paidRes.ok) {
+ throw new Error(
+ `payment rejected by endpoint (HTTP ${paidRes.status}): ${result?.error?.message || result?.error || resultText.slice(0, 300)}`,
+ );
+ }
+ let settlement = null;
+ const settleHeader = paidRes.headers.get('x-payment-response');
+ if (settleHeader) {
+ try {
+ settlement = JSON.parse(Buffer.from(settleHeader, 'base64').toString('utf8'));
+ } catch {
+ settlement = null;
+ }
+ }
+ emit({
+ stage: 'done',
+ amount: accept.amount,
+ payer: payerAddress,
+ payTo: accept.payTo,
+ settlement,
+ result,
+ });
+}
+
+// ── HTTP server ───────────────────────────────────────────────────────────
+
+function readBody(req) {
+ return new Promise((resolvePromise, reject) => {
+ let data = '';
+ req.on('data', (c) => {
+ data += c;
+ if (data.length > 64 * 1024) reject(new Error('request body too large'));
+ });
+ req.on('end', () => resolvePromise(data));
+ req.on('error', reject);
+ });
+}
+
+function sendJson(res, status, obj) {
+ res.writeHead(status, { 'content-type': 'application/json; charset=utf-8' });
+ res.end(JSON.stringify(obj));
+}
+
+const server = createServer(async (req, res) => {
+ const origin = req.headers.origin;
+ if (origin && corsOriginAllowed(origin)) {
+ res.setHeader('access-control-allow-origin', origin);
+ res.setHeader('vary', 'origin');
+ res.setHeader('access-control-allow-methods', 'GET,POST,OPTIONS');
+ res.setHeader('access-control-allow-headers', 'content-type');
+ }
+ if (req.method === 'OPTIONS') {
+ res.writeHead(204);
+ return res.end();
+ }
+
+ const url = new URL(req.url, `http://localhost:${PORT}`);
+ try {
+ if (req.method === 'GET' && url.pathname === '/status') {
+ return sendJson(res, 200, await walletStatus());
+ }
+
+ if (req.method === 'GET' && url.pathname === '/quote') {
+ const endpoint = url.searchParams.get('endpoint') || '';
+ const method = (url.searchParams.get('method') || 'POST').toUpperCase();
+ if (!endpointAllowed(endpoint)) {
+ return sendJson(res, 400, { ok: false, error: `endpoint origin not allowed (allowed: ${ALLOWED_ENDPOINT_ORIGINS.join(', ')})` });
+ }
+ const bodyParam = url.searchParams.get('body');
+ const probeBody = bodyParam ? JSON.parse(bodyParam) : undefined;
+ const { challenge, accept } = await fetch402(endpoint, method, probeBody);
+ return sendJson(res, 200, {
+ ok: true,
+ amount: accept.amount,
+ payTo: accept.payTo,
+ asset: accept.asset,
+ network: accept.network,
+ maxTimeoutSeconds: accept.maxTimeoutSeconds,
+ resource: challenge.resource || null,
+ domainName: accept.extra?.name || 'USD Coin',
+ });
+ }
+
+ if (req.method === 'POST' && url.pathname === '/pay') {
+ const raw = await readBody(req);
+ let parsed;
+ try {
+ parsed = JSON.parse(raw || '{}');
+ } catch {
+ return sendJson(res, 400, { ok: false, error: 'invalid JSON body' });
+ }
+ const endpoint = String(parsed.endpoint || '');
+ const method = String(parsed.method || 'POST').toUpperCase();
+ if (!['GET', 'POST'].includes(method)) {
+ return sendJson(res, 400, { ok: false, error: 'method must be GET or POST' });
+ }
+ if (!endpointAllowed(endpoint)) {
+ return sendJson(res, 400, { ok: false, error: `endpoint origin not allowed (allowed: ${ALLOWED_ENDPOINT_ORIGINS.join(', ')})` });
+ }
+ res.writeHead(200, {
+ 'content-type': 'text/event-stream; charset=utf-8',
+ 'cache-control': 'no-store',
+ connection: 'keep-alive',
+ });
+ let lastStage = 'challenge';
+ const emit = (evt) => {
+ lastStage = evt.stage || lastStage;
+ res.write(`data: ${JSON.stringify(evt)}\n\n`);
+ };
+ try {
+ await executePayment({ endpoint, method, body: parsed.body, emit });
+ } catch (err) {
+ emit({ stage: 'error', failedStage: lastStage, message: err.message });
+ }
+ return res.end();
+ }
+
+ sendJson(res, 404, { ok: false, error: 'not found' });
+ } catch (err) {
+ if (!res.headersSent) sendJson(res, 500, { ok: false, error: err.message });
+ else res.end();
+ }
+});
+
+server.listen(PORT, '127.0.0.1', () => {
+ console.log(`mm-x402 bridge listening on http://127.0.0.1:${PORT}`);
+ console.log(` allowed endpoint origins: ${ALLOWED_ENDPOINT_ORIGINS.join(', ')}`);
+ console.log(` per-payment cap: ${fmtUsdc(MAX_USDC_MICROS.toString())} USDC`);
+ walletStatus()
+ .then((s) => console.log(` agent wallet: ${s.wallet.address} (${s.wallet.mode} mode, balance $${s.balance.totalValue})`))
+ .catch((e) => console.warn(` wallet status unavailable: ${e.message} — run \`mm login\``));
+});
diff --git a/snapshots/current/desktop/forge.jpg b/snapshots/current/desktop/forge.jpg
new file mode 100644
index 000000000..a371b1b3c
Binary files /dev/null and b/snapshots/current/desktop/forge.jpg differ
diff --git a/snapshots/current/desktop/ibm.jpg b/snapshots/current/desktop/ibm.jpg
deleted file mode 100644
index a7353e9d4..000000000
Binary files a/snapshots/current/desktop/ibm.jpg and /dev/null differ
diff --git a/snapshots/current/desktop/segment.jpg b/snapshots/current/desktop/segment.jpg
new file mode 100644
index 000000000..5fc7560e6
Binary files /dev/null and b/snapshots/current/desktop/segment.jpg differ
diff --git a/snapshots/current/index.html b/snapshots/current/index.html
index 09be4e8cb..61566aeed 100644
--- a/snapshots/current/index.html
+++ b/snapshots/current/index.html
@@ -3,7 +3,7 @@
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
-<title>three.ws — site snapshot 2026-06-05</title>
+<title>three.ws — site snapshot 2026-06-11</title>
<style>
:root { --bg:#0a0a0b; --panel:#141416; --line:#26262b; --fg:#f4f4f5; --mut:#9a9aa3; --accent:#e8e8ea; }
* { box-sizing: border-box; }
@@ -43,7 +43,7 @@
</header>
<main id="main"></main>
<script>
-const DATA = {"capturedAt":"2026-06-05T08:31:41.751Z","date":"2026-06-05","baseUrl":"https://three.ws","viewports":["desktop"],"pages":[{"path":"/","title":"/","section":"Selected","slug":"home","shots":{}},{"path":"/ibm","title":"/ibm","section":"Selected","slug":"ibm","shots":{"desktop":{"bytes":700364,"navStatus":200}}},{"path":"/pay","title":"/pay","section":"Selected","slug":"pay","shots":{}},{"path":"/three-live","title":"/three-live","section":"Selected","slug":"three-live","shots":{}},{"path":"/docs","title":"/docs","section":"Selected","slug":"docs","shots":{}}]};
+const DATA = {"capturedAt":"2026-06-11T23:12:49.165Z","date":"2026-06-11","baseUrl":"http://localhost:3457","viewports":["desktop"],"pages":[{"path":"/forge","title":"/forge","section":"Selected","slug":"forge","shots":{"desktop":{"bytes":144849,"navStatus":200}}},{"path":"/segment","title":"/segment","section":"Selected","slug":"segment","shots":{"desktop":{"bytes":123456,"navStatus":200}}}]};
let viewport = DATA.viewports.includes('desktop') ? 'desktop' : 'mobile';
let query = '';
const main = document.getElementById('main');
diff --git a/snapshots/current/manifest.json b/snapshots/current/manifest.json
index 28d9ccb85..0c45c7881 100644
--- a/snapshots/current/manifest.json
+++ b/snapshots/current/manifest.json
@@ -1,52 +1,36 @@
{
- "capturedAt": "2026-06-05T08:31:41.751Z",
- "date": "2026-06-05",
- "baseUrl": "https://three.ws",
+ "capturedAt": "2026-06-11T23:12:49.165Z",
+ "date": "2026-06-11",
+ "baseUrl": "http://localhost:3457",
"viewports": [
"desktop"
],
- "pageCount": 5,
- "capturedCount": 1,
+ "pageCount": 2,
+ "capturedCount": 2,
"pages": [
{
- "path": "/",
- "title": "/",
+ "path": "/forge",
+ "title": "/forge",
"section": "Selected",
- "slug": "home",
- "shots": {}
- },
- {
- "path": "/ibm",
- "title": "/ibm",
- "section": "Selected",
- "slug": "ibm",
+ "slug": "forge",
"shots": {
"desktop": {
- "bytes": 700364,
+ "bytes": 144849,
"navStatus": 200
}
}
},
{
- "path": "/pay",
- "title": "/pay",
- "section": "Selected",
- "slug": "pay",
- "shots": {}
- },
- {
- "path": "/three-live",
- "title": "/three-live",
- "section": "Selected",
- "slug": "three-live",
- "shots": {}
- },
- {
- "path": "/docs",
- "title": "/docs",
+ "path": "/segment",
+ "title": "/segment",
"section": "Selected",
- "slug": "docs",
- "shots": {}
+ "slug": "segment",
+ "shots": {
+ "desktop": {
+ "bytes": 123456,
+ "navStatus": 200
+ }
+ }
}
]
}
\ No newline at end of file
diff --git a/src/marketplace-detail.js b/src/marketplace-detail.js
index e13d8030d..fb2d5b405 100644
--- a/src/marketplace-detail.js
+++ b/src/marketplace-detail.js
@@ -12,6 +12,7 @@
import { onchainBadgeHTML } from './shared/onchain-badge.js';
import { coinChipHTML } from './shared/agent-coin.js';
+import { agentAvatarGlb, hasCustomAvatar, seeInWorldHref } from './shared/agent-3d.js';
import { log } from './shared/log.js';
const API = '/api';
@@ -78,6 +79,194 @@ export function renderDetailAvatar(a) {
}
}
+// ── Detail 3D model stage ───────────────────────────────────────────────
+//
+// A full-width interactive viewer at the top of the Overview tab: orbit +
+// zoom camera controls, load progress, fullscreen, "open in world", and a
+// GLB download when the agent ships its own model. Agents without a custom
+// GLB stand on the base mannequin (see shared/agent-3d.js) so the stage is
+// never a dead hole — the hint copy says exactly which one you're looking at.
+
+let stageVisibilityObserver = null;
+let stageFullscreenBound = false;
+
+// R2's public bucket only allows the three.ws origin — in dev (localhost /
+// Codespaces) GLB fetches fail CORS, so route them through Vite's /r2-proxy
+// (same workaround as avatar-drop.js). No-op in production.
+function resolveStageGlb(url) {
+ if (!url) return url;
+ const isDev =
+ location.hostname === 'localhost' ||
+ location.hostname.includes('.github.dev') ||
+ location.hostname.includes('.gitpod.io');
+ if (isDev && url.includes('r2.dev')) {
+ try {
+ return '/r2-proxy' + new URL(url).pathname;
+ } catch {
+ /* malformed URL — use as-is */
+ }
+ }
+ return url;
+}
+
+export function renderDetailModelStage(a) {
+ const card = $('d-model-card');
+ const stage = $('d-model-stage');
+ if (!card || !stage) return;
+
+ const glbUrl = agentAvatarGlb(a);
+ const custom = hasCustomAvatar(a);
+
+ if (stageVisibilityObserver) {
+ stageVisibilityObserver.disconnect();
+ stageVisibilityObserver = null;
+ }
+ stage.innerHTML = '';
+
+ const hint = $('d-model-hint');
+ if (hint) {
+ hint.textContent = custom
+ ? 'Drag to orbit · scroll to zoom'
+ : 'Base avatar — fork this agent to attach a custom model';
+ }
+
+ const mv = document.createElement('model-viewer');
+ mv.setAttribute('src', resolveStageGlb(glbUrl));
+ mv.setAttribute('alt', `${a.name || 'Agent'} — 3D model`);
+ mv.setAttribute('camera-controls', '');
+ mv.setAttribute('auto-rotate', '');
+ mv.setAttribute('rotation-per-second', '18deg');
+ mv.setAttribute('interaction-prompt', 'when-focused');
+ mv.setAttribute('autoplay', '');
+ mv.setAttribute('exposure', '1.05');
+ mv.setAttribute('shadow-intensity', '0.7');
+ mv.setAttribute('tone-mapping', 'aces');
+ if (custom && a.thumbnail_url) mv.setAttribute('poster', a.thumbnail_url);
+ mv.style.cssText = 'opacity:0;transition:opacity .3s ease;';
+ stage.appendChild(mv);
+
+ const progressEl = Object.assign(document.createElement('div'), {
+ className: 'modal-load-progress',
+ });
+ progressEl.innerHTML =
+ '<div class="modal-load-bar-wrap"><div class="modal-load-bar"></div></div><span class="modal-load-label">Loading 3D…</span>';
+ stage.insertBefore(progressEl, mv);
+ const bar = progressEl.querySelector('.modal-load-bar');
+ mv.addEventListener('progress', (e) => {
+ if (bar) bar.style.width = Math.round((e.detail?.totalProgress || 0) * 100) + '%';
+ });
+ const loadTimeout = setTimeout(() => {
+ const label = progressEl.querySelector('.modal-load-label');
+ if (label) label.textContent = 'Still loading — large model or slow connection.';
+ }, 15_000);
+ mv.addEventListener(
+ 'load',
+ () => {
+ clearTimeout(loadTimeout);
+ progressEl.remove();
+ mv.style.opacity = '1';
+ },
+ { once: true },
+ );
+ mv.addEventListener(
+ 'error',
+ () => {
+ clearTimeout(loadTimeout);
+ const label = progressEl.querySelector('.modal-load-label');
+ if (label) label.textContent = "Couldn't load the 3D model.";
+ const wrap = progressEl.querySelector('.modal-load-bar-wrap');
+ if (wrap) wrap.remove();
+ },
+ { once: true },
+ );
+
+ // Suspend auto-rotate while the stage is off-screen so model-viewer halts
+ // its rAF loop (same trick the marketplace grid cards use).
+ if ('IntersectionObserver' in window) {
+ stageVisibilityObserver = new IntersectionObserver(
+ (entries) => {
+ for (const entry of entries) {
+ if (entry.isIntersecting) mv.setAttribute('auto-rotate', '');
+ else mv.removeAttribute('auto-rotate');
+ }
+ },
+ { rootMargin: '100px' },
+ );
+ stageVisibilityObserver.observe(stage);
+ }
+
+ // Actions.
+ const world = $('d-model-world');
+ if (world) world.href = seeInWorldHref(a);
+
+ const dl = $('d-model-download');
+ if (dl) {
+ if (custom) {
+ dl.href = glbUrl;
+ dl.download = `${(a.name || 'agent').toLowerCase().replace(/[^a-z0-9]+/g, '-').replace(/^-|-$/g, '') || 'agent'}.glb`;
+ dl.hidden = false;
+ } else {
+ dl.hidden = true;
+ }
+ }
+
+ // Fullscreen the whole card (not just the stage) so the action row — and
+ // the exit button — stays on screen.
+ const fsBtn = $('d-model-fullscreen');
+ if (fsBtn) {
+ if (!card.requestFullscreen) {
+ // iOS Safari has no element fullscreen — hide rather than dead-end.
+ fsBtn.hidden = true;
+ } else {
+ fsBtn.hidden = false;
+ fsBtn.onclick = () => {
+ if (document.fullscreenElement === card) document.exitFullscreen();
+ else card.requestFullscreen().catch(() => {});
+ };
+ if (!stageFullscreenBound) {
+ stageFullscreenBound = true;
+ document.addEventListener('fullscreenchange', () => {
+ const on = document.fullscreenElement === $('d-model-card');
+ const btn = $('d-model-fullscreen');
+ if (btn) {
+ btn.textContent = on ? '✕ Exit fullscreen' : '⛶ Fullscreen';
+ btn.setAttribute(
+ 'aria-label',
+ on ? 'Exit fullscreen' : 'View 3D model fullscreen',
+ );
+ }
+ });
+ }
+ }
+ }
+
+ // The small header avatar doubles as a shortcut to the stage.
+ const headAvatar = $('d-avatar');
+ if (headAvatar && headAvatar.dataset.stageWired !== '1') {
+ headAvatar.dataset.stageWired = '1';
+ headAvatar.setAttribute('role', 'button');
+ headAvatar.setAttribute('tabindex', '0');
+ headAvatar.setAttribute('aria-label', 'Jump to 3D model viewer');
+ headAvatar.title = 'View 3D model';
+ const jump = () => {
+ const target = $('d-model-card');
+ if (!target) return;
+ // The stage lives on the Overview tab — switch to it if needed.
+ document.querySelector('.market-tabs [data-tab="overview"]')?.click();
+ target.scrollIntoView({ behavior: 'smooth', block: 'center' });
+ target.classList.remove('flash');
+ requestAnimationFrame(() => target.classList.add('flash'));
+ };
+ headAvatar.addEventListener('click', jump);
+ headAvatar.addEventListener('keydown', (e) => {
+ if (e.key === 'Enter' || e.key === ' ') {
+ e.preventDefault();
+ jump();
+ }
+ });
+ }
+}
+
// ── Live chat preview on detail page ────────────────────────────────────
const previewState = {
diff --git a/src/marketplace.js b/src/marketplace.js
index 76ae7267f..cdef935b3 100644
--- a/src/marketplace.js
+++ b/src/marketplace.js
@@ -9,6 +9,7 @@
import {
renderDetailAvatar,
+ renderDetailModelStage,
startPreviewSession,
submitPreviewMessage,
openCreatorModal,
@@ -4377,6 +4378,7 @@ function renderDetail(a, bookmarked) {
const forks = a.forks_count ?? a.forks ?? 0;
$('d-name').textContent = a.name || 'Untitled';
renderDetailAvatar(a);
+ renderDetailModelStage(a);
const authorBtn = $('d-author');
authorBtn.textContent = author;
diff --git a/src/play-agent-wallet.js b/src/play-agent-wallet.js
new file mode 100644
index 000000000..9756d18a0
--- /dev/null
+++ b/src/play-agent-wallet.js
@@ -0,0 +1,692 @@
+// /play/agent-wallet — your avatar pays for a real x402 endpoint with the
+// MetaMask agent wallet, visualized in 3D.
+//
+// The scene: your /play avatar (localStorage `cc-avatar`, same contract as the
+// coin-communities world) stands on a plaza with a paid-endpoint kiosk and a
+// big stage board. Press Pay and the avatar walks to the kiosk while the
+// MetaMask Agentic CLI — reached through the local bridge in
+// scripts/mm-x402-bridge.mjs — signs a USDC TransferWithAuthorization and the
+// endpoint settles it on Base mainnet. Every stage the bridge streams
+// (402 → sign → submit → settled) animates the board, the kiosk, and the
+// side panel in lockstep. No mocks: the $0.01 leaves the wallet for real.
+
+import {
+ Scene, PerspectiveCamera, WebGLRenderer, Group, Clock, Color, FogExp2,
+ HemisphereLight, DirectionalLight, Mesh, MeshStandardMaterial, MeshBasicMaterial,
+ CircleGeometry, BoxGeometry, PlaneGeometry, RingGeometry, CylinderGeometry,
+ CanvasTexture, SRGBColorSpace, DoubleSide, GridHelper, Vector3, MathUtils,
+ ACESFilmicToneMapping, PCFSoftShadowMap,
+} from 'three';
+import { OrbitControls } from 'three/addons/controls/OrbitControls.js';
+import {
+ buildAvatar, resolveAvatarUrl, loadManifest, getEmoteDefs, playEmoteClip,
+ newAnim, CLIP_IDLE, CLIP_WALK,
+} from './game/avatar-rig.js';
+import { CC_AVATAR_KEY } from './game/play-handoff.js';
+
+// ── config ──────────────────────────────────────────────────────────────────
+
+const params = new URLSearchParams(location.search);
+const BRIDGE_URL = (params.get('bridge') || 'http://127.0.0.1:4402').replace(/\/$/, '');
+// The paid endpoint the avatar buys from. three.ws prod by default so the
+// payment settles against the live facilitator even from local dev.
+const ENDPOINT = params.get('endpoint') || 'https://three.ws/api/x402/crypto-intel';
+const TOPICS = [
+ { id: 'bitcoin', label: 'BTC' },
+ { id: 'ethereum', label: 'ETH' },
+ { id: 'solana', label: 'SOL' },
+];
+
+const COL = {
+ bg0: '#0a0a0c', bg1: '#15151a',
+ text: '#f5f5f6', dim: '#8c8c92', faint: '#5a5a60',
+ mm: '#f6851b', mmLt: '#ffa04d',
+ good: '#5fd08a', bad: '#e06c75',
+ line: 'rgba(255,255,255,0.07)',
+};
+
+const STAGES = [
+ { id: 'walk', label: 'Avatar walks to the endpoint' },
+ { id: 'challenge', label: '402 challenge received' },
+ { id: 'signing', label: 'MetaMask agent wallet signs' },
+ { id: 'submitting', label: 'Submit + settle on Base' },
+ { id: 'done', label: 'Confirmed on-chain' },
+];
+const BOARD_STEPS = [
+ { id: 'walk', label: 'Walk' },
+ { id: 'challenge', label: '402' },
+ { id: 'signing', label: 'Sign' },
+ { id: 'submitting', label: 'Settle' },
+ { id: 'done', label: 'Paid' },
+];
+
+function fmtUsdc(micros) {
+ const n = Number(micros);
+ return '$' + (isFinite(n) && n > 0 ? (n / 1e6).toFixed(2) : '0.00');
+}
+function shortAddr(a) {
+ const s = String(a || '');
+ return s.length > 11 ? `${s.slice(0, 6)}…${s.slice(-4)}` : s || '—';
+}
+function shortTx(tx) {
+ const s = String(tx || '');
+ return s.length > 16 ? `${s.slice(0, 8)}…${s.slice(-6)}` : s;
+}
+
+// ── 3D scene ────────────────────────────────────────────────────────────────
+
+const stageEl = document.getElementById('stage3d');
+const scene = new Scene();
+scene.background = new Color(COL.bg0);
+scene.fog = new FogExp2(0x0a0a0c, 0.055);
+
+const camera = new PerspectiveCamera(46, 1, 0.1, 80);
+camera.position.set(-1.6, 2.5, 6.4);
+
+const renderer = new WebGLRenderer({ antialias: true, powerPreference: 'high-performance' });
+renderer.setPixelRatio(Math.min(devicePixelRatio, 2));
+renderer.shadowMap.enabled = true;
+renderer.shadowMap.type = PCFSoftShadowMap;
+renderer.toneMapping = ACESFilmicToneMapping;
+stageEl.appendChild(renderer.domElement);
+
+const controls = new OrbitControls(camera, renderer.domElement);
+controls.target.set(0.6, 1.0, 0);
+controls.enableDamping = true;
+controls.dampingFactor = 0.08;
+controls.minDistance = 2.5;
+controls.maxDistance = 14;
+controls.maxPolarAngle = Math.PI * 0.495;
+let hintFaded = false;
+controls.addEventListener('start', () => {
+ if (!hintFaded) { hintFaded = true; document.getElementById('sceneHint').classList.add('fade'); }
+});
+
+scene.add(new HemisphereLight(0x9aa6c0, 0x101014, 1.1));
+const sun = new DirectionalLight(0xfff2e0, 2.2);
+sun.position.set(5, 8, 4);
+sun.castShadow = true;
+sun.shadow.mapSize.set(2048, 2048);
+sun.shadow.camera.left = -8; sun.shadow.camera.right = 8;
+sun.shadow.camera.top = 8; sun.shadow.camera.bottom = -8;
+scene.add(sun);
+
+const ground = new Mesh(
+ new CircleGeometry(16, 56),
+ new MeshStandardMaterial({ color: 0x121215, roughness: 0.95, metalness: 0 }),
+);
+ground.rotation.x = -Math.PI / 2;
+ground.receiveShadow = true;
+scene.add(ground);
+const grid = new GridHelper(32, 64, 0x26262c, 0x1b1b20);
+grid.position.y = 0.002;
+scene.add(grid);
+
+// ── kiosk: the paid endpoint, physically in the world ───────────────────────
+
+const KIOSK_POS = new Vector3(2.4, 0, 0);
+const kiosk = new Group();
+kiosk.position.copy(KIOSK_POS);
+kiosk.rotation.y = -Math.PI / 2.6; // face the avatar spawn
+scene.add(kiosk);
+
+const kioskMat = new MeshStandardMaterial({ color: 0x17171b, roughness: 0.35, metalness: 0.7 });
+const pedestal = new Mesh(new BoxGeometry(0.85, 1.05, 0.4), kioskMat);
+pedestal.position.y = 0.525;
+pedestal.castShadow = true;
+kiosk.add(pedestal);
+
+const kioskCanvas = document.createElement('canvas');
+kioskCanvas.width = 512; kioskCanvas.height = 320;
+const kioskCtx = kioskCanvas.getContext('2d');
+const kioskTex = new CanvasTexture(kioskCanvas);
+kioskTex.colorSpace = SRGBColorSpace;
+const kioskScreen = new Mesh(
+ new PlaneGeometry(1.0, 0.625),
+ new MeshBasicMaterial({ map: kioskTex, toneMapped: false }),
+);
+kioskScreen.position.set(0, 1.38, 0.06);
+kioskScreen.rotation.x = -0.16;
+kiosk.add(kioskScreen);
+const kioskBezel = new Mesh(new BoxGeometry(1.08, 0.71, 0.05), kioskMat);
+kioskBezel.position.set(0, 1.38, 0.02);
+kioskBezel.rotation.x = -0.16;
+kioskBezel.castShadow = true;
+kiosk.add(kioskBezel);
+
+// pay ring on the floor — pulses MetaMask orange while a payment runs
+const payRing = new Mesh(
+ new RingGeometry(0.62, 0.72, 48),
+ new MeshBasicMaterial({ color: COL.mm, transparent: true, opacity: 0.25, side: DoubleSide }),
+);
+payRing.rotation.x = -Math.PI / 2;
+payRing.position.set(KIOSK_POS.x - 0.9, 0.01, KIOSK_POS.z + 0.55);
+scene.add(payRing);
+
+// antenna mast — kiosks broadcast that they're paid x402 services
+const mast = new Mesh(new CylinderGeometry(0.02, 0.02, 0.5, 8), kioskMat);
+mast.position.set(0.34, 1.95, 0);
+kiosk.add(mast);
+const beacon = new Mesh(new CylinderGeometry(0.05, 0.05, 0.07, 10), new MeshBasicMaterial({ color: COL.mm }));
+beacon.position.set(0.34, 2.22, 0);
+kiosk.add(beacon);
+
+// ── stage board: the big screen narrating the payment ───────────────────────
+
+const BOARD_W = 6, BOARD_CW = 1280, BOARD_CH = 640;
+const board = new Group();
+board.position.set(2.2, 0, -3.4);
+board.rotation.y = -0.12;
+scene.add(board);
+const boardH = (BOARD_W * BOARD_CH) / BOARD_CW;
+const postMat = new MeshStandardMaterial({ color: 0x141417, roughness: 0.5, metalness: 0.6 });
+for (const sx of [-BOARD_W / 2 + 0.5, BOARD_W / 2 - 0.5]) {
+ const post = new Mesh(new CylinderGeometry(0.09, 0.12, 2.2 + boardH, 12), postMat);
+ post.position.set(sx, (2.2 + boardH) / 2, -0.08);
+ post.castShadow = true;
+ board.add(post);
+}
+const boardBezel = new Mesh(new BoxGeometry(BOARD_W + 0.3, boardH + 0.3, 0.22), new MeshStandardMaterial({ color: 0x050506, roughness: 0.4, metalness: 0.7 }));
+boardBezel.position.set(0, 2.2 + boardH / 2, -0.1);
+boardBezel.castShadow = true;
+board.add(boardBezel);
+const boardCanvas = document.createElement('canvas');
+boardCanvas.width = BOARD_CW; boardCanvas.height = BOARD_CH;
+const boardCtx = boardCanvas.getContext('2d');
+const boardTex = new CanvasTexture(boardCanvas);
+boardTex.colorSpace = SRGBColorSpace;
+boardTex.anisotropy = 4;
+const boardPanel = new Mesh(
+ new PlaneGeometry(BOARD_W, boardH),
+ new MeshBasicMaterial({ map: boardTex, toneMapped: false }),
+);
+boardPanel.position.set(0, 2.2 + boardH / 2, 0.02);
+board.add(boardPanel);
+
+// ── avatar ──────────────────────────────────────────────────────────────────
+
+const SPAWN = new Vector3(-2.7, 0, 1.4);
+const PAY_SPOT = new Vector3(KIOSK_POS.x - 0.9, 0, KIOSK_POS.z + 0.55);
+const rig = new Group();
+rig.position.copy(SPAWN);
+scene.add(rig);
+const anim = newAnim();
+let avatarReady = false;
+(async () => {
+ loadManifest();
+ const saved = localStorage.getItem(CC_AVATAR_KEY) || params.get('avatar') || '';
+ const url = await resolveAvatarUrl(params.get('avatar') || saved);
+ await buildAvatar(rig, url, anim);
+ rig.lookAt(KIOSK_POS.x, 0, KIOSK_POS.z);
+ avatarReady = true;
+})();
+
+// walking state machine: idle | toKiosk | toSpawn
+let motion = 'idle';
+let walkResolve = null;
+const WALK_SPEED = 1.35;
+function walkTo(target) {
+ return new Promise((res) => {
+ walkResolve = res;
+ motion = target === PAY_SPOT ? 'toKiosk' : 'toSpawn';
+ anim.crossfadeTo(CLIP_WALK, 0.22);
+ });
+}
+function tickWalk(dt) {
+ if (motion === 'idle') return;
+ const target = motion === 'toKiosk' ? PAY_SPOT : SPAWN;
+ const dx = target.x - rig.position.x;
+ const dz = target.z - rig.position.z;
+ const dist = Math.hypot(dx, dz);
+ if (dist < 0.06) {
+ motion = 'idle';
+ anim.crossfadeTo(CLIP_IDLE, 0.25);
+ rig.lookAt(KIOSK_POS.x, 0, KIOSK_POS.z);
+ const r = walkResolve; walkResolve = null;
+ if (r) r();
+ return;
+ }
+ const step = Math.min(dist, WALK_SPEED * dt);
+ rig.position.x += (dx / dist) * step;
+ rig.position.z += (dz / dist) * step;
+ const targetYaw = Math.atan2(dx, dz);
+ rig.rotation.y += MathUtils.degToRad(MathUtils.radToDeg(targetYaw - rig.rotation.y + Math.PI) % 360 - 180) * Math.min(1, dt * 10);
+}
+
+// ── canvas painting ─────────────────────────────────────────────────────────
+
+// live state shared by board + kiosk + panel
+const live = {
+ bridge: 'connecting', // connecting | online | offline
+ wallet: null, // { address, mode }
+ balanceUsd: null,
+ quote: null, // parsed /quote payload
+ stage: null, // active stage id while paying
+ stageText: '',
+ receipt: null, // { amount, payer, payTo, tx, result }
+ error: null, // { stage, message }
+ paying: false,
+ sessionTotal: 0,
+};
+let t = 0;
+
+function roundRect(ctx, x, y, w, h, r) {
+ ctx.beginPath();
+ ctx.moveTo(x + r, y);
+ ctx.arcTo(x + w, y, x + w, y + h, r);
+ ctx.arcTo(x + w, y + h, x, y + h, r);
+ ctx.arcTo(x, y + h, x, y, r);
+ ctx.arcTo(x, y, x + w, y, r);
+ ctx.closePath();
+}
+
+function drawKiosk() {
+ const c = kioskCtx, W = kioskCanvas.width, H = kioskCanvas.height;
+ const g = c.createLinearGradient(0, 0, 0, H);
+ g.addColorStop(0, COL.bg1); g.addColorStop(1, COL.bg0);
+ c.fillStyle = g; c.fillRect(0, 0, W, H);
+ c.strokeStyle = COL.line; c.strokeRect(1, 1, W - 2, H - 2);
+ c.textAlign = 'left'; c.fillStyle = COL.faint;
+ c.font = '700 22px Inter, system-ui, sans-serif';
+ c.fillText('x402 PAID ENDPOINT', 28, 48);
+ c.fillStyle = COL.text; c.font = '800 36px Inter, system-ui, sans-serif';
+ c.fillText(live.quote?.resource?.serviceName || 'crypto-intel', 28, 100);
+ c.fillStyle = COL.dim; c.font = '600 24px Inter, system-ui, sans-serif';
+ c.fillText('POST /api/x402/crypto-intel', 28, 140);
+ const price = live.quote ? fmtUsdc(live.quote.amount) : '…';
+ c.fillStyle = COL.good; c.font = '800 52px Inter, system-ui, sans-serif';
+ c.fillText(`${price} USDC`, 28, 220);
+ c.fillStyle = COL.faint; c.font = '600 22px Inter, system-ui, sans-serif';
+ const pulse = 0.5 + 0.5 * Math.sin(t * 3);
+ if (live.paying) {
+ c.fillStyle = `rgba(246,133,27,${0.5 + pulse * 0.5})`;
+ c.fillText('● PAYMENT IN PROGRESS', 28, 280);
+ } else if (live.receipt) {
+ c.fillStyle = COL.good;
+ c.fillText('✓ PAID — THANK YOU', 28, 280);
+ } else {
+ c.fillText('AWAITING PAYMENT · BASE MAINNET', 28, 280);
+ }
+ kioskTex.needsUpdate = true;
+}
+
+function drawBoard() {
+ const c = boardCtx, W = BOARD_CW, H = BOARD_CH, padX = 48;
+ const g = c.createLinearGradient(0, 0, 0, H);
+ g.addColorStop(0, COL.bg1); g.addColorStop(1, COL.bg0);
+ c.fillStyle = g; c.fillRect(0, 0, W, H);
+
+ // header
+ c.textAlign = 'left';
+ c.fillStyle = COL.mm; c.font = '800 34px Inter, system-ui, sans-serif';
+ c.fillText('METAMASK AGENT WALLET', padX, 62);
+ c.fillStyle = COL.dim; c.font = '600 19px Inter, system-ui, sans-serif';
+ c.fillText('x402 MICROPAYMENTS · USDC ON BASE MAINNET (eip155:8453)', padX, 92);
+ // wallet chip (top-right)
+ c.textAlign = 'right';
+ c.fillStyle = COL.text; c.font = '700 22px ui-monospace, Menlo, monospace';
+ c.fillText(shortAddr(live.wallet?.address), W - padX, 58);
+ c.fillStyle = COL.faint; c.font = '600 17px Inter, system-ui, sans-serif';
+ c.fillText(
+ live.bridge === 'online' ? `balance $${live.balanceUsd ?? '—'} · ${live.wallet?.mode || ''} wallet`
+ : live.bridge === 'offline' ? 'bridge offline' : 'connecting…',
+ W - padX, 86,
+ );
+ c.textAlign = 'left';
+ c.strokeStyle = COL.line; c.beginPath(); c.moveTo(padX, 116); c.lineTo(W - padX, 116); c.stroke();
+
+ // hero zone
+ const heroY = 178;
+ if (live.bridge === 'offline') {
+ c.fillStyle = COL.bad; c.font = '800 38px Inter, system-ui, sans-serif';
+ c.fillText('Bridge offline', padX, heroY);
+ c.fillStyle = COL.dim; c.font = '600 24px Inter, system-ui, sans-serif';
+ c.fillText('Run `npm run demo:agent-wallet-bridge` in the repo, then retry.', padX, heroY + 42);
+ } else if (live.error) {
+ c.fillStyle = COL.bad; c.font = '800 38px Inter, system-ui, sans-serif';
+ c.fillText('✕ Payment failed — no funds moved', padX, heroY);
+ c.fillStyle = COL.dim; c.font = '600 23px Inter, system-ui, sans-serif';
+ c.fillText(String(live.error.message || '').slice(0, 88), padX, heroY + 42);
+ } else if (live.paying) {
+ c.fillStyle = COL.text; c.font = '800 40px Inter, system-ui, sans-serif';
+ c.fillText(`Paying ${live.quote ? fmtUsdc(live.quote.amount) : ''} USDC for live crypto intel`, padX, heroY);
+ c.fillStyle = COL.mmLt; c.font = '600 25px Inter, system-ui, sans-serif';
+ c.fillText(live.stageText || 'Working…', padX, heroY + 44);
+ } else if (live.receipt) {
+ c.fillStyle = COL.good; c.font = '800 40px Inter, system-ui, sans-serif';
+ c.fillText(`✓ ${fmtUsdc(live.receipt.amount)} USDC settled on Base`, padX, heroY);
+ c.fillStyle = COL.dim; c.font = '600 23px ui-monospace, Menlo, monospace';
+ const txLine = live.receipt.tx ? `tx ${shortTx(live.receipt.tx)}` : 'settlement confirmed';
+ c.fillText(`${shortAddr(live.receipt.payer)} → ${shortAddr(live.receipt.payTo)} · ${txLine}`, padX, heroY + 42);
+ } else {
+ c.fillStyle = COL.text; c.font = '800 40px Inter, system-ui, sans-serif';
+ c.fillText('Your avatar. Your agent wallet. A real paid API.', padX, heroY);
+ c.fillStyle = COL.dim; c.font = '600 25px Inter, system-ui, sans-serif';
+ c.fillText('Press “Send avatar to pay” — the MetaMask CLI signs, Base settles.', padX, heroY + 44);
+ }
+
+ // stepper
+ const sy = 300;
+ const activeIdx = live.stage ? BOARD_STEPS.findIndex((s) => s.id === live.stage) : -1;
+ const colW = (W - padX * 2) / BOARD_STEPS.length;
+ const pulse = 0.5 + 0.5 * Math.sin(t * 4);
+ BOARD_STEPS.forEach((s, i) => {
+ const x = padX + colW * i;
+ const done = (activeIdx >= 0 && i < activeIdx) || (live.receipt && !live.paying);
+ const isActive = i === activeIdx && live.paying;
+ const errHere = live.error && i === activeIdx;
+ roundRect(c, x, sy, colW - 26, 6, 3);
+ c.fillStyle = errHere ? COL.bad
+ : done ? COL.mm
+ : isActive ? `rgba(246,133,27,${0.35 + pulse * 0.6})`
+ : 'rgba(255,255,255,0.1)';
+ c.fill();
+ c.fillStyle = errHere ? COL.bad : done ? COL.text : isActive ? COL.mmLt : COL.faint;
+ c.font = '700 19px Inter, system-ui, sans-serif';
+ c.fillText(s.label.toUpperCase(), x, sy + 38);
+ });
+
+ // result zone — the thing the avatar actually bought
+ c.strokeStyle = COL.line; c.beginPath(); c.moveTo(padX, 392); c.lineTo(W - padX, 392); c.stroke();
+ c.fillStyle = COL.faint; c.font = '700 18px Inter, system-ui, sans-serif';
+ c.fillText('PURCHASED INTEL', padX, 432);
+ if (live.sessionTotal > 0) {
+ c.textAlign = 'right';
+ c.fillStyle = COL.dim;
+ c.fillText(`$${live.sessionTotal.toFixed(2)} paid this session`, W - padX, 432);
+ c.textAlign = 'left';
+ }
+ const r = live.receipt?.result;
+ if (r && r.headline) {
+ const sigCol = r.signal === 'bullish' ? COL.good : r.signal === 'bearish' ? COL.bad : '#f5a623';
+ c.fillStyle = sigCol; c.font = '800 26px Inter, system-ui, sans-serif';
+ c.fillText((r.signal || '').toUpperCase(), padX, 482);
+ c.fillStyle = COL.text; c.font = '700 30px Inter, system-ui, sans-serif';
+ c.fillText(String(r.headline).slice(0, 70), padX, 524);
+ c.fillStyle = COL.dim; c.font = '600 22px Inter, system-ui, sans-serif';
+ c.fillText(String(r.rationale || '').slice(0, 95), padX, 560);
+ } else {
+ c.fillStyle = COL.faint; c.font = '600 24px Inter, system-ui, sans-serif';
+ c.fillText('Nothing purchased yet — the API response lands here after settlement.', padX, 488);
+ }
+ boardTex.needsUpdate = true;
+}
+
+// ── render loop ─────────────────────────────────────────────────────────────
+
+const clock = new Clock();
+let redrawAcc = 0;
+function resize() {
+ const w = stageEl.clientWidth, h = stageEl.clientHeight;
+ renderer.setSize(w, h, false);
+ camera.aspect = w / h;
+ camera.updateProjectionMatrix();
+}
+new ResizeObserver(resize).observe(stageEl);
+resize();
+
+renderer.setAnimationLoop(() => {
+ const dt = Math.min(clock.getDelta(), 0.1);
+ t += dt;
+ if (avatarReady) { tickWalk(dt); anim.update(dt); }
+ payRing.material.opacity = live.paying ? 0.35 + 0.3 * Math.sin(t * 5) : 0.18;
+ beacon.material.color.set(live.paying ? COL.mmLt : live.bridge === 'offline' ? '#5a5a60' : COL.mm);
+ redrawAcc += dt;
+ if (redrawAcc > 0.1) { redrawAcc = 0; drawBoard(); drawKiosk(); }
+ controls.update();
+ renderer.render(scene, camera);
+});
+
+// ── side panel wiring ───────────────────────────────────────────────────────
+
+const $ = (id) => document.getElementById(id);
+const payBtn = $('payBtn');
+const stagesEl = $('stages');
+let activeTopic = TOPICS[0].id;
+
+for (const topic of TOPICS) {
+ const b = document.createElement('button');
+ b.type = 'button';
+ b.className = 't-chip' + (topic.id === activeTopic ? ' active' : '');
+ b.textContent = topic.label;
+ b.setAttribute('aria-pressed', String(topic.id === activeTopic));
+ b.addEventListener('click', () => {
+ activeTopic = topic.id;
+ for (const el of document.querySelectorAll('.t-chip')) {
+ const on = el === b;
+ el.classList.toggle('active', on);
+ el.setAttribute('aria-pressed', String(on));
+ }
+ });
+ $('topics').appendChild(b);
+}
+
+function renderStages() {
+ stagesEl.innerHTML = '';
+ const activeIdx = live.stage ? STAGES.findIndex((s) => s.id === live.stage) : -1;
+ STAGES.forEach((s, i) => {
+ const row = document.createElement('div');
+ const done = (activeIdx >= 0 && i < activeIdx) || (live.receipt && !live.paying && !live.error);
+ const isActive = i === activeIdx && live.paying;
+ const errHere = live.error && live.error.stage === s.id;
+ row.className = 'stage' + (errHere ? ' error' : done ? ' done' : isActive ? ' active' : '');
+ row.innerHTML = `<span class="si"></span><span>${s.label}</span><span class="sd"></span>`;
+ if (s.id === 'signing' && live.wallet?.address) row.querySelector('.sd').textContent = shortAddr(live.wallet.address);
+ if (s.id === 'done' && live.receipt?.tx) row.querySelector('.sd').textContent = shortTx(live.receipt.tx);
+ stagesEl.appendChild(row);
+ });
+}
+renderStages();
+
+function renderError() {
+ const el = $('flowError');
+ if (!live.error) { el.classList.remove('show'); return; }
+ el.innerHTML = `<div class="b-head">Payment failed — no funds moved</div>${escapeHtml(live.error.message)}`;
+ el.classList.add('show');
+}
+function escapeHtml(s) {
+ return String(s || '').replace(/[&<>"']/g, (ch) => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;' }[ch]));
+}
+
+function renderReceipt() {
+ const el = $('receipt');
+ const r = live.receipt;
+ if (!r) { el.classList.remove('show'); return; }
+ const res = r.result || {};
+ const sigClass = res.signal === 'bullish' ? 'signal-bullish' : res.signal === 'bearish' ? 'signal-bearish' : 'signal-neutral';
+ el.innerHTML = `
+ <div class="r-head">
+ <span class="r-badge">✓ Settled on Base</span>
+ <span class="r-amt">${fmtUsdc(r.amount)} USDC</span>
+ </div>
+ <div class="rf"><span class="k">From (agent wallet)</span><span class="v">${shortAddr(r.payer)}</span></div>
+ <div class="rf"><span class="k">To (endpoint)</span><span class="v">${shortAddr(r.payTo)}</span></div>
+ ${r.tx ? `<div class="rf"><span class="k">Transaction</span><span class="v"><a href="https://basescan.org/tx/${encodeURIComponent(r.tx)}" target="_blank" rel="noopener">${shortTx(r.tx)} ↗</a></span></div>` : ''}
+ ${res.headline ? `<div class="r-payload"><span class="r-signal ${sigClass}">${escapeHtml((res.signal || '').toUpperCase())}</span>${escapeHtml(res.headline)}${res.rationale ? `<div style="color:var(--muted);font-size:12.5px;margin-top:4px">${escapeHtml(res.rationale)}</div>` : ''}</div>` : ''}
+ `;
+ el.classList.add('show');
+}
+
+function updatePayButton() {
+ const lbl = payBtn.querySelector('.lbl');
+ if (live.paying) {
+ payBtn.disabled = true;
+ payBtn.classList.add('busy');
+ lbl.textContent = live.stageText || 'Paying…';
+ return;
+ }
+ payBtn.classList.remove('busy');
+ if (live.bridge !== 'online') {
+ payBtn.disabled = true;
+ lbl.textContent = live.bridge === 'offline' ? 'Bridge offline' : 'Connecting to bridge…';
+ return;
+ }
+ payBtn.disabled = false;
+ lbl.textContent = `Send avatar to pay — ${live.quote ? fmtUsdc(live.quote.amount) : '$0.01'} USDC`;
+}
+
+// ── bridge client ───────────────────────────────────────────────────────────
+
+async function refreshStatus() {
+ try {
+ const r = await fetch(`${BRIDGE_URL}/status`, { signal: AbortSignal.timeout(4000) });
+ if (!r.ok) throw new Error('HTTP ' + r.status);
+ const data = await r.json();
+ live.bridge = 'online';
+ live.wallet = data.wallet;
+ live.balanceUsd = data.balance?.totalValue ?? null;
+ $('wAddr').textContent = shortAddr(data.wallet.address);
+ $('wAddr').title = data.wallet.address;
+ $('wMode').textContent = `${data.wallet.mode} wallet`;
+ $('wBal').innerHTML = `$${escapeHtml(Number(data.balance?.totalValue || 0).toFixed(2))}<small>USD</small>`;
+ $('bridgeOffline').classList.remove('show');
+ const lowBal = Number(data.balance?.totalValue || 0) <= 0;
+ $('lowBalance').classList.toggle('show', lowBal && !live.receipt);
+ } catch {
+ live.bridge = 'offline';
+ $('bridgeOffline').classList.add('show');
+ $('lowBalance').classList.remove('show');
+ $('wBal').innerHTML = '—<small>USD</small>';
+ }
+ updatePayButton();
+ renderStages();
+}
+
+async function loadQuote() {
+ try {
+ const qs = new URLSearchParams({ endpoint: ENDPOINT, method: 'POST', body: JSON.stringify({ topic: activeTopic }) });
+ const r = await fetch(`${BRIDGE_URL}/quote?${qs}`, { signal: AbortSignal.timeout(8000) });
+ if (!r.ok) throw new Error('HTTP ' + r.status);
+ const q = await r.json();
+ if (!q.ok) throw new Error(q.error || 'quote failed');
+ live.quote = q;
+ $('epName').textContent = q.resource?.serviceName || 'three.ws Crypto Intel';
+ $('epPrice').textContent = `${fmtUsdc(q.amount)} USDC`;
+ $('epDesc').textContent = q.resource?.description
+ ? String(q.resource.description).split('. ').slice(0, 2).join('. ') + '.'
+ : 'Pay-per-call market signal, settled in USDC on Base mainnet.';
+ const tags = $('epTags');
+ tags.innerHTML = '';
+ for (const tag of [`pay to ${shortAddr(q.payTo)}`, 'Base mainnet', 'EIP-3009 USDC', ...(q.resource?.tags || []).slice(0, 2)]) {
+ const el = document.createElement('span');
+ el.className = 'ep-tag';
+ el.textContent = tag;
+ tags.appendChild(el);
+ }
+ } catch {
+ // quote requires the bridge; the bridge-offline banner already explains
+ $('epName').textContent = 'three.ws Crypto Intel';
+ $('epPrice').textContent = '$0.01 USDC';
+ $('epDesc').textContent = 'Live market signal (bullish / bearish / neutral) — pay per call, settled in USDC on Base mainnet.';
+ }
+ updatePayButton();
+}
+
+async function pay() {
+ if (live.paying || live.bridge !== 'online') return;
+ live.paying = true;
+ live.error = null;
+ live.receipt = null;
+ live.stage = 'walk';
+ live.stageText = 'Avatar walking to the endpoint…';
+ renderError(); renderReceipt(); renderStages(); updatePayButton();
+
+ // the walk is part of the show — arrive, then start the real payment
+ await walkTo(PAY_SPOT);
+
+ try {
+ const res = await fetch(`${BRIDGE_URL}/pay`, {
+ method: 'POST',
+ headers: { 'content-type': 'application/json', accept: 'text/event-stream' },
+ body: JSON.stringify({ endpoint: ENDPOINT, method: 'POST', body: { topic: activeTopic } }),
+ });
+ if (!res.ok || !res.body) throw new Error(`bridge /pay failed: HTTP ${res.status}`);
+ const reader = res.body.getReader();
+ const decoder = new TextDecoder();
+ let buf = '';
+ for (;;) {
+ const { done, value } = await reader.read();
+ if (done) break;
+ buf += decoder.decode(value, { stream: true });
+ const lines = buf.split('\n');
+ buf = lines.pop() || '';
+ for (const line of lines) {
+ if (!line.startsWith('data:')) continue;
+ let evt;
+ try { evt = JSON.parse(line.slice(5)); } catch { continue; }
+ handleStageEvent(evt);
+ }
+ }
+ if (live.paying && !live.receipt && !live.error) {
+ throw new Error('payment stream ended without a settlement');
+ }
+ } catch (err) {
+ live.error = { stage: live.stage || 'challenge', message: err.message };
+ } finally {
+ live.paying = false;
+ }
+ renderError(); renderReceipt(); renderStages(); updatePayButton();
+ refreshStatus();
+
+ // celebrate a settle, then amble home either way
+ if (live.receipt && avatarReady) {
+ const emote = getEmoteDefs()[0];
+ if (emote) await playEmoteClip(anim, emote.name, 'idle');
+ await new Promise((r) => setTimeout(r, 1800));
+ }
+ await walkTo(SPAWN);
+}
+
+function handleStageEvent(evt) {
+ switch (evt.stage) {
+ case 'challenge':
+ live.stage = 'challenge';
+ live.stageText = `402 challenge: ${fmtUsdc(evt.amount)} USDC to ${shortAddr(evt.payTo)}`;
+ break;
+ case 'signing':
+ live.stage = 'signing';
+ live.stageText = `MetaMask signing TransferWithAuthorization (${evt.domain?.name || 'USD Coin'})…`;
+ break;
+ case 'signed':
+ live.stage = 'submitting';
+ live.stageText = 'Signature ready — submitting X-PAYMENT…';
+ break;
+ case 'submitting':
+ live.stage = 'submitting';
+ live.stageText = 'Endpoint verifying + settling via facilitator…';
+ break;
+ case 'done': {
+ live.stage = 'done';
+ live.stageText = 'Settled on Base mainnet';
+ live.receipt = {
+ amount: evt.amount,
+ payer: evt.payer,
+ payTo: evt.payTo,
+ tx: evt.settlement?.transaction || null,
+ result: evt.result || null,
+ };
+ live.sessionTotal += Number(evt.amount) / 1e6 || 0;
+ break;
+ }
+ case 'error':
+ live.error = { stage: evt.failedStage === 'done' ? 'submitting' : evt.failedStage || 'challenge', message: evt.message };
+ break;
+ }
+ renderStages();
+ updatePayButton();
+}
+
+payBtn.addEventListener('click', pay);
+$('retryBridge').addEventListener('click', () => { refreshStatus().then(loadQuote); });
+$('copyAddr').addEventListener('click', async () => {
+ const full = $('wAddr').title;
+ if (!full) return;
+ try {
+ await navigator.clipboard.writeText(full);
+ $('copyAddr').textContent = 'copied';
+ setTimeout(() => { $('copyAddr').textContent = 'copy'; }, 1200);
+ } catch { /* clipboard unavailable */ }
+});
+
+refreshStatus().then(loadQuote);
+setInterval(refreshStatus, 30_000);
diff --git a/vercel.json b/vercel.json
index b6c4ad3ee..c0e2b5a23 100644
--- a/vercel.json
+++ b/vercel.json
@@ -567,6 +567,10 @@
"src": "/city/?",
"dest": "/city.html"
},
+ {
+ "src": "/play/agent-wallet/?",
+ "dest": "/play/agent-wallet.html"
+ },
{
"src": "/play/?",
"dest": "/play.html"
diff --git a/vite.config.js b/vite.config.js
index 8ea2266a3..1001392ef 100644
--- a/vite.config.js
+++ b/vite.config.js
@@ -355,6 +355,7 @@ const appConfig = {
'walk-embed': resolve(__dirname, 'pages/walk-embed.html'),
city: resolve(__dirname, 'pages/city.html'),
play: resolve(__dirname, 'pages/play.html'),
+ 'play-agent-wallet': resolve(__dirname, 'pages/play/agent-wallet.html'),
pose: resolve(__dirname, 'pages/pose.html'),
club: resolve(__dirname, 'pages/club.html'),
skills: resolve(__dirname, 'pages/skills.html'),
@@ -674,6 +675,8 @@ const appConfig = {
'/walk/': resolve(root, 'pages/walk.html'),
'/play': resolve(root, 'pages/play.html'),
'/play/': resolve(root, 'pages/play.html'),
+ '/play/agent-wallet': resolve(root, 'pages/play/agent-wallet.html'),
+ '/play/agent-wallet/': resolve(root, 'pages/play/agent-wallet.html'),
'/walk-embed': resolve(root, 'pages/walk-embed.html'),
'/walk-embed/': resolve(root, 'pages/walk-embed.html'),
'/demo': resolve(root, 'pages/demo-economy.html'),