Skip to content

Open-source platform for 3D AI agents. Turn text or a photo into a rigged, animated GLB avatar, give it an LLM brain, memory and a wallet, and embed it anywhere with one web component. Remote MCP server, x402 payments, Three.js, browser-native.

studio: deposit/withdraw harness + multi-page polish

nirholas357fea97dd8b
diff --git a/.gitignore b/.gitignore
index 1613013b3..147110d7b 100644
--- a/.gitignore
+++ b/.gitignore
@@ -73,3 +73,4 @@ threews-launch-week-case-study.html
# GLB optimization backups (see scripts/optimize-glb.mjs)
*.glb.bak
+.secrets/
diff --git a/.studio-deposit-test.mjs b/.studio-deposit-test.mjs
new file mode 100644
index 000000000..0eb603a2a
--- /dev/null
+++ b/.studio-deposit-test.mjs
@@ -0,0 +1,117 @@
+import { chromium } from 'playwright';
+
+const ADDR = 'FYiw1234567890abcdefghijklmnopqrstuvwxyzNFYP';
+const browser = await chromium.launch();
+const ctx = await browser.newContext({ permissions: ['clipboard-read', 'clipboard-write'] });
+const page = await ctx.newPage();
+
+const myErrors = [];
+const ignoreUrl = (u) => /\/api\/(pump\/by-agent|auth\/wallets)/.test(u);
+page.on('pageerror', (e) => myErrors.push('PAGEERROR: ' + e.message));
+page.on('console', (m) => {
+ if (m.type() !== 'error') return;
+ const text = m.text();
+ if (/Failed to load resource/i.test(text)) return; // captured via response handler below
+ myErrors.push('CONSOLE: ' + text);
+});
+page.on('response', (r) => {
+ if (r.status() >= 400 && !ignoreUrl(r.url())) {
+ myErrors.push(`HTTP ${r.status()} ${r.url()}`);
+ }
+});
+
+await page.addInitScript((addr) => {
+ const pub = { toBase58: () => addr, toString: () => addr };
+ window.phantom = {
+ solana: {
+ isPhantom: true, isConnected: true, publicKey: pub,
+ connect: async () => ({ publicKey: pub }),
+ disconnect: async () => {},
+ on: () => {}, off: () => {},
+ },
+ };
+}, ADDR);
+
+await page.route('**/api/solana-rpc**', async (route) => {
+ const body = JSON.parse(route.request().postData() || '{}');
+ const result = body?.method === 'getBalance'
+ ? { context: { slot: 1 }, value: 16_000_000 }
+ : null;
+ await route.fulfill({
+ status: 200, contentType: 'application/json',
+ body: JSON.stringify({ jsonrpc: '2.0', id: body.id, result }),
+ });
+});
+
+await page.goto('http://localhost:3000/studio-deposit-harness.html', { waitUntil: 'domcontentloaded' });
+await page.waitForFunction(() => window.__ready === true, { timeout: 10000 });
+await page.waitForSelector('.lp-wallet-addr', { timeout: 10000 });
+
+const log = (k, v) => console.log(`${k}: ${JSON.stringify(v)}`);
+
+// 1. Bar address renders short
+log('SHORT_ADDR', await page.textContent('.lp-wallet-addr'));
+
+// 2. Bar copy works
+await page.click('.lp-wallet-addr');
+await page.waitForTimeout(150);
+log('BAR_CLIPBOARD_MATCH', (await page.evaluate(() => navigator.clipboard.readText())) === ADDR);
+log('BAR_FEEDBACK', await page.textContent('.lp-wallet-addr'));
+
+// Wait for label to restore
+await page.waitForFunction(() => !/Copied/.test(document.querySelector('.lp-wallet-addr').textContent), { timeout: 3000 });
+
+// 3. Open modal
+await page.click('#lp-deposit');
+await page.waitForSelector('.lp-dep');
+await page.waitForSelector('.lp-dep-qr canvas', { timeout: 15000 });
+
+// 4. QR loading spinner had role=status (was replaced by canvas, but check the markup)
+const spinnerCheck = await page.evaluate(() => {
+ const s = document.createElement('div');
+ s.className = 'lp-dep-qr-load';
+ // Read it from a freshly opened modal — instead check that the loader had role/aria via DOM history
+ return true;
+});
+
+// Grab focus-trap behavior: first focus should be the close button
+log('FIRST_FOCUS', await page.evaluate(() => document.activeElement?.id));
+
+// Tab — should land on the address copy region
+await page.keyboard.press('Tab');
+log('TAB1_FOCUS', await page.evaluate(() => document.activeElement?.id));
+
+// Tab again — wraps back to close button (focus trap)
+await page.keyboard.press('Tab');
+log('TAB2_FOCUS_WRAPS_TO_CLOSE', (await page.evaluate(() => document.activeElement?.id)) === 'lp-dep-close');
+
+// Shift+Tab — wraps backward to address
+await page.keyboard.press('Shift+Tab');
+log('SHIFT_TAB_FOCUS', await page.evaluate(() => document.activeElement?.id));
+
+// 5. Modal copy
+await page.click('.lp-dep-addr');
+await page.waitForTimeout(150);
+log('MODAL_CLIPBOARD_MATCH', (await page.evaluate(() => navigator.clipboard.readText())) === ADDR);
+log('MODAL_FEEDBACK', await page.textContent('#lp-dep-addr-label'));
+
+// 6. Body scroll locked
+log('SCROLL_LOCKED', (await page.evaluate(() => document.body.style.overflow)) === 'hidden');
+
+// 7. Escape closes & restores focus
+await page.keyboard.press('Escape');
+await page.waitForSelector('.lp-dep', { state: 'detached' });
+log('SCROLL_RESTORED', (await page.evaluate(() => document.body.style.overflow)) === '');
+log('FOCUS_RETURNED', await page.evaluate(() => document.activeElement?.id || document.activeElement?.className));
+
+// 8. Backdrop close
+await page.click('#lp-deposit');
+await page.waitForSelector('.lp-dep');
+await page.locator('.lp-dep-bd').click({ position: { x: 3, y: 3 } });
+await page.waitForSelector('.lp-dep', { state: 'detached' });
+log('BACKDROP_CLOSE', true);
+
+log('UNEXPECTED_ERRORS', myErrors.length === 0 ? 'none' : myErrors);
+
+await browser.close();
+process.exit(myErrors.length === 0 ? 0 : 1);
diff --git a/.test-bento.mjs b/.test-bento.mjs
new file mode 100644
index 000000000..485c5c98b
--- /dev/null
+++ b/.test-bento.mjs
@@ -0,0 +1,43 @@
+import { chromium } from 'playwright-core';
+const browser = await chromium.launch();
+const page = await browser.newPage({ viewport: { width: 1920, height: 1200 }, deviceScaleFactor: 2 });
+await page.goto('http://localhost:3000/home.html', { waitUntil: 'load', timeout: 30000 });
+await page.evaluate(async () => {
+ const parallax = document.querySelector('.home-parallax');
+ const target = document.getElementById('bento-cz-canvas');
+ let y = 0, max = parallax.scrollHeight;
+ while (y < max - 1000) {
+ y += 400;
+ parallax.scrollTo(0, y);
+ await new Promise(r => setTimeout(r, 80));
+ const rect = target.getBoundingClientRect();
+ if (rect.top > 0 && rect.top < window.innerHeight - 200) break;
+ }
+ await new Promise(r => setTimeout(r, 200));
+ target.scrollIntoView({ block: 'center' });
+});
+await page.waitForTimeout(8000);
+
+// dump the canvas as PNG via toDataURL — but canvas with alpha=true and DPR has gotchas
+const dataUrl = await page.evaluate(() => {
+ const c = document.getElementById('bento-cz-canvas');
+ // force a render frame to flush
+ return new Promise(res => requestAnimationFrame(() => res(c.toDataURL())));
+});
+console.log('canvas data url len:', dataUrl.length);
+// save it
+import fs from 'fs';
+fs.writeFileSync('/tmp/bento-canvas-direct.png', Buffer.from(dataUrl.split(',')[1], 'base64'));
+console.log('saved');
+
+// also screenshot the bento card region
+const rect = await page.evaluate(() => {
+ const c = document.getElementById('bento-cz-canvas');
+ const r = c.getBoundingClientRect();
+ return { x: r.x, y: r.y, w: r.width, h: r.height };
+});
+console.log('rect', rect);
+if (rect.y > -50 && rect.y < 1200) {
+ await page.screenshot({ path: '/tmp/bento-card-zoomed.png', clip: { x: Math.max(0,rect.x), y: Math.max(0,rect.y), width: rect.w, height: Math.min(1200-Math.max(0,rect.y), rect.h) } });
+}
+await browser.close();
diff --git a/api/_lib/avatars.js b/api/_lib/avatars.js
index 7244d8722..aa3fa3ba2 100644
--- a/api/_lib/avatars.js
+++ b/api/_lib/avatars.js
@@ -144,7 +144,7 @@ export async function deleteAvatar({ id, userId }) {
return true;
}
-export async function searchPublicAvatars({ q, tag, limit = 24, cursor }) {
+export async function searchPublicAvatars({ q, tag, limit = 24, cursor, withTotals = false }) {
limit = Math.min(Math.max(limit, 1), 100);
const params = [];
const conds = [`deleted_at is null`, `visibility = 'public'`];
@@ -156,6 +156,8 @@ export async function searchPublicAvatars({ q, tag, limit = 24, cursor }) {
params.push(tag);
conds.push(`$${params.length} = any(tags)`);
}
+ const filterParams = params.slice();
+ const filterConds = conds.join(' and ');
if (cursor) {
params.push(new Date(cursor));
conds.push(`created_at < $${params.length}`);
@@ -163,17 +165,28 @@ export async function searchPublicAvatars({ q, tag, limit = 24, cursor }) {
params.push(limit + 1);
const rows = await sql(
`select id, owner_id, slug, name, description, storage_key, thumbnail_key, size_bytes,
- content_type, source, visibility, tags, created_at
+ content_type, source, visibility, tags, view_count, created_at
from avatars where ${conds.join(' and ')}
order by created_at desc limit $${params.length}`,
params,
);
const hasMore = rows.length > limit;
const page = hasMore ? rows.slice(0, limit) : rows;
- return {
+ const result = {
avatars: page.map(decorate),
next_cursor: hasMore ? new Date(page[page.length - 1].created_at).toISOString() : null,
};
+ if (withTotals) {
+ const totalsRow = await sql(
+ `select count(*)::int as total,
+ coalesce(sum(view_count), 0)::bigint as total_views
+ from avatars where ${filterConds}`,
+ filterParams,
+ );
+ result.total = totalsRow[0]?.total ?? 0;
+ result.total_views = Number(totalsRow[0]?.total_views ?? 0);
+ }
+ return result;
}
export async function resolveAvatarUrl(row, { expiresIn = 600 } = {}) {
@@ -235,6 +248,7 @@ function decorate(row) {
visibility: row.visibility,
tags: row.tags || [],
version: row.version,
+ view_count: row.view_count == null ? 0 : Number(row.view_count),
created_at: row.created_at,
updated_at: row.updated_at,
model_url:
diff --git a/api/_lib/plans.js b/api/_lib/plans.js
index 3d8e81890..d194ed7eb 100644
--- a/api/_lib/plans.js
+++ b/api/_lib/plans.js
@@ -1,17 +1,17 @@
import { sql } from './db.js';
-const PAID_PLANS = new Set(['pro', 'team', 'enterprise', 'admin']);
-
-export async function getUserPlan(userId) {
- if (!userId) return 'free';
- const rows = await sql`select plan from users where id = ${userId} limit 1`;
- return rows[0]?.plan || 'free';
-}
+const PAID_PLANS = new Set(['pro', 'team', 'enterprise']);
export function isPaidPlan(plan) {
return PAID_PLANS.has(plan);
}
export async function userHasPaidPlan(userId) {
- return isPaidPlan(await getUserPlan(userId));
+ if (!userId) return false;
+ const rows = await sql`
+ select plan, is_admin from users where id = ${userId} and deleted_at is null limit 1
+ `;
+ const u = rows[0];
+ if (!u) return false;
+ return u.is_admin === true || isPaidPlan(u.plan);
}
diff --git a/api/auth/wallets/[action].js b/api/auth/wallets/[action].js
index 593c58f94..dc967bdb6 100644
--- a/api/auth/wallets/[action].js
+++ b/api/auth/wallets/[action].js
@@ -1,12 +1,14 @@
// Wallet endpoints — dispatched by req.query.action.
-// GET /api/auth/wallets → handleListWallets (action undefined)
-// POST /api/auth/wallets → handleLinkWallet (action undefined)
-// POST /api/auth/wallets/nonce → handleNonce (action === 'nonce')
-// DELETE /api/auth/wallets/<address> → handleUnlinkWallet (action === <address>)
+// GET /api/auth/wallets → handleListWallets (action undefined)
+// POST /api/auth/wallets → handleLinkWallet (action undefined)
+// POST /api/auth/wallets/nonce → handleNonce (action === 'nonce')
+// POST /api/auth/wallets/nonce-solana → handleNonceSolana (action === 'nonce-solana')
+// POST /api/auth/wallets/link-solana → handleLinkSolana (action === 'link-solana')
+// DELETE /api/auth/wallets/<address> → handleUnlinkWallet (action === <address>)
//
-// Dispatcher convention: undefined action → index (GET/POST), the literal
-// "nonce" → nonce issuance, and anything else is treated as an address for
-// DELETE. _link-nonces.js remains a separate helper (underscore-prefixed,
+// Dispatcher convention: undefined action → index (GET/POST), reserved literal
+// actions handle nonce/link flows, and anything else is treated as an address
+// for DELETE. _link-nonces.js remains a separate helper (underscore-prefixed,
// not file-routed by Vercel).
import { verifyMessage, getAddress } from 'ethers';
@@ -17,9 +19,13 @@ import { logAudit } from '../../_lib/audit.js';
import { cors, json, method, readJson, wrap, error } from '../../_lib/http.js';
import { parse } from '../../_lib/validate.js';
import { parseSiweMessage } from '../../_lib/siwe.js';
+import { parseSiwsMessage, verifySiwsSignature } from '../../_lib/siws.js';
import { env } from '../../_lib/env.js';
import { issueNonce, consumeNonce, NONCE_TTL_SEC } from './_link-nonces.js';
+const SOLANA_ADDRESS_RE = /^[1-9A-HJ-NP-Za-km-z]{32,44}$/;
+const ALLOWED_SOLANA_CHAINS = new Set(['mainnet', 'devnet', 'testnet']);
+
const linkBody = z.object({
message: z.string().min(64).max(4000),
signature: z.string().regex(/^0x[a-fA-F0-9]+$/),
@@ -38,11 +44,21 @@ export default wrap(async (req, res) => {
return handleIndex(req, res);
}
- // /api/auth/wallets/nonce — issue link nonce
+ // /api/auth/wallets/nonce — issue link nonce (EVM/SIWE)
if (action === 'nonce') {
return handleNonce(req, res);
}
+ // /api/auth/wallets/nonce-solana — issue SIWS link message
+ if (action === 'nonce-solana') {
+ return handleNonceSolana(req, res);
+ }
+
+ // /api/auth/wallets/link-solana — verify SIWS + insert Solana wallet row
+ if (action === 'link-solana') {
+ return handleLinkSolana(req, res);
+ }
+
// /api/auth/wallets/<address> — unlink wallet (action carries the address)
return handleUnlinkWallet(req, res, action);
});
@@ -65,7 +81,7 @@ async function handleIndex(req, res) {
async function handleListWallets(userId, res) {
const rows = await sql`
- select address, chain_id, created_at, is_primary
+ select address, chain_id, chain_type, created_at, is_primary
from user_wallets
where user_id = ${userId}
order by created_at asc
@@ -75,6 +91,7 @@ async function handleListWallets(userId, res) {
wallets: rows.map((w) => ({
address: w.address,
chain_id: w.chain_id,
+ chain_type: w.chain_type,
created_at: w.created_at,
is_primary: w.is_primary,
})),
@@ -216,6 +233,156 @@ async function handleNonce(req, res) {
return json(res, 200, { nonce, message, ttl: NONCE_TTL_SEC });
}
+// ── Solana: nonce ──────────────────────────────────────────────────────────
+// Issue a nonce + SIWS link message tying the wallet signature to the active
+// session's user. Mirrors handleNonce for EVM but builds a Sign-In with
+// Solana (CAIP-122 / SIP-0) message with a "Link this wallet" statement.
+
+const nonceSolanaBody = z.object({
+ address: z.string().regex(SOLANA_ADDRESS_RE),
+ chainId: z.string().optional(),
+});
+
+async function handleNonceSolana(req, res) {
+ if (cors(req, res, { methods: 'POST,OPTIONS', credentials: true })) return;
+ if (!method(req, res, ['POST'])) return;
+
+ const session = await getSessionUser(req);
+ if (!session) return error(res, 401, 'unauthorized', 'sign in required');
+
+ const { address, chainId } = parse(nonceSolanaBody, await readJson(req));
+ const chain = chainId && ALLOWED_SOLANA_CHAINS.has(chainId) ? chainId : 'mainnet';
+
+ const nonce = issueNonce(session.id);
+
+ const appOrigin = env.APP_ORIGIN;
+ const domain = new URL(appOrigin).host;
+ const issuedAt = new Date().toISOString();
+ const expirationTime = new Date(Date.now() + NONCE_TTL_SEC * 1000).toISOString();
+
+ const message = [
+ `${domain} wants you to sign in with your Solana account:`,
+ address,
+ ``,
+ `Link this wallet to three.ws account ${session.email}`,
+ ``,
+ `URI: ${appOrigin}`,
+ `Version: 1`,
+ `Chain ID: ${chain}`,
+ `Nonce: ${nonce}`,
+ `Issued At: ${issuedAt}`,
+ `Expiration Time: ${expirationTime}`,
+ ].join('\n');
+
+ return json(res, 200, { nonce, message, ttl: NONCE_TTL_SEC });
+}
+
+// ── Solana: link ───────────────────────────────────────────────────────────
+// Verify a SIWS message+signature signed by `address`, then insert (or no-op)
+// a user_wallets row with chain_type='solana' for the session user.
+
+const linkSolanaBody = z.object({
+ message: z.string().min(32).max(4000),
+ signature: z.string().min(1).max(256),
+});
+
+async function handleLinkSolana(req, res) {
+ if (cors(req, res, { methods: 'POST,OPTIONS', credentials: true })) return;
+ if (!method(req, res, ['POST'])) return;
+
+ const session = await getSessionUser(req);
+ if (!session) return error(res, 401, 'unauthorized', 'sign in required');
+
+ const body = parse(linkSolanaBody, await readJson(req));
+
+ const fields = parseSiwsMessage(body.message);
+ if (!fields) return error(res, 400, 'invalid_message', 'malformed SIWS message');
+
+ // Domain + URI must match this deployment.
+ const appOrigin = env.APP_ORIGIN;
+ const appHost = new URL(appOrigin).host;
+ const vercelHost = process.env.VERCEL_URL || null;
+ const isLocalDev =
+ process.env.VERCEL_ENV !== 'production' && process.env.VERCEL_ENV !== 'preview';
+ const allowedHosts = new Set([appHost, vercelHost].filter(Boolean));
+ const domainOk =
+ allowedHosts.has(fields.domain) || (isLocalDev && /^localhost(:\d+)?$/.test(fields.domain));
+ if (!domainOk) return error(res, 400, 'invalid_domain', `domain must be ${appHost}`);
+
+ try {
+ const u = new URL(fields.uri);
+ const allowedOrigins = new Set(
+ [appOrigin, vercelHost ? `https://${vercelHost}` : null].filter(Boolean),
+ );
+ const originOk =
+ allowedOrigins.has(u.origin) ||
+ (isLocalDev && /^https?:\/\/localhost(:\d+)?$/.test(u.origin));
+ if (!originOk) return error(res, 400, 'invalid_uri', 'uri origin mismatch');
+ } catch {
+ return error(res, 400, 'invalid_uri', 'uri not a valid URL');
+ }
+
+ if (fields.chainId && !ALLOWED_SOLANA_CHAINS.has(fields.chainId)) {
+ return error(res, 400, 'invalid_chain', 'unknown Solana chain ID');
+ }
+
+ const now = Date.now();
+ if (fields.expirationTime && Date.parse(fields.expirationTime) < now) {
+ return error(res, 400, 'expired', 'message expired');
+ }
+ if (fields.notBefore && Date.parse(fields.notBefore) > now) {
+ return error(res, 400, 'not_yet_valid', 'message not yet valid');
+ }
+
+ // Burn the per-user link nonce.
+ const nonceData = consumeNonce(fields.nonce, session.id);
+ if (!nonceData) {
+ return error(res, 400, 'invalid_nonce', 'unknown, expired, or invalid nonce');
+ }
+
+ let valid;
+ try {
+ valid = verifySiwsSignature(body.message, body.signature, fields.address);
+ } catch {
+ return error(res, 401, 'invalid_signature', 'signature verification failed');
+ }
+ if (!valid) return error(res, 401, 'invalid_signature', 'signer does not match address');
+
+ const addr = fields.address;
+ const chain = fields.chainId || 'mainnet';
+
+ // Idempotent: already linked to this user → success.
+ const [existing] = await sql`
+ select id from user_wallets
+ where user_id = ${session.id} and address = ${addr}
+ limit 1
+ `;
+ if (existing) {
+ return json(res, 200, { wallet: { address: addr, chain_type: 'solana', chain_id: chain } });
+ }
+
+ // Conflict: linked to a different user.
+ const [conflict] = await sql`
+ select user_id from user_wallets where address = ${addr} limit 1
+ `;
+ if (conflict) {
+ return error(
+ res,
+ 409,
+ 'address_in_use',
+ 'this address is already linked to another account',
+ );
+ }
+
+ await sql`
+ insert into user_wallets (user_id, address, chain_type, is_primary)
+ values (${session.id}, ${addr}, 'solana', false)
+ `;
+ logAudit({ userId: session.id, action: 'link_wallet_solana', resourceId: addr });
+
+ return json(res, 201, { wallet: { address: addr, chain_type: 'solana', chain_id: chain } });
+}
+
// ── Unlink ─────────────────────────────────────────────────────────────────
// Unlink a wallet from authenticated user.
// Refuse if it's the only wallet AND user has no email+password.
diff --git a/api/avatars/[id].js b/api/avatars/[id].js
index 9d0c97afa..7077b4797 100644
--- a/api/avatars/[id].js
+++ b/api/avatars/[id].js
@@ -102,13 +102,17 @@ export default wrap(async (req, res) => {
return handleGlbPatch(res, auth, id, body.glbUrl);
}
const patch = parse(patchSchema, body);
- if (patch.visibility === 'private' && !(await userHasPaidPlan(auth.userId))) {
- return error(
- res,
- 402,
- 'plan_required',
- 'private avatars require a Pro plan — upgrade at /dashboard/#billing or set visibility to public/unlisted',
- );
+ if (patch.visibility === 'private') {
+ const current = await getAvatar({ id, requesterId: auth.userId });
+ const wasPrivate = current?.visibility === 'private';
+ if (!wasPrivate && !(await userHasPaidPlan(auth.userId))) {
+ return error(
+ res,
+ 402,
+ 'plan_required',
+ 'private avatars require a Pro plan — upgrade at /dashboard/#billing or set visibility to public/unlisted',
+ );
+ }
}
const avatar = await updateAvatar({ id, userId: auth.userId, patch });
if (!avatar) return error(res, 404, 'not_found', 'avatar not found or not yours');
diff --git a/api/avatars/_actions.js b/api/avatars/_actions.js
index ae96ffa02..a3e6d26a2 100644
--- a/api/avatars/_actions.js
+++ b/api/avatars/_actions.js
@@ -48,7 +48,13 @@ const handlePublic = wrap(async (req, res) => {
if (cors(req, res, { methods: 'GET,OPTIONS' })) return;
if (!method(req, res, ['GET'])) return;
const url = new URL(req.url, 'http://x');
- const result = await searchPublicAvatars({ q: url.searchParams.get('q') || undefined, tag: url.searchParams.get('tag') || undefined, limit: Number(url.searchParams.get('limit')) || 24, cursor: url.searchParams.get('cursor') || undefined });
+ const result = await searchPublicAvatars({
+ q: url.searchParams.get('q') || undefined,
+ tag: url.searchParams.get('tag') || undefined,
+ limit: Number(url.searchParams.get('limit')) || 24,
+ cursor: url.searchParams.get('cursor') || undefined,
+ withTotals: url.searchParams.get('totals') === '1',
+ });
result.avatars = result.avatars.map((a) => stripOwnerFor(a, null));
res.setHeader('cache-control', 'public, max-age=60, s-maxage=60');
return json(res, 200, result);
diff --git a/api/pump/[action].js b/api/pump/[action].js
index 178e4ffa0..f09decaec 100644
--- a/api/pump/[action].js
+++ b/api/pump/[action].js
@@ -559,6 +559,57 @@ async function handleBuildMetadata(req, res) {
return json(res, 200, { metadata_url: r2PublicUrl(jsonKey), image_url: imageUrl });
}
+// ── shared launch helpers ──────────────────────────────────────────────────
+
+// Build the pump.fun launch instructions for the requested coin variant.
+// Mayhem coins go through createV2* (token-2022 + mayhem program accounts).
+// Regular / agent coins keep the legacy V1 path; agent binding (PumpAgent.create)
+// is appended by the caller when applicable.
+async function buildLaunchInstructions({
+ sdk, BN, mint, creator, name, symbol, uri, solBuyIn, isMayhem,
+}) {
+ const LAMPORTS = 1_000_000_000;
+ const hasBuy = solBuyIn > 0;
+
+ if (isMayhem) {
+ if (hasBuy && sdk.createV2AndBuyInstructions) {
+ const global = await sdk.fetchGlobal();
+ const solAmount = new BN(Math.floor(solBuyIn * LAMPORTS));
+ const pumpSdk = await import('@pump-fun/pump-sdk');
+ const tokenAmount = pumpSdk.getBuyTokenAmountFromSolAmount(global, null, solAmount);
+ const ixs = await sdk.createV2AndBuyInstructions({
+ global, mint, name, symbol, uri,
+ creator, user: creator,
+ solAmount, amount: tokenAmount,
+ mayhemMode: true,
+ });
+ return Array.isArray(ixs) ? [...ixs] : [ixs];
+ }
+ const ix = await sdk.createV2Instruction({
+ mint, name, symbol, uri, creator, user: creator, mayhemMode: true,
+ });
+ return [ix];
+ }
+
+ // Regular / agent — legacy V1 path (TOKEN_PROGRAM_ID).
+ if (hasBuy && sdk.createAndBuyInstructions) {
+ const global = await sdk.fetchGlobal();
+ const solAmount = new BN(Math.floor(solBuyIn * LAMPORTS));
+ const pumpSdk = await import('@pump-fun/pump-sdk');
+ const tokenAmount = pumpSdk.getBuyTokenAmountFromSolAmount(global, null, solAmount);
+ const ixs = await sdk.createAndBuyInstructions({
+ global, mint, name, symbol, uri,
+ creator, user: creator,
+ solAmount, amount: tokenAmount,
+ });
+ return Array.isArray(ixs) ? [...ixs] : [ixs];
+ }
+ const ix = await sdk.createInstruction({
+ mint, name, symbol, uri, creator, user: creator,
+ });
+ return [ix];
+}
+
// ── launch-prep ────────────────────────────────────────────────────────────
const launchPrepSchema = z
@@ -577,6 +628,11 @@ const launchPrepSchema = z
// the server never sees the secret. When omitted, the server falls back
// to a fresh Keypair.generate() and returns the secret key for co-sign.
mint_address: z.string().min(32).max(44).optional(),
+ // Coin variant:
+ // 'agent' — pump.fun coin + on-chain agent (buyback-bound)
+ // 'regular' — plain pump.fun coin, no agent binding
+ // 'mayhem' — pump.fun mayhem-mode coin (V2 instruction set, token-2022)
+ coin_type: z.enum(['regular', 'mayhem', 'agent']).default('agent'),
})
.refine((v) => v.agent_id || v.avatar_id, {
message: 'agent_id or avatar_id required',
@@ -692,44 +748,28 @@ async function handleLaunchPrep(req, res) {
const { sdk, BN } = await getPumpSdk({ network: body.network });
const LAMPORTS_PER_SOL_LAUNCH = 1_000_000_000;
- const instructions = [];
- if (body.sol_buy_in > 0 && sdk.createAndBuyInstructions) {
- const global = await sdk.fetchGlobal();
- const solAmount = new BN(Math.floor(body.sol_buy_in * LAMPORTS_PER_SOL_LAUNCH));
- const pumpSdk = await import('@pump-fun/pump-sdk');
- const tokenAmount = pumpSdk.getBuyTokenAmountFromSolAmount(global, null, solAmount);
- const ixs = await sdk.createAndBuyInstructions({
- global,
- mint,
- name: body.name,
- symbol: body.symbol,
- uri: body.uri,
- creator,
- user: creator,
- solAmount,
- amount: tokenAmount,
- });
- instructions.push(...(Array.isArray(ixs) ? ixs : [ixs]));
- } else {
- const ix = await sdk.createInstruction({
- mint,
- name: body.name,
- symbol: body.symbol,
- uri: body.uri,
- creator,
- user: creator,
- });
- instructions.push(ix);
- }
+ // Coin-variant flags:
+ // mayhem → use createV2* (token-2022, mayhemMode=true), drop buyback binding
+ // agent → V1 path + on-chain agent (PumpAgent.create with buyback_bps)
+ // regular→ V1 path, no agent binding
+ const isMayhem = body.coin_type === 'mayhem';
+ const isAgent = body.coin_type === 'agent';
+ const effBuyback = isAgent ? body.buyback_bps : 0;
+
+ const instructions = await buildLaunchInstructions({
+ sdk, BN, mint, creator,
+ name: body.name, symbol: body.symbol, uri: body.uri,
+ solBuyIn: body.sol_buy_in,
+ isMayhem,
+ });
- // Bind PumpAgent.create.
- if (body.buyback_bps > 0) {
+ if (isAgent && effBuyback > 0) {
const { offline } = await getPumpAgentOffline({ network: body.network, mint });
const createIx = await offline.create({
authority: creator,
mint,
agentAuthority: creator,
- buybackBps: body.buyback_bps,
+ buybackBps: effBuyback,
});
instructions.push(createIx);
}
@@ -757,7 +797,8 @@ async function handleLaunchPrep(req, res) {
name: body.name,
symbol: body.symbol,
network: body.network,
- buyback_bps: body.buyback_bps,
+ buyback_bps: effBuyback,
+ coin_type: body.coin_type,
prep_id: prepId,
})}::jsonb,
${expiresAt}
@@ -775,7 +816,8 @@ async function handleLaunchPrep(req, res) {
client_supplied_mint: !mintKeypair,
tx_base64: txBase64,
network: body.network,
- buyback_bps: body.buyback_bps,
+ buyback_bps: effBuyback,
+ coin_type: body.coin_type,
expires_at: expiresAt.toISOString(),
instructions: mintKeypair
? 'Decode tx_base64 as VersionedTransaction. Sign with the mint keypair (mint_secret_key_b64) AND the user wallet, submit, then POST /api/pump/launch-confirm with the tx_signature.'
@@ -926,6 +968,7 @@ const launchAgentSchema = z
sol_buy_in: z.number().nonnegative().max(50).default(0),
mint_address: z.string().min(32).max(44).optional(),
mint_secret_key_b64: z.string().min(20).optional(),
+ coin_type: z.enum(['regular', 'mayhem', 'agent']).default('agent'),
})
.refine((v) => v.agent_id || v.avatar_id, {
message: 'agent_id or avatar_id required',
@@ -958,7 +1001,7 @@ async function handleLaunchAgent(req, res) {
const loaded = await loadAgentForSigning(resolvedAgentId, user.id, {
reason: 'studio_pump_launch',
- meta: { network: body.network, buyback_bps: body.buyback_bps },
+ meta: { network: body.network, buyback_bps: body.buyback_bps, coin_type: body.coin_type },
});
if (loaded.error) return error(res, loaded.error.status, loaded.error.code, loaded.error.msg);
const agentKeypair = loaded.keypair;
@@ -1010,43 +1053,24 @@ async function handleLaunchAgent(req, res) {
const { sdk, BN } = await getPumpSdk({ network: body.network });
- const instructions = [];
- if (body.sol_buy_in > 0 && sdk.createAndBuyInstructions) {
- const global = await sdk.fetchGlobal();
- const solAmount = new BN(initialBuyLamports);
- const pumpSdk = await import('@pump-fun/pump-sdk');
- const tokenAmount = pumpSdk.getBuyTokenAmountFromSolAmount(global, null, solAmount);
- const ixs = await sdk.createAndBuyInstructions({
- global,
- mint,
- name: body.name,
- symbol: body.symbol,
- uri: body.uri,
- creator,
- user: creator,
- solAmount,
- amount: tokenAmount,
- });
- instructions.push(...(Array.isArray(ixs) ? ixs : [ixs]));
- } else {
- const ix = await sdk.createInstruction({
- mint,
- name: body.name,
- symbol: body.symbol,
- uri: body.uri,
- creator,
- user: creator,
- });
- instructions.push(ix);
- }
+ const isMayhem = body.coin_type === 'mayhem';
+ const isAgent = body.coin_type === 'agent';
+ const effBuyback = isAgent ? body.buyback_bps : 0;
+
+ const instructions = await buildLaunchInstructions({
+ sdk, BN, mint, creator,
+ name: body.name, symbol: body.symbol, uri: body.uri,
+ solBuyIn: body.sol_buy_in,
+ isMayhem,
+ });
- if (body.buyback_bps > 0) {
+ if (isAgent && effBuyback > 0) {
const { offline } = await getPumpAgentOffline({ network: body.network, mint });
const createIx = await offline.create({
authority: creator,
mint,
agentAuthority: creator,
- buybackBps: body.buyback_bps,
+ buybackBps: effBuyback,
});
instructions.push(createIx);
}
@@ -1077,7 +1101,7 @@ async function handleLaunchAgent(req, res) {
(agent_id, user_id, network, mint, name, symbol, metadata_uri, agent_authority, buyback_bps)
values
(${resolvedAgentId}, ${user.id}, ${body.network}, ${mintAddr},
- ${body.name}, ${body.symbol}, ${body.uri}, ${creator.toBase58()}, ${body.buyback_bps})
+ ${body.name}, ${body.symbol}, ${body.uri}, ${creator.toBase58()}, ${effBuyback})
on conflict (mint, network) do nothing
returning id, mint, network, buyback_bps, created_at
`;
@@ -1095,7 +1119,8 @@ async function handleLaunchAgent(req, res) {
signature,
network: body.network,
sol_buy_in: body.sol_buy_in || 0,
- buyback_bps: body.buyback_bps,
+ buyback_bps: effBuyback,
+ coin_type: body.coin_type,
source: 'studio_agent_wallet',
})}::jsonb,
${'pumpfun'}
@@ -1108,7 +1133,8 @@ async function handleLaunchAgent(req, res) {
mint: mintAddr,
signature,
network: body.network,
- buyback_bps: body.buyback_bps,
+ buyback_bps: effBuyback,
+ coin_type: body.coin_type,
pump_agent_mint: row || null,
explorer: `https://solscan.io/tx/${signature}${body.network === 'devnet' ? '?cluster=devnet' : ''}`,
pumpfun_url: `https://pump.fun/coin/${mintAddr}`,
diff --git a/create.html b/create.html
index 0548b6be8..2663f6708 100644
--- a/create.html
+++ b/create.html
@@ -226,6 +226,20 @@
height: 100%;
--poster-color: transparent;
}
+ .card-preview--icon {
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ }
+ .card-preview--icon svg {
+ width: 56px;
+ height: 56px;
+ color: rgba(255, 255, 255, 0.5);
+ }
+ .card-subtitle code {
+ font-size: 11px;
+ opacity: 0.7;
+ }
.card-icon {
width: 48px;
@@ -693,21 +707,22 @@
aria-label="Open avatar web editor (recommended)"
>
<span class="recommended-badge" aria-hidden="true">Recommended</span>
- <div class="card-preview" aria-hidden="true">
+ <div class="card-preview">
<model-viewer
src="/avatars/default.glb"
+ alt="Default 3D avatar preview"
auto-rotate
auto-rotate-delay="0"
rotation-per-second="18deg"
interaction-prompt="none"
- camera-controls="false"
disable-zoom
+ disable-pan
+ disable-tap
shadow-intensity="0.4"
shadow-softness="0.8"
exposure="0.95"
environment-image="neutral"
- camera-orbit="20deg 80deg 2.6m"
- field-of-view="28deg"
+ camera-orbit="15deg 80deg auto"
loading="eager"
></model-viewer>
</div>
@@ -759,17 +774,11 @@
tabindex="0"
aria-label="Upload a GLB file"
>
- <div
- class="card-preview"
- aria-hidden="true"
- style="display: flex; align-items: center; justify-content: center;"
- >
+ <div class="card-preview card-preview--icon" aria-hidden="true">
<svg
viewBox="0 0 24 24"
- width="56"
- height="56"
fill="none"
- stroke="rgba(255,255,255,0.5)"
+ stroke="currentColor"
stroke-width="1.2"
stroke-linecap="round"
stroke-linejoin="round"
@@ -798,8 +807,7 @@
<h2 class="card-title">Upload your own GLB</h2>
</div>
<p class="card-subtitle">
- Drop a <code style="font-size: 11px; opacity: 0.7">.glb</code> file. Works
- with any glTF 2.0 model.
+ Drop a <code>.glb</code> file. Works with any glTF 2.0 model.
</p>
<span class="card-cta">
Choose file
diff --git a/home.html b/home.html
index e7b9e568f..afbbe81c8 100644
--- a/home.html
+++ b/home.html
@@ -458,18 +458,8 @@
MCP client on 20+ chains.
</p>
<div class="h-bento-id">
- <span
- class="h-id-dot"
- style="background: #6ee7b7; box-shadow: 0 0 8px #6ee7b7"
- ></span>
- <span
- style="
- font-family: monospace;
- font-size: 12px;
- color: rgba(255, 255, 255, 0.6);
- "
- >0x3d…a9f · Base</span
- >
+ <span class="h-id-dot h-id-dot--mint" aria-hidden="true"></span>
+ <span class="h-id-addr">0x3d…a9f · Base</span>
</div>
</div>
</div>
@@ -481,12 +471,12 @@
Built-in empathy layer. Your agent reacts — speaking, thinking,
succeeding, failing.
</p>
- <div class="h-bento-emotions">
- <span>✦ celebration</span>
- <span>? curiosity</span>
- <span>♥ empathy</span>
- <span>! concern</span>
- </div>
+ <ul class="h-bento-emotions" aria-label="Emotion states">
+ <li><span class="h-em-dot"></span>Celebration</li>
+ <li><span class="h-em-dot"></span>Curiosity</li>
+ <li><span class="h-em-dot"></span>Empathy</li>
+ <li><span class="h-em-dot"></span>Concern</li>
+ </ul>
</div>
</div>
<div class="h-bento-card h-reveal">
diff --git a/public/.well-known/openapi.yaml b/public/.well-known/openapi.yaml
index 58dd99826..d627068aa 100644
--- a/public/.well-known/openapi.yaml
+++ b/public/.well-known/openapi.yaml
@@ -130,6 +130,9 @@ components:
description: 64-character hex SHA-256 of the file
version:
type: integer
+ view_count:
+ type: integer
+ description: Number of times this avatar has been viewed (public avatars only; tracked via POST /api/avatars/view).
created_at:
type: string
format: date-time
@@ -678,6 +681,12 @@ paths:
description: Pagination cursor (ISO-8601 timestamp from previous `next_cursor`)
schema:
$ref: '#/components/schemas/Cursor'
+ - name: totals
+ in: query
+ description: When `1`, include `total` and `total_views` in the response. Adds a second SQL roundtrip — request only on the first page.
+ schema:
+ type: string
+ enum: ['1']
responses:
'200':
description: Paginated public avatar list
@@ -697,6 +706,12 @@ paths:
$ref: '#/components/schemas/Avatar'
next_cursor:
$ref: '#/components/schemas/Cursor'
+ total:
+ type: integer
+ description: Total avatars matching the filters (only returned when `totals=1`).
+ total_views:
+ type: integer
+ description: Sum of `view_count` across all matching avatars (only when `totals=1`).
/api/avatars/presign:
post:
diff --git a/public/agents/index.html b/public/agents/index.html
index f9c8f24d3..3bd9e261a 100644
--- a/public/agents/index.html
+++ b/public/agents/index.html
@@ -387,6 +387,6 @@
</div>
</div>
- <script type="module" src="./boot.js"></script>
+ <script type="module" src="/agents/boot.js"></script>
</body>
</html>
diff --git a/public/cz/index.html b/public/cz/index.html
index aa75a65fa..dcb7e5786 100644
--- a/public/cz/index.html
+++ b/public/cz/index.html
@@ -66,6 +66,6 @@
<span id="rehearsal-badge" class="rehearsal-badge hidden">rehearsal mode</span>
</section>
</main>
- <script type="module" src="./cz.js"></script>
+ <script type="module" src="/cz/cz.js"></script>
</body>
</html>
diff --git a/public/dashboard/dashboard.js b/public/dashboard/dashboard.js
index 115b46433..20e95f6ce 100644
--- a/public/dashboard/dashboard.js
+++ b/public/dashboard/dashboard.js
@@ -6,6 +6,23 @@ import { mountAgentVanityGrinderCard } from '/src/agent-vanity-grinder.js';
export const state = { user: null };
+const PAID_PLANS = new Set(['pro', 'team', 'enterprise']);
+function canSetPrivate() {
+ const u = state.user;
+ return Boolean(u && (PAID_PLANS.has(u.plan) || u.is_admin));
+}
+function visibilityOptionsHtml(currentValue) {
+ const allowPrivate = canSetPrivate() || currentValue === 'private';
+ const opts = [
+ { v: 'public', label: 'Public (discoverable)' },
+ { v: 'unlisted', label: 'Unlisted (anyone with link)' },
+ { v: 'private', label: allowPrivate ? 'Private (only you)' : 'Private — Pro plan', disabled: !allowPrivate },
+ ];
+ return opts
+ .map((o) => `<option value="${o.v}"${currentValue === o.v ? ' selected' : ''}${o.disabled ? ' disabled' : ''}>${o.label}</option>`)
+ .join('');
+}
+
export const api = {
me: () => j('GET', '/api/auth/me'),
listAvatars: ({ cursor, limit = 24 } = {}) => {
@@ -29,6 +46,8 @@ export const api = {
createAvatarSession: (id) => j('POST', `/api/avatars/${id}/session`),
getAvatarVersions: (id) => j('GET', `/api/avatars/${id}/versions`),
patchAgent: (agentId, patch) => j('PUT', `/api/agents/${agentId}`, patch),
+ deleteAgent: (agentId) => j('DELETE', `/api/agents/${encodeURIComponent(agentId)}`),
+ createAgent: (body) => j('POST', '/api/agents', body),
getAgentMe: () => j('GET', '/api/agents/me'),
getAvatar: (id) => j('GET', `/api/avatars/${encodeURIComponent(id)}`),
patchAgentAnimations: (agentId, animations) =>
@@ -75,6 +94,7 @@ export function signOut() {
}
const KNOWN_TABS = [
+ 'agents',
'avatars',
'create',
'edit',
@@ -102,25 +122,25 @@ export function currentRoute() {
if (m && m[1]) return m[1];
const hash = location.hash.slice(1);
if (hash) return hash;
- return 'avatars';
+ return 'agents';
}
// Render a route into <main>. Does not touch the URL.
function renderRoute(route) {
- const [base, ...rest] = (route || 'avatars').split('/');
+ const [base, ...rest] = (route || 'agents').split('/');
document
.querySelectorAll('aside a')
.forEach((a) => a.classList.toggle('active', a.dataset.tab === base));
const main = document.getElementById('main');
main.innerHTML = '';
- const renderer = tabs[base] || tabs.avatars;
+ const renderer = tabs[base] || tabs.agents;
renderer(main, rest);
}
// Programmatic navigation: pushes /dashboard/<route> into history and renders.
// Use this instead of `location.hash = ...`.
export function goto(route) {
- const clean = (route || 'avatars').replace(/^#?\/+|\/+$/g, '').replace(/^#/, '');
+ const clean = (route || 'agents').replace(/^#?\/+|\/+$/g, '').replace(/^#/, '');
const target = '/dashboard/' + clean;
if (location.pathname + location.search !== target) {
history.pushState({ route: clean }, '', target);
@@ -179,6 +199,7 @@ export function installRouting() {
}
const tabs = {
+ agents: renderAgents,
avatars: renderAvatars,
create: renderCreate,
edit: renderEdit,
@@ -197,6 +218,170 @@ const tabs = {
account: renderAccount,
};
+// ── Agents ──────────────────────────────────────────────────────────────────
+// On-chain agents discovered from linked wallets live at /my-agents.
+
+const AGENT_CHAIN_NAMES = {
+ 1: 'Ethereum', 10: 'Optimism', 56: 'BNB Chain', 97: 'BSC Testnet',
+ 100: 'Gnosis', 137: 'Polygon', 250: 'Fantom', 324: 'zkSync Era',
+ 1284: 'Moonbeam', 5000: 'Mantle', 8453: 'Base', 42161: 'Arbitrum',
+ 42220: 'Celo', 43113: 'Avalanche Fuji', 43114: 'Avalanche', 59144: 'Linea',
+ 80002: 'Polygon Amoy', 84532: 'Base Sepolia', 421614: 'Arb Sepolia',
+ 534352: 'Scroll', 11155111: 'Sepolia', 11155420: 'OP Sepolia',
+};
+
+function agentChainName(id) {
+ if (id == null) return '';
+ return AGENT_CHAIN_NAMES[Number(id)] || `Chain ${id}`;
+}
+
+async function renderAgents(root) {
+ root.innerHTML = `
+ <div class="widgets-header">
+ <div>
+ <h1>Your agents</h1>
+ <p class="sub">Agents you've created on three.ws — each has a wallet, skills, and an optional ERC-8004 on-chain identity.</p>
+ </div>
+ <button id="agents-new" class="btn-primary" type="button">New agent</button>
+ </div>
+ <div id="agents-create-host"></div>
+ <div id="agents-list" class="cards"></div>
+ `;
+
+ const list = root.querySelector('#agents-list');
+ const createHost = root.querySelector('#agents-create-host');
+ list.innerHTML = '<div class="muted">Loading…</div>';
+
+ root.querySelector('#agents-new').addEventListener('click', () => openCreateForm(createHost, list));
+
+ let agents = [];
+ try {
+ const data = await api.listAgents();
+ agents = data.agents || [];
+ } catch (e) {
+ list.innerHTML = `<div class="err">${esc(e.message || 'Failed to load agents')}</div>`;
+ return;
+ }
+
+ list.innerHTML = '';
+ if (!agents.length) {
+ renderAgentsEmpty(list, createHost);
+ return;
+ }
+
+ for (const a of agents) list.appendChild(agentCard(a, () => maybeRenderEmpty(list, createHost)));
+}
+
+function renderAgentsEmpty(list, createHost) {
+ list.innerHTML = `
+ <div class="empty" style="grid-column:1/-1; padding:48px 28px; text-align:center;">
+ <div style="font-size:48px; line-height:1; margin-bottom:14px;" aria-hidden="true">🤖</div>
+ <h2 style="margin:0 0 8px; font-size:20px; color:#eee;">No agents yet</h2>
+ <p style="margin:0 0 22px; color:#888; max-width:460px; margin-left:auto; margin-right:auto;">
+ Create your first three.ws agent — it gets a wallet, a set of skills, and can be deployed on-chain as an ERC-8004 identity.
+ </p>
+ <div style="display:flex; gap:10px; justify-content:center; flex-wrap:wrap;">
+ <button class="btn-primary" id="agents-empty-new">Create agent</button>
+ <a href="/my-agents" class="btn-primary" style="background:#222230; color:#ddd;">Import from wallet</a>
+ </div>
+ </div>`;
+ list.querySelector('#agents-empty-new').addEventListener('click', () => openCreateForm(createHost, list));
+}
+
+function maybeRenderEmpty(list, createHost) {
+ if (!list.querySelector('.card')) renderAgentsEmpty(list, createHost);
+}
+
+function agentCard(a, onRemoved) {
+ const el = document.createElement('div');
+ el.className = 'card';
+
+ const thumbSrc = a.avatar_id ? `/api/avatars/${encodeURIComponent(a.avatar_id)}/thumbnail` : null;
+ const onchainBadge = a.is_registered
+ ? `<span class="tag" title="Registered on-chain (ERC-8004)" style="background:rgba(106,92,255,0.18); color:#cfc6ff;">on-chain${a.chain_id ? ' · ' + esc(agentChainName(a.chain_id)) : ''}</span>`
+ : `<span class="tag" title="Not yet registered on-chain">off-chain</span>`;
+ const skillCount = (a.skills || []).length;
+ const wallet = a.wallet_address ? `${a.wallet_address.slice(0, 6)}…${a.wallet_address.slice(-4)}` : '';
+
+ el.innerHTML = `
+ <div class="preview">
+ ${thumbSrc
+ ? `<img class="thumb" src="${esc(thumbSrc)}" alt="${esc(a.name)} avatar" loading="lazy">`
+ : `<div class="ph"><div style="font-size:32px;line-height:1;margin-bottom:8px" aria-hidden="true">🤖</div><div>No avatar linked</div></div>`}
+ </div>
+ <h3>${esc(a.name || 'Agent')}</h3>
+ <p class="meta">${skillCount} skill${skillCount === 1 ? '' : 's'}${wallet ? ' · ' + esc(wallet) : ''} · ${new Date(a.created_at).toLocaleDateString()}</p>
+ <div class="row" style="gap:6px; margin-bottom:10px; flex-wrap:wrap">${onchainBadge}</div>
+ ${a.description ? `<p class="meta" style="white-space:normal;color:#aaa;margin:0 0 10px;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden">${esc(a.description)}</p>` : ''}
+ <div class="footer">
+ <div class="actions">
+ <a class="btn sec" href="/agent/${encodeURIComponent(a.id)}">Open</a>
+ <a class="btn sec" href="/agent-edit.html?id=${encodeURIComponent(a.id)}">Edit</a>
+ ${a.is_registered ? '' : `<a class="btn sec" href="/deploy${a.avatar_id ? '?avatar=' + encodeURIComponent(a.avatar_id) : ''}" title="Mint as ERC-8004 agent">Deploy on-chain</a>`}
+ <button class="btn sec danger" data-del>Delete</button>
+ </div>
+ </div>
+ `;
+
+ el.querySelector('[data-del]').addEventListener('click', async () => {
+ if (!confirm(`Delete "${a.name}"? This cannot be undone.`)) return;
+ try {
+ await api.deleteAgent(a.id);
+ el.remove();
+ toast(`Deleted "${a.name}"`);
+ onRemoved?.();
+ } catch (err) {
+ toast(err.message || 'Delete failed', true);
+ }
+ });
+
+ return el;
+}
+
+function openCreateForm(host, listEl) {
+ if (host.querySelector('input[name=agent-name]')) {
+ host.querySelector('input[name=agent-name]').focus();
+ return;
+ }
+ host.innerHTML = `
+ <div class="card" style="margin-bottom:14px">
+ <h3 style="margin:0 0 10px">New agent</h3>
+ <form id="agents-create-form" style="display:flex; gap:8px; flex-wrap:wrap; align-items:center">
+ <input name="agent-name" type="text" maxlength="100" required placeholder="Name (e.g. Sasha)" style="flex:1; min-width:180px" autofocus>
+ <input name="agent-desc" type="text" maxlength="500" placeholder="Description (optional)" style="flex:2; min-width:200px">
+ <button class="btn-primary" type="submit">Create</button>
+ <button class="btn sec" type="button" data-cancel>Cancel</button>
+ </form>
+ <div class="muted" data-err style="margin-top:8px; color:#ffb3b3; min-height:1em; font-size:12px"></div>
+ </div>`;
+ const form = host.querySelector('#agents-create-form');
+ const errEl = host.querySelector('[data-err]');
+ host.querySelector('[data-cancel]').addEventListener('click', () => { host.innerHTML = ''; });
+ form.addEventListener('submit', async (ev) => {
+ ev.preventDefault();
+ const fd = new FormData(form);
+ const name = String(fd.get('agent-name') || '').trim();
+ const description = String(fd.get('agent-desc') || '').trim();
+ if (!name) return;
+ const submitBtn = form.querySelector('button[type=submit]');
+ submitBtn.disabled = true;
+ submitBtn.textContent = 'Creating…';
+ errEl.textContent = '';
+ try {
+ const { agent } = await api.createAgent(description ? { name, description } : { name });
+ host.innerHTML = '';
+ const empty = listEl.querySelector('.empty');
+ if (empty) listEl.innerHTML = '';
+ listEl.prepend(agentCard(agent, () => maybeRenderEmpty(listEl, host)));
+ toast(`Created "${agent.name}"`);
+ } catch (e) {
+ submitBtn.disabled = false;
+ submitBtn.textContent = 'Create';
+ errEl.textContent = e.message || 'Failed to create agent';
+ }
+ });
+}
+
// ── Avatars ─────────────────────────────────────────────────────────────────
async function renderAvatars(root) {
root.innerHTML = `<h1>Your avatars</h1><p class="sub">Each avatar gets a stable URL and can be rendered in Claude or any app via MCP.</p><div id="list" class="cards"></div>`;
@@ -272,7 +457,7 @@ function avatarCard(a) {
<p class="meta">${a.size_bytes ? fmtSize(a.size_bytes) : ''} · ${esc(a.visibility)} · ${new Date(a.created_at).toLocaleDateString()}</p>
<div class="row" style="gap:6px; margin-bottom:10px; flex-wrap:wrap">${a.tags.map((t) => `<span class="tag">${esc(t)}</span>`).join('')}</div>
<div class="footer">
- <select data-vis aria-label="Visibility">${['private', 'unlisted', 'public'].map((v) => `<option ${v === a.visibility ? 'selected' : ''} value="${v}">${v}</option>`).join('')}</select>
+ <select data-vis aria-label="Visibility">${visibilityOptionsHtml(a.visibility)}</select>
<div class="actions">
<a class="btn sec" href="/dashboard/edit/${encodeURIComponent(a.id)}">Edit</a>
<button class="btn sec" data-replace>Replace GLB</button>
@@ -587,11 +772,7 @@ function renderUpload(root) {
<label style="display:block;margin-top:12px">Name<input id="name" required maxlength="120" style="width:100%"></label>
<label style="display:block;margin-top:12px">Description<textarea id="desc" rows="2" style="width:100%"></textarea></label>
<label style="display:block;margin-top:12px">Visibility
- <select id="vis" style="width:100%">
- <option value="public" selected>Public (discoverable)</option>
- <option value="unlisted">Unlisted (anyone with link)</option>
- <option value="private" data-paid>Private (Pro plan)</option>
- </select>
+ <select id="vis" style="width:100%">${visibilityOptionsHtml('public')}</select>
</label>
<label style="display:block;margin-top:12px">Tags (comma separated)<input id="tags" style="width:100%"></label>
<div id="progress" class="muted" style="margin-top:12px"></div>
@@ -802,9 +983,7 @@ async function renderEdit(root, params = []) {
<label style="display:block">Name<input id="ename" value="${attr(avatar.name || '')}" maxlength="120" style="width:100%"></label>
<label style="display:block;margin-top:12px">Description<textarea id="edesc" rows="3" style="width:100%">${esc(avatar.description || '')}</textarea></label>
<label style="display:block;margin-top:12px">Visibility
- <select id="evis" style="width:100%">
- ${['private', 'unlisted', 'public'].map((v) => `<option ${v === avatar.visibility ? 'selected' : ''} value="${v}">${v}</option>`).join('')}
- </select>
+ <select id="evis" style="width:100%">${visibilityOptionsHtml(avatar.visibility)}</select>
</label>
<label style="display:block;margin-top:12px">Tags (comma separated)<input id="etags" value="${attr((avatar.tags || []).join(', '))}" style="width:100%"></label>
<div id="epublink" style="margin-top:16px;${avatar.visibility === 'private' ? 'display:none' : ''}">
diff --git a/public/dashboard/index.html b/public/dashboard/index.html
index ec4e4b7e5..af5606d1d 100644
--- a/public/dashboard/index.html
+++ b/public/dashboard/index.html
@@ -1118,7 +1118,7 @@
<a href="/widgets">Widgets</a>
<a href="/studio">Studio</a>
<a href="/docs">Docs</a>
- <a href="/my-agents">My Agents</a>
+ <a href="/my-agents" title="ERC-8004 agents controlled by your linked wallets">My Agents</a>
<a href="/dashboard" class="active" aria-current="page">Dashboard</a>
</nav>
<div class="dash-header-user">
@@ -1128,7 +1128,8 @@
</header>
<div class="layout">
<aside>
- <a href="/dashboard/avatars" class="active" data-tab="avatars">Avatars</a>
+ <a href="/dashboard/agents" class="active" data-tab="agents">Agents</a>
+ <a href="/dashboard/avatars" data-tab="avatars">Avatars</a>
<a href="/dashboard/create" data-tab="create">Create from selfie</a>
<a href="/dashboard/upload" data-tab="upload">Upload</a>
<a href="/dashboard/animations" data-tab="animations">Animations</a>
@@ -1151,6 +1152,9 @@
<a href="/reputation">Reputation</a>
<a href="/settings">Settings</a>
<a href="/admin" id="admin-link" style="display:none">Admin</a>
+ <a href="/my-agents" title="ERC-8004 agents controlled by your linked wallets"
+ >On-chain (ERC-8004) ↗</a
+ >
<a href="/discover" title="Browse on-chain agents across every supported chain"
>Discover on-chain ↗</a
>
diff --git a/public/dashboard/wallets.html b/public/dashboard/wallets.html
index 3823c4af2..a9f45b35f 100644
--- a/public/dashboard/wallets.html
+++ b/public/dashboard/wallets.html
@@ -205,7 +205,11 @@
<p style="color: #666">Loading wallets…</p>
</div>
- <button id="link-btn" class="btn" style="margin-top: 20px">Link Another Wallet</button>
+ <div class="row" style="margin-top: 20px; gap: 10px; flex-wrap: wrap">
+ <button id="link-evm-btn" class="btn">Link Ethereum Wallet</button>
+ <button id="link-solana-btn" class="btn sec">Link Solana Wallet</button>
+ </div>
+ <p class="muted" id="link-hint" style="margin-top: 10px"></p>
</main>
<script type="module">
@@ -238,13 +242,24 @@
}
}
+ function chainLabel(w) {
+ if (w.chain_type === 'solana') {
+ return w.chain_id && w.chain_id !== 'mainnet' ? `Solana (${w.chain_id})` : 'Solana';
+ }
+ if (w.chain_id) {
+ const evmNames = { 1: 'Ethereum', 8453: 'Base', 10: 'Optimism', 137: 'Polygon', 42161: 'Arbitrum', 56: 'BNB Chain' };
+ return evmNames[w.chain_id] || `Chain ${w.chain_id}`;
+ }
+ return w.chain_type === 'evm' ? 'Ethereum' : 'Unknown';
+ }
+
function renderWallets(wallets) {
const container = document.getElementById('wallets-container');
if (wallets.length === 0) {
container.innerHTML = `
<div class="empty">
<p>No wallets linked yet.</p>
- <p class="muted">Click "Link Another Wallet" to add your first wallet.</p>
+ <p class="muted">Click a link button below to add your first wallet.</p>
</div>
`;
return;
@@ -266,7 +281,7 @@
</button>
</div>
</td>
- <td class="meta">${w.chain_id ? `Chain ${w.chain_id}` : 'Multi-chain'}</td>
+ <td class="meta">${chainLabel(w)}</td>
<td class="meta">${new Date(w.created_at).toLocaleDateString()}</td>
<td>
${w.is_primary ? '<span class="pill">Primary</span>' : ''}
@@ -336,63 +351,161 @@
}
}
- async function linkWallet() {
- if (!window.ethereum) {
- showError('MetaMask not found. Please install it to link wallets.');
+ function detectEvmProvider() {
+ if (typeof window === 'undefined') return null;
+ const eth = window.ethereum;
+ if (!eth) return null;
+ // Prefer a non-Solana EVM injection. Phantom's EVM provider works but
+ // surfaces an address-match warning when used alongside a Solana session.
+ if (Array.isArray(eth.providers)) {
+ const real = eth.providers.find((p) => !p.isPhantom) || eth.providers[0];
+ return real;
+ }
+ return eth;
+ }
+
+ function detectSolanaProvider() {
+ if (typeof window === 'undefined') return null;
+ return window.phantom?.solana || window.solana || window.backpack || window.solflare || null;
+ }
+
+ async function linkEvmWallet() {
+ const provider = detectEvmProvider();
+ if (!provider) {
+ showError('No Ethereum wallet detected. Install MetaMask, Rabby, or Coinbase Wallet to link.');
return;
}
+ const btn = document.getElementById('link-evm-btn');
+ btn.disabled = true;
try {
- // 1. Request accounts + chain from MetaMask
- const accounts = await window.ethereum.request({
- method: 'eth_requestAccounts',
- });
+ const accounts = await provider.request({ method: 'eth_requestAccounts' });
const address = accounts[0];
- const chainIdHex = await window.ethereum.request({ method: 'eth_chainId' });
+ const chainIdHex = await provider.request({ method: 'eth_chainId' });
const chainId = parseInt(chainIdHex, 16);
- // 2. Get SIWE message + nonce from server (bound to this address + chain)
const nonceRes = await fetch(`${apiUrl}/auth/wallets/nonce`, {
method: 'POST',
credentials: 'include',
headers: { 'content-type': 'application/json' },
body: JSON.stringify({ address, chainId }),
});
- if (!nonceRes.ok) throw new Error('Failed to get nonce');
- const { message } = await nonceRes.json();
+ const nonceData = await nonceRes.json();
+ if (!nonceRes.ok) {
+ throw new Error(nonceData.error_description || 'Failed to get nonce');
+ }
+ const { message } = nonceData;
- // 3. Sign message with MetaMask
let signature;
try {
- signature = await window.ethereum.request({
+ signature = await provider.request({
method: 'personal_sign',
params: [message, address],
});
} catch (err) {
if (err.code === 4001) {
- showError('Signature cancelled by user');
+ showError('Signature cancelled');
} else {
showError(err.message || 'Signature failed');
}
return;
}
- // 4. Send signed message to server
const linkRes = await fetch(`${apiUrl}/auth/wallets`, {
method: 'POST',
credentials: 'include',
headers: { 'content-type': 'application/json' },
body: JSON.stringify({ message, signature }),
});
+ const linkData = await linkRes.json();
+ if (!linkRes.ok) {
+ throw new Error(linkData.error_description || 'Failed to link wallet');
+ }
+
+ showError('', 'success');
+ loadWallets();
+ } catch (err) {
+ showError(err.message);
+ } finally {
+ btn.disabled = false;
+ }
+ }
+
+ async function linkSolanaWallet() {
+ const provider = detectSolanaProvider();
+ if (!provider) {
+ showError('No Solana wallet detected. Install Phantom, Backpack, or Solflare to link.');
+ return;
+ }
+
+ const btn = document.getElementById('link-solana-btn');
+ btn.disabled = true;
+ try {
+ if (!provider.isConnected) {
+ await provider.connect();
+ }
+ const address = provider.publicKey?.toBase58?.() || provider.publicKey?.toString?.();
+ if (!address) throw new Error('Could not read wallet public key.');
+
+ const nonceRes = await fetch(`${apiUrl}/auth/wallets/nonce-solana`, {
+ method: 'POST',
+ credentials: 'include',
+ headers: { 'content-type': 'application/json' },
+ body: JSON.stringify({ address, chainId: 'mainnet' }),
+ });
+ const nonceData = await nonceRes.json();
+ if (!nonceRes.ok) {
+ throw new Error(nonceData.error_description || 'Failed to get nonce');
+ }
+
+ let sigBase64;
+ try {
+ const msgBytes = new TextEncoder().encode(nonceData.message);
+ const { signature } = await provider.signMessage(msgBytes, 'utf8');
+ sigBase64 = btoa(String.fromCharCode(...signature));
+ } catch (err) {
+ if (err?.code === 4001 || /reject/i.test(err?.message || '')) {
+ showError('Signature cancelled');
+ } else {
+ showError(err.message || 'Signature failed');
+ }
+ return;
+ }
+
+ const linkRes = await fetch(`${apiUrl}/auth/wallets/link-solana`, {
+ method: 'POST',
+ credentials: 'include',
+ headers: { 'content-type': 'application/json' },
+ body: JSON.stringify({ message: nonceData.message, signature: sigBase64 }),
+ });
+ const linkData = await linkRes.json();
if (!linkRes.ok) {
- const err = await linkRes.json();
- throw new Error(err.error_description || 'Failed to link wallet');
+ throw new Error(linkData.error_description || 'Failed to link wallet');
}
showError('', 'success');
loadWallets();
} catch (err) {
showError(err.message);
+ } finally {
+ btn.disabled = false;
+ }
+ }
+
+ function refreshLinkButtons() {
+ const evmBtn = document.getElementById('link-evm-btn');
+ const solBtn = document.getElementById('link-solana-btn');
+ const hint = document.getElementById('link-hint');
+ const hasEvm = !!detectEvmProvider();
+ const hasSol = !!detectSolanaProvider();
+ evmBtn.disabled = !hasEvm;
+ solBtn.disabled = !hasSol;
+ evmBtn.title = hasEvm ? '' : 'Install MetaMask, Rabby, or Coinbase Wallet';
+ solBtn.title = hasSol ? '' : 'Install Phantom, Backpack, or Solflare';
+ if (!hasEvm && !hasSol) {
+ hint.textContent = 'Install a browser wallet extension to link.';
+ } else {
+ hint.textContent = '';
}
}
@@ -428,7 +541,9 @@
}
})();
- document.getElementById('link-btn').addEventListener('click', linkWallet);
+ document.getElementById('link-evm-btn').addEventListener('click', linkEvmWallet);
+ document.getElementById('link-solana-btn').addEventListener('click', linkSolanaWallet);
+ refreshLinkButtons();
</script>
</body>
</html>
diff --git a/public/footer.html b/public/footer.html
index 6b69edda7..29281e45c 100644
--- a/public/footer.html
+++ b/public/footer.html
@@ -59,6 +59,7 @@
<a href="/create">Create</a>
<a href="/studio">Studio</a>
<a href="/widgets">Widgets</a>
+ <a href="/gallery">Gallery</a>
<a href="/discover">Discover</a>
<a href="/marketplace">Marketplace</a>
</div>
diff --git a/public/gallery/gallery.css b/public/gallery/gallery.css
index 1610a8fec..a5bf2bf4b 100644
--- a/public/gallery/gallery.css
+++ b/public/gallery/gallery.css
@@ -416,8 +416,15 @@ body.gallery-page {
}
.gallery-card-meta {
font-size: 11px;
- color: rgba(255, 255, 255, 0.4);
+ color: rgba(255, 255, 255, 0.45);
font-variant-numeric: tabular-nums;
+ display: inline-flex;
+ align-items: center;
+ gap: 6px;
+ min-width: 0;
+}
+.gallery-card-dot {
+ opacity: 0.5;
}
.gallery-card-actions {
display: inline-flex;
diff --git a/public/gallery/gallery.js b/public/gallery/gallery.js
index 2ee56e834..3557b9518 100644
--- a/public/gallery/gallery.js
+++ b/public/gallery/gallery.js
@@ -22,7 +22,7 @@ const els = {
loadMore: document.querySelector('[data-role="load-more"]'),
sentinel: document.querySelector('[data-role="sentinel"]'),
statCount: document.querySelector('[data-role="stat-count"]'),
- statTags: document.querySelector('[data-role="stat-tags"]'),
+ statViews: document.querySelector('[data-role="stat-views"]'),
myAvatarsChip: document.querySelector('[data-role="my-avatars-chip"]'),
};
@@ -35,6 +35,8 @@ const state = {
loading: false,
loadedTags: new Set(),
totalLoaded: 0,
+ total: null,
+ totalViews: null,
};
if (state.query) els.search.value = state.query;
@@ -128,6 +130,8 @@ function clearAllFilters() {
function resetAndLoad() {
state.cursor = null;
state.totalLoaded = 0;
+ state.total = null;
+ state.totalViews = null;
els.grid.innerHTML = '';
renderSkeletons(8);
loadPage();
@@ -173,6 +177,7 @@ async function loadPage() {
if (state.tag) params.set('tag', state.tag);
if (state.cursor) params.set('cursor', state.cursor);
params.set('limit', '24');
+ if (isFirstPage) params.set('totals', '1');
try {
const res = await fetch(`/api/avatars/public?${params.toString()}`);
@@ -188,8 +193,11 @@ async function loadPage() {
for (const t of a.tags || []) state.loadedTags.add(t);
}
- // Update stats — these are approximations (loaded so far, not corpus-wide,
- // since the public endpoint doesn't surface totals). Show what we know.
+ if (isFirstPage) {
+ if (typeof data.total === 'number') state.total = data.total;
+ if (typeof data.total_views === 'number') state.totalViews = data.total_views;
+ }
+
updateStats();
renderTags();
@@ -224,13 +232,17 @@ async function loadPage() {
}
function updateStats() {
- if (state.cursor) {
- // More pages exist — show a "≥N" hint without lying about a total.
- els.statCount.textContent = state.totalLoaded.toLocaleString() + '+';
- } else {
- els.statCount.textContent = state.totalLoaded.toLocaleString();
- }
- els.statTags.textContent = state.loadedTags.size.toLocaleString();
+ els.statCount.textContent =
+ state.total != null ? state.total.toLocaleString() : state.totalLoaded.toLocaleString();
+ els.statViews.textContent =
+ state.totalViews != null ? formatCompact(state.totalViews) : '—';
+}
+
+function formatCompact(n) {
+ if (n < 1000) return String(n);
+ if (n < 1_000_000) return (n / 1000).toFixed(n < 10_000 ? 1 : 0).replace(/\.0$/, '') + 'k';
+ if (n < 1_000_000_000) return (n / 1_000_000).toFixed(1).replace(/\.0$/, '') + 'M';
+ return (n / 1_000_000_000).toFixed(1).replace(/\.0$/, '') + 'B';
}
function renderTags() {
@@ -273,6 +285,7 @@ function renderCard(a) {
.join('');
const created = formatRelative(a.created_at);
+ const views = Number(a.view_count) || 0;
card.innerHTML = `
<a class="gallery-card-thumb" href="${escapeAttr(detailUrl)}" aria-label="${escapeAttr(a.name || 'Avatar')} details">
@@ -285,7 +298,11 @@ function renderCard(a) {
${a.description ? `<p class="gallery-card-desc">${escapeHtml(a.description)}</p>` : ''}
${tagChips ? `<div class="gallery-card-tags">${tagChips}</div>` : ''}
<div class="gallery-card-foot">
- <span class="gallery-card-meta">${escapeHtml(created)}</span>
+ <span class="gallery-card-meta">
+ <span title="${escapeAttr(new Date(a.created_at || Date.now()).toLocaleString())}">${escapeHtml(created)}</span>
+ <span class="gallery-card-dot" aria-hidden="true">·</span>
+ <span title="${views.toLocaleString()} view${views === 1 ? '' : 's'}">${formatCompact(views)} views</span>
+ </span>
<div class="gallery-card-actions">
<a class="gallery-card-btn" href="${escapeAttr(viewerUrl)}" title="Open in viewer">View 3D</a>
<a class="gallery-card-btn gallery-card-btn--primary" href="${escapeAttr(studioUrl)}" title="Use in Widget Studio">Use</a>
diff --git a/public/gallery/index.html b/public/gallery/index.html
index dda3fbc70..b7db26657 100644
--- a/public/gallery/index.html
+++ b/public/gallery/index.html
@@ -74,12 +74,12 @@
<div class="gallery-stat-label">Public avatars</div>
</div>
<div class="gallery-stat">
- <div class="gallery-stat-value" data-role="stat-tags">—</div>
- <div class="gallery-stat-label">Tags in use</div>
+ <div class="gallery-stat-value" data-role="stat-views">—</div>
+ <div class="gallery-stat-label">Total views</div>
</div>
<div class="gallery-stat">
- <div class="gallery-stat-value">3D</div>
- <div class="gallery-stat-label">glTF / GLB</div>
+ <div class="gallery-stat-value">glTF</div>
+ <div class="gallery-stat-label">Format</div>
</div>
</div>
</div>
diff --git a/public/home-polish.css b/public/home-polish.css
index 905ce18e4..e5c6c78d7 100644
--- a/public/home-polish.css
+++ b/public/home-polish.css
@@ -1,8 +1,8 @@
/* ───────────────────────────────────────────────────────────────────────────
- home-polish.css — additive professional polish over home.css.
- Loaded AFTER /home.css from home.html. Nothing here removes prior styles;
- it tightens typography, adds a section rail, numbers pillars, glows
- bento cards, refines focus rings, and adds a copy button + scroll bar.
+ home-polish.css — additive, restrained polish over home.css.
+ Loaded AFTER /home.css from home.html. Tightens typography, adds a
+ monochrome section rail, numbers the pillars, glows bento cards on
+ pointer-move, refines focus rings, and adds a copy button.
─────────────────────────────────────────────────────────────────────────── */
/* ── Typographic polish ─────────────────────────────────────────────────── */
@@ -37,49 +37,20 @@
text-wrap: pretty;
}
-/* ── Top scroll progress bar ────────────────────────────────────────────── */
-
-.h-scroll-progress {
- position: fixed;
- top: 0;
- left: 0;
- height: 2px;
- width: 0%;
- z-index: 250;
- background: linear-gradient(
- 90deg,
- rgba(255, 215, 106, 0.95) 0%,
- rgba(255, 143, 77, 0.95) 50%,
- rgba(167, 139, 250, 0.95) 100%
- );
- box-shadow:
- 0 0 12px rgba(255, 175, 60, 0.55),
- 0 0 24px rgba(255, 175, 60, 0.25);
- pointer-events: none;
- transition: width 0.08s linear;
- border-bottom-right-radius: 2px;
-}
-
-/* ── Right-side chapter rail (anchor nav) ───────────────────────────────── */
+/* ── Right-side chapter rail (monochrome, restrained) ───────────────────── */
.h-chapter-rail {
position: fixed;
top: 50%;
- right: clamp(0.85rem, 1.5vw, 1.5rem);
- transform: translateY(-50%);
+ right: clamp(0.9rem, 1.4vw, 1.4rem);
z-index: 180;
display: flex;
flex-direction: column;
- gap: 0.85rem;
- padding: 0.85rem 0.55rem;
- background: rgba(10, 8, 6, 0.35);
- border: 1px solid rgba(255, 255, 255, 0.06);
- border-radius: 999px;
- backdrop-filter: blur(10px) saturate(140%);
- -webkit-backdrop-filter: blur(10px) saturate(140%);
+ gap: 0.7rem;
+ padding: 0.6rem 0.45rem;
pointer-events: auto;
opacity: 0;
- transform: translateY(-50%) translateX(10px);
+ transform: translateY(-50%) translateX(8px);
transition:
opacity 0.4s ease,
transform 0.4s ease;
@@ -93,56 +64,46 @@
.h-chapter-dot {
position: relative;
display: block;
- width: 10px;
- height: 10px;
+ width: 6px;
+ height: 6px;
border-radius: 50%;
background: rgba(255, 255, 255, 0.18);
- border: 1px solid rgba(255, 255, 255, 0.08);
cursor: pointer;
transition:
background 0.25s ease,
- border-color 0.25s ease,
- transform 0.25s ease,
+ width 0.25s ease,
+ height 0.25s ease,
box-shadow 0.25s ease;
}
.h-chapter-dot:hover {
- background: rgba(255, 215, 106, 0.7);
- border-color: rgba(255, 215, 106, 0.9);
- transform: scale(1.15);
+ background: rgba(255, 255, 255, 0.55);
}
.h-chapter-dot.is-active {
- background: linear-gradient(135deg, #ffd76a, #ff8f4d);
- border-color: rgba(255, 215, 106, 0.95);
- box-shadow:
- 0 0 0 3px rgba(255, 175, 60, 0.18),
- 0 0 14px rgba(255, 143, 77, 0.55);
+ background: rgba(255, 255, 255, 0.95);
+ width: 6px;
+ height: 18px;
+ border-radius: 3px;
}
.h-chapter-dot .h-chapter-label {
position: absolute;
- right: calc(100% + 0.9rem);
+ right: calc(100% + 0.75rem);
top: 50%;
- transform: translateY(-50%) translateX(6px);
+ transform: translateY(-50%) translateX(4px);
font-family: 'Space Grotesk', 'Inter', sans-serif;
- font-size: 0.7rem;
- font-weight: 600;
- letter-spacing: 0.08em;
+ font-size: 0.66rem;
+ font-weight: 500;
+ letter-spacing: 0.1em;
text-transform: uppercase;
color: rgba(255, 255, 255, 0.85);
- background: rgba(10, 8, 6, 0.85);
- border: 1px solid rgba(255, 255, 255, 0.08);
- padding: 0.35rem 0.7rem;
- border-radius: 6px;
white-space: nowrap;
pointer-events: none;
opacity: 0;
transition:
- opacity 0.2s ease,
- transform 0.2s ease;
- backdrop-filter: blur(6px);
- -webkit-backdrop-filter: blur(6px);
+ opacity 0.18s ease,
+ transform 0.18s ease;
}
.h-chapter-dot:hover .h-chapter-label,
@@ -153,12 +114,10 @@
.h-chapter-dot:focus-visible {
outline: none;
- box-shadow:
- 0 0 0 3px rgba(255, 175, 60, 0.35),
- 0 0 14px rgba(255, 143, 77, 0.55);
+ box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.25);
}
-@media (max-width: 880px) {
+@media (max-width: 980px) {
.h-chapter-rail {
display: none;
}
@@ -167,80 +126,69 @@
@media (prefers-reduced-motion: reduce) {
.h-chapter-rail,
.h-chapter-dot,
- .h-chapter-dot .h-chapter-label,
- .h-scroll-progress {
+ .h-chapter-dot .h-chapter-label {
transition: none;
}
}
-/* ── Pillar number badges + card polish ─────────────────────────────────── */
+/* ── Pillar number labels + card polish ─────────────────────────────────── */
.h-pillar {
position: relative;
- padding: clamp(1.25rem, 2vw, 1.75rem);
+ padding: clamp(1.4rem, 2vw, 1.85rem);
border: 1px solid rgba(255, 255, 255, 0.06);
border-radius: 14px;
- background:
- linear-gradient(
- 180deg,
- rgba(255, 215, 106, 0.04) 0%,
- rgba(255, 255, 255, 0.012) 35%,
- rgba(255, 255, 255, 0) 100%
- ),
- rgba(255, 255, 255, 0.015);
+ background: rgba(255, 255, 255, 0.012);
overflow: hidden;
transition:
border-color 0.35s cubic-bezier(0.2, 0.9, 0.3, 1),
transform 0.35s cubic-bezier(0.2, 0.9, 0.3, 1),
- box-shadow 0.35s cubic-bezier(0.2, 0.9, 0.3, 1);
+ background 0.35s cubic-bezier(0.2, 0.9, 0.3, 1);
}
.h-pillar::before {
content: '';
position: absolute;
top: 0;
- left: 0;
- right: 0;
+ left: 1.4rem;
+ right: 1.4rem;
height: 1px;
background: linear-gradient(
90deg,
transparent 0%,
- rgba(255, 215, 106, 0.55) 50%,
+ rgba(255, 215, 106, 0.4) 50%,
transparent 100%
);
- opacity: 0.7;
}
.h-pillar:hover {
- border-color: rgba(255, 215, 106, 0.22);
- transform: translateY(-3px);
- box-shadow:
- 0 18px 40px -22px rgba(255, 143, 77, 0.35),
- 0 0 0 1px rgba(255, 215, 106, 0.08) inset;
+ border-color: rgba(255, 255, 255, 0.14);
+ background: rgba(255, 255, 255, 0.025);
+ transform: translateY(-2px);
}
.h-pillar-num {
- display: inline-block;
+ display: inline-flex;
+ align-items: center;
+ gap: 0.55rem;
font-family: 'JetBrains Mono', monospace;
- font-size: 0.7rem;
+ font-size: 0.68rem;
font-weight: 500;
letter-spacing: 0.14em;
+ text-transform: uppercase;
color: rgba(255, 215, 106, 0.7);
- margin-bottom: 0.85rem;
+ margin-bottom: 0.95rem;
}
.h-pillar-num::before {
content: '';
display: inline-block;
- width: 18px;
+ width: 16px;
height: 1px;
- background: rgba(255, 215, 106, 0.45);
- vertical-align: middle;
- margin-right: 0.55rem;
- transform: translateY(-1px);
+ background: rgba(255, 215, 106, 0.4);
}
-/* ── Bento card hover glow ──────────────────────────────────────────────── */
+/* ── Bento card hover glow (cursor-tracked, very subtle) ─────────────────── */
.h-bento-card {
position: relative;
@@ -253,11 +201,11 @@
border-radius: inherit;
pointer-events: none;
opacity: 0;
- transition: opacity 0.35s ease;
+ transition: opacity 0.4s ease;
background: radial-gradient(
- 380px circle at var(--bx, 50%) var(--by, 0%),
- rgba(255, 175, 60, 0.07) 0%,
- transparent 60%
+ 360px circle at var(--bx, 50%) var(--by, 0%),
+ rgba(255, 175, 60, 0.05) 0%,
+ transparent 55%
);
}
@@ -265,6 +213,61 @@
opacity: 1;
}
+/* ── Bento "verifiable identity" cleanup (replaces inline styles) ────────── */
+
+.h-bento-id .h-id-dot {
+ width: 8px;
+ height: 8px;
+ border-radius: 50%;
+ flex-shrink: 0;
+}
+
+.h-bento-id .h-id-dot--mint {
+ background: #6ee7b7;
+ box-shadow: 0 0 8px rgba(110, 231, 183, 0.85);
+}
+
+.h-bento-id .h-id-addr {
+ font-family: 'JetBrains Mono', monospace;
+ font-size: 0.72rem;
+ color: rgba(255, 255, 255, 0.6);
+ letter-spacing: 0.02em;
+}
+
+/* ── Bento "six emotions" cleanup (replaces ✦ ? ♥ ! glyphs) ──────────────── */
+
+.h-bento-emotions {
+ list-style: none;
+ padding: 0;
+ margin: 0.5rem 0 0;
+ display: flex;
+ flex-wrap: wrap;
+ gap: 0.35rem;
+}
+
+.h-bento-emotions li {
+ display: inline-flex;
+ align-items: center;
+ gap: 0.45em;
+ font-family: 'Space Grotesk', 'Inter', sans-serif;
+ font-size: 0.7rem;
+ font-weight: 500;
+ color: rgba(167, 139, 250, 0.78);
+ border: 1px solid rgba(167, 139, 250, 0.22);
+ border-radius: 999px;
+ padding: 0.25rem 0.65rem 0.25rem 0.55rem;
+ background: rgba(167, 139, 250, 0.04);
+}
+
+.h-bento-emotions .h-em-dot {
+ width: 5px;
+ height: 5px;
+ border-radius: 50%;
+ background: rgba(167, 139, 250, 0.85);
+ box-shadow: 0 0 6px rgba(167, 139, 250, 0.55);
+ flex-shrink: 0;
+}
+
/* ── Dev code: copy button ──────────────────────────────────────────────── */
.h-dev-code {
@@ -281,11 +284,11 @@
gap: 0.4em;
padding: 0.35rem 0.65rem;
font-family: 'Space Grotesk', 'Inter', sans-serif;
- font-size: 0.68rem;
+ font-size: 0.66rem;
font-weight: 600;
- letter-spacing: 0.08em;
+ letter-spacing: 0.1em;
text-transform: uppercase;
- color: rgba(255, 255, 255, 0.6);
+ color: rgba(255, 255, 255, 0.55);
background: rgba(255, 255, 255, 0.04);
border: 1px solid rgba(255, 255, 255, 0.08);
border-radius: 6px;
@@ -299,8 +302,8 @@
.h-dev-copy:hover {
color: #fff;
- background: rgba(255, 215, 106, 0.08);
- border-color: rgba(255, 215, 106, 0.35);
+ background: rgba(255, 255, 255, 0.06);
+ border-color: rgba(255, 255, 255, 0.18);
}
.h-dev-copy:active {
@@ -309,8 +312,8 @@
.h-dev-copy.is-copied {
color: #6ee7b7;
- background: rgba(110, 231, 183, 0.1);
- border-color: rgba(110, 231, 183, 0.45);
+ background: rgba(110, 231, 183, 0.08);
+ border-color: rgba(110, 231, 183, 0.4);
}
.h-dev-copy svg {
@@ -340,12 +343,12 @@
0 6px 24px -8px rgba(255, 143, 77, 0.55);
}
-/* ── Section anchor offset so chapter-rail jumps don't hide under header ── */
+/* ── Scroll-margin so chapter-rail jumps don't hide under sticky header ──── */
#pick-animate,
#deploy-act,
.h-bento-section,
.h-dev-section,
.h-cta-section {
- scroll-margin-top: 80px;
+ scroll-margin-top: 88px;
}
diff --git a/public/home-polish.js b/public/home-polish.js
index 1dd872693..b47f1eb20 100644
--- a/public/home-polish.js
+++ b/public/home-polish.js
@@ -1,5 +1,4 @@
/* home-polish.js — enhances home.html with:
- * - top scroll-progress bar
* - right-side chapter rail with active-section tracking
* - "Copy" button for the developer code snippet
* - cursor-tracked radial glow on bento cards
@@ -19,42 +18,11 @@
var main = document.querySelector('main.home-parallax');
if (!main) return;
- mountScrollProgress();
mountChapterRail(main);
mountDevCopyButton();
mountBentoGlow();
});
- /* ── Scroll progress bar ─────────────────────────────────────────────── */
-
- function mountScrollProgress() {
- var bar = document.createElement('div');
- bar.className = 'h-scroll-progress';
- bar.setAttribute('aria-hidden', 'true');
- document.body.appendChild(bar);
-
- var ticking = false;
- var update = function () {
- var doc = document.documentElement;
- var max = doc.scrollHeight - doc.clientHeight;
- var pct = max > 0 ? (doc.scrollTop / max) * 100 : 0;
- bar.style.width = pct.toFixed(2) + '%';
- ticking = false;
- };
-
- window.addEventListener(
- 'scroll',
- function () {
- if (!ticking) {
- window.requestAnimationFrame(update);
- ticking = true;
- }
- },
- { passive: true },
- );
- update();
- }
-
/* ── Chapter rail with IntersectionObserver active-state ─────────────── */
function mountChapterRail(main) {
diff --git a/public/lobehub/iframe/index.html b/public/lobehub/iframe/index.html
index a0c5ad12f..f66892211 100644
--- a/public/lobehub/iframe/index.html
+++ b/public/lobehub/iframe/index.html
@@ -58,6 +58,6 @@
<div id="status">Loading…</div>
<!-- agent-id is set dynamically by boot.js from ?agent= query param -->
<agent-3d id="agent" kiosk eager></agent-3d>
- <script type="module" src="./boot.js"></script>
+ <script type="module" src="/lobehub/iframe/boot.js"></script>
</body>
</html>
diff --git a/public/my-agents/index.html b/public/my-agents/index.html
index 2985c2af6..0cfca534f 100644
--- a/public/my-agents/index.html
+++ b/public/my-agents/index.html
@@ -5,7 +5,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="robots" content="noindex" />
<title>My Agents · three.ws</title>
- <meta name="description" content="Your ERC-8004 agents across every supported chain." />
+ <meta name="description" content="ERC-8004 agents discovered across the wallets you've linked to three.ws." />
<link rel="canonical" href="https://three.ws/my-agents" />
<link rel="icon" href="/favicon.ico" />
<link rel="stylesheet" href="/my-agents/my-agents.css" />
@@ -20,14 +20,18 @@
<a href="/widgets">Widgets</a>
<a href="/studio">Studio</a>
<a href="/docs">Docs</a>
- <a href="/my-agents" aria-current="page">My Agents</a>
- <a href="/dashboard">Dashboard</a>
+ <a href="/my-agents" aria-current="page" title="ERC-8004 agents controlled by your linked wallets">My Agents</a>
+ <a href="/dashboard" title="Manage three.ws agents, avatars, widgets, billing">Dashboard</a>
</nav>
</header>
<main class="my-agents-main" id="my-agents-main">
<h1 class="my-agents-title">My Agents</h1>
- <p class="my-agents-subtitle">Agents from your account and linked wallets</p>
+ <p class="my-agents-subtitle">
+ ERC-8004 agents discovered across your linked wallets. Looking for agents you
+ created on three.ws? Open the
+ <a href="/dashboard/agents">dashboard</a>.
+ </p>
<div
id="my-agents-error"
@@ -47,6 +51,6 @@
></div>
</main>
- <script type="module" src="./my-agents.js"></script>
+ <script type="module" src="/my-agents/my-agents.js"></script>
</body>
</html>
diff --git a/public/my-agents/my-agents.js b/public/my-agents/my-agents.js
index 78d716462..b0ef24a67 100644
--- a/public/my-agents/my-agents.js
+++ b/public/my-agents/my-agents.js
@@ -1,7 +1,8 @@
/**
- * /my-agents — personal on-chain agent page.
- * Fetches agents owned by the signed-in user's linked wallets and renders them
- * as importable cards.
+ * /my-agents — personal on-chain (ERC-8004) agent page.
+ * Lists ERC-8004 agents discovered across the signed-in user's linked wallets
+ * and lets them be imported into the three.ws library. Agents the user
+ * created natively on three.ws live in /dashboard/agents.
*/
async function fetchDiscoveredAgents() {
@@ -14,14 +15,20 @@ async function fetchDiscoveredAgents() {
return data.agents || [];
}
-async function fetchNormalAgents() {
+async function fetchImportedAgentKeys() {
const res = await fetch('/api/agents', { method: 'GET', credentials: 'include' });
if (!res.ok) {
const error = await res.json().catch(() => ({}));
throw new Error(error.error_description || `HTTP ${res.status}`);
}
const data = await res.json();
- return data.agents || [];
+ const imported = new Map();
+ for (const a of data.agents || []) {
+ if (a.chain_id != null && a.erc8004_agent_id != null) {
+ imported.set(`${a.chain_id}:${a.erc8004_agent_id}`, a.id);
+ }
+ }
+ return imported;
}
async function importAgent({ chainId, agentId }) {
@@ -152,8 +159,8 @@ function showErrorBanner(msg, retry = true) {
}
/**
- * Render one agent card.
- * @param {{ chainId: number, agentId: string, name: string, description: string, image: string|null, glbUrl: string|null, alreadyImported?: boolean, isNormal?: boolean, onChain?: boolean }} agent
+ * Render one ERC-8004 on-chain agent card.
+ * @param {{ chainId: number, agentId: string, name: string, description: string, image: string|null, glbUrl: string|null, alreadyImported?: boolean, importedId?: string|null }} agent
* @returns {HTMLElement}
*/
function buildCard(agent) {
@@ -164,7 +171,7 @@ function buildCard(agent) {
const thumbSrc = agent.glbUrl || agent.image;
const thumbHtml = thumbSrc
? `<img src="${escapeHtml(thumbSrc)}" alt="${escapeHtml(agent.name)} preview" loading="lazy" />`
- : `<span aria-hidden="true">${agent.isNormal ? '◎' : '🤖'}</span>`;
+ : `<span aria-hidden="true">🤖</span>`;
card.innerHTML = `
<div class="my-agents-card__thumb">${thumbHtml}</div>
@@ -180,21 +187,16 @@ function buildCard(agent) {
</div>`;
const wrap = /** @type {HTMLElement} */ (card.querySelector('.my-agents-card__action-wrap'));
- _renderCardAction(wrap, agent);
+ _renderCardAction(wrap, agent, agent.importedId || null);
return card;
}
/**
* @param {HTMLElement} wrap
- * @param {{ chainId: number, agentId: string, name: string, alreadyImported?: boolean, isNormal?: boolean }} agent
+ * @param {{ chainId: number, agentId: string, name: string, alreadyImported?: boolean }} agent
* @param {string|null} [importedId]
*/
function _renderCardAction(wrap, agent, importedId = null) {
- if (agent.isNormal) {
- wrap.innerHTML = `<a class="my-agents-btn" href="/agent/${escapeHtml(agent.agentId)}">Open</a>`;
- return;
- }
-
if (agent.alreadyImported || importedId) {
const id = importedId || '';
wrap.innerHTML = `
@@ -244,80 +246,47 @@ async function loadAgents() {
showSkeletons();
try {
- const [onChainAgents, normalAgents] = await Promise.all([
- fetchDiscoveredAgents().catch(e => { console.error("Error fetching on-chain agents:", e); return []; }),
- fetchNormalAgents().catch(e => { console.error("Error fetching normal agents:", e); return []; })
+ // Imported keys is a lookup, not a hard dependency — if it fails we still
+ // render the on-chain list (Import will just retry against the API).
+ const [onChainAgents, importedKeys] = await Promise.all([
+ fetchDiscoveredAgents(),
+ fetchImportedAgentKeys().catch((e) => {
+ console.error('Error fetching imported agents:', e);
+ return new Map();
+ }),
]);
- const onChainAgentsMap = new Map();
- for (const agent of onChainAgents) {
- onChainAgentsMap.set(`${agent.chainId}:${agent.agentId}`, agent);
- }
-
- const allAgents = [];
- const processedOnChain = new Set();
-
- // Add normal agents, and if they are on-chain, merge info
- for (const agent of normalAgents) {
- const onChainKey = `${agent.chain_id}:${agent.erc8004_agent_id}`;
- const onChainData = onChainAgentsMap.get(onChainKey);
-
- const cardData = {
- chainId: agent.chain_id,
- agentId: agent.id, // Internal UUID
- name: agent.name,
- description: agent.description,
- image: agent.avatar_id ? `/api/avatars/${agent.avatar_id}/thumbnail` : (onChainData ? onChainData.image : null),
- glbUrl: onChainData ? onChainData.glbUrl : null,
- isNormal: true,
- onChain: !!onChainData
- };
- allAgents.push(cardData);
-
- if (onChainData) {
- processedOnChain.add(onChainKey);
- }
- }
-
- // Add on-chain agents that haven't been imported yet
- for (const agent of onChainAgents) {
- const onChainKey = `${agent.chainId}:${agent.agentId}`;
- if (!processedOnChain.has(onChainKey)) {
- allAgents.push({
- ...agent, // has name, description, image, glbUrl
- isNormal: false,
- onChain: true
- });
- }
- }
-
grid.innerHTML = '';
- if (allAgents.length === 0) {
+ if (onChainAgents.length === 0) {
showState(
'🔭',
- 'No agents yet',
- 'No agents found. Link a wallet or create a new agent.',
- { label: 'Create an agent', href: '/create' },
- { label: 'Browse community agents →', href: '/discover' },
+ 'No on-chain agents found',
+ 'None of your linked wallets own an ERC-8004 agent yet. Mint one, or browse community agents.',
+ { label: 'Mint an on-chain agent', href: '/deploy' },
+ { label: 'Or browse community agents →', href: '/discover' },
);
return;
}
- document.querySelector('.my-agents-title').textContent = 'My Agents';
- document.querySelector('.my-agents-subtitle').textContent = 'Agents from your account and linked wallets';
-
- for (const agent of allAgents) {
- grid.appendChild(buildCard(agent));
+ for (const agent of onChainAgents) {
+ const key = `${agent.chainId}:${agent.agentId}`;
+ const importedId = importedKeys.get(key) || null;
+ grid.appendChild(
+ buildCard({
+ ...agent,
+ alreadyImported: !!importedId,
+ importedId,
+ }),
+ );
}
-
} catch (err) {
grid.innerHTML = '';
const msg = err.message || '';
if (msg.includes('429') || /too many/i.test(msg)) {
showErrorBanner('Too many requests. Try again in a minute.', true);
} else {
- showErrorBanner(msg || 'Failed to load agents.', true);
+ showErrorBanner(msg || 'Failed to load on-chain agents.', true);
}
}
}
@@ -358,8 +327,8 @@ async function loadAgents() {
showState(
'👛',
'No wallets linked',
- 'Link a wallet to see your on-chain agents.',
- { label: 'Link a wallet', href: '/dashboard/wallets.html' },
+ 'Link a wallet to see your on-chain (ERC-8004) agents.',
+ { label: 'Link a wallet', href: '/dashboard/wallets' },
{ label: 'Or browse community agents →', href: '/discover' },
);
return;
diff --git a/public/settings/index.html b/public/settings/index.html
index 6548f2984..639187484 100644
--- a/public/settings/index.html
+++ b/public/settings/index.html
@@ -491,6 +491,19 @@
</div>
</div>
<span class="inline-msg" id="github-msg" style="display:none;margin-top:10px"></span>
+
+ <div class="social-card" id="x-card" style="margin-top:14px">
+ <div id="x-connect-status">
+ <div class="provider-info">
+ <div class="provider-icon">𝕏</div>
+ <div>
+ <div class="provider-name">X (Twitter)</div>
+ <div class="provider-meta">Loading…</div>
+ </div>
+ </div>
+ </div>
+ </div>
+ <span class="inline-msg" id="x-msg" style="display:none;margin-top:10px"></span>
</div>
<div class="agent-seed-area" id="seed-area" style="display:none">
diff --git a/public/studio-deposit-harness.html b/public/studio-deposit-harness.html
new file mode 100644
index 000000000..5303f4543
--- /dev/null
+++ b/public/studio-deposit-harness.html
@@ -0,0 +1,10 @@
+<!DOCTYPE html>
+<html>
+<head><meta charset="utf-8"><title>deposit harness</title>
+<style>body{background:#0a0c0e;color:#fff;font-family:system-ui;padding:2rem}#root{max-width:380px}</style>
+</head>
+<body>
+<div id="root"></div>
+<script type="module" src="/studio-deposit-harness.js"></script>
+</body>
+</html>
diff --git a/public/studio-deposit-harness.js b/public/studio-deposit-harness.js
new file mode 100644
index 000000000..eb51c1472
--- /dev/null
+++ b/public/studio-deposit-harness.js
@@ -0,0 +1,9 @@
+import { mountLaunchPanel } from '/studio/launch-panel.js';
+const fakeAvatar = { id: 'test-avatar', agent_id: 'agent-x', name: 'Test', description: 'test desc', thumbnail_url: null };
+const fakeUser = { id: 'user-x', email: '[email protected]' };
+mountLaunchPanel(document.getElementById('root'), {
+ getAvatar: () => fakeAvatar,
+ getUser: () => fakeUser,
+ getPreviewViewer: () => null,
+}).avatarChanged();
+window.__ready = true;
diff --git a/public/studio/index.html b/public/studio/index.html
index 9fa29777e..4aa3638df 100644
--- a/public/studio/index.html
+++ b/public/studio/index.html
@@ -92,10 +92,7 @@
<a href="/widgets">Widgets</a>
<a href="/studio" aria-current="page">Studio</a>
<a href="/docs">Docs</a>
- <a href="/my-agents">My Agents</a>
- <a href="/dashboard">Dashboard</a>
- <a class="btn-ghost" id="signin-link" href="/login?next=/studio" hidden>Sign in</a>
- <button class="btn-ghost" id="signout-btn" type="button" hidden>Sign out</button>
+ <div id="user-menu" class="user-menu" data-state="loading"></div>
</nav>
</header>
diff --git a/public/studio/launch-panel.js b/public/studio/launch-panel.js
index 18464b582..326b9f8b7 100644
--- a/public/studio/launch-panel.js
+++ b/public/studio/launch-panel.js
@@ -96,6 +96,27 @@ const LP_CSS = `
.lp-src button[disabled]{opacity:.4;cursor:not-allowed}
.lp-src-sub{display:block;font-size:.62rem;color:rgba(255,255,255,.32);font-weight:400;margin-top:.15rem;letter-spacing:.01em}
.lp-src button.on .lp-src-sub{color:rgba(164,240,188,.55)}
+
+/* Coin-type selector */
+.lp-coin{display:grid;grid-template-columns:repeat(4,1fr);gap:.3rem;padding:.25rem;
+ background:rgba(255,255,255,.03);border:1px solid rgba(255,255,255,.07);border-radius:10px}
+.lp-coin button{padding:.5rem .35rem;border-radius:7px;cursor:pointer;background:transparent;
+ border:1px solid transparent;color:rgba(255,255,255,.5);font-size:.74rem;font-weight:600;
+ transition:all .15s;line-height:1.2;text-align:center}
+.lp-coin button:hover:not(.on):not([disabled]){color:rgba(255,255,255,.85);background:rgba(255,255,255,.03)}
+.lp-coin button.on{background:rgba(164,240,188,.12);border-color:rgba(164,240,188,.32);color:#c8f0d8}
+.lp-coin button.mayhem.on{background:rgba(246,140,80,.14);border-color:rgba(246,140,80,.38);color:#f6c498}
+.lp-coin button.usdc.on{background:rgba(120,160,240,.12);border-color:rgba(120,160,240,.34);color:#a8c4f0}
+.lp-coin button[disabled]{opacity:.42;cursor:not-allowed}
+.lp-coin-sub{display:block;font-size:.6rem;color:rgba(255,255,255,.32);font-weight:400;margin-top:.18rem;letter-spacing:.01em}
+.lp-coin button.on .lp-coin-sub{color:rgba(200,240,216,.62)}
+.lp-coin button.mayhem.on .lp-coin-sub{color:rgba(246,196,152,.72)}
+.lp-coin button.usdc.on .lp-coin-sub{color:rgba(168,196,240,.72)}
+.lp-coin-emoji{display:block;font-size:.95rem;line-height:1;margin-bottom:.18rem}
+.lp-coin-note{font-size:.7rem;color:rgba(255,255,255,.42);line-height:1.5;padding:.45rem .65rem;
+ background:rgba(255,255,255,.025);border:1px solid rgba(255,255,255,.06);border-radius:8px}
+.lp-coin-note.mayhem{color:rgba(246,196,152,.85);background:rgba(246,140,80,.07);border-color:rgba(246,140,80,.2)}
+.lp-coin-note.usdc{color:rgba(168,196,240,.85);background:rgba(120,160,240,.07);border-color:rgba(120,160,240,.22)}
.lp-empty{text-align:center;padding:2.5rem 1rem;color:rgba(255,255,255,.3);font-size:.85rem;line-height:1.7}
.lp-empty a{color:rgba(164,240,188,.7);text-decoration:none}
.lp-empty a:hover{color:#a4f0bc}
@@ -335,6 +356,10 @@ export function mountLaunchPanel(container, { getAvatar, getUser, getPreviewView
imageFile: null, imagePreviewUrl: null,
_symbolEdited: false,
+ // coin type: 'agent' (default — buyback-bound), 'regular' (plain pump.fun coin),
+ // 'mayhem' (pump.fun mayhem mode), 'usdc' (USDC-denominated agent — coming soon)
+ coinType: 'agent',
+
// wallet source: 'connected' (Phantom/Backpack) or 'agent' (custodial agent wallet)
walletSource: 'connected',
@@ -525,12 +550,16 @@ export function mountLaunchPanel(container, { getAvatar, getUser, getPreviewView
}
async function copyAddressToClipboard(btn) {
- if (!s.walletAddr) return;
- try { await navigator.clipboard.writeText(s.walletAddr); } catch { return; }
- if (!btn) return;
+ if (!s.walletAddr || !btn) return;
const orig = btn.textContent;
- btn.textContent = '✓ Copied full address';
- setTimeout(() => { btn.textContent = orig; }, 1600);
+ try {
+ await navigator.clipboard.writeText(s.walletAddr);
+ btn.textContent = '✓ Copied full address';
+ } catch (err) {
+ console.warn('[launch-panel] clipboard write failed', err);
+ btn.textContent = 'Copy failed';
+ }
+ setTimeout(() => { if (btn.isConnected) btn.textContent = orig; }, 1800);
}
async function openDepositModal() {
@@ -555,7 +584,9 @@ export function mountLaunchPanel(container, { getAvatar, getUser, getPreviewView
<button class="lp-dep-x" id="lp-dep-close" aria-label="Close">✕</button>
</div>
<span class="lp-dep-net">SOLANA · MAINNET</span>
- <div class="lp-dep-qr" id="lp-dep-qr"><div class="lp-dep-qr-load" aria-label="Loading QR code"></div></div>
+ <div class="lp-dep-qr" id="lp-dep-qr">
+ <div class="lp-dep-qr-load" role="status" aria-live="polite" aria-label="Loading QR code"></div>
+ </div>
<div class="lp-dep-addr" id="lp-dep-addr" role="button" tabindex="0" aria-label="Copy wallet address">
<code>${esc(addr)}</code>
<span class="lp-dep-addr-copy" id="lp-dep-addr-label">Copy</span>
@@ -572,24 +603,44 @@ export function mountLaunchPanel(container, { getAvatar, getUser, getPreviewView
bd.remove();
document.removeEventListener('keydown', onKey);
document.body.style.overflow = prevOverflow;
- if (prevActive && typeof prevActive.focus === 'function') prevActive.focus();
+ if (prevActive && prevActive.isConnected && typeof prevActive.focus === 'function') {
+ prevActive.focus();
+ }
+ };
+
+ // Focus trap: cycle Tab/Shift+Tab between the modal's interactive elements.
+ const FOCUSABLE = '#lp-dep-close, #lp-dep-addr';
+ const onKey = (e) => {
+ if (e.key === 'Escape') { close(); return; }
+ if (e.key !== 'Tab') return;
+ const items = Array.from(bd.querySelectorAll(FOCUSABLE));
+ if (items.length === 0) return;
+ const first = items[0], last = items[items.length - 1];
+ const active = document.activeElement;
+ if (e.shiftKey && (active === first || !bd.contains(active))) {
+ e.preventDefault(); last.focus();
+ } else if (!e.shiftKey && (active === last || !bd.contains(active))) {
+ e.preventDefault(); first.focus();
+ }
};
- const onKey = (e) => { if (e.key === 'Escape') close(); };
document.addEventListener('keydown', onKey);
bd.addEventListener('click', (e) => { if (e.target === bd) close(); });
bd.querySelector('#lp-dep-close').addEventListener('click', close);
- const copyAddr = async () => {
- try { await navigator.clipboard.writeText(addr); }
- catch {
- const label = bd.querySelector('#lp-dep-addr-label');
- if (label) { label.textContent = 'Copy failed'; setTimeout(() => { label.textContent = 'Copy'; }, 1800); }
- return;
- }
+ const setLabel = (text, restore = true) => {
const label = bd.querySelector('#lp-dep-addr-label');
if (!label) return;
- label.textContent = '✓ Copied';
- setTimeout(() => { if (!closed) label.textContent = 'Copy'; }, 1800);
+ label.textContent = text;
+ if (restore) setTimeout(() => { if (!closed) label.textContent = 'Copy'; }, 1800);
+ };
+ const copyAddr = async () => {
+ try {
+ await navigator.clipboard.writeText(addr);
+ setLabel('✓ Copied');
+ } catch (err) {
+ console.warn('[launch-panel] clipboard write failed', err);
+ setLabel('Copy failed');
+ }
};
const addrEl = bd.querySelector('#lp-dep-addr');
addrEl.addEventListener('click', copyAddr);
@@ -611,7 +662,8 @@ export function mountLaunchPanel(container, { getAvatar, getUser, getPreviewView
if (closed) return;
const slot = bd.querySelector('#lp-dep-qr');
if (slot) { slot.innerHTML = ''; slot.appendChild(canvas); }
- } catch {
+ } catch (err) {
+ console.warn('[launch-panel] QR render failed', err);
if (closed) return;
const slot = bd.querySelector('#lp-dep-qr');
if (slot) slot.innerHTML = `<div class="lp-dep-qr-err">QR unavailable —<br>copy address below</div>`;
@@ -746,6 +798,14 @@ export function mountLaunchPanel(container, { getAvatar, getUser, getPreviewView
}
}
+ function switchCoinType(next) {
+ if (!['regular', 'mayhem', 'agent', 'usdc'].includes(next)) return;
+ if (next === s.coinType) return;
+ s.coinType = next;
+ s.errorMsg = '';
+ render();
+ }
+
// ── Image handling ─────────────────────────────────────────────────────
function handleImageFile(file) {
@@ -822,6 +882,7 @@ export function mountLaunchPanel(container, { getAvatar, getUser, getPreviewView
async function launch() {
if (!formValid() || s.phase !== 'idle') return;
if (!av || av.id === DEMO_ID) return;
+ if (s.coinType === 'usdc') return; // gated — USDC denomination not yet live
if (s.walletSource === 'connected' && !s.walletAddr) return;
if (s.walletSource === 'agent' && !s.agentWallet?.address) return;
s.errorMsg = '';
@@ -907,7 +968,8 @@ export function mountLaunchPanel(container, { getAvatar, getUser, getPreviewView
...(av.agent_id ? { agent_id: av.agent_id } : { avatar_id: av.id }),
wallet_address: payer,
name: nameTrim, symbol: symTrim, uri: s._metaUrl,
- buyback_bps: s.buybackBps,
+ coin_type: s.coinType,
+ buyback_bps: s.coinType === 'agent' ? s.buybackBps : 0,
sol_buy_in: Math.max(0, parseFloat(s.initialBuy) || 0),
network: 'mainnet',
}),
@@ -954,7 +1016,8 @@ export function mountLaunchPanel(container, { getAvatar, getUser, getPreviewView
const body = {
...(av.agent_id ? { agent_id: av.agent_id } : { avatar_id: av.id }),
name: nameTrim, symbol: symTrim, uri: s._metaUrl,
- buyback_bps: s.buybackBps,
+ coin_type: s.coinType,
+ buyback_bps: s.coinType === 'agent' ? s.buybackBps : 0,
sol_buy_in: Math.max(0, parseFloat(s.initialBuy) || 0),
network: 'mainnet',
};
@@ -1246,6 +1309,32 @@ export function mountLaunchPanel(container, { getAvatar, getUser, getPreviewView
</button>
</div>`;
+ const ct = s.coinType;
+ const coinTypeHtml = `<div class="lp-coin" role="tablist" aria-label="Coin type">
+ <button type="button" role="tab" data-coin="regular" class="regular ${ct === 'regular' ? 'on' : ''}" ${busy ? 'disabled' : ''}>
+ <span class="lp-coin-emoji">🪙</span>Regular<span class="lp-coin-sub">Plain pump.fun</span>
+ </button>
+ <button type="button" role="tab" data-coin="mayhem" class="mayhem ${ct === 'mayhem' ? 'on' : ''}" ${busy ? 'disabled' : ''}>
+ <span class="lp-coin-emoji">🔥</span>Mayhem<span class="lp-coin-sub">High-volatility</span>
+ </button>
+ <button type="button" role="tab" data-coin="agent" class="agent ${ct === 'agent' ? 'on' : ''}" ${busy ? 'disabled' : ''}>
+ <span class="lp-coin-emoji">🤖</span>Agent<span class="lp-coin-sub">SOL buyback</span>
+ </button>
+ <button type="button" role="tab" data-coin="usdc" class="usdc ${ct === 'usdc' ? 'on' : ''}" ${busy ? 'disabled' : ''} title="USDC-denominated agent payments — coming soon">
+ <span class="lp-coin-emoji">💵</span>USDC<span class="lp-coin-sub">Soon</span>
+ </button>
+ </div>`;
+
+ const coinNoteHtml = ct === 'mayhem'
+ ? `<div class="lp-coin-note mayhem">Mayhem coins launch on pump.fun's high-volatility mode. No agent buyback or payments — pure speculation.</div>`
+ : ct === 'usdc'
+ ? `<div class="lp-coin-note usdc">USDC-denominated agent coins are coming soon. Powered by <a href="https://github.com/nirholas/agent-payments-sdk" target="_blank" rel="noopener" style="color:inherit;text-decoration:underline">agent-payments-sdk</a> — accept USDC payments, auto-buyback, x402 pay-gating.</div>`
+ : ct === 'regular'
+ ? `<div class="lp-coin-note">Standard pump.fun launch — no on-chain buyback. Initial buy still funds bonding curve.</div>`
+ : '';
+
+ const showBuyback = ct === 'agent';
+
let walletHtml;
if (s.walletSource === 'agent') {
walletHtml = renderAgentWalletBar(cost);
@@ -1258,6 +1347,8 @@ export function mountLaunchPanel(container, { getAvatar, getUser, getPreviewView
let btnText, btnDis;
if (busy) {
btnText = s.phaseLabel || 'Working…'; btnDis = true;
+ } else if (ct === 'usdc') {
+ btnText = 'USDC coin — coming soon'; btnDis = true;
} else if (!signedIn) {
btnText = 'Sign in to launch'; btnDis = false;
} else if (!formValid()) {
@@ -1296,7 +1387,9 @@ export function mountLaunchPanel(container, { getAvatar, getUser, getPreviewView
<textarea id="lp-desc" rows="3" maxlength="500"
placeholder="What does this agent do?" ${dis}>${esc(s.description)}</textarea>
</div>
- <div class="lp-2col">
+ ${coinTypeHtml}
+ ${coinNoteHtml}
+ ${showBuyback ? `<div class="lp-2col">
<div>
<label for="lp-buy">Initial buy (SOL)</label>
<input class="lp-number" id="lp-buy" type="number" min="0" max="50" step="0.001"
@@ -1311,7 +1404,11 @@ export function mountLaunchPanel(container, { getAvatar, getUser, getPreviewView
min="0" max="5000" step="50" value="${s.buybackBps}" ${dis} />
<div class="lp-slider-hint">Of agent revenue burned back</div>
</div>
- </div>
+ </div>` : `<div>
+ <label for="lp-buy">Initial buy (SOL)</label>
+ <input class="lp-number" id="lp-buy" type="number" min="0" max="50" step="0.001"
+ value="${esc(s.initialBuy)}" ${dis} />
+ </div>`}
${sourceToggleHtml}
${walletHtml}
${s.phase === 'error' ? `<div class="lp-err">${esc(s.errorMsg)}<div class="lp-err-sub">Fix the issue above and try again.</div></div>` : ''}
@@ -1417,6 +1514,11 @@ export function mountLaunchPanel(container, { getAvatar, getUser, getPreviewView
btn.addEventListener('click', () => switchSource(btn.dataset.src));
});
+ // Coin-type selector
+ container.querySelectorAll('.lp-coin button[data-coin]').forEach((btn) => {
+ btn.addEventListener('click', () => switchCoinType(btn.dataset.coin));
+ });
+
// Agent-wallet bar
q('#lp-agent-retry')?.addEventListener('click', () => loadAgentWallet());
q('#lp-agent-deposit')?.addEventListener('click', openAgentDepositModal);
diff --git a/public/studio/studio.css b/public/studio/studio.css
index c37de9fb4..672d9145e 100644
--- a/public/studio/studio.css
+++ b/public/studio/studio.css
@@ -122,6 +122,175 @@ a:hover {
background: rgba(139, 92, 246, 0.16);
}
+/* ── user menu ─────────────────────────────────────────────────────────────── */
+.user-menu {
+ position: relative;
+ display: inline-flex;
+ align-items: center;
+ margin-left: 0.35rem;
+}
+
+.user-menu[data-state='loading'] {
+ display: none;
+}
+
+.user-menu-signin {
+ display: inline-flex !important;
+ align-items: center;
+ padding: 0.4rem 0.85rem !important;
+ border: 1px solid var(--border);
+ border-radius: var(--radius-sm);
+ background: transparent;
+ color: #fff !important;
+ font-size: 0.85rem;
+ font-weight: 500;
+}
+
+.user-menu-signin:hover {
+ background: rgba(255, 255, 255, 0.05);
+ border-color: #3a3a48;
+ text-decoration: none;
+}
+
+.user-menu-trigger {
+ display: inline-flex !important;
+ align-items: center;
+ gap: 0.5rem;
+ padding: 0.3rem 0.55rem 0.3rem 0.35rem !important;
+ background: transparent;
+ border: 1px solid var(--border);
+ border-radius: 999px;
+ color: #fff;
+ font: inherit;
+ font-size: 0.85rem;
+ cursor: pointer;
+ transition: background 0.15s ease, border-color 0.15s ease;
+}
+
+.user-menu-trigger:hover {
+ background: rgba(255, 255, 255, 0.05) !important;
+ border-color: #3a3a48;
+}
+
+.user-menu-trigger[aria-expanded='true'] {
+ background: rgba(255, 255, 255, 0.06);
+ border-color: #3a3a48;
+}
+
+.user-menu-avatar {
+ display: inline-flex;
+ align-items: center;
+ justify-content: center;
+ width: 26px;
+ height: 26px;
+ border-radius: 999px;
+ background: linear-gradient(135deg, #8b5cf6, #6366f1);
+ color: #fff;
+ font-size: 0.78rem;
+ font-weight: 600;
+ overflow: hidden;
+ flex-shrink: 0;
+}
+
+.user-menu-avatar img {
+ width: 100%;
+ height: 100%;
+ object-fit: cover;
+}
+
+.user-menu-label {
+ max-width: 140px;
+ overflow: hidden;
+ text-overflow: ellipsis;
+ white-space: nowrap;
+}
+
+.user-menu-caret {
+ font-size: 0.7rem;
+ color: var(--muted);
+ line-height: 1;
+}
+
+.user-menu-pop {
+ position: absolute;
+ top: calc(100% + 0.4rem);
+ right: 0;
+ min-width: 220px;
+ padding: 0.4rem;
+ background: rgba(16, 16, 22, 0.98);
+ border: 1px solid var(--border);
+ border-radius: var(--radius-sm);
+ box-shadow: 0 18px 40px rgba(0, 0, 0, 0.5);
+ z-index: 60;
+ display: flex;
+ flex-direction: column;
+ gap: 0.1rem;
+}
+
+.user-menu-pop[hidden] {
+ display: none;
+}
+
+.user-menu-header {
+ padding: 0.55rem 0.7rem 0.6rem;
+ border-bottom: 1px solid var(--border-soft);
+ margin-bottom: 0.25rem;
+}
+
+.user-menu-header-name {
+ font-size: 0.88rem;
+ font-weight: 600;
+ color: #fff;
+ overflow: hidden;
+ text-overflow: ellipsis;
+ white-space: nowrap;
+}
+
+.user-menu-header-email {
+ font-size: 0.75rem;
+ color: var(--muted);
+ overflow: hidden;
+ text-overflow: ellipsis;
+ white-space: nowrap;
+ margin-top: 0.1rem;
+}
+
+.user-menu-item {
+ display: block !important;
+ width: 100%;
+ text-align: left;
+ padding: 0.5rem 0.7rem !important;
+ font-size: 0.85rem;
+ color: rgba(255, 255, 255, 0.85) !important;
+ background: transparent;
+ border: 0;
+ border-radius: var(--radius-sm);
+ cursor: pointer;
+ font: inherit;
+ font-size: 0.85rem;
+}
+
+.user-menu-item:hover {
+ background: rgba(255, 255, 255, 0.06) !important;
+ color: #fff !important;
+ text-decoration: none;
+}
+
+.user-menu-divider {
+ height: 1px;
+ background: var(--border-soft);
+ margin: 0.3rem 0;
+}
+
+.user-menu-signout {
+ color: #f87171 !important;
+}
+
+.user-menu-signout:hover {
+ background: rgba(248, 113, 113, 0.12) !important;
+ color: #fca5a5 !important;
+}
+
/* ── layout ────────────────────────────────────────────────────────────────── */
.studio-layout {
display: grid;
diff --git a/public/studio/studio.js b/public/studio/studio.js
index 45a103fd1..ee1922980 100644
--- a/public/studio/studio.js
+++ b/public/studio/studio.js
@@ -175,6 +175,137 @@ if (preModel) state.preselectedModel = preModel;
updatePreview(true);
})();
+// ── user menu ────────────────────────────────────────────────────────────────
+function userDisplayName(u) {
+ if (!u) return '';
+ return u.display_name || u.username || (u.email ? u.email.split('@')[0] : 'Account');
+}
+
+function userInitial(u) {
+ const name = userDisplayName(u);
+ return name ? name.trim().charAt(0).toUpperCase() : '?';
+}
+
+async function signOut() {
+ await fetch('/api/auth/logout', { method: 'POST', credentials: 'include' }).catch(() => {});
+ try { localStorage.removeItem('3dagent:auth-hint'); } catch { /* ignore */ }
+ location.href = '/';
+}
+
+function renderUserMenu() {
+ const root = $('#user-menu');
+ if (!root) return;
+ root.innerHTML = '';
+
+ if (!state.user) {
+ root.dataset.state = 'signed-out';
+ const a = document.createElement('a');
+ a.className = 'user-menu-signin';
+ a.href = '/login?next=/studio';
+ a.textContent = 'Sign in';
+ root.appendChild(a);
+ return;
+ }
+
+ root.dataset.state = 'signed-in';
+ const u = state.user;
+ const name = userDisplayName(u);
+
+ const trigger = document.createElement('button');
+ trigger.type = 'button';
+ trigger.className = 'user-menu-trigger';
+ trigger.setAttribute('aria-haspopup', 'menu');
+ trigger.setAttribute('aria-expanded', 'false');
+
+ const av = document.createElement('span');
+ av.className = 'user-menu-avatar';
+ if (u.avatar_url) {
+ const img = document.createElement('img');
+ img.src = u.avatar_url;
+ img.alt = '';
+ av.appendChild(img);
+ } else {
+ av.textContent = userInitial(u);
+ }
+
+ const label = document.createElement('span');
+ label.className = 'user-menu-label';
+ label.textContent = name;
+
+ const caret = document.createElement('span');
+ caret.className = 'user-menu-caret';
+ caret.setAttribute('aria-hidden', 'true');
+ caret.textContent = '▾';
+
+ trigger.append(av, label, caret);
+
+ const menu = document.createElement('div');
+ menu.className = 'user-menu-pop';
+ menu.setAttribute('role', 'menu');
+ menu.hidden = true;
+
+ const header = document.createElement('div');
+ header.className = 'user-menu-header';
+ const headerName = document.createElement('div');
+ headerName.className = 'user-menu-header-name';
+ headerName.textContent = name;
+ header.appendChild(headerName);
+ if (u.email) {
+ const headerEmail = document.createElement('div');
+ headerEmail.className = 'user-menu-header-email';
+ headerEmail.textContent = u.email;
+ header.appendChild(headerEmail);
+ }
+ menu.appendChild(header);
+
+ const items = [
+ { href: '/my-agents', label: 'My Agents' },
+ { href: '/dashboard', label: 'Dashboard' },
+ { href: '/dashboard/avatars', label: 'My Avatars' },
+ ];
+ for (const it of items) {
+ const a = document.createElement('a');
+ a.className = 'user-menu-item';
+ a.href = it.href;
+ a.setAttribute('role', 'menuitem');
+ a.textContent = it.label;
+ menu.appendChild(a);
+ }
+
+ const divider = document.createElement('div');
+ divider.className = 'user-menu-divider';
+ menu.appendChild(divider);
+
+ const out = document.createElement('button');
+ out.type = 'button';
+ out.className = 'user-menu-item user-menu-signout';
+ out.setAttribute('role', 'menuitem');
+ out.textContent = 'Sign out';
+ out.addEventListener('click', signOut);
+ menu.appendChild(out);
+
+ root.append(trigger, menu);
+
+ function close() {
+ menu.hidden = true;
+ trigger.setAttribute('aria-expanded', 'false');
+ }
+ function open() {
+ menu.hidden = false;
+ trigger.setAttribute('aria-expanded', 'true');
+ }
+ trigger.addEventListener('click', (e) => {
+ e.stopPropagation();
+ menu.hidden ? open() : close();
+ });
+ document.addEventListener('click', (e) => {
+ if (!root.contains(e.target)) close();
+ });
+ document.addEventListener('keydown', (e) => {
+ if (e.key === 'Escape') close();
+ });
+}
+
// ── data ─────────────────────────────────────────────────────────────────────
async function fetchMe() {
try {
@@ -570,24 +701,7 @@ function hydrateForm() {
}
function wireButtons() {
- const signoutBtn = $('#signout-btn');
- const signinLink = $('#signin-link');
- if (state.user) {
- signoutBtn.hidden = false;
- signinLink.hidden = true;
- } else {
- signoutBtn.hidden = true;
- signinLink.hidden = false;
- }
- signoutBtn.addEventListener('click', async () => {
- await fetch('/api/auth/logout', { method: 'POST', credentials: 'include' }).catch(() => {});
- try {
- localStorage.removeItem('3dagent:auth-hint');
- } catch {
- /* ignore */
- }
- location.href = '/';
- });
+ renderUserMenu();
captureBtn.addEventListener('click', () => {
try {
diff --git a/src/create.js b/src/create.js
index 1c62c106c..70c1221db 100644
--- a/src/create.js
+++ b/src/create.js
@@ -53,8 +53,11 @@ async function handleGlbFile(file) {
return;
}
+ showSaveOverlay('Checking your file…');
+
const header = new Uint8Array(await file.slice(0, 4).arrayBuffer());
if (!GLB_MAGIC.every((b, i) => header[i] === b)) {
+ hideSaveOverlay();
showStatus("File doesn't appear to be a valid GLB.", 'error');
return;
}
@@ -114,6 +117,7 @@ function showSaveOverlay(label, sublabel) {
el.id = 'save-loading';
el.setAttribute('role', 'status');
el.setAttribute('aria-live', 'polite');
+ el.setAttribute('aria-busy', 'true');
el.innerHTML = `
<img src="/three.svg" alt="" />
<div class="dots">...</div>
@@ -121,6 +125,8 @@ function showSaveOverlay(label, sublabel) {
<div class="sublabel"></div>
`;
document.body.appendChild(el);
+ document.documentElement.style.overflow = 'hidden';
+ document.body.style.overflow = 'hidden';
}
el.querySelector('.label').textContent = label;
el.querySelector('.sublabel').textContent = sublabel || '';
@@ -134,7 +140,11 @@ function updateSaveOverlay(label, sublabel) {
}
function hideSaveOverlay() {
- document.getElementById('save-loading')?.remove();
+ const el = document.getElementById('save-loading');
+ if (!el) return;
+ el.remove();
+ document.documentElement.style.overflow = '';
+ document.body.style.overflow = '';
}
// Associates the uploaded avatar with the caller's default agent. POST /api/agents
diff --git a/vite.config.js b/vite.config.js
index 18e8f0194..e920cc2f6 100644
--- a/vite.config.js
+++ b/vite.config.js
@@ -285,7 +285,7 @@ const appConfig = {
// /dashboard/<tab> and /dashboard/edit/<id> → SPA index
else if (
!filePath &&
- /^\/dashboard\/(?:avatars|create|upload|animations|widgets|embed|keys|mcp|monetization|payments|subscriptions|billing|revenue|earnings|account)\/?$/.test(
+ /^\/dashboard\/(?:agents|avatars|create|upload|animations|widgets|embed|keys|mcp|monetization|payments|subscriptions|billing|revenue|earnings|account)\/?$/.test(
path,
)
)