Open-source platform for 3D AI agents. Turn text or a photo into a rigged, animated GLB avatar, give it an LLM brain, memory and a wallet, and embed it anywhere with one web component. Remote MCP server, x402 payments, Three.js, browser-native.
JavaScript 3d-generationai-agentsanimationavatardigital-humangenerative-aiglbgltfimage-to-3dllmmcpmcp-servermodel-context-protocolsolanatext-to-3dthreejsweb-componentswebglwebxrx402
chore: dashboard pages, fonts, pricing + x analytics/reviews, cross-page polish
nirholasdf11ee512008
diff --git a/a-edit.html b/a-edit.htmlindex df3355387..530c81ec6 100644--- a/a-edit.html+++ b/a-edit.html@@ -8,13 +8,8 @@<meta name="theme-color" content="#000000" /><link rel="shortcut icon" href="/favicon.ico" />- <link rel="preconnect" href="https://fonts.googleapis.com" />- <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin /><link rel="stylesheet" href="/style.css" />- <link- href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500&display=swap"- rel="stylesheet"- />+ <link rel="stylesheet" href="/fonts/fonts.css" /><scripttype="module"src="https://ajax.googleapis.com/ajax/libs/model-viewer/4.0.0/model-viewer.min.js"diff --git a/a-embed.html b/a-embed.htmlindex 285fbf0e1..a3b044936 100644--- a/a-embed.html+++ b/a-embed.html@@ -236,6 +236,28 @@el: document.getElementById('stage'),model: avatar,});+ if (bg === 'transparent') {+ viewer.renderer?.setClearAlpha(0);+ if (viewer.scene) viewer.scene.background = null;+ }+ if (plateOn || openLinkOn) {+ try {+ const r = await fetch(`/api/avatars/${encodeURIComponent(avatar)}`, {+ credentials: 'include',+ });+ if (r.ok) {+ const { avatar: a } = await r.json();+ if (plateOn && a?.name) {+ document.getElementById('name-plate').textContent = a.name;+ }+ if (openLinkOn) {+ const ol = document.getElementById('open-link');+ ol.href = `/avatars/${encodeURIComponent(avatar)}`;+ ol.style.display = 'inline-block';+ }+ }+ } catch {}+ }document.getElementById('loading').style.display = 'none';return;}diff --git a/agent-detail.html b/agent-detail.htmlindex d0cbb6a6c..635b8718e 100644--- a/agent-detail.html+++ b/agent-detail.html@@ -1,7 +1,4 @@- <link- href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600&display=swap"- rel="stylesheet"- />+ <link rel="stylesheet" href="/fonts/fonts.css" /><link rel="stylesheet" href="/src/agent-detail.css" /><script src="https://cdnjs.cloudflare.com/ajax/libs/qrious/4.0.2/qrious.min.js"></script><style>diff --git a/agent-edit.html b/agent-edit.htmlindex 0ea90f7a2..caa7bdc1e 100644--- a/agent-edit.html+++ b/agent-edit.html@@ -16,14 +16,8 @@<meta name="twitter:image" content="https://three.ws/assets/og-image.png"><link rel="shortcut icon" href="/favicon.ico" />- <link rel="preconnect" href="https://fonts.googleapis.com" />- <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin /><link rel="stylesheet" href="/style.css" />- <link- href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500&display=swap"- rel="stylesheet"- />-+ <link rel="stylesheet" href="/fonts/fonts.css" /><style>body {overflow: auto;diff --git a/agent-home.html b/agent-home.htmlindex 96a2479bd..568f0882a 100644--- a/agent-home.html+++ b/agent-home.html@@ -11,16 +11,11 @@<meta name="theme-color" content="#000000" /><link rel="shortcut icon" href="/favicon.ico" />- <link rel="preconnect" href="https://fonts.googleapis.com" />- <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin /><link rel="stylesheet" href="/style.css" /><link rel="stylesheet" href="/footer.css" /><link rel="stylesheet" href="/src/pump/launch-token-modal.css" /><script defer src="/footer-newsletter.js"></script>- <link- href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500&display=swap"- rel="stylesheet"- />+ <link rel="stylesheet" href="/fonts/fonts.css" /><scripttype="module"src="https://ajax.googleapis.com/ajax/libs/model-viewer/4.0.0/model-viewer.min.js"diff --git a/api/_lib/x-post.js b/api/_lib/x-post.jsindex 1e965f23b..ad2de6878 100644--- a/api/_lib/x-post.js+++ b/api/_lib/x-post.js@@ -1,14 +1,17 @@-// Internal helper: publish a tweet on behalf of a three.ws user whose X-// account is connected. Handles token refresh, quota check, dedup, and logging.-// Used by api/x/post.js (manual) and the scheduled-posts cron job.+// Internal helper: publish to X on behalf of a three.ws user.+// Handles: tier-aware quota, token refresh, dedup, cadence guard, threads,+// optional link-back, and post logging.import { sql } from './db.js';import { env } from './env.js';import { encryptToken, decryptToken } from '../auth/x/[action].js';export const FREE_MONTHLY_QUOTA = 5;-export const MAX_TWEET_LEN = 280;-export const DEDUP_WINDOW_DAYS = 7;+export const PRO_MONTHLY_QUOTA = 100;+export const MAX_TWEET_LEN = 280;+export const DEDUP_WINDOW_DAYS = 7;+export const FREE_MIN_INTERVAL = 30; // minutes between posts+export const PRO_MIN_INTERVAL = 5;class XPostError extends Error {constructor(code, message, status = 400, extra = {}) {@@ -19,6 +22,21 @@ class XPostError extends Error {}}+export async function getUserTier(userId) {+ const r = await sql`+ select plan, active_until from subscriptions+ where user_id = ${userId} and status = 'active' and active_until > now()+ limit 1+ `;+ if (!r.length) return { tier: 'free', quota: FREE_MONTHLY_QUOTA, min_interval_min: FREE_MIN_INTERVAL };+ return {+ tier: r[0].plan,+ active_until: r[0].active_until,+ quota: PRO_MONTHLY_QUOTA,+ min_interval_min: PRO_MIN_INTERVAL,+ };+}+async function refreshIfNeeded(conn) {const expiresAt = conn.expires_at ? new Date(conn.expires_at).getTime() : 0;if (expiresAt - Date.now() > 60_000) return decryptToken(conn.access_token);@@ -45,13 +63,35 @@ async function refreshIfNeeded(conn) {return tok.access_token;}-export async function publishTweet({ userId, agentId = null, text }) {+async function postOne({ accessToken, text, replyTo }) {+ const body = { text };+ if (replyTo) body.reply = { in_reply_to_tweet_id: replyTo };+ const r = await fetch('https://api.twitter.com/2/tweets', {+ method: 'POST',+ headers: { 'content-type': 'application/json', authorization: `Bearer ${accessToken}` },+ body: JSON.stringify(body),+ });+ if (!r.ok) throw new XPostError('tweet_failed', `X API error: ${(await r.text()).slice(0, 200)}`, 502);+ return (await r.json()).data;+}++// Publish a single tweet (text) or a thread (threadParts).+// Counts each tweet against the user's monthly quota.+// Optionally appends a link to https://three.ws/avatars/<agentId> on the final tweet.+export async function publishTweet({ userId, agentId = null, text, threadParts = null, replyTo = null, appendLink = false }) {if (!env.X_OAUTH_CLIENT_ID || !env.X_OAUTH_CLIENT_SECRET) {throw new XPostError('not_configured', 'X OAuth is not configured', 501);}- const trimmed = String(text || '').trim();- if (!trimmed) throw new XPostError('validation_error', 'text required', 400);- if (trimmed.length > MAX_TWEET_LEN) throw new XPostError('validation_error', `text exceeds ${MAX_TWEET_LEN} chars`, 400);++ const parts = Array.isArray(threadParts) && threadParts.length+ ? threadParts.map((s) => String(s || '').trim()).filter(Boolean)+ : [String(text || '').trim()].filter(Boolean);+ if (!parts.length) throw new XPostError('validation_error', 'text required', 400);+ for (const p of parts) {+ if (p.length > MAX_TWEET_LEN) throw new XPostError('validation_error', `each tweet must be ≤${MAX_TWEET_LEN} chars`, 400);+ }++ const tier = await getUserTier(userId);const rows = await sql`select * from social_connections@@ -61,7 +101,7 @@ export async function publishTweet({ userId, agentId = null, text }) {const conn = rows[0];if (!conn) throw new XPostError('not_connected', 'X account not connected', 400);- // Reset monthly counter if we crossed the boundary.+ // Reset monthly counter if month boundary crossed.if (new Date(conn.month_resets_at) <= new Date()) {await sql`update social_connections@@ -72,55 +112,80 @@ export async function publishTweet({ userId, agentId = null, text }) {conn.posts_this_month = 0;}- if (conn.posts_this_month >= FREE_MONTHLY_QUOTA) {- throw new XPostError('quota_exceeded', `free tier limit of ${FREE_MONTHLY_QUOTA} posts/month reached`, 402, {+ if (conn.posts_this_month + parts.length > tier.quota) {+ throw new XPostError('quota_exceeded', `${tier.tier} tier limit of ${tier.quota} posts/month reached`, 402, {posts_used: conn.posts_this_month,- quota: FREE_MONTHLY_QUOTA,+ quota: tier.quota,+ tier: tier.tier,month_resets_at: conn.month_resets_at,upgrade_url: '/pricing',});}- // Dedup — refuse identical text within the window. Prevents X suspension- // from repetitive content patterns.+ // Cadence guard.+ if (conn.last_posted_at) {+ const elapsedMin = (Date.now() - new Date(conn.last_posted_at).getTime()) / 60_000;+ if (elapsedMin < tier.min_interval_min) {+ const wait = Math.ceil(tier.min_interval_min - elapsedMin);+ throw new XPostError('rate_limited', `please wait ${wait} more min before posting again`, 429, {+ retry_after_minutes: wait,+ tier: tier.tier,+ upgrade_url: tier.tier === 'free' ? '/pricing' : undefined,+ });+ }+ }++ // Dedup on first part of thread.+ const head = parts[0];const dup = await sql`select 1 from x_posts- where user_id = ${userId} and text = ${trimmed}+ where user_id = ${userId} and text = ${head}and created_at > now() - ${`${DEDUP_WINDOW_DAYS} days`}::intervallimit 1`;if (dup.length) throw new XPostError('duplicate', `same text posted within the last ${DEDUP_WINDOW_DAYS} days`, 409);+ // Append link-back to agent page on final tweet (if it fits).+ if (appendLink && agentId) {+ const link = `https://three.ws/avatars/${agentId}`;+ const last = parts[parts.length - 1];+ if (!last.includes(link)) {+ const candidate = `${last}\n\n${link}`;+ if (candidate.length <= MAX_TWEET_LEN) parts[parts.length - 1] = candidate;+ }+ }+const accessToken = await refreshIfNeeded(conn);- const tweetRes = await fetch('https://api.twitter.com/2/tweets', {- method: 'POST',- headers: { 'content-type': 'application/json', authorization: `Bearer ${accessToken}` },- body: JSON.stringify({ text: trimmed }),- });- if (!tweetRes.ok) {- const detail = await tweetRes.text();- throw new XPostError('tweet_failed', `X API error: ${detail.slice(0, 200)}`, 502);+ const published = [];+ let prevId = replyTo;+ for (const part of parts) {+ const d = await postOne({ accessToken, text: part, replyTo: prevId });+ published.push(d);+ await sql`+ insert into x_posts (user_id, agent_id, tweet_id, text, reply_to_tweet_id)+ values (${userId}, ${agentId}, ${d.id}, ${part}, ${prevId})+ `;+ prevId = d.id;}- const { data } = await tweetRes.json();await sql`update social_connections- set posts_this_month = posts_this_month + 1,+ set posts_this_month = posts_this_month + ${published.length},+ last_posted_at = now(),updated_at = now()where id = ${conn.id}`;- await sql`- insert into x_posts (user_id, agent_id, tweet_id, text)- values (${userId}, ${agentId}, ${data.id}, ${trimmed})- `;+ const head0 = published[0];return {- tweet_id: data.id,- url: `https://x.com/${conn.username}/status/${data.id}`,+ tweet_id: head0.id,+ url: `https://x.com/${conn.username}/status/${head0.id}`,username: conn.username,- posts_used: conn.posts_this_month + 1,- quota: FREE_MONTHLY_QUOTA,+ thread: published.length > 1 ? published.map((p) => p.id) : undefined,+ posts_used: conn.posts_this_month + published.length,+ quota: tier.quota,+ tier: tier.tier,};}diff --git a/api/agents/_id/payments.js b/api/agents/_id/payments.jsindex 17d5e7812..575e4f5c6 100644--- a/api/agents/_id/payments.js+++ b/api/agents/_id/payments.js@@ -1,25 +1,33 @@import { sql } from '../../_lib/db.js';-import { getSessionUser } from '../../_lib/auth.js';+import { getSessionUser, authenticateBearer, extractBearer } from '../../_lib/auth.js';import { cors, json, method, wrap, error } from '../../_lib/http.js';import { limits, clientIp } from '../../_lib/rate-limit.js';+async function resolveAuth(req) {+ const session = await getSessionUser(req);+ if (session) return { userId: session.id };+ const bearer = await authenticateBearer(extractBearer(req));+ return bearer ? { userId: bearer.userId } : null;+}+// GET /api/agents/:id/payments?direction=sent|received&limit=20&cursor=export const handlePayments = wrap(async (req, res, id) => {if (cors(req, res, { methods: 'GET,OPTIONS', credentials: true })) return;if (!method(req, res, ['GET'])) return;- const user = await getSessionUser(req);- if (!user) return error(res, 401, 'unauthorized', 'sign in required');+ const auth = await resolveAuth(req);+ if (!auth) return error(res, 401, 'unauthorized', 'sign in required');const rl = await limits.authIp(clientIp(req));if (!rl.success) return error(res, 429, 'rate_limited', 'too many requests');const [agent] = await sql`- select id from agent_identities- where id = ${id} and user_id = ${user.id} and deleted_at is null+ select id, user_id from agent_identities+ where id = ${id} and deleted_at is nulllimit 1`;if (!agent) return error(res, 404, 'not_found', 'agent not found');+ if (agent.user_id !== auth.userId) return error(res, 403, 'forbidden', 'not your agent');const url = new URL(req.url, 'http://x');const direction = url.searchParams.get('direction') === 'received' ? 'received' : 'sent';diff --git a/api/agents/solana-wallet.js b/api/agents/solana-wallet.jsindex 5670f904b..30088a230 100644--- a/api/agents/solana-wallet.js+++ b/api/agents/solana-wallet.js@@ -64,47 +64,92 @@ async function handleActivity(req, res, id) {const url = new URL(req.url, 'http://x');const network = url.searchParams.get('network') === 'devnet' ? 'devnet' : 'mainnet';const limit = Math.min(parseInt(url.searchParams.get('limit') || '20', 10) || 20, 50);+ const pk = new PublicKey(address);- const fetchActivity = async (conn) => {- const pk = new PublicKey(address);- const sigs = await conn.getSignaturesForAddress(pk, { limit });- const parsed = await conn.getParsedTransactions(sigs.map((s) => s.signature), { maxSupportedTransactionVersion: 0, commitment: 'confirmed' });- return sigs.map((s, i) => {- const tx = parsed[i];- let lamportDelta = null, summary = null;- if (tx?.meta && tx?.transaction) {- const keys = tx.transaction.message.accountKeys.map((k) => k.pubkey?.toString());- const idx = keys.indexOf(address);- if (idx >= 0 && tx.meta.preBalances && tx.meta.postBalances) lamportDelta = tx.meta.postBalances[idx] - tx.meta.preBalances[idx];- const ix = tx.transaction.message.instructions?.[0];- if (ix?.parsed?.type) summary = ix.parsed.type;- else if (ix?.programId) summary = `program ${ix.programId.toString().slice(0, 6)}…`;- }- return { signature: s.signature, slot: s.slot, block_time: s.blockTime ?? null, success: !s.err && !tx?.meta?.err, error: s.err || tx?.meta?.err || null, lamport_delta: lamportDelta, sol_delta: lamportDelta == null ? null : lamportDelta / 1e9, summary };- });- };+ // Try the configured RPC first, then the public RPC. Distinct connection+ // objects each call so a hung socket on one doesn't poison retries.+ const conns = [solanaConnection(network), solanaPublicConnection(network)];- let signatures = [];- try {- signatures = await fetchActivity(solanaConnection(network));- } catch (err) {- const hasCustomRpc = !!(network === 'devnet'- ? process.env.SOLANA_RPC_URL_DEVNET- : process.env.SOLANA_RPC_URL);- if (hasCustomRpc) {- try {- signatures = await fetchActivity(solanaPublicConnection(network));- } catch (fallbackErr) {- console.error('[agents/solana/activity] RPC fetch failed (fallback)', fallbackErr);- return error(res, 502, 'rpc_error', 'failed to fetch on-chain activity');- }+ const sigInfos = await withRpcRetry(+ conns,+ (c) => c.getSignaturesForAddress(pk, { limit }),+ 'getSignaturesForAddress',+ );+ if (!sigInfos.ok) {+ console.error('[agents/solana/activity] signature fetch failed on all RPCs', sigInfos.error);+ return error(res, 502, 'rpc_error', 'failed to fetch on-chain activity');+ }+ const sigs = sigInfos.value;++ // getParsedTransactions is the expensive call and the one most often rate-limited.+ // Degrade gracefully: if it fails everywhere, we still return the signature list+ // without the lamport delta / summary enrichment instead of 502-ing the whole call.+ let parsed = null;+ if (sigs.length) {+ const parsedRes = await withRpcRetry(+ conns,+ (c) => c.getParsedTransactions(sigs.map((s) => s.signature), {+ maxSupportedTransactionVersion: 0,+ commitment: 'confirmed',+ }),+ 'getParsedTransactions',+ );+ if (parsedRes.ok) {+ parsed = parsedRes.value;} else {- console.error('[agents/solana/activity] RPC fetch failed', err);- return error(res, 502, 'rpc_error', 'failed to fetch on-chain activity');+ console.warn('[agents/solana/activity] parsed-tx enrichment unavailable', parsedRes.error?.message);}}- return json(res, 200, { data: { address, network, signatures } });+ const signatures = sigs.map((s, i) => {+ const tx = parsed?.[i] ?? null;+ let lamportDelta = null;+ let summary = null;+ if (tx?.meta && tx?.transaction) {+ const keys = tx.transaction.message.accountKeys.map((k) => k.pubkey?.toString());+ const idx = keys.indexOf(address);+ if (idx >= 0 && tx.meta.preBalances && tx.meta.postBalances) {+ lamportDelta = tx.meta.postBalances[idx] - tx.meta.preBalances[idx];+ }+ const ix = tx.transaction.message.instructions?.[0];+ if (ix?.parsed?.type) summary = ix.parsed.type;+ else if (ix?.programId) summary = `program ${ix.programId.toString().slice(0, 6)}…`;+ }+ return {+ signature: s.signature,+ slot: s.slot,+ block_time: s.blockTime ?? null,+ success: !s.err && !tx?.meta?.err,+ error: s.err || tx?.meta?.err || null,+ lamport_delta: lamportDelta,+ sol_delta: lamportDelta == null ? null : lamportDelta / 1e9,+ summary,+ };+ });++ return json(res, 200, {+ data: { address, network, signatures, parsed_available: parsed !== null },+ });+}++// Walk an ordered list of connections, returning the first successful result.+// Skips duplicates (e.g. when SOLANA_RPC_URL is unset, both entries point at+// the same public endpoint — no point in calling it twice).+async function withRpcRetry(conns, call, label) {+ let lastErr = null;+ const seen = new Set();+ for (const conn of conns) {+ const key = conn?.rpcEndpoint || '';+ if (key && seen.has(key)) continue;+ seen.add(key);+ try {+ return { ok: true, value: await call(conn) };+ } catch (err) {+ lastErr = err;+ console.warn(`[agents/solana/activity] ${label} via ${key} failed: ${err?.message || err}`);+ }+ }+ return { ok: false, error: lastErr };}// ── airdrop ───────────────────────────────────────────────────────────────────diff --git a/api/auth/wallets/[action].js b/api/auth/wallets/[action].jsindex dc967bdb6..c51f23bd4 100644--- a/api/auth/wallets/[action].js+++ b/api/auth/wallets/[action].js@@ -284,6 +284,11 @@ async function handleNonceSolana(req, res) {const linkSolanaBody = z.object({message: z.string().min(32).max(4000),signature: z.string().min(1).max(256),+ // When true and the wallet is already linked to a different account, the+ // signature proves ownership of the keypair and the row is moved to the+ // session user atomically. The default keeps the safe "409 first, confirm+ // second" UX: the caller must opt in to a takeover.+ takeover: z.boolean().optional(),});async function handleLinkSolana(req, res) {@@ -366,12 +371,40 @@ async function handleLinkSolana(req, res) {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',- );+ // Signature already verified above — the caller controls the keypair.+ // With explicit takeover consent, move the wallet row to the session+ // user atomically. Without it, surface 409 so the UI can confirm.+ if (!body.takeover) {+ return error(+ res,+ 409,+ 'address_in_use',+ 'this address is already linked to another account',+ { takeover_available: true },+ );+ }++ await sql.transaction([+ sql`delete from user_wallets where address = ${addr}`,+ sql`insert into user_wallets (user_id, address, chain_type, is_primary)+ values (${session.id}, ${addr}, 'solana', false)`,+ ]);+ logAudit({+ userId: conflict.user_id,+ action: 'unlink_wallet_transferred',+ resourceId: addr,+ meta: { to_user_id: session.id },+ });+ logAudit({+ userId: session.id,+ action: 'link_wallet_solana_takeover',+ resourceId: addr,+ meta: { from_user_id: conflict.user_id },+ });+ return json(res, 200, {+ wallet: { address: addr, chain_type: 'solana', chain_id: chain },+ transferred: true,+ });}await sql`diff --git a/api/avatars/[id]/[action].js b/api/avatars/[id]/[action].jsindex 1f591d23e..6c09b32b2 100644--- a/api/avatars/[id]/[action].js+++ b/api/avatars/[id]/[action].js@@ -22,14 +22,17 @@ import {defaultStorageMode,} from '../../_lib/storage-mode.js';import { getAvatar, resolveAvatarUrl } from '../../_lib/avatars.js';-import { r2 } from '../../_lib/r2.js';+import { r2, publicUrl } from '../../_lib/r2.js';import { env } from '../../_lib/env.js';+import { DEMO_AVATARS } from '../../_lib/demo-avatars.js';const PINATA_ENDPOINT = 'https://api.pinata.cloud/pinning/pinFileToIPFS';export default wrap(async (req, res) => {const action = req.query?.action;switch (action) {+ case 'agents':+ return handleAgentsByAvatar(req, res);case 'glb-versions':return handleGlbVersions(req, res);case 'pin-ipfs':@@ -40,6 +43,8 @@ export default wrap(async (req, res) => {return handleSession(req, res);case 'storage-mode':return handleStorageMode(req, res);+ case 'thumbnail':+ return handleThumbnail(req, res);case 'versions':return handleVersions(req, res);default:@@ -47,6 +52,52 @@ export default wrap(async (req, res) => {}});+// ── agents (public agents wearing this avatar) ────────────────────────────+// GET /api/avatars/:id/agents+// Returns up to 12 public agents (is_public = true) whose avatar_id matches.+// Public endpoint, rate-limited by IP. Demo avatars never have wearers (they+// are seeded fixtures), so we short-circuit with an empty list.++async function handleAgentsByAvatar(req, res) {+ if (cors(req, res, { methods: 'GET,OPTIONS' })) return;+ if (!method(req, res, ['GET'])) return;++ const id = req.query?.id;+ if (!id) return error(res, 400, 'invalid_request', 'id required');++ const rl = await limits.publicIp(clientIp(req));+ if (!rl.success) return error(res, 429, 'rate_limited', 'too many requests');++ if (String(id).startsWith('avatar_demo_')) {+ return json(res, 200, { agents: [] });+ }++ const rows = await sql`+ SELECT i.id, i.name, i.description, i.profile_image_url, i.created_at,+ i.erc8004_agent_id, i.chain_id+ FROM agent_identities i+ WHERE i.avatar_id = ${id}+ AND i.deleted_at IS NULL+ AND i.is_public = true+ ORDER BY (i.erc8004_agent_id IS NOT NULL) DESC, i.created_at DESC+ LIMIT 12+ `;++ const agents = rows.map((r) => ({+ id: r.id,+ name: r.name,+ description: r.description || '',+ profileImage: r.profile_image_url || null,+ onchain: r.erc8004_agent_id != null,+ chainId: r.chain_id || null,+ createdAt: r.created_at,+ url: `/agent/${r.id}`,+ }));++ res.setHeader('cache-control', 'public, max-age=30, s-maxage=120, stale-while-revalidate=600');+ return json(res, 200, { agents });+}+// ── glb-versions ───────────────────────────────────────────────────────────async function handleGlbVersions(req, res) {@@ -450,3 +501,49 @@ async function resolveVersionsAuth(req) {const bearer = await authenticateBearer(extractBearer(req));return bearer ? { userId: bearer.userId } : null;}++// ── thumbnail ──────────────────────────────────────────────────────────────+// GET /api/avatars/:id/thumbnail — 302 to the avatar's R2-hosted PNG poster.+// Public/unlisted avatars: anyone. Private: owner (session or bearer) only.+// Demo avatars: redirect to the bundled demo image. No thumbnail → 404.++async function handleThumbnail(req, res) {+ if (cors(req, res, { methods: 'GET,OPTIONS', credentials: true })) return;+ if (!method(req, res, ['GET'])) return;++ const id =+ req.query?.id || new URL(req.url, 'http://x').pathname.split('/').filter(Boolean)[2];+ if (!id) return error(res, 400, 'invalid_request', 'avatar id required');++ if (id.startsWith('avatar_demo_')) {+ const demo = DEMO_AVATARS.find((a) => a.avatarId === id);+ if (!demo?.image) return error(res, 404, 'not_found', 'demo avatar has no thumbnail');+ return redirect(res, demo.image);+ }++ const [row] = await sql`+ SELECT id, owner_id, visibility, thumbnail_key+ FROM avatars WHERE id = ${id} AND deleted_at IS NULL+ LIMIT 1+ `;+ if (!row) return error(res, 404, 'not_found', 'avatar not found');++ if (row.visibility === 'private') {+ const auth = await resolveVersionsAuth(req);+ if (!auth) return error(res, 401, 'unauthorized', 'sign in required');+ if (auth.userId !== row.owner_id) return error(res, 403, 'forbidden', 'not your avatar');+ }++ if (!row.thumbnail_key) return error(res, 404, 'not_found', 'avatar has no thumbnail');++ return redirect(res, publicUrl(row.thumbnail_key));+}++function redirect(res, url) {+ // 302 keeps the URL cacheable for short windows without sticking permanently —+ // the underlying thumbnail_key can change after a re-render.+ res.statusCode = 302;+ res.setHeader('location', url);+ res.setHeader('cache-control', 'public, max-age=60, s-maxage=300');+ res.end();+}diff --git a/api/cron/[name].js b/api/cron/[name].jsindex 9abc3bea9..029153ea5 100644--- a/api/cron/[name].js+++ b/api/cron/[name].js@@ -69,6 +69,7 @@ const HANDLERS = {'process-withdrawals': handleProcessWithdrawals,'run-x-scheduled-posts': handleRunXScheduledPosts,'run-x-triggers': handleRunXTriggers,+ 'fetch-x-metrics': handleFetchXMetrics,};export default wrap(async (req, res) => {@@ -2574,7 +2575,7 @@ async function handleRunXScheduledPosts(req, res) {const { publishTweet, XPostError } = await import('../_lib/x-post.js');const due = await sql`- select id, user_id, agent_id, text, attempts+ select id, user_id, agent_id, text, thread_parts, reply_to_tweet_id, attemptsfrom x_scheduled_postswhere posted_at is null and error is nulland scheduled_at <= now()@@ -2588,7 +2589,14 @@ async function handleRunXScheduledPosts(req, res) {for (const row of due) {report.processed++;try {- const result = await publishTweet({ userId: row.user_id, agentId: row.agent_id, text: row.text });+ const result = await publishTweet({+ userId: row.user_id,+ agentId: row.agent_id,+ text: row.thread_parts ? null : row.text,+ threadParts: Array.isArray(row.thread_parts) ? row.thread_parts : null,+ replyTo: row.reply_to_tweet_id || null,+ appendLink: Boolean(row.agent_id),+ });await sql`update x_scheduled_postsset posted_at = now(), tweet_id = ${result.tweet_id}, attempts = attempts + 1@@ -2634,7 +2642,7 @@ async function handleRunXTriggers(req, res) {const started = Date.now();const rows = await sql`- select id, user_id, agent_id, kind, config, last_fired_at, last_state+ select id, user_id, agent_id, kind, config, auto_publish, last_fired_at, last_statefrom x_triggerswhere enabled = trueorder by coalesce(last_fired_at, '1970-01-01'::timestamptz) asc@@ -2669,7 +2677,16 @@ function utcHour(d) { return d.getUTCHours(); }function utcDay(d) { return d.getUTCDay(); }function ymdUTC(d) { return `${d.getUTCFullYear()}-${String(d.getUTCMonth()+1).padStart(2,'0')}-${String(d.getUTCDate()).padStart(2,'0')}`; }+// Either enqueue for immediate publish (auto_publish=true) or stash in the+// pending-review queue for the user to approve (auto_publish=false).async function enqueueTriggerPost(t, text) {+ if (t.auto_publish === false) {+ await sql`+ insert into x_pending_reviews (user_id, trigger_id, agent_id, text)+ values (${t.user_id}, ${t.id}, ${t.agent_id}, ${text})+ `;+ return;+ }await sql`insert into x_scheduled_posts (user_id, agent_id, text, scheduled_at)values (${t.user_id}, ${t.agent_id}, ${text}, now())@@ -2824,3 +2841,77 @@ async function evalPaymentReceived(t) {if (lastId) await setTriggerState(t, { last_payment_id: lastId });return true;}++// ═══════════════════════════════════════════════════════════════════════════+// fetch-x-metrics+//+// Pulls public_metrics (likes, retweets, replies, impressions) for posts+// older than ~1h and not refreshed in last 6h. Stored on x_posts.metrics.+// ═══════════════════════════════════════════════════════════════════════════++async function handleFetchXMetrics(req, res) {+ if (cors(req, res, { methods: 'GET,POST,OPTIONS' })) return;+ const auth = req.headers['authorization'] || '';+ const expected = env.CRON_SECRET ? `Bearer ${env.CRON_SECRET}` : null;+ const fromCron = req.headers['x-vercel-cron'] === '1';+ if (!fromCron && expected && auth !== expected) {+ return error(res, 401, 'unauthorized', 'cron secret required');+ }++ const { decryptToken } = await import('../auth/x/[action].js');++ // Pick distinct users with posts needing refresh.+ const users = await sql`+ select distinct user_id+ from x_posts+ where created_at < now() - interval '1 hour'+ and (metrics_fetched_at is null or metrics_fetched_at < now() - interval '6 hours')+ limit 50+ `;++ const report = { users: 0, fetched: 0, errors: 0 };+ for (const u of users) {+ report.users++;+ const conn = (await sql`+ select access_token, expires_at, refresh_token, id+ from social_connections+ where user_id = ${u.user_id} and provider = 'x' and disconnected_at is null+ limit 1+ `)[0];+ if (!conn || !conn.access_token) continue;+ let accessToken;+ try { accessToken = decryptToken(conn.access_token); } catch { continue; }++ const posts = await sql`+ select id, tweet_id from x_posts+ where user_id = ${u.user_id}+ and created_at < now() - interval '1 hour'+ and (metrics_fetched_at is null or metrics_fetched_at < now() - interval '6 hours')+ order by created_at desc+ limit 100+ `;+ if (!posts.length) continue;++ // X allows up to 100 ids per /2/tweets lookup.+ const ids = posts.map((p) => p.tweet_id).join(',');+ const r = await fetch(`https://api.twitter.com/2/tweets?ids=${ids}&tweet.fields=public_metrics`, {+ headers: { authorization: `Bearer ${accessToken}` },+ });+ if (!r.ok) { report.errors++; continue; }+ const { data = [] } = await r.json();+ const byId = new Map(data.map((d) => [d.id, d.public_metrics]));++ for (const p of posts) {+ const m = byId.get(p.tweet_id);+ if (!m) continue;+ await sql`+ update x_posts+ set metrics = ${JSON.stringify(m)}::jsonb, metrics_fetched_at = now()+ where id = ${p.id}+ `;+ report.fetched++;+ }+ }++ return json(res, 200, report);+}diff --git a/api/x/analytics.js b/api/x/analytics.jsnew file mode 100644index 000000000..4fc4e61c9--- /dev/null+++ b/api/x/analytics.js@@ -0,0 +1,43 @@+// GET /api/x/analytics — recent posts with engagement metrics+// Optional: ?agent_id=<id> to filter++import { sql } from '../_lib/db.js';+import { getSessionUser } from '../_lib/auth.js';+import { cors, method, wrap, error, json } from '../_lib/http.js';++export default wrap(async (req, res) => {+ if (cors(req, res, { methods: 'GET,OPTIONS', credentials: true })) return;+ if (!method(req, res, ['GET'])) return;++ const user = await getSessionUser(req);+ if (!user) return error(res, 401, 'unauthorized', 'sign in required');++ const url = new URL(req.url, 'http://x');+ const agentId = url.searchParams.get('agent_id');++ const rows = agentId+ ? await sql`+ select id, tweet_id, text, agent_id, metrics, metrics_fetched_at, created_at+ from x_posts where user_id = ${user.id} and agent_id = ${agentId}+ order by created_at desc limit 50+ `+ : await sql`+ select id, tweet_id, text, agent_id, metrics, metrics_fetched_at, created_at+ from x_posts where user_id = ${user.id}+ order by created_at desc limit 50+ `;++ // Roll up totals.+ const totals = rows.reduce((acc, r) => {+ const m = r.metrics || {};+ acc.likes += m.like_count || 0;+ acc.retweets += m.retweet_count || 0;+ acc.replies += m.reply_count || 0;+ acc.quotes += m.quote_count || 0;+ acc.impressions += m.impression_count || 0;+ acc.posts++;+ return acc;+ }, { posts: 0, likes: 0, retweets: 0, replies: 0, quotes: 0, impressions: 0 });++ return json(res, 200, { totals, posts: rows });+});diff --git a/api/x/post.js b/api/x/post.jsindex 6a1d1473a..2be1e9442 100644--- a/api/x/post.js+++ b/api/x/post.js@@ -1,5 +1,6 @@-// POST /api/x/post — publish a tweet immediately. Body: { text, agent_id? }-// Quota, dedup, and token-refresh logic live in api/_lib/x-post.js.+// POST /api/x/post+// Body: { text?, thread_parts?, agent_id?, append_link?, reply_to_tweet_id? }+// One of `text` (single tweet) or `thread_parts` (array → thread) is required.import { getSessionUser } from '../_lib/auth.js';import { cors, method, wrap, error, readJson, json } from '../_lib/http.js';@@ -14,10 +15,13 @@ export default wrap(async (req, res) => {const body = await readJson(req);const text = typeof body?.text === 'string' ? body.text : '';+ const threadParts = Array.isArray(body?.thread_parts) ? body.thread_parts : null;const agentId = typeof body?.agent_id === 'string' ? body.agent_id : null;+ const replyTo = typeof body?.reply_to_tweet_id === 'string' ? body.reply_to_tweet_id : null;+ const appendLink = body?.append_link === true;try {- const result = await publishTweet({ userId: user.id, agentId, text });+ const result = await publishTweet({ userId: user.id, agentId, text, threadParts, replyTo, appendLink });return json(res, 200, result);} catch (err) {if (err instanceof XPostError) return error(res, err.status, err.code, err.message, err.extra);diff --git a/api/x/reviews.js b/api/x/reviews.jsnew file mode 100644index 000000000..91aa00a1a--- /dev/null+++ b/api/x/reviews.js@@ -0,0 +1,73 @@+// GET /api/x/reviews — list pending review drafts+// PATCH /api/x/reviews?id=<uuid> — approve (publishes) or edit + approve+// body: { action: 'approve'|'reject', text?, thread_parts? }+// DELETE /api/x/reviews?id=<uuid> — reject without publishing++import { sql } from '../_lib/db.js';+import { getSessionUser } from '../_lib/auth.js';+import { cors, method, wrap, error, readJson, json } from '../_lib/http.js';+import { publishTweet, XPostError } from '../_lib/x-post.js';++export default wrap(async (req, res) => {+ if (cors(req, res, { methods: 'GET,PATCH,DELETE,OPTIONS', credentials: true })) return;+ if (!method(req, res, ['GET', 'PATCH', 'DELETE'])) return;++ const user = await getSessionUser(req);+ if (!user) return error(res, 401, 'unauthorized', 'sign in required');++ if (req.method === 'GET') {+ const rows = await sql`+ select id, trigger_id, agent_id, text, thread_parts, status, created_at+ from x_pending_reviews+ where user_id = ${user.id} and status = 'pending'+ order by created_at desc+ limit 50+ `;+ return json(res, 200, { reviews: rows });+ }++ const url = new URL(req.url, 'http://x');+ const id = url.searchParams.get('id');+ if (!id) return error(res, 400, 'validation_error', 'id required');++ const rows = await sql`+ select * from x_pending_reviews+ where id = ${id} and user_id = ${user.id} and status = 'pending'+ limit 1+ `;+ const review = rows[0];+ if (!review) return error(res, 404, 'not_found', 'review not found or already resolved');++ if (req.method === 'DELETE') {+ await sql`update x_pending_reviews set status = 'rejected', resolved_at = now() where id = ${id}`;+ return json(res, 200, { rejected: id });+ }++ // PATCH — approve (possibly with edits)+ const body = await readJson(req);+ const action = body?.action || 'approve';+ if (action === 'reject') {+ await sql`update x_pending_reviews set status = 'rejected', resolved_at = now() where id = ${id}`;+ return json(res, 200, { rejected: id });+ }+ if (action !== 'approve') return error(res, 400, 'validation_error', 'action must be approve or reject');++ const text = typeof body?.text === 'string' ? body.text : review.text;+ const threadParts = Array.isArray(body?.thread_parts) ? body.thread_parts : (Array.isArray(review.thread_parts) ? review.thread_parts : null);+ const appendLink = body?.append_link === true;++ try {+ const result = await publishTweet({+ userId: user.id,+ agentId: review.agent_id,+ text: threadParts ? null : text,+ threadParts,+ appendLink,+ });+ await sql`update x_pending_reviews set status = 'approved', resolved_at = now() where id = ${id}`;+ return json(res, 200, { approved: id, ...result });+ } catch (err) {+ if (err instanceof XPostError) return error(res, err.status, err.code, err.message, err.extra);+ return error(res, 500, 'internal_error', err.message || 'publish failed');+ }+});diff --git a/api/x/status.js b/api/x/status.jsindex 291c6a051..655943ea3 100644--- a/api/x/status.js+++ b/api/x/status.js@@ -1,11 +1,10 @@-// GET /api/x/status — current user's X connection + quota-// DELETE /api/x/status — disconnect X account (soft delete: sets disconnected_at)+// GET /api/x/status — connection + quota + tier+// DELETE /api/x/status — disconnectimport { sql } from '../_lib/db.js';import { getSessionUser } from '../_lib/auth.js';import { cors, method, wrap, error, json } from '../_lib/http.js';--const FREE_MONTHLY_QUOTA = 5;+import { getUserTier } from '../_lib/x-post.js';export default wrap(async (req, res) => {if (cors(req, res, { methods: 'GET,DELETE,OPTIONS', credentials: true })) return;@@ -23,16 +22,17 @@ export default wrap(async (req, res) => {return json(res, 200, { disconnected: true });}+ const tier = await getUserTier(user.id);+const rows = await sql`- select username, posts_this_month, month_resets_at, connected_at+ select username, posts_this_month, month_resets_at, connected_at, last_posted_atfrom social_connectionswhere user_id = ${user.id} and provider = 'x' and disconnected_at is nulllimit 1`;const conn = rows[0];- if (!conn) return json(res, 200, { connected: false });+ if (!conn) return json(res, 200, { connected: false, tier: tier.tier, quota: tier.quota });- // Reset counter if month rolled over.let postsThisMonth = conn.posts_this_month;if (new Date(conn.month_resets_at) <= new Date()) {await sql`@@ -47,9 +47,12 @@ export default wrap(async (req, res) => {return json(res, 200, {connected: true,username: conn.username,+ tier: tier.tier,+ quota: tier.quota,posts_used: postsThisMonth,- quota: FREE_MONTHLY_QUOTA,month_resets_at: conn.month_resets_at,connected_at: conn.connected_at,+ last_posted_at: conn.last_posted_at,+ min_interval_min: tier.min_interval_min,});});diff --git a/app-demo.html b/app-demo.htmlindex 5af2108c5..c340bbad4 100644--- a/app-demo.html+++ b/app-demo.html@@ -46,14 +46,9 @@<meta name="robots" content="noindex" /><link rel="shortcut icon" href="/favicon.ico" /><link rel="apple-touch-icon" href="/pwa-192x192.png" />- <link rel="preconnect" href="https://fonts.googleapis.com" />- <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin /><link rel="stylesheet" href="style.css" /><link rel="stylesheet" href="/app-demo.css" />- <link- href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Space+Grotesk:wght@500;600;700&display=swap"- rel="stylesheet"- />+ <link rel="stylesheet" href="/fonts/fonts.css" /><script defer type="module" src="/src/app.js"></script><link rel="stylesheet" href="/nav.css" /></head>diff --git a/app.html b/app.htmlindex 35d633a16..a0dac0fd8 100644--- a/app.html+++ b/app.html@@ -45,13 +45,8 @@<link rel="canonical" href="https://three.ws/app" /><link rel="shortcut icon" href="/favicon.ico" /><link rel="apple-touch-icon" href="/pwa-192x192.png" />- <link rel="preconnect" href="https://fonts.googleapis.com" />- <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin /><link rel="stylesheet" href="style.css" />- <link- href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Space+Grotesk:wght@500;600;700&display=swap"- rel="stylesheet"- />+ <link rel="stylesheet" href="/fonts/fonts.css" /><script defer type="module" src="/src/app.js"></script><link rel="stylesheet" href="/nav.css" /></head>diff --git a/avatar-page.html b/avatar-page.htmlindex e56202425..3e53b8299 100644--- a/avatar-page.html+++ b/avatar-page.html@@ -10,10 +10,7 @@<link rel="stylesheet" href="/footer.css" /><link rel="stylesheet" href="/nav.css" /><script defer src="/footer-newsletter.js"></script>- <link- href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Space+Grotesk:wght@500;600;700&display=swap"- rel="stylesheet"- />+ <link rel="stylesheet" href="/fonts/fonts.css" /><scripttype="module"src="https://ajax.googleapis.com/ajax/libs/model-viewer/4.0.0/model-viewer.min.js"@@ -554,6 +551,79 @@font-weight: 600;}+ /* ── Used by (agents wearing this body) ──────────── */+ .av-used-by {+ margin-top: 18px;+ padding-top: 16px;+ border-top: 1px solid var(--border);+ }+ .av-used-by-heading {+ font-size: 11px;+ text-transform: uppercase;+ letter-spacing: 0.08em;+ color: var(--text-3);+ margin: 0 0 10px;+ font-weight: 600;+ }+ .av-used-by-grid {+ display: grid;+ grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));+ gap: 8px;+ }+ .av-used-by-card {+ display: flex;+ align-items: center;+ gap: 10px;+ padding: 8px 10px;+ background: var(--panel);+ border: 1px solid var(--border);+ border-radius: 10px;+ text-decoration: none;+ color: inherit;+ transition: border-color 0.15s, transform 0.15s;+ }+ .av-used-by-card:hover {+ border-color: var(--text-3);+ transform: translateY(-1px);+ }+ .av-used-by-thumb {+ flex: 0 0 32px;+ width: 32px;+ height: 32px;+ border-radius: 50%;+ object-fit: cover;+ background: var(--panel-2);+ }+ .av-used-by-thumb--placeholder {+ display: grid;+ place-items: center;+ color: var(--text-3);+ font-size: 13px;+ font-weight: 600;+ font-family: 'Space Grotesk', sans-serif;+ }+ .av-used-by-meta {+ min-width: 0;+ display: flex;+ flex-direction: column;+ gap: 2px;+ }+ .av-used-by-name {+ font-size: 12px;+ font-weight: 600;+ color: var(--text);+ white-space: nowrap;+ overflow: hidden;+ text-overflow: ellipsis;+ }+ .av-used-by-badge {+ font-size: 9px;+ letter-spacing: 0.08em;+ text-transform: uppercase;+ color: var(--success);+ font-weight: 600;+ }+/* ── Embed panel ─────────────────────────────────── */.av-embed-section { margin-bottom: 18px; }.av-embed-label {diff --git a/chat/index.html b/chat/index.htmlindex a2cf6a355..e4608053c 100644--- a/chat/index.html+++ b/chat/index.html@@ -24,9 +24,7 @@<meta name="twitter:description" content="Chat with any AI model — Claude, GPT, Gemini, Ollama and more." /><meta name="twitter:image" content="https://three.ws/og-image.png" />- <link rel="preconnect" href="https://fonts.googleapis.com">- <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>- <link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=Lora:ital,wght@0,500;0,600;0,700;1,500&display=swap" rel="stylesheet">+ <link rel="stylesheet" href="/fonts/fonts.css" /><linkrel="stylesheet"href="https://cdn.jsdelivr.net/npm/[email protected]/dist/katex.min.css"diff --git a/docs/api.html b/docs/api.htmlindex 84805304b..cecf8fedf 100644--- a/docs/api.html+++ b/docs/api.html@@ -9,12 +9,7 @@content="API Reference for three.ws — the open-source platform for 3D AI agents."/><link rel="icon" href="/favicon.ico" />- <link rel="preconnect" href="https://fonts.googleapis.com" />- <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />- <link- href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Space+Grotesk:wght@500;600;700&display=swap"- rel="stylesheet"- />+ <link rel="stylesheet" href="/fonts/fonts.css" /><link rel="stylesheet" href="/style.css" /><linkrel="stylesheet"diff --git a/docs/index.html b/docs/index.htmlindex 85da5f609..b6d318dff 100644--- a/docs/index.html+++ b/docs/index.html@@ -6,12 +6,7 @@<title>Docs — three.ws</title><meta name="description" content="Documentation for three.ws — the open-source platform for 3D AI agents." /><link rel="icon" href="/favicon.ico" />- <link rel="preconnect" href="https://fonts.googleapis.com" />- <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />- <link- href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Space+Grotesk:wght@500;600;700&display=swap"- rel="stylesheet"- />+ <link rel="stylesheet" href="/fonts/fonts.css" /><link rel="stylesheet" href="/style.css" /><linkrel="stylesheet"@@ -806,5 +801,8 @@buildSidebar();navigate();</script>++ <div id="footer-container"></div>+ <script src="/footer.js" defer></script></body></html>diff --git a/features.html b/features.htmlindex 1b9e95e38..755895032 100644--- a/features.html+++ b/features.html@@ -35,15 +35,10 @@<link rel="canonical" href="https://three.ws/features" /><link rel="shortcut icon" href="/favicon.ico" /><link rel="apple-touch-icon" href="/pwa-192x192.png" />- <link rel="preconnect" href="https://fonts.googleapis.com" />- <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin /><link rel="stylesheet" href="/style.css" /><link rel="stylesheet" href="/nav.css" /><link rel="stylesheet" href="/features.css" />- <link- href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400&family=Space+Grotesk:wght@500;600;700&display=swap"- rel="stylesheet"- />+ <link rel="stylesheet" href="/fonts/fonts.css" /><scripttype="module"src="https://ajax.googleapis.com/ajax/libs/model-viewer/4.0.0/model-viewer.min.js"diff --git a/home.html b/home.htmlindex e9d4bd0e6..4ce01ff03 100644--- a/home.html+++ b/home.html@@ -35,8 +35,6 @@<link rel="canonical" href="https://three.ws/" /><link rel="shortcut icon" href="/favicon.ico" /><link rel="apple-touch-icon" href="/pwa-192x192.png" />- <link rel="preconnect" href="https://fonts.googleapis.com" />- <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin /><link rel="stylesheet" href="/style.css" /><link rel="stylesheet" href="/nav.css" /><link rel="stylesheet" href="/home.css" />@@ -44,10 +42,7 @@<link rel="stylesheet" href="/footer.css" /><script defer src="/footer-newsletter.js"></script><script defer src="/home-polish.js"></script>- <link- href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400&family=Space+Grotesk:wght@500;600;700&display=swap"- rel="stylesheet"- />+ <link rel="stylesheet" href="/fonts/fonts.css" /><scripttype="module"src="https://ajax.googleapis.com/ajax/libs/model-viewer/4.0.0/model-viewer.min.js"diff --git a/marketplace.html b/marketplace.htmlindex 42f132d1a..5cdaa5897 100644--- a/marketplace.html+++ b/marketplace.html@@ -11,17 +11,12 @@<meta name="theme-color" content="#000000" /><link rel="canonical" href="https://three.ws/marketplace" /><link rel="shortcut icon" href="/favicon.ico" />- <link rel="preconnect" href="https://fonts.googleapis.com" />- <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin /><link rel="stylesheet" href="style.css" /><link rel="stylesheet" href="footer.css" /><link rel="stylesheet" href="marketplace.css" /><link rel="stylesheet" href="marketplace-skills.css" /><link rel="stylesheet" href="marketplace-v2.css" />- <link- href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Space+Grotesk:wght@500;600;700&display=swap"- rel="stylesheet"- />+ <link rel="stylesheet" href="/fonts/fonts.css" /><style>/* Author display rules on modal overlays override the UA stylesheet's[hidden] { display: none } default, so `<div … hidden>` was stilldiff --git a/package.json b/package.jsonindex c4afb67a0..9babd002a 100644--- a/package.json+++ b/package.json@@ -43,6 +43,8 @@"postinstall": "npm run build --prefix agent-payments-sdk && node scripts/fix-pump-sdk-esm.mjs","dev": "vite --port 3000","dev:lib": "TARGET=lib vite",+ "build:pages": "node scripts/build-page-index.mjs",+ "prebuild": "node scripts/build-page-index.mjs","build": "vite build","build:animations": "node scripts/build-animations.mjs","build:artifact-viewer": "node scripts/build-artifact-viewer.mjs",diff --git a/playground.html b/playground.htmlindex 451db4e3a..d69f37daa 100644--- a/playground.html+++ b/playground.html@@ -8,10 +8,7 @@<link rel="stylesheet" href="/style.css"><link rel="stylesheet" href="/nav.css" /><link rel="stylesheet" href="/footer.css" />- <link- href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap"- rel="stylesheet"- />+ <link rel="stylesheet" href="/fonts/fonts.css" /><scripttype="module"src="https://ajax.googleapis.com/ajax/libs/model-viewer/4.0.0/model-viewer.min.js"diff --git a/pretext-demo.html b/pretext-demo.htmlindex 55ee24d4a..d37a572b1 100644--- a/pretext-demo.html+++ b/pretext-demo.html@@ -4,9 +4,7 @@<meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><title>three.ws — Give Your AI a Body</title>- <link rel="preconnect" href="https://fonts.googleapis.com">- <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>- <link href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Space+Grotesk:wght@500;600;700&display=swap" rel="stylesheet">+ <link rel="stylesheet" href="/fonts/fonts.css" /><script type="module" src="https://ajax.googleapis.com/ajax/libs/model-viewer/4.0.0/model-viewer.min.js"></script><style>*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }diff --git a/pricing.html b/pricing.htmlnew file mode 100644index 000000000..988222512--- /dev/null+++ b/pricing.html@@ -0,0 +1,158 @@+<!doctype html>+<html lang="en">+<head>+ <meta charset="utf-8" />+ <meta name="viewport" content="width=device-width,initial-scale=1" />+ <title>Pricing · three.ws</title>+ <link rel="icon" href="/favicon.ico" />+ <style>+ :root { color-scheme: dark; --accent:#6a5cff; --accent2:#ff5ca8; --border:#22222e; --bg:#0b0b10; --panel:#14141c; }+ * { box-sizing: border-box; }+ body { font: 15px/1.55 -apple-system, system-ui, Segoe UI, Roboto, sans-serif; color:#eee; margin:0; background:var(--bg); min-height:100vh; }+ .wrap { max-width: 880px; margin: 0 auto; padding: 56px 24px 80px; }+ h1 { font-size: 32px; margin: 0 0 8px; letter-spacing: -0.02em; }+ .sub { color:#888; margin: 0 0 36px; font-size:15px; }+ .grid { display:grid; grid-template-columns: 1fr 1fr; gap:18px; }+ @media (max-width: 720px) { .grid { grid-template-columns: 1fr; } }+ .card { background:var(--panel); border:1px solid var(--border); border-radius:16px; padding:28px 24px; display:flex; flex-direction:column; }+ .card.pro { border-color:var(--accent); box-shadow:0 0 0 1px var(--accent) inset; position:relative; }+ .tag { position:absolute; top:-10px; right:18px; background:var(--accent); color:#fff; font-size:11px; padding:3px 10px; border-radius:99px; font-weight:600; letter-spacing:0.05em; }+ .tier { font-size:13px; text-transform:uppercase; letter-spacing:0.08em; color:#888; font-weight:600; }+ .price { font-size:38px; margin:8px 0 4px; font-weight:600; letter-spacing:-0.01em; }+ .price small { font-size:14px; color:#888; font-weight:400; }+ .feat { list-style:none; padding:0; margin:18px 0 0; }+ .feat li { padding:8px 0; border-bottom:1px solid #1c1c26; color:#ccc; font-size:14px; display:flex; align-items:center; gap:8px; }+ .feat li:last-child { border-bottom:none; }+ .feat li::before { content:"✓"; color:var(--accent); font-weight:600; }+ .btn { padding:12px 16px; border-radius:10px; border:0; background:var(--accent); color:#fff; font-size:14px; font-weight:600; cursor:pointer; margin-top:auto; }+ .btn:hover { filter:brightness(1.1); }+ .btn.sec { background:#222230; color:#ddd; }+ .btn:disabled { opacity:0.5; cursor:not-allowed; }+ .checkout { display:none; margin-top:36px; padding:24px; border:1px solid var(--accent); border-radius:14px; background:rgba(106,92,255,0.06); }+ .checkout.show { display:block; }+ .qr { display:block; width:200px; height:200px; margin:16px 0; background:#fff; padding:10px; border-radius:10px; }+ code.payurl { display:block; font-size:11px; word-break:break-all; padding:10px; background:#0f0f17; border:1px solid var(--border); border-radius:8px; color:#9a8cff; margin:10px 0; }+ .muted { color:#888; font-size:13px; }+ .status { margin-top:12px; font-size:13px; }+ .ok { color:#4ade80; }+ .err { color:#ffb3b3; }+ a { color:#9a8cff; }+ header { padding:18px 24px; border-bottom:1px solid var(--border); }+ header a { color:#aaa; text-decoration:none; font-size:14px; }+ </style>+</head>+<body>+ <header><a href="/">← three.ws</a></header>+ <div class="wrap">+ <h1>Pricing</h1>+ <p class="sub">Run autonomous AI agents that post, trade, and earn on-chain. <span id="current-plan" class="muted"></span></p>++ <div class="grid">+ <div class="card">+ <div class="tier">Free</div>+ <div class="price">$0<small> /month</small></div>+ <ul class="feat">+ <li>5 X posts per month</li>+ <li>1 post every 30 min</li>+ <li>All trigger types (daily, weekly, milestones)</li>+ <li>AI-drafted tweets with tone presets</li>+ <li>Manual + scheduled posts</li>+ <li>Engagement analytics</li>+ </ul>+ <button class="btn sec" disabled>You're on Free</button>+ </div>+ <div class="card pro">+ <div class="tag">Recommended</div>+ <div class="tier">Pro</div>+ <div class="price">$19<small> /month</small></div>+ <ul class="feat">+ <li>100 X posts per month</li>+ <li>1 post every 5 min</li>+ <li>Threads (multi-tweet posts)</li>+ <li>Review-before-publish mode</li>+ <li>Multi-draft picker (3 options)</li>+ <li>Priority support</li>+ </ul>+ <button class="btn" id="upgrade-btn">Upgrade with USDC</button>+ </div>+ </div>++ <div class="checkout" id="checkout">+ <h3 style="margin:0 0 8px">Pay $19 USDC on Solana</h3>+ <p class="muted">Scan with Phantom or any Solana wallet, or open the link on the device with your wallet.</p>+ <img class="qr" id="qr" alt="Solana Pay QR" />+ <code class="payurl" id="payurl"></code>+ <a class="btn" id="open-link" href="#" target="_blank" rel="noopener" style="display:inline-block; text-align:center; text-decoration:none">Open in wallet</a>+ <div class="muted" style="margin-top:14px">After paying, paste the transaction signature:</div>+ <input id="txsig" placeholder="Transaction signature" style="width:100%; margin-top:6px; padding:9px 11px; background:#0f0f17; border:1px solid var(--border); border-radius:8px; color:#eee; font-size:13px; font-family:inherit" />+ <button class="btn" id="confirm-btn" style="margin-top:10px">I've paid — confirm</button>+ <div class="status" id="status"></div>+ </div>+ </div>++ <script type="module">+ const $ = (id) => document.getElementById(id);+ const setStatus = (text, cls = '') => { $('status').textContent = text; $('status').className = 'status ' + cls; };++ let currentIntent = null;++ // Show current plan if signed in.+ try {+ const r = await fetch('/api/x/status', { credentials: 'include' });+ if (r.ok) {+ const d = await r.json();+ $('current-plan').textContent = d.tier === 'pro' ? "You're already on Pro." : '';+ if (d.tier === 'pro') $('upgrade-btn').textContent = 'Already Pro ✓', $('upgrade-btn').disabled = true;+ }+ } catch {}++ $('upgrade-btn').addEventListener('click', async () => {+ $('upgrade-btn').disabled = true;+ $('upgrade-btn').textContent = 'Creating checkout…';+ try {+ const r = await fetch('/api/payments/solana?action=checkout', {+ method: 'POST',+ credentials: 'include',+ headers: { 'content-type': 'application/json' },+ body: JSON.stringify({ plan: 'pro', network: 'mainnet' }),+ });+ const d = await r.json();+ if (!r.ok) throw new Error(d.error_description || 'checkout failed');+ currentIntent = d;+ $('payurl').textContent = d.solana_pay_url;+ $('qr').src = `https://api.qrserver.com/v1/create-qr-code/?size=400x400&data=${encodeURIComponent(d.solana_pay_url)}`;+ $('open-link').href = d.solana_pay_url;+ $('checkout').classList.add('show');+ $('upgrade-btn').textContent = 'Pay below ↓';+ } catch (err) {+ $('upgrade-btn').disabled = false;+ $('upgrade-btn').textContent = 'Upgrade with USDC';+ alert(err.message);+ }+ });++ $('confirm-btn').addEventListener('click', async () => {+ const txsig = $('txsig').value.trim();+ if (!txsig) return setStatus('Paste the transaction signature first.', 'err');+ if (!currentIntent) return setStatus('No active checkout — click Upgrade first.', 'err');+ $('confirm-btn').disabled = true;+ setStatus('Verifying transaction on-chain…');+ try {+ const r = await fetch('/api/payments/solana?action=confirm', {+ method: 'POST',+ credentials: 'include',+ headers: { 'content-type': 'application/json' },+ body: JSON.stringify({ intent_id: currentIntent.intent_id, tx_signature: txsig, network: 'mainnet' }),+ });+ const d = await r.json();+ if (!r.ok) throw new Error(d.error_description || 'confirm failed');+ setStatus(`You're Pro until ${new Date(d.active_until).toLocaleDateString()}. Redirecting…`, 'ok');+ setTimeout(() => { location.href = '/dashboard'; }, 1800);+ } catch (err) {+ setStatus(err.message, 'err');+ $('confirm-btn').disabled = false;+ }+ });+ </script>+</body>+</html>diff --git a/profile.html b/profile.htmlindex e7a81b0c3..7806ca310 100644--- a/profile.html+++ b/profile.html@@ -8,15 +8,10 @@<meta name="theme-color" content="#000000" /><link rel="shortcut icon" href="/favicon.ico" />- <link rel="preconnect" href="https://fonts.googleapis.com" />- <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin /><link rel="stylesheet" href="/style.css" /><link rel="stylesheet" href="/footer.css" /><script defer src="/footer-newsletter.js"></script>- <link- href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500&display=swap"- rel="stylesheet"- />+ <link rel="stylesheet" href="/fonts/fonts.css" /><scripttype="module"src="https://ajax.googleapis.com/ajax/libs/model-viewer/4.0.0/model-viewer.min.js"diff --git a/public/agent/index.html b/public/agent/index.htmlindex 91e282bfc..296b10a7d 100644--- a/public/agent/index.html+++ b/public/agent/index.html@@ -11,14 +11,8 @@<meta name="theme-color" content="#000000" /><link rel="shortcut icon" href="/favicon.ico" />- <link rel="preconnect" href="https://fonts.googleapis.com" />- <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin /><link rel="stylesheet" href="/style.css" />- <link- href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500&display=swap"- rel="stylesheet"- />-+ <link rel="stylesheet" href="/fonts/fonts.css" /><!-- unfurl (populated at runtime from identity) --><meta property="og:type" content="website" /><meta property="og:title" content="Agent" id="og-title" />diff --git a/public/ai-stream.html b/public/ai-stream.htmlindex f1e87b1cd..6ff03bfc4 100644--- a/public/ai-stream.html+++ b/public/ai-stream.html@@ -5,11 +5,9 @@<meta name="viewport" content="width=device-width,initial-scale=1" /><title>AI Stream · three.ws</title><link rel="icon" href="/favicon.ico" />- <link rel="preconnect" href="https://fonts.googleapis.com" />- <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin /><link rel="stylesheet" href="/style.css" /><link rel="stylesheet" href="/ai-stream.css" />- <link href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Space+Grotesk:wght@500;600;700&display=swap" rel="stylesheet" />+ <link rel="stylesheet" href="/fonts/fonts.css" /></head><body class="ai-stream-page"><header class="ai-stream-header">diff --git a/public/artifact/index.html b/public/artifact/index.htmlindex 80b046498..82fc3f2dc 100644--- a/public/artifact/index.html+++ b/public/artifact/index.html@@ -415,6 +415,11 @@</style></head><body>+ <header>+ <div id="nav-container"></div>+ </header>+ <script src="/nav.js"></script>+<main class="artifact-page"><header class="hero"><span class="eyebrow">Claude.ai artifact</span>@@ -734,5 +739,8 @@}})();</script>++ <div id="footer-container"></div>+ <script src="/footer.js" defer></script></body></html>diff --git a/public/cz/index.html b/public/cz/index.htmlindex dcb7e5786..85752074f 100644--- a/public/cz/index.html+++ b/public/cz/index.html@@ -26,6 +26,11 @@</head><body><header>+ <div id="nav-container"></div>+ </header>+ <script src="/nav.js"></script>++ <header class="page-header"><span class="logo"><img src="/three.svg" alt="" class="header-logo" aria-hidden="true" />three.ws</span></header><main>@@ -67,5 +72,8 @@</section></main><script type="module" src="/cz/cz.js"></script>++ <div id="footer-container"></div>+ <script src="/footer.js" defer></script></body></html>diff --git a/public/dashboard/_agent-picker.js b/public/dashboard/_agent-picker.jsnew file mode 100644index 000000000..8a95e9c70--- /dev/null+++ b/public/dashboard/_agent-picker.js@@ -0,0 +1,71 @@+// Shared agent picker for /dashboard sub-pages.+// Reads ?agent=<id> from the URL or, if absent, fetches the user's agents+// and renders a dropdown. Calls onPick(agentId, agent) when ready.++export async function mountAgentPicker({ host, onPick, paramKey = 'agent' }) {+ const params = new URLSearchParams(location.search);+ let selected = params.get(paramKey);++ let agents = [];+ try {+ const r = await fetch('/api/agents', { credentials: 'include' });+ if (r.status === 401) {+ location.href = '/login?next=' + encodeURIComponent(location.pathname + location.search);+ return;+ }+ if (r.ok) {+ const data = await r.json();+ agents = data.agents || [];+ }+ } catch {+ /* fall through with empty list */+ }++ if (!agents.length) {+ host.innerHTML =+ '<div style="padding:14px 16px;background:#1a1a24;border:1px solid #22222e;border-radius:10px;color:#aaa">' ++ 'You have no agents yet. <a href="/dashboard/agents" style="color:#9a8cff">Create your first agent</a> to use this page.' ++ '</div>';+ return;+ }++ const pre = agents.find((a) => a.id === selected) || null;+ if (!pre && selected) selected = null;++ const select = document.createElement('select');+ select.style.cssText =+ 'background:#14141c;color:#eee;border:1px solid #22222e;border-radius:8px;padding:8px 10px;font-size:14px;min-width:240px';++ if (!selected) {+ const opt = document.createElement('option');+ opt.value = '';+ opt.textContent = 'Pick an agent…';+ select.appendChild(opt);+ }+ for (const a of agents) {+ const opt = document.createElement('option');+ opt.value = a.id;+ opt.textContent = `${a.name || 'Agent'} · ${a.id.slice(0, 8)}…`;+ if (a.id === selected) opt.selected = true;+ select.appendChild(opt);+ }++ const label = document.createElement('span');+ label.style.cssText = 'color:#888;font-size:13px;margin-right:8px';+ label.textContent = 'Agent:';++ host.innerHTML = '';+ host.style.cssText = 'display:flex;align-items:center;gap:8px;margin-bottom:18px;flex-wrap:wrap';+ host.appendChild(label);+ host.appendChild(select);++ select.addEventListener('change', () => {+ if (!select.value) return;+ const url = new URL(location.href);+ url.searchParams.set(paramKey, select.value);+ history.replaceState({}, '', url);+ onPick(select.value, agents.find((a) => a.id === select.value));+ });++ if (selected) onPick(selected, pre);+}diff --git a/public/dashboard/_dash-shell.css b/public/dashboard/_dash-shell.cssnew file mode 100644index 000000000..757870e38--- /dev/null+++ b/public/dashboard/_dash-shell.css@@ -0,0 +1,111 @@+/* Shared shell styling for /dashboard sub-pages. Dark theme to match dashboard. */+:root {+ color-scheme: dark;+ --accent: #6a5cff;+ --accent2: #ff5ca8;+ --border: #22222e;+ --bg: #0b0b10;+ --panel: #14141c;+}+* { box-sizing: border-box; }+body {+ font: 15px/1.55 system-ui, -apple-system, Segoe UI, Roboto, sans-serif;+ color: #eee;+ margin: 0;+ background: var(--bg);+ min-height: 100vh;+}+a { color: #9a8cff; text-decoration: none; }+a:hover { text-decoration: underline; }+.dash-shell { max-width: 980px; margin: 0 auto; padding: 28px; }+.dash-back { color: #888; font-size: 13px; margin-bottom: 10px; display: inline-block; }+.dash-back:hover { color: #ccc; }+h1.dash-title { font-size: 22px; margin: 0 0 6px; letter-spacing: -0.01em; }+.dash-sub { color: #888; margin: 4px 0 22px; font-size: 14px; }+.dash-card {+ background: var(--panel);+ border: 1px solid var(--border);+ border-radius: 12px;+ padding: 18px;+ margin-bottom: 14px;+}+.dash-card h2 {+ margin: 0 0 14px;+ font-size: 14px;+ letter-spacing: 0.06em;+ text-transform: uppercase;+ color: #aaa;+}+.dash-btn {+ background: #1f1f2c;+ color: #eee;+ border: 1px solid var(--border);+ border-radius: 8px;+ padding: 8px 14px;+ font-size: 13px;+ cursor: pointer;+}+.dash-btn:hover { background: #28283a; }+.dash-btn:disabled { opacity: 0.5; cursor: not-allowed; }+.dash-btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }+.dash-btn.primary:hover { background: #7d70ff; }+.dash-btn.danger { color: #ff8a9c; border-color: #3a2530; }+.dash-btn.danger:hover { background: #2a1820; }+.dash-input, .dash-textarea, .dash-select {+ background: #0f0f17;+ color: #eee;+ border: 1px solid var(--border);+ border-radius: 8px;+ padding: 9px 11px;+ font-size: 13px;+ font-family: inherit;+ width: 100%;+}+.dash-textarea { font-family: ui-monospace, Menlo, Consolas, monospace; min-height: 160px; }+.dash-muted { color: #888; font-size: 13px; }+.dash-err {+ background: rgba(239, 68, 68, 0.1);+ border: 1px solid #ef4444;+ color: #fca5a5;+ padding: 10px 12px;+ border-radius: 6px;+ font-size: 13px;+ margin: 8px 0;+}+.dash-ok {+ background: rgba(34, 197, 94, 0.1);+ border: 1px solid #22c55e;+ color: #86efac;+ padding: 10px 12px;+ border-radius: 6px;+ font-size: 13px;+ margin: 8px 0;+}+.dash-row {+ display: flex;+ gap: 10px;+ align-items: center;+ flex-wrap: wrap;+}+.dash-pill {+ display: inline-block;+ background: rgba(106, 92, 255, 0.12);+ border: 1px solid rgba(106, 92, 255, 0.4);+ border-radius: 999px;+ padding: 3px 10px;+ font-size: 11px;+ color: #cfc6ff;+}+.dash-mono { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12px; color: #aaa; }+.dash-list { list-style: none; padding: 0; margin: 0; }+.dash-list li {+ border-bottom: 1px solid var(--border);+ padding: 12px 0;+}+.dash-list li:last-child { border-bottom: 0; }+.dash-empty {+ text-align: center;+ color: #666;+ padding: 32px 16px;+ font-size: 14px;+}diff --git a/public/dashboard/dashboard.js b/public/dashboard/dashboard.jsindex 2570bc327..687607eb4 100644--- a/public/dashboard/dashboard.js+++ b/public/dashboard/dashboard.js@@ -302,16 +302,34 @@ function agentCard(a, onRemoved) {const skillCount = (a.skills || []).length;const wallet = a.wallet_address ? `${a.wallet_address.slice(0, 6)}…${a.wallet_address.slice(-4)}` : '';+ const agentIdEnc = encodeURIComponent(a.id);el.innerHTML = `<div class="preview" data-agent-preview></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>` : ''}+ <details class="agent-inspector" style="margin:0 0 10px;border-top:1px solid #22222e;padding-top:10px">+ <summary style="cursor:pointer;font-size:12px;color:#9a8cff;list-style:none">Inspector ▾</summary>+ <div style="display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:6px 12px;margin-top:10px;font-size:12px">+ <a href="/dashboard/memory?agent=${agentIdEnc}">Memory</a>+ <a href="/dashboard/actions?agent=${agentIdEnc}">Action log</a>+ <a href="/dashboard/strategy?agent=${agentIdEnc}">Strategy</a>+ <a href="/dashboard/usage?agent=${agentIdEnc}">LLM usage</a>+ <a href="/dashboard/voice?agent=${agentIdEnc}">Voice</a>+ <a href="/dashboard/sns?agent=${agentIdEnc}">SNS domains</a>+ <a href="/dashboard/delegation?agent=${agentIdEnc}">Delegation</a>+ <a href="/dashboard/embed-policy?agent=${agentIdEnc}">Embed policy</a>+ <a href="/dashboard/portfolio?agent=${agentIdEnc}">Portfolio & NFTs</a>+ <a href="/dashboard/sessions?agent=${agentIdEnc}">Sessions</a>+ <a href="/dashboard/storage?agent=${agentIdEnc}">Storage</a>+ <a href="/dashboard/tokens?agent=${agentIdEnc}">Tokens (Pump.fun)</a>+ </div>+ </details><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 class="btn sec" href="/agent/${agentIdEnc}">Open</a>+ <a class="btn sec" href="/agent-edit.html?id=${agentIdEnc}">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>@@ -516,6 +534,15 @@ async function renderAvatars(root) {function avatarCard(a) {const el = document.createElement('div');el.className = 'card';+ const isPrivate = a.visibility === 'private';+ const studioUrl = `/studio?avatar=${encodeURIComponent(a.id)}`;+ const viewUrl = `/avatars/${encodeURIComponent(a.id)}`;+ const embedDisabledAttr = isPrivate+ ? 'disabled title="Set this avatar to public or unlisted to embed it."'+ : '';+ const copyDisabledAttr = isPrivate+ ? 'disabled title="Private avatars have no public link. Switch to unlisted or public to share."'+ : '';el.innerHTML = `<div class="preview" data-preview></div><h3>${esc(a.name)}</h3>@@ -524,6 +551,10 @@ function avatarCard(a) {<div class="footer"><select data-vis aria-label="Visibility">${visibilityOptionsHtml(a.visibility)}</select><div class="actions">+ <a class="btn" href="${attr(studioUrl)}" title="Open this avatar in Studio to build an embeddable widget">Studio</a>+ <button class="btn" data-embed ${embedDisabledAttr}>Embed</button>+ <a class="btn sec" href="${attr(viewUrl)}" target="_blank" rel="noopener" title="Open the public viewer in a new tab">View</a>+ <button class="btn sec" data-copy-url ${copyDisabledAttr}>Copy URL</button><a class="btn sec" href="/dashboard/edit/${encodeURIComponent(a.id)}">Edit</a><button class="btn sec" data-replace>Replace GLB</button><a class="btn sec" href="/deploy?avatar=${encodeURIComponent(a.id)}" title="Mint as ERC-8004 agent">Deploy on-chain</a>@@ -537,11 +568,32 @@ function avatarCard(a) {mountAvatarWalletSection(el.querySelector('[data-wallet-host]'), a);el.querySelector('[data-vis]').addEventListener('change', async (e) => {+ const next = e.target.value;try {- await api.patchAvatar(a.id, { visibility: e.target.value });- a.visibility = e.target.value;+ await api.patchAvatar(a.id, { visibility: next });+ a.visibility = next;+ const nowPrivate = next === 'private';+ const embedBtn = el.querySelector('[data-embed]');+ const copyBtn = el.querySelector('[data-copy-url]');+ if (embedBtn) {+ embedBtn.disabled = nowPrivate;+ embedBtn.title = nowPrivate+ ? 'Set this avatar to public or unlisted to embed it.'+ : '';+ }+ if (copyBtn) {+ copyBtn.disabled = nowPrivate;+ copyBtn.title = nowPrivate+ ? 'Private avatars have no public link. Switch to unlisted or public to share.'+ : '';+ }+ const metaEl = el.querySelector('.meta');+ if (metaEl) {+ metaEl.textContent = `${a.size_bytes ? fmtSize(a.size_bytes) : ''} · ${next} · ${new Date(a.created_at).toLocaleDateString()}`;+ }} catch (err) {- alert(err.message);+ toast(err.message || 'Failed to update visibility', true);+ e.target.value = a.visibility;}});el.querySelector('[data-del]').addEventListener('click', async () => {@@ -554,6 +606,14 @@ function avatarCard(a) {}});el.querySelector('[data-replace]').addEventListener('click', () => replaceGlbFlow(a, el));+ el.querySelector('[data-embed]').addEventListener('click', (e) => {+ if (e.currentTarget.disabled) return;+ openAvatarEmbedModal(a);+ });+ el.querySelector('[data-copy-url]').addEventListener('click', (e) => {+ if (e.currentTarget.disabled) return;+ copyToClipboard(`${location.origin}/avatars/${a.id}`, e.currentTarget);+ });return el;}@@ -643,22 +703,43 @@ async function loadXPanel({ host, meterEl, bodyEl, avatar }) {const used = status.posts_used;const quota = status.quota;const remaining = Math.max(0, quota - used);- meterEl.innerHTML = `@${esc(status.username)} · <span style="color:${remaining === 0 ? '#ffb3b3' : '#9a8cff'}">${used}/${quota} posts</span>`;+ const tier = status.tier || 'free';+ const tierBadge = tier === 'pro'+ ? `<span style="background:rgba(106,92,255,0.15);color:#a78bfa;padding:2px 7px;border-radius:99px;font-size:10px;font-weight:600;margin-left:6px">PRO</span>`+ : `<a href="/pricing" style="background:rgba(255,184,77,0.15);color:#ffb84d;padding:2px 7px;border-radius:99px;font-size:10px;font-weight:600;margin-left:6px;text-decoration:none">FREE · upgrade</a>`;+ meterEl.innerHTML = `@${esc(status.username)} ${tierBadge} <span style="color:${remaining === 0 ? '#ffb3b3' : '#9a8cff'};margin-left:6px">${used}/${quota}</span>`;bodyEl.innerHTML = `- <textarea data-x-text placeholder="What should your agent tweet?" rows="3" maxlength="280" style="width:100%;font-family:inherit"></textarea>+ <div class="row" style="gap:8px;margin-bottom:8px;font-size:12px;flex-wrap:wrap;align-items:center">+ <label style="color:#888">Tone+ <select data-x-tone style="width:auto;display:inline-block;margin-left:4px">+ <option value="neutral">Neutral</option>+ <option value="hype">Hype</option>+ <option value="sarcastic">Sarcastic</option>+ <option value="technical">Technical</option>+ <option value="deadpan">Deadpan</option>+ </select>+ </label>+ <label style="color:#888"><input type="checkbox" data-x-thread style="width:auto;display:inline-block;margin:0 4px 0 8px"> Thread</label>+ <label style="color:#888"><input type="checkbox" data-x-link checked style="width:auto;display:inline-block;margin:0 4px 0 8px"> Append three.ws link</label>+ </div>+ <textarea data-x-text placeholder="What should your agent tweet? (or click Draft with AI)" rows="3" style="width:100%;font-family:inherit"></textarea><div class="row" style="justify-content:space-between;margin-top:6px;font-size:11px">- <span class="muted"><span data-x-count>0</span>/280</span>+ <span class="muted"><span data-x-count>0</span> chars</span><span class="muted">Resets ${new Date(status.month_resets_at).toLocaleDateString()}</span></div><div class="row" style="gap:8px;margin-top:10px;flex-wrap:wrap">- <button class="btn sec" data-x-draft type="button">✨ Draft with AI</button>+ <button class="btn sec" data-x-draft type="button">✨ Draft (1)</button>+ <button class="btn sec" data-x-draft3 type="button">✨ Draft 3 options</button><button class="btn" data-x-post type="button" ${remaining === 0 ? 'disabled' : ''}>Post now</button><button class="btn sec" data-x-schedule type="button" ${remaining === 0 ? 'disabled' : ''}>Schedule…</button><button class="btn sec" data-x-disconnect type="button" style="margin-left:auto;font-size:11px;padding:4px 8px;background:transparent;color:#888">Disconnect</button></div>+ <div data-x-drafts style="margin-top:10px"></div><div data-x-msg style="margin-top:10px;font-size:13px"></div>+ <div data-x-reviews style="margin-top:14px"></div><div data-x-scheduled style="margin-top:14px"></div>+ <div data-x-analytics style="margin-top:14px"></div><div data-x-triggers style="margin-top:18px;padding-top:14px;border-top:1px solid #22222e"></div>`;@@ -666,38 +747,93 @@ async function loadXPanel({ host, meterEl, bodyEl, avatar }) {const countEl = bodyEl.querySelector('[data-x-count]');const msgEl = bodyEl.querySelector('[data-x-msg]');const draftBtn = bodyEl.querySelector('[data-x-draft]');+ const draft3Btn = bodyEl.querySelector('[data-x-draft3]');const postBtn = bodyEl.querySelector('[data-x-post]');const scheduleBtn = bodyEl.querySelector('[data-x-schedule]');const disconnectBtn = bodyEl.querySelector('[data-x-disconnect]');const scheduledEl = bodyEl.querySelector('[data-x-scheduled]');const triggersEl = bodyEl.querySelector('[data-x-triggers]');+ const reviewsEl = bodyEl.querySelector('[data-x-reviews]');+ const analyticsEl = bodyEl.querySelector('[data-x-analytics]');+ const draftsEl = bodyEl.querySelector('[data-x-drafts]');+ const toneEl = bodyEl.querySelector('[data-x-tone]');+ const threadEl = bodyEl.querySelector('[data-x-thread]');+ const linkEl = bodyEl.querySelector('[data-x-link]');const setMsg = (text, color = '#9a8cff') => { msgEl.style.color = color; msgEl.innerHTML = text; };textEl.addEventListener('input', () => { countEl.textContent = textEl.value.length; });- draftBtn.addEventListener('click', async () => {- const original = draftBtn.textContent;- draftBtn.disabled = true;- draftBtn.textContent = 'Drafting…';+ function readThreadParts() {+ const raw = textEl.value;+ if (!threadEl.checked) return null;+ return raw.split(/\n---+\n|\n\n\n+/).map((s) => s.trim()).filter(Boolean);+ }++ async function generateDrafts(count) {try {const r = await fetch('/api/x/draft', {- method: 'POST',- credentials: 'include',+ method: 'POST', credentials: 'include',headers: { 'content-type': 'application/json' },- body: JSON.stringify({ agent_id: avatar.agent_id || avatar.id, prompt: textEl.value.trim() }),+ body: JSON.stringify({+ agent_id: avatar.agent_id || avatar.id,+ prompt: textEl.value.trim(),+ tone: toneEl.value,+ thread: threadEl.checked,+ count,+ }),});const data = await r.json();if (!r.ok) throw new Error(data.error_description || 'draft failed');- textEl.value = data.text;- countEl.textContent = data.text.length;- setMsg('Draft ready — review and post.');+ return data.drafts;} catch (err) {setMsg(err.message, '#ffb3b3');- } finally {- draftBtn.disabled = false;- draftBtn.textContent = original;+ return null;}- });+ }++ function renderDrafts(drafts) {+ if (!drafts || !drafts.length) { draftsEl.innerHTML = ''; return; }+ if (drafts.length === 1) {+ const d = drafts[0];+ if (d.thread_parts) textEl.value = d.thread_parts.join('\n\n\n');+ else textEl.value = d.text;+ countEl.textContent = textEl.value.length;+ draftsEl.innerHTML = '';+ setMsg('Draft ready — review and post.');+ return;+ }+ draftsEl.innerHTML = `+ <div class="muted" style="font-size:11px;text-transform:uppercase;letter-spacing:0.07em;margin-bottom:6px">Pick one</div>+ ${drafts.map((d, i) => {+ const display = d.thread_parts ? d.thread_parts.join('\n\n— —\n\n') : d.text;+ return `<div data-draft-idx="${i}" style="padding:10px 12px;background:#0f0f17;border:1px solid #22222e;border-radius:8px;margin-bottom:6px;cursor:pointer;font-size:13px;color:#ccc;white-space:pre-wrap">${esc(display)}</div>`;+ }).join('')}+ `;+ draftsEl.querySelectorAll('[data-draft-idx]').forEach((el) => {+ el.addEventListener('click', () => {+ const d = drafts[Number(el.getAttribute('data-draft-idx'))];+ if (d.thread_parts) textEl.value = d.thread_parts.join('\n\n\n');+ else textEl.value = d.text;+ countEl.textContent = textEl.value.length;+ draftsEl.innerHTML = '';+ setMsg('Selected.');+ });+ });+ }++ async function doDraft(count) {+ const btn = count === 1 ? draftBtn : draft3Btn;+ const original = btn.textContent;+ btn.disabled = true;+ btn.textContent = 'Drafting…';+ const drafts = await generateDrafts(count);+ btn.disabled = false;+ btn.textContent = original;+ if (drafts) renderDrafts(drafts);+ }++ draftBtn.addEventListener('click', () => doDraft(1));+ draft3Btn.addEventListener('click', () => doDraft(3));postBtn.addEventListener('click', async () => {const text = textEl.value.trim();@@ -705,15 +841,24 @@ async function loadXPanel({ host, meterEl, bodyEl, avatar }) {postBtn.disabled = true;setMsg('Posting…');try {+ const parts = readThreadParts();+ const body = parts && parts.length > 1+ ? { thread_parts: parts, agent_id: avatar.agent_id || avatar.id, append_link: linkEl.checked }+ : { text, agent_id: avatar.agent_id || avatar.id, append_link: linkEl.checked };const r = await fetch('/api/x/post', {- method: 'POST',- credentials: 'include',+ method: 'POST', credentials: 'include',headers: { 'content-type': 'application/json' },- body: JSON.stringify({ text, agent_id: avatar.agent_id || avatar.id }),+ body: JSON.stringify(body),});const data = await r.json();- if (!r.ok) throw new Error(data.error_description || 'post failed');- setMsg(`Posted: <a href="${data.url}" target="_blank" rel="noopener">${data.url}</a>`);+ if (!r.ok) {+ if (data.upgrade_url) {+ setMsg(`${data.error_description} <a href="${data.upgrade_url}">Upgrade to Pro</a>`, '#ffb3b3');+ return;+ }+ throw new Error(data.error_description || 'post failed');+ }+ setMsg(`Posted: <a href="${data.url}" target="_blank" rel="noopener">${data.url}</a>${data.thread ? ` (${data.thread.length}-tweet thread)` : ''}`);textEl.value = '';countEl.textContent = 0;loadXPanel({ host, meterEl, bodyEl, avatar });@@ -734,8 +879,7 @@ async function loadXPanel({ host, meterEl, bodyEl, avatar }) {setMsg('Scheduling…');try {const r = await fetch('/api/x/schedule', {- method: 'POST',- credentials: 'include',+ method: 'POST', credentials: 'include',headers: { 'content-type': 'application/json' },body: JSON.stringify({ text, scheduled_at: when.toISOString(), agent_id: avatar.agent_id || avatar.id }),});@@ -3685,6 +3829,152 @@ function makeIframeSnippet(w, pageUrl, width, height) {return `<iframe src="${pageUrl}" width="${width}" height="${height}" style="border:0;border-radius:12px;max-width:100%" allow="autoplay; xr-spatial-tracking; clipboard-write" title="${title}" loading="lazy"></iframe>`;}+// ── Avatar embed modal ──────────────────────────────────────────────────────+// Builds a copy-paste <iframe> for /a-embed.html?avatar=<id> with size presets,+// background choice, and live preview. Mirrors openShareModal() for parity.+function openAvatarEmbedModal(avatar) {+ const SIZES = [+ { label: 'Square', width: 480, height: 480 },+ { label: 'Portrait', width: 360, height: 540 },+ { label: 'Banner', width: 1200, height: 400 },+ { label: 'Custom', width: 0, height: 0 },+ ];+ let active = 0;+ let dim = { ...SIZES[active] };+ const opts = { bg: 'transparent', name: true, openLink: true };++ const buildEmbedUrl = () => {+ const u = new URL('/a-embed.html', location.origin);+ u.searchParams.set('avatar', avatar.id);+ if (opts.bg !== 'transparent') u.searchParams.set('bg', opts.bg);+ if (!opts.name) u.searchParams.set('name', '0');+ if (!opts.openLink) u.searchParams.set('open-link', '0');+ return u.toString();+ };++ const overlay = document.createElement('div');+ overlay.className = 'modal-overlay';+ overlay.innerHTML = `+ <div class="modal" role="dialog" aria-label="Embed avatar">+ <h2>Embed "${esc(avatar.name || 'avatar')}"</h2>+ <p class="sub">Drop this iframe into any site to render the avatar inline.</p>+ <div class="size-presets" role="tablist">+ ${SIZES.map((s, i) => `<button type="button" data-i="${i}" class="${i === active ? 'active' : ''}" role="tab" aria-selected="${i === active}">${esc(s.label)}${s.width ? ` (${s.width}×${s.height})` : ''}</button>`).join('')}+ </div>+ <div class="size-inputs">+ <label class="muted" style="font-size:12px">W <input id="a-em-w" type="number" min="120" max="2000" value="${dim.width}"></label>+ <label class="muted" style="font-size:12px">H <input id="a-em-h" type="number" min="120" max="2000" value="${dim.height}"></label>+ </div>+ <div class="size-presets" style="margin-bottom:14px" role="tablist" aria-label="Background">+ <button type="button" data-bg="transparent" class="active">Transparent</button>+ <button type="button" data-bg="dark">Dark</button>+ <button type="button" data-bg="light">Light</button>+ </div>+ <div class="row" style="gap:14px; flex-wrap:wrap; margin-bottom:14px; font-size:12px; color:#bbb">+ <label class="row" style="gap:6px"><input type="checkbox" id="a-em-name" checked> Name plate</label>+ <label class="row" style="gap:6px"><input type="checkbox" id="a-em-link" checked> "Open ↗" link</label>+ </div>+ <div style="background:#0f0f17; border:1px solid var(--border); border-radius:10px; padding:12px; margin-bottom:12px">+ <div class="muted" style="font-size:11px; margin-bottom:8px">Live preview (scaled to fit)</div>+ <div id="a-em-preview" style="display:grid; place-items:center; min-height:200px; max-height:340px; overflow:hidden"></div>+ </div>+ <div>+ <div class="row" style="justify-content:space-between; margin-bottom:4px"><strong style="font-size:12px">Iframe</strong><button class="btn sec" id="a-em-copy" type="button">Copy</button></div>+ <pre id="a-em-snip" style="margin:0"></pre>+ </div>+ <div class="row" style="justify-content:space-between; margin-top:14px">+ <a class="muted" style="font-size:12px" href="/avatars/${encodeURIComponent(avatar.id)}" target="_blank" rel="noopener">Open public page ↗</a>+ <button class="btn sec" id="a-em-close" type="button">Close</button>+ </div>+ </div>+ `;+ document.body.appendChild(overlay);+ requestAnimationFrame(() => overlay.classList.add('open'));++ const wInput = overlay.querySelector('#a-em-w');+ const hInput = overlay.querySelector('#a-em-h');+ const snipEl = overlay.querySelector('#a-em-snip');+ const previewEl = overlay.querySelector('#a-em-preview');+ const sizeBtns = overlay.querySelectorAll('.size-presets [data-i]');+ const bgBtns = overlay.querySelectorAll('.size-presets [data-bg]');++ const safeName = (avatar.name || 'avatar').replace(/"/g, '"');+ const refresh = () => {+ const url = buildEmbedUrl();+ snipEl.textContent = `<iframe src="${url}" width="${dim.width}" height="${dim.height}" style="border:0;border-radius:12px;max-width:100%" allow="xr-spatial-tracking" title="${safeName}" loading="lazy"></iframe>`;+ const maxW = 320,+ maxH = 320;+ const scale = Math.min(maxW / dim.width, maxH / dim.height, 1);+ previewEl.innerHTML = `<iframe src="${attr(url)}" style="width:${dim.width}px; height:${dim.height}px; border:0; transform:scale(${scale}); transform-origin:center" title="Preview" allow="xr-spatial-tracking"></iframe>`;+ previewEl.style.width = `${dim.width * scale}px`;+ previewEl.style.height = `${dim.height * scale}px`;+ };+ const setPreset = (i) => {+ active = i;+ sizeBtns.forEach((b, j) => {+ b.classList.toggle('active', i === j);+ b.setAttribute('aria-selected', i === j ? 'true' : 'false');+ });+ if (SIZES[i].width) {+ dim = { width: SIZES[i].width, height: SIZES[i].height };+ wInput.value = dim.width;+ hInput.value = dim.height;+ }+ refresh();+ };+ sizeBtns.forEach((b) => b.addEventListener('click', () => setPreset(Number(b.dataset.i))));+ bgBtns.forEach((b) =>+ b.addEventListener('click', () => {+ opts.bg = b.dataset.bg;+ bgBtns.forEach((x) => x.classList.toggle('active', x === b));+ refresh();+ }),+ );+ const onDimChange = () => {+ dim = {+ width: clampInt(wInput.value, 120, 2000, 480),+ height: clampInt(hInput.value, 120, 2000, 480),+ };+ active = SIZES.length - 1;+ sizeBtns.forEach((b, j) => {+ b.classList.toggle('active', j === active);+ b.setAttribute('aria-selected', j === active ? 'true' : 'false');+ });+ refresh();+ };+ wInput.addEventListener('input', onDimChange);+ hInput.addEventListener('input', onDimChange);+ overlay.querySelector('#a-em-name').addEventListener('change', (e) => {+ opts.name = e.target.checked;+ refresh();+ });+ overlay.querySelector('#a-em-link').addEventListener('change', (e) => {+ opts.openLink = e.target.checked;+ refresh();+ });++ const close = () => {+ overlay.classList.remove('open');+ setTimeout(() => {+ overlay.remove();+ document.removeEventListener('keydown', onKey);+ }, 200);+ };+ const onKey = (e) => {+ if (e.key === 'Escape') close();+ };+ document.addEventListener('keydown', onKey);+ overlay.addEventListener('click', (e) => {+ if (e.target === overlay) close();+ });+ overlay.querySelector('#a-em-close').addEventListener('click', close);+ overlay+ .querySelector('#a-em-copy')+ .addEventListener('click', (e) => copyToClipboard(snipEl.textContent, e.currentTarget));++ refresh();+}+// ── shared widget UI helpers ────────────────────────────────────────────────async function copyToClipboard(text, btn) {try {diff --git a/public/dashboard/delegation.html b/public/dashboard/delegation.htmlnew file mode 100644index 000000000..b4bbf06ae--- /dev/null+++ b/public/dashboard/delegation.html@@ -0,0 +1,141 @@+<!doctype html>+<html lang="en">+ <head>+ <meta charset="utf-8" />+ <meta name="viewport" content="width=device-width,initial-scale=1" />+ <title>Agent Delegation · three.ws</title>+ <link rel="stylesheet" href="/dashboard/_dash-shell.css" />+ </head>+ <body>+ <div class="dash-shell">+ <a class="dash-back" href="/dashboard/agents">← Back to dashboard</a>+ <h1 class="dash-title">Agent Delegation</h1>+ <p class="dash-sub">+ Send a message from one of your agents to any other agent. Calls+ <code class="dash-mono">/api/agent-delegate</code>. Nested calls are rejected — depth is+ capped at 1 to prevent recursion.+ </p>++ <div id="picker"></div>+ <div id="status"></div>+ <div id="content"></div>+ </div>++ <script type="module">+ import { mountAgentPicker } from '/dashboard/_agent-picker.js';++ const statusEl = document.getElementById('status');+ const contentEl = document.getElementById('content');+ let allAgents = [];++ function showStatus(msg, kind = '') {+ statusEl.innerHTML = msg+ ? `<div class="${kind === 'err' ? 'dash-err' : 'dash-ok'}">${escapeHtml(msg)}</div>`+ : '';+ }+ function escapeHtml(s) {+ return String(s == null ? '' : s).replace(+ /[&<>"']/g,+ (c) => ({ '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' })[c],+ );+ }++ async function callDelegate(fromAgentId, toAgentId, message) {+ const r = await fetch('/api/agent-delegate', {+ method: 'POST',+ credentials: 'include',+ headers: { 'content-type': 'application/json' },+ body: JSON.stringify({ fromAgentId, toAgentId, message }),+ });+ if (!r.ok) {+ const err = await r.json().catch(() => ({}));+ throw new Error(err.error_description || `HTTP ${r.status}`);+ }+ return r.json();+ }++ async function fetchAllAgents() {+ const r = await fetch('/api/agents', { credentials: 'include' });+ if (!r.ok) return [];+ const data = await r.json();+ return data.agents || [];+ }++ function render(fromAgentId) {+ contentEl.innerHTML = `+ <div class="dash-card">+ <h2>Send message</h2>+ <form id="del-form" style="display:grid;gap:12px">+ <label>+ <div class="dash-muted" style="margin-bottom:4px">From (this agent)</div>+ <input class="dash-input" readonly value="${escapeHtml(fromAgentId)}" />+ </label>+ <label>+ <div class="dash-muted" style="margin-bottom:4px">To (target agent)</div>+ <select class="dash-select" name="to" required>+ <option value="">Pick a target agent…</option>+ ${allAgents+ .filter((a) => a.id !== fromAgentId)+ .map(+ (a) =>+ `<option value="${escapeHtml(a.id)}">${escapeHtml(a.name || 'Agent')} · ${escapeHtml(a.id.slice(0, 8))}…</option>`,+ )+ .join('')}+ </select>+ <div class="dash-muted" style="margin-top:4px;font-size:11px">+ Pasting any UUID works too — targets need not belong to you.+ </div>+ <input class="dash-input" name="to_manual" placeholder="…or paste any agent UUID" style="margin-top:6px" />+ </label>+ <label>+ <div class="dash-muted" style="margin-bottom:4px">Message</div>+ <textarea class="dash-textarea" name="message" required maxlength="8000" placeholder="What should the target agent respond to?"></textarea>+ </label>+ <div class="dash-row">+ <button class="dash-btn primary" type="submit">Send</button>+ <span class="dash-muted" id="del-status"></span>+ </div>+ </form>+ </div>+ <div class="dash-card" id="reply-card" style="display:none">+ <h2>Reply</h2>+ <div id="reply-body" style="white-space:pre-wrap;color:#ddd"></div>+ </div>+ `;++ document.getElementById('del-form').addEventListener('submit', async (e) => {+ e.preventDefault();+ const fd = new FormData(e.target);+ const toAgentId = String(fd.get('to_manual') || fd.get('to') || '').trim();+ const message = String(fd.get('message') || '').trim();+ if (!toAgentId || !message) return;+ const replyCard = document.getElementById('reply-card');+ const replyBody = document.getElementById('reply-body');+ const delStatus = document.getElementById('del-status');+ delStatus.textContent = 'Sending…';+ replyCard.style.display = 'none';+ try {+ const { response } = await callDelegate(fromAgentId, toAgentId, message);+ replyBody.textContent = response || '(empty response)';+ replyCard.style.display = 'block';+ delStatus.textContent = '';+ } catch (err) {+ delStatus.textContent = '';+ showStatus(err.message || 'Delegate failed', 'err');+ }+ });+ }++ async function refresh(agentId) {+ contentEl.innerHTML = '<div class="dash-empty">Loading agents…</div>';+ if (!allAgents.length) allAgents = await fetchAllAgents();+ render(agentId);+ }++ mountAgentPicker({+ host: document.getElementById('picker'),+ onPick: (agentId) => refresh(agentId),+ });+ </script>+ </body>+</html>diff --git a/public/dashboard/index.html b/public/dashboard/index.htmlindex e8f8e7a9b..2a74dfe64 100644--- a/public/dashboard/index.html+++ b/public/dashboard/index.html@@ -5,12 +5,7 @@<meta name="viewport" content="width=device-width,initial-scale=1" /><title>Dashboard · three.ws</title><link rel="icon" href="/favicon.ico" />- <link rel="preconnect" href="https://fonts.googleapis.com" />- <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />- <link- href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Space+Grotesk:wght@500;600;700&display=swap"- rel="stylesheet"- />+ <link rel="stylesheet" href="/fonts/fonts.css" /><link rel="stylesheet" href="/footer.css" /><style>:root {@@ -1169,10 +1164,21 @@<a href="/dashboard/revenue" data-tab="revenue">Revenue</a><a href="/dashboard/earnings" data-tab="earnings">Earnings</a><a href="/dashboard/account" data-tab="account">Account</a>- <a href="/dashboard/portfolio">Portfolio</a>+ <a href="/dashboard/portfolio">Portfolio & NFTs</a><a href="/dashboard/wallets">Wallets</a><a href="/vanity-wallet">Vanity wallet ✦</a><a href="/eth-vanity">ETH vanity (CREATE2) ✦</a>+ <a href="/dashboard/memory">Memory</a>+ <a href="/dashboard/strategy">Strategy</a>+ <a href="/dashboard/voice">Voice</a>+ <a href="/dashboard/sns">SNS domains</a>+ <a href="/dashboard/delegation">Delegation</a>+ <a href="/dashboard/tokens">Tokens (Pump.fun)</a>+ <a href="/dashboard/actions">Action log</a>+ <a href="/dashboard/usage">LLM usage</a>+ <a href="/dashboard/embed-policy">Embed policy</a>+ <a href="/dashboard/sessions">Sessions</a>+ <a href="/dashboard/storage">Storage</a><a href="/dashboard/agent-pumpfun">Agent · Pump.fun</a><a href="/strategy-lab">Strategy lab</a><a href="/reputation">Reputation</a>diff --git a/public/dashboard/memory.html b/public/dashboard/memory.htmlnew file mode 100644index 000000000..d978d177a--- /dev/null+++ b/public/dashboard/memory.html@@ -0,0 +1,204 @@+<!doctype html>+<html lang="en">+ <head>+ <meta charset="utf-8" />+ <meta name="viewport" content="width=device-width,initial-scale=1" />+ <title>Agent Memory · three.ws</title>+ <link rel="stylesheet" href="/dashboard/_dash-shell.css" />+ </head>+ <body>+ <div class="dash-shell">+ <a class="dash-back" href="/dashboard/agents">← Back to dashboard</a>+ <h1 class="dash-title">Agent Memory</h1>+ <p class="dash-sub">+ Browse, prune, and add long-term memories your agent uses for context. Memories sync via+ <code class="dash-mono">/api/agent-memory</code>.+ </p>++ <div id="picker"></div>+ <div id="status"></div>+ <div id="content"></div>+ </div>++ <script type="module">+ import { mountAgentPicker } from '/dashboard/_agent-picker.js';++ const TYPES = ['user', 'feedback', 'project', 'reference'];++ const $ = (id) => document.getElementById(id);+ const statusEl = $('status');+ const contentEl = $('content');++ function showStatus(msg, kind = '') {+ statusEl.innerHTML = msg+ ? `<div class="${kind === 'err' ? 'dash-err' : 'dash-ok'}">${escapeHtml(msg)}</div>`+ : '';+ }++ function escapeHtml(s) {+ return String(s == null ? '' : s).replace(+ /[&<>"']/g,+ (c) => ({ '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' })[c],+ );+ }++ function fmtTime(ms) {+ if (!ms) return '';+ const d = new Date(ms);+ return d.toLocaleString();+ }++ async function loadMemories(agentId) {+ const r = await fetch(+ `/api/agent-memory?agentId=${encodeURIComponent(agentId)}&limit=500`,+ { credentials: 'include' },+ );+ if (!r.ok) throw new Error(`HTTP ${r.status}`);+ const data = await r.json();+ return data.entries || [];+ }++ async function deleteMemory(id) {+ const r = await fetch(`/api/agent-memory/${encodeURIComponent(id)}`, {+ method: 'DELETE',+ credentials: 'include',+ });+ if (!r.ok) throw new Error(`HTTP ${r.status}`);+ return r.json();+ }++ async function createMemory(agentId, entry) {+ const r = await fetch('/api/agent-memory', {+ method: 'POST',+ credentials: 'include',+ headers: { 'content-type': 'application/json' },+ body: JSON.stringify({ agentId, entry }),+ });+ if (!r.ok) {+ const err = await r.json().catch(() => ({}));+ throw new Error(err.error_description || `HTTP ${r.status}`);+ }+ return r.json();+ }++ function renderList(agentId, entries) {+ const grouped = {};+ for (const t of TYPES) grouped[t] = [];+ for (const e of entries) (grouped[e.type] || (grouped[e.type] = [])).push(e);++ const sections = Object.entries(grouped)+ .filter(([, arr]) => arr.length)+ .map(+ ([type, arr]) => `+ <div class="dash-card">+ <h2>${escapeHtml(type)} <span class="dash-muted" style="text-transform:none;letter-spacing:0">· ${arr.length}</span></h2>+ <ul class="dash-list">+ ${arr+ .map(+ (m) => `+ <li>+ <div style="display:flex;justify-content:space-between;gap:14px;align-items:flex-start">+ <div style="flex:1;min-width:0">+ <div style="white-space:pre-wrap;word-break:break-word;color:#ddd;font-size:14px">${escapeHtml(m.content)}</div>+ <div class="dash-muted" style="margin-top:6px;font-size:11px">+ ${escapeHtml(fmtTime(m.createdAt))}+ ${(m.tags || []).length ? ' · ' + m.tags.map((t) => `<span class="dash-pill">${escapeHtml(t)}</span>`).join(' ') : ''}+ ${m.salience != null ? ` · salience ${Number(m.salience).toFixed(2)}` : ''}+ </div>+ </div>+ <button class="dash-btn danger" data-del="${escapeHtml(m.id)}">Forget</button>+ </div>+ </li>+ `,+ )+ .join('')}+ </ul>+ </div>+ `,+ )+ .join('');++ contentEl.innerHTML = `+ <div class="dash-card">+ <h2>Add memory</h2>+ <form id="mem-form" style="display:grid;gap:10px">+ <label>+ <div class="dash-muted" style="margin-bottom:4px">Type</div>+ <select class="dash-select" name="type">+ ${TYPES.map((t) => `<option value="${t}">${t}</option>`).join('')}+ </select>+ </label>+ <label>+ <div class="dash-muted" style="margin-bottom:4px">Content</div>+ <textarea class="dash-textarea" name="content" required maxlength="4000" placeholder="Anything the agent should remember…"></textarea>+ </label>+ <label>+ <div class="dash-muted" style="margin-bottom:4px">Tags (comma-separated)</div>+ <input class="dash-input" name="tags" placeholder="trading, defi" />+ </label>+ <div class="dash-row">+ <button class="dash-btn primary" type="submit">Save memory</button>+ <span class="dash-muted" id="mem-form-status"></span>+ </div>+ </form>+ </div>+ ${sections || '<div class="dash-empty">No memories yet for this agent.</div>'}+ `;++ $('mem-form').addEventListener('submit', async (e) => {+ e.preventDefault();+ const fd = new FormData(e.target);+ const tags = String(fd.get('tags') || '')+ .split(',')+ .map((t) => t.trim())+ .filter(Boolean);+ const entry = {+ type: String(fd.get('type')),+ content: String(fd.get('content')),+ tags,+ createdAt: Date.now(),+ updatedAt: Date.now(),+ };+ const formStatus = $('mem-form-status');+ formStatus.textContent = 'Saving…';+ try {+ await createMemory(agentId, entry);+ formStatus.textContent = '';+ await refresh(agentId);+ } catch (err) {+ formStatus.textContent = err.message || 'Save failed';+ }+ });++ contentEl.querySelectorAll('[data-del]').forEach((btn) => {+ btn.addEventListener('click', async () => {+ if (!confirm('Forget this memory? This cannot be undone.')) return;+ btn.disabled = true;+ try {+ await deleteMemory(btn.dataset.del);+ await refresh(agentId);+ } catch (err) {+ showStatus(err.message || 'Delete failed', 'err');+ btn.disabled = false;+ }+ });+ });+ }++ async function refresh(agentId) {+ contentEl.innerHTML = '<div class="dash-empty">Loading memories…</div>';+ try {+ const entries = await loadMemories(agentId);+ renderList(agentId, entries);+ } catch (e) {+ showStatus(e.message || 'Failed to load memories', 'err');+ }+ }++ mountAgentPicker({+ host: document.getElementById('picker'),+ onPick: (agentId) => refresh(agentId),+ });+ </script>+ </body>+</html>diff --git a/public/dashboard/sns.html b/public/dashboard/sns.htmlnew file mode 100644index 000000000..78b09a28a--- /dev/null+++ b/public/dashboard/sns.html@@ -0,0 +1,182 @@+<!doctype html>+<html lang="en">+ <head>+ <meta charset="utf-8" />+ <meta name="viewport" content="width=device-width,initial-scale=1" />+ <title>SNS Domains · three.ws</title>+ <link rel="stylesheet" href="/dashboard/_dash-shell.css" />+ </head>+ <body>+ <div class="dash-shell">+ <a class="dash-back" href="/dashboard/agents">← Back to dashboard</a>+ <h1 class="dash-title">SNS Domains</h1>+ <p class="dash-sub">+ Attach a Solana Name Service <code class="dash-mono">.sol</code> domain as your agent's+ readable id. Domains owned by either the agent's wallet or any wallet linked to your account+ are eligible.+ </p>++ <div id="picker"></div>+ <div id="status"></div>+ <div id="content"></div>+ </div>++ <script type="module">+ import { mountAgentPicker } from '/dashboard/_agent-picker.js';++ const statusEl = document.getElementById('status');+ const contentEl = document.getElementById('content');++ function showStatus(msg, kind = '') {+ statusEl.innerHTML = msg+ ? `<div class="${kind === 'err' ? 'dash-err' : 'dash-ok'}">${escapeHtml(msg)}</div>`+ : '';+ }+ function escapeHtml(s) {+ return String(s == null ? '' : s).replace(+ /[&<>"']/g,+ (c) => ({ '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' })[c],+ );+ }++ async function getSns(agentId) {+ const r = await fetch(`/api/agents/${encodeURIComponent(agentId)}/sns`, {+ credentials: 'include',+ });+ if (!r.ok) {+ const err = await r.json().catch(() => ({}));+ throw new Error(err.error_description || `HTTP ${r.status}`);+ }+ return r.json();+ }++ async function attach(agentId, domain) {+ const r = await fetch(`/api/agents/${encodeURIComponent(agentId)}/sns`, {+ method: 'POST',+ credentials: 'include',+ headers: { 'content-type': 'application/json' },+ body: JSON.stringify({ domain }),+ });+ if (!r.ok) {+ const err = await r.json().catch(() => ({}));+ throw new Error(err.error_description || `HTTP ${r.status}`);+ }+ return r.json();+ }++ async function detach(agentId) {+ const r = await fetch(`/api/agents/${encodeURIComponent(agentId)}/sns`, {+ method: 'DELETE',+ credentials: 'include',+ });+ if (!r.ok) {+ const err = await r.json().catch(() => ({}));+ throw new Error(err.error_description || `HTTP ${r.status}`);+ }+ return r.json();+ }++ function render(agentId, data) {+ const current = data.sns_domain;+ const domains = data.domains || [];+ const favorite = data.favorite;++ contentEl.innerHTML = `+ <div class="dash-card">+ <h2>Current SNS id</h2>+ <div class="dash-row">+ ${+ current+ ? `<span class="dash-pill" style="font-size:13px">${escapeHtml(current)}.sol</span>+ ${data.sns_owner_wallet ? `<span class="dash-muted">owned by <span class="dash-mono">${escapeHtml(data.sns_owner_wallet)}</span></span>` : ''}+ <button class="dash-btn danger" id="detach-btn">Detach</button>`+ : '<span class="dash-muted">None attached.</span>'+ }+ </div>+ <div class="dash-muted" style="margin-top:10px">+ Agent wallet: <span class="dash-mono">${escapeHtml(data.address || '')}</span>+ </div>+ </div>++ <div class="dash-card">+ <h2>Owned domains</h2>+ ${+ !data.upstream_ok+ ? '<div class="dash-err">SNS API unreachable — retry in a moment.</div>'+ : ''+ }+ ${+ domains.length+ ? `<ul class="dash-list">+ ${domains+ .map(+ (d) => `<li class="dash-row" style="justify-content:space-between">+ <div>+ <span class="dash-mono" style="font-size:14px">${escapeHtml(d)}.sol</span>+ ${favorite === d ? ' <span class="dash-pill">favorite</span>' : ''}+ ${current === d ? ' <span class="dash-pill">attached</span>' : ''}+ </div>+ ${current === d ? '' : `<button class="dash-btn primary" data-attach="${escapeHtml(d)}">Use as agent id</button>`}+ </li>`,+ )+ .join('')}+ </ul>`+ : '<div class="dash-empty">No .sol domains found for this agent\'s wallet or your linked Solana wallets.</div>'+ }+ </div>++ <div class="dash-card">+ <h2>Register a new domain</h2>+ <p class="dash-muted">Search and buy a fresh .sol on the official SNS site, then return here to attach it.</p>+ <a class="dash-btn primary" href="${escapeHtml(data.register_url || 'https://www.sns.id/?search=')}" target="_blank" rel="noopener">Open sns.id ↗</a>+ </div>+ `;++ const detachBtn = document.getElementById('detach-btn');+ if (detachBtn) {+ detachBtn.addEventListener('click', async () => {+ if (!confirm(`Detach ${current}.sol?`)) return;+ detachBtn.disabled = true;+ try {+ await detach(agentId);+ showStatus('Detached.', 'ok');+ await refresh(agentId);+ } catch (e) {+ showStatus(e.message || 'Detach failed', 'err');+ detachBtn.disabled = false;+ }+ });+ }+ contentEl.querySelectorAll('[data-attach]').forEach((btn) => {+ btn.addEventListener('click', async () => {+ btn.disabled = true;+ try {+ await attach(agentId, btn.dataset.attach);+ showStatus(`Attached ${btn.dataset.attach}.sol`, 'ok');+ await refresh(agentId);+ } catch (e) {+ showStatus(e.message || 'Attach failed', 'err');+ btn.disabled = false;+ }+ });+ });+ }++ async function refresh(agentId) {+ contentEl.innerHTML = '<div class="dash-empty">Loading SNS data…</div>';+ try {+ const { data } = await getSns(agentId);+ render(agentId, data);+ } catch (e) {+ showStatus(e.message || 'Failed to load', 'err');+ contentEl.innerHTML = '';+ }+ }++ mountAgentPicker({+ host: document.getElementById('picker'),+ onPick: (agentId) => refresh(agentId),+ });+ </script>+ </body>+</html>diff --git a/public/dashboard/strategy.html b/public/dashboard/strategy.htmlnew file mode 100644index 000000000..a45b93918--- /dev/null+++ b/public/dashboard/strategy.html@@ -0,0 +1,136 @@+<!doctype html>+<html lang="en">+ <head>+ <meta charset="utf-8" />+ <meta name="viewport" content="width=device-width,initial-scale=1" />+ <title>Agent Strategy · three.ws</title>+ <link rel="stylesheet" href="/dashboard/_dash-shell.css" />+ </head>+ <body>+ <div class="dash-shell">+ <a class="dash-back" href="/dashboard/agents">← Back to dashboard</a>+ <h1 class="dash-title">Agent Strategy</h1>+ <p class="dash-sub">+ Freeform JSON your agent's skills can read at runtime. Stored on+ <code class="dash-mono">agent_identities.meta.strategy</code>. For typed DCA rules see+ <a href="/strategy-lab">Strategy lab</a>.+ </p>++ <div id="picker"></div>+ <div id="status"></div>+ <div id="content"></div>+ </div>++ <script type="module">+ import { mountAgentPicker } from '/dashboard/_agent-picker.js';++ const statusEl = document.getElementById('status');+ const contentEl = document.getElementById('content');++ function showStatus(msg, kind = '') {+ statusEl.innerHTML = msg+ ? `<div class="${kind === 'err' ? 'dash-err' : 'dash-ok'}">${escapeHtml(msg)}</div>`+ : '';+ }+ function escapeHtml(s) {+ return String(s == null ? '' : s).replace(+ /[&<>"']/g,+ (c) => ({ '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' })[c],+ );+ }++ async function loadStrategy(agentId) {+ const r = await fetch(`/api/agent-strategy?id=${encodeURIComponent(agentId)}`, {+ credentials: 'include',+ });+ if (r.status === 404) return null;+ if (!r.ok) throw new Error(`HTTP ${r.status}`);+ const data = await r.json();+ return data?.data?.strategy ?? null;+ }++ async function saveStrategy(agentId, strategy) {+ const r = await fetch(`/api/agent-strategy?id=${encodeURIComponent(agentId)}`, {+ method: 'POST',+ credentials: 'include',+ headers: { 'content-type': 'application/json' },+ body: JSON.stringify({ strategy }),+ });+ if (!r.ok) {+ const err = await r.json().catch(() => ({}));+ throw new Error(err.error_description || `HTTP ${r.status}`);+ }+ return r.json();+ }++ function render(agentId, current) {+ const initial =+ current === null+ ? '{\n "objective": "trade memes profitably",\n "max_position_sol": 0.5,\n "stop_loss_pct": 20\n}'+ : JSON.stringify(current, null, 2);++ contentEl.innerHTML = `+ <div class="dash-card">+ <h2>Strategy JSON</h2>+ <textarea id="strategy-input" class="dash-textarea" style="min-height:340px" spellcheck="false">${escapeHtml(initial)}</textarea>+ <div class="dash-row" style="margin-top:12px">+ <button class="dash-btn primary" id="save-btn">Save strategy</button>+ <button class="dash-btn" id="format-btn">Reformat JSON</button>+ <span class="dash-muted" id="form-status"></span>+ </div>+ <p class="dash-muted" style="margin-top:10px">+ Skills receive this object from+ <code class="dash-mono">getStrategy()</code>. Empty <code class="dash-mono">{}</code> is valid.+ </p>+ </div>+ `;++ const input = document.getElementById('strategy-input');+ const formStatus = document.getElementById('form-status');++ document.getElementById('format-btn').addEventListener('click', () => {+ try {+ input.value = JSON.stringify(JSON.parse(input.value), null, 2);+ formStatus.textContent = '';+ } catch (e) {+ formStatus.textContent = 'Invalid JSON: ' + e.message;+ }+ });++ document.getElementById('save-btn').addEventListener('click', async () => {+ let parsed;+ try {+ parsed = JSON.parse(input.value);+ } catch (e) {+ formStatus.textContent = 'Invalid JSON: ' + e.message;+ return;+ }+ formStatus.textContent = 'Saving…';+ try {+ await saveStrategy(agentId, parsed);+ formStatus.textContent = 'Saved.';+ showStatus('Strategy saved.', 'ok');+ } catch (e) {+ formStatus.textContent = '';+ showStatus(e.message || 'Save failed', 'err');+ }+ });+ }++ async function refresh(agentId) {+ contentEl.innerHTML = '<div class="dash-empty">Loading strategy…</div>';+ try {+ const current = await loadStrategy(agentId);+ render(agentId, current);+ } catch (e) {+ showStatus(e.message || 'Failed to load', 'err');+ }+ }++ mountAgentPicker({+ host: document.getElementById('picker'),+ onPick: (agentId) => refresh(agentId),+ });+ </script>+ </body>+</html>diff --git a/public/dashboard/tokens.html b/public/dashboard/tokens.htmlnew file mode 100644index 000000000..2ddd3bcd9--- /dev/null+++ b/public/dashboard/tokens.html@@ -0,0 +1,161 @@+<!doctype html>+<html lang="en">+ <head>+ <meta charset="utf-8" />+ <meta name="viewport" content="width=device-width,initial-scale=1" />+ <title>Agent Tokens · three.ws</title>+ <link rel="stylesheet" href="/dashboard/_dash-shell.css" />+ </head>+ <body>+ <div class="dash-shell">+ <a class="dash-back" href="/dashboard/agents">← Back to dashboard</a>+ <h1 class="dash-title">Agent Tokens</h1>+ <p class="dash-sub">+ If your agent has launched a Pump.fun token, the live state lives here. Launch a new one via+ <a href="/dashboard/agent-pumpfun">Agent · Pump.fun</a> or from the agent's home page.+ </p>++ <div id="picker"></div>+ <div id="status"></div>+ <div id="content"></div>+ </div>++ <script type="module">+ import { mountAgentPicker } from '/dashboard/_agent-picker.js';++ const statusEl = document.getElementById('status');+ const contentEl = document.getElementById('content');++ function showStatus(msg, kind = '') {+ statusEl.innerHTML = msg+ ? `<div class="${kind === 'err' ? 'dash-err' : 'dash-ok'}">${escapeHtml(msg)}</div>`+ : '';+ }+ function escapeHtml(s) {+ return String(s == null ? '' : s).replace(+ /[&<>"']/g,+ (c) => ({ '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' })[c],+ );+ }++ async function getAgent(agentId) {+ const r = await fetch(`/api/agents/${encodeURIComponent(agentId)}`, {+ credentials: 'include',+ });+ if (!r.ok) throw new Error(`HTTP ${r.status}`);+ return (await r.json()).agent;+ }++ // Pump.fun Frontend API for live state. Public, no auth.+ async function fetchPumpData(mint) {+ try {+ const r = await fetch(`https://frontend-api-v3.pump.fun/coins/${mint}`);+ if (!r.ok) return null;+ return r.json();+ } catch {+ return null;+ }+ }++ async function render(agentId) {+ contentEl.innerHTML = '<div class="dash-empty">Loading token data…</div>';+ let agent;+ try {+ agent = await getAgent(agentId);+ } catch (e) {+ showStatus(e.message || 'Failed to load agent', 'err');+ return;+ }++ const token = agent?.token || agent?.meta?.token || null;+ if (!token?.mint) {+ contentEl.innerHTML = `+ <div class="dash-card">+ <h2>No token launched</h2>+ <p class="dash-muted" style="margin-bottom:14px">+ This agent has no Pump.fun token yet. Launch one from the agent's home page or via the+ Pump.fun studio.+ </p>+ <div class="dash-row">+ <a class="dash-btn primary" href="/agent/${encodeURIComponent(agentId)}">Open agent</a>+ <a class="dash-btn" href="/dashboard/agent-pumpfun">Pump.fun studio</a>+ </div>+ </div>`;+ return;+ }++ const live = token.cluster === 'mainnet' ? await fetchPumpData(token.mint) : null;+ const usdMc = live?.usd_market_cap;+ const solBalance = (live?.virtual_sol_reserves || 0) / 1e9;+ const tokensLeft = (live?.virtual_token_reserves || 0) / 1e6;+ const complete = live?.complete;++ contentEl.innerHTML = `+ <div class="dash-card">+ <h2>${escapeHtml(token.name || 'Token')} · ${escapeHtml(token.symbol || '')}</h2>+ <div class="dash-row" style="gap:18px;flex-wrap:wrap;margin-bottom:14px">+ ${token.image ? `<img src="${escapeHtml(token.image)}" alt="" width="64" height="64" style="border-radius:10px;background:#1a1a24" />` : ''}+ <div style="flex:1;min-width:240px">+ <div class="dash-mono">${escapeHtml(token.mint)}</div>+ <div class="dash-muted" style="margin-top:4px">+ Launched ${token.launched_at ? new Date(token.launched_at).toLocaleString() : '—'}+ ${token.cluster ? ' · ' + escapeHtml(token.cluster) : ''}+ </div>+ ${token.description ? `<p style="margin:8px 0 0;color:#ccc">${escapeHtml(token.description)}</p>` : ''}+ </div>+ </div>+ <div class="dash-row">+ ${token.pumpfun_url ? `<a class="dash-btn primary" href="${escapeHtml(token.pumpfun_url)}" target="_blank" rel="noopener">Pump.fun ↗</a>` : ''}+ ${token.explorer_url ? `<a class="dash-btn" href="${escapeHtml(token.explorer_url)}" target="_blank" rel="noopener">Explorer ↗</a>` : ''}+ <a class="dash-btn" href="https://dexscreener.com/solana/${encodeURIComponent(token.mint)}" target="_blank" rel="noopener">DEX Screener ↗</a>+ <a class="dash-btn" href="https://birdeye.so/token/${encodeURIComponent(token.mint)}?chain=solana" target="_blank" rel="noopener">Birdeye ↗</a>+ </div>+ </div>++ ${+ live+ ? `<div class="dash-card">+ <h2>Live state</h2>+ <div class="dash-row" style="gap:24px">+ <div>+ <div class="dash-muted" style="font-size:11px;text-transform:uppercase">Market cap</div>+ <div style="font-size:18px">${usdMc != null ? '$' + Number(usdMc).toLocaleString(undefined, { maximumFractionDigits: 0 }) : '—'}</div>+ </div>+ <div>+ <div class="dash-muted" style="font-size:11px;text-transform:uppercase">SOL in curve</div>+ <div style="font-size:18px">${solBalance.toFixed(2)}</div>+ </div>+ <div>+ <div class="dash-muted" style="font-size:11px;text-transform:uppercase">Tokens left</div>+ <div style="font-size:18px">${tokensLeft.toLocaleString(undefined, { maximumFractionDigits: 0 })}</div>+ </div>+ <div>+ <div class="dash-muted" style="font-size:11px;text-transform:uppercase">Status</div>+ <div style="font-size:18px">${complete ? '🎓 Graduated' : '📈 Bonding'}</div>+ </div>+ </div>+ </div>`+ : token.cluster === 'mainnet'+ ? '<div class="dash-empty">Pump.fun returned no data for this mint — token may be very new.</div>'+ : '<div class="dash-muted" style="text-align:center;padding:12px">Devnet token — live Pump.fun stats are mainnet-only.</div>'+ }++ <div class="dash-card">+ <h2>Launch tx</h2>+ ${+ token.tx_signature+ ? `<div class="dash-mono" style="word-break:break-all">${escapeHtml(token.tx_signature)}</div>+ <a class="dash-btn" style="margin-top:10px" target="_blank" rel="noopener" href="https://solscan.io/tx/${encodeURIComponent(token.tx_signature)}${token.cluster === 'devnet' ? '?cluster=devnet' : ''}">View on Solscan ↗</a>`+ : '<div class="dash-muted">No tx signature recorded.</div>'+ }+ </div>+ `;+ }++ mountAgentPicker({+ host: document.getElementById('picker'),+ onPick: (agentId) => render(agentId),+ });+ </script>+ </body>+</html>diff --git a/public/dashboard/voice.html b/public/dashboard/voice.htmlnew file mode 100644index 000000000..b4236fd62--- /dev/null+++ b/public/dashboard/voice.html@@ -0,0 +1,221 @@+<!doctype html>+<html lang="en">+ <head>+ <meta charset="utf-8" />+ <meta name="viewport" content="width=device-width,initial-scale=1" />+ <title>Agent Voice · three.ws</title>+ <link rel="stylesheet" href="/dashboard/_dash-shell.css" />+ </head>+ <body>+ <div class="dash-shell">+ <a class="dash-back" href="/dashboard/agents">← Back to dashboard</a>+ <h1 class="dash-title">Agent Voice</h1>+ <p class="dash-sub">+ Clone a voice from a ≥30-second sample (ElevenLabs) or fall back to browser TTS. Used by chat,+ agent-3d, and the X-Spaces voice agent.+ </p>++ <div id="picker"></div>+ <div id="status"></div>+ <div id="content"></div>+ </div>++ <script type="module">+ import { mountAgentPicker } from '/dashboard/_agent-picker.js';++ const statusEl = document.getElementById('status');+ const contentEl = document.getElementById('content');++ function showStatus(msg, kind = '') {+ statusEl.innerHTML = msg+ ? `<div class="${kind === 'err' ? 'dash-err' : 'dash-ok'}">${escapeHtml(msg)}</div>`+ : '';+ }+ function escapeHtml(s) {+ return String(s == null ? '' : s).replace(+ /[&<>"']/g,+ (c) => ({ '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' })[c],+ );+ }++ async function getVoice(agentId) {+ const r = await fetch(`/api/agents/${encodeURIComponent(agentId)}/voice`, {+ credentials: 'include',+ });+ if (!r.ok) throw new Error(`HTTP ${r.status}`);+ return r.json();+ }++ async function deleteVoice(agentId) {+ const r = await fetch(`/api/agents/${encodeURIComponent(agentId)}/voice`, {+ method: 'DELETE',+ credentials: 'include',+ });+ if (!r.ok) throw new Error(`HTTP ${r.status}`);+ return r.json();+ }++ let recorder = null;+ let chunks = [];+ let startedAt = 0;+ let timerInt = null;++ function pickMime() {+ const cands = [+ 'audio/webm;codecs=opus',+ 'audio/webm',+ 'audio/mp4',+ 'audio/mpeg',+ ];+ for (const c of cands) {+ if (window.MediaRecorder && MediaRecorder.isTypeSupported(c)) return c;+ }+ return 'audio/webm';+ }++ async function startRecord() {+ const stream = await navigator.mediaDevices.getUserMedia({ audio: true });+ const mime = pickMime();+ recorder = new MediaRecorder(stream, { mimeType: mime });+ chunks = [];+ recorder.ondataavailable = (e) => {+ if (e.data && e.data.size) chunks.push(e.data);+ };+ recorder.start();+ startedAt = Date.now();+ const timerEl = document.getElementById('rec-timer');+ timerInt = setInterval(() => {+ const sec = Math.floor((Date.now() - startedAt) / 1000);+ timerEl.textContent = sec + 's';+ }, 200);+ }++ async function stopRecord() {+ if (!recorder) return null;+ const r = recorder;+ const durationSec = Math.max(1, Math.floor((Date.now() - startedAt) / 1000));+ const blob = await new Promise((resolve) => {+ r.onstop = () => resolve(new Blob(chunks, { type: r.mimeType }));+ r.stop();+ });+ r.stream.getTracks().forEach((t) => t.stop());+ clearInterval(timerInt);+ recorder = null;+ return { blob, durationSec };+ }++ async function uploadClone(agentId, blob, durationSec) {+ const r = await fetch(+ `/api/agents/${encodeURIComponent(agentId)}/voice/clone?name=${encodeURIComponent(+ (document.getElementById('voice-name').value || 'Agent Voice').slice(0, 100),+ )}`,+ {+ method: 'POST',+ credentials: 'include',+ headers: {+ 'content-type': blob.type || 'audio/webm',+ 'x-recording-duration': String(durationSec),+ },+ body: blob,+ },+ );+ if (!r.ok) {+ const err = await r.json().catch(() => ({}));+ throw new Error(err.error_description || `HTTP ${r.status}`);+ }+ return r.json();+ }++ function render(agentId, voice) {+ const hasClone = !!voice.voice_id;+ contentEl.innerHTML = `+ <div class="dash-card">+ <h2>Current voice</h2>+ <div class="dash-row" style="gap:14px">+ <span class="dash-pill">${escapeHtml(voice.voice_provider || 'browser')}</span>+ ${hasClone ? `<span class="dash-mono">${escapeHtml(voice.voice_id)}</span>` : '<span class="dash-muted">No cloned voice — falls back to browser TTS.</span>'}+ ${hasClone ? `<button class="dash-btn danger" id="remove-voice">Remove clone</button>` : ''}+ </div>+ ${voice.voice_cloned_at ? `<div class="dash-muted" style="margin-top:8px">Cloned ${new Date(voice.voice_cloned_at).toLocaleString()}</div>` : ''}+ </div>+ <div class="dash-card">+ <h2>Clone a new voice</h2>+ <label style="display:block;margin-bottom:10px">+ <div class="dash-muted" style="margin-bottom:4px">Voice name</div>+ <input id="voice-name" class="dash-input" value="${escapeHtml(voice.voice_name || 'Agent Voice')}" maxlength="100" />+ </label>+ <div class="dash-row" style="gap:12px;align-items:center">+ <button class="dash-btn primary" id="rec-toggle">Start recording</button>+ <span class="dash-mono" id="rec-timer">0s</span>+ <span class="dash-muted">Min 30 seconds. Limit 10 MB.</span>+ </div>+ <div id="rec-out" style="margin-top:14px"></div>+ </div>+ `;++ const removeBtn = document.getElementById('remove-voice');+ if (removeBtn) {+ removeBtn.addEventListener('click', async () => {+ if (!confirm('Remove the cloned voice? The agent will fall back to browser TTS.')) return;+ removeBtn.disabled = true;+ try {+ await deleteVoice(agentId);+ showStatus('Removed.', 'ok');+ await refresh(agentId);+ } catch (e) {+ showStatus(e.message || 'Remove failed', 'err');+ removeBtn.disabled = false;+ }+ });+ }++ const toggleBtn = document.getElementById('rec-toggle');+ const outEl = document.getElementById('rec-out');+ toggleBtn.addEventListener('click', async () => {+ if (!recorder) {+ try {+ await startRecord();+ toggleBtn.textContent = 'Stop & upload';+ toggleBtn.classList.add('danger');+ toggleBtn.classList.remove('primary');+ } catch (e) {+ showStatus('Microphone access denied: ' + (e.message || e.name), 'err');+ }+ return;+ }+ toggleBtn.disabled = true;+ toggleBtn.textContent = 'Uploading…';+ try {+ const { blob, durationSec } = await stopRecord();+ outEl.innerHTML = `<audio controls src="${URL.createObjectURL(blob)}" style="width:100%;margin-bottom:10px"></audio>`;+ if (durationSec < 30) throw new Error(`Recording was ${durationSec}s — need ≥30s.`);+ const { voice_id } = await uploadClone(agentId, blob, durationSec);+ showStatus(`Voice cloned: ${voice_id}`, 'ok');+ await refresh(agentId);+ } catch (e) {+ showStatus(e.message || 'Upload failed', 'err');+ toggleBtn.disabled = false;+ toggleBtn.textContent = 'Start recording';+ toggleBtn.classList.add('primary');+ toggleBtn.classList.remove('danger');+ }+ });+ }++ async function refresh(agentId) {+ contentEl.innerHTML = '<div class="dash-empty">Loading voice status…</div>';+ try {+ const voice = await getVoice(agentId);+ render(agentId, voice);+ } catch (e) {+ showStatus(e.message || 'Failed to load voice', 'err');+ }+ }++ mountAgentPicker({+ host: document.getElementById('picker'),+ onPick: (agentId) => refresh(agentId),+ });+ </script>+ </body>+</html>diff --git a/public/discover/detail.html b/public/discover/detail.htmlindex 8b8244956..7cba3f917 100644--- a/public/discover/detail.html+++ b/public/discover/detail.html@@ -8,15 +8,10 @@<meta name="description" content="Agent detail on three.ws" /><meta name="theme-color" content="#000000" /><link rel="shortcut icon" href="/favicon.ico" />- <link rel="preconnect" href="https://fonts.googleapis.com" />- <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin /><link rel="stylesheet" href="/style.css" /><link rel="stylesheet" href="/nav.css" /><link rel="stylesheet" href="/discover/detail.css" />- <link- href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Space+Grotesk:wght@500;600;700&display=swap"- rel="stylesheet"- />+ <link rel="stylesheet" href="/fonts/fonts.css" /></head><body class="features-page detail-page"><header>diff --git a/public/discover/index.html b/public/discover/index.htmlindex 9c87d4ee5..e5761a324 100644--- a/public/discover/index.html+++ b/public/discover/index.html@@ -28,14 +28,9 @@/><meta name="twitter:image" content="https://three.ws/og-image.png" /><link rel="shortcut icon" href="/favicon.ico" />- <link rel="preconnect" href="https://fonts.googleapis.com" />- <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin /><link rel="stylesheet" href="/style.css" /><link rel="stylesheet" href="/nav.css" />- <link- href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Space+Grotesk:wght@500;600;700&display=swap"- rel="stylesheet"- />+ <link rel="stylesheet" href="/fonts/fonts.css" /></head><body class="features-page explore-page"><header>diff --git a/public/docs-widgets.html b/public/docs-widgets.htmlindex 22e1013b9..33a53b13f 100644--- a/public/docs-widgets.html+++ b/public/docs-widgets.html@@ -21,12 +21,7 @@<link rel="canonical" href="https://three.ws/docs/widgets" /><link rel="shortcut icon" href="/favicon.ico" />- <link rel="preconnect" href="https://fonts.googleapis.com" />- <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />- <link- href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Space+Grotesk:wght@500;600;700&display=swap"- rel="stylesheet"- />+ <link rel="stylesheet" href="/fonts/fonts.css" /><link rel="stylesheet" href="/style.css" /><link rel="stylesheet" href="/widgets-gallery/gallery.css" /><link rel="stylesheet" href="/footer.css" />diff --git a/public/eth-vanity.html b/public/eth-vanity.htmlindex b6f448e60..7cf1a784e 100644--- a/public/eth-vanity.html+++ b/public/eth-vanity.html@@ -7,9 +7,7 @@<meta name="description" content="Grind a vanity Ethereum smart-contract address by searching CREATE2 salts. Runs entirely in your browser — no keys involved, just a salt you feed to your factory."><link rel="icon" href="/favicon.ico"><link rel="stylesheet" href="/nav.css">- <link rel="preconnect" href="https://fonts.googleapis.com">- <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>- <link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&family=Space+Grotesk:wght@600;700&display=swap" rel="stylesheet">+ <link rel="stylesheet" href="/fonts/fonts.css" /><style>* { box-sizing: border-box; }:root {@@ -609,5 +607,8 @@});}</script>++ <div id="footer-container"></div>+ <script src="/footer.js" defer></script></body></html>diff --git a/public/fonts/fonts.css b/public/fonts/fonts.cssnew file mode 100644index 000000000..bf1947700--- /dev/null+++ b/public/fonts/fonts.css@@ -0,0 +1,60 @@+/* Self-hosted fonts for 3D-Agent.+ Source: Google Fonts (Inter, Space Grotesk, JetBrains Mono) — woff2, latin + latin-ext subsets.+ All three are variable fonts; one file per subset covers every weight we declare. */++/* Inter — latin */+@font-face {+ font-family: 'Inter';+ font-style: normal;+ font-weight: 300 800;+ font-display: swap;+ src: url('/fonts/inter-latin.woff2') format('woff2');+ unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;+}+/* Inter — latin-ext */+@font-face {+ font-family: 'Inter';+ font-style: normal;+ font-weight: 300 800;+ font-display: swap;+ src: url('/fonts/inter-latin-ext.woff2') format('woff2');+ unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;+}++/* Space Grotesk — latin */+@font-face {+ font-family: 'Space Grotesk';+ font-style: normal;+ font-weight: 300 700;+ font-display: swap;+ src: url('/fonts/space-grotesk-latin.woff2') format('woff2');+ unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;+}+/* Space Grotesk — latin-ext */+@font-face {+ font-family: 'Space Grotesk';+ font-style: normal;+ font-weight: 300 700;+ font-display: swap;+ src: url('/fonts/space-grotesk-latin-ext.woff2') format('woff2');+ unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;+}++/* JetBrains Mono — latin */+@font-face {+ font-family: 'JetBrains Mono';+ font-style: normal;+ font-weight: 400;+ font-display: swap;+ src: url('/fonts/jetbrains-mono-latin.woff2') format('woff2');+ unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;+}+/* JetBrains Mono — latin-ext */+@font-face {+ font-family: 'JetBrains Mono';+ font-style: normal;+ font-weight: 400;+ font-display: swap;+ src: url('/fonts/jetbrains-mono-latin-ext.woff2') format('woff2');+ unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;+}diff --git a/public/fonts/inter-latin-ext.woff2 b/public/fonts/inter-latin-ext.woff2new file mode 100644index 000000000..479d010d2Binary files /dev/null and b/public/fonts/inter-latin-ext.woff2 differdiff --git a/public/fonts/inter-latin.woff2 b/public/fonts/inter-latin.woff2new file mode 100644index 000000000..d15208de0Binary files /dev/null and b/public/fonts/inter-latin.woff2 differdiff --git a/public/fonts/jetbrains-mono-latin-ext.woff2 b/public/fonts/jetbrains-mono-latin-ext.woff2new file mode 100644index 000000000..9d97c9b79Binary files /dev/null and b/public/fonts/jetbrains-mono-latin-ext.woff2 differdiff --git a/public/fonts/jetbrains-mono-latin.woff2 b/public/fonts/jetbrains-mono-latin.woff2new file mode 100644index 000000000..585887339Binary files /dev/null and b/public/fonts/jetbrains-mono-latin.woff2 differdiff --git a/public/fonts/space-grotesk-latin-ext.woff2 b/public/fonts/space-grotesk-latin-ext.woff2new file mode 100644index 000000000..db732c272Binary files /dev/null and b/public/fonts/space-grotesk-latin-ext.woff2 differdiff --git a/public/fonts/space-grotesk-latin.woff2 b/public/fonts/space-grotesk-latin.woff2new file mode 100644index 000000000..0f3474ee8Binary files /dev/null and b/public/fonts/space-grotesk-latin.woff2 differdiff --git a/public/footer.html b/public/footer.htmlindex 29281e45c..2819e643a 100644--- a/public/footer.html+++ b/public/footer.html@@ -73,6 +73,7 @@<div class="h-footer-link-col"><h4 class="h-footer-link-heading">Developers</h4><a href="/docs">Docs</a>+ <a href="/sitemap">Sitemap</a><a href="https://github.com/nirholas/three.ws" target="_blank" rel="noopener">GitHub</a><a href="https://eips.ethereum.org/EIPS/eip-8004" target="_blank" rel="noopener">ERC-8004</a></div>diff --git a/public/gallery/index.html b/public/gallery/index.htmlindex b7db26657..6057c8d29 100644--- a/public/gallery/index.html+++ b/public/gallery/index.html@@ -29,15 +29,10 @@<meta name="twitter:image" content="https://three.ws/og-image.png" /><link rel="shortcut icon" href="/favicon.ico" />- <link rel="preconnect" href="https://fonts.googleapis.com" />- <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin /><link rel="stylesheet" href="/style.css" /><link rel="stylesheet" href="/nav.css" /><link rel="stylesheet" href="/gallery/gallery.css" />- <link- href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Space+Grotesk:wght@500;600;700&display=swap"- rel="stylesheet"- />+ <link rel="stylesheet" href="/fonts/fonts.css" /></head><body class="gallery-page"><header>diff --git a/public/hydrate/index.html b/public/hydrate/index.htmlindex 8f7d01b7e..b0c6ab64b 100644--- a/public/hydrate/index.html+++ b/public/hydrate/index.html@@ -272,6 +272,11 @@</style></head><body>+ <header>+ <div id="nav-container"></div>+ </header>+ <script src="/nav.js"></script>+<div class="container"><div class="breadcrumb"><a href="/marketplace.html?tab=mine">Home</a> / <a href="/dashboard/">Dashboard</a> / Import Agents@@ -481,5 +486,8 @@// Load on page loadloadAgents();</script>++ <div id="footer-container"></div>+ <script src="/footer.js" defer></script></body></html>diff --git a/public/pay/calls/index.html b/public/pay/calls/index.htmlindex b4affc0fb..139c422bc 100644--- a/public/pay/calls/index.html+++ b/public/pay/calls/index.html@@ -330,5 +330,8 @@ if (!tx) {}</script>+<div id="footer-container"></div>+<script src="/footer.js" defer></script>+</body></html>diff --git a/public/pay/index.html b/public/pay/index.htmlindex 45bebdb74..aabf55fd3 100644--- a/public/pay/index.html+++ b/public/pay/index.html@@ -580,6 +580,11 @@<body><header>+ <div id="nav-container"></div>+</header>+<script src="/nav.js"></script>++<header class="page-header"><div class="brand"><div class="logo"></div><div>@@ -1321,5 +1326,8 @@ if (params.get('list') === '1') queueMicrotask(() => run({ tool: 'tools/list', apromptEl.focus();</script>+<div id="footer-container"></div>+<script src="/footer.js" defer></script>+</body></html>diff --git a/public/pumpfun.html b/public/pumpfun.htmlindex 833409d45..a0dcef973 100644--- a/public/pumpfun.html+++ b/public/pumpfun.html@@ -5,13 +5,11 @@<meta name="viewport" content="width=device-width,initial-scale=1" /><title>PumpFun migrations · three.ws</title><link rel="icon" href="/favicon.ico" />- <link rel="preconnect" href="https://fonts.googleapis.com" />- <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin /><link rel="stylesheet" href="/style.css" /><link rel="stylesheet" href="/home.css" /><link rel="stylesheet" href="/footer.css" /><link rel="stylesheet" href="/nav.css" />- <link href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Space+Grotesk:wght@500;600;700&display=swap" rel="stylesheet" />+ <link rel="stylesheet" href="/fonts/fonts.css" /><script type="module" src="https://ajax.googleapis.com/ajax/libs/model-viewer/4.0.0/model-viewer.min.js"></script><script defer src="/footer-newsletter.js"></script><style>diff --git a/public/reputation/index.html b/public/reputation/index.htmlindex 64722521b..1a4dc6781 100644--- a/public/reputation/index.html+++ b/public/reputation/index.html@@ -9,13 +9,7 @@<meta name="theme-color" content="#0a0a0a" /><link rel="shortcut icon" href="/favicon.ico" />- <link rel="preconnect" href="https://fonts.googleapis.com" />- <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />- <link- href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Space+Grotesk:wght@500;600;700&display=swap"- rel="stylesheet"- />-+ <link rel="stylesheet" href="/fonts/fonts.css" /><link rel="stylesheet" href="/style.css" /><link rel="stylesheet" href="/home.css" /><link rel="stylesheet" href="/footer.css" />diff --git a/public/robots.txt b/public/robots.txtindex 3b59cf5ec..720402cc2 100644--- a/public/robots.txt+++ b/public/robots.txt@@ -1,4 +1,11 @@User-agent: *Allow: /Disallow: /my-agents+Disallow: /dashboard+Disallow: /settings+Sitemap: https://three.ws/sitemap.xml++# AI-agent index (https://llmstxt.org/)+# Concise: https://three.ws/llms.txt+# Long form: https://three.ws/llms-full.txtdiff --git a/public/settings/index.html b/public/settings/index.htmlindex 40c2e27b2..866c3bc8c 100644--- a/public/settings/index.html+++ b/public/settings/index.html@@ -5,9 +5,7 @@<meta name="viewport" content="width=device-width,initial-scale=1" /><title>Settings · three.ws</title><link rel="icon" href="/favicon.ico" />- <link rel="preconnect" href="https://fonts.googleapis.com" />- <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />- <link href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Space+Grotesk:wght@500;600;700&display=swap" rel="stylesheet" />+ <link rel="stylesheet" href="/fonts/fonts.css" /><link rel="stylesheet" href="/footer.css" /><style>:root {diff --git a/public/sitemap/index.html b/public/sitemap/index.htmlindex adb56204d..5917a0289 100644--- a/public/sitemap/index.html+++ b/public/sitemap/index.html@@ -40,7 +40,7 @@</style></head><body>- <div id="home-nav-mount"></div>+ <div id="nav-container"></div><main class="sm-wrap"><div class="sm-hero"><h1>Sitemap</h1>@@ -540,7 +540,7 @@</ul></section></main>- <div id="home-footer-mount"></div>+ <div id="footer-container"></div><script type="module" src="/nav.js"></script><script type="module" src="/footer.js"></script></body>diff --git a/public/strategy-lab.html b/public/strategy-lab.htmlindex 988fb7f37..04df43542 100644--- a/public/strategy-lab.html+++ b/public/strategy-lab.html@@ -85,6 +85,11 @@</style></head><body>+ <header>+ <div id="nav-container"></div>+ </header>+ <script src="/nav.js"></script>+<h1>Strategy lab</h1><p class="lead">Declarative pump.fun strategies, executed end-to-end. Backtests query the@@ -520,5 +525,8 @@loadAgents();</script>++<div id="footer-container"></div>+<script src="/footer.js" defer></script></body></html>diff --git a/public/studio/index.html b/public/studio/index.htmlindex 4aa3638df..d6707a0ef 100644--- a/public/studio/index.html+++ b/public/studio/index.html@@ -12,12 +12,7 @@<meta name="theme-color" content="#0a0a0a" /><meta name="robots" content="noindex" /><link rel="shortcut icon" href="/favicon.ico" />- <link rel="preconnect" href="https://fonts.googleapis.com" />- <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />- <link- href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Space+Grotesk:wght@500;600;700&display=swap"- rel="stylesheet"- />+ <link rel="stylesheet" href="/fonts/fonts.css" /><link rel="stylesheet" href="/studio/studio.css?v=2" /><style>/* Critical layout — guarantees the 3-column grid renders even ifdiff --git a/public/studio/launch-panel.js b/public/studio/launch-panel.jsindex 326b9f8b7..9b35c607a 100644--- a/public/studio/launch-panel.js+++ b/public/studio/launch-panel.js@@ -367,6 +367,10 @@ export function mountLaunchPanel(container, { getAvatar, getUser, getPreviewViewwalletAddr: null, solBalance: null,// link status: null=unknown/checking, true=linked, false=not linkedwalletLinked: null, walletLinkChecking: false, walletLinking: false, walletLinkError: '',+ // True after a 409 from /link-solana; flips the link row into a+ // "Transfer wallet to this account" confirmation that re-signs with+ // takeover=true.+ walletConflict: false,// agent wallet (resolved/provisioned when source switches to 'agent')agentWallet: null, // { agent_id, address, sol, lamports } | null@@ -439,7 +443,7 @@ export function mountLaunchPanel(container, { getAvatar, getUser, getPreviewViewif (addr === s.walletAddr) return;s.walletAddr = addr;s.solBalance = null;- s.walletLinked = null; s.walletLinkError = '';+ s.walletLinked = null; s.walletLinkError = ''; s.walletConflict = false;render();fetchBalance(addr);checkWalletLinked(addr);@@ -476,7 +480,7 @@ export function mountLaunchPanel(container, { getAvatar, getUser, getPreviewViewconst addr = w.publicKey?.toBase58?.() || w.publicKey?.toString?.();if (!addr) return;s.walletAddr = addr;- s.walletLinked = null; s.walletLinkError = '';+ s.walletLinked = null; s.walletLinkError = ''; s.walletConflict = false;render();subscribeWalletEvents(w);startBalancePoll(addr);@@ -488,6 +492,7 @@ export function mountLaunchPanel(container, { getAvatar, getUser, getPreviewViews.walletAddr = null; s.solBalance = null;s.walletLinked = null; s.walletLinkChecking = false;s.walletLinking = false; s.walletLinkError = '';+ s.walletConflict = false;if (_balanceInterval) { clearInterval(_balanceInterval); _balanceInterval = null; }render();}@@ -517,17 +522,26 @@ export function mountLaunchPanel(container, { getAvatar, getUser, getPreviewView// Run the SIWS link ceremony for the connected wallet. Triggered by the// explicit "Link wallet" button so the user understands the prompt.- async function linkConnectedWallet() {+ // When `takeover` is true the server is told to move the wallet from+ // whichever account currently holds it to the session user — only+ // reached from the conflict confirmation UI.+ async function linkConnectedWallet(takeover = false) {const provider = detectWallet();const addr = s.walletAddr;if (!provider || !addr || s.walletLinking) return;s.walletLinking = true; s.walletLinkError = '';render();try {- await linkSolanaWallet(provider, addr);+ await linkSolanaWallet(provider, addr, { takeover });s.walletLinked = true;+ s.walletConflict = false;} catch (e) {- s.walletLinkError = friendlyError(e.message || String(e));+ if (e.code === 'address_in_use' && !takeover) {+ s.walletConflict = true;+ s.walletLinkError = '';+ } else {+ s.walletLinkError = friendlyError(e.message || String(e));+ }} finally {s.walletLinking = false;render();@@ -891,7 +905,9 @@ export function mountLaunchPanel(container, { getAvatar, getUser, getPreviewView// 1 ── Build / reuse metadata (shared)s.phase = 'building'; s.phaseLabel = 'Uploading metadata…'; render();- const nameTrim = s.name.trim(), symTrim = s.symbol.trim(), descTrim = s.description.trim();+ const nameTrim = s.name.trim().slice(0, 32);+ const symTrim = s.symbol.trim().slice(0, 10);+ const descTrim = s.description.trim().slice(0, 500);const metaKey = `${nameTrim}|${symTrim}|${descTrim}|${!!s.imageFile}`;if (s._metaKey !== metaKey || !s._metaUrl) {@@ -907,7 +923,14 @@ export function mountLaunchPanel(container, { getAvatar, getUser, getPreviewView...(imageDataUrl ? { image_data_url: imageDataUrl } : {}),}),});- if (!mr.ok) throw new Error(`Metadata build failed (${mr.status})`);+ if (!mr.ok) {+ const errJson = await mr.json().catch(() => null);+ const detail = errJson?.error_description+ || errJson?.issues?.map((i) => `${i.path?.join('.') || 'body'}: ${i.message}`).join('; ')+ || errJson?.error+ || `HTTP ${mr.status}`;+ throw new Error(`Metadata build failed — ${detail}`);+ }const md = await mr.json();s._metaUrl = md.metadata_url; s._metaKey = metaKey;}@@ -925,7 +948,9 @@ export function mountLaunchPanel(container, { getAvatar, getUser, getPreviewView// Issue a SIWS "link wallet" prompt and POST it to /api/auth/wallets/link-solana.// Idempotent on the server — safe to call when already linked.- async function linkSolanaWallet(provider, address) {+ // With `{ takeover: true }`, an existing link on another account is moved+ // to the session user atomically (signature already proves ownership).+ async function linkSolanaWallet(provider, address, { takeover = false } = {}) {const nonceRes = await fetch('/api/auth/wallets/nonce-solana', {method: 'POST', credentials: 'include',headers: { 'content-type': 'application/json' },@@ -933,7 +958,9 @@ export function mountLaunchPanel(container, { getAvatar, getUser, getPreviewView});const nonceData = await nonceRes.json();if (!nonceRes.ok) {- throw new Error(nonceData.error_description || nonceData.error || 'Could not start wallet link');+ const err = new Error(nonceData.error_description || nonceData.error || 'Could not start wallet link');+ err.code = nonceData.error;+ throw err;}const msgBytes = new TextEncoder().encode(nonceData.message);@@ -943,11 +970,14 @@ export function mountLaunchPanel(container, { getAvatar, getUser, getPreviewViewconst linkRes = await fetch('/api/auth/wallets/link-solana', {method: 'POST', credentials: 'include',headers: { 'content-type': 'application/json' },- body: JSON.stringify({ message: nonceData.message, signature: sigBase64 }),+ body: JSON.stringify({ message: nonceData.message, signature: sigBase64, takeover }),});const linkData = await linkRes.json();if (!linkRes.ok) {- throw new Error(linkData.error_description || linkData.error || 'Wallet link failed');+ const err = new Error(linkData.error_description || linkData.error || 'Wallet link failed');+ err.code = linkData.error;+ err.takeoverAvailable = linkData.takeover_available === true;+ throw err;}}@@ -1547,9 +1577,9 @@ export function mountLaunchPanel(container, { getAvatar, getUser, getPreviewViews.agentWalletLoading = false;if (av && av.id !== DEMO_ID) {- if (!s.name) s.name = av.name || '';+ if (!s.name) s.name = (av.name || '').slice(0, 32);if (!s._symbolEdited) s.symbol = toSymbol(s.name);- if (!s.description) s.description = av.description || '';+ if (!s.description) s.description = (av.description || '').slice(0, 500);if (s.walletSource === 'agent') loadAgentWallet();}@@ -1560,9 +1590,9 @@ export function mountLaunchPanel(container, { getAvatar, getUser, getPreviewViewav = getAvatar?.() || null;if (av && av.id !== DEMO_ID) {- s.name = av.name || '';+ s.name = (av.name || '').slice(0, 32);s.symbol = toSymbol(s.name);- s.description = av.description || '';+ s.description = (av.description || '').slice(0, 500);}render();diff --git a/public/validation/index.html b/public/validation/index.htmlindex d9fe178e7..24dc43db8 100644--- a/public/validation/index.html+++ b/public/validation/index.html@@ -831,17 +831,9 @@</head><body><header>- <div class="brand">- <a href="/"- ><img src="/three.svg" alt="" class="header-logo" aria-hidden="true" />three.ws</a- >- </div>- <nav>- <a href="/marketplace.html?tab=mine">Home</a>- <a href="/dashboard">Dashboard</a>- <a href="/discover">Discover</a>- </nav>+ <div id="nav-container"></div></header>+ <script src="/nav.js"></script><main><h1>glTF Validator</h1>@@ -1074,5 +1066,8 @@.getElementById('empty-submit-btn').addEventListener('click', () => dashboard.openModal());</script>++ <div id="footer-container"></div>+ <script src="/footer.js" defer></script></body></html>diff --git a/public/vanity-wallet.html b/public/vanity-wallet.htmlindex 78e7f95b9..886826c62 100644--- a/public/vanity-wallet.html+++ b/public/vanity-wallet.html@@ -8,9 +8,7 @@<link rel="icon" href="/favicon.ico"><link rel="stylesheet" href="/footer.css"><link rel="stylesheet" href="/nav.css">- <link rel="preconnect" href="https://fonts.googleapis.com">- <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>- <link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&family=Space+Grotesk:wght@600;700&display=swap" rel="stylesheet">+ <link rel="stylesheet" href="/fonts/fonts.css" /><script defer src="/footer-newsletter.js"></script><script type="module" src="https://ajax.googleapis.com/ajax/libs/model-viewer/4.0.0/model-viewer.min.js"></script><style>diff --git a/public/widgets-gallery/index.html b/public/widgets-gallery/index.htmlindex 49c029a02..5214c1b87 100644--- a/public/widgets-gallery/index.html+++ b/public/widgets-gallery/index.html@@ -23,12 +23,7 @@<link rel="canonical" href="https://three.ws/widgets" /><link rel="shortcut icon" href="/favicon.ico" />- <link rel="preconnect" href="https://fonts.googleapis.com" />- <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />- <link- href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Space+Grotesk:wght@500;600;700&display=swap"- rel="stylesheet"- />+ <link rel="stylesheet" href="/fonts/fonts.css" /><link rel="stylesheet" href="/style.css" /><link rel="stylesheet" href="/widgets-gallery/gallery.css" /><link rel="stylesheet" href="/footer.css" />diff --git a/scripts/build-page-index.mjs b/scripts/build-page-index.mjsindex 9bc97bc8f..32b574bb5 100644--- a/scripts/build-page-index.mjs+++ b/scripts/build-page-index.mjs@@ -209,7 +209,7 @@ ${items}</style></head><body>-\t<div id="home-nav-mount"></div>+\t<div id="nav-container"></div>\t<main class="sm-wrap">\t\t<div class="sm-hero">\t\t\t<h1>Sitemap</h1>@@ -226,7 +226,7 @@ ${tocHtml}\t\t</nav>${sectionHtml}\t</main>-\t<div id="home-footer-mount"></div>+\t<div id="footer-container"></div>\t<script type="module" src="/nav.js"></script>\t<script type="module" src="/footer.js"></script></body>diff --git a/src/agent-edit.js b/src/agent-edit.jsindex 1e6d39da4..ee1636135 100644--- a/src/agent-edit.js+++ b/src/agent-edit.js@@ -453,28 +453,1207 @@ $('autopilot-save').addEventListener('click', async () => {}});-// --- Tab switching ---+// ─────────────────────────────────────────────────────────────────────────────+// Voice tab+// ─────────────────────────────────────────────────────────────────────────────-document.querySelectorAll('.edit-tab').forEach((tab) => {- tab.addEventListener('click', (e) => {- const btn = e.currentTarget;- const tabId = btn.dataset.tab;-- document.querySelectorAll('.edit-tab').forEach((t) => {- const active = t === btn;- t.classList.toggle('active', active);- t.setAttribute('aria-selected', active ? 'true' : 'false');+let voicesCache = null;+let voiceStatus = null;+let voicePreviewAudio = null;+let voiceTabMounted = false;++async function ensureVoiceTab() {+ if (voiceTabMounted) return;+ voiceTabMounted = true;+ await Promise.all([loadVoiceStatus(), loadVoiceList()]);+}++async function loadVoiceStatus() {+ const el = $('voice-current');+ try {+ const r = await fetch(`${API_BASE}/agents/${agentId}/voice`, { credentials: 'include' });+ if (!r.ok) throw new Error(`HTTP ${r.status}`);+ voiceStatus = await r.json();+ renderVoiceStatus();+ } catch (err) {+ el.textContent = `Could not load voice: ${err.message}`;+ }+}++function renderVoiceStatus() {+ const el = $('voice-current');+ const previewBtn = $('voice-preview-btn');+ const removeBtn = $('voice-remove-btn');+ if (!voiceStatus || !voiceStatus.voice_id) {+ el.textContent = `Browser speech synthesis (no custom voice set).`;+ previewBtn.hidden = true;+ removeBtn.hidden = true;+ return;+ }+ const name = (voicesCache || []).find((v) => v.voice_id === voiceStatus.voice_id)?.name || voiceStatus.voice_id;+ const cloned = voiceStatus.voice_cloned_at ? ` — cloned ${new Date(voiceStatus.voice_cloned_at).toLocaleDateString()}` : '';+ el.textContent = `${voiceStatus.voice_provider || 'elevenlabs'}: ${name}${cloned}`;+ previewBtn.hidden = false;+ removeBtn.hidden = false;+}++async function loadVoiceList(filter = '') {+ const container = $('voice-list');+ if (!voicesCache) {+ try {+ const r = await fetch(`${API_BASE}/tts/eleven/voices`, { credentials: 'include' });+ if (!r.ok) throw new Error(`HTTP ${r.status}`);+ const j = await r.json();+ voicesCache = j.voices || [];+ } catch (err) {+ container.innerHTML = `<div class="muted">Could not load voices: ${escapeHtml(err.message)}</div>`;+ return;+ }+ }+ renderVoiceList(filter);+}++function renderVoiceList(filter = '') {+ const container = $('voice-list');+ const f = filter.trim().toLowerCase();+ const list = (voicesCache || []).filter((v) => !f || (v.name || '').toLowerCase().includes(f) || (v.category || '').toLowerCase().includes(f));+ if (!list.length) {+ container.innerHTML = '<div class="muted">No voices match.</div>';+ return;+ }+ const currentId = voiceStatus?.voice_id;+ container.innerHTML = list.map((v) => `+ <div class="voice-tile${v.voice_id === currentId ? ' current' : ''}" data-voice-id="${escapeHtml(v.voice_id)}" data-preview="${escapeHtml(v.preview_url || '')}">+ <div class="voice-tile-name">+ <span>${escapeHtml(v.name || v.voice_id)}</span>+ <span class="voice-tile-meta">${escapeHtml(v.category || '')}</span>+ </div>+ ${v.preview_url ? '<button type="button" class="voice-tile-play" title="Preview">▶</button>' : ''}+ </div>+ `).join('');+ container.querySelectorAll('.voice-tile').forEach((tile) => {+ tile.addEventListener('click', (e) => {+ if (e.target.classList.contains('voice-tile-play')) {+ playVoicePreview(tile.dataset.preview);+ return;+ }+ selectVoice(tile.dataset.voiceId);+ });+ });+}++function playVoicePreview(url) {+ if (!url) return;+ try { voicePreviewAudio?.pause(); } catch {}+ voicePreviewAudio = new Audio(url);+ voicePreviewAudio.play().catch(() => {});+}++async function selectVoice(voiceId) {+ if (!voiceId) return;+ const status = $('voice-status');+ status.textContent = 'Saving…';+ status.className = 'form-status';+ try {+ const r = await fetch(`${API_BASE}/agents/${agentId}`, {+ method: 'PUT',+ headers: { 'Content-Type': 'application/json' },+ credentials: 'include',+ body: JSON.stringify({ voice_provider: 'elevenlabs', voice_id: voiceId }),});+ if (!r.ok) {+ const j = await r.json().catch(() => ({}));+ throw new Error(j.error_description || j.error || `HTTP ${r.status}`);+ }+ voiceStatus = { voice_provider: 'elevenlabs', voice_id: voiceId, voice_cloned_at: null };+ renderVoiceStatus();+ renderVoiceList($('voice-filter').value);+ status.textContent = 'Saved.';+ status.className = 'form-status ok';+ } catch (err) {+ status.textContent = `Error: ${err.message}`;+ status.className = 'form-status err';+ }+}++$('voice-filter').addEventListener('input', (e) => renderVoiceList(e.target.value));++$('voice-preview-btn').addEventListener('click', () => {+ const v = (voicesCache || []).find((x) => x.voice_id === voiceStatus?.voice_id);+ if (v?.preview_url) playVoicePreview(v.preview_url);+});++$('voice-remove-btn').addEventListener('click', async () => {+ const status = $('voice-status');+ if (!confirm('Remove cloned voice? This frees the ElevenLabs quota slot.')) return;+ status.textContent = 'Removing…';+ status.className = 'form-status';+ try {+ const r = await fetch(`${API_BASE}/agents/${agentId}/voice`, { method: 'DELETE', credentials: 'include' });+ if (!r.ok) {+ const j = await r.json().catch(() => ({}));+ throw new Error(j.error_description || j.error || `HTTP ${r.status}`);+ }+ voiceStatus = { voice_provider: 'browser', voice_id: null, voice_cloned_at: null };+ renderVoiceStatus();+ renderVoiceList($('voice-filter').value);+ status.textContent = 'Removed.';+ status.className = 'form-status ok';+ } catch (err) {+ status.textContent = `Error: ${err.message}`;+ status.className = 'form-status err';+ }+});++$('voice-clone-btn').addEventListener('click', () => $('voice-clone-file').click());++$('voice-clone-file').addEventListener('change', async (e) => {+ const file = e.target.files?.[0];+ if (!file) return;+ const status = $('voice-status');+ status.textContent = 'Uploading…';+ status.className = 'form-status';+ try {+ const cloneName = $('voice-clone-name').value.trim() || `${agentData.name || 'Agent'} voice`;+ const qs = new URLSearchParams({ name: cloneName });+ const audio = await blobToArrayBuffer(file);+ const r = await fetch(`${API_BASE}/agents/${agentId}/voice/clone?${qs}`, {+ method: 'POST',+ credentials: 'include',+ headers: { 'Content-Type': file.type || 'audio/mpeg' },+ body: audio,+ });+ if (!r.ok) {+ const j = await r.json().catch(() => ({}));+ throw new Error(j.error_description || j.error || `HTTP ${r.status}`);+ }+ const j = await r.json();+ voiceStatus = { voice_provider: 'elevenlabs', voice_id: j.voice_id, voice_cloned_at: new Date().toISOString() };+ renderVoiceStatus();+ status.textContent = 'Voice cloned.';+ status.className = 'form-status ok';+ } catch (err) {+ status.textContent = `Error: ${err.message}`;+ status.className = 'form-status err';+ } finally {+ e.target.value = '';+ }+});++function blobToArrayBuffer(blob) {+ return new Promise((resolve, reject) => {+ const fr = new FileReader();+ fr.onload = () => resolve(fr.result);+ fr.onerror = reject;+ fr.readAsArrayBuffer(blob);+ });+}++// ─────────────────────────────────────────────────────────────────────────────+// Knowledge tab+// ─────────────────────────────────────────────────────────────────────────────++let knowledgeTabMounted = false;++async function ensureKnowledgeTab() {+ if (knowledgeTabMounted) return;+ knowledgeTabMounted = true;+ await loadMemories();+}++async function loadMemories() {+ const container = $('mem-list');+ try {+ const r = await fetch(`${API_BASE}/agents/${agentId}/memories`, { credentials: 'include' });+ if (!r.ok) throw new Error(`HTTP ${r.status}`);+ const j = await r.json();+ renderMemories(j.data || []);+ } catch (err) {+ container.innerHTML = `<div class="muted">Could not load memories: ${escapeHtml(err.message)}</div>`;+ }+}++function renderMemories(rows) {+ const container = $('mem-list');+ if (!rows.length) {+ container.innerHTML = '<div class="muted">No memories yet.</div>';+ return;+ }+ container.innerHTML = rows.map((m) => `+ <div class="mem-item" data-id="${escapeHtml(m.id)}">+ <div class="mem-item-body">+ <div class="mem-item-type">${escapeHtml(m.type)}</div>+ <div class="mem-item-content">${escapeHtml(m.content)}</div>+ ${m.tags?.length ? `<div class="mem-item-tags">${m.tags.map(escapeHtml).join(' · ')}</div>` : ''}+ </div>+ <button class="chip-remove" data-del="${escapeHtml(m.id)}" title="Delete">×</button>+ </div>+ `).join('');+ container.querySelectorAll('[data-del]').forEach((btn) => {+ btn.addEventListener('click', () => deleteMemory(btn.dataset.del));+ });+}++async function deleteMemory(id) {+ try {+ const r = await fetch(`${API_BASE}/agents/${agentId}/memories/${id}`, { method: 'DELETE', credentials: 'include' });+ if (!r.ok) throw new Error(`HTTP ${r.status}`);+ await loadMemories();+ } catch (err) {+ $('mem-status').textContent = `Delete failed: ${err.message}`;+ $('mem-status').className = 'form-status err';+ }+}++$('mem-add-btn').addEventListener('click', async () => {+ const status = $('mem-status');+ const type = $('mem-type').value;+ const content = $('mem-content').value.trim();+ const tags = $('mem-tags').value.split(',').map((t) => t.trim()).filter(Boolean).slice(0, 20);+ if (!content) {+ status.textContent = 'Content is required.';+ status.className = 'form-status err';+ return;+ }+ status.textContent = 'Saving…';+ status.className = 'form-status';+ try {+ const r = await fetch(`${API_BASE}/agents/${agentId}/memories`, {+ method: 'POST',+ headers: { 'Content-Type': 'application/json' },+ credentials: 'include',+ body: JSON.stringify({ type, content, tags }),+ });+ if (!r.ok) {+ const j = await r.json().catch(() => ({}));+ throw new Error(j.error_description || j.error || `HTTP ${r.status}`);+ }+ $('mem-content').value = '';+ $('mem-tags').value = '';+ status.textContent = 'Added.';+ status.className = 'form-status ok';+ await loadMemories();+ } catch (err) {+ status.textContent = `Error: ${err.message}`;+ status.className = 'form-status err';+ }+});- document.querySelectorAll('.edit-panel').forEach((p) => {- const active = p.id === `panel-${tabId}`;- p.classList.toggle('active', active);- if (active) p.removeAttribute('hidden');- else p.setAttribute('hidden', '');+$('mem-seed-btn').addEventListener('click', async () => {+ const status = $('mem-status');+ const url = $('mem-seed-url').value.trim();+ if (!url) {+ status.textContent = 'URL is required.';+ status.className = 'form-status err';+ return;+ }+ status.textContent = 'Seeding…';+ status.className = 'form-status';+ try {+ const r = await fetch(`${API_BASE}/agents/${agentId}/memory-seed`, {+ method: 'POST',+ headers: { 'Content-Type': 'application/json' },+ credentials: 'include',+ body: JSON.stringify({ url }),});+ if (!r.ok) {+ const j = await r.json().catch(() => ({}));+ throw new Error(j.error_description || j.error || `HTTP ${r.status}`);+ }+ const j = await r.json().catch(() => ({}));+ $('mem-seed-url').value = '';+ status.textContent = `Seeded ${j.added ?? ''} memories.`.trim();+ status.className = 'form-status ok';+ await loadMemories();+ } catch (err) {+ status.textContent = `Error: ${err.message}`;+ status.className = 'form-status err';+ }+});++// ─────────────────────────────────────────────────────────────────────────────+// Skills tab+// ─────────────────────────────────────────────────────────────────────────────++const BUILTIN_SKILLS = new Set(['greet', 'present-model', 'validate-model', 'remember', 'think']);+let skillsTabMounted = false;+let workingSkills = null;++async function ensureSkillsTab() {+ if (skillsTabMounted) return;+ skillsTabMounted = true;+ workingSkills = [...(agentData.skills || [])];+ renderSkillsChips();+ await loadMarketplaceSkillSuggestions();+}- if (tabId === 'outfit' && agentData) ensureOutfitTab();+function renderSkillsChips() {+ const container = $('skills-list');+ if (!workingSkills.length) {+ container.innerHTML = '<div class="muted">No skills.</div>';+ return;+ }+ container.innerHTML = workingSkills.map((s) => {+ const builtin = BUILTIN_SKILLS.has(s);+ return `<span class="chip${builtin ? ' chip-builtin' : ''}">${escapeHtml(s)}${builtin ? '' : ` <button class="chip-remove" data-skill="${escapeHtml(s)}" title="Remove">×</button>`}</span>`;+ }).join('');+ container.querySelectorAll('.chip-remove').forEach((btn) => {+ btn.addEventListener('click', () => {+ workingSkills = workingSkills.filter((s) => s !== btn.dataset.skill);+ renderSkillsChips();+ });});+}++async function loadMarketplaceSkillSuggestions() {+ const datalist = $('skills-marketplace');+ try {+ const r = await fetch(`${API_BASE}/skills?limit=50`, { credentials: 'include' });+ if (!r.ok) return;+ const j = await r.json();+ const items = j.skills || j.data || [];+ datalist.innerHTML = items.map((s) => `<option value="${escapeHtml(s.slug || s.name)}">${escapeHtml(s.name || s.slug || '')}</option>`).join('');+ } catch {+ // Suggestions are optional; silently skip on error.+ }+}++$('skill-add-btn').addEventListener('click', () => {+ const status = $('skills-status');+ const value = $('skill-add-input').value.trim().toLowerCase();+ if (!value) return;+ if (workingSkills.includes(value)) {+ status.textContent = 'Already added.';+ status.className = 'form-status err';+ return;+ }+ workingSkills.push(value);+ $('skill-add-input').value = '';+ renderSkillsChips();+ status.textContent = '';+});++$('skills-save').addEventListener('click', async () => {+ const status = $('skills-status');+ status.textContent = 'Saving…';+ status.className = 'form-status';+ try {+ const r = await fetch(`${API_BASE}/agents/${agentId}`, {+ method: 'PUT',+ headers: { 'Content-Type': 'application/json' },+ credentials: 'include',+ body: JSON.stringify({ skills: workingSkills }),+ });+ if (!r.ok) {+ const j = await r.json().catch(() => ({}));+ throw new Error(j.error_description || j.error || `HTTP ${r.status}`);+ }+ const j = await r.json();+ agentData.skills = j.agent?.skills || workingSkills;+ status.textContent = 'Saved.';+ status.className = 'form-status ok';+ renderMonetization();+ } catch (err) {+ status.textContent = `Error: ${err.message}`;+ status.className = 'form-status err';+ }});-loadAgent();+// ─────────────────────────────────────────────────────────────────────────────+// Wallet tab+// ─────────────────────────────────────────────────────────────────────────────++let walletTabMounted = false;+let walletInfo = null;++async function ensureWalletTab() {+ if (walletTabMounted) return;+ walletTabMounted = true;+ await loadWallet();+ loadWalletActivity();+}++async function loadWallet() {+ const meta = agentData.meta || {};+ const solAddr = meta.solana_address || agentData.solana_address || null;+ const evmAddr = agentData.wallet_address || null;+ const chainId = agentData.chain_id || null;++ walletInfo = { solAddr, evmAddr, chainId };++ if (solAddr) {+ $('wallet-sol-address').textContent = solAddr;+ $('wallet-explorer').href = `https://solscan.io/account/${solAddr}`;+ $('wallet-explorer').hidden = false;+ } else {+ $('wallet-sol-address').textContent = 'Not provisioned.';+ $('wallet-explorer').hidden = true;+ }++ if (evmAddr) {+ $('wallet-evm-address').textContent = evmAddr;+ $('wallet-evm-chain').textContent = chainId ? `Chain ${chainId}` : '—';+ const explorer = $('wallet-evm-explorer');+ explorer.href = chainId === 8453 ? `https://basescan.org/address/${evmAddr}` : `https://etherscan.io/address/${evmAddr}`;+ explorer.hidden = false;+ } else {+ $('wallet-evm-address').textContent = 'Not linked.';+ $('wallet-evm-chain').textContent = '—';+ $('wallet-evm-explorer').hidden = true;+ }++ const idParts = [];+ if (agentData.erc8004_agent_id) idParts.push(`ERC-8004 agent #${agentData.erc8004_agent_id} on chain ${chainId}`);+ const fname = meta.farcaster_fname || agentData.farcaster_fname;+ if (fname) idParts.push(`Farcaster: @${fname}`);+ if (agentData.registration_cid) idParts.push(`IPFS: ${agentData.registration_cid}`);+ if (agentData.x_username) idParts.push(`X: @${agentData.x_username}`);+ $('wallet-identity').innerHTML = idParts.length+ ? idParts.map(escapeHtml).join('<br>')+ : '<span class="muted">No on-chain registrations linked.</span>';++ await refreshBalances();+}++async function refreshBalances() {+ try {+ const r = await fetch(`${API_BASE}/portfolio/summary`, { credentials: 'include' });+ if (!r.ok) return;+ const j = await r.json();+ const mine = (j.wallets || []).filter((w) => w.agent_id === agentId);+ let solBal = null, usdcBal = null, totalUsd = 0;+ for (const w of mine) {+ totalUsd += Number(w.usd_total || 0);+ for (const a of (w.assets || [])) {+ if (w.chain === 'solana') {+ if (a.symbol === 'SOL') solBal = a;+ if (a.symbol === 'USDC') usdcBal = a;+ }+ }+ }+ $('wallet-sol-balance').textContent = solBal ? Number(solBal.amount).toFixed(4) : '0';+ $('wallet-usdc-balance').textContent = usdcBal ? Number(usdcBal.amount).toFixed(2) : '0';+ $('wallet-total-usd').textContent = `$${totalUsd.toFixed(2)}`;+ } catch {+ // Balance fetch is non-fatal — addresses are still useful.+ }+}++async function loadWalletActivity() {+ const el = $('wallet-activity');+ if (!walletInfo?.solAddr) {+ el.innerHTML = '<span class="muted">No Solana wallet.</span>';+ return;+ }+ try {+ const r = await fetch(`${API_BASE}/agents/${agentId}/solana/activity?limit=5`, { credentials: 'include' });+ if (!r.ok) throw new Error(`HTTP ${r.status}`);+ const j = await r.json();+ const items = j.activity || [];+ if (!items.length) {+ el.innerHTML = '<span class="muted">No recent activity.</span>';+ return;+ }+ el.innerHTML = items.map((it) => {+ const date = it.blockTime ? new Date(it.blockTime * 1000).toLocaleDateString() : '';+ const delta = it.lamportDelta != null ? `${(it.lamportDelta / 1e9).toFixed(4)} SOL` : '';+ return `<div class="pay-item"><span>${escapeHtml(it.summary || it.signature?.slice(0, 8) || 'tx')} · ${escapeHtml(date)}</span><span>${escapeHtml(delta)}</span></div>`;+ }).join('');+ } catch {+ el.innerHTML = `<span class="muted">Activity unavailable.</span>`;+ }+}++function copyToClipboard(text) {+ return navigator.clipboard.writeText(text).catch(() => {});+}++$('wallet-copy-sol').addEventListener('click', () => walletInfo?.solAddr && copyToClipboard(walletInfo.solAddr));+$('wallet-evm-copy').addEventListener('click', () => walletInfo?.evmAddr && copyToClipboard(walletInfo.evmAddr));++$('wallet-send-btn').addEventListener('click', () => {+ if (!walletInfo?.solAddr) { alert('Solana wallet not provisioned yet.'); return; }+ $('send-modal').hidden = false;+});++$('send-cancel').addEventListener('click', () => { $('send-modal').hidden = true; });++$('send-confirm').addEventListener('click', async () => {+ const status = $('send-status');+ const asset = $('send-asset').value;+ const to = $('send-to').value.trim();+ const amount = parseFloat($('send-amount').value);+ if (!to || !(amount > 0)) {+ status.textContent = 'Recipient and positive amount required.';+ status.className = 'form-status err';+ return;+ }+ if (!confirm(`Send ${amount} ${asset.toUpperCase()} to ${to}?`)) return;+ status.textContent = 'Sending…';+ status.className = 'form-status';+ try {+ const r = await fetch(`${API_BASE}/portfolio/send`, {+ method: 'POST',+ headers: { 'Content-Type': 'application/json' },+ credentials: 'include',+ body: JSON.stringify({ agent_id: agentId, chain: 'solana', asset, to, amount: amount.toString() }),+ });+ const j = await r.json().catch(() => ({}));+ if (!r.ok) throw new Error(j.error_description || j.error || `HTTP ${r.status}`);+ status.textContent = `Sent. tx ${j.signature?.slice(0, 8) || ''}…`;+ status.className = 'form-status ok';+ $('send-to').value = '';+ $('send-amount').value = '';+ refreshBalances();+ setTimeout(() => { $('send-modal').hidden = true; status.textContent = ''; }, 2500);+ } catch (err) {+ status.textContent = `Error: ${err.message}`;+ status.className = 'form-status err';+ }+});++$('wallet-fund-btn').addEventListener('click', () => {+ if (!walletInfo?.solAddr) { alert('Solana wallet not provisioned yet.'); return; }+ $('fund-address').textContent = walletInfo.solAddr;+ $('fund-qr').src = `https://api.qrserver.com/v1/create-qr-code/?size=240x240&data=${encodeURIComponent(walletInfo.solAddr)}`;+ $('fund-modal').hidden = false;+});+$('fund-close').addEventListener('click', () => { $('fund-modal').hidden = true; });+$('fund-copy').addEventListener('click', () => walletInfo?.solAddr && copyToClipboard(walletInfo.solAddr));++// ─────────────────────────────────────────────────────────────────────────────+// Social (X) tab+// ─────────────────────────────────────────────────────────────────────────────++let socialTabMounted = false;+let xConnection = null;++async function ensureSocialTab() {+ if (socialTabMounted) return;+ socialTabMounted = true;++ $('x-username').value = agentData.x_username || '';+ await Promise.all([loadXStatus(), loadXTriggers()]);++ const params = new URLSearchParams(location.search);+ const xParam = params.get('x');+ if (xParam === 'connected') {+ $('x-post-status').textContent = 'X connected.';+ $('x-post-status').className = 'form-status ok';+ } else if (xParam === 'error' || xParam === 'denied') {+ $('x-post-status').textContent = `X connect failed (${xParam}).`;+ $('x-post-status').className = 'form-status err';+ }+}++async function loadXStatus() {+ const el = $('x-status');+ try {+ const r = await fetch(`${API_BASE}/x/status`, { credentials: 'include' });+ if (!r.ok) throw new Error(`HTTP ${r.status}`);+ xConnection = await r.json();+ renderXStatus();+ } catch (err) {+ el.textContent = `Could not load status: ${err.message}`;+ }+}++function renderXStatus() {+ const el = $('x-status');+ const connectBtn = $('x-connect-btn');+ const disconnectBtn = $('x-disconnect-btn');+ if (!xConnection?.connected) {+ el.textContent = 'Not connected.';+ connectBtn.hidden = false;+ disconnectBtn.hidden = true;+ return;+ }+ el.innerHTML = `Connected as <strong>@${escapeHtml(xConnection.username)}</strong> · ${xConnection.posts_used}/${xConnection.quota} posts this month`;+ connectBtn.hidden = true;+ disconnectBtn.hidden = false;+}++$('x-connect-btn').addEventListener('click', () => {+ location.href = `${API_BASE}/auth/x/connect?agent_id=${encodeURIComponent(agentId)}`;+});++$('x-disconnect-btn').addEventListener('click', async () => {+ if (!confirm('Disconnect X account?')) return;+ try {+ const r = await fetch(`${API_BASE}/x/status`, { method: 'DELETE', credentials: 'include' });+ if (!r.ok) throw new Error(`HTTP ${r.status}`);+ await loadXStatus();+ } catch (err) {+ alert(`Disconnect failed: ${err.message}`);+ }+});++$('x-username-save').addEventListener('click', async () => {+ const val = $('x-username').value.trim().replace(/^@/, '') || null;+ try {+ const r = await fetch(`${API_BASE}/agents/${agentId}`, {+ method: 'PUT',+ headers: { 'Content-Type': 'application/json' },+ credentials: 'include',+ body: JSON.stringify({ x_username: val }),+ });+ if (!r.ok) {+ const j = await r.json().catch(() => ({}));+ throw new Error(j.error_description || j.error || `HTTP ${r.status}`);+ }+ agentData.x_username = val;+ $('x-post-status').textContent = 'Handle saved.';+ $('x-post-status').className = 'form-status ok';+ } catch (err) {+ $('x-post-status').textContent = `Error: ${err.message}`;+ $('x-post-status').className = 'form-status err';+ }+});++async function loadXTriggers() {+ const container = $('x-triggers-list');+ try {+ const r = await fetch(`${API_BASE}/x/triggers`, { credentials: 'include' });+ if (!r.ok) throw new Error(`HTTP ${r.status}`);+ const j = await r.json();+ const mine = (j.triggers || []).filter((t) => !t.agent_id || t.agent_id === agentId);+ renderXTriggers(mine);+ } catch (err) {+ container.innerHTML = `<div class="muted">Could not load triggers: ${escapeHtml(err.message)}</div>`;+ }+}++function defaultTriggerConfig(kind) {+ if (kind === 'daily_persona') return { hour_utc: 14, topic: '' };+ if (kind === 'weekly_digest') return { day_of_week: 1, hour_utc: 14 };+ if (kind === 'price_milestone') return { thresholds_usd: [10, 100, 1000] };+ if (kind === 'payment_received') return { min_amount_usd: 1 };+ return {};+}++function triggerLabel(kind) {+ return {+ daily_persona: 'Daily persona post',+ weekly_digest: 'Weekly digest',+ price_milestone: 'Price milestone',+ payment_received: 'Payment received',+ }[kind] || kind;+}++function renderXTriggers(rows) {+ const container = $('x-triggers-list');+ if (!rows.length) {+ container.innerHTML = '<div class="muted">No triggers yet.</div>';+ return;+ }+ container.innerHTML = rows.map((t) => {+ const cfg = t.config || {};+ let body = '';+ if (t.kind === 'daily_persona') {+ body = `<label>Hour (UTC): <input type="number" min="0" max="23" data-cfg="hour_utc" value="${cfg.hour_utc ?? 14}"></label>+ <label>Topic: <input type="text" data-cfg="topic" value="${escapeHtml(cfg.topic || '')}" placeholder="optional"></label>`;+ } else if (t.kind === 'weekly_digest') {+ body = `<label>Day: <select data-cfg="day_of_week">+ ${['Sun','Mon','Tue','Wed','Thu','Fri','Sat'].map((d, i) => `<option value="${i}" ${cfg.day_of_week === i ? 'selected' : ''}>${d}</option>`).join('')}+ </select></label>+ <label>Hour (UTC): <input type="number" min="0" max="23" data-cfg="hour_utc" value="${cfg.hour_utc ?? 14}"></label>`;+ } else if (t.kind === 'price_milestone') {+ body = `<label>Thresholds (USD, comma-separated): <input type="text" data-cfg="thresholds_usd" value="${(cfg.thresholds_usd || []).join(', ')}"></label>`;+ } else if (t.kind === 'payment_received') {+ body = `<label>Min amount (USD): <input type="number" min="0" step="0.01" data-cfg="min_amount_usd" value="${cfg.min_amount_usd ?? 1}"></label>`;+ }+ return `+ <div class="trigger-item" data-id="${escapeHtml(t.id)}">+ <div class="trigger-item-head">+ <div class="trigger-item-kind">${escapeHtml(triggerLabel(t.kind))}</div>+ <label style="display:inline-flex;align-items:center;gap:.5rem;font-size:.764rem;color:rgba(255,255,255,.6)">+ <input type="checkbox" class="trigger-enabled" ${t.enabled ? 'checked' : ''}> Enabled+ </label>+ <button class="chip-remove" data-del="${escapeHtml(t.id)}" title="Delete">×</button>+ </div>+ <div class="trigger-item-body">${body}</div>+ <div class="form-actions" style="margin-top:.5rem">+ <button class="btn-ghost trigger-save">Save</button>+ </div>+ </div>+ `;+ }).join('');++ container.querySelectorAll('.trigger-item').forEach((item) => {+ const id = item.dataset.id;+ item.querySelector('[data-del]').addEventListener('click', () => deleteTrigger(id));+ item.querySelector('.trigger-save').addEventListener('click', () => saveTrigger(item, id));+ item.querySelector('.trigger-enabled').addEventListener('change', (e) => saveTriggerEnabled(id, e.target.checked));+ });+}++function readTriggerConfig(item) {+ const cfg = {};+ item.querySelectorAll('[data-cfg]').forEach((el) => {+ const key = el.dataset.cfg;+ let val = el.value;+ if (el.type === 'number') val = Number(val);+ if (key === 'thresholds_usd') val = val.split(',').map((n) => Number(n.trim())).filter((n) => n > 0);+ if (key === 'day_of_week') val = Number(val);+ cfg[key] = val;+ });+ return cfg;+}++async function saveTrigger(item, id) {+ const cfg = readTriggerConfig(item);+ try {+ const r = await fetch(`${API_BASE}/x/triggers?id=${encodeURIComponent(id)}`, {+ method: 'PATCH',+ headers: { 'Content-Type': 'application/json' },+ credentials: 'include',+ body: JSON.stringify({ config: cfg }),+ });+ if (!r.ok) {+ const j = await r.json().catch(() => ({}));+ throw new Error(j.error_description || j.error || `HTTP ${r.status}`);+ }+ } catch (err) {+ alert(`Save failed: ${err.message}`);+ }+}++async function saveTriggerEnabled(id, enabled) {+ await fetch(`${API_BASE}/x/triggers?id=${encodeURIComponent(id)}`, {+ method: 'PATCH',+ headers: { 'Content-Type': 'application/json' },+ credentials: 'include',+ body: JSON.stringify({ enabled }),+ });+}++async function deleteTrigger(id) {+ if (!confirm('Delete this trigger?')) return;+ await fetch(`${API_BASE}/x/triggers?id=${encodeURIComponent(id)}`, { method: 'DELETE', credentials: 'include' });+ await loadXTriggers();+}++$('x-trigger-add').addEventListener('click', async () => {+ const kind = $('x-trigger-kind').value;+ const config = defaultTriggerConfig(kind);+ try {+ const r = await fetch(`${API_BASE}/x/triggers`, {+ method: 'POST',+ headers: { 'Content-Type': 'application/json' },+ credentials: 'include',+ body: JSON.stringify({ kind, config, agent_id: agentId, enabled: true }),+ });+ if (!r.ok) {+ const j = await r.json().catch(() => ({}));+ throw new Error(j.error_description || j.error || `HTTP ${r.status}`);+ }+ await loadXTriggers();+ } catch (err) {+ alert(`Add trigger failed: ${err.message}`);+ }+});++$('x-post-btn').addEventListener('click', async () => {+ const status = $('x-post-status');+ const text = $('x-post-text').value.trim();+ if (!text) {+ status.textContent = 'Tweet text required.';+ status.className = 'form-status err';+ return;+ }+ status.textContent = 'Posting…';+ status.className = 'form-status';+ try {+ const r = await fetch(`${API_BASE}/x/post`, {+ method: 'POST',+ headers: { 'Content-Type': 'application/json' },+ credentials: 'include',+ body: JSON.stringify({ text, agent_id: agentId }),+ });+ const j = await r.json().catch(() => ({}));+ if (!r.ok) throw new Error(j.error_description || j.error || `HTTP ${r.status}`);+ status.textContent = `Posted (${j.tweet_id || 'ok'}).`;+ status.className = 'form-status ok';+ $('x-post-text').value = '';+ loadXStatus();+ } catch (err) {+ status.textContent = `Error: ${err.message}`;+ status.className = 'form-status err';+ }+});++// ─────────────────────────────────────────────────────────────────────────────+// Analytics tab+// ─────────────────────────────────────────────────────────────────────────────++let analyticsTabMounted = false;++async function ensureAnalyticsTab() {+ if (analyticsTabMounted) return;+ analyticsTabMounted = true;+ await Promise.all([loadUsage(), loadPayments('received'), loadPayments('sent')]);+}++async function loadUsage() {+ try {+ const r = await fetch(`${API_BASE}/agents/${agentId}/usage`, { credentials: 'include' });+ if (!r.ok) throw new Error(`HTTP ${r.status}`);+ const j = await r.json();+ $('m-llm-month').textContent = String(j.currentMonthCalls ?? 0);+ const daily = j.dailyBreakdown || [];+ const total30 = daily.reduce((sum, d) => sum + (d.calls || 0), 0);+ $('m-llm-30d').textContent = String(total30);+ renderBarChart(daily);+ } catch (err) {+ $('m-llm-month').textContent = '—';+ $('m-llm-30d').textContent = '—';+ $('m-chart').innerHTML = `<div class="muted">Usage unavailable: ${escapeHtml(err.message)}</div>`;+ }+}++function renderBarChart(daily) {+ const container = $('m-chart');+ const byDay = new Map(daily.map((d) => [String(d.day).slice(0, 10), d.calls]));+ const cols = [];+ for (let i = 29; i >= 0; i--) {+ const d = new Date();+ d.setDate(d.getDate() - i);+ const key = d.toISOString().slice(0, 10);+ cols.push({ key, calls: byDay.get(key) || 0 });+ }+ const max = Math.max(1, ...cols.map((c) => c.calls));+ container.innerHTML = cols.map((c) => {+ const h = Math.round((c.calls / max) * 100);+ return `<div class="bar-chart-col" data-value="${c.calls}" style="height:${h}%" title="${c.key}: ${c.calls}"></div>`;+ }).join('');+}++async function loadPayments(direction) {+ const el = direction === 'received' ? $('m-pay-in') : $('m-pay-out');+ const totalEl = direction === 'received' ? $('m-earn-in') : $('m-earn-out');+ try {+ const r = await fetch(`${API_BASE}/agents/${agentId}/payments?direction=${direction}&limit=10`, { credentials: 'include' });+ if (!r.ok) throw new Error(`HTTP ${r.status}`);+ const j = await r.json();+ const rows = j.payments || j.data || [];+ let total = 0;+ rows.forEach((p) => { total += Number(p.amount_wei || 0) / 1e6; });+ totalEl.textContent = `$${total.toFixed(2)}`;+ if (!rows.length) { el.innerHTML = '<div class="muted">None yet.</div>'; return; }+ el.innerHTML = rows.slice(0, 10).map((p) => {+ const amt = (Number(p.amount_wei || 0) / 1e6).toFixed(2);+ const who = direction === 'received' ? (p.payer_name || p.payer_agent_id?.slice(0, 8)) : (p.payee_name || p.payee_agent_id?.slice(0, 8));+ const skill = p.skill_name || p.skill_slug || '';+ return `<div class="pay-item"><span>${escapeHtml(who || 'someone')}${skill ? ` · ${escapeHtml(skill)}` : ''}</span><span class="pay-amount${direction === 'sent' ? ' out' : ''}">$${amt}</span></div>`;+ }).join('');+ } catch {+ el.innerHTML = `<div class="muted">Unavailable.</div>`;+ totalEl.textContent = '—';+ }+}++// ─────────────────────────────────────────────────────────────────────────────+// Embed tab+// ─────────────────────────────────────────────────────────────────────────────++let embedTabMounted = false;++function embedOrigin() {+ return location.origin;+}++function ensureEmbedTab() {+ if (embedTabMounted) return;+ embedTabMounted = true;+ updateEmbedPreview();+ loadEmbedPolicy();+}++function parseSize(token) {+ const [w, h] = token.split('x');+ return { w, h };+}++function updateEmbedPreview() {+ const { w, h } = parseSize($('embed-size').value);+ const origin = embedOrigin();+ const embedUrl = `${origin}/agent/${agentId}/embed`;+ const pageUrl = `${origin}/agent/${agentId}`;+ const oembedUrl = `${origin}/api/oembed?url=${encodeURIComponent(pageUrl)}`;++ const iframeAttrs = `src="${embedUrl}" width="${w}" height="${h}" frameborder="0" allow="microphone; autoplay; clipboard-write" style="border:0;border-radius:12px;background:#000"`;+ $('embed-iframe-code').value = `<iframe ${iframeAttrs}></iframe>`;+ $('embed-link').value = pageUrl;+ $('embed-oembed').value = oembedUrl;+ $('embed-open').href = pageUrl;++ $('embed-preview').innerHTML = `<iframe ${iframeAttrs}></iframe>`;+}++async function loadEmbedPolicy() {+ try {+ const r = await fetch(`${API_BASE}/agents/${agentId}/embed-policy`, { credentials: 'include' });+ if (!r.ok) return;+ const j = await r.json();+ const origins = j.policy?.allowed_origins || [];+ $('embed-allowed-origins').value = origins.join('\n');+ } catch {+ // Policy is optional — silent.+ }+}++$('embed-size').addEventListener('change', updateEmbedPreview);++document.addEventListener('click', (e) => {+ const btn = e.target.closest('[data-copy]');+ if (!btn) return;+ const target = document.querySelector(btn.dataset.copy);+ if (!target) return;+ copyToClipboard(target.value);+ const original = btn.textContent;+ btn.textContent = 'Copied';+ setTimeout(() => { btn.textContent = original; }, 1200);+});++$('embed-policy-save').addEventListener('click', async () => {+ const status = $('embed-policy-status');+ const origins = $('embed-allowed-origins').value.split('\n').map((s) => s.trim()).filter(Boolean);+ status.textContent = 'Saving…';+ status.className = 'form-status';+ try {+ const r = await fetch(`${API_BASE}/agents/${agentId}/embed-policy`, {+ method: 'PUT',+ headers: { 'Content-Type': 'application/json' },+ credentials: 'include',+ body: JSON.stringify({ allowed_origins: origins }),+ });+ if (!r.ok) {+ const j = await r.json().catch(() => ({}));+ throw new Error(j.error_description || j.error || `HTTP ${r.status}`);+ }+ status.textContent = 'Saved.';+ status.className = 'form-status ok';+ } catch (err) {+ status.textContent = `Error: ${err.message}`;+ status.className = 'form-status err';+ }+});++$('embed-policy-clear').addEventListener('click', async () => {+ if (!confirm('Clear embed policy (allow embedding everywhere)?')) return;+ const status = $('embed-policy-status');+ status.textContent = 'Clearing…';+ status.className = 'form-status';+ try {+ const r = await fetch(`${API_BASE}/agents/${agentId}/embed-policy`, { method: 'DELETE', credentials: 'include' });+ if (!r.ok) throw new Error(`HTTP ${r.status}`);+ $('embed-allowed-origins').value = '';+ status.textContent = 'Cleared.';+ status.className = 'form-status ok';+ } catch (err) {+ status.textContent = `Error: ${err.message}`;+ status.className = 'form-status err';+ }+});++// ─────────────────────────────────────────────────────────────────────────────+// Widgets tab+// ─────────────────────────────────────────────────────────────────────────────++let widgetsTabMounted = false;++async function ensureWidgetsTab() {+ if (widgetsTabMounted) return;+ widgetsTabMounted = true;+ await loadWidgets();+}++async function loadWidgets() {+ const container = $('widgets-list');+ try {+ const r = await fetch(`${API_BASE}/widgets`, { credentials: 'include' });+ if (!r.ok) throw new Error(`HTTP ${r.status}`);+ const j = await r.json();+ const items = j.widgets || [];+ if (!items.length) {+ container.innerHTML = '<div class="muted">No widgets yet. Create one above.</div>';+ return;+ }+ container.innerHTML = items.map((w) => {+ const url = `${embedOrigin()}/embed.html?id=${encodeURIComponent(w.id)}`;+ return `+ <div class="widget-card" data-id="${escapeHtml(w.id)}">+ <div class="widget-card-type">${escapeHtml(w.type)}</div>+ <div class="widget-card-name">${escapeHtml(w.name || 'Untitled')}</div>+ <div class="widget-card-meta">${w.view_count || 0} views · ${w.is_public ? 'public' : 'private'}</div>+ <div class="form-actions">+ <a class="btn-ghost" href="${escapeHtml(url)}" target="_blank" rel="noopener">Open ›</a>+ <button class="btn-ghost" data-copy-text="${escapeHtml(url)}">Copy link</button>+ <button class="btn-ghost danger" data-del-widget="${escapeHtml(w.id)}">Delete</button>+ </div>+ </div>+ `;+ }).join('');+ container.querySelectorAll('[data-del-widget]').forEach((btn) => {+ btn.addEventListener('click', () => deleteWidget(btn.dataset.delWidget));+ });+ container.querySelectorAll('[data-copy-text]').forEach((btn) => {+ btn.addEventListener('click', () => {+ copyToClipboard(btn.dataset.copyText);+ const t = btn.textContent;+ btn.textContent = 'Copied';+ setTimeout(() => { btn.textContent = t; }, 1200);+ });+ });+ } catch (err) {+ container.innerHTML = `<div class="muted">Could not load widgets: ${escapeHtml(err.message)}</div>`;+ }+}++$('widget-new-btn').addEventListener('click', async () => {+ const status = $('widget-status');+ const type = $('widget-new-type').value;+ const name = $('widget-new-name').value.trim() || `${agentData.name || 'Agent'} ${type}`;+ if (!agentData.avatar_id) {+ status.textContent = 'Pick an avatar first (Outfit tab).';+ status.className = 'form-status err';+ return;+ }+ status.textContent = 'Creating…';+ status.className = 'form-status';+ try {+ const r = await fetch(`${API_BASE}/widgets`, {+ method: 'POST',+ headers: { 'Content-Type': 'application/json' },+ credentials: 'include',+ body: JSON.stringify({ type, name, avatar_id: agentData.avatar_id, config: { agent_id: agentId }, is_public: true }),+ });+ if (!r.ok) {+ const j = await r.json().catch(() => ({}));+ throw new Error(j.error_description || j.error || `HTTP ${r.status}`);+ }+ $('widget-new-name').value = '';+ status.textContent = 'Created.';+ status.className = 'form-status ok';+ await loadWidgets();+ } catch (err) {+ status.textContent = `Error: ${err.message}`;+ status.className = 'form-status err';+ }+});++async function deleteWidget(id) {+ if (!confirm('Delete this widget?')) return;+ try {+ const r = await fetch(`${API_BASE}/widgets/${id}`, { method: 'DELETE', credentials: 'include' });+ if (!r.ok) throw new Error(`HTTP ${r.status}`);+ await loadWidgets();+ } catch (err) {+ alert(`Delete failed: ${err.message}`);+ }+}++// ─────────────────────────────────────────────────────────────────────────────+// Studio tab+// ─────────────────────────────────────────────────────────────────────────────++let studioTabMounted = false;++function ensureStudioTab() {+ if (studioTabMounted) return;+ studioTabMounted = true;+ const origin = embedOrigin();+ $('studio-playground').href = `/playground.html?agent_id=${encodeURIComponent(agentId)}`;+ $('studio-avatar').href = agentData.avatar_id ? `/avatar-page.html?id=${encodeURIComponent(agentData.avatar_id)}` : '/dashboard/#avatars';+ $('studio-public').href = `/agent/${agentId}`;+ $('studio-manifest').href = `${origin}/api/agents/${agentId}/manifest`;++ const anims = agentData.meta?.animations || [];+ const animsEl = $('studio-animations');+ if (!anims.length) {+ animsEl.innerHTML = '<div class="muted">No animations attached.</div>';+ } else {+ animsEl.innerHTML = anims.map((a) => `<span class="chip">${escapeHtml(a.name)}${a.source ? ` <span class="voice-tile-meta">(${escapeHtml(a.source)})</span>` : ''}</span>`).join('');+ }+}++// ─────────────────────────────────────────────────────────────────────────────+// Danger zone+// ─────────────────────────────────────────────────────────────────────────────++$('danger-confirm').addEventListener('input', (e) => {+ $('danger-delete-btn').disabled = !agentData?.name || e.target.value.trim() !== agentData.name.trim();+});++$('danger-delete-btn').addEventListener('click', async () => {+ const status = $('danger-status');+ if ($('danger-confirm').value.trim() !== agentData.name) {+ status.textContent = 'Name does not match.';+ status.className = 'form-status err';+ return;+ }+ status.textContent = 'Deleting…';+ status.className = 'form-status';+ try {+ const r = await fetch(`${API_BASE}/agents/${agentId}`, { method: 'DELETE', credentials: 'include' });+ if (!r.ok) {+ const j = await r.json().catch(() => ({}));+ throw new Error(j.error_description || j.error || `HTTP ${r.status}`);+ }+ status.textContent = 'Deleted. Redirecting…';+ status.className = 'form-status ok';+ setTimeout(() => location.replace('/dashboard/'), 1000);+ } catch (err) {+ status.textContent = `Error: ${err.message}`;+ status.className = 'form-status err';+ }+});++// ─────────────────────────────────────────────────────────────────────────────+// Tab switching+// ─────────────────────────────────────────────────────────────────────────────++const TAB_LOADERS = {+ outfit: ensureOutfitTab,+ voice: ensureVoiceTab,+ knowledge: ensureKnowledgeTab,+ skills: ensureSkillsTab,+ wallet: ensureWalletTab,+ social: ensureSocialTab,+ analytics: ensureAnalyticsTab,+ embed: ensureEmbedTab,+ widgets: ensureWidgetsTab,+ studio: ensureStudioTab,+};++function activateTab(tabId) {+ document.querySelectorAll('.edit-tab').forEach((t) => {+ const active = t.dataset.tab === tabId;+ t.classList.toggle('active', active);+ t.setAttribute('aria-selected', active ? 'true' : 'false');+ });+ document.querySelectorAll('.edit-panel').forEach((p) => {+ const active = p.id === `panel-${tabId}`;+ p.classList.toggle('active', active);+ if (active) p.removeAttribute('hidden');+ else p.setAttribute('hidden', '');+ });+ if (agentData && TAB_LOADERS[tabId]) TAB_LOADERS[tabId]();+}++document.querySelectorAll('.edit-tab').forEach((tab) => {+ tab.addEventListener('click', (e) => activateTab(e.currentTarget.dataset.tab));+});++// Open a specific tab via ?tab=… (used by OAuth callback redirects).+async function init() {+ await loadAgent();+ if (!agentData) return;+ const params = new URLSearchParams(location.search);+ const initialTab = params.get('tab');+ if (initialTab && document.getElementById(`panel-${initialTab}`)) {+ activateTab(initialTab);+ }+}++init();diff --git a/src/avatar-page.js b/src/avatar-page.jsindex 611084cd6..fc4cabba6 100644--- a/src/avatar-page.js+++ b/src/avatar-page.js@@ -97,6 +97,7 @@ async function init() {loadSkills();loadPlugins();loadRelated();+ loadUsedBy();measureModel(glbUrl);}@@ -234,6 +235,10 @@ function renderShell(glbUrl) {<div class="av-panels"><div class="av-panel active" data-panel="overview" id="av-overview">${avatar.description ? `<p class="av-desc">${esc(avatar.description)}</p>` : '<p class="av-desc" style="color:var(--text-3)">No description provided.</p>'}+ <section class="av-used-by" id="av-used-by" hidden aria-labelledby="av-used-by-heading">+ <h3 class="av-used-by-heading" id="av-used-by-heading">Used by</h3>+ <div class="av-used-by-grid" id="av-used-by-grid"></div>+ </section>${renderAttribution()}${renderAttached()}</div>@@ -886,6 +891,38 @@ function buildSystemContext() {return parts.filter(Boolean).join('\n');}+// ── Agents wearing this avatar ────────────────────────────────────────++async function loadUsedBy() {+ const grid = $('av-used-by-grid');+ const section = $('av-used-by');+ if (!grid || !section) return;++ const r = await fetch(`/api/avatars/${encodeURIComponent(avatarId)}/agents`);+ if (!r.ok) return;+ const { agents } = await r.json();+ if (!Array.isArray(agents) || agents.length === 0) return;++ section.hidden = false;+ grid.innerHTML = agents+ .map((a) => {+ const thumb = a.profileImage+ ? `<img class="av-used-by-thumb" src="${esc(a.profileImage)}" alt="${esc(a.name)} avatar" loading="lazy" />`+ : `<div class="av-used-by-thumb av-used-by-thumb--placeholder" aria-hidden="true">${esc((a.name || 'A').slice(0, 1).toUpperCase())}</div>`;+ const badge = a.onchain+ ? `<span class="av-used-by-badge" title="Registered on-chain">on-chain</span>`+ : '';+ return `<a class="av-used-by-card" href="${esc(a.url)}" title="${esc(a.name)}">+ ${thumb}+ <div class="av-used-by-meta">+ <span class="av-used-by-name">${esc(a.name)}</span>+ ${badge}+ </div>+ </a>`;+ })+ .join('');+}+// ── Related avatars ───────────────────────────────────────────────────async function loadRelated() {diff --git a/src/pump/pump-modals.js b/src/pump/pump-modals.jsindex 0039a26e7..487ef5a2a 100644--- a/src/pump/pump-modals.js+++ b/src/pump/pump-modals.js@@ -396,20 +396,29 @@ function openLaunch({ identity, agentId, avatarId, formData }) {reader.readAsDataURL(formData.image);});}+ const descSource = description || formData?.description || identity?.description || '';+ const payload = {+ name: String(name).trim().slice(0, 32),+ symbol: String(symbol).trim().slice(0, 10),+ description: String(descSource).trim().slice(0, 500),+ ...(avatarId ? { avatar_id: avatarId } : {}),+ ...(agentId ? { agent_id: agentId } : {}),+ ...(imageDataUrl ? { image_data_url: imageDataUrl } : {}),+ };const resp = await fetch('/api/pump/build-metadata', {method: 'POST',headers: { 'content-type': 'application/json' },credentials: 'include',- body: JSON.stringify({- name,- symbol,- description: description || formData?.description || identity?.description || '',- ...(avatarId ? { avatar_id: avatarId } : {}),- ...(agentId ? { agent_id: agentId } : {}),- ...(imageDataUrl ? { image_data_url: imageDataUrl } : {}),- }),+ body: JSON.stringify(payload),});- if (!resp.ok) throw new Error(`Metadata build failed: ${resp.status}`);+ if (!resp.ok) {+ const errJson = await resp.json().catch(() => null);+ const detail = errJson?.error_description+ || errJson?.issues?.map((i) => `${i.path?.join('.') || 'body'}: ${i.message}`).join('; ')+ || errJson?.error+ || `HTTP ${resp.status}`;+ throw new Error(detail);+ }return resp.json();}@@ -420,11 +429,12 @@ function openLaunch({ identity, agentId, avatarId, formData }) {}function render() {- const nameDefault = formData?.name || identity?.name || 'Agent';+ const nameDefault = String(formData?.name || identity?.name || 'Agent').slice(0, 32);const symbolDefault = (formData?.symbol || nameDefault).toUpperCase().replace(/[^A-Z0-9]/g, '').slice(0, 8) || 'AGENT';+ const descDefault = String(formData?.description || identity?.description || '').slice(0, 500);inner.innerHTML = `<h3>Launch $${esc(symbolDefault)}</h3>@@ -452,7 +462,7 @@ function openLaunch({ identity, agentId, avatarId, formData }) {<label>Symbol</label><input type="text" id="pmodal-launch-symbol" maxlength="10" value="${esc(cachedSymbol)}" /><label>Description</label>- <textarea id="pmodal-launch-desc" rows="2" maxlength="500">${esc(formData?.description || identity?.description || '')}</textarea>+ <textarea id="pmodal-launch-desc" rows="2" maxlength="500">${esc(descDefault)}</textarea><div class="pmodal-sub" style="margin-top:0.5rem">Token image and metadata are generated automatically from your avatar.</div>`;} else if (step === 2) {diff --git a/style.css b/style.cssindex 009b1e3c2..662e07721 100644--- a/style.css+++ b/style.css@@ -74,7 +74,7 @@ html,body {margin: 0;padding: 0;- font-family: 'Inter', 'Raleway', sans-serif;+ font-family: 'Inter', system-ui, -apple-system, sans-serif;background: #000;height: 100%;overflow: hidden;diff --git a/three-ws-launch-week.html b/three-ws-launch-week.htmlindex 114338377..cb24bafbb 100644--- a/three-ws-launch-week.html+++ b/three-ws-launch-week.html@@ -6,7 +6,7 @@<title>three.ws — Launch Week Recap</title><meta property="og:title" content="three.ws — Launch Week Recap"><meta property="og:description" content="Open-source 3D AI agent platform for the browser. Week one in numbers and what we shipped.">-<link href="https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;500;600;700&family=Instrument+Serif:ital@0;1&family=DM+Sans:wght@300;400;500;600;700&display=swap" rel="stylesheet">+<link rel="stylesheet" href="/fonts/fonts.css" /><style>:root {--bg: #0a0a0b;diff --git a/tutorials.html b/tutorials.htmlindex cebcc4c6e..0a7646a4b 100644--- a/tutorials.html+++ b/tutorials.html@@ -26,17 +26,12 @@<link rel="canonical" href="https://three.ws/tutorials.html" /><link rel="shortcut icon" href="/favicon.ico" /><link rel="apple-touch-icon" href="/pwa-192x192.png" />- <link rel="preconnect" href="https://fonts.googleapis.com" />- <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin /><link rel="stylesheet" href="/style.css" /><link rel="stylesheet" href="/nav.css" /><link rel="stylesheet" href="/home.css" /><link rel="stylesheet" href="/footer.css" /><script defer src="/footer-newsletter.js"></script>- <link- href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400&family=Space+Grotesk:wght@500;600;700&display=swap"- rel="stylesheet"- />+ <link rel="stylesheet" href="/fonts/fonts.css" /><script type="module" src="https://ajax.googleapis.com/ajax/libs/model-viewer/4.0.0/model-viewer.min.js"></script><style>diff --git a/vercel.json b/vercel.jsonindex 9e8347da4..4c1938561 100644--- a/vercel.json+++ b/vercel.json@@ -188,6 +188,10 @@"src": "/launch-week/?","dest": "/three-ws-launch-week.html"},+ {+ "src": "/pricing/?",+ "dest": "/pricing.html"+ },{"src": "/deploy","dest": "/app.html"@@ -224,6 +228,30 @@"src": "/dashboard/embed-policy","dest": "/dashboard/embed-policy.html"},+ {+ "src": "/dashboard/memory",+ "dest": "/dashboard/memory.html"+ },+ {+ "src": "/dashboard/strategy",+ "dest": "/dashboard/strategy.html"+ },+ {+ "src": "/dashboard/voice",+ "dest": "/dashboard/voice.html"+ },+ {+ "src": "/dashboard/sns",+ "dest": "/dashboard/sns.html"+ },+ {+ "src": "/dashboard/delegation",+ "dest": "/dashboard/delegation.html"+ },+ {+ "src": "/dashboard/tokens",+ "dest": "/dashboard/tokens.html"+ },{"src": "/dashboard/(agents|avatars|create|upload|animations|widgets|embed|keys|mcp|monetization|payments|subscriptions|billing|revenue|earnings|account)/?","dest": "/dashboard/index.html"@@ -348,6 +376,10 @@"src": "/api/agents/([^/]+)/pumpfun/([^/]+)","dest": "/api/agents/[id]"},+ {+ "src": "/api/avatars/([^/]+)/agents",+ "dest": "/api/avatars/[id]/agents?id=$1"+ },{"src": "/api/avatars/([^/]+)/storage-mode","dest": "/api/avatars/[id]/storage-mode?id=$1"@@ -356,6 +388,10 @@"src": "/api/avatars/([^/]+)/pin-ipfs","dest": "/api/avatars/[id]/pin-ipfs?id=$1"},+ {+ "src": "/api/avatars/([^/]+)/thumbnail",+ "dest": "/api/avatars/[id]/thumbnail?id=$1"+ },{"src": "/dashboard/storage","dest": "/dashboard/storage.html"@@ -1152,6 +1188,24 @@"src": "/sitemap.xml","dest": "/sitemap.xml"},+ {+ "src": "/sitemap",+ "dest": "/sitemap/index.html"+ },+ {+ "src": "/sitemap/",+ "dest": "/sitemap/index.html"+ },+ {+ "src": "/llms.txt",+ "headers": { "content-type": "text/plain; charset=utf-8", "cache-control": "public, max-age=3600" },+ "dest": "/llms.txt"+ },+ {+ "src": "/llms-full.txt",+ "headers": { "content-type": "text/plain; charset=utf-8", "cache-control": "public, max-age=3600" },+ "dest": "/llms-full.txt"+ },{"src": "/app","dest": "/app.html"@@ -1302,6 +1356,10 @@"path": "/api/cron/run-x-triggers","schedule": "*/5 * * * *"},+ {+ "path": "/api/cron/fetch-x-metrics",+ "schedule": "0 */6 * * *"+ },{"path": "/api/cron/pumpfun-signals","schedule": "*/15 * * * *"diff --git a/vite.config.js b/vite.config.jsindex d590959b1..add2f3b16 100644--- a/vite.config.js+++ b/vite.config.js@@ -219,6 +219,8 @@ const appConfig = {'/eth-vanity/': resolve(root, 'public/eth-vanity.html'),'/strategy-lab': resolve(root, 'public/strategy-lab.html'),'/strategy-lab/': resolve(root, 'public/strategy-lab.html'),+ '/sitemap': resolve(root, 'public/sitemap/index.html'),+ '/sitemap/': resolve(root, 'public/sitemap/index.html'),'/': resolve(root, 'home.html'),'/home': resolve(root, 'home.html'),'/features': resolve(root, 'features.html'),diff --git a/widgets.html b/widgets.htmlindex bed5c1988..a21c14709 100644--- a/widgets.html+++ b/widgets.html@@ -53,14 +53,9 @@</style><link rel="canonical" href="https://three.ws/widgets" /><link rel="shortcut icon" href="/favicon.ico" />- <link rel="preconnect" href="https://fonts.googleapis.com" />- <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin /><link rel="stylesheet" href="/style.css" /><link rel="stylesheet" href="/marketplace.css" />- <link- href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap"- rel="stylesheet"- />+ <link rel="stylesheet" href="/fonts/fonts.css" /><link rel="stylesheet" href="/nav.css" /><link rel="stylesheet" href="/footer.css" /><script defer src="/footer-newsletter.js"></script>