Skip to content

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.

Fix forge seed: avatars.source CHECK was rejecting 'forge' inserts

nirholas7fee19281033
diff --git a/api/_lib/migrations/20260615030000_avatars_source_forge.sql b/api/_lib/migrations/20260615030000_avatars_source_forge.sql
new file mode 100644
index 000000000..f2a9e4538
--- /dev/null
+++ b/api/_lib/migrations/20260615030000_avatars_source_forge.sql
@@ -0,0 +1,11 @@
+-- Allow 'forge' as a valid source for AI-generated avatars seeded by the cron.
+-- The previous constraint only covered user-uploaded sources; platform-seeded
+-- content via forge-seed-cron uses source='forge' for clear provenance.
+
+ALTER TABLE avatars
+DROP CONSTRAINT avatars_source_check,
+ADD CONSTRAINT avatars_source_check
+ CHECK (source = ANY (ARRAY[
+ 'upload', 'avaturn', 'readyplayer', 'import',
+ 'direct-upload', 'reconstruct', 'studio', 'forge'
+ ]));
diff --git a/api/cron/forge-seed-cron.js b/api/cron/forge-seed-cron.js
index 1feab3abc..7b06be52f 100644
--- a/api/cron/forge-seed-cron.js
+++ b/api/cron/forge-seed-cron.js
@@ -217,12 +217,17 @@ async function startNextJob(origin) {
// finished model in the submit response with job_id:null — there is nothing
// to poll. Attribute it to the synthetic user right now.
if (submit.body?.status === 'done' && submit.body?.glb_url) {
- await insertSeedAvatar({
- userId: user.id,
- prompt: chosen.prompt,
- modelCategory: chosen.category,
- creationId,
- });
+ try {
+ await insertSeedAvatar({
+ userId: user.id,
+ prompt: chosen.prompt,
+ modelCategory: chosen.category,
+ creationId,
+ });
+ } catch (err) {
+ await sql`delete from users where id = ${user.id}`.catch(() => {});
+ return { ok: false, reason: `avatar insert failed: ${err?.message}` };
+ }
await sql`
insert into forge_seed_jobs
(user_id, raw_client_id, job_id, prompt, model_category,