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
fix: PayAI x402 resource shape, agents public by default, avatar coins, wallet/check, portfolio top-50
nirholased28f9e465f1
diff --git a/agent-payments-sdk/src/solana/x402/client.ts b/agent-payments-sdk/src/solana/x402/client.tsindex e3ccde9c7..f6e0d2087 100644--- a/agent-payments-sdk/src/solana/x402/client.ts+++ b/agent-payments-sdk/src/solana/x402/client.ts@@ -124,11 +124,16 @@ export function createX402Fetch(: input instanceof URL? input.href: input.url);+ // PayAI's facilitator rejects a bare-string `resource` with `invalid_payload`;+ // it requires the same `{url, mimeType}` ResourceInfo object as the 402 body.const paymentPayload: PaymentPayload = {x402Version: X402_VERSION,scheme: accepted.scheme,network: accepted.network,- resource: resourceUrl,+ resource: {+ url: resourceUrl,+ mimeType: paymentRequired.resource.mimeType ?? "application/json",+ },accepted,payload: proof,};diff --git a/agent-payments-sdk/src/solana/x402/types.ts b/agent-payments-sdk/src/solana/x402/types.tsindex d9502c1d4..7f5578259 100644--- a/agent-payments-sdk/src/solana/x402/types.ts+++ b/agent-payments-sdk/src/solana/x402/types.ts@@ -55,6 +55,8 @@ export interface ResourceInfo {url: string;/** Human-readable description */description?: string;+ /** MIME type of the response body (required on PaymentPayload.resource by PayAI) */+ mimeType?: string;}// ─── Payment Requirements (per-scheme offer in 402 body) ────────────────────@@ -119,8 +121,9 @@ export interface PaymentPayload {scheme: PaymentScheme;/** CAIP-2 network identifier (matches the chosen `accepts[]` entry) */network: string;- /** The resource URL this payment is for */- resource?: string;+ /** The resource this payment is for — PayAI's facilitator requires the+ * ResourceInfo object shape (bare string is rejected as invalid_payload). */+ resource?: ResourceInfo;/** Which accepted scheme/requirements this payment matches (full entry) */accepted: PaymentRequirements;/** Scheme-specific proof data */diff --git a/api/_lib/balances.js b/api/_lib/balances.jsindex 7859ec33f..b8a5e60dd 100644--- a/api/_lib/balances.js+++ b/api/_lib/balances.js@@ -68,12 +68,12 @@ async function getSolanaBalances(address) {const info = a.account?.data?.parsed?.info;if (!info) return null;const { mint, tokenAmount } = info;- if (!tokenAmount || tokenAmount.uiAmount === 0) return null;+ if (!tokenAmount || !tokenAmount.uiAmount || tokenAmount.uiAmount === 0) return null;return { mint, amount: tokenAmount.uiAmount, decimals: tokenAmount.decimals };}).filter(Boolean).sort((a, b) => b.amount - a.amount)- .slice(0, 9);+ .slice(0, 50);const mintList = fungible.map((t) => t.mint).join(',');let cgTokenPrices = {};@@ -121,6 +121,7 @@ async function getSolanaBalances(address) {tokens.push({ symbol, mint: t.mint, decimals: t.decimals, amount: t.amount, usd: t.amount * price, logo });}+ tokens.sort((a, b) => (b.usd || 0) - (a.usd || 0));return {chain: 'solana',address,@@ -167,7 +168,7 @@ async function getEvmBalances(address) {const rawTokens = (tokenBalResp.result?.tokenBalances ?? []).filter((t) => t.tokenBalance && t.tokenBalance !== '0x0' && t.tokenBalance !== '0x')- .slice(0, 9);+ .slice(0, 50);const metadataResults = await Promise.allSettled(rawTokens.map((t) =>@@ -222,6 +223,7 @@ async function getEvmBalances(address) {};});+ tokens.sort((a, b) => (b.usd || 0) - (a.usd || 0));return {chain: 'evm',address,diff --git a/api/_lib/migrations/2026-05-13-agents-default-public.sql b/api/_lib/migrations/2026-05-13-agents-default-public.sqlnew file mode 100644index 000000000..1b26006d7--- /dev/null+++ b/api/_lib/migrations/2026-05-13-agents-default-public.sql@@ -0,0 +1,19 @@+-- Agents are now public by default so newly-created agents are reachable+-- immediately by their owner-share links and public listings. Every INSERT+-- path in api/ omits is_public, so changing the column default is enough+-- to fix new rows; existing rows are backfilled because the prior false+-- default was effectively a bug — there is no UI to opt agents into private.+--+-- On databases that predate the original CREATE TABLE definition, is_public+-- never landed (it was only in the inline create, not an additive migration).+-- Add it here with the intended default in one step.++alter table agent_identities+ add column if not exists is_public boolean not null default true;++alter table agent_identities alter column is_public set default true;++update agent_identities+ set is_public = true+ where is_public = false+ and deleted_at is null;diff --git a/api/_lib/schema.sql b/api/_lib/schema.sqlindex fd2f94944..80a319814 100644--- a/api/_lib/schema.sql+++ b/api/_lib/schema.sql@@ -270,7 +270,7 @@ CREATE TABLE IF NOT EXISTS agent_identities (home_url text,avatar_url text,profile_image_url text,- is_public boolean NOT NULL DEFAULT false,+ is_public boolean NOT NULL DEFAULT true,is_template boolean NOT NULL DEFAULT false);@@ -298,6 +298,13 @@ alter table agent_identities add column if not exists persona_prompt_hash textalter table agent_identities add column if not exists persona_prompt_sig text;alter table agent_identities add column if not exists persona_tone_tags jsonb not null default '[]'::jsonb;alter table agent_identities add column if not exists persona_extracted_at timestamptz;+-- is_public arrived via inline CREATE on fresh DBs but never as an additive+-- migration, so pre-existing deployments are missing the column entirely —+-- that 500s /api/avatars/:id/agents. Add it and backfill to the new default.+alter table agent_identities add column if not exists is_public boolean not null default true;+alter table agent_identities alter column is_public set default true;+update agent_identities set is_public = true+ where is_public = false and deleted_at is null;-- ── agent_memories — the agent's persistent context ──────────────────────────create table if not exists agent_memories (@@ -1010,29 +1017,71 @@ CREATE INDEX IF NOT EXISTS agent_skill_prices_agent_id ON agent_skill_prices(age-- verified by /api/marketplace/purchase/:reference/confirm or by the-- /api/webhooks/solana-pay endpoint. See migration 2026-05-10-skill-purchases.sql.CREATE TABLE IF NOT EXISTS skill_purchases (- id UUID PRIMARY KEY DEFAULT gen_random_uuid(),- user_id UUID NOT NULL REFERENCES users(id) ON DELETE CASCADE,- agent_id UUID NOT NULL REFERENCES agent_identities(id) ON DELETE CASCADE,- skill TEXT NOT NULL,- status TEXT NOT NULL DEFAULT 'pending'- CHECK (status IN ('pending', 'confirmed', 'failed')),- reference TEXT NOT NULL UNIQUE,- tx_signature TEXT UNIQUE,- amount BIGINT NOT NULL,- currency_mint TEXT NOT NULL,- chain TEXT NOT NULL DEFAULT 'solana',- created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),- updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),- confirmed_at TIMESTAMPTZ+ id UUID PRIMARY KEY DEFAULT gen_random_uuid(),+ user_id UUID NOT NULL REFERENCES users(id) ON DELETE CASCADE,+ agent_id UUID NOT NULL REFERENCES agent_identities(id) ON DELETE CASCADE,+ skill TEXT NOT NULL,+ status TEXT NOT NULL DEFAULT 'pending'+ CHECK (status IN ('pending', 'confirmed', 'failed', 'expired', 'tipped', 'trial')),+ reference TEXT NOT NULL UNIQUE,+ tx_signature TEXT UNIQUE,+ amount BIGINT NOT NULL,+ currency_mint TEXT NOT NULL,+ chain TEXT NOT NULL DEFAULT 'solana',+ kind TEXT NOT NULL DEFAULT 'purchase'+ CHECK (kind IN ('purchase', 'trial', 'time_pass')),+ expires_at TIMESTAMPTZ, -- A3 pending TTL+ valid_until TIMESTAMPTZ, -- C3 time-bounded access (time_pass)+ trial_remaining INTEGER, -- C2 trial counter+ tipped_amount BIGINT, -- A6 mismatch-as-tip+ referrer_user_id UUID REFERENCES users(id), -- C6 referral attribution+ created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),+ updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),+ confirmed_at TIMESTAMPTZ);-CREATE UNIQUE INDEX IF NOT EXISTS skill_purchases_one_confirmed_per_user+-- 'confirmed' or 'trial' both count as active ownership for uniqueness.+CREATE UNIQUE INDEX IF NOT EXISTS skill_purchases_one_active_per_userON skill_purchases (user_id, agent_id, skill)- WHERE status = 'confirmed';+ WHERE status IN ('confirmed', 'trial');CREATE INDEX IF NOT EXISTS skill_purchases_user_agent ON skill_purchases (user_id, agent_id);CREATE INDEX IF NOT EXISTS skill_purchases_agent ON skill_purchases (agent_id);CREATE INDEX IF NOT EXISTS skill_purchases_status_created ON skill_purchases (status, created_at DESC);+CREATE INDEX IF NOT EXISTS skill_purchases_expires_at+ ON skill_purchases (expires_at)+ WHERE status = 'pending' AND expires_at IS NOT NULL;++-- ── purchase_receipts ────────────────────────────────────────────────────────+-- Append-only signed receipts for confirmed skill purchases. See+-- api/_lib/purchase-confirm.js and migration 2026-05-10-monetization-v2.sql.+CREATE TABLE IF NOT EXISTS purchase_receipts (+ id UUID PRIMARY KEY DEFAULT gen_random_uuid(),+ purchase_id UUID NOT NULL REFERENCES skill_purchases(id) ON DELETE CASCADE,+ receipt_json JSONB NOT NULL,+ signature TEXT NOT NULL, -- HMAC-SHA256 over canonical receipt_json+ created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),+ UNIQUE (purchase_id)+);++CREATE INDEX IF NOT EXISTS purchase_receipts_created_at+ ON purchase_receipts (created_at DESC);++-- ── purchase_events ──────────────────────────────────────────────────────────+-- Funnel telemetry for the purchase lifecycle.+CREATE TABLE IF NOT EXISTS purchase_events (+ id BIGSERIAL PRIMARY KEY,+ purchase_id UUID REFERENCES skill_purchases(id) ON DELETE CASCADE,+ event TEXT NOT NULL,+ payload JSONB NOT NULL DEFAULT '{}'::jsonb,+ created_at TIMESTAMPTZ NOT NULL DEFAULT NOW()+);++CREATE INDEX IF NOT EXISTS purchase_events_purchase+ ON purchase_events (purchase_id, created_at DESC);++CREATE INDEX IF NOT EXISTS purchase_events_event_time+ ON purchase_events (event, created_at DESC);-- ── agent_payment_intents ────────────────────────────────────────────────────-- Generic payment intent (subscriptions, one-shot, x402 invocations). Skilldiff --git a/api/auth/wallets/[action].js b/api/auth/wallets/[action].jsindex c51f23bd4..80525657f 100644--- a/api/auth/wallets/[action].js+++ b/api/auth/wallets/[action].js@@ -1,15 +1,16 @@// Wallet endpoints — dispatched by req.query.action.// GET /api/auth/wallets → handleListWallets (action undefined)// POST /api/auth/wallets → handleLinkWallet (action undefined)+// GET /api/auth/wallets/check → handleCheck (action === 'check')// POST /api/auth/wallets/nonce → handleNonce (action === 'nonce')// POST /api/auth/wallets/nonce-solana → handleNonceSolana (action === 'nonce-solana')// POST /api/auth/wallets/link-solana → handleLinkSolana (action === 'link-solana')// DELETE /api/auth/wallets/<address> → handleUnlinkWallet (action === <address>)//// Dispatcher convention: undefined action → index (GET/POST), reserved literal-// actions handle nonce/link flows, and anything else is treated as an address-// for DELETE. _link-nonces.js remains a separate helper (underscore-prefixed,-// not file-routed by Vercel).+// actions handle nonce/link/check flows, and anything else is treated as an+// address for DELETE. _link-nonces.js remains a separate helper (underscore-+// prefixed, not file-routed by Vercel).import { verifyMessage, getAddress } from 'ethers';import { z } from 'zod';@@ -44,6 +45,11 @@ export default wrap(async (req, res) => {return handleIndex(req, res);}+ // /api/auth/wallets/check — cheap pre-check: is this address already linked to the session user?+ if (action === 'check') {+ return handleCheck(req, res);+ }+// /api/auth/wallets/nonce — issue link nonce (EVM/SIWE)if (action === 'nonce') {return handleNonce(req, res);@@ -195,6 +201,43 @@ async function handleLinkWallet(userId, req, res) {return json(res, 201, { wallet: { address: claimed, chain_id: chainId } });}+// ── Check ──────────────────────────────────────────────────────────────────+// GET /api/auth/wallets/check?chain_type=<solana|evm>&address=<addr>+// Returns { linked: bool } — true iff the address is already linked to the+// session user with a matching chain_type. Used by the Solana deploy flow+// to skip the SIWS prompt when the wallet is already linked. Unauthenticated+// callers get { linked: false } (200) — the address simply isn't linked to+// "the current session" when there is no session.++const checkAddressRe = /^[A-Za-z0-9]{1,128}$/;++async function handleCheck(req, res) {+ if (cors(req, res, { methods: 'GET,OPTIONS', credentials: true })) return;+ if (!method(req, res, ['GET'])) return;++ const session = await getSessionUser(req);+ if (!session) return json(res, 200, { linked: false });++ const chainType = String(req.query?.chain_type || '').toLowerCase();+ const address = String(req.query?.address || '');+ if (!chainType || !address || !checkAddressRe.test(address)) {+ return error(res, 400, 'invalid_request', 'chain_type and address required');+ }++ // EVM addresses normalize to lowercase; Solana base58 is case-sensitive.+ const addrLookup = chainType === 'solana' ? address : address.toLowerCase();++ const rows = await sql`+ select 1 from user_wallets+ where user_id = ${session.id}+ and address = ${addrLookup}+ and chain_type = ${chainType}+ limit 1+ `;++ return json(res, 200, { linked: rows.length > 0 });+}+// ── Nonce ──────────────────────────────────────────────────────────────────// Issue a nonce + EIP-4361 (SIWE) message for wallet linking.// Caller must already be authenticated; the resulting message ties the walletdiff --git a/api/avatars/[id]/[action].js b/api/avatars/[id]/[action].jsindex 6c09b32b2..5bf9d75bd 100644--- a/api/avatars/[id]/[action].js+++ b/api/avatars/[id]/[action].js@@ -33,6 +33,8 @@ export default wrap(async (req, res) => {switch (action) {case 'agents':return handleAgentsByAvatar(req, res);+ case 'coins':+ return handleCoinsByAvatar(req, res);case 'glb-versions':return handleGlbVersions(req, res);case 'pin-ipfs':@@ -98,6 +100,64 @@ async function handleAgentsByAvatar(req, res) {return json(res, 200, { agents });}+// ── coins (pump.fun mints linked to agents wearing this avatar) ───────────+// GET /api/avatars/:id/coins+// Lists every pump_agent_mints row whose owning agent_identity has avatar_id+// = :id and is public. Demo avatars short-circuit to []. One coin per agent+// (most recent if an agent has multiple).++async function handleCoinsByAvatar(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, { coins: [] });+ }++ const rows = await sql`+ SELECT DISTINCT ON (pam.agent_id)+ pam.id, pam.mint, pam.network, pam.name, pam.symbol,+ pam.buyback_bps, pam.agent_authority, pam.metadata_uri,+ pam.created_at,+ ai.id AS agent_id, ai.name AS agent_name+ FROM pump_agent_mints pam+ JOIN agent_identities ai+ ON ai.id = pam.agent_id+ AND ai.deleted_at IS NULL+ AND ai.is_public = true+ WHERE ai.avatar_id = ${id}+ ORDER BY pam.agent_id, pam.created_at DESC+ `;++ const coins = rows.map((r) => ({+ id: r.id,+ mint: r.mint,+ network: r.network,+ name: r.name,+ symbol: r.symbol,+ buybackBps: r.buyback_bps,+ agentAuthority: r.agent_authority,+ metadataUri: r.metadata_uri,+ createdAt: r.created_at,+ agentId: r.agent_id,+ agentName: r.agent_name,+ agentUrl: `/agent/${r.agent_id}`,+ pumpfunUrl:+ r.network === 'devnet'+ ? `https://explorer.solana.com/address/${r.mint}?cluster=devnet`+ : `https://pump.fun/${r.mint}`,+ }));++ res.setHeader('cache-control', 'public, max-age=30, s-maxage=120, stale-while-revalidate=600');+ return json(res, 200, { coins });+}+// ── glb-versions ───────────────────────────────────────────────────────────async function handleGlbVersions(req, res) {diff --git a/api/chat.js b/api/chat.jsindex e5da95637..933242b27 100644--- a/api/chat.js+++ b/api/chat.js@@ -278,10 +278,24 @@ export default wrap(async (req, res) => {status: upstream.status,body: text.slice(0, 400),});- if (process.env.DEBUG === 'true') {- console.warn(`[chat:${route.name}]`, upstream.status, text.slice(0, 400));+ // Always log — diagnosing prod 502s without provider context is hopeless.+ console.warn(`[chat:${route.name}]`, upstream.status, text.slice(0, 400));+ // Surface the upstream reason in the response body. Strip any API-key+ // fragments out of defence; the body is generally short JSON like+ // {"error":{"type":"invalid_request_error","message":"..."}}.+ let upstreamMessage = '';+ try {+ const parsed = JSON.parse(text);+ upstreamMessage = parsed?.error?.message || parsed?.message || '';+ } catch {+ upstreamMessage = text.slice(0, 200);}- return error(res, 502, 'upstream_error', `chat backend returned ${upstream.status}`);+ return error(+ res,+ 502,+ 'upstream_error',+ `${route.name} returned ${upstream.status}${upstreamMessage ? `: ${upstreamMessage}` : ''}`,+ );}res.writeHead(200, {diff --git a/api/users/me/purchased-skills.js b/api/users/me/purchased-skills.jsindex f3b31a122..ffb612e45 100644--- a/api/users/me/purchased-skills.js+++ b/api/users/me/purchased-skills.js@@ -36,7 +36,7 @@ export default wrap(async (req, res) => {sp.trial_remaining,sp.created_at,ai.name AS agent_name,- ai.thumbnail_url AS agent_thumbnail+ ai.profile_image_url AS agent_thumbnailFROM skill_purchases spLEFT JOIN agent_identities ai ON ai.id = sp.agent_idWHERE sp.user_id = ${userId} AND sp.status IN ('confirmed', 'trial')diff --git a/api/x402-pay.js b/api/x402-pay.jsindex 195e58211..771610241 100644--- a/api/x402-pay.js+++ b/api/x402-pay.js@@ -344,9 +344,10 @@ async function buildSolanaPaymentPayload({ accept, buyer, conn, resourceUrl }) {x402Version: 2,scheme: 'exact',network: accept.network,- // v2 spec: resource is a string URL on the PaymentPayload. The mimeType- // belongs on the 402-challenge top-level resource object, not on the payload.- resource: resourceUrl,+ // PayAI's v2 facilitator schema rejects a bare-string `resource` with+ // `invalid_payload` — it requires the same `{url, mimeType}` object+ // shape as the 402-challenge top-level resource. Keep them aligned.+ resource: { url: resourceUrl, mimeType: 'application/json' },accepted: accept,payload: { transaction: txBase64 },};diff --git a/avatar-page.html b/avatar-page.htmlindex 3e53b8299..bfc1fcd10 100644--- a/avatar-page.html+++ b/avatar-page.html@@ -624,6 +624,85 @@font-weight: 600;}+ /* ── Linked coins (pump.fun mints on agents wearing this avatar) ── */+ .av-coins {+ margin-top: 18px;+ padding-top: 16px;+ border-top: 1px solid var(--border);+ }+ .av-coins-heading {+ font-size: 11px;+ text-transform: uppercase;+ letter-spacing: 0.08em;+ color: var(--text-3);+ margin: 0 0 10px;+ font-weight: 600;+ }+ .av-coins-grid {+ display: grid;+ grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));+ gap: 8px;+ }+ .av-coin-card {+ display: flex;+ flex-direction: column;+ gap: 6px;+ padding: 10px 12px;+ 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-coin-card:hover {+ border-color: rgba(253, 224, 71, 0.45);+ transform: translateY(-1px);+ }+ .av-coin-head {+ display: flex;+ align-items: center;+ justify-content: space-between;+ gap: 8px;+ }+ .av-coin-symbol {+ font-family: 'Space Grotesk', sans-serif;+ font-size: 13px;+ font-weight: 700;+ color: var(--warn);+ letter-spacing: 0.04em;+ }+ .av-coin-net {+ font-size: 9px;+ letter-spacing: 0.08em;+ text-transform: uppercase;+ color: var(--text-3);+ border: 1px solid var(--border-2);+ border-radius: 999px;+ padding: 1px 7px;+ }+ .av-coin-name {+ font-size: 12px;+ color: var(--text);+ white-space: nowrap;+ overflow: hidden;+ text-overflow: ellipsis;+ }+ .av-coin-mint {+ font-family: ui-monospace, 'SF Mono', monospace;+ font-size: 10px;+ color: var(--text-3);+ white-space: nowrap;+ overflow: hidden;+ text-overflow: ellipsis;+ }+ .av-coin-agent {+ font-size: 10px;+ color: var(--text-3);+ }+ .av-coin-agent a { color: var(--accent-2); text-decoration: none; }+ .av-coin-agent a:hover { color: var(--text); }+/* ── Embed panel ─────────────────────────────────── */.av-embed-section { margin-bottom: 18px; }.av-embed-label {diff --git a/package-lock.json b/package-lock.jsonindex 48bc86b03..b6c70b829 100644--- a/package-lock.json+++ b/package-lock.json@@ -62,6 +62,7 @@"jose": "^5.9.6","livekit-client": "^2.18.8","node-fetch": "^3.3.2",+ "qrcode": "^1.5.4","query-string": "^8.1.0","resend": "^6.12.2","sas-lib": "^1.0.10",@@ -11907,6 +11908,99 @@"qrcode": "1.5.3"}},+ "node_modules/@reown/appkit-ui/node_modules/camelcase": {+ "version": "5.3.1",+ "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-5.3.1.tgz",+ "integrity": "sha512-L28STB170nwWS63UjtlEOE3dldQApaJXZkOI1uMFfzf3rRuPegHaHesyee+YxQ+W6SvRDQV6UrdOdRiR153wJg==",+ "license": "MIT",+ "engines": {+ "node": ">=6"+ }+ },+ "node_modules/@reown/appkit-ui/node_modules/cliui": {+ "version": "6.0.0",+ "resolved": "https://registry.npmjs.org/cliui/-/cliui-6.0.0.tgz",+ "integrity": "sha512-t6wbgtoCXvAzst7QgXxJYqPt0usEfbgQdftEPbLL/cvv6HPE5VgvqCuAIDR0NgU52ds6rFwqrgakNLrHEjCbrQ==",+ "license": "ISC",+ "dependencies": {+ "string-width": "^4.2.0",+ "strip-ansi": "^6.0.0",+ "wrap-ansi": "^6.2.0"+ }+ },+ "node_modules/@reown/appkit-ui/node_modules/qrcode": {+ "version": "1.5.3",+ "resolved": "https://registry.npmjs.org/qrcode/-/qrcode-1.5.3.tgz",+ "integrity": "sha512-puyri6ApkEHYiVl4CFzo1tDkAZ+ATcnbJrJ6RiBM1Fhctdn/ix9MTE3hRph33omisEbC/2fcfemsseiKgBPKZg==",+ "license": "MIT",+ "dependencies": {+ "dijkstrajs": "^1.0.1",+ "encode-utf8": "^1.0.3",+ "pngjs": "^5.0.0",+ "yargs": "^15.3.1"+ },+ "bin": {+ "qrcode": "bin/qrcode"+ },+ "engines": {+ "node": ">=10.13.0"+ }+ },+ "node_modules/@reown/appkit-ui/node_modules/wrap-ansi": {+ "version": "6.2.0",+ "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-6.2.0.tgz",+ "integrity": "sha512-r6lPcBGxZXlIcymEu7InxDMhdW0KDxpLgoFLcguasxCaJ/SOIZwINatK9KY/tf+ZrlywOKU0UDj3ATXUBfxJXA==",+ "license": "MIT",+ "dependencies": {+ "ansi-styles": "^4.0.0",+ "string-width": "^4.1.0",+ "strip-ansi": "^6.0.0"+ },+ "engines": {+ "node": ">=8"+ }+ },+ "node_modules/@reown/appkit-ui/node_modules/y18n": {+ "version": "4.0.3",+ "resolved": "https://registry.npmjs.org/y18n/-/y18n-4.0.3.tgz",+ "integrity": "sha512-JKhqTOwSrqNA1NY5lSztJ1GrBiUodLMmIZuLiDaMRJ+itFd+ABVE8XBjOvIWL+rSqNDC74LCSFmlb/U4UZ4hJQ==",+ "license": "ISC"+ },+ "node_modules/@reown/appkit-ui/node_modules/yargs": {+ "version": "15.4.1",+ "resolved": "https://registry.npmjs.org/yargs/-/yargs-15.4.1.tgz",+ "integrity": "sha512-aePbxDmcYW++PaqBsJ+HYUFwCdv4LVvdnhBy78E57PIor8/OVvhMrADFFEDh8DHDFRv/O9i3lPhsENjO7QX0+A==",+ "license": "MIT",+ "dependencies": {+ "cliui": "^6.0.0",+ "decamelize": "^1.2.0",+ "find-up": "^4.1.0",+ "get-caller-file": "^2.0.1",+ "require-directory": "^2.1.1",+ "require-main-filename": "^2.0.0",+ "set-blocking": "^2.0.0",+ "string-width": "^4.2.0",+ "which-module": "^2.0.0",+ "y18n": "^4.0.0",+ "yargs-parser": "^18.1.2"+ },+ "engines": {+ "node": ">=8"+ }+ },+ "node_modules/@reown/appkit-ui/node_modules/yargs-parser": {+ "version": "18.1.3",+ "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-18.1.3.tgz",+ "integrity": "sha512-o50j0JeToy/4K6OZcaQmW6lyXXKhq7csREXcDwk2omFPJEwUNOVtJKvmDr9EI1fAJZUyZcRF7kxGBWmRXudrCQ==",+ "license": "ISC",+ "dependencies": {+ "camelcase": "^5.0.0",+ "decamelize": "^1.2.0"+ },+ "engines": {+ "node": ">=6"+ }+ },"node_modules/@reown/appkit-utils": {"version": "1.7.2","resolved": "https://registry.npmjs.org/@reown/appkit-utils/-/appkit-utils-1.7.2.tgz",@@ -36788,13 +36882,12 @@"license": "MIT"},"node_modules/qrcode": {- "version": "1.5.3",- "resolved": "https://registry.npmjs.org/qrcode/-/qrcode-1.5.3.tgz",- "integrity": "sha512-puyri6ApkEHYiVl4CFzo1tDkAZ+ATcnbJrJ6RiBM1Fhctdn/ix9MTE3hRph33omisEbC/2fcfemsseiKgBPKZg==",+ "version": "1.5.4",+ "resolved": "https://registry.npmjs.org/qrcode/-/qrcode-1.5.4.tgz",+ "integrity": "sha512-1ca71Zgiu6ORjHqFBDpnSMTR2ReToX4l1Au1VFLyVeBTFavzQnv5JxMFr3ukHVKpSrSA2MCk0lNJSykjUfz7Zg==","license": "MIT","dependencies": {"dijkstrajs": "^1.0.1",- "encode-utf8": "^1.0.3","pngjs": "^5.0.0","yargs": "^15.3.1"},diff --git a/package.json b/package.jsonindex 9babd002a..fce7a22b8 100644--- a/package.json+++ b/package.json@@ -130,6 +130,7 @@"jose": "^5.9.6","livekit-client": "^2.18.8","node-fetch": "^3.3.2",+ "qrcode": "^1.5.4","query-string": "^8.1.0","resend": "^6.12.2","sas-lib": "^1.0.10",diff --git a/public/dashboard/index.html b/public/dashboard/index.htmlindex 070d710e6..448a8e5bc 100644--- a/public/dashboard/index.html+++ b/public/dashboard/index.html@@ -1192,6 +1192,7 @@</header><div class="layout"><aside>+ <a href="/dashboard/portfolio">Portfolio & NFTs</a><a href="/dashboard/avatars" class="active" data-tab="avatars">Avatars</a><a href="/dashboard/agents" data-tab="agents">Agents</a><a href="/dashboard/create" data-tab="create">Create from selfie</a>@@ -1208,7 +1209,6 @@<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 & NFTs</a><a href="/dashboard/wallets">Wallets</a><a href="/vanity-wallet">Vanity wallet ✦</a><a href="/eth-vanity">ETH vanity (CREATE2) ✦</a>diff --git a/public/settings/index.html b/public/settings/index.htmlindex 866c3bc8c..0104c5c47 100644--- a/public/settings/index.html+++ b/public/settings/index.html@@ -640,7 +640,7 @@// ── Privacy (stored in localStorage until backend supports it) ──const PRIV_KEY = '3dagent:default-vis';- document.getElementById('sel-default-vis').value = localStorage.getItem(PRIV_KEY) || 'private';+ document.getElementById('sel-default-vis').value = localStorage.getItem(PRIV_KEY) || 'public';document.getElementById('save-privacy-btn').addEventListener('click', () => {const val = document.getElementById('sel-default-vis').value;localStorage.setItem(PRIV_KEY, val);diff --git a/publish/src/account.js b/publish/src/account.jsindex 431b659f1..ece4e2394 100644--- a/publish/src/account.js+++ b/publish/src/account.js@@ -128,7 +128,7 @@ export async function saveRemoteGlbToAccount(source, meta = {}) {checksum_sha256: checksum,name: meta.name || deriveAvatarName(source, checksum),description: meta.description,- visibility: meta.visibility || 'private',+ visibility: meta.visibility || 'public',tags: meta.tags || [],source: meta.source || 'upload',source_meta: sourceMeta,diff --git a/publish/src/erc8004/solana-deploy.js b/publish/src/erc8004/solana-deploy.jsindex fe310e607..29ded03cd 100644--- a/publish/src/erc8004/solana-deploy.js+++ b/publish/src/erc8004/solana-deploy.js@@ -25,9 +25,16 @@ export function detectSolanaWallet() {return null;}+// Route through our same-origin proxy. The public mainnet RPC returns 403 to+// most browser origins; the proxy forwards server-side to Helius when+// HELIUS_API_KEY is set, otherwise to the public RPC from a datacentre IP.+const SOLANA_RPC_ORIGIN =+ typeof window !== 'undefined' && window.location?.origin+ ? window.location.origin+ : 'https://three.ws';export const SOLANA_RPC = {- mainnet: 'https://api.mainnet-beta.solana.com',- devnet: 'https://api.devnet.solana.com',+ mainnet: `${SOLANA_RPC_ORIGIN}/api/solana-rpc`,+ devnet: `${SOLANA_RPC_ORIGIN}/api/solana-rpc?net=devnet`,};const RPC = SOLANA_RPC;diff --git a/publish/src/onchain/adapters/solana.js b/publish/src/onchain/adapters/solana.jsindex b51ef9c6c..86e6e1550 100644--- a/publish/src/onchain/adapters/solana.js+++ b/publish/src/onchain/adapters/solana.js@@ -16,9 +16,16 @@ import { Connection, Transaction, VersionedTransaction } from '@solana/web3.js';import { WalletAdapter } from './base.js';import { solana } from '../chain-ref.js';+// Route through our same-origin proxy. The public mainnet RPC returns 403 to+// most browser origins; the proxy forwards server-side to Helius when+// HELIUS_API_KEY is set. Absolute URL because Connection() derives a WS URL.+const RPC_ORIGIN =+ typeof window !== 'undefined' && window.location?.origin+ ? window.location.origin+ : 'https://three.ws';const RPC = {- mainnet: 'https://api.mainnet-beta.solana.com',- devnet: 'https://api.devnet.solana.com',+ mainnet: `${RPC_ORIGIN}/api/solana-rpc`,+ devnet: `${RPC_ORIGIN}/api/solana-rpc?net=devnet`,};function detect(preferred) {diff --git a/publish/src/onchain/payments/pumpfun-payments.js b/publish/src/onchain/payments/pumpfun-payments.jsindex fa896fc3f..1bdc95128 100644--- a/publish/src/onchain/payments/pumpfun-payments.js+++ b/publish/src/onchain/payments/pumpfun-payments.js@@ -15,9 +15,14 @@import { Connection, Transaction, VersionedTransaction } from '@solana/web3.js';import { getAdapter as getWalletAdapter } from '../adapters/index.js';+// Route through our same-origin proxy. Public mainnet RPC 403s most browsers.+const RPC_ORIGIN =+ typeof window !== 'undefined' && window.location?.origin+ ? window.location.origin+ : 'https://three.ws';const SOLANA_RPC = {- mainnet: 'https://api.mainnet-beta.solana.com',- devnet: 'https://api.devnet.solana.com',+ mainnet: `${RPC_ORIGIN}/api/solana-rpc`,+ devnet: `${RPC_ORIGIN}/api/solana-rpc?net=devnet`,};function decodeTx(b64) {diff --git a/publish/src/onchain/tokens/pumpfun.js b/publish/src/onchain/tokens/pumpfun.jsindex b1f9dd38f..96163e1ba 100644--- a/publish/src/onchain/tokens/pumpfun.js+++ b/publish/src/onchain/tokens/pumpfun.js@@ -19,9 +19,14 @@ import { Connection, Transaction, VersionedTransaction } from '@solana/web3.js';import { TokenAdapter } from './base.js';import { getAdapter as getWalletAdapter } from '../adapters/index.js';+// Route through our same-origin proxy. Public mainnet RPC 403s most browsers.+const RPC_ORIGIN =+ typeof window !== 'undefined' && window.location?.origin+ ? window.location.origin+ : 'https://three.ws';const SOLANA_RPC = {- mainnet: 'https://api.mainnet-beta.solana.com',- devnet: 'https://api.devnet.solana.com',+ mainnet: `${RPC_ORIGIN}/api/solana-rpc`,+ devnet: `${RPC_ORIGIN}/api/solana-rpc?net=devnet`,};function decodeTx(b64) {diff --git a/publish/src/pump/agent-token-widget.js b/publish/src/pump/agent-token-widget.jsindex 3dfa8ac3e..b814854f8 100644--- a/publish/src/pump/agent-token-widget.js+++ b/publish/src/pump/agent-token-widget.js@@ -289,10 +289,14 @@ export class AgentTokenWidget {if (this._wsUnsubs.length) return; // already subscribedtry {const [{ Connection, PublicKey }] = await Promise.all([import('@solana/web3.js')]);+ // Route through our same-origin proxy. Public mainnet RPC 403s most+ // browser origins. NOTE: WS subscriptions still go direct to the+ // derived ws:// URL; proxying WS is a separate concern.+ const rpcOrigin = window.location?.origin || 'https://three.ws';const url =this.token.network === 'devnet'- ? 'https://api.devnet.solana.com'- : 'https://api.mainnet-beta.solana.com';+ ? `${rpcOrigin}/api/solana-rpc?net=devnet`+ : `${rpcOrigin}/api/solana-rpc`;const conn = new Connection(url, 'confirmed');this._wsConn = conn;const subscribe = (addr, name) => {diff --git a/publish/src/pump/pump-modals.js b/publish/src/pump/pump-modals.jsindex fdad6cb1a..6ab94d72b 100644--- a/publish/src/pump/pump-modals.js+++ b/publish/src/pump/pump-modals.js@@ -121,10 +121,17 @@ import {ASSOCIATED_TOKEN_PROGRAM_ID,} from '@solana/spl-token';+// Route through our same-origin proxy. The public mainnet RPC returns 403 to+// most browser origins; the proxy forwards server-side to Helius when+// HELIUS_API_KEY is set.+const RPC_ORIGIN =+ typeof window !== 'undefined' && window.location?.origin+ ? window.location.origin+ : 'https://three.ws';const RPC = (network) =>network === 'devnet'- ? 'https://api.devnet.solana.com'- : 'https://api.mainnet-beta.solana.com';+ ? `${RPC_ORIGIN}/api/solana-rpc?net=devnet`+ : `${RPC_ORIGIN}/api/solana-rpc`;const USDC_MINT = {mainnet: 'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v',diff --git a/scripts/verify-x402-wire.mjs b/scripts/verify-x402-wire.mjsindex 4ca34049f..df70c5f95 100644--- a/scripts/verify-x402-wire.mjs+++ b/scripts/verify-x402-wire.mjs@@ -75,7 +75,9 @@ const sdkPayload = {x402Version: 2,scheme: accept.scheme,network: accept.network,- resource: 'https://three.ws/api/mcp',+ // PayAI's facilitator requires the ResourceInfo object form on the payload,+ // not a bare URL string — a string triggers `invalid_payload` on /verify.+ resource: { url: 'https://three.ws/api/mcp', mimeType: 'application/json' },accepted: accept,payload: { transaction: 'base64...', payer: '11111111111111111111111111111111' },};diff --git a/src/account.js b/src/account.jsindex 69a970f77..0cfd68996 100644--- a/src/account.js+++ b/src/account.js@@ -128,7 +128,7 @@ export async function saveRemoteGlbToAccount(source, meta = {}) {checksum_sha256: checksum,name: meta.name || deriveAvatarName(source, checksum),description: meta.description,- visibility: meta.visibility || 'private',+ visibility: meta.visibility || 'public',tags: meta.tags || [],source: meta.source || 'upload',source_meta: sourceMeta,diff --git a/src/agent-detail.js b/src/agent-detail.jsindex 6e5b72b30..44dc367ff 100644--- a/src/agent-detail.js+++ b/src/agent-detail.js@@ -695,7 +695,10 @@ const getProvider = () => {};let wallet = null;-const connection = new solanaWeb3.Connection(solanaWeb3.clusterApiUrl('devnet'), 'confirmed');+// Route through our same-origin proxy. Public devnet RPC is also rate-limited+// from browsers; the proxy keeps both clusters consistent.+const _rpcOrigin = window.location?.origin || 'https://three.ws';+const connection = new solanaWeb3.Connection(`${_rpcOrigin}/api/solana-rpc?net=devnet`, 'confirmed');const connectWalletBtn = document.getElementById('connect-wallet-btn');connectWalletBtn.addEventListener('click', async () => {diff --git a/src/agent-home-claims.js b/src/agent-home-claims.jsindex 7aa1ed8ca..e9b78eac9 100644--- a/src/agent-home-claims.js+++ b/src/agent-home-claims.js@@ -5,9 +5,16 @@*/const PUMP_PROGRAM = '6EF8rrecthR5Dkzon8Nwu78hRvfCKubJ14M5uBEwF6P';+// Route through our same-origin proxy. The public mainnet RPC returns 403 to+// most browser origins; the proxy forwards server-side to Helius when+// HELIUS_API_KEY is set.+const RPC_ORIGIN =+ typeof window !== 'undefined' && window.location?.origin+ ? window.location.origin+ : 'https://three.ws';const SOLANA_RPC = {- mainnet: 'https://api.mainnet-beta.solana.com',- devnet: 'https://api.devnet.solana.com',+ mainnet: `${RPC_ORIGIN}/api/solana-rpc`,+ devnet: `${RPC_ORIGIN}/api/solana-rpc?net=devnet`,};// Minimum SOL delta (lamports) to qualify as a fee claim rather than tx-fee noise.diff --git a/src/avatar-page.js b/src/avatar-page.jsindex fc4cabba6..b1e0529bd 100644--- a/src/avatar-page.js+++ b/src/avatar-page.js@@ -98,6 +98,7 @@ async function init() {loadPlugins();loadRelated();loadUsedBy();+ loadCoins();measureModel(glbUrl);}@@ -239,6 +240,10 @@ function renderShell(glbUrl) {<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>+ <section class="av-coins" id="av-coins" hidden aria-labelledby="av-coins-heading">+ <h3 class="av-coins-heading" id="av-coins-heading">Linked coins</h3>+ <div class="av-coins-grid" id="av-coins-grid"></div>+ </section>${renderAttribution()}${renderAttached()}</div>@@ -923,6 +928,43 @@ async function loadUsedBy() {.join('');}+// ── Linked coins (pump.fun mints on agents wearing this avatar) ──────++async function loadCoins() {+ const grid = $('av-coins-grid');+ const section = $('av-coins');+ if (!grid || !section) return;++ const r = await fetch(`/api/avatars/${encodeURIComponent(avatarId)}/coins`);+ if (!r.ok) return;+ const { coins } = await r.json();+ if (!Array.isArray(coins) || coins.length === 0) return;++ section.hidden = false;+ grid.innerHTML = coins+ .map((c) => {+ const symbol = c.symbol || 'TOKEN';+ const name = c.name || c.symbol || 'Untitled token';+ const mintShort = c.mint+ ? `${c.mint.slice(0, 4)}…${c.mint.slice(-4)}`+ : '';+ const network = (c.network || 'mainnet').toUpperCase();+ const agentLine = c.agentId+ ? `On <a href="${esc(c.agentUrl)}">${esc(c.agentName || 'agent')}</a>`+ : '';+ return `<a class="av-coin-card" href="${esc(c.pumpfunUrl)}" target="_blank" rel="noopener" title="${esc(name)}">+ <div class="av-coin-head">+ <span class="av-coin-symbol">$${esc(symbol)}</span>+ <span class="av-coin-net">${esc(network)}</span>+ </div>+ <div class="av-coin-name">${esc(name)}</div>+ <div class="av-coin-mint">${esc(mintShort)}</div>+ ${agentLine ? `<div class="av-coin-agent">${agentLine}</div>` : ''}+ </a>`;+ })+ .join('');+}+// ── Related avatars ───────────────────────────────────────────────────async function loadRelated() {diff --git a/src/editor/publish.js b/src/editor/publish.jsindex 51594c78d..8076991be 100644--- a/src/editor/publish.js+++ b/src/editor/publish.js@@ -110,7 +110,7 @@ export async function publishEditedGLB(storage_key: presign.storage_key,content_type: 'model/gltf-binary',size_bytes: bytes.byteLength,- visibility: isPublic ? 'public' : 'private',+ visibility: isPublic ? 'public' : 'unlisted',source: 'upload',source_meta: { origin: 'editor-publish' },},diff --git a/src/erc8004/solana-deploy.js b/src/erc8004/solana-deploy.jsindex fe310e607..29ded03cd 100644--- a/src/erc8004/solana-deploy.js+++ b/src/erc8004/solana-deploy.js@@ -25,9 +25,16 @@ export function detectSolanaWallet() {return null;}+// Route through our same-origin proxy. The public mainnet RPC returns 403 to+// most browser origins; the proxy forwards server-side to Helius when+// HELIUS_API_KEY is set, otherwise to the public RPC from a datacentre IP.+const SOLANA_RPC_ORIGIN =+ typeof window !== 'undefined' && window.location?.origin+ ? window.location.origin+ : 'https://three.ws';export const SOLANA_RPC = {- mainnet: 'https://api.mainnet-beta.solana.com',- devnet: 'https://api.devnet.solana.com',+ mainnet: `${SOLANA_RPC_ORIGIN}/api/solana-rpc`,+ devnet: `${SOLANA_RPC_ORIGIN}/api/solana-rpc?net=devnet`,};const RPC = SOLANA_RPC;diff --git a/src/marketplace.js b/src/marketplace.jsindex c3bc81390..feb3fa534 100644--- a/src/marketplace.js+++ b/src/marketplace.js@@ -2221,15 +2221,17 @@ const WALLET_PROVIDERS = [let connectedWallet = null; // { provider, name, publicKey }async function loadSolanaModules() {- if (!solanaWeb3Mod) solanaWeb3Mod = await import('https://esm.sh/@solana/[email protected]');- if (!splTokenMod) splTokenMod = await import('https://esm.sh/@solana/[email protected]');+ if (!solanaWeb3Mod) solanaWeb3Mod = await import('@solana/web3.js');+ if (!splTokenMod) splTokenMod = await import('@solana/spl-token');return { web3: solanaWeb3Mod, spl: splTokenMod };}async function getSolanaConnection() {if (solanaConnection) return solanaConnection;const { web3 } = await loadSolanaModules();- solanaConnection = new web3.Connection(web3.clusterApiUrl('mainnet-beta'), 'confirmed');+ // Route through our same-origin proxy. Public mainnet RPC 403s most browsers.+ const rpcOrigin = window.location?.origin || 'https://three.ws';+ solanaConnection = new web3.Connection(`${rpcOrigin}/api/solana-rpc`, 'confirmed');return solanaConnection;}@@ -2552,7 +2554,7 @@ async function startQrPurchase() {if (qrEl) {qrEl.innerHTML = `<canvas id="payment-qr-canvas" width="240" height="240"></canvas><p class="muted small">Scan with a Solana Pay wallet (Phantom mobile, Solflare mobile, etc.)</p>`;- const QRCode = await import('https://esm.sh/[email protected]');+ const QRCode = await import('qrcode');await (QRCode.default ?? QRCode).toCanvas(document.getElementById('payment-qr-canvas'), url.toString(), { width: 240 });}diff --git a/src/onchain/adapters/solana.js b/src/onchain/adapters/solana.jsindex b51ef9c6c..86e6e1550 100644--- a/src/onchain/adapters/solana.js+++ b/src/onchain/adapters/solana.js@@ -16,9 +16,16 @@ import { Connection, Transaction, VersionedTransaction } from '@solana/web3.js';import { WalletAdapter } from './base.js';import { solana } from '../chain-ref.js';+// Route through our same-origin proxy. The public mainnet RPC returns 403 to+// most browser origins; the proxy forwards server-side to Helius when+// HELIUS_API_KEY is set. Absolute URL because Connection() derives a WS URL.+const RPC_ORIGIN =+ typeof window !== 'undefined' && window.location?.origin+ ? window.location.origin+ : 'https://three.ws';const RPC = {- mainnet: 'https://api.mainnet-beta.solana.com',- devnet: 'https://api.devnet.solana.com',+ mainnet: `${RPC_ORIGIN}/api/solana-rpc`,+ devnet: `${RPC_ORIGIN}/api/solana-rpc?net=devnet`,};function detect(preferred) {diff --git a/src/onchain/payments/pumpfun-payments.js b/src/onchain/payments/pumpfun-payments.jsindex fa896fc3f..270069e0c 100644--- a/src/onchain/payments/pumpfun-payments.js+++ b/src/onchain/payments/pumpfun-payments.js@@ -15,9 +15,16 @@import { Connection, Transaction, VersionedTransaction } from '@solana/web3.js';import { getAdapter as getWalletAdapter } from '../adapters/index.js';+// Route through our same-origin proxy. The public mainnet RPC returns 403 to+// most browser origins; the proxy forwards server-side to Helius when+// HELIUS_API_KEY is set. Absolute URL because Connection() derives a WS URL.+const RPC_ORIGIN =+ typeof window !== 'undefined' && window.location?.origin+ ? window.location.origin+ : 'https://three.ws';const SOLANA_RPC = {- mainnet: 'https://api.mainnet-beta.solana.com',- devnet: 'https://api.devnet.solana.com',+ mainnet: `${RPC_ORIGIN}/api/solana-rpc`,+ devnet: `${RPC_ORIGIN}/api/solana-rpc?net=devnet`,};function decodeTx(b64) {diff --git a/src/onchain/tokens/pumpfun.js b/src/onchain/tokens/pumpfun.jsindex b1f9dd38f..fa3148b4e 100644--- a/src/onchain/tokens/pumpfun.js+++ b/src/onchain/tokens/pumpfun.js@@ -19,9 +19,16 @@ import { Connection, Transaction, VersionedTransaction } from '@solana/web3.js';import { TokenAdapter } from './base.js';import { getAdapter as getWalletAdapter } from '../adapters/index.js';+// Route through our same-origin proxy. The public mainnet RPC returns 403 to+// most browser origins; the proxy forwards server-side to Helius when+// HELIUS_API_KEY is set. Absolute URL because Connection() derives a WS URL.+const RPC_ORIGIN =+ typeof window !== 'undefined' && window.location?.origin+ ? window.location.origin+ : 'https://three.ws';const SOLANA_RPC = {- mainnet: 'https://api.mainnet-beta.solana.com',- devnet: 'https://api.devnet.solana.com',+ mainnet: `${RPC_ORIGIN}/api/solana-rpc`,+ devnet: `${RPC_ORIGIN}/api/solana-rpc?net=devnet`,};function decodeTx(b64) {diff --git a/src/payment-modal.js b/src/payment-modal.jsindex b0d93d2f7..d29c7c01a 100644--- a/src/payment-modal.js+++ b/src/payment-modal.js@@ -11,13 +11,14 @@const USDC_DECIMALS = 6;-// Lazy-load Solana modules from esm.sh — same pattern as marketplace.js so-// the browser can reuse the same cached module across both surfaces.+// Lazy-load Solana modules via bundled npm deps. Dynamic import keeps the+// Solana SDKs out of the initial chunk; Vite splits them into their own+// asset that's only fetched when a payment actually happens.let _web3 = null;let _spl = null;async function loadSolana() {- if (!_web3) _web3 = await import('https://esm.sh/@solana/[email protected]');- if (!_spl) _spl = await import('https://esm.sh/@solana/[email protected]');+ if (!_web3) _web3 = await import('@solana/web3.js');+ if (!_spl) _spl = await import('@solana/spl-token');return { web3: _web3, spl: _spl };}@@ -270,7 +271,7 @@ export class SkillPaymentModal {const { getAssociatedTokenAddressSync, createTransferInstruction } = spl;if (!this._connection) {- const rpc = window.__solanaRpc || 'https://api.mainnet-beta.solana.com';+ const rpc = window.__solanaRpc || `${window.location.origin}/api/solana-rpc`;this._connection = new Connection(rpc, 'confirmed');}diff --git a/src/pump/agent-token-widget.js b/src/pump/agent-token-widget.jsindex fe27bfc25..7ec00bc0d 100644--- a/src/pump/agent-token-widget.js+++ b/src/pump/agent-token-widget.js@@ -288,10 +288,14 @@ export class AgentTokenWidget {if (this._wsUnsubs.length) return; // already subscribedtry {const [{ Connection, PublicKey }] = await Promise.all([import('@solana/web3.js')]);+ // Route through our same-origin proxy. Public mainnet RPC 403s most+ // browser origins. NOTE: WS subscriptions still go direct to the+ // derived ws:// URL; proxying WS is a separate concern.+ const rpcOrigin = window.location?.origin || 'https://three.ws';const url =this.token.network === 'devnet'- ? 'https://api.devnet.solana.com'- : 'https://api.mainnet-beta.solana.com';+ ? `${rpcOrigin}/api/solana-rpc?net=devnet`+ : `${rpcOrigin}/api/solana-rpc`;const conn = new Connection(url, 'confirmed');this._wsConn = conn;const subscribe = (addr, name) => {diff --git a/src/pump/launch-token-modal.js b/src/pump/launch-token-modal.jsindex 45cec2cb0..9e8632628 100644--- a/src/pump/launch-token-modal.js+++ b/src/pump/launch-token-modal.js@@ -655,10 +655,9 @@ export class LaunchTokenModal {this._msg('Broadcasting to Solana…');const { Connection } = await import('@solana/web3.js');- const rpcUrl =- prep.cluster === 'devnet'- ? 'https://api.devnet.solana.com'- : 'https://api.mainnet-beta.solana.com';+ // Route via same-origin proxy — public mainnet RPC 403s most browsers.+ const rpcOrigin = window.location?.origin || 'https://three.ws';+ const rpcUrl = `${rpcOrigin}/api/solana-rpc${prep.cluster === 'devnet' ? '?net=devnet' : ''}`;const conn = new Connection(rpcUrl, 'confirmed');let signature;diff --git a/src/pump/pump-modals.js b/src/pump/pump-modals.jsindex 487ef5a2a..feb710a9a 100644--- a/src/pump/pump-modals.js+++ b/src/pump/pump-modals.js@@ -112,28 +112,36 @@ function openModal() {return { back, inner, close };}-// Loaded from esm.sh because this module is served raw to the browser-// (Vercel does not bundle /src/*). Versions match package.json so signing-// produces byte-identical transactions to the bundled Node code paths.+// Bundled npm imports — public/agent/index.html is registered as a Vite+// build input so its inline scripts (and this module) are processed by Rollup,+// which resolves bare specifiers against node_modules and ships the deps+// in the page's hashed asset chunk.const {VersionedTransaction,Connection,PublicKey,Keypair,TransactionMessage,-} = await import('https://esm.sh/@solana/[email protected]');+} = await import('@solana/web3.js');const {getAssociatedTokenAddress,createAssociatedTokenAccountInstruction,getAccount,TOKEN_PROGRAM_ID,ASSOCIATED_TOKEN_PROGRAM_ID,-} = await import('https://esm.sh/@solana/[email protected]?deps=@solana/[email protected]');+} = await import('@solana/spl-token');+// Route through our same-origin proxy. The public mainnet RPC returns 403 to+// most browser origins; the proxy forwards server-side to Helius when+// HELIUS_API_KEY is set.+const RPC_ORIGIN =+ typeof window !== 'undefined' && window.location?.origin+ ? window.location.origin+ : 'https://three.ws';const RPC = (network) =>network === 'devnet'- ? 'https://api.devnet.solana.com'- : 'https://api.mainnet-beta.solana.com';+ ? `${RPC_ORIGIN}/api/solana-rpc?net=devnet`+ : `${RPC_ORIGIN}/api/solana-rpc`;const USDC_MINT = {mainnet: 'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v',diff --git a/src/solana-stake.js b/src/solana-stake.jsindex f3495cb9c..13c8fe2df 100644--- a/src/solana-stake.js+++ b/src/solana-stake.js@@ -18,9 +18,15 @@ const MEMO_PROGRAM_ID = new PublicKey('MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcexport const MIN_STAKE_LAMPORTS = 1_000_000n; // 0.001 SOLexport const SOL_PER_LAMPORT = 1e-9;+// Route through our same-origin proxy. The public mainnet RPC returns 403 to+// most browser origins.+const RPC_ORIGIN =+ typeof window !== 'undefined' && window.location?.origin+ ? window.location.origin+ : 'https://three.ws';const RPC = {- mainnet: 'https://api.mainnet-beta.solana.com',- devnet: 'https://api.devnet.solana.com',+ mainnet: `${RPC_ORIGIN}/api/solana-rpc`,+ devnet: `${RPC_ORIGIN}/api/solana-rpc?net=devnet`,};/**diff --git a/src/solana/sns.js b/src/solana/sns.jsindex 5413068f5..81065686e 100644--- a/src/solana/sns.js+++ b/src/solana/sns.js@@ -1,9 +1,13 @@import { Connection, PublicKey } from '@solana/web3.js';import { resolve, getFavoriteDomain } from '@bonfida/spl-name-service';+// Server-side: prefer SOLANA_RPC_URL (typically Helius). Browser-side: route+// through our same-origin proxy because public mainnet-beta 403s most origins.const DEFAULT_RPC_URL =(typeof process !== 'undefined' && process.env?.SOLANA_RPC_URL) ||- 'https://api.mainnet-beta.solana.com';+ (typeof window !== 'undefined' && window.location?.origin+ ? `${window.location.origin}/api/solana-rpc`+ : 'https://three.ws/api/solana-rpc');function makeConnection() {return new Connection(DEFAULT_RPC_URL, 'confirmed');diff --git a/vercel.json b/vercel.jsonindex 2d74aefb6..87c474718 100644--- a/vercel.json+++ b/vercel.json@@ -380,6 +380,10 @@"src": "/api/avatars/([^/]+)/agents","dest": "/api/avatars/[id]/agents?id=$1"},+ {+ "src": "/api/avatars/([^/]+)/coins",+ "dest": "/api/avatars/[id]/coins?id=$1"+ },{"src": "/api/avatars/([^/]+)/storage-mode","dest": "/api/avatars/[id]/storage-mode?id=$1"diff --git a/vite.config.js b/vite.config.jsindex add2f3b16..790f19bec 100644--- a/vite.config.js+++ b/vite.config.js@@ -1,6 +1,6 @@import { defineConfig } from 'vite';import { resolve } from 'path';-import { readFileSync, cpSync, createReadStream, existsSync, statSync } from 'fs';+import { readFileSync, cpSync, createReadStream, existsSync, statSync, rmSync } from 'fs';import { VitePWA } from 'vite-plugin-pwa';// The build emits two targets controlled by the TARGET env var:@@ -143,6 +143,11 @@ const appConfig = {studio: resolve(__dirname, 'public/studio/index.html'),reputation: resolve(__dirname, 'public/reputation/index.html'),hydrate: resolve(__dirname, 'public/hydrate/index.html'),+ // /agent/index.html is reachable as a static page (vercel.json+ // routes it to itself). Registering it as a Vite input bundles+ // its inline modules (incl. pump-modals, agent-token-widget)+ // instead of shipping /src/* refs that 404 in production.+ 'agent-token-page': resolve(__dirname, 'public/agent/index.html'),// BEGIN:DISCOVER_ROUTE'my-agents': resolve(__dirname, 'public/my-agents/index.html'),discover: resolve(__dirname, 'public/discover/index.html'),@@ -436,6 +441,31 @@ const appConfig = {});},},+ {+ // publicDir copies `public/agent/index.html` verbatim to+ // `dist/agent/index.html`, but we also register it as a Vite+ // input so its inline modules are bundled (Solana SDKs etc.).+ // The bundled output lands at `dist/public/agent/index.html`;+ // swap it into the serving path and drop the duplicate tree+ // so Vercel doesn't ship the raw-imports version that 404s on+ // `/src/*` in production.+ name: 'promote-bundled-public-html',+ closeBundle() {+ const pairs = [+ ['dist/public/agent/index.html', 'dist/agent/index.html'],+ ];+ for (const [from, to] of pairs) {+ const src = resolve(__dirname, from);+ const dst = resolve(__dirname, to);+ if (!existsSync(src)) continue;+ cpSync(src, dst, { force: true });+ }+ const publicMirror = resolve(__dirname, 'dist/public');+ if (existsSync(publicMirror)) {+ rmSync(publicMirror, { recursive: true, force: true });+ }+ },+ },VitePWA({registerType: 'autoUpdate',includeAssets: ['favicon.ico', 'pwa-192x192.png', 'pwa-512x512.png', 'pwa-icon.svg'],