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
Agent-detail OG tags + canonical; Solana RPC fallback; forge circuit breaker
nirholas40734f83540f
diff --git a/api/agents/solana/_handlers.js b/api/agents/solana/_handlers.jsindex 6fe4d4268..50877e21f 100644--- a/api/agents/solana/_handlers.js+++ b/api/agents/solana/_handlers.js@@ -6,7 +6,7 @@import crypto from 'node:crypto';import { z } from 'zod';import { PublicKey } from '@solana/web3.js';-import { solanaConnection } from '../../_lib/solana/connection.js';+import { solanaConnection, solanaRpcEndpoints, isEndpointCooling } from '../../_lib/solana/connection.js';import { sql } from '../../_lib/db.js';import { cors, json, method, wrap, error, readJson, rateLimited } from '../../_lib/http.js';import { limits, clientIp } from '../../_lib/rate-limit.js';@@ -549,14 +549,11 @@ export const handleRegisterPrep = wrap(async (req, res) => {}}- const PUBLIC_RPC = {- mainnet: 'https://api.mainnet-beta.solana.com',- devnet: 'https://api.devnet.solana.com',- };- const configuredRpc = network === 'devnet'- ? (process.env.SOLANA_RPC_URL_DEVNET || PUBLIC_RPC.devnet)- : (process.env.SOLANA_RPC_URL || PUBLIC_RPC.mainnet);- const publicRpc = PUBLIC_RPC[network] || PUBLIC_RPC.mainnet;+ // Pick the first non-cooling endpoint from the full Helius → Alchemy → Ankr →+ // public chain. When Helius is parked in _endpointCooldown (e.g. quota 429)+ // this silently skips it rather than burning a 503 on the user.+ const rpcEndpoints = solanaRpcEndpoints(network);+ const liveEndpoint = rpcEndpoints.find((ep) => !isEndpointCooling(ep)) || rpcEndpoints[0];const appOrigin = env.APP_ORIGIN;@@ -566,7 +563,7 @@ export const handleRegisterPrep = wrap(async (req, res) => {// configured RPC is unreachable.const assetSigner = asset_pubkey? createNoopSigner(umiPublicKey(asset_pubkey))- : generateSigner(createUmi(publicRpc).use(mplCore()));+ : generateSigner(createUmi(liveEndpoint).use(mplCore()));const assetPubkey = assetSigner.publicKey;const passportUrl = `${appOrigin}/agent-passport.html?asset=${assetPubkey}&network=${network}`;@@ -629,19 +626,10 @@ export const handleRegisterPrep = wrap(async (req, res) => {let txBytes;try {- txBytes = await buildTx(configuredRpc);+ txBytes = await buildTx(liveEndpoint);} catch (rpcErr) {- if (configuredRpc === publicRpc) {- console.error('[solana/register-prep] public RPC failed:', rpcErr.message);- return error(res, 503, 'rpc_unavailable', 'Solana RPC temporarily unavailable — try again in a moment.');- }- console.warn('[solana/register-prep] configured RPC failed, retrying with public RPC:', rpcErr.message);- try {- txBytes = await buildTx(publicRpc);- } catch (fallbackErr) {- console.error('[solana/register-prep] public RPC fallback also failed:', fallbackErr.message);- return error(res, 503, 'rpc_unavailable', 'Solana RPC temporarily unavailable — try again in a moment.');- }+ console.error('[solana/register-prep] RPC error after all fallbacks:', rpcErr.message);+ return error(res, 503, 'rpc_unavailable', 'Solana RPC temporarily unavailable — try again in a moment.');}const txBase64 = Buffer.from(txBytes).toString('base64');diff --git a/api/cron/forge-seed-cron.js b/api/cron/forge-seed-cron.jsindex 255cfc849..674b5105b 100644--- a/api/cron/forge-seed-cron.js+++ b/api/cron/forge-seed-cron.js@@ -34,6 +34,13 @@ const FETCH_TIMEOUT_MS = 48_000;const MAX_CONCURRENT_PENDING = 3;const MIN_JOB_AGE_SECONDS = 20;+// Circuit breaker — survives warm lambda invocations; resets on cold start / redeploy.+// When CIRCUIT_THRESHOLD consecutive forge submits fail the circuit opens for+// (failures × CIRCUIT_BASE_MS) so the cron goes quiet during provider outages.+const CIRCUIT_THRESHOLD = 3;+const CIRCUIT_BASE_MS = 10 * 60_000; // 10 min × consecutive failures+const _circuit = { failures: 0, openUntil: 0 };+function requireCron(req, res) {const secret = process.env.CRON_SECRET || env.CRON_SECRET;if (!secret) {@@ -175,6 +182,14 @@ async function startNextJob(origin) {return { skipped: true, reason: `${count} jobs already pending` };}+ if (_circuit.openUntil > Date.now()) {+ const minsLeft = Math.ceil((_circuit.openUntil - Date.now()) / 60_000);+ return {+ skipped: true,+ reason: `circuit open for ${minsLeft}m more (${_circuit.failures} consecutive failures)`,+ };+ }+// Pick next prompt — avoid recently used ones so the full library cycles// before any prompt repeats.const recent = await sql`@@ -220,11 +235,19 @@ async function startNextJob(origin) {});if (submit.timedOut) {+ _circuit.failures++;+ if (_circuit.failures >= CIRCUIT_THRESHOLD) {+ _circuit.openUntil = Date.now() + _circuit.failures * CIRCUIT_BASE_MS;+ }await sql`delete from users where id = ${user.id}`.catch(() => {});return { ok: false, reason: 'forge submit timed out — will retry next tick' };}if (submit.status !== 200) {+ _circuit.failures++;+ if (_circuit.failures >= CIRCUIT_THRESHOLD) {+ _circuit.openUntil = Date.now() + _circuit.failures * CIRCUIT_BASE_MS;+ }await sql`delete from users where id = ${user.id}`.catch(() => {});return {ok: false,@@ -249,6 +272,8 @@ async function startNextJob(origin) {await sql`delete from users where id = ${user.id}`.catch(() => {});return { ok: false, reason: `avatar insert failed: ${err?.message}` };}+ _circuit.failures = 0;+ _circuit.openUntil = 0;await sql`insert into forge_seed_jobs(user_id, raw_client_id, job_id, prompt, model_category,@@ -270,6 +295,8 @@ async function startNextJob(origin) {// Otherwise the lane is asynchronous — record the job so the next tick polls it.if (submit.body?.job_id) {+ _circuit.failures = 0;+ _circuit.openUntil = 0;await sql`insert into forge_seed_jobs (user_id, raw_client_id, job_id, prompt, model_category)values (${user.id}, ${rawClientId}, ${submit.body.job_id}, ${chosen.prompt}, ${chosen.category})@@ -285,6 +312,10 @@ async function startNextJob(origin) {}// Neither a finished model nor a poll token — a genuine failure.+ _circuit.failures++;+ if (_circuit.failures >= CIRCUIT_THRESHOLD) {+ _circuit.openUntil = Date.now() + _circuit.failures * CIRCUIT_BASE_MS;+ }await sql`delete from users where id = ${user.id}`.catch(() => {});return {ok: false,diff --git a/pages/agent-detail.html b/pages/agent-detail.htmlindex e9f955e14..b546ab2b5 100644--- a/pages/agent-detail.html+++ b/pages/agent-detail.html@@ -24,6 +24,7 @@content="Meet your 3D AI agent — voice, memory, payments, and an on-chain identity. Built on three.ws."/><meta name="twitter:image" content="https://three.ws/og-image.png" />+ <link rel="canonical" href="https://three.ws/agent" id="canonical-link" /><meta name="theme-color" content="#0a0a0a" /><link rel="icon" href="/favicon.ico" sizes="any" /><link rel="icon" type="image/svg+xml" href="/favicon.svg" />diff --git a/src/agent-detail.js b/src/agent-detail.jsindex c6d98d926..22b51b2cc 100644--- a/src/agent-detail.js+++ b/src/agent-detail.js@@ -391,6 +391,20 @@ function render(agent) {}$('ad-name').textContent = agent.name;+ // Update page title, canonical URL, and OG tags for social sharing+ if (agent.id && agent.name) {+ const pageUrl = `https://three.ws/agent/${agent.id}`;+ const ogImg = `https://three.ws/api/og/agent?id=${encodeURIComponent(agent.id)}`;+ document.title = `${agent.name} · three.ws`;+ const canonical = document.getElementById('canonical-link');+ if (canonical) canonical.href = pageUrl;+ document.querySelector('meta[property="og:url"]')?.setAttribute('content', pageUrl);+ document.querySelector('meta[property="og:title"]')?.setAttribute('content', `${agent.name} · three.ws`);+ document.querySelector('meta[property="og:image"]')?.setAttribute('content', ogImg);+ document.querySelector('meta[name="twitter:title"]')?.setAttribute('content', `${agent.name} · three.ws`);+ document.querySelector('meta[name="twitter:image"]')?.setAttribute('content', ogImg);+ }+// Let visitors save this agent's avatar as their own fork (its wallet is// already managed in the holdings panel below, so fork-only here).const fork = $('ad-avatar-actions');@@ -1499,7 +1513,7 @@ function makeSnsResolver(inputEl, statusEl) {function wireShareButton(agent) {const origin = location.origin;- const shareUrl = `${origin}/agent/${agent.id}`;+ const shareUrl = `${origin}/agent/${agent.id}/share`;const remixUrl = `${origin}/create`;const shareData = {kind: 'agent',