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(assets): serve the CC0 library from the public CDN when a signed S3 read fails, so a credential fault cannot empty the catalog
nirholasa5c15cfaff71
diff --git a/api/_lib/asset-catalog.js b/api/_lib/asset-catalog.jsindex 348872634..ecbcb6e6f 100644--- a/api/_lib/asset-catalog.js+++ b/api/_lib/asset-catalog.js@@ -18,7 +18,7 @@//// `id` is `<kind>:<name>` and is the stable handle every consumer quotes back.-import { getObjectBuffer } from './r2.js';+import { getPublicObjectBuffer } from './r2.js';// Each source: the R2 manifest key, the array field inside it, and the kind the// rows become. The generated animation catalog is a separate object that may not@@ -48,7 +48,7 @@ function asArray(parsed, field) {async function readManifest({ key, field }) {try {- const buf = await getObjectBuffer(key);+ const buf = await getPublicObjectBuffer(key);const parsed = JSON.parse(buf.toString('utf8'));return { rows: asArray(parsed, field), generatedAt: parsed?.generated_at || null };} catch (err) {diff --git a/api/_lib/r2.js b/api/_lib/r2.jsindex ba8aca0aa..42ae1ea2a 100644--- a/api/_lib/r2.js+++ b/api/_lib/r2.js@@ -249,6 +249,54 @@ export async function getObjectBuffer(key) {return Buffer.concat(chunks);}+// Keys already warned about, so a credential fault logs once per process per key+// instead of once per edge-cache miss.+const publicFallbackWarned = new Set();++// Read an object whose bytes are PUBLIC anyway (a CC0 library manifest, a+// rendered thumbnail) with the signed read first and the bucket's own public CDN+// domain as the fallback.+//+// The signed read stays first because it is authoritative: it sees a freshly+// published manifest the instant it lands, while the CDN may still be serving+// the previous copy. But it is also the only part of a public read that can fail+// for a reason having nothing to do with the object. On 2026-09-09 the+// production S3 secret stopped matching its access key id, every signed GET came+// back SignatureDoesNotMatch, and the whole CC0 asset catalog (511 objects, the+// character library, the animation clips) read as empty to every visitor, while+// the exact same bytes stayed downloadable by anyone on the public domain those+// manifests already hand out. A credential fault must not be able to empty a+// route that serves public bytes.+//+// Both paths failing rethrows the SIGNED error, so callers that treat NoSuchKey+// as "not uploaded yet" keep working unchanged.+export async function getPublicObjectBuffer(key) {+ let signedErr;+ try {+ return await getObjectBuffer(key);+ } catch (err) {+ signedErr = err;+ }+ const url = publicUrlOrNull(key);+ if (!url) throw signedErr;+ let res;+ try {+ res = await fetch(url, { signal: AbortSignal.timeout(8000) });+ } catch {+ throw signedErr;+ }+ // A CDN 404 means the object genuinely is not there; surface the signed error+ // so a NoSuchKey stays a NoSuchKey upstream rather than becoming an HTTP 404+ // nobody has a branch for.+ if (!res.ok) throw signedErr;+ const buf = Buffer.from(await res.arrayBuffer());+ if (!publicFallbackWarned.has(key)) {+ publicFallbackWarned.add(key);+ console.warn(`[r2] signed read of ${key} failed (${signedErr?.name || 'error'}: ${signedErr?.message || signedErr}); served it from the public CDN instead`);+ }+ return buf;+}+// Read an object together with the user metadata it was stored with. Used by// caches that key on a stable path and decide freshness from a stamp in the// metadata (the glance PNG cache stores the card's ETag there), so a stalediff --git a/api/animations/library.js b/api/animations/library.jsindex 659ed3050..9b3f61be2 100644--- a/api/animations/library.js+++ b/api/animations/library.js@@ -36,7 +36,7 @@// grows.import { cors, json, method, wrap } from '../_lib/http.js';-import { getObjectBuffer } from '../_lib/r2.js';+import { getPublicObjectBuffer } from '../_lib/r2.js';const MANIFEST_KEY = 'animations/library/manifest.json';const GENERATED_MANIFEST_KEY = 'animations/library/generated/manifest.json';@@ -53,7 +53,7 @@ const MAX_PAGE = 1000;*/async function readManifest(key) {try {- const buf = await getObjectBuffer(key);+ const buf = await getPublicObjectBuffer(key);const parsed = JSON.parse(buf.toString('utf8'));const clips = Array.isArray(parsed)? parseddiff --git a/api/avatars/library.js b/api/avatars/library.jsindex 70dbf02bf..8f1b6cea4 100644--- a/api/avatars/library.js+++ b/api/avatars/library.js@@ -27,7 +27,7 @@// `next_offset` (null on the last page). `total` is always the full library size.import { cors, json, method, wrap } from '../_lib/http.js';-import { getObjectBuffer } from '../_lib/r2.js';+import { getPublicObjectBuffer } from '../_lib/r2.js';const MANIFEST_KEY = 'avatars/library/manifest.json';const MAX_PAGE = 1000;@@ -39,7 +39,7 @@ export default wrap(async (req, res) => {let avatars = [];let generatedAt = null;try {- const buf = await getObjectBuffer(MANIFEST_KEY);+ const buf = await getPublicObjectBuffer(MANIFEST_KEY);const parsed = JSON.parse(buf.toString('utf8'));avatars = Array.isArray(parsed) ? parsed : Array.isArray(parsed.avatars) ? parsed.avatars : [];generatedAt = parsed.generated_at || null;diff --git a/api/objects/library.js b/api/objects/library.jsindex b65156963..39071e195 100644--- a/api/objects/library.js+++ b/api/objects/library.js@@ -10,7 +10,7 @@// feature-detect by emptiness. Pagination via ?limit=N (1..1000) + ?offset=M.import { cors, error, json, method, wrap } from '../_lib/http.js';-import { getObjectBuffer } from '../_lib/r2.js';+import { getPublicObjectBuffer } from '../_lib/r2.js';const MANIFEST_KEY = 'objects/library/manifest.json';const MAX_PAGE = 1000;@@ -72,7 +72,7 @@ export default wrap(async (req, res) => {let generatedAt = null;let degraded = false;try {- const buf = await getObjectBuffer(MANIFEST_KEY);+ const buf = await getPublicObjectBuffer(MANIFEST_KEY);const parsed = JSON.parse(buf.toString('utf8'));const list = Array.isArray(parsed) ? parsed : Array.isArray(parsed?.objects) ? parsed.objects : null;// A manifest that parses but carries no object list is corrupt, not empty.