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(forge): stop reporting rerig as supported when no rig worker is configured
nirholasae572fca5110
diff --git a/api/_providers/gcp.js b/api/_providers/gcp.jsindex f0286c326..52c0a5352 100644--- a/api/_providers/gcp.js+++ b/api/_providers/gcp.js@@ -24,7 +24,7 @@// rembg → GCP_REMBG_URL (workers/rembg)// segment → GCP_SEGMENT_URL (workers/segment)// sketch → GCP_TRIPOSG_URL (workers/model-triposg, scribble mode)-// rerig → GCP_RECONSTRUCTION_URL (avatar-pipeline-controller, /rig endpoint)+// rerig → GCP_UNIRIG_URL (workers/rig, /rig + /tasks/:id)// video2scene → GCP_VIDEO2SCENE_URL (workers/model-video2scene, LingBot-Map)// Streaming video → 3D point cloud. Standard /infer + /tasks/:id// shape; the result is a .ply point cloud, not a GLB mesh.@@ -108,13 +108,16 @@ function serviceUrlForMode(mode) {// mask/video/meta sidecar URLs.return readEnv('GCP_VIDEO2MOTION_URL');case 'rerig':- // Rigging: prefer the standalone rig worker (workers/rig, Cloud Run- // `model-rig`: direct /rig + /tasks/:id, `mesh_gcs_url` request schema)- // when GCP_UNIRIG_URL is set; otherwise the legacy pipeline-controller- // /rig endpoint behind GCP_RECONSTRUCTION_URL. The deployed- // avatar-reconstruction service exposes no /rig, so without- // GCP_UNIRIG_URL every rig submit 404s.- return readEnv('GCP_UNIRIG_URL') || readEnv('GCP_RECONSTRUCTION_URL');+ // Rigging: the standalone rig worker only (workers/rig, Cloud Run+ // `model-rig`: /rig + /tasks/:id, `mesh_gcs_url` request schema).+ // There is deliberately NO fallback to GCP_RECONSTRUCTION_URL: neither+ // deployed service behind it (avatar-reconstruction or the pipeline+ // controller) exposes a /rig endpoint, so the old fallback made+ // supportsMode('rerig') report true and then 404 on every submit,+ // which silently downgraded reconstructions to unrigged meshes.+ // With no GCP_UNIRIG_URL the mode is honestly unsupported and the+ // finalize stage skips the rig chain cleanly.+ return readEnv('GCP_UNIRIG_URL');default:return null;}@@ -340,30 +343,18 @@ function buildWorkerRequest(request) {}if (mode === 'rerig') {- // Two rig backends share the /rig path but disagree on the schema. The- // standalone rig worker behind GCP_UNIRIG_URL (workers/rig, the+ // The standalone rig worker behind GCP_UNIRIG_URL (workers/rig, the// Make-It-Animatable service; the env name predates it) takes// `mesh_gcs_url` (any https URL, the name is historical) and reports- // `rigged_gcs_url`; the legacy pipeline controller takes- // `mesh_url`/`rig_type` and reports `glb_url`. Branch on which env the- // rerig URL resolved from.- if (readEnv('GCP_UNIRIG_URL')) {- return {- path: '/rig',- resultKey: 'rigged_gcs_url',- body: {- mesh_gcs_url: sourceUrl,- template: params?.template || 'wolf3d_neutral',- blendshapes: params?.blendshapes !== false,- },- };- }+ // `rigged_gcs_url`. It is the only rerig backend: serviceUrlForMode+ // resolves rerig from GCP_UNIRIG_URL alone.return {path: '/rig',- resultKey: 'glb_url',+ resultKey: 'rigged_gcs_url',body: {- mesh_url: sourceUrl,- rig_type: params?.rig_type || 'biped',+ mesh_gcs_url: sourceUrl,+ template: params?.template || 'wolf3d_neutral',+ blendshapes: params?.blendshapes !== false,},};}@@ -624,6 +615,15 @@ export function createRegenProvider({ reconstructUrl } = {}) {if (status === 'failed') {result.error = data.error || `${mode} failed`;+ // The avatar workers classify failures ('input' = the caller's+ // photos were unusable and `error` is caller-facing copy;+ // 'internal' = service fault, `error` is an opaque correlation+ // id). Surface the taxonomy so the status endpoint can relay+ // actionable capture errors instead of masking every failure+ // into the generic retry message.+ if (data.error_kind === 'input' || data.error_kind === 'internal') {+ result.errorKind = data.error_kind;+ }}return result;diff --git a/api/avatars/_actions.js b/api/avatars/_actions.jsindex 2341e6096..f23447e2d 100644--- a/api/avatars/_actions.js+++ b/api/avatars/_actions.js@@ -520,7 +520,7 @@ const handleRegenerateStatus = wrap(async (req, res) => {const jobId = url.searchParams.get('jobId');if (!jobId) return error(res, 400, 'invalid_request', 'jobId required');const rows = await sql`- select job_id, status, result_avatar_id, result_glb_url, error, provider, ext_job_id, created_at,+ select job_id, status, result_avatar_id, result_glb_url, error, error_kind, provider, ext_job_id, created_at,mode, params, source_avatar_idfrom avatar_regen_jobswhere job_id = ${jobId} and user_id = ${userId}@@ -552,6 +552,9 @@ const handleRegenerateStatus = wrap(async (req, res) => {let nextStatus = update.status;let nextResultUrl = update.resultGlbUrl ?? null;let nextError = update.error ?? null;+ // Worker failure taxonomy (gcp adapter only): 'input' means the+ // error text is caller-facing copy we can relay verbatim.+ let nextErrorKind = update.errorKind === 'input' || update.errorKind === 'internal' ? update.errorKind : null;// SSRF gate (defense-in-depth): a provider-returned result URL is// attacker-influenceable if the provider account/payload is forged.// Pin it to an allowed provider host BEFORE it ever lands in@@ -566,6 +569,7 @@ const handleRegenerateStatus = wrap(async (req, res) => {nextStatus = 'failed';nextResultUrl = null;nextError = 'provider returned a disallowed result url';+ nextErrorKind = null;}if (isAutoRig && nextStatus === 'done') autoRigProviderDone = true;@@ -573,13 +577,15 @@ const handleRegenerateStatus = wrap(async (req, res) => {if (persistStatus !== job.status ||nextResultUrl !== job.result_glb_url ||- nextError !== job.error+ nextError !== job.error ||+ nextErrorKind !== job.error_kind) {await sql`update avatar_regen_jobsset status = ${persistStatus},result_glb_url = ${nextResultUrl},error = ${nextError},+ error_kind = ${nextErrorKind},updated_at = now()where job_id = ${jobId} and user_id = ${userId}`;@@ -588,6 +594,7 @@ const handleRegenerateStatus = wrap(async (req, res) => {status: persistStatus,result_glb_url: nextResultUrl,error: nextError,+ error_kind: nextErrorKind,};}}@@ -659,7 +666,13 @@ const handleRegenerateStatus = wrap(async (req, res) => {// Never return the raw provider/job error — it can carry a vendor name, task// id, or upstream status. The DB row keeps the raw value for operators; the// wire gets the masked form only (safe for both the web UI and API consumers).- const maskedError = sanitizeJobError(job.error);+ // One exception: our own avatar workers classify a failure as error_kind+ // 'input' when the error text is caller-facing by contract ("no face+ // detected in any of the provided photos"), so relay that copy verbatim+ // instead of collapsing it into the generic retry message.+ const maskedError = job.error_kind === 'input' && job.error+ ? String(job.error).slice(0, 300)+ : sanitizeJobError(job.error);if (maskedError) response.error = maskedError;if (job.provider) response.provider = job.provider;return json(res, 200, response);diff --git a/api/cron/[name].js b/api/cron/[name].jsindex 50c0a7259..3a3f140f9 100644--- a/api/cron/[name].js+++ b/api/cron/[name].js@@ -33,7 +33,7 @@* solana-attestations-crawl → handleSolanaAttestationsCrawl*/-import { id as keccakId, AbiCoder, getAddress, Interface } from 'ethers';+import { Interface } from 'ethers';import { createPublicClient, encodeFunctionData, parseAbi } from 'viem';import { evmTransport } from '../_lib/evm/rpc.js';import { baseSepolia, base } from 'viem/chains';@@ -299,10 +299,14 @@ async function erc8004CrawlChain(chain) {const chunkSize = chain.blockChunk || ERC8004_BLOCK_CHUNK;const toBlock = Math.min(fromBlock + chunkSize - 1, latestBlock);+ // Topic OR-set, not the single Registered topic: an agent's row used to+ // freeze at its registration block because ownership transfers, URI updates+ // and metadata writes were never requested from the RPC at all. See the+ // coverage census in api/_lib/erc8004-registry-events.js.const logs = await erc8004RpcCall(chain.rpcUrls ?? chain.rpcUrl, 'eth_getLogs', [{address: chain.registry,- topics: [REGISTERED_TOPIC],+ topics: [REGISTRY_TOPICS],fromBlock: '0x' + fromBlock.toString(16),toBlock: '0x' + toBlock.toString(16),},@@ -329,35 +333,87 @@ async function erc8004CrawlChain(chain) {}let inserted = 0;+ const byClass = { registration: 0, metadata: 0, transfer: 0 };+ const events = [];+for (const log of logs) {try {- const agentId = BigInt(log.topics[1]).toString();- const ownerHex = '0x' + log.topics[2].slice(-40);- const owner = getAddress(ownerHex).toLowerCase();- const [agentURI] = ABI_CODER.decode(['string'], log.data);- const blockNumber = Number.parseInt(log.blockNumber, 16);+ const ev = decodeRegistryLog(log);+ if (!ev) continue;+const ts = blockTimes[log.blockNumber];- const registeredAt = ts ? new Date(ts * 1000).toISOString() : null;+ const occurredAt = ts ? new Date(ts * 1000).toISOString() : null;+ // Absolute on-chain time only. A log whose block timestamp could not be+ // read is still applied to the agent row, but is NOT written to the event+ // index, because a timeline entry stamped with ingestion time is a lie.+ if (occurredAt) {+ events.push({+ chain: 'evm',+ chainId: chain.id,+ network: chain.testnet ? 'testnet' : 'mainnet',+ agentRef: agentRef({ chain: 'evm', chainId: chain.id, agentId: ev.agentId }),+ eventClass: ev.eventClass,+ eventName: ev.eventName,+ tx: ev.tx,+ logIndex: ev.logIndex,+ blockNumber: ev.blockNumber,+ occurredAt,+ actor: ev.type === 'transfer' ? ev.from : ev.owner || null,+ counterparty: ev.type === 'transfer' ? ev.to : null,+ payload: erc8004EventPayload(ev, chain),+ });+ }- await sql`- INSERT INTO erc8004_agents_index- (chain_id, agent_id, owner, registry, agent_uri,- registered_block, registered_tx, registered_at, last_seen_at)- VALUES- (${chain.id}, ${agentId}, ${owner}, ${chain.registry.toLowerCase()},- ${agentURI || null}, ${blockNumber}, ${log.transactionHash},- ${registeredAt}, now())- ON CONFLICT (chain_id, agent_id) DO UPDATE SET- owner = excluded.owner,- agent_uri = COALESCE(excluded.agent_uri, erc8004_agents_index.agent_uri),- last_seen_at = now()- `;- inserted += 1;+ if (ev.type === 'registered') {+ await sql`+ INSERT INTO erc8004_agents_index+ (chain_id, agent_id, owner, registry, agent_uri,+ registered_block, registered_tx, registered_at, last_seen_at)+ VALUES+ (${chain.id}, ${ev.agentId}, ${ev.owner}, ${chain.registry.toLowerCase()},+ ${ev.agentUri || null}, ${ev.blockNumber}, ${ev.tx},+ ${occurredAt}, now())+ ON CONFLICT (chain_id, agent_id) DO UPDATE SET+ owner = excluded.owner,+ agent_uri = COALESCE(excluded.agent_uri, erc8004_agents_index.agent_uri),+ last_seen_at = now()+ `;+ inserted += 1;+ byClass.registration += 1;+ } else if (ev.type === 'uri_updated') {+ // A new agentURI invalidates every enriched field. Clearing+ // last_metadata_at re-queues the row for the enrichment pass instead+ // of serving the old name and image for the next seven days.+ await sql`+ UPDATE erc8004_agents_index+ SET agent_uri = ${ev.agentUri || null},+ last_metadata_at = null,+ metadata_error = null,+ last_seen_at = now()+ WHERE chain_id = ${chain.id} AND agent_id = ${ev.agentId}+ `;+ byClass.metadata += 1;+ } else if (ev.type === 'metadata_set') {+ byClass.metadata += 1;+ } else if (ev.type === 'transfer' && !ev.isMint) {+ // The reason an agent's indexed owner could never change: nothing+ // watched Transfer. Only a row that already exists is updated; a+ // transfer of an agent registered before the crawl window is+ // recorded as history and reconciled when Registered is backfilled.+ await sql`+ UPDATE erc8004_agents_index+ SET owner = ${ev.to}, last_seen_at = now()+ WHERE chain_id = ${chain.id} AND agent_id = ${ev.agentId}+ `;+ byClass.transfer += 1;+ }} catch (decodeErr) {console.warn('[crawl] decode failed', chain.id, log.transactionHash, decodeErr.message);}}+ const recorded = events.length ? await recordEvents(events) : { inserted: 0, rejected: 0 };+// Always advance cursor to toBlock so the next run continues from here.await sql`INSERT INTO erc8004_crawl_cursor (chain_id, last_block, updated_at)@@ -367,7 +423,29 @@ async function erc8004CrawlChain(chain) {updated_at = now()`;- return { inserted, scanned: toBlock - fromBlock + 1, lastBlock: toBlock, fromBlock };+ return {+ inserted,+ scanned: toBlock - fromBlock + 1,+ lastBlock: toBlock,+ fromBlock,+ logs: logs.length,+ events: recorded.inserted,+ byClass,+ };+}++// Per-class payload for the event index. Keeps the raw on-chain detail that the+// agent-row columns cannot hold (which metadata key changed, the URI at the time+// of the event, whether a transfer was the registration mint).+function erc8004EventPayload(ev, chain) {+ const base = { registry: chain.registry.toLowerCase(), agentId: ev.agentId };+ if (ev.type === 'registered' || ev.type === 'uri_updated') {+ return { ...base, agentUri: ev.agentUri || null, owner: ev.owner };+ }+ if (ev.type === 'metadata_set') {+ return { ...base, key: ev.key, value: ev.value };+ }+ return { ...base, from: ev.from, to: ev.to, mint: ev.isMint };}async function erc8004EnrichMetadata(limit, deadline) {diff --git a/src/selfie-capture.js b/src/selfie-capture.jsindex dfb026194..dcc37a611 100644--- a/src/selfie-capture.js+++ b/src/selfie-capture.js@@ -785,9 +785,10 @@ async function fileToScaledDataUrl(file) {}return new Promise((resolve, reject) => {const img = new Image();- img.onload = () => resolve(img);- img.onerror = () => reject(new Error('could not decode image'));- img.src = URL.createObjectURL(file);+ const url = URL.createObjectURL(file);+ img.onload = () => { URL.revokeObjectURL(url); resolve(img); };+ img.onerror = () => { URL.revokeObjectURL(url); reject(new Error('could not decode image')); };+ img.src = url;});})();const w = bitmap.width || bitmap.naturalWidth;