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: add solana wallet address and vanity pattern to character and trending APIs; update changelog and add tests for vanity wallet functionality
roundtripped8e7ea7fff5b2
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 659801005..fef53db00 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -7,10 +7,13 @@ Public history for [three.ws](https://three.ws), newest first. New pages come fr## 2026-06-19- **Agent wallet's full money loop is now verified end-to-end on devnet** — A re-runnable harness now exercises the entire agent-wallet lifecycle in one pass — create a wallet, fund it, trade and snipe pump.fun tokens, pay an x402 service, exit a graduated position, and withdraw — against real Solana devnet state. It runs simulate-first and reports each step as passed or honestly blocked on funding/credentials, never a fake result, so regressions in the seams between deposit, trading, sniping, payments, and withdrawal surface before they reach holders. The agent wallet hub's Snipe tab now opens the live Sniper dashboard directly instead of a placeholder. (`/agent-wallet`) `[infra]`+- **Align a whole room of agents in one gesture** — When you place several agents around a room, their spacing is already exact for everyone — but the whole cluster can sit a few metres off where it really is, because phone GPS only knows the spot to within several metres. Now you can fix that in one move: open any of your room agents and tap “Align this room,” then drag to slide the entire group onto its true spot and twist with two fingers to rotate it — every agent moves together, keeping its layout intact, instead of nudging them one at a time. A live readout shows the move in honest metres and degrees, and the room is labelled with how tightly it's anchored so you know when it's worth aligning. Only the room's owner can move it. And if you arrive at a room someone placed without a compass that looks turned the wrong way, a one-tap “Align to your view” straightens it out for you. (`/irl`) `[improvement]`- **AR & half-body avatar export fixed for compressed models** — View-in-AR (USDZ for iOS Quick Look) and the half-body VR-seat export now work for avatars that ship with meshopt or Draco geometry compression. Previously these exports silently failed on compressed GLBs because the loader had no decoder registered; the pipeline now loads the meshopt and Draco decoders before parsing, so every avatar — including the compressed ones produced by the server-side bake — converts cleanly. (`/gallery`) `[fix]`+- **AR agents hold their place and size when you rotate your phone** — Camera AR used to assume you were holding your phone upright. Rotate to landscape — or just have the browser's toolbar slide away as you scroll — and a pinned agent could quietly change size or drift off the real-world spot you placed it on. IRL now re-reads your camera's lens and your screen's orientation the instant either changes, so the agent keeps its true scale and stays locked to its spot whether you hold the phone portrait or sideways. The motion-sensor lock that rotates the view as you turn now understands landscape too, so panning around the agent stays smooth and accurate, and the rapid resizing iPhone Safari does while scrolling no longer makes the scene stutter. (`/irl`) `[improvement, fix]`- **Clearer IRL onboarding and copy** — Opening IRL for the first time now spells out the core loop in plain words: turn on Camera AR, aim at the spot you want, then tap Pin here to anchor your agent in real space. The on-screen guidance updates as you go — it points you to the next step before you've pinned, and confirms when your agent is anchored. We rewrote the status messages around pinning to be calm and literal instead of technical or alarming: waiting on a GPS fix now tells you it's quicker outdoors, pinning without location explains your agent is saved on this device until you turn location on, and a missing compass reads as a gentle note rather than a warning. The caption keyboard now opens reliably when the panel slides up on iPhone. (`/irl`) `[improvement]`- **Creator royalty payouts protected against double-settlement** — Royalty payouts to skill authors now claim each pending amount atomically before sending funds on-chain, so two overlapping settlement runs can never pay the same balance twice. Creators are paid exactly once for what they've earned. `[fix]`- **Discovery now shows only real creator avatars** — The Explore / discovery feed previously padded itself with a set of built-in sample avatars and counted them in the totals. The feed and its counts now reflect only real avatars created by the community — no filler. (`/explore`) `[improvement]`+- **Drop agents on your real floor with AR precision** — On Android phones that support AR, placing an agent in your room is now pinpoint: point at the floor, a reticle locks onto the real ground, and you tap to drop the agent exactly where you're looking — feet on the actual floor, not floating at a guess. It anchors into the same shared room as the rest of your agents, so everyone who opens IRL at that spot — including iPhones — sees it in the same place, and you can re-tap “Refine on floor” on one of your agents to sharpen just its spot without nudging the others. iPhones and phones without AR keep the aim-and-distance flow they already had, with no extra buttons and nothing that doesn't work — every device gets the best placement it can do. (`/irl`) `[feature]`- **Every IRL moment now has a designed, honest state** — IRL asks for the three most sensitive permissions a web app can — camera, motion, and location — and we made every moment around them feel deliberate instead of uncertain. While your phone is still finding your GPS fix, the top bar shows a clear "Finding your location…" shimmer so the wait never looks like an empty, nobody-here screen. If discovery ever has to slow down to catch its breath, you get a calm "catching up…" note that quietly recovers on its own — never a scary error. The live-presence indicator stays honest too: when it drops, nearby discovery keeps working and nothing implies otherwise. Every control is now reachable by keyboard with a visible focus ring, screen readers announce each state change once, and all of it respects reduced-motion settings. (`/irl`) `[improvement]`- **Every page now shares with its own social card** — Share any three.ws page on X, Discord, Slack, iMessage, or LinkedIn and the link now previews with a branded card built for that exact page — its title, its one-line description, and a colour that matches the section it belongs to — instead of one generic image for the whole site. The cards render as real PNGs so they show up everywhere (not just the apps that handle SVG), and they're generated on the fly from the same page catalog that feeds the sitemap, so the preview always matches what's actually on the page. We also tightened the behind-the-scenes SEO on every page: cleaner canonical links, richer structured data with breadcrumbs, and crawler hints that let search engines show large image previews. `[improvement, infra]`- **Fixed broken links and added retry on failed loads across the app** — Several navigation links pointed at pages that no longer exist — "View plans" on the agent deploy flow, the Classic viewer menu item, and the API-key links on the AWS welcome and selfie pages — and now go to the right place. List pages that could get stuck showing a blank grid or endless skeletons on a network hiccup (your collection, a coin's community profile, the bounty board, the agents directory) now show a clear, retryable error instead. The $THREE dashboard also replaced a non-working "claim" button with a plain explanation that revenue share is distributed to holders automatically. `[fix, improvement]`@@ -36,6 +39,7 @@ Public history for [three.ws](https://three.ws), newest first. New pages come fr- **Tapping an agent in AR now lands every time** — Inspecting an agent in IRL AR is a tap — and we made that tap far harder to miss. There's now a finger-sized catch zone around each agent's floating name, so a tap that lands just beside a small or distant agent still opens its card instead of doing nothing. When several agents overlap on screen, your tap resolves to the one in front of you, and it never selects an agent that's behind you or off-screen. We also kept agents from vanishing when you bring your phone right up to one to look closely. Inspecting works whether the agent is centered, near the edge of the frame, close, or far. (`/irl`) `[improvement]`- **Token Oracle follow / unfollow is working again** — Subscribing an agent to a token's oracle alerts — and unsubscribing — was silently failing for everyone; only the status check worked. Both now go through correctly, so you can opt an agent into (and out of) score-based alerts as intended. `[fix]`- **Unity & Unreal avatar loading documented with code that actually works** — The developer hub's Unity and Unreal cards used to show sample code for an SDK that doesn't exist yet. They now show the real, working way to load a three.ws avatar today — your avatar's GLB endpoint loaded at runtime with glTFast (Unity) or glTFRuntime (Unreal), both standard glTF importers — alongside an honest note that a native package is still on the roadmap. (`/dashboard/developers`) `[docs, improvement]`+- **Vanity wallets for every agent — opt-in, owned per user** — Every agent and avatar has its own custodial Solana wallet, and you own it per creation: make an avatar and its agent wallet is yours; if someone forks or saves that avatar, they get a brand-new wallet they alone control — yours is never shared or copied. A new Vanity tab in the agent wallet hub lets you grind a custom address (your own prefix and/or suffix) on demand. If the wallet already holds funds, they're automatically and safely swept to the new address before the switch completes, so funds are never stranded. The wallet now appears everywhere an agent or avatar shows up — profiles, avatar pages, your Agents and Avatars dashboards, the Characters feed and Trending — each with one-tap copy, an explorer link, and a vanity badge. (`/vanity-wallet`) `[feature]`## 2026-06-18diff --git a/api/characters.js b/api/characters.jsindex 79f0330b1..6c38e49f7 100644--- a/api/characters.js+++ b/api/characters.js@@ -99,6 +99,12 @@ export default wrap(async (req, res) => {author_username: row.author_username || null,author_avatar: row.author_avatar || null,chat_count: row.chat_count,+ // Public custodial wallet address (same value GET /api/agents/:id/solana+ // serves anonymously) + its vanity pattern, so the shared wallet chip can+ // render on character cards. The signing secret never leaves the server.+ solana_address: typeof meta.solana_address === 'string' ? meta.solana_address : null,+ solana_vanity_prefix: meta.solana_vanity_prefix || null,+ solana_vanity_suffix: meta.solana_vanity_suffix || null,token: token? {symbol: token.symbol || null,diff --git a/api/trending.js b/api/trending.jsindex 2e2e9eaf8..89f86291d 100644--- a/api/trending.js+++ b/api/trending.js@@ -95,6 +95,10 @@ export default wrap(async (req, res) => {chat_count: Number(r.chat_count) || 0,window_chats: Number(r.window_chats) || null,is_onchain: isOnchain,+ // Public custodial wallet + vanity pattern for the shared wallet chip.+ solana_address: typeof meta.solana_address === 'string' ? meta.solana_address : null,+ solana_vanity_prefix: meta.solana_vanity_prefix || null,+ solana_vanity_suffix: meta.solana_vanity_suffix || null,agent_url: `https://three.ws/agent/${encodeURIComponent(r.id)}`,};});diff --git a/data/changelog.json b/data/changelog.jsonindex 622ce57db..80af4cfe7 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-19",+ "title": "Vanity wallets for every agent — opt-in, owned per user",+ "summary": "Every agent and avatar has its own custodial Solana wallet, and you own it per creation: make an avatar and its agent wallet is yours; if someone forks or saves that avatar, they get a brand-new wallet they alone control — yours is never shared or copied. A new Vanity tab in the agent wallet hub lets you grind a custom address (your own prefix and/or suffix) on demand. If the wallet already holds funds, they're automatically and safely swept to the new address before the switch completes, so funds are never stranded. The wallet now appears everywhere an agent or avatar shows up — profiles, avatar pages, your Agents and Avatars dashboards, the Characters feed and Trending — each with one-tap copy, an explorer link, and a vanity badge.",+ "tags": [+ "feature"+ ],+ "link": "/vanity-wallet"+ },+ {+ "date": "2026-06-19",+ "title": "Align a whole room of agents in one gesture",+ "summary": "When you place several agents around a room, their spacing is already exact for everyone — but the whole cluster can sit a few metres off where it really is, because phone GPS only knows the spot to within several metres. Now you can fix that in one move: open any of your room agents and tap “Align this room,” then drag to slide the entire group onto its true spot and twist with two fingers to rotate it — every agent moves together, keeping its layout intact, instead of nudging them one at a time. A live readout shows the move in honest metres and degrees, and the room is labelled with how tightly it's anchored so you know when it's worth aligning. Only the room's owner can move it. And if you arrive at a room someone placed without a compass that looks turned the wrong way, a one-tap “Align to your view” straightens it out for you.",+ "tags": [+ "improvement"+ ],+ "link": "/irl"+ },{"date": "2026-06-19","title": "Drop agents on your real floor with AR precision",diff --git a/pages/trending.html b/pages/trending.htmlindex a2191d2c0..c029f98c8 100644--- a/pages/trending.html+++ b/pages/trending.html@@ -272,6 +272,7 @@</style><script type="module">+ import { walletChipHTML } from '/src/shared/agent-wallet-chip.js';const $ = (s) => document.querySelector(s);const $$ = (s) => document.querySelectorAll(s);const esc = (s) => String(s ?? '').replace(/[&<>"']/g, (c) =>@@ -365,6 +366,7 @@<span class="tr-body"><span class="tr-name">${esc(a.name || 'Unnamed agent')}${onchainBadge}</span>${a.description ? `<span class="tr-desc">${esc(a.description)}</span>` : ''}+ ${a.solana_address ? `<span class="tr-wallet" style="margin-top:4px;display:inline-flex">${walletChipHTML(a, { link: false, showPending: false })}</span>` : ''}</span><span class="tr-meta"><span class="tr-metric">${fmt(count)}</span>diff --git a/public/changelog.json b/public/changelog.jsonindex 3f5f75e4e..52e64f4c4 100644--- a/public/changelog.json+++ b/public/changelog.json@@ -1,5 +1,5 @@{- "generated_at": "2026-06-19T10:02:43.442Z",+ "generated_at": "2026-06-19T10:19:18.628Z","generated_by": "scripts/build-page-index.mjs from data/pages.json + data/changelog.json","site": {"name": "three.ws",@@ -16,6 +16,16 @@"infra"]},+ {+ "date": "2026-06-19",+ "type": "update",+ "title": "Align a whole room of agents in one gesture",+ "summary": "When you place several agents around a room, their spacing is already exact for everyone — but the whole cluster can sit a few metres off where it really is, because phone GPS only knows the spot to within several metres. Now you can fix that in one move: open any of your room agents and tap “Align this room,” then drag to slide the entire group onto its true spot and twist with two fingers to rotate it — every agent moves together, keeping its layout intact, instead of nudging them one at a time. A live readout shows the move in honest metres and degrees, and the room is labelled with how tightly it's anchored so you know when it's worth aligning. Only the room's owner can move it. And if you arrive at a room someone placed without a compass that looks turned the wrong way, a one-tap “Align to your view” straightens it out for you.",+ "link": "/irl",+ "tags": [+ "improvement"+ ]+ },{"date": "2026-06-19","type": "update",@@ -26,6 +36,17 @@"fix"]},+ {+ "date": "2026-06-19",+ "type": "update",+ "title": "AR agents hold their place and size when you rotate your phone",+ "summary": "Camera AR used to assume you were holding your phone upright. Rotate to landscape — or just have the browser's toolbar slide away as you scroll — and a pinned agent could quietly change size or drift off the real-world spot you placed it on. IRL now re-reads your camera's lens and your screen's orientation the instant either changes, so the agent keeps its true scale and stays locked to its spot whether you hold the phone portrait or sideways. The motion-sensor lock that rotates the view as you turn now understands landscape too, so panning around the agent stays smooth and accurate, and the rapid resizing iPhone Safari does while scrolling no longer makes the scene stutter.",+ "link": "/irl",+ "tags": [+ "improvement",+ "fix"+ ]+ },{"date": "2026-06-19","type": "update",@@ -56,6 +77,16 @@"improvement"]},+ {+ "date": "2026-06-19",+ "type": "update",+ "title": "Drop agents on your real floor with AR precision",+ "summary": "On Android phones that support AR, placing an agent in your room is now pinpoint: point at the floor, a reticle locks onto the real ground, and you tap to drop the agent exactly where you're looking — feet on the actual floor, not floating at a guess. It anchors into the same shared room as the rest of your agents, so everyone who opens IRL at that spot — including iPhones — sees it in the same place, and you can re-tap “Refine on floor” on one of your agents to sharpen just its spot without nudging the others. iPhones and phones without AR keep the aim-and-distance flow they already had, with no extra buttons and nothing that doesn't work — every device gets the best placement it can do.",+ "link": "/irl",+ "tags": [+ "feature"+ ]+ },{"date": "2026-06-19","type": "update",@@ -315,6 +346,16 @@"improvement"]},+ {+ "date": "2026-06-19",+ "type": "update",+ "title": "Vanity wallets for every agent — opt-in, owned per user",+ "summary": "Every agent and avatar has its own custodial Solana wallet, and you own it per creation: make an avatar and its agent wallet is yours; if someone forks or saves that avatar, they get a brand-new wallet they alone control — yours is never shared or copied. A new Vanity tab in the agent wallet hub lets you grind a custom address (your own prefix and/or suffix) on demand. If the wallet already holds funds, they're automatically and safely swept to the new address before the switch completes, so funds are never stranded. The wallet now appears everywhere an agent or avatar shows up — profiles, avatar pages, your Agents and Avatars dashboards, the Characters feed and Trending — each with one-tap copy, an explorer link, and a vanity badge.",+ "link": "/vanity-wallet",+ "tags": [+ "feature"+ ]+ },{"date": "2026-06-18","type": "update",diff --git a/public/changelog.xml b/public/changelog.xmlindex 249880c81..aec758810 100644--- a/public/changelog.xml+++ b/public/changelog.xml@@ -14,6 +14,14 @@<category>infra</category><description>A re-runnable harness now exercises the entire agent-wallet lifecycle in one pass — create a wallet, fund it, trade and snipe pump.fun tokens, pay an x402 service, exit a graduated position, and withdraw — against real Solana devnet state. It runs simulate-first and reports each step as passed or honestly blocked on funding/credentials, never a fake result, so regressions in the seams between deposit, trading, sniping, payments, and withdrawal surface before they reach holders. The agent wallet hub's Snipe tab now opens the live Sniper dashboard directly instead of a placeholder.</description></item>+ <item>+ <title>Align a whole room of agents in one gesture</title>+ <link>https://three.ws/irl</link>+ <guid isPermaLink="false">2026-06-19:Align a whole room of agents in one gesture</guid>+ <pubDate>Fri, 19 Jun 2026 12:00:00 GMT</pubDate>+ <category>improvement</category>+ <description>When you place several agents around a room, their spacing is already exact for everyone — but the whole cluster can sit a few metres off where it really is, because phone GPS only knows the spot to within several metres. Now you can fix that in one move: open any of your room agents and tap “Align this room,” then drag to slide the entire group onto its true spot and twist with two fingers to rotate it — every agent moves together, keeping its layout intact, instead of nudging them one at a time. A live readout shows the move in honest metres and degrees, and the room is labelled with how tightly it's anchored so you know when it's worth aligning. Only the room's owner can move it. And if you arrive at a room someone placed without a compass that looks turned the wrong way, a one-tap “Align to your view” straightens it out for you.</description>+ </item><item><title>AR & half-body avatar export fixed for compressed models</title><link>https://three.ws/gallery</link>@@ -22,6 +30,14 @@<category>fix</category><description>View-in-AR (USDZ for iOS Quick Look) and the half-body VR-seat export now work for avatars that ship with meshopt or Draco geometry compression. Previously these exports silently failed on compressed GLBs because the loader had no decoder registered; the pipeline now loads the meshopt and Draco decoders before parsing, so every avatar — including the compressed ones produced by the server-side bake — converts cleanly.</description></item>+ <item>+ <title>AR agents hold their place and size when you rotate your phone</title>+ <link>https://three.ws/irl</link>+ <guid isPermaLink="false">2026-06-19:AR agents hold their place and size when you rotate your phone</guid>+ <pubDate>Fri, 19 Jun 2026 12:00:00 GMT</pubDate>+ <category>improvement</category>+ <description>Camera AR used to assume you were holding your phone upright. Rotate to landscape — or just have the browser's toolbar slide away as you scroll — and a pinned agent could quietly change size or drift off the real-world spot you placed it on. IRL now re-reads your camera's lens and your screen's orientation the instant either changes, so the agent keeps its true scale and stays locked to its spot whether you hold the phone portrait or sideways. The motion-sensor lock that rotates the view as you turn now understands landscape too, so panning around the agent stays smooth and accurate, and the rapid resizing iPhone Safari does while scrolling no longer makes the scene stutter.</description>+ </item><item><title>Clearer IRL onboarding and copy</title><link>https://three.ws/irl</link>@@ -46,6 +62,14 @@<category>improvement</category><description>The Explore / discovery feed previously padded itself with a set of built-in sample avatars and counted them in the totals. The feed and its counts now reflect only real avatars created by the community — no filler.</description></item>+ <item>+ <title>Drop agents on your real floor with AR precision</title>+ <link>https://three.ws/irl</link>+ <guid isPermaLink="false">2026-06-19:Drop agents on your real floor with AR precision</guid>+ <pubDate>Fri, 19 Jun 2026 12:00:00 GMT</pubDate>+ <category>feature</category>+ <description>On Android phones that support AR, placing an agent in your room is now pinpoint: point at the floor, a reticle locks onto the real ground, and you tap to drop the agent exactly where you're looking — feet on the actual floor, not floating at a guess. It anchors into the same shared room as the rest of your agents, so everyone who opens IRL at that spot — including iPhones — sees it in the same place, and you can re-tap “Refine on floor” on one of your agents to sharpen just its spot without nudging the others. iPhones and phones without AR keep the aim-and-distance flow they already had, with no extra buttons and nothing that doesn't work — every device gets the best placement it can do.</description>+ </item><item><title>Every IRL moment now has a designed, honest state</title><link>https://three.ws/irl</link>@@ -246,6 +270,14 @@<category>docs</category><description>The developer hub's Unity and Unreal cards used to show sample code for an SDK that doesn't exist yet. They now show the real, working way to load a three.ws avatar today — your avatar's GLB endpoint loaded at runtime with glTFast (Unity) or glTFRuntime (Unreal), both standard glTF importers — alongside an honest note that a native package is still on the roadmap.</description></item>+ <item>+ <title>Vanity wallets for every agent — opt-in, owned per user</title>+ <link>https://three.ws/vanity-wallet</link>+ <guid isPermaLink="false">2026-06-19:Vanity wallets for every agent — opt-in, owned per user</guid>+ <pubDate>Fri, 19 Jun 2026 12:00:00 GMT</pubDate>+ <category>feature</category>+ <description>Every agent and avatar has its own custodial Solana wallet, and you own it per creation: make an avatar and its agent wallet is yours; if someone forks or saves that avatar, they get a brand-new wallet they alone control — yours is never shared or copied. A new Vanity tab in the agent wallet hub lets you grind a custom address (your own prefix and/or suffix) on demand. If the wallet already holds funds, they're automatically and safely swept to the new address before the switch completes, so funds are never stranded. The wallet now appears everywhere an agent or avatar shows up — profiles, avatar pages, your Agents and Avatars dashboards, the Characters feed and Trending — each with one-tap copy, an explorer link, and a vanity badge.</description>+ </item><item><title>Agent economy demos now show honest run status</title><link>https://three.ws/live</link>diff --git a/public/features.json b/public/features.jsonindex 96949420e..b0efe63a3 100644--- a/public/features.json+++ b/public/features.json@@ -1,5 +1,5 @@{- "generated_at": "2026-06-19T10:02:43.304Z",+ "generated_at": "2026-06-19T10:19:18.585Z","generated_by": "scripts/build-page-index.mjs from data/pages.json","site": {"name": "three.ws",diff --git a/src/characters.js b/src/characters.jsindex b50d2d033..ebaf94015 100644--- a/src/characters.js+++ b/src/characters.js@@ -5,6 +5,8 @@* Each card links to /character/:id. Supports search, sort, and load-more.*/+import { walletChipHTML } from './shared/agent-wallet-chip.js';+let state = { cursor: null, loading: false, sort: 'new', q: '' };function formatNum(n) {@@ -96,6 +98,7 @@ function cardHtml(ch) {${ch.description ? `<p class="chs-card-desc">${escHtml(ch.description)}</p>` : ''}${statsHtml}${tokenHtml}+ ${ch.solana_address ? `<div class="chs-card-wallet" style="margin-top:8px">${walletChipHTML(ch, { link: false, showPending: false })}</div>` : ''}</a>`;}diff --git a/src/irl.js b/src/irl.jsindex b512253e1..4b2d139ad 100644--- a/src/irl.js+++ b/src/irl.js@@ -55,7 +55,7 @@ import { reserveWebGLContext, releaseWebGLContext } from './webgl-budget.js';import { detectTier, BUDGETS, TIER_ORDER, shiftTier } from './irl/perf-budget.js';import { sharedGLTFLoader, createLoadQueue } from './irl/load-queue.js';import { roomOriginWorld, agentWorldPosition, localToGeo, calibrateRoomOrigin } from './irl/room-anchor.js';-import { anchorPoseToPin, yawDegFromQuat } from './irl/floor-anchor.js';+import { anchorPoseToPin, yawDegFromQuat, roomPlacementFromHit, roomRelFromGeo } from './irl/floor-anchor.js';import { initRoomMode } from './irl/room-mode.js';import { createRoomGhost } from './irl/room-ghost.js';import { isFiniteReading, isCompassFresh, shouldUseAbsoluteYaw, resolveLockYaw, clampPitch, screenPitchDeg } from './irl/sensor-fusion.js';diff --git a/tests/agent-wallet-vanity.test.js b/tests/agent-wallet-vanity.test.jsnew file mode 100644index 000000000..7b2493936--- /dev/null+++ b/tests/agent-wallet-vanity.test.js@@ -0,0 +1,96 @@+// Per-agent vanity wallet — the grind primitive and the shared wallet chip.+//+// Covers the two pure pieces of the opt-in vanity feature that don't need a DB+// or an RPC: the server-side keypair grinder (api/_lib/pump-vanity.js, also used+// by POST /api/agents/:id/solana/vanity) and the wallet-chip status normalizer+// every agent/avatar surface renders from (src/shared/agent-wallet-chip.js).++import { describe, it, expect } from 'vitest';++import { grindMintKeypair, estimateAttempts, isValidVanityPrefix, BASE58_ALPHABET } from '../api/_lib/pump-vanity.js';+import { getWalletStatus, hasWallet, walletChipHTML } from '../src/shared/agent-wallet-chip.js';++describe('grindMintKeypair', () => {+ it('finds an address with the requested prefix', async () => {+ // One base58 char ≈ 58 attempts expected — comfortably inside the cap.+ const { keypair, iterations } = await grindMintKeypair({ prefix: 'a', ignoreCase: true, maxIterations: 200_000 });+ const addr = keypair.publicKey.toBase58();+ expect(addr.toLowerCase().startsWith('a')).toBe(true);+ expect(iterations).toBeGreaterThan(0);+ });++ it('finds an address with the requested suffix', async () => {+ const { keypair } = await grindMintKeypair({ suffix: 'z', ignoreCase: true, maxIterations: 200_000 });+ expect(keypair.publicKey.toBase58().toLowerCase().endsWith('z')).toBe(true);+ });++ it('honours case-sensitive prefixes exactly', async () => {+ const { keypair } = await grindMintKeypair({ prefix: 'A', ignoreCase: false, maxIterations: 500_000 });+ expect(keypair.publicKey.toBase58().startsWith('A')).toBe(true);+ });++ it('rejects non-base58 patterns', async () => {+ // 0, O, I, l are not in the base58 alphabet.+ await expect(grindMintKeypair({ prefix: '0' })).rejects.toThrow();+ expect(BASE58_ALPHABET).not.toContain('0');+ expect(isValidVanityPrefix('0')).toBe(false);+ expect(isValidVanityPrefix('ab')).toBe(true);+ });++ it('estimates difficulty as alphabet^length', () => {+ expect(estimateAttempts({ prefix: 'a' })).toBe(58);+ expect(estimateAttempts({ prefix: 'ab' })).toBe(58 * 58);+ // case-insensitive folds the alphabet to ~33 distinct buckets+ expect(estimateAttempts({ prefix: 'ab', ignoreCase: true })).toBe(33 * 33);+ });+});++describe('getWalletStatus / wallet chip', () => {+ const VANITY = 'agntSo1111111111111111111111111111111111ws';+ const PLAIN = '4Nd1mDQkSp9Xb6hT2pXc8QwJ5kR7yZ3aB9cD1eF2gH3';++ it('returns null when there is no solana wallet', () => {+ expect(getWalletStatus({ id: 'x' })).toBeNull();+ expect(hasWallet({ id: 'x' })).toBe(false);+ });++ it('reads the address from any record shape', () => {+ expect(getWalletStatus({ id: 'a', solana_address: PLAIN }).address).toBe(PLAIN);+ expect(getWalletStatus({ id: 'a', meta: { solana_address: PLAIN } }).address).toBe(PLAIN);+ expect(getWalletStatus({ id: 'a', wallet: PLAIN }).address).toBe(PLAIN);+ });++ it('detects vanity from top-level or meta fields', () => {+ const top = getWalletStatus({ id: 'a', solana_address: VANITY, solana_vanity_prefix: 'agnt', solana_vanity_suffix: 'ws' });+ expect(top.isVanity).toBe(true);+ expect(top.prefix).toBe('agnt');+ expect(top.suffix).toBe('ws');+ const viaMeta = getWalletStatus({ id: 'a', meta: { solana_address: VANITY, solana_vanity_prefix: 'agnt' } });+ expect(viaMeta.isVanity).toBe(true);+ expect(getWalletStatus({ id: 'a', solana_address: PLAIN }).isVanity).toBe(false);+ });++ it('renders an owner make-vanity entry point only for non-vanity owner wallets', () => {+ const ownerPlain = walletChipHTML({ id: 'agent-1', solana_address: PLAIN }, { isOwner: true });+ expect(ownerPlain).toContain('/agent/agent-1/wallet#vanity');+ expect(ownerPlain).toContain('data-twc-copy');++ const ownerVanity = walletChipHTML({ id: 'agent-1', solana_address: VANITY, solana_vanity_prefix: 'agnt' }, { isOwner: true });+ expect(ownerVanity).toContain('vanity');+ expect(ownerVanity).not.toContain('#vanity'); // already vanity — no upgrade CTA++ const visitor = walletChipHTML({ id: 'agent-1', solana_address: PLAIN }, { isOwner: false });+ expect(visitor).not.toContain('#vanity');+ });++ it('renders a pending chip when asked and no wallet exists', () => {+ expect(walletChipHTML({ id: 'a' }, { showPending: true })).toContain('Wallet pending');+ expect(walletChipHTML({ id: 'a' }, { showPending: false })).toBe('');+ });++ it('omits interactive controls in link:false mode (safe inside card anchors)', () => {+ const ro = walletChipHTML({ id: 'a', solana_address: PLAIN }, { link: false });+ expect(ro).not.toContain('data-twc-copy');+ expect(ro).not.toContain('<a');+ });+});diff --git a/tests/api/irl-pins-refine-rel.test.js b/tests/api/irl-pins-refine-rel.test.jsnew file mode 100644index 000000000..1645813f3--- /dev/null+++ b/tests/api/irl-pins-refine-rel.test.js@@ -0,0 +1,136 @@+// PATCH /api/irl/pins { calibrate: { …, relEast, relNorth } } — per-agent refine (R3).+//+// "Refine on floor" re-places ONE room agent from a fresh WebXR hit. A room pin+// renders from rel_east_m / rel_north_m (not the absolute lat/lng), so the calibrate+// PATCH must persist the new offset — otherwise the sharpened spot snaps back on the+// next viewer re-fetch. This suite pins that contract:+// • a room pin's calibrate updates rel_east_m / rel_north_m (the render-authoritative+// columns) and never touches the shared origin (origin_lat/lng stay put);+// • the offset move is bounded by the same A3 ceiling (±5 m) with the 422 code;+// • a non-room pin ignores rel (its absolute lat/lng stays authoritative).+// DB / auth / limiter / guardian are mocked so the suite stays offline.++import { describe, it, expect, vi, beforeEach } from 'vitest';++const ORIGIN = { lat: 40.7128, lng: -74.006 };+const ID = '11111111-1111-1111-1111-111111111111';++// The single pin the per-agent SELECT returns. Tests mutate it per case.+let thePin = null;+// Captured per-agent UPDATE: the joined query text + bound values, so we can assert+// what was written (and what was NOT — the origin must never appear).+let lastUpdate = null;++const sqlMock = vi.fn((strings, ...values) => {+ const q = Array.isArray(strings) ? strings.join(' ') : String(strings);+ // Per-agent calibrate SELECT (by id, carries rel_*; NOT the room_id= cluster read).+ if (/SELECT/i.test(q) && /WHERE id =/i.test(q) && /rel_east_m/i.test(q) && !/room_id =/i.test(q)) {+ return Promise.resolve(thePin ? [thePin] : []);+ }+ // The per-agent UPDATE … RETURNING (no unnest — that's the room path).+ if (/UPDATE irl_pins SET/i.test(q) && !/unnest/i.test(q)) {+ lastUpdate = { q, values };+ return Promise.resolve([{ id: ID }]);+ }+ return Promise.resolve([]); // DDL + anything else+});+vi.mock('../../api/_lib/db.js', () => ({ sql: (...a) => sqlMock(...a) }));+vi.mock('../../api/_lib/auth.js', () => ({ getSessionUser: vi.fn(async () => null) }));+vi.mock('../../api/_lib/rate-limit.js', () => ({+ limits: {+ irlPinIp: vi.fn(async () => ({ success: true })),+ irlPinBurst: vi.fn(async () => ({ success: true })),+ irlPinHourly: vi.fn(async () => ({ success: true })),+ publicIp: vi.fn(async () => ({ success: true })),+ },+ clientIp: () => '127.0.0.1',+}));+vi.mock('../../api/_lib/granite-guardian.js', () => ({+ guardianConfig: () => ({ configured: false }), assess: vi.fn(), decide: vi.fn(),+}));++let handler;++function makeRes() {+ return {+ statusCode: 200, _h: {}, headersSent: false, writableEnded: false,+ setHeader(k, v) { this._h[k.toLowerCase()] = v; },+ getHeader(k) { return this._h[k.toLowerCase()]; },+ end(body) { this.writableEnded = true; this._body = body; },+ };+}+async function patch(body, headers = {}) {+ const res = makeRes();+ await handler({ url: '/api/irl/pins', method: 'PATCH', headers: { host: 'x', ...headers }, query: {}, body }, res);+ let parsed = null; try { parsed = JSON.parse(res._body); } catch {}+ return { res, body: parsed };+}++// A room pin owned by device-A: couch 2 m east of the origin, true-north frame.+const roomPin = (token = 'device-A') => ({+ id: ID, user_id: null, device_token: token,+ lat: ORIGIN.lat, lng: ORIGIN.lng, heading: 90, anchor_yaw_deg: 90, anchor_height_m: 0,+ room_id: 'living-room-7', rel_east_m: 2, rel_north_m: 0, expires_at: null, hidden_at: null,+});++beforeEach(async () => {+ sqlMock.mockClear(); thePin = null; lastUpdate = null;+ vi.resetModules();+ ({ default: handler } = await import('../../api/irl/pins.js'));+});++describe('PATCH /api/irl/pins — per-agent floor refine (R3)', () => {+ it('updates rel_east_m / rel_north_m for a room pin and never moves the origin', async () => {+ thePin = roomPin();+ // Sharpen the couch agent from (2,0) to (2.4, 0.3) — well within the ±5 m ceiling.+ const next = { relEast: 2.4, relNorth: 0.3 };+ const { res, body } = await patch({+ id: ID, deviceToken: 'device-A',+ calibrate: { lat: ORIGIN.lat + 0.0000027, lng: ORIGIN.lng + 0.0000035, anchorHeightM: -1.4, ...next },+ });+ expect(res.statusCode).toBe(200);+ expect(body.calibrated).toBe(true);+ // The UPDATE set the room offset columns with the new values…+ expect(lastUpdate.q).toMatch(/rel_east_m\s*=/);+ expect(lastUpdate.q).toMatch(/rel_north_m\s*=/);+ expect(lastUpdate.values).toContain(2.4);+ expect(lastUpdate.values).toContain(0.3);+ // …and never touches the shared origin — refine sharpens one agent only.+ expect(lastUpdate.q).not.toMatch(/origin_lat\s*=/);+ expect(lastUpdate.q).not.toMatch(/origin_yaw_deg\s*=/);+ });++ it('rejects an offset move beyond the ±5 m ceiling (422), origin untouched', async () => {+ thePin = roomPin();+ // 9 m east of the stored (2,0) offset — a relocation, not a refine.+ const { res, body } = await patch({+ id: ID, deviceToken: 'device-A',+ calibrate: { lat: ORIGIN.lat, lng: ORIGIN.lng, relEast: 11, relNorth: 0 },+ });+ expect(res.statusCode).toBe(422);+ expect(body.error).toMatch(/move too large/i);+ expect(lastUpdate).toBeNull(); // nothing written+ });++ it('only the owner can refine — a stranger device is denied (403)', async () => {+ thePin = roomPin('device-A');+ const { res } = await patch({+ id: ID, deviceToken: 'device-B',+ calibrate: { lat: ORIGIN.lat, lng: ORIGIN.lng, relEast: 2.2, relNorth: 0 },+ });+ expect(res.statusCode).toBe(403);+ expect(lastUpdate).toBeNull();+ });++ it('a non-room pin ignores rel — its absolute lat/lng stays authoritative', async () => {+ thePin = { ...roomPin(), room_id: null, rel_east_m: null, rel_north_m: null };+ const { res } = await patch({+ id: ID, deviceToken: 'device-A',+ calibrate: { lat: ORIGIN.lat + 0.00001, lng: ORIGIN.lng, relEast: 2.4, relNorth: 0.3 },+ });+ expect(res.statusCode).toBe(200);+ // rel columns COALESCE to null (no change) — the bound rel values are absent.+ expect(lastUpdate.values).not.toContain(2.4);+ expect(lastUpdate.values).not.toContain(0.3);+ });+});