Open-source platform for 3D AI agents. Turn text or a photo into a rigged, animated GLB avatar, give it an LLM brain, memory and a wallet, and embed it anywhere with one web component. Remote MCP server, x402 payments, Three.js, browser-native.
JavaScript 3d-generationai-agentsanimationavatardigital-humangenerative-aiglbgltfimage-to-3dllmmcpmcp-servermodel-context-protocolsolanatext-to-3dthreejsweb-componentswebglwebxrx402
feat(console): put a live 3D agent inside a handheld console anyone can embed
nirholasd0ee51ff19a8
diff --git a/pages/console.html b/pages/console.htmlnew file mode 100644index 000000000..6439fb947--- /dev/null+++ b/pages/console.html@@ -0,0 +1,244 @@+<!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.0" />+ <title>Agent Console · three.ws</title>+ <meta+ name="description"+ content="A handheld console with a real 3D agent living inside the screen. Steer it with the D-pad, swap the cartridge for any public three.ws agent, pick a shell, and drop the whole console onto your own site with one line of HTML."+ />+ <meta name="theme-color" content="#0a0a0a" />+ <link rel="canonical" href="https://three.ws/console" />+ <link rel="icon" href="/favicon.ico" sizes="any" />+ <link rel="icon" type="image/svg+xml" href="/favicon.svg" />+ <link rel="apple-touch-icon" href="/apple-touch-icon.png" />+ <link rel="manifest" href="/manifest.webmanifest" />+ <link rel="stylesheet" href="/fonts/fonts.css" />+ <link rel="stylesheet" href="/style.css" />+ <link rel="stylesheet" href="/nav.css" />+ <link rel="stylesheet" href="/src/console.css" />+ <link rel="stylesheet" href="/footer.css" />+ <script defer src="/footer-newsletter.js"></script>++ <meta name="robots" content="index, follow, max-image-preview:large, max-snippet:-1" />+ <meta property="og:type" content="website" />+ <meta property="og:site_name" content="three.ws" />+ <meta property="og:locale" content="en_US" />+ <meta property="og:title" content="Agent Console · three.ws" />+ <meta+ property="og:description"+ content="A handheld console with a real 3D agent walking inside the screen. D-pad steers it, cartridges swap the agent, one line of HTML puts it on your site."+ />+ <meta property="og:url" content="https://three.ws/console" />+ <meta+ property="og:image"+ content="https://three.ws/api/page-og?s=labs&t=Agent+Console&d=A+handheld+console+with+a+real+3D+agent+walking+inside+the+screen.+D-pad+steers+it%2C+cartridges+swap+the+agent%2C+one+line+of+HTML+puts+it+on+your+site&p=%2Fconsole"+ />+ <meta property="og:image:width" content="1200" />+ <meta property="og:image:height" content="630" />+ <meta property="og:image:type" content="image/png" />+ <meta property="og:image:alt" content="Agent Console - three.ws" />+ <meta name="twitter:card" content="summary_large_image" />+ <meta name="twitter:site" content="@trythreews" />+ <meta name="twitter:title" content="Agent Console · three.ws" />+ <meta+ name="twitter:description"+ content="A handheld console with a real 3D agent walking inside the screen. D-pad steers it, cartridges swap the agent, one line of HTML puts it on your site."+ />+ <meta+ name="twitter:image"+ content="https://three.ws/api/page-og?s=labs&t=Agent+Console&d=A+handheld+console+with+a+real+3D+agent+walking+inside+the+screen.+D-pad+steers+it%2C+cartridges+swap+the+agent%2C+one+line+of+HTML+puts+it+on+your+site&p=%2Fconsole"+ />+ </head>+ <body>+ <script>/* embed mode (?chrome=off) is the device and nothing else: the site nav, footer, walk companion, tour and language pill all belong to three.ws, not to the page hosting this iframe. Decided here, before any of them load. */(function(){try{if(new URLSearchParams(location.search).get('chrome')==='off'){document.body.dataset.chrome='off';document.body.setAttribute('data-no-lang-switcher','');}}catch(e){}})();</script>+ <header><div id="nav-container"></div></header>++ <main class="cn-shell">+ <div class="cn-top">+ <section class="cn-hero">+ <p class="cn-kicker"><span class="cn-dot" aria-hidden="true"></span> Live 3D · not a mockup</p>+ <h1 class="cn-title">Your agent, <em>in a handheld</em></h1>+ <p class="cn-sub">+ Everyone is drawing portfolios inside pretend consoles. This one boots. There is a+ real 3D agent walking around inside the screen, the D-pad actually steers it, the+ cartridges are live agents anyone on three.ws built, and one line of HTML drops the+ whole thing onto your own site.+ </p>+ <div class="cn-ctas">+ <a class="cn-btn cn-btn-primary" href="/create">Build your own agent</a>+ <button type="button" class="cn-btn" id="cn-share">Copy share link</button>+ <button type="button" class="cn-btn" id="cn-post">Post on X</button>+ </div>+ </section>++ <section class="cn-stage" aria-label="Agent console">+ <div class="cn-device" id="cn-device" data-shell="graphite" data-power="on">+ <div class="cn-shoulders">+ <button type="button" class="cn-shoulder" id="cn-l" aria-label="Previous agent">L</button>+ <button type="button" class="cn-shoulder" id="cn-r" aria-label="Next agent">R</button>+ </div>++ <div class="cn-brandbar">+ <span class="cn-brand-name">three.ws</span>+ <span id="cn-model-line">pocket agent</span>+ </div>++ <div class="cn-bezel">+ <span class="cn-power-led" aria-hidden="true"></span>+ <span class="cn-power-label" aria-hidden="true">power</span>++ <div class="cn-screen">+ <div class="cn-screen-view">+ <div class="cn-cart" id="cn-cart-play" data-cart="play"></div>++ <section class="cn-panel" id="cn-cart-stats" data-cart="stats" aria-label="Agent stats">+ <div class="cn-panel-head">+ <span>Stats</span><span id="cn-stats-id">--</span>+ </div>+ <div class="cn-panel-body">+ <dl id="cn-stats-list"></dl>+ <p class="cn-panel-note" id="cn-stats-note"></p>+ </div>+ </section>++ <section class="cn-panel" id="cn-cart-select" data-cart="select" aria-label="Select an agent">+ <div class="cn-panel-head">+ <span>Select agent</span><span id="cn-select-count">--</span>+ </div>+ <div class="cn-panel-body">+ <div id="cn-roster" role="listbox" aria-label="Public agents"></div>+ </div>+ </section>+ </div>++ <div class="cn-boot" id="cn-boot">+ <span id="cn-boot-text">Booting agent</span>+ <span class="cn-boot-bar" aria-hidden="true"><span class="cn-boot-fill"></span></span>+ <button type="button" class="cn-boot-retry" id="cn-boot-retry" hidden>Retry</button>+ </div>++ <div class="cn-glass" aria-hidden="true"></div>++ <div class="cn-hud" aria-hidden="true">+ <span class="cn-hud-name" id="cn-hud-name">loading</span>+ <span class="cn-hud-cart" id="cn-hud-cart">play</span>+ </div>+ </div>+ </div>++ <div class="cn-deck">+ <div class="cn-dpad" role="group" aria-label="Direction pad">+ <span class="cn-dpad-plate" aria-hidden="true"></span>+ <span class="cn-dpad-hub" aria-hidden="true"></span>+ <button type="button" class="cn-dir" data-dir="up" aria-label="Walk forward">▲</button>+ <button type="button" class="cn-dir" data-dir="left" aria-label="Walk left">◀</button>+ <button type="button" class="cn-dir" data-dir="right" aria-label="Walk right">▶</button>+ <button type="button" class="cn-dir" data-dir="down" aria-label="Walk back">▼</button>+ </div>++ <div></div>++ <div class="cn-face">+ <button type="button" class="cn-face-btn" data-btn="b" aria-label="B button: jump">B<small>jump</small></button>+ <button type="button" class="cn-face-btn" data-btn="a" aria-label="A button: wave">A<small>wave</small></button>+ </div>+ </div>++ <div class="cn-menu">+ <button type="button" class="cn-menu-btn" data-btn="select" aria-label="Select: change scene">select</button>+ <button type="button" class="cn-menu-btn" data-btn="start" aria-label="Start: change cartridge">start</button>+ </div>++ <div class="cn-speaker" aria-hidden="true">+ <span></span><span></span><span></span><span></span><span></span><span></span>+ </div>++ <span class="cn-gamepad-pill" id="cn-gamepad">controller live</span>+ </div>+ </section>++ <div class="cn-tools">+ <div class="cn-tool-group" role="group" aria-label="Shell colour">+ <span class="cn-tool-label">Shell</span>+ <button type="button" class="cn-tab" data-shell="graphite" aria-pressed="true">+ <span class="cn-swatch" style="background: #34363c" aria-hidden="true"></span>Graphite+ </button>+ <button type="button" class="cn-tab" data-shell="bone" aria-pressed="false">+ <span class="cn-swatch" style="background: #e0dcd2" aria-hidden="true"></span>Bone+ </button>+ <button type="button" class="cn-tab" data-shell="clear" aria-pressed="false">+ <span class="cn-swatch" style="background: #98a0b8" aria-hidden="true"></span>Clear+ </button>+ <button type="button" class="cn-tab" data-shell="indigo" aria-pressed="false">+ <span class="cn-swatch" style="background: #3b3568" aria-hidden="true"></span>Indigo+ </button>+ </div>++ <div class="cn-tool-group" role="group" aria-label="Cartridge">+ <span class="cn-tool-label">Cartridge</span>+ <button type="button" class="cn-tab" data-cart="play" aria-pressed="true">Play</button>+ <button type="button" class="cn-tab" data-cart="stats" aria-pressed="false">Stats</button>+ <button type="button" class="cn-tab" data-cart="select" aria-pressed="false">Select</button>+ </div>++ <div class="cn-tool-group" role="group" aria-label="Scene">+ <span class="cn-tool-label">Scene</span>+ <button type="button" class="cn-tab" data-env="night" aria-pressed="true">Night</button>+ <button type="button" class="cn-tab" data-env="studio" aria-pressed="false">Studio</button>+ <button type="button" class="cn-tab" data-env="sunset" aria-pressed="false">Sunset</button>+ <button type="button" class="cn-tab" data-env="grid" aria-pressed="false">Grid</button>+ </div>+ </div>++ </div>++ <section class="cn-rail" aria-labelledby="cn-rail-title">+ <div class="cn-rail-head">+ <h2 class="cn-rail-title" id="cn-rail-title">Cartridges</h2>+ <p class="cn-rail-hint">Every agent here is real and public. Slot one in, or press L / R on the console.</p>+ </div>+ <div class="cn-carts" id="cn-carts" aria-busy="true"></div>+ </section>++ <div class="cn-panels">+ <section class="cn-card">+ <h2>Put this console on your site</h2>+ <p>+ One iframe. It carries the agent you have loaded right now, boots its 3D body, and+ runs on any origin. No SDK, no build step, no API key.+ </p>+ <code class="cn-code" id="cn-embed-code"></code>+ <button type="button" class="cn-btn" id="cn-copy-embed">Copy embed code</button>+ </section>++ <section class="cn-card">+ <h2>Controls</h2>+ <p>+ Keyboard, touch and a real gamepad all drive the same console. Plug a controller in+ and the D-pad on screen lights up with it.+ </p>+ <div class="cn-keys">+ <div><span>Walk</span> <kbd>W A S D</kbd></div>+ <div><span>Run</span> <kbd>Shift</kbd></div>+ <div><span>Wave</span> <kbd>K</kbd></div>+ <div><span>Jump</span> <kbd>J</kbd></div>+ <div><span>Change cartridge</span> <kbd>Enter</kbd></div>+ <div><span>Change scene</span> <kbd>Space</kbd></div>+ <div><span>Previous / next agent</span> <kbd>Q</kbd> <kbd>E</kbd></div>+ <div><span>Power</span> <kbd>P</kbd></div>+ </div>+ </section>+ </div>+ </main>++ <div class="cn-toast" id="cn-toast" role="status"></div>+ <div id="cn-live" class="sr-only" role="status" aria-live="polite"></div>++ <script type="module" src="/src/console.js"></script>+ <div id="footer-container"></div>+ <script>/* Site chrome loads only outside embed mode. Same files, same order as every other page; an embedded console just never asks for them. */(function(){if(document.body.dataset.chrome==='off')return;for(const src of ['/nav.js','/footer.js']){const s=document.createElement('script');s.src=src;document.body.appendChild(s);}const b=document.createElement('script');b.src='/brand.js';b.defer=true;document.body.appendChild(b);const i=document.createElement('script');i.type='module';i.src='/i18n.js';document.body.appendChild(i);})();</script>+ </body>+</html>diff --git a/pages/walk-embed.html b/pages/walk-embed.htmlindex 37010ba42..2d3b58ea1 100644--- a/pages/walk-embed.html+++ b/pages/walk-embed.html@@ -246,7 +246,7 @@}</style></head>- <body>+ <body data-no-lang-switcher><div id="walk-stage" data-controls="joystick"><canvasid="walk-canvas"diff --git a/src/console.css b/src/console.cssnew file mode 100644index 000000000..40e4767e3--- /dev/null+++ b/src/console.css@@ -0,0 +1,1227 @@+/* Agent Console (/console) — a real handheld with a live 3D agent in the screen.++ Every page-chrome value comes from public/tokens.css. The device itself is+ physical media, not a page surface: its shell colours, plastics and button+ faces are declared per shell theme below (--sh-*), the same way the site's+ scrim tokens sit outside the theme system. Nothing here is decorative-only:+ the tilt, the glare and the scanlines are what make a screenshot of this page+ read as an object somebody is holding.++ Internal device geometry is expressed in `em` against .cn-device's own+ font-size, so one clamp() scales the whole handheld from a 320px phone to a+ 1440px desktop without a media query per part. */++.cn-shell {+ max-width: 1180px;+ margin: 0 auto;+ padding: var(--space-lg, 26px) var(--space-lg, 26px) var(--space-2xl, 68px);+}++.sr-only {+ position: absolute;+ width: 1px;+ height: 1px;+ padding: 0;+ margin: -1px;+ overflow: hidden;+ clip: rect(0 0 0 0);+ white-space: nowrap;+ border: 0;+}++/* ── top block ────────────────────────────────────────────────────────────+ Narrow: pitch, then the device, then its settings. Wide: the device takes+ its own column so the whole handheld is visible without scrolling, which is+ the entire point of the page. */++.cn-top {+ display: grid;+ gap: var(--space-md, 16px);+}++@media (min-width: 1040px) {+ .cn-top {+ grid-template-columns: minmax(410px, 460px) 1fr;+ grid-template-areas:+ 'stage hero'+ 'stage tools';+ align-content: center;+ gap: var(--space-lg, 26px) var(--space-2xl, 68px);+ padding-top: var(--space-lg, 26px);+ }++ .cn-hero {+ grid-area: hero;+ text-align: left;+ margin: 0;+ align-self: end;+ }++ .cn-stage {+ grid-area: stage;+ }++ .cn-tools {+ grid-area: tools;+ justify-content: flex-start;+ align-self: start;+ margin: 0;+ }++ .cn-ctas {+ justify-content: flex-start;+ }++ .cn-sub {+ margin: 0;+ }++ .cn-title {+ font-size: var(--text-2xl, 42px);+ }+}++/* ── hero ─────────────────────────────────────────────────────────────── */++.cn-hero {+ text-align: center;+ max-width: 46rem;+ margin: 0 auto var(--space-md, 16px);+}++.cn-kicker {+ display: inline-flex;+ align-items: center;+ gap: var(--space-sm, 10px);+ margin: 0 0 var(--space-sm, 10px);+ font-family: var(--font-mono);+ font-size: var(--text-2xs, 11px);+ letter-spacing: 0.14em;+ text-transform: uppercase;+ color: var(--ink-dim, #888);+}++.cn-dot {+ width: 6px;+ height: 6px;+ border-radius: var(--radius-pill, 999px);+ background: var(--success, #4ade80);+ box-shadow: 0 0 0 3px color-mix(in srgb, var(--success, #4ade80) 22%, transparent);+}++.cn-title {+ margin: 0 0 var(--space-md, 16px);+ font-family: var(--font-display);+ font-size: var(--text-2xl, 42px);+ line-height: var(--leading-tight, 1.15);+ letter-spacing: -0.025em;+ font-weight: var(--weight-bold, 700);+ color: var(--ink-bright, #fff);+}++.cn-title em {+ font-style: normal;+ color: var(--ink-dim, #888);+}++.cn-sub {+ margin: 0 auto;+ max-width: 40rem;+ font-size: var(--text-base, 16px);+ line-height: var(--leading-normal, 1.618);+ color: var(--ink-dim, #888);+}++/* ── generic controls ─────────────────────────────────────────────────── */++.cn-btn {+ appearance: none;+ display: inline-flex;+ align-items: center;+ gap: var(--space-xs, 7px);+ padding: 0.62em 1.05em;+ border-radius: var(--radius-md, 10px);+ border: 1px solid var(--stroke-strong, rgba(255, 255, 255, 0.14));+ background: var(--surface-2, rgba(255, 255, 255, 0.05));+ color: var(--ink, #e8e8e8);+ font-family: var(--font-body);+ font-size: var(--text-ui, 14px);+ font-weight: var(--weight-medium, 500);+ line-height: 1;+ cursor: pointer;+ transition:+ background 0.18s ease,+ border-color 0.18s ease,+ transform 0.12s ease,+ color 0.18s ease;+}++.cn-btn:hover {+ background: var(--surface-3, rgba(255, 255, 255, 0.08));+ border-color: var(--accent, #fff);+ color: var(--ink-bright, #fff);+}++.cn-btn:active {+ transform: translateY(1px);+}++.cn-btn:focus-visible,+.cn-chip:focus-visible,+.cn-key:focus-visible,+.cn-tab:focus-visible {+ outline: 2px solid var(--accent, #fff);+ outline-offset: 2px;+}++.cn-btn-primary {+ background: var(--accent, #fff);+ border-color: var(--accent, #fff);+ color: #0a0a0b;+}++.cn-btn-primary:hover {+ background: var(--ink-bright, #fff);+ color: #0a0a0b;+ filter: brightness(0.92);+}++.cn-ctas {+ display: flex;+ flex-wrap: wrap;+ gap: var(--space-sm, 10px);+ justify-content: center;+ margin-top: var(--space-lg, 26px);+}++/* ── stage + device ───────────────────────────────────────────────────── */++.cn-stage {+ display: flex;+ justify-content: center;+ perspective: 1600px;+ padding: var(--space-md, 16px) 0;+}++.cn-device {+ /* One knob scales the entire handheld: the device is 34em wide, so the+ type size is whatever keeps those 34em inside the viewport (less the+ page gutter), capped at the size the desktop column is built for. */+ font-size: clamp(7.5px, calc((100vw - 3.4rem) / 34), 12px);+ position: relative;+ width: 34em;+ padding: 1.35em 1.6em 1.8em;+ border-radius: 2.4em 2.4em 3.6em 2.4em;+ background: var(--sh-body);+ box-shadow:+ inset 0 0.14em 0 var(--sh-hi),+ inset 0 -0.5em 0.9em var(--sh-lo),+ inset 0.14em 0 0 var(--sh-edge),+ inset -0.14em 0 0 var(--sh-edge),+ 0 2.4em 4em rgba(0, 0, 0, 0.55),+ 0 0.5em 1.2em rgba(0, 0, 0, 0.4);+ transform-style: preserve-3d;+ transition: transform 0.5s cubic-bezier(0.22, 1, 0.36, 1);+ will-change: transform;+ user-select: none;+ -webkit-tap-highlight-color: transparent;+}++/* Shell themes. Physical plastic, not page surfaces — so these are literals. */+.cn-device[data-shell='graphite'] {+ --sh-body: linear-gradient(168deg, #34363c 0%, #26282d 44%, #1a1c20 100%);+ --sh-hi: rgba(255, 255, 255, 0.16);+ --sh-lo: rgba(0, 0, 0, 0.55);+ --sh-edge: rgba(255, 255, 255, 0.05);+ --sh-ink: rgba(255, 255, 255, 0.42);+ --sh-ink-strong: rgba(255, 255, 255, 0.72);+ --sh-bezel: linear-gradient(165deg, #16181c, #0c0d10);+ --sh-btn: linear-gradient(160deg, #4c4f57, #2c2e34);+ --sh-btn-ink: rgba(255, 255, 255, 0.78);+ --sh-accent: #d8d8dc;+}++.cn-device[data-shell='bone'] {+ --sh-body: linear-gradient(168deg, #e9e6dd 0%, #dcd8cd 46%, #c3bfb4 100%);+ --sh-hi: rgba(255, 255, 255, 0.85);+ --sh-lo: rgba(90, 84, 70, 0.35);+ --sh-edge: rgba(255, 255, 255, 0.4);+ --sh-ink: rgba(60, 56, 48, 0.55);+ --sh-ink-strong: rgba(40, 37, 31, 0.85);+ --sh-bezel: linear-gradient(165deg, #56534b, #2f2d29);+ --sh-btn: linear-gradient(160deg, #b9b4a7, #97927f);+ --sh-btn-ink: rgba(38, 35, 29, 0.8);+ --sh-accent: #6b6558;+}++.cn-device[data-shell='clear'] {+ --sh-body: linear-gradient(168deg, rgba(150, 158, 178, 0.5) 0%, rgba(96, 104, 128, 0.42) 48%, rgba(52, 58, 78, 0.6) 100%);+ --sh-hi: rgba(255, 255, 255, 0.5);+ --sh-lo: rgba(6, 8, 16, 0.55);+ --sh-edge: rgba(255, 255, 255, 0.22);+ --sh-ink: rgba(255, 255, 255, 0.55);+ --sh-ink-strong: rgba(255, 255, 255, 0.9);+ --sh-bezel: linear-gradient(165deg, #1a1e2b, #0b0d14);+ --sh-btn: linear-gradient(160deg, rgba(210, 216, 232, 0.72), rgba(126, 136, 166, 0.6));+ --sh-btn-ink: rgba(20, 24, 36, 0.8);+ --sh-accent: #e6e9f4;+ backdrop-filter: blur(2px);+}++.cn-device[data-shell='indigo'] {+ --sh-body: linear-gradient(168deg, #3b3568 0%, #2b2650 46%, #1a1733 100%);+ --sh-hi: rgba(255, 255, 255, 0.18);+ --sh-lo: rgba(0, 0, 0, 0.6);+ --sh-edge: rgba(255, 255, 255, 0.07);+ --sh-ink: rgba(226, 222, 255, 0.45);+ --sh-ink-strong: rgba(238, 235, 255, 0.85);+ --sh-bezel: linear-gradient(165deg, #14122a, #09081a);+ --sh-btn: linear-gradient(160deg, #6a5fae, #3d3672);+ --sh-btn-ink: rgba(255, 255, 255, 0.86);+ --sh-accent: #c9c2ff;+}++/* Shoulder buttons sit behind the shell's top edge. */+.cn-shoulders {+ position: absolute;+ left: 1.6em;+ right: 1.6em;+ top: -1.05em;+ display: flex;+ justify-content: space-between;+ z-index: 0;+}++.cn-shoulder {+ appearance: none;+ width: 7.4em;+ height: 1.9em;+ padding: 0 0 0.5em;+ border: 0;+ border-radius: 1em 1em 0 0;+ background: var(--sh-btn);+ color: var(--sh-btn-ink);+ font-family: var(--font-mono);+ font-size: 0.72em;+ letter-spacing: 0.16em;+ cursor: pointer;+ box-shadow: inset 0 0.12em 0 var(--sh-hi);+ transition:+ transform 0.1s ease,+ filter 0.16s ease;+}++.cn-shoulder:hover {+ filter: brightness(1.14);+}++.cn-shoulder:active,+.cn-shoulder[data-held='1'] {+ transform: translateY(0.3em);+ filter: brightness(0.9);+}++.cn-brandbar {+ display: flex;+ align-items: center;+ justify-content: space-between;+ gap: 1em;+ margin-bottom: 0.9em;+ font-family: var(--font-mono);+ font-size: 0.78em;+ letter-spacing: 0.2em;+ text-transform: uppercase;+ color: var(--sh-ink);+}++.cn-brand-name {+ color: var(--sh-ink-strong);+ font-weight: var(--weight-semibold, 600);+}++/* ── screen ───────────────────────────────────────────────────────────── */++.cn-bezel {+ position: relative;+ border-radius: 1.1em;+ padding: 1.25em 2.7em 1.55em;+ background: var(--sh-bezel);+ box-shadow:+ inset 0 0.12em 0.5em rgba(0, 0, 0, 0.75),+ 0 0.16em 0 var(--sh-hi);+}++.cn-power-led {+ position: absolute;+ left: 1.15em;+ top: 50%;+ width: 0.55em;+ height: 0.55em;+ margin-top: -0.27em;+ border-radius: 50%;+ background: #4b1f24;+ box-shadow: none;+ transition:+ background 0.3s ease,+ box-shadow 0.3s ease;+}++.cn-device[data-power='on'] .cn-power-led {+ background: #ff5a5f;+ box-shadow:+ 0 0 0.5em rgba(255, 90, 95, 0.9),+ 0 0 1.4em rgba(255, 90, 95, 0.45);+}++.cn-power-label {+ position: absolute;+ left: 0.55em;+ top: 50%;+ transform: translateY(2.2em) rotate(-90deg);+ transform-origin: left top;+ font-family: var(--font-mono);+ font-size: 0.52em;+ letter-spacing: 0.24em;+ color: var(--sh-ink);+ pointer-events: none;+}++.cn-screen {+ position: relative;+ aspect-ratio: 4 / 3;+ border-radius: 0.4em;+ overflow: hidden;+ background: #05070a;+ box-shadow: inset 0 0 2.2em rgba(0, 0, 0, 0.9);+}++.cn-screen-view {+ position: absolute;+ inset: 0;+ transform-origin: center;+ transition:+ transform 0.28s cubic-bezier(0.6, 0, 0.9, 0.2),+ opacity 0.22s ease;+}++.cn-device[data-power='off'] .cn-screen-view {+ transform: scaleY(0.004) scaleX(0.85);+ opacity: 0;+}++.cn-screen iframe {+ position: absolute;+ inset: 0;+ width: 100%;+ height: 100%;+ border: 0;+ display: block;+}++/* Cartridge panels: the non-3D screens (stats, roster). */+.cn-panel {+ position: absolute;+ inset: 0;+ display: none;+ flex-direction: column;+ gap: 0.55em;+ /* the HUD strip is painted over the bottom of the screen, so every panel+ keeps that band clear of its own content */+ padding: 0.95em 1.05em 2em;+ background: radial-gradient(120% 100% at 50% 0%, #101a17 0%, #060a09 100%);+ color: #9ef0c8;+ font-family: var(--font-mono);+ font-size: 0.86em;+ line-height: 1.5;+ overflow: hidden;+}++.cn-panel[data-active='1'] {+ display: flex;+}++.cn-panel-head {+ display: flex;+ align-items: baseline;+ justify-content: space-between;+ gap: 0.6em;+ padding-bottom: 0.4em;+ border-bottom: 1px solid rgba(158, 240, 200, 0.22);+ letter-spacing: 0.14em;+ text-transform: uppercase;+ font-size: 0.8em;+ color: rgba(158, 240, 200, 0.62);+}++.cn-panel-body {+ flex: 1;+ min-height: 0;+ overflow: hidden auto;+ scrollbar-width: thin;+}++.cn-stat-row {+ display: flex;+ align-items: baseline;+ justify-content: space-between;+ gap: 0.8em;+ padding: 0.22em 0;+ border-bottom: 1px dotted rgba(158, 240, 200, 0.16);+}++.cn-stat-row dt {+ color: rgba(158, 240, 200, 0.55);+ letter-spacing: 0.08em;+ text-transform: uppercase;+ font-size: 0.82em;+ margin: 0;+}++.cn-stat-row dd {+ margin: 0;+ color: #d8ffe9;+ text-align: right;+ max-width: 62%;+ overflow-wrap: anywhere;+}++.cn-panel-note {+ color: rgba(158, 240, 200, 0.7);+ font-size: 0.86em;+ line-height: 1.5;+ margin: 0.3em 0 0;+}++.cn-roster-item {+ display: flex;+ align-items: center;+ gap: 0.55em;+ width: 100%;+ padding: 0.3em 0.45em;+ border: 0;+ border-radius: 0.25em;+ background: transparent;+ color: inherit;+ font: inherit;+ text-align: left;+ cursor: pointer;+}++.cn-roster-item[aria-selected='true'] {+ background: rgba(158, 240, 200, 0.16);+ color: #eafff4;+}++.cn-roster-item::before {+ content: '\25B8';+ opacity: 0;+}++.cn-roster-item[aria-selected='true']::before {+ opacity: 1;+}++.cn-roster-name {+ flex: 1;+ white-space: nowrap;+ overflow: hidden;+ text-overflow: ellipsis;+}++.cn-roster-meta {+ color: rgba(158, 240, 200, 0.5);+ font-size: 0.82em;+}++/* Boot / failure overlay lives above whichever cartridge is mounted. */+.cn-boot {+ position: absolute;+ inset: 0;+ z-index: 4;+ display: flex;+ flex-direction: column;+ align-items: center;+ justify-content: center;+ gap: 0.6em;+ padding: 1.2em;+ text-align: center;+ background: #05070a;+ color: #9ef0c8;+ font-family: var(--font-mono);+ font-size: 0.86em;+ letter-spacing: 0.12em;+ transition: opacity 0.35s ease;+}++.cn-boot[hidden] {+ display: none;+}++.cn-boot-bar {+ width: 8.5em;+ height: 0.35em;+ border: 1px solid rgba(158, 240, 200, 0.5);+ border-radius: 0.2em;+ overflow: hidden;+}++.cn-boot-fill {+ display: block;+ height: 100%;+ width: 18%;+ background: #9ef0c8;+ animation: cn-boot-slide 1.1s ease-in-out infinite;+}++@keyframes cn-boot-slide {+ 0% {+ transform: translateX(-110%);+ }+ 100% {+ transform: translateX(560%);+ }+}++.cn-boot-retry {+ margin-top: 0.4em;+ padding: 0.4em 0.9em;+ border: 1px solid rgba(158, 240, 200, 0.55);+ border-radius: 0.25em;+ background: transparent;+ color: inherit;+ font: inherit;+ letter-spacing: 0.14em;+ cursor: pointer;+}++.cn-boot-retry:hover {+ background: rgba(158, 240, 200, 0.16);+}++/* Glass: scanlines, glare, vignette. Purely optical, never interactive. */+.cn-glass {+ position: absolute;+ inset: 0;+ z-index: 5;+ pointer-events: none;+ background:+ repeating-linear-gradient(+ to bottom,+ rgba(0, 0, 0, 0.16) 0 1px,+ rgba(0, 0, 0, 0) 1px 3px+ ),+ linear-gradient(118deg, rgba(255, 255, 255, 0.13) 0 22%, rgba(255, 255, 255, 0) 46%),+ radial-gradient(120% 90% at 50% 50%, rgba(0, 0, 0, 0) 55%, rgba(0, 0, 0, 0.45) 100%);+ mix-blend-mode: screen;+ opacity: 0.75;+}++.cn-hud {+ position: absolute;+ left: 0;+ right: 0;+ bottom: 0;+ z-index: 6;+ display: flex;+ align-items: center;+ justify-content: space-between;+ gap: 0.6em;+ padding: 0.35em 0.6em;+ background: linear-gradient(0deg, rgba(0, 0, 0, 0.72), rgba(0, 0, 0, 0));+ font-family: var(--font-mono);+ font-size: 0.66em;+ letter-spacing: 0.12em;+ text-transform: uppercase;+ color: rgba(255, 255, 255, 0.78);+ pointer-events: none;+}++.cn-hud-name {+ overflow: hidden;+ white-space: nowrap;+ text-overflow: ellipsis;+}++.cn-hud-cart {+ color: rgba(255, 255, 255, 0.55);+ flex: none;+}++/* ── controls deck ────────────────────────────────────────────────────── */++.cn-deck {+ display: grid;+ grid-template-columns: auto 1fr auto;+ align-items: center;+ gap: 1em;+ margin-top: 1.3em;+}++.cn-dpad {+ position: relative;+ width: 8.8em;+ height: 8.8em;+ flex: none;+}++.cn-dpad-plate {+ position: absolute;+ inset: 0;+ background: var(--sh-btn);+ clip-path: polygon(+ 34% 0,+ 66% 0,+ 66% 34%,+ 100% 34%,+ 100% 66%,+ 66% 66%,+ 66% 100%,+ 34% 100%,+ 34% 66%,+ 0 66%,+ 0 34%,+ 34% 34%+ );+ box-shadow: inset 0 0.1em 0 var(--sh-hi);+ pointer-events: none;+}++.cn-dpad-hub {+ position: absolute;+ left: 50%;+ top: 50%;+ width: 2.4em;+ height: 2.4em;+ margin: -1.2em 0 0 -1.2em;+ border-radius: 50%;+ background: radial-gradient(circle at 50% 35%, rgba(0, 0, 0, 0.28), rgba(0, 0, 0, 0.05));+ pointer-events: none;+}++.cn-dir {+ position: absolute;+ appearance: none;+ border: 0;+ background: transparent;+ color: var(--sh-btn-ink);+ font-size: 0.9em;+ line-height: 1;+ display: flex;+ align-items: center;+ justify-content: center;+ cursor: pointer;+ width: 36%;+ height: 36%;+ border-radius: 0.4em;+ transition:+ transform 0.08s ease,+ background 0.12s ease;+}++.cn-dir[data-dir='up'] {+ left: 32%;+ top: 0;+}++.cn-dir[data-dir='down'] {+ left: 32%;+ bottom: 0;+}++.cn-dir[data-dir='left'] {+ left: 0;+ top: 32%;+}++.cn-dir[data-dir='right'] {+ right: 0;+ top: 32%;+}++.cn-dir:hover {+ background: rgba(255, 255, 255, 0.08);+}++.cn-dir[data-held='1'] {+ transform: scale(0.92);+ background: rgba(0, 0, 0, 0.22);+}++.cn-face {+ display: flex;+ align-items: center;+ gap: 1.1em;+ transform: rotate(-18deg);+ flex: none;+}++.cn-face-btn {+ appearance: none;+ width: 3.5em;+ height: 3.5em;+ border: 0;+ border-radius: 50%;+ background: var(--sh-btn);+ color: var(--sh-btn-ink);+ font-family: var(--font-mono);+ font-size: 1em;+ font-weight: var(--weight-bold, 700);+ cursor: pointer;+ box-shadow:+ inset 0 0.14em 0 var(--sh-hi),+ 0 0.3em 0.5em rgba(0, 0, 0, 0.4);+ transition:+ transform 0.09s ease,+ filter 0.14s ease;+}++.cn-face-btn:hover {+ filter: brightness(1.14);+}++.cn-face-btn:active,+.cn-face-btn[data-held='1'] {+ transform: translateY(0.16em) scale(0.96);+ filter: brightness(0.88);+}++.cn-face-btn small {+ display: block;+ margin-top: 0.1em;+ font-size: 0.5em;+ letter-spacing: 0.1em;+ opacity: 0.7;+}++.cn-menu {+ display: flex;+ justify-content: center;+ gap: 1.4em;+ margin-top: 1.1em;+ transform: rotate(-18deg);+}++.cn-menu-btn {+ appearance: none;+ padding: 0.42em 1.4em;+ border: 0;+ border-radius: var(--radius-pill, 999px);+ background: var(--sh-btn);+ color: var(--sh-btn-ink);+ font-family: var(--font-mono);+ font-size: 0.66em;+ letter-spacing: 0.2em;+ cursor: pointer;+ box-shadow: inset 0 0.1em 0 var(--sh-hi);+ transition:+ transform 0.09s ease,+ filter 0.14s ease;+}++.cn-menu-btn:hover {+ filter: brightness(1.14);+}++.cn-menu-btn:active,+.cn-menu-btn[data-held='1'] {+ transform: translateY(0.14em);+ filter: brightness(0.88);+}++.cn-menu-btn:focus-visible,+.cn-face-btn:focus-visible,+.cn-dir:focus-visible,+.cn-shoulder:focus-visible {+ outline: 2px solid var(--sh-ink-strong);+ outline-offset: 2px;+}++.cn-speaker {+ display: flex;+ justify-content: flex-end;+ gap: 0.42em;+ margin-top: 1.1em;+ padding-right: 0.6em;+ transform: rotate(-18deg);+ transform-origin: right center;+}++.cn-speaker span {+ display: block;+ width: 0.32em;+ height: 2.9em;+ border-radius: var(--radius-pill, 999px);+ background: rgba(0, 0, 0, 0.32);+ box-shadow: 0 0.08em 0 var(--sh-hi);+}++.cn-gamepad-pill {+ position: absolute;+ right: 1.8em;+ bottom: 1.2em;+ display: none;+ align-items: center;+ gap: 0.4em;+ padding: 0.3em 0.7em;+ border-radius: var(--radius-pill, 999px);+ background: rgba(0, 0, 0, 0.32);+ color: var(--sh-ink-strong);+ font-family: var(--font-mono);+ font-size: 0.6em;+ letter-spacing: 0.14em;+ text-transform: uppercase;+}++.cn-gamepad-pill[data-on='1'] {+ display: inline-flex;+}++/* ── side rails: shells, keys, agents ─────────────────────────────────── */++.cn-tools {+ display: flex;+ flex-wrap: wrap;+ align-items: center;+ justify-content: center;+ gap: var(--space-sm, 10px);+ margin: 0 0 var(--space-sm, 10px);+}++.cn-tool-group {+ display: flex;+ align-items: center;+ gap: var(--space-2xs, 4px);+ padding: 4px;+ border: 1px solid var(--stroke, rgba(255, 255, 255, 0.08));+ border-radius: var(--radius-pill, 999px);+ background: var(--surface-1, rgba(255, 255, 255, 0.03));+}++.cn-tool-label {+ padding: 0 var(--space-sm, 10px) 0 var(--space-xs, 7px);+ font-family: var(--font-mono);+ font-size: var(--text-2xs, 11px);+ letter-spacing: 0.12em;+ text-transform: uppercase;+ color: var(--ink-dim, #888);+}++.cn-tab {+ appearance: none;+ padding: 0.42em 0.9em;+ border: 0;+ border-radius: var(--radius-pill, 999px);+ background: transparent;+ color: var(--ink-dim, #888);+ font-family: var(--font-body);+ font-size: var(--text-sm, 12px);+ cursor: pointer;+ transition:+ background 0.16s ease,+ color 0.16s ease;+}++.cn-tab:hover {+ color: var(--ink-bright, #fff);+ background: var(--surface-2, rgba(255, 255, 255, 0.05));+}++.cn-tab[aria-pressed='true'] {+ background: var(--accent, #fff);+ color: #0a0a0b;+}++.cn-swatch {+ width: 1.15em;+ height: 1.15em;+ border-radius: 50%;+ border: 1px solid rgba(0, 0, 0, 0.35);+ display: inline-block;+ vertical-align: -0.2em;+ margin-right: 0.45em;+}++.cn-rail {+ margin-top: var(--space-xl, 42px);+}++.cn-rail-head {+ display: flex;+ align-items: baseline;+ justify-content: space-between;+ gap: var(--space-md, 16px);+ margin-bottom: var(--space-sm, 10px);+}++.cn-rail-title {+ margin: 0;+ font-family: var(--font-display);+ font-size: var(--text-lg, 20px);+ font-weight: var(--weight-semibold, 600);+ color: var(--ink-bright, #fff);+}++.cn-rail-hint {+ margin: 0;+ font-size: var(--text-sm, 12px);+ color: var(--ink-dim, #888);+}++.cn-carts {+ display: flex;+ gap: var(--space-sm, 10px);+ overflow-x: auto;+ padding: var(--space-2xs, 4px) 2px var(--space-sm, 10px);+ scroll-snap-type: x proximity;+ scrollbar-width: thin;+}++.cn-chip {+ flex: none;+ display: flex;+ align-items: center;+ gap: var(--space-sm, 10px);+ width: 15rem;+ padding: var(--space-sm, 10px);+ border: 1px solid var(--stroke, rgba(255, 255, 255, 0.08));+ border-radius: var(--radius-md, 10px);+ background: var(--surface-1, rgba(255, 255, 255, 0.03));+ color: var(--ink, #e8e8e8);+ text-align: left;+ cursor: pointer;+ scroll-snap-align: start;+ transition:+ border-color 0.18s ease,+ background 0.18s ease,+ transform 0.14s ease;+}++.cn-chip:hover {+ border-color: var(--stroke-strong, rgba(255, 255, 255, 0.14));+ background: var(--surface-2, rgba(255, 255, 255, 0.05));+ transform: translateY(-2px);+}++.cn-chip[aria-pressed='true'] {+ border-color: var(--accent, #fff);+ background: var(--surface-3, rgba(255, 255, 255, 0.08));+}++.cn-chip-thumb {+ width: 2.6rem;+ height: 2.6rem;+ flex: none;+ border-radius: var(--radius-sm, 6px);+ object-fit: cover;+ background: var(--surface-2, rgba(255, 255, 255, 0.05));+}++.cn-chip-text {+ min-width: 0;+}++.cn-chip-name {+ display: block;+ font-size: var(--text-md, 13px);+ font-weight: var(--weight-medium, 500);+ color: var(--ink-bright, #fff);+ white-space: nowrap;+ overflow: hidden;+ text-overflow: ellipsis;+}++.cn-chip-meta {+ display: block;+ margin-top: 2px;+ font-family: var(--font-mono);+ font-size: var(--text-2xs, 11px);+ color: var(--ink-dim, #888);+ white-space: nowrap;+ overflow: hidden;+ text-overflow: ellipsis;+}++.cn-chip-skeleton {+ pointer-events: none;+ background: linear-gradient(+ 100deg,+ var(--surface-1, rgba(255, 255, 255, 0.03)) 30%,+ var(--surface-3, rgba(255, 255, 255, 0.08)) 50%,+ var(--surface-1, rgba(255, 255, 255, 0.03)) 70%+ );+ background-size: 220% 100%;+ animation: cn-shimmer 1.4s linear infinite;+ height: 3.7rem;+}++@keyframes cn-shimmer {+ from {+ background-position: 120% 0;+ }+ to {+ background-position: -120% 0;+ }+}++.cn-rail-error {+ display: flex;+ flex-wrap: wrap;+ align-items: center;+ gap: var(--space-sm, 10px);+ padding: var(--space-md, 16px);+ border: 1px solid var(--stroke, rgba(255, 255, 255, 0.08));+ border-radius: var(--radius-md, 10px);+ background: var(--surface-1, rgba(255, 255, 255, 0.03));+ color: var(--ink-dim, #888);+ font-size: var(--text-md, 13px);+}++/* ── share + embed ────────────────────────────────────────────────────── */++.cn-panels {+ display: grid;+ grid-template-columns: repeat(auto-fit, minmax(19rem, 1fr));+ gap: var(--space-md, 16px);+ margin-top: var(--space-xl, 42px);+}++.cn-card {+ padding: var(--space-lg, 26px);+ border: 1px solid var(--stroke, rgba(255, 255, 255, 0.08));+ border-radius: var(--radius-lg, 14px);+ background: var(--surface-glass, rgba(255, 255, 255, 0.03));+}++.cn-card h2 {+ margin: 0 0 var(--space-xs, 7px);+ font-family: var(--font-display);+ font-size: var(--text-lg, 20px);+ font-weight: var(--weight-semibold, 600);+ color: var(--ink-bright, #fff);+}++.cn-card p {+ margin: 0 0 var(--space-md, 16px);+ font-size: var(--text-md, 13px);+ line-height: var(--leading-normal, 1.618);+ color: var(--ink-dim, #888);+}++.cn-code {+ display: block;+ margin: 0 0 var(--space-md, 16px);+ padding: var(--space-sm, 10px) var(--space-md, 16px);+ border: 1px solid var(--stroke, rgba(255, 255, 255, 0.08));+ border-radius: var(--radius-md, 10px);+ background: var(--bg-0, #0a0a0b);+ color: var(--ink, #e8e8e8);+ font-family: var(--font-mono);+ font-size: var(--text-sm, 12px);+ line-height: 1.7;+ white-space: pre-wrap;+ overflow-wrap: anywhere;+}++.cn-keys {+ display: grid;+ grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr));+ gap: var(--space-xs, 7px) var(--space-md, 16px);+ margin: 0;+ font-size: var(--text-md, 13px);+ color: var(--ink-dim, #888);+}++.cn-keys div {+ display: flex;+ align-items: center;+ justify-content: space-between;+ gap: var(--space-sm, 10px);+ padding: 0.3em 0;+ border-bottom: 1px solid var(--hairline, rgba(255, 255, 255, 0.055));+}++.cn-keys kbd {+ font-family: var(--font-mono);+ font-size: var(--text-2xs, 11px);+ padding: 0.24em 0.5em;+ border: 1px solid var(--stroke-strong, rgba(255, 255, 255, 0.14));+ border-radius: var(--radius-sm, 6px);+ background: var(--surface-2, rgba(255, 255, 255, 0.05));+ color: var(--ink, #e8e8e8);+ white-space: nowrap;+}++.cn-toast {+ position: fixed;+ left: 50%;+ bottom: 1.5rem;+ transform: translate(-50%, 1.5rem);+ z-index: 90;+ padding: 0.6em 1.1em;+ border-radius: var(--radius-pill, 999px);+ border: 1px solid var(--stroke-strong, rgba(255, 255, 255, 0.14));+ background: var(--bg-1, #131316);+ color: var(--ink-bright, #fff);+ font-size: var(--text-md, 13px);+ opacity: 0;+ pointer-events: none;+ transition:+ opacity 0.22s ease,+ transform 0.22s ease;+}++.cn-toast[data-on='1'] {+ opacity: 1;+ transform: translate(-50%, 0);+}++/* ── chrome-off (embed) mode ──────────────────────────────────────────── */++body[data-chrome='off'] {+ background: transparent;+}++body[data-chrome='off'] header,+body[data-chrome='off'] #footer-container,+body[data-chrome='off'] .cn-hero,+body[data-chrome='off'] .cn-tools,+body[data-chrome='off'] .cn-rail,+body[data-chrome='off'] .cn-panels {+ display: none;+}++body[data-chrome='off'] .cn-shell {+ padding: var(--space-sm, 10px);+ display: flex;+ align-items: center;+ justify-content: center;+ min-height: 100vh;+}++body[data-chrome='off'] .cn-stage {+ padding: 0;+}++@media (max-width: 640px) {+ .cn-deck {+ gap: 0.5em;+ }++ .cn-title {+ font-size: var(--text-xl, 26px);+ }+}++@media (prefers-reduced-motion: reduce) {+ .cn-device,+ .cn-screen-view,+ .cn-chip,+ .cn-toast {+ transition-duration: 0.01ms;+ }++ .cn-boot-fill,+ .cn-chip-skeleton {+ animation: none;+ }+}diff --git a/src/console.js b/src/console.jsnew file mode 100644index 000000000..92c9d0e02--- /dev/null+++ b/src/console.js@@ -0,0 +1,960 @@+// Agent Console (/console) — a handheld with a live 3D agent inside the screen.+//+// The screen is a real /walk-embed iframe, so the body walking around in there+// is the same renderer, retargeting and animation library the rest of the+// platform uses. This module is the console around it: it owns the cartridge+// (which screen is mounted), the roster (which public agent is loaded), the+// physical controls, and the share/embed surface.+//+// Everything the device sends into the screen goes over the typed walk-embed+// contract documented in src/walk-embed-events.js:+// walk:move { x, y, run } held analog vector from the D-pad+// walk:gesture{ gesture } one-shot wave / jump from A and B+// walk:avatar { avatarId } slotting a different agent's body+// walk:env { env } SELECT cycles the scene+// walk:say { text } the agent introduces itself when slotted+// and the screen answers with walk:ready / walk:avatarChanged / walk:error,+// which is what drives the boot overlay. Nothing here fakes a loading state.+//+// URL params:+// ?agent=<uuid> boot straight into that agent+// ?shell=graphite|bone|clear|indigo+// ?env=studio|void|beach|sunset|night|grid+// ?cart=play|stats|select+// ?chrome=off device only, transparent background (this is the embed mode)++const WALK_CHANNEL = 'three-walk';+const ROSTER_URL = '/api/agents/public?limit=24';+const ROSTER_LIMIT = 24;+const SHELLS = ['graphite', 'bone', 'clear', 'indigo'];+const ENVS = ['night', 'studio', 'sunset', 'grid'];+const CARTS = ['play', 'stats', 'select'];+const BOOT_TIMEOUT_MS = 25000;+const SWAP_TIMEOUT_MS = 20000;+const TILT_MAX_DEG = 7;++const params = new URLSearchParams(location.search);+const chromeOff = (params.get('chrome') || '').toLowerCase() === 'off';+const reduceMotion =+ typeof matchMedia === 'function' && matchMedia('(prefers-reduced-motion: reduce)').matches;+const canHover =+ typeof matchMedia === 'function' && matchMedia('(hover: hover) and (pointer: fine)').matches;++const el = {+ device: document.getElementById('cn-device'),+ screenPlay: document.getElementById('cn-cart-play'),+ boot: document.getElementById('cn-boot'),+ bootText: document.getElementById('cn-boot-text'),+ bootRetry: document.getElementById('cn-boot-retry'),+ hudName: document.getElementById('cn-hud-name'),+ hudCart: document.getElementById('cn-hud-cart'),+ modelLine: document.getElementById('cn-model-line'),+ statsId: document.getElementById('cn-stats-id'),+ statsList: document.getElementById('cn-stats-list'),+ statsNote: document.getElementById('cn-stats-note'),+ roster: document.getElementById('cn-roster'),+ selectCount: document.getElementById('cn-select-count'),+ carts: document.getElementById('cn-carts'),+ embedCode: document.getElementById('cn-embed-code'),+ gamepadPill: document.getElementById('cn-gamepad'),+ toast: document.getElementById('cn-toast'),+ live: document.getElementById('cn-live'),+};++const state = {+ agents: [],+ index: -1,+ detail: null,+ detailFor: null,+ cart: CARTS.includes(params.get('cart')) ? params.get('cart') : 'play',+ env: ENVS.includes(params.get('env')) ? params.get('env') : 'night',+ shell: SHELLS.includes(params.get('shell')) ? params.get('shell') : 'graphite',+ power: true,+ ready: false,+ rosterCursor: 0,+ frame: null,+ swapTimer: 0,+ bootTimer: 0,+};++const held = { up: false, down: false, left: false, right: false, run: false };+let lastVector = { x: 0, y: 0, run: false };++// ── screen plumbing ───────────────────────────────────────────────────────++// The screen is framed tighter than a full-bleed walk embed (?zoom) and the+// body is addressed by avatar id whenever we know it: that route streams the+// GLB through the same-origin proxy, so the console renders identically on+// three.ws and inside somebody else's page, where R2's own CORS would refuse+// the raw model URL.+function frameSrc(agentId) {+ const q = new URLSearchParams({+ controls: 'none',+ orbit: 'false',+ badge: 'false',+ click: 'false',+ gestures: 'false',+ zoom: '0.74',+ env: state.env,+ });+ const avatarId = agentId && state.detailFor === agentId ? state.detail?.avatar_id : null;+ if (avatarId) q.set('avatar', avatarId);+ else if (agentId) q.set('agent', agentId);+ return `/walk-embed?${q.toString()}`;+}++function mountFrame(agentId) {+ unmountFrame();+ const frame = document.createElement('iframe');+ frame.src = frameSrc(agentId);+ frame.title = 'Live 3D agent';+ frame.loading = 'eager';+ frame.allow = 'xr-spatial-tracking';+ el.screenPlay.appendChild(frame);+ state.frame = frame;+ state.ready = false;+ showBoot('Booting agent');+ clearTimeout(state.bootTimer);+ state.bootTimer = setTimeout(() => {+ if (!state.ready) failBoot('Screen did not answer');+ }, BOOT_TIMEOUT_MS);+}++function unmountFrame() {+ clearTimeout(state.bootTimer);+ clearTimeout(state.swapTimer);+ if (state.frame) state.frame.remove();+ state.frame = null;+ state.ready = false;+}++function post(type, payload = {}) {+ if (!state.frame || !state.frame.contentWindow) return;+ state.frame.contentWindow.postMessage({ channel: WALK_CHANNEL, v: 1, type, ...payload }, '*');+}++function showBoot(text) {+ el.bootText.textContent = text;+ el.bootRetry.hidden = true;+ el.boot.hidden = false;+}++function hideBoot() {+ el.boot.hidden = true;+}++function failBoot(message) {+ el.bootText.textContent = message;+ el.bootRetry.hidden = false;+ el.boot.hidden = false;+}++window.addEventListener('message', (event) => {+ if (!state.frame || event.source !== state.frame.contentWindow) return;+ const data = event.data;+ if (!data || typeof data !== 'object' || typeof data.type !== 'string') return;+ if (data.channel && data.channel !== WALK_CHANNEL) return;++ if (data.type === 'walk:ready' || data.type === 'walk:loaded') {+ state.ready = true;+ clearTimeout(state.bootTimer);+ hideBoot();+ post('walk:env', { env: state.env });+ greet();+ return;+ }+ if (data.type === 'walk:avatarChanged') {+ clearTimeout(state.swapTimer);+ hideBoot();+ greet();+ return;+ }+ if (data.type === 'walk:error') {+ clearTimeout(state.swapTimer);+ failBoot(data.message ? String(data.message).slice(0, 90) : 'Screen error');+ }+});++el.bootRetry.addEventListener('click', () => {+ const agent = currentAgent();+ mountFrame(agent ? agent.id : null);+});++function greet() {+ const agent = currentAgent();+ if (!agent) return;+ post('walk:say', { text: agent.name, durationMs: 2600 });+}++// ── roster ────────────────────────────────────────────────────────────────++function currentAgent() {+ return state.index >= 0 ? state.agents[state.index] || null : null;+}++async function loadRoster() {+ el.carts.setAttribute('aria-busy', 'true');+ renderCartSkeletons();+ try {+ const res = await fetch(ROSTER_URL, { headers: { accept: 'application/json' } });+ if (!res.ok) throw new Error(`HTTP ${res.status}`);+ const body = await res.json();+ const list = Array.isArray(body?.agents) ? body.agents : [];+ state.agents = list.filter((a) => a && a.id && a.name).slice(0, ROSTER_LIMIT);+ if (!state.agents.length) throw new Error('empty roster');+ el.carts.setAttribute('aria-busy', 'false');+ renderCarts();+ renderRoster();+ const wanted = params.get('agent');+ const at = wanted ? state.agents.findIndex((a) => a.id === wanted) : -1;+ if (wanted && at < 0) {+ await loadUnlistedAgent(wanted);+ return;+ }+ selectAgent(at >= 0 ? at : 0, { boot: true });+ } catch (err) {+ el.carts.setAttribute('aria-busy', 'false');+ renderRosterError(err?.message || 'could not reach the agent index');+ }+}++// A shared /console?agent=<id> link can name an agent outside the first page of+// the public index. Pull that one record directly and put it at the head of the+// roster so the link always boots the agent it promised.+async function loadUnlistedAgent(id) {+ try {+ const res = await fetch(`/api/agents/${encodeURIComponent(id)}`, {+ headers: { accept: 'application/json' },+ });+ if (!res.ok) throw new Error(`HTTP ${res.status}`);+ const body = await res.json();+ const rec = body?.agent || body;+ if (!rec?.id) throw new Error('agent not found');+ state.agents.unshift({+ id: rec.id,+ name: rec.name || 'Agent',+ description: rec.description || '',+ skills: rec.skills || [],+ avatar_thumbnail: rec.avatar_thumbnail_url || rec.avatar_thumbnail || null,+ chat_count: rec.chat_count || 0,+ created_at: rec.created_at || null,+ is_registered: !!rec.is_registered,+ });+ state.detail = rec;+ state.detailFor = rec.id;+ renderCarts();+ renderRoster();+ selectAgent(0, { boot: true });+ } catch {+ toast('That agent is not public. Booting the first cartridge instead.');+ selectAgent(0, { boot: true });+ }+}++function renderCartSkeletons() {+ el.carts.replaceChildren();+ for (let i = 0; i < 5; i += 1) {+ const chip = document.createElement('div');+ chip.className = 'cn-chip cn-chip-skeleton';+ el.carts.appendChild(chip);+ }+}++function renderRosterError(reason) {+ el.carts.replaceChildren();+ const box = document.createElement('div');+ box.className = 'cn-rail-error';+ const text = document.createElement('span');+ text.textContent = `The cartridge shelf is unreachable (${reason}). The console still runs on its default body.`;+ const retry = document.createElement('button');+ retry.type = 'button';+ retry.className = 'cn-btn';+ retry.textContent = 'Try again';+ retry.addEventListener('click', loadRoster);+ box.append(text, retry);+ el.carts.appendChild(box);++ el.roster.replaceChildren();+ const line = document.createElement('p');+ line.className = 'cn-panel-note';+ line.textContent = 'NO SIGNAL. The agent index did not answer.';+ el.roster.appendChild(line);+ el.selectCount.textContent = '0';++ el.hudName.textContent = 'default body';+ el.statsNote.textContent = 'No agent loaded. Pick one from the shelf once the index answers.';+ mountFrame(null);+}++function renderCarts() {+ el.carts.replaceChildren();+ state.agents.forEach((agent, i) => {+ const chip = document.createElement('button');+ chip.type = 'button';+ chip.className = 'cn-chip';+ chip.setAttribute('aria-pressed', String(i === state.index));+ chip.dataset.index = String(i);++ const thumb = document.createElement('img');+ thumb.className = 'cn-chip-thumb';+ thumb.alt = '';+ thumb.loading = 'lazy';+ thumb.decoding = 'async';+ if (agent.avatar_thumbnail) thumb.src = agent.avatar_thumbnail;++ const text = document.createElement('span');+ text.className = 'cn-chip-text';+ const name = document.createElement('span');+ name.className = 'cn-chip-name';+ name.textContent = agent.name;+ const meta = document.createElement('span');+ meta.className = 'cn-chip-meta';+ meta.textContent = cartMeta(agent);+ text.append(name, meta);++ chip.append(thumb, text);+ chip.addEventListener('click', () => selectAgent(i));+ el.carts.appendChild(chip);+ });+}++function cartMeta(agent) {+ const skills = Array.isArray(agent.skills) ? agent.skills.length : 0;+ const chats = Number(agent.chat_count) || 0;+ return `${skills} skills · ${chats} chats`;+}++function renderRoster() {+ el.roster.replaceChildren();+ state.agents.forEach((agent, i) => {+ const row = document.createElement('button');+ row.type = 'button';+ row.className = 'cn-roster-item';+ row.setAttribute('role', 'option');+ row.setAttribute('aria-selected', String(i === state.rosterCursor));+ const name = document.createElement('span');+ name.className = 'cn-roster-name';+ name.textContent = agent.name;+ const meta = document.createElement('span');+ meta.className = 'cn-roster-meta';+ meta.textContent = i === state.index ? 'LOADED' : `${Number(agent.chat_count) || 0}`;+ row.append(name, meta);+ row.addEventListener('click', () => {+ state.rosterCursor = i;+ selectAgent(i);+ });+ el.roster.appendChild(row);+ });+ el.selectCount.textContent = String(state.agents.length);+}++function moveRosterCursor(delta) {+ if (!state.agents.length) return;+ const next = (state.rosterCursor + delta + state.agents.length) % state.agents.length;+ state.rosterCursor = next;+ const rows = el.roster.querySelectorAll('.cn-roster-item');+ rows.forEach((row, i) => row.setAttribute('aria-selected', String(i === next)));+ rows[next]?.scrollIntoView({ block: 'nearest' });+ announce(`${state.agents[next].name} highlighted`);+}++// ── agent selection ───────────────────────────────────────────────────────++function selectAgent(index, { boot = false } = {}) {+ if (!state.agents.length) return;+ const i = ((index % state.agents.length) + state.agents.length) % state.agents.length;+ const changed = i !== state.index;+ state.index = i;+ state.rosterCursor = i;+ const agent = state.agents[i];++ el.carts.querySelectorAll('.cn-chip').forEach((chip) => {+ chip.setAttribute('aria-pressed', String(Number(chip.dataset.index) === i));+ });+ renderRoster();+ el.hudName.textContent = agent.name;+ el.modelLine.textContent = `cartridge ${String(i + 1).padStart(2, '0')}`;+ announce(`${agent.name} loaded`);+ syncUrl();+ renderEmbed();+ loadDetail(agent.id);++ if (boot || !state.frame) {+ bootBody(agent);+ return;+ }+ if (!changed) return;+ swapBody(agent);+}++// First mount for an agent: read its record first so the screen can be handed+// the avatar id (same-origin GLB proxy) instead of the agent id (raw R2 URL).+// A failed read still boots, just through the server-side resolve.+async function bootBody(agent) {+ showBoot(`Loading ${agent.name}`);+ try {+ await detailFor(agent.id);+ } catch {+ state.detailFor = null;+ }+ if (currentAgent()?.id !== agent.id) return;+ mountFrame(agent.id);+}++// Swap the body without reloading the screen when we know the avatar id; fall+// back to a full remount (which resolves the agent server-side) when we do not.+async function swapBody(agent) {+ showBoot(`Loading ${agent.name}`);+ clearTimeout(state.swapTimer);+ let avatarId = null;+ try {+ avatarId = (await detailFor(agent.id))?.avatar_id || null;+ } catch {+ avatarId = null;+ }+ if (!avatarId) {+ mountFrame(agent.id);+ return;+ }+ el.hudName.textContent = agent.name;+ if (currentAgent()?.id !== agent.id) return;+ post('walk:avatar', { avatarId });+ state.swapTimer = setTimeout(() => {+ if (currentAgent()?.id === agent.id) mountFrame(agent.id);+ }, SWAP_TIMEOUT_MS);+}++// One request per agent, shared by the stats cartridge and the body swap that+// happen in the same tick; a failed read is not cached so Retry can refetch.+const detailCache = new Map();++function detailFor(id) {+ if (state.detailFor === id && state.detail) return Promise.resolve(state.detail);+ const pending = detailCache.get(id);+ if (pending) return pending;+ const req = fetch(`/api/agents/${encodeURIComponent(id)}`, {+ headers: { accept: 'application/json' },+ })+ .then(async (res) => {+ if (!res.ok) throw new Error(`HTTP ${res.status}`);+ const body = await res.json();+ const rec = body?.agent || body;+ state.detail = rec;+ state.detailFor = id;+ return rec;+ })+ .catch((err) => {+ detailCache.delete(id);+ throw err;+ });+ detailCache.set(id, req);+ return req;+}++async function loadDetail(id) {+ el.statsId.textContent = id.slice(0, 8);+ el.statsNote.textContent = 'Reading the agent record…';+ el.statsList.replaceChildren();+ try {+ const rec = await detailFor(id);+ if (currentAgent()?.id !== id) return;+ renderStats(rec);+ } catch (err) {+ if (currentAgent()?.id !== id) return;+ el.statsList.replaceChildren();+ el.statsNote.textContent = `Could not read this agent (${err?.message || 'network error'}).`;+ }+}++function renderStats(rec) {+ const skills = Array.isArray(rec.skills) ? rec.skills : [];+ const paid = rec.skill_prices ? Object.keys(rec.skill_prices).length : 0;+ const rows = [+ ['name', rec.name || 'unnamed'],+ ['builder', rec.author_name || 'anonymous'],+ ['skills', skills.length ? `${skills.length}` : 'none'],+ ['paid skills', paid ? `${paid} · x402` : 'free'],+ ['chats', String(rec.chat_count ?? 0)],+ ['body', rec.avatar_id ? 'rigged 3D' : 'default'],+ ['on-chain', rec.erc8004_agent_id ? `#${rec.erc8004_agent_id}` : 'off-chain'],+ ['born', rec.created_at ? new Date(rec.created_at).toISOString().slice(0, 10) : 'unknown'],+ ];+ el.statsList.replaceChildren();+ for (const [label, value] of rows) {+ const row = document.createElement('div');+ row.className = 'cn-stat-row';+ const dt = document.createElement('dt');+ dt.textContent = label;+ const dd = document.createElement('dd');+ dd.textContent = value;+ row.append(dt, dd);+ el.statsList.appendChild(row);+ }+ const desc = (rec.description || '').trim();+ el.statsNote.textContent = desc+ ? desc.length > 220+ ? `${desc.slice(0, 217)}...`+ : desc+ : 'This agent shipped without a description.';+}++// ── cartridges, scene, shell, power ───────────────────────────────────────++function setCart(cart) {+ if (!CARTS.includes(cart)) return;+ state.cart = cart;+ el.device.querySelectorAll('.cn-panel').forEach((panel) => {+ panel.dataset.active = panel.dataset.cart === cart ? '1' : '0';+ });+ el.screenPlay.style.display = cart === 'play' ? '' : 'none';+ el.hudCart.textContent = cart;+ document.querySelectorAll('[data-cart]').forEach((tab) => {+ if (tab.classList.contains('cn-tab')) {+ tab.setAttribute('aria-pressed', String(tab.dataset.cart === cart));+ }+ });+ if (cart !== 'play') releaseAll();+ announce(`${cart} cartridge`);+ syncUrl();+}++function setEnv(env) {+ if (!ENVS.includes(env)) return;+ state.env = env;+ post('walk:env', { env });+ document.querySelectorAll('[data-env]').forEach((tab) => {+ tab.setAttribute('aria-pressed', String(tab.dataset.env === env));+ });+ announce(`${env} scene`);+ syncUrl();+ renderEmbed();+}++function setShell(shell) {+ if (!SHELLS.includes(shell)) return;+ state.shell = shell;+ el.device.dataset.shell = shell;+ document.querySelectorAll('[data-shell].cn-tab').forEach((tab) => {+ tab.setAttribute('aria-pressed', String(tab.dataset.shell === shell));+ });+ syncUrl();+ renderEmbed();+}++function setPower(on) {+ state.power = on;+ el.device.dataset.power = on ? 'on' : 'off';+ if (!on) {+ releaseAll();+ hideBoot();+ // A screen that is off must actually stop rendering, so the WebGL+ // context goes away with the frame rather than idling behind an opacity.+ setTimeout(() => {+ if (!state.power) unmountFrame();+ }, 300);+ announce('console off');+ return;+ }+ const agent = currentAgent();+ mountFrame(agent ? agent.id : null);+ announce('console on');+}++// ── input ─────────────────────────────────────────────────────────────────++function pushVector() {+ let x = (held.right ? 1 : 0) - (held.left ? 1 : 0);+ let y = (held.up ? 1 : 0) - (held.down ? 1 : 0);+ const mag = Math.hypot(x, y);+ if (mag > 1) {+ x /= mag;+ y /= mag;+ }+ const run = held.run && mag > 0;+ if (x === lastVector.x && y === lastVector.y && run === lastVector.run) return;+ lastVector = { x, y, run };+ post('walk:move', { x, y, run });+}++function setDir(dir, down) {+ if (!(dir in held)) return;+ if (state.cart === 'select') {+ if (!down) return;+ if (dir === 'up') moveRosterCursor(-1);+ if (dir === 'down') moveRosterCursor(1);+ return;+ }+ if (state.cart !== 'play' || !state.power) return;+ held[dir] = down;+ paintDir(dir, down);+ pushVector();+}++function paintDir(dir, down) {+ const btn = el.device.querySelector(`.cn-dir[data-dir="${dir}"]`);+ if (btn) btn.dataset.held = down ? '1' : '0';+}++function releaseAll() {+ for (const key of ['up', 'down', 'left', 'right']) {+ held[key] = false;+ paintDir(key, false);+ }+ held.run = false;+ pushVector();+}++function pressFace(btn) {+ if (!state.power) return;+ if (btn === 'a') {+ if (state.cart === 'select') {+ selectAgent(state.rosterCursor);+ setCart('play');+ return;+ }+ post('walk:gesture', { gesture: 'wave' });+ announce('wave');+ return;+ }+ if (btn === 'b') {+ if (state.cart !== 'play') {+ setCart('play');+ return;+ }+ post('walk:gesture', { gesture: 'jump' });+ announce('jump');+ }+}++function flash(selector) {+ const node = el.device.querySelector(selector);+ if (!node) return;+ node.dataset.held = '1';+ setTimeout(() => {+ node.dataset.held = '0';+ }, 140);+}++function nextCart() {+ setCart(CARTS[(CARTS.indexOf(state.cart) + 1) % CARTS.length]);+}++function nextEnv() {+ setEnv(ENVS[(ENVS.indexOf(state.env) + 1) % ENVS.length]);+}++// Pointer: press and hold anywhere on a control.+el.device.querySelectorAll('.cn-dir').forEach((btn) => {+ const dir = btn.dataset.dir;+ btn.addEventListener('pointerdown', (e) => {+ btn.setPointerCapture(e.pointerId);+ setDir(dir, true);+ });+ const up = () => setDir(dir, false);+ btn.addEventListener('pointerup', up);+ btn.addEventListener('pointercancel', up);+ btn.addEventListener('pointerleave', up);+ btn.addEventListener('keydown', (e) => {+ if (e.key === 'Enter' || e.key === ' ') {+ e.preventDefault();+ setDir(dir, true);+ }+ });+ btn.addEventListener('keyup', (e) => {+ if (e.key === 'Enter' || e.key === ' ') setDir(dir, false);+ });+});++el.device.querySelectorAll('.cn-face-btn').forEach((btn) => {+ btn.addEventListener('click', () => pressFace(btn.dataset.btn));+});++el.device.querySelectorAll('.cn-menu-btn').forEach((btn) => {+ btn.addEventListener('click', () => {+ if (btn.dataset.btn === 'start') nextCart();+ else nextEnv();+ });+});++document.getElementById('cn-l').addEventListener('click', () => selectAgent(state.index - 1));+document.getElementById('cn-r').addEventListener('click', () => selectAgent(state.index + 1));++// The power LED doubles as the power switch, the way the real thing does.+el.device.querySelector('.cn-power-led')?.addEventListener('click', () => setPower(!state.power));++const KEY_DIRS = {+ arrowup: 'up',+ w: 'up',+ arrowdown: 'down',+ s: 'down',+ arrowleft: 'left',+ a: 'left',+ arrowright: 'right',+ d: 'right',+};++function typingTarget(target) {+ if (!target) return false;+ const tag = target.tagName;+ return tag === 'INPUT' || tag === 'TEXTAREA' || tag === 'SELECT' || target.isContentEditable;+}++window.addEventListener('keydown', (e) => {+ if (e.metaKey || e.ctrlKey || e.altKey || typingTarget(e.target)) return;+ const key = e.key.toLowerCase();+ const dir = KEY_DIRS[key];+ if (dir) {+ e.preventDefault();+ setDir(dir, true);+ return;+ }+ if (key === 'shift') {+ held.run = true;+ pushVector();+ return;+ }+ if (key === 'k') {+ flash('.cn-face-btn[data-btn="a"]');+ pressFace('a');+ return;+ }+ if (key === 'j') {+ flash('.cn-face-btn[data-btn="b"]');+ pressFace('b');+ return;+ }+ if (key === 'enter') {+ e.preventDefault();+ flash('.cn-menu-btn[data-btn="start"]');+ nextCart();+ return;+ }+ if (key === ' ') {+ e.preventDefault();+ flash('.cn-menu-btn[data-btn="select"]');+ nextEnv();+ return;+ }+ if (key === 'q') {+ flash('#cn-l');+ selectAgent(state.index - 1);+ return;+ }+ if (key === 'e') {+ flash('#cn-r');+ selectAgent(state.index + 1);+ return;+ }+ if (key === 'p') setPower(!state.power);+});++window.addEventListener('keyup', (e) => {+ const key = e.key.toLowerCase();+ const dir = KEY_DIRS[key];+ if (dir) setDir(dir, false);+ if (key === 'shift') {+ held.run = false;+ pushVector();+ }+});++window.addEventListener('blur', releaseAll);++// ── gamepad ───────────────────────────────────────────────────────────────+// Polled only while a pad is actually connected, so an unused page costs no+// frames. Standard mapping: sticks + D-pad walk, A/B gesture, triggers run,+// shoulders change cartridge, start/select mirror the console's own buttons.++const padPrev = new Map();+let padRaf = 0;++function pollPads() {+ const pads = navigator.getGamepads ? navigator.getGamepads() : [];+ let live = false;+ for (const pad of pads) {+ if (!pad) continue;+ live = true;+ const prev = padPrev.get(pad.index) || {};+ const now = {};+ const ax = pad.axes[0] || 0;+ const ay = pad.axes[1] || 0;+ const dead = 0.22;+ const dpad = {+ up: pad.buttons[12]?.pressed || ay < -dead,+ down: pad.buttons[13]?.pressed || ay > dead,+ left: pad.buttons[14]?.pressed || ax < -dead,+ right: pad.buttons[15]?.pressed || ax > dead,+ };+ for (const dir of ['up', 'down', 'left', 'right']) {+ now[dir] = dpad[dir];+ if (dpad[dir] !== !!prev[dir]) setDir(dir, dpad[dir]);+ }+ const run = !!(pad.buttons[6]?.pressed || pad.buttons[7]?.pressed);+ if (run !== !!prev.run && state.cart === 'play') {+ held.run = run;+ pushVector();+ }+ now.run = run;++ const edge = (i, fn) => {+ const pressed = !!pad.buttons[i]?.pressed;+ now[`b${i}`] = pressed;+ if (pressed && !prev[`b${i}`]) fn();+ };+ edge(0, () => {+ flash('.cn-face-btn[data-btn="a"]');+ pressFace('a');+ });+ edge(1, () => {+ flash('.cn-face-btn[data-btn="b"]');+ pressFace('b');+ });+ edge(4, () => {+ flash('#cn-l');+ selectAgent(state.index - 1);+ });+ edge(5, () => {+ flash('#cn-r');+ selectAgent(state.index + 1);+ });+ edge(8, () => {+ flash('.cn-menu-btn[data-btn="select"]');+ nextEnv();+ });+ edge(9, () => {+ flash('.cn-menu-btn[data-btn="start"]');+ nextCart();+ });+ padPrev.set(pad.index, now);+ }+ el.gamepadPill.dataset.on = live ? '1' : '0';+ padRaf = live ? requestAnimationFrame(pollPads) : 0;+}++window.addEventListener('gamepadconnected', () => {+ el.gamepadPill.dataset.on = '1';+ announce('controller connected');+ if (!padRaf) padRaf = requestAnimationFrame(pollPads);+});++window.addEventListener('gamepaddisconnected', (e) => {+ padPrev.delete(e.gamepad?.index);+ releaseAll();+});++// ── tilt ──────────────────────────────────────────────────────────────────++if (canHover && !reduceMotion) {+ const stage = el.device.parentElement;+ stage.addEventListener('pointermove', (e) => {+ const rect = el.device.getBoundingClientRect();+ const px = (e.clientX - rect.left) / rect.width - 0.5;+ const py = (e.clientY - rect.top) / rect.height - 0.5;+ el.device.style.transform = `rotateX(${(-py * TILT_MAX_DEG).toFixed(2)}deg) rotateY(${(px * TILT_MAX_DEG).toFixed(2)}deg)`;+ });+ stage.addEventListener('pointerleave', () => {+ el.device.style.transform = '';+ });+}++// ── share, embed, url state ───────────────────────────────────────────────++function shareUrl() {+ const agent = currentAgent();+ const q = new URLSearchParams();+ if (agent) q.set('agent', agent.id);+ q.set('shell', state.shell);+ q.set('env', state.env);+ return `${location.origin}/console?${q.toString()}`;+}++function embedCode() {+ const url = new URL(shareUrl());+ url.searchParams.set('chrome', 'off');+ const agent = currentAgent();+ const title = agent ? `${agent.name} on three.ws` : 'three.ws Agent Console';+ return `<iframe src="${url.toString()}" width="440" height="700" title="${title}" style="border:0;background:transparent" allow="xr-spatial-tracking" loading="lazy"></iframe>`;+}++function renderEmbed() {+ if (el.embedCode) el.embedCode.textContent = embedCode();+}++function syncUrl() {+ if (chromeOff) return;+ const url = new URL(location.href);+ const agent = currentAgent();+ if (agent) url.searchParams.set('agent', agent.id);+ url.searchParams.set('shell', state.shell);+ url.searchParams.set('env', state.env);+ if (state.cart !== 'play') url.searchParams.set('cart', state.cart);+ else url.searchParams.delete('cart');+ history.replaceState(null, '', url);+}++async function copy(text, message) {+ try {+ await navigator.clipboard.writeText(text);+ toast(message);+ } catch {+ const area = document.createElement('textarea');+ area.value = text;+ area.setAttribute('readonly', '');+ area.style.position = 'fixed';+ area.style.opacity = '0';+ document.body.appendChild(area);+ area.select();+ const ok = document.execCommand('copy');+ area.remove();+ toast(ok ? message : 'Copy failed. Select the text and copy it manually.');+ }+}++let toastTimer = 0;+function toast(message) {+ el.toast.textContent = message;+ el.toast.dataset.on = '1';+ clearTimeout(toastTimer);+ toastTimer = setTimeout(() => {+ el.toast.dataset.on = '0';+ }, 2600);+}++function announce(message) {+ el.live.textContent = message;+}++document.getElementById('cn-share')?.addEventListener('click', () => {+ copy(shareUrl(), 'Share link copied.');+});++document.getElementById('cn-copy-embed')?.addEventListener('click', () => {+ copy(embedCode(), 'Embed code copied.');+});++document.getElementById('cn-post')?.addEventListener('click', () => {+ const agent = currentAgent();+ const who = agent ? agent.name : 'My agent';+ const text = `${who} lives in a handheld now. Real 3D, the D-pad actually works, built on @trythreews`;+ const url = `https://x.com/intent/post?text=${encodeURIComponent(text)}&url=${encodeURIComponent(shareUrl())}`;+ window.open(url, '_blank', 'noopener');+});++document.querySelectorAll('.cn-tab[data-shell]').forEach((tab) => {+ tab.addEventListener('click', () => setShell(tab.dataset.shell));+});+document.querySelectorAll('.cn-tab[data-cart]').forEach((tab) => {+ tab.addEventListener('click', () => setCart(tab.dataset.cart));+});+document.querySelectorAll('.cn-tab[data-env]').forEach((tab) => {+ tab.addEventListener('click', () => setEnv(tab.dataset.env));+});++// ── boot ──────────────────────────────────────────────────────────────────++if (chromeOff) document.body.dataset.chrome = 'off';+setShell(state.shell);+setCart(state.cart);+setEnv(state.env);+renderEmbed();+loadRoster();diff --git a/src/walk-embed.js b/src/walk-embed.jsindex 5ffa45822..88d9111c2 100644--- a/src/walk-embed.js+++ b/src/walk-embed.js@@ -64,6 +64,16 @@ const SPEED_PARAM = (() => {if (!Number.isFinite(n)) return 1.0;return Math.min(3, Math.max(0.3, n));})();+// Camera pull-in. The chase camera frames the avatar from `height * 1.95` back+// by default, which reads well full-bleed but leaves a lot of empty sky when the+// embed is squeezed into a small 4:3 window (the /console handheld screen). A+// host passes ?zoom=0.5..2 to scale that distance and eye height; 1 is the+// untouched default, below 1 pulls in.+const ZOOM_PARAM = (() => {+ const n = Number(params.get('zoom'));+ if (!Number.isFinite(n)) return 1.0;+ return Math.min(2, Math.max(0.5, n));+})();// Attribution badge ships by default — the embed is the distribution channel, so// every dropped avatar links home. `?badge=false` removes it (paid/whitelabel).const SHOW_BADGE = params.get('badge') !== 'false' && params.get('badge') !== '0';@@ -625,7 +635,7 @@ async function loadAvatar() {avatarRig.add(avatar);const height = Math.max(0.5, box.max.y - box.min.y);- CAM_OFFSET.set(0, height * 1.05, height * 1.95);+ CAM_OFFSET.set(0, height * 1.05 * ZOOM_PARAM, height * 1.95 * ZOOM_PARAM);CAM_LOOK_OFFSET.set(0, height * 0.6, 0);applyCameraImmediate();@@ -960,7 +970,7 @@ const runtime = {avatar.position.y -= box.min.y;avatarRig.add(avatar);const height = Math.max(0.5, box.max.y - box.min.y);- CAM_OFFSET.set(0, height * 1.05, height * 1.95);+ CAM_OFFSET.set(0, height * 1.05 * ZOOM_PARAM, height * 1.95 * ZOOM_PARAM);CAM_LOOK_OFFSET.set(0, height * 0.6, 0);applyCameraImmediate();animationManager.attach(avatar);