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
feat(forge): wire AniGen as the rig-on-generation Forge image lane
nirholas7f2646b67148
diff --git a/api/_lib/forge-tiers.js b/api/_lib/forge-tiers.jsindex 795cfe7f3..bca228455 100644--- a/api/_lib/forge-tiers.js+++ b/api/_lib/forge-tiers.js@@ -373,6 +373,34 @@ export const BACKENDS = Object.freeze({free: true,blurb: '"Match my photo": 1 to 4 reference images fused pixel-aligned into one PBR mesh on our own Pixal3D worker, no vendor cost. Label views front/back/left/right, or let the worker fill in the other sides from a single photo.',}),+ anigen: Object.freeze({+ id: 'anigen',+ label: 'AniGen (self-host)',+ vendor: 'VAST-AI-Research AniGen · self-host',+ paths: Object.freeze(['image']),+ byok: false,+ provider: 'gcp',+ // Our own AniGen worker (workers/model-anigen on Cloud Run, MIT). The only+ // image lane that hands back an already-rigged GLB: mesh, joint skeleton+ // and skin weights predicted together in one pass, so no separate rerig+ // call is needed. Opt-in only, like pixal3d: never a named free default or+ // a fallback target, so a plain request never lands here by chance, the+ // caller asks for a pre-rigged result explicitly. Single reference image;+ // extra images are accepted but only the first is used.+ requiresEnv: Object.freeze(['MODEL_ANIGEN_URL', 'GCP_RECONSTRUCTION_KEY']),+ polyControl: false,+ userImages: true,+ // Discoverable capability flag the catalog/UI read directly, rather than+ // hardcoding an "anigen" check outside this registry.+ rigged: true,+ baseEta: 90,+ // Cold-start budget for our own scale-to-zero worker: checkpoint copy ++ // pipeline load before the first inference.+ coldStartSeconds: 90,+ credits: null,+ free: true,+ blurb: 'Image to already-rigged 3D on our own AniGen worker: mesh, skeleton and skin weights predicted together in one pass, no vendor cost, no separate rigging step.',+ }),triposg: Object.freeze({id: 'triposg',label: 'TripoSG',@@ -845,7 +873,7 @@ export function backendIsConfigured(backendId) {// to the standing single-view reconstruct chain instead of silently dropping// the caller's second and third photos on a lane that only reads the first.export const MODLY_LANES = Object.freeze(['modly', 'modly_hunyuan']);-const SELF_HOST_IMAGE_LANES = Object.freeze(['trellis2', 'trellis_selfhost', 'pixal3d', ...MODLY_LANES]);+const SELF_HOST_IMAGE_LANES = Object.freeze(['trellis2', 'trellis_selfhost', 'pixal3d', 'anigen', ...MODLY_LANES]);export function isSelfHostImageLane(backendId) {return SELF_HOST_IMAGE_LANES.includes(backendId);@@ -855,6 +883,7 @@ export function isSelfHostImageLane(backendId) {export function selfHostLaneName(backendId) {if (MODLY_LANES.includes(backendId)) return BACKENDS[backendId].label;if (backendId === 'pixal3d') return 'Pixal3D';+ if (backendId === 'anigen') return 'AniGen';return 'Self-hosted TRELLIS';}@@ -960,6 +989,10 @@ export function buildCatalog() {multi_view: Boolean(b.multiView),view_labels: b.multiView ? PIXAL3D_VIEW_LABELS : undefined,fill_other_sides: Boolean(b.fillOtherSides),+ // True only for the lane(s) that hand back an already-rigged GLB+ // (skeleton + skin weights predicted alongside the mesh), so the UI can+ // skip offering a separate rigging step for the result.+ rigged: Boolean(b.rigged),estimates: b.paths.reduce((acc, p) => {acc[p] = TIER_IDS.map((tierId) => ({tier: tierId,diff --git a/api/_providers/gcp.js b/api/_providers/gcp.jsindex b845ce1e7..e2d7cfd90 100644--- a/api/_providers/gcp.js+++ b/api/_providers/gcp.js@@ -118,6 +118,13 @@ function serviceUrlForMode(mode) {// every one of its 1-4 reference views instead of reading the first.// Same /infer + /tasks/:id task shape.return readEnv('MODEL_PIXAL3D_URL');+ case 'anigen':+ // Self-hosted VAST-AI-Research AniGen worker (workers/model-anigen):+ // the only image lane that hands back an already-rigged GLB (mesh ++ // skeleton + skin weights in one pass), so a caller can skip the+ // separate rerig step. Same /infer + /tasks/:id task shape; conditions+ // on the first reference image only.+ return readEnv('MODEL_ANIGEN_URL');case 'modly':case 'modly_hunyuan':// Self-hosted Modly worker (workers/modly): one service, two models.@@ -252,6 +259,22 @@ function buildWorkerRequest(request) {};}+ if (mode === 'anigen') {+ // Self-hosted AniGen (workers/model-anigen): one reference view in, a+ // rigged GLB (mesh + skeleton + skin weights) out. The worker reads only+ // the first image; extra views are accepted but ignored.+ const photos = Array.isArray(params?.images) && params.images.length+ ? params.images+ : [sourceUrl].filter(Boolean);+ const body = { images: photos };+ if (Number.isFinite(Number(params?.seed))) body.seed = Math.floor(Number(params.seed));+ return {+ path: '/infer',+ resultKey: 'result_gcs_url',+ body,+ };+ }+if (mode === 'modly' || mode === 'modly_hunyuan') {return buildModlyRequest(mode, sourceUrl, params);}@@ -537,6 +560,8 @@ const MODE_ETA = {// multi-view fusion path (2-4 images) and the optional MV-Adapter// "fill the other sides" rung both run meaningfully heavier.pixal3d: 100,+ // Mesh + skeleton prediction + skin-weight transfer in one pass.+ anigen: 90,// TripoSG's 20 to 50 flow steps plus repair and decimate on the L4.modly: 60,// Hunyuan3D 2 Mini Turbo is a few-step distilled sampler.@@ -647,7 +672,7 @@ export function createRegenProvider({ reconstructUrl } = {}) {// on the primary view only (report 1 so a multi-view request is never// silently claimed as fused); other modes are single-source.const viewsUsed =- mode === 'hunyuan' || mode === 'trellis2' || mode === 'modly' || mode === 'modly_hunyuan'+ mode === 'hunyuan' || mode === 'trellis2' || mode === 'modly' || mode === 'modly_hunyuan' || mode === 'anigen'? 1: (mode === 'reconstruct' || mode === 'trellis' || mode === 'pixal3d') && Array.isArray(workerReq.body.images)? workerReq.body.images.length@@ -737,6 +762,12 @@ export function createRegenProvider({ reconstructUrl } = {}) {} else {result.resultGlbUrl = url;}+ // AniGen's GLB already carries a skeleton and skin weights. Tell the+ // caller so the UI can skip offering a separate rerig step.+ if (mode === 'anigen') {+ result.rigged = true;+ if (typeof data.joint_count === 'number') result.jointCount = data.joint_count;+ }// Surface remesh telemetry so callers can show topology stats.if (mode === 'remesh') {if (typeof data.face_count === 'number') result.faceCount = data.face_count;diff --git a/api/forge.js b/api/forge.jsindex c7a0ca290..29919f983 100644--- a/api/forge.js+++ b/api/forge.js@@ -2210,6 +2210,16 @@ async function startJobWithBody(req, res, body) {texture_size: opts.textureSize ?? undefined,decimation_target: opts.targetPolycount ?? undefined,},+ } : backendId === 'anigen' ? {+ mode: 'anigen',+ sourceUrl: referenceImageUrl,+ params: {+ // The worker reads only the first view; it predicts mesh, joint+ // skeleton and skin weights together, so the result needs no+ // separate rerig call.+ images: views,+ seed: opts.seed ?? undefined,+ },} : {mode: 'trellis',sourceUrl: referenceImageUrl,@@ -3228,6 +3238,10 @@ async function pollJob(req, res, jobId) {quality: durable?.quality || null,quality_gate: qualityGate || undefined,compression: durable?.compression || null,+ // AniGen's GLB already carries a skeleton and skin weights. Tell the+ // client so it can skip offering a separate rerig step.+ rigged: result.rigged || undefined,+ joint_count: result.jointCount ?? undefined,...metaFields,});}diff --git a/api/gpt-forge.js b/api/gpt-forge.jsindex e78fdd547..d0f632baf 100644--- a/api/gpt-forge.js+++ b/api/gpt-forge.js@@ -2095,6 +2095,16 @@ async function startJob(req, res) {resolution: opts.resolution ?? undefined,tier: tier.id,},+ } : backendId === 'anigen' ? {+ mode: 'anigen',+ sourceUrl: referenceImageUrl,+ params: {+ // The worker reads only the first view; it predicts mesh, joint+ // skeleton and skin weights together, so the result needs no+ // separate rerig call.+ images: views,+ seed: opts.seed ?? undefined,+ },} : {mode: 'trellis',sourceUrl: referenceImageUrl,@@ -3106,6 +3116,10 @@ async function pollJob(req, res, jobId) {quality: durable?.quality || null,quality_gate: qualityGate || undefined,compression: durable?.compression || null,+ // AniGen's GLB already carries a skeleton and skin weights. Tell the+ // client so it can skip offering a separate rerig step.+ rigged: result.rigged || undefined,+ joint_count: result.jointCount ?? undefined,...metaFields,};await rememberDoneFrame(jobId, doneFrame);diff --git a/src/forge.js b/src/forge.jsindex a8cdc1446..d5ad4fdf2 100644--- a/src/forge.js+++ b/src/forge.js@@ -297,6 +297,9 @@ const ENGINE_LABELS = {// unseen sides from one view: "Match my photo" is what that buys the user,// not the vendor name.pixal3d: 'Match my photo',+ // AniGen hands back a GLB that already carries a skeleton and skin weights:+ // the result is drivable immediately, no separate rigging call needed.+ anigen: 'Rig on generate',};// Where to mint a key per BYOK provider, keyed by the backend's `byok` name.@@ -2218,6 +2221,7 @@ function setViewsBadge(meta) {if (meta?.tier) parts.push(meta.tier);if (meta?.path === 'geometry') parts.push('geometry-first');if (meta?.path === 'sketch') parts.push('sketch→3D');+ if (meta?.rigged) parts.push('already rigged');if (parts.length === 0) {els.resultViews.classList.add('is-hidden');els.resultViews.textContent = '';@@ -3005,6 +3009,7 @@ async function run(cfg) {path: done.path ?? job.path,quality: done.quality ?? job.quality,quality_gate: done.quality_gate ?? job.quality_gate,+ rigged: done.rigged ?? job.rigged,},{ autoSaved: !!done.creation_id },);@@ -3619,6 +3624,7 @@ async function resumeInflight() {path: done.path ?? inflight.path,quality: done.quality,quality_gate: done.quality_gate,+ rigged: done.rigged,},{ autoSaved: !!done.creation_id },);diff --git a/tests/api/forge-anigen-request.test.js b/tests/api/forge-anigen-request.test.jsnew file mode 100644index 000000000..2d4beb372--- /dev/null+++ b/tests/api/forge-anigen-request.test.js@@ -0,0 +1,191 @@+/**+ * Request-boundary contract for AniGen's "rig on generate" lane on+ * api/forge.js: the request body the gcp provider receives (single image,+ * seed, no multi-view noise), and the happy path that must return a GLB job+ * recording the backend on the creation row.+ *+ * Modeled on tests/api/forge-pixal3d-request.test.js (same mocking shape).+ */++import { describe, it, expect, vi, beforeAll, beforeEach } from 'vitest';++beforeAll(() => {+ Object.assign(process.env, {+ APP_ORIGIN: 'https://three.ws',+ MODEL_ANIGEN_URL: 'https://anigen.example.run.app',+ MODEL_TRELLIS2_URL: 'https://trellis2.example.run.app',+ GCP_RECONSTRUCTION_KEY: 'test-gcp-key',+ NVIDIA_API_KEY: 'nvapi-test',+ JWT_SECRET: 'test-jwt-secret-at-least-32-characters-long',+ });+});++const gcpSubmit = vi.fn(async ({ params }) => ({+ extJobId: 'gcpjob-anigen-01',+ viewsUsed: 1,+ multiview: false,+}));+vi.mock('../../api/_providers/gcp.js', () => ({+ createRegenProvider: () => ({ submit: gcpSubmit }),+}));++vi.mock('../../api/_mcp3d/text-to-image.js', () => ({+ textToImage: vi.fn(async () => ({ imageUrl: 'https://cdn.example/ref.png', model: 'flux' })),+ synthesizeTurnaroundViews: vi.fn(async () => []),+}));++const createCreation = vi.fn(async () => 'creation-anigen-1');+vi.mock('../../api/_lib/forge-store.js', () => ({+ hashClient: (v) => `client:${v || 'anon'}`,+ hashIp: (v) => `ip:${v}`,+ createCreation,+ materializeCreation: vi.fn(async ({ glbUrl }) => ({ id: 'creation-anigen-1', glbUrl })),+ markFailed: vi.fn(async () => {}),+ findByJob: vi.fn(async () => null),+ runWithCreationContext: (_facts, fn) => fn(),+}));++vi.mock('../../api/_lib/forge-lane-health.js', () => ({+ laneHealthSnapshot: vi.fn(async () => ({ statusMap: {}, byId: {} })),+ markLaneUnhealthy: vi.fn(async () => {}),+ laneCooldownKey: (id) => `forge-lane:${id}`,+}));++vi.mock('../../api/_lib/forge-image-validate.js', () => ({+ validateForgeImage: vi.fn(async () => ({ ok: true })),+}));++vi.mock('../../api/_lib/rate-limit.js', async (importActual) => {+ const actual = await importActual();+ return {+ ...actual,+ limits: {+ ...actual.limits,+ mcp3dGenerate: vi.fn(async () => ({ success: true, reset: Date.now() + 1000 })),+ mcp3dGenerateFree: vi.fn(async () => ({ success: true, reset: Date.now() + 1000 })),+ },+ clientIp: () => '203.0.113.9',+ };+});++const { default: handler } = await import('../../api/forge.js');++function makeReq(body) {+ return {+ method: 'POST',+ url: '/api/forge',+ headers: { 'content-type': 'application/json', 'x-forge-client': 'tester' },+ on(event, cb) {+ if (event === 'data') cb(Buffer.from(JSON.stringify(body)));+ if (event === 'end') cb();+ },+ };+}++function makeRes() {+ return {+ statusCode: 200,+ headers: {},+ body: null,+ setHeader(name, value) {+ this.headers[String(name).toLowerCase()] = value;+ },+ end(body) {+ this.body = body ? JSON.parse(body) : null;+ },+ };+}++beforeEach(() => {+ gcpSubmit.mockClear();+ createCreation.mockClear();+});++describe('AniGen happy path', () => {+ it('a single-image request queues a job on the anigen backend', async () => {+ const req = makeReq({+ image_urls: ['https://cdn.example/front.png'],+ tier: 'standard',+ path: 'image',+ backend: 'anigen',+ skip_validation: true,+ });+ const res = makeRes();+ await handler(req, res);++ expect(res.statusCode).toBe(200);+ expect(res.body.backend).toBe('anigen');+ expect(res.body.status).toBe('queued');++ expect(gcpSubmit).toHaveBeenCalledTimes(1);+ const submitted = gcpSubmit.mock.calls[0][0];+ expect(submitted.mode).toBe('anigen');+ expect(submitted.params.images).toEqual(['https://cdn.example/front.png']);+ // No pixal3d-only fields leak into the anigen request shape.+ expect(submitted.params).not.toHaveProperty('view_labels');+ expect(submitted.params).not.toHaveProperty('fill_other_sides');+ expect(submitted.params).not.toHaveProperty('resolution');++ expect(createCreation).toHaveBeenCalledTimes(1);+ const creation = createCreation.mock.calls[0][0];+ expect(creation.backend).toBe('anigen');+ expect(creation.viewsRequested).toBe(1);+ expect(creation.viewsUsed).toBe(1);+ expect(creation.multiview).toBe(false);+ });++ it('an explicit seed rides through to the worker body', async () => {+ const req = makeReq({+ image_urls: ['https://cdn.example/front.png'],+ tier: 'standard',+ path: 'image',+ backend: 'anigen',+ seed: 123,+ skip_validation: true,+ });+ const res = makeRes();+ await handler(req, res);++ expect(res.statusCode).toBe(200);+ expect(gcpSubmit.mock.calls[0][0].params.seed).toBe(123);+ });++ it('extra views beyond the first are still forwarded (the worker reads only the first)', async () => {+ const req = makeReq({+ image_urls: ['https://cdn.example/front.png', 'https://cdn.example/back.png'],+ tier: 'standard',+ path: 'image',+ backend: 'anigen',+ skip_validation: true,+ });+ const res = makeRes();+ await handler(req, res);++ expect(res.statusCode).toBe(200);+ expect(gcpSubmit.mock.calls[0][0].params.images).toHaveLength(2);+ });+});++describe('AniGen unconfigured deployment', () => {+ it('returns a branchable 501 when MODEL_ANIGEN_URL is not set', async () => {+ const prev = process.env.MODEL_ANIGEN_URL;+ delete process.env.MODEL_ANIGEN_URL;+ try {+ gcpSubmit.mockRejectedValueOnce(Object.assign(new Error('no url'), { code: 'mode_unconfigured' }));+ const req = makeReq({+ image_urls: ['https://cdn.example/front.png'],+ tier: 'standard',+ path: 'image',+ backend: 'anigen',+ skip_validation: true,+ });+ const res = makeRes();+ await handler(req, res);+ expect(res.statusCode).toBe(501);+ expect(res.body.error).toBe('backend_unconfigured');+ expect(res.body.backend).toBe('anigen');+ } finally {+ if (prev !== undefined) process.env.MODEL_ANIGEN_URL = prev;+ }+ });+});diff --git a/tests/api/forge-anigen.test.js b/tests/api/forge-anigen.test.jsnew file mode 100644index 000000000..adef7b81c--- /dev/null+++ b/tests/api/forge-anigen.test.js@@ -0,0 +1,199 @@+// AniGen "rig on generate" lane: registration, env-gated config, opt-in+// routing (never a default or a failover target, same posture as Pixal3D),+// the catalog's `rigged` discoverability flag, and the gcp provider's+// `anigen` mode wire contract (request shape in, `rigged`/`joint_count`+// surfaced out).+//+// Unlike every other self-host image lane, AniGen's GLB already carries a+// skeleton and skin weights: the result needs no separate rerig call, which+// is the one behavior these tests exist to pin down.++import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest';+import {+ BACKENDS,+ resolveBackendId,+ backendIsConfigured,+ buildCatalog,+ isSelfHostImageLane,+ nextSelfHostImageLane,+ selfHostLaneName,+ FREE_DEFAULT_FOR_TIERS,+ FREE_FALLBACK_FOR_PATH,+} from '../../api/_lib/forge-tiers.js';+import { createRegenProvider } from '../../api/_providers/gcp.js';++const VARS = ['MODEL_ANIGEN_URL', 'MODEL_TRELLIS2_URL', 'MODEL_TRELLIS_URL', 'GCP_RECONSTRUCTION_KEY'];+const saved = {};+const ORIGINAL_FETCH = globalThis.fetch;++beforeEach(() => {+ for (const v of VARS) {+ saved[v] = process.env[v];+ delete process.env[v];+ }+});+afterEach(() => {+ for (const v of VARS) {+ if (saved[v] === undefined) delete process.env[v];+ else process.env[v] = saved[v];+ }+ globalThis.fetch = ORIGINAL_FETCH;+ vi.restoreAllMocks();+});++describe('forge-tiers: AniGen backend registration', () => {+ it('registers a free, platform-keyed, single-image backend that accepts user photos and reports rigged:true', () => {+ const b = BACKENDS.anigen;+ expect(b).toBeTruthy();+ expect(b.provider).toBe('gcp');+ expect(b.byok).toBe(false);+ expect(b.paths).toEqual(['image']);+ expect(b.requiresEnv).toEqual(['MODEL_ANIGEN_URL', 'GCP_RECONSTRUCTION_KEY']);+ expect(b.free).toBe(true);+ expect(b.userImages).toBe(true);+ expect(b.rigged).toBe(true);+ expect(b.credits).toBeNull();+ });++ it('is configured only when BOTH the worker URL and the shared key are present', () => {+ expect(backendIsConfigured('anigen')).toBe(false);+ process.env.MODEL_ANIGEN_URL = 'https://anigen.example.run.app';+ expect(backendIsConfigured('anigen')).toBe(false); // key still missing+ process.env.GCP_RECONSTRUCTION_KEY = 'secret';+ expect(backendIsConfigured('anigen')).toBe(true);+ });++ it('surfaces in the catalog with the rigged discoverability flag set', () => {+ process.env.MODEL_ANIGEN_URL = 'https://anigen.example.run.app';+ process.env.GCP_RECONSTRUCTION_KEY = 'secret';+ const b = buildCatalog().backends.find((x) => x.id === 'anigen');+ expect(b).toBeTruthy();+ expect(b.free).toBe(true);+ expect(b.user_images).toBe(true);+ expect(b.configured).toBe(true);+ expect(b.rigged).toBe(true);+ expect(b.max_images).toBe(1);+ expect(b.multi_view).toBe(false);+ });++ it('every OTHER backend reports rigged:false in the catalog', () => {+ const backends = buildCatalog().backends.filter((x) => x.id !== 'anigen');+ expect(backends.length).toBeGreaterThan(0);+ for (const b of backends) expect(b.rigged).toBe(false);+ });++ it('is a self-host image lane, but never a named default or a failover target', () => {+ process.env.MODEL_ANIGEN_URL = 'https://anigen.example.run.app';+ process.env.MODEL_TRELLIS2_URL = 'https://trellis2.example.run.app';+ process.env.GCP_RECONSTRUCTION_KEY = 'secret';+ expect(isSelfHostImageLane('anigen')).toBe(true);+ // Not named anywhere in the free-default or free-fallback tables.+ expect(Object.values(FREE_DEFAULT_FOR_TIERS).some((v) => v.image === 'anigen')).toBe(false);+ expect(FREE_FALLBACK_FOR_PATH.image).not.toContain('anigen');+ // A plain (no explicit backend) photo request never lands here.+ expect(resolveBackendId({ path: 'image', tier: 'standard', userImages: true, country: 'US' })).not.toBe('anigen');+ // Nothing fails over TO anigen, and anigen fails over to nothing (a down+ // AniGen worker must never silently deliver an unrigged result from+ // another lane under the "rig on generate" label).+ expect(nextSelfHostImageLane('trellis2')).not.toBe('anigen');+ expect(nextSelfHostImageLane('anigen')).toBeNull();+ expect(selfHostLaneName('anigen')).toBe('AniGen');+ });++ it('stays explicitly selectable even when unconfigured (the handler owns rejection)', () => {+ expect(+ resolveBackendId({ path: 'image', tier: 'standard', backend: 'anigen', userImages: true, country: 'US' }),+ ).toBe('anigen');+ });+});++describe('gcp provider: anigen mode wire contract', () => {+ it('submits the first reference image plus seed, and the ETA/viewsUsed shape is single-view', async () => {+ process.env.MODEL_ANIGEN_URL = 'https://anigen.example.run.app';+ process.env.GCP_RECONSTRUCTION_KEY = 'secret';+ let sent = null;+ globalThis.fetch = vi.fn(async (url, opts) => {+ expect(url).toBe('https://anigen.example.run.app/infer');+ sent = JSON.parse(opts.body);+ expect(opts.headers.authorization).toBe('Bearer secret');+ return new Response(JSON.stringify({ task_id: 'task-anigen', status: 'queued' }), {+ status: 202,+ headers: { 'content-type': 'application/json' },+ });+ });++ const provider = createRegenProvider();+ const images = ['https://three.ws/cdn/front.png'];+ const submitted = await provider.submit({+ mode: 'anigen',+ sourceUrl: images[0],+ params: { images, seed: 7 },+ });++ expect(sent).toEqual({ images, seed: 7 });+ expect(submitted.viewsUsed).toBe(1);+ expect(submitted.multiview).toBe(false);+ expect(submitted.eta).toBe(90);+ });++ it('surfaces rigged:true and joint_count from the finished task record', async () => {+ process.env.MODEL_ANIGEN_URL = 'https://anigen.example.run.app';+ process.env.GCP_RECONSTRUCTION_KEY = 'secret';+ globalThis.fetch = vi.fn(async (url) => {+ if (String(url).endsWith('/infer')) {+ return new Response(JSON.stringify({ task_id: 'task-anigen', status: 'queued' }), {+ status: 202,+ headers: { 'content-type': 'application/json' },+ });+ }+ return new Response(+ JSON.stringify({+ status: 'done',+ result_gcs_url: 'https://cdn.example/rigged.glb',+ joint_count: 24,+ }),+ { status: 200, headers: { 'content-type': 'application/json' } },+ );+ });++ const provider = createRegenProvider();+ const submitted = await provider.submit({+ mode: 'anigen',+ sourceUrl: 'https://three.ws/cdn/front.png',+ params: { images: ['https://three.ws/cdn/front.png'] },+ });+ const result = await provider.status(submitted.extJobId);++ expect(result.status).toBe('done');+ expect(result.resultGlbUrl).toBe('https://cdn.example/rigged.glb');+ expect(result.rigged).toBe(true);+ expect(result.jointCount).toBe(24);+ });++ it('a never-rigged backend (trellis2) does not report rigged/jointCount', async () => {+ process.env.MODEL_TRELLIS2_URL = 'https://trellis2.example.run.app';+ process.env.GCP_RECONSTRUCTION_KEY = 'secret';+ globalThis.fetch = vi.fn(async (url) => {+ if (String(url).endsWith('/infer')) {+ return new Response(JSON.stringify({ task_id: 'task-t2', status: 'queued' }), {+ status: 202,+ headers: { 'content-type': 'application/json' },+ });+ }+ return new Response(+ JSON.stringify({ status: 'done', result_gcs_url: 'https://cdn.example/plain.glb' }),+ { status: 200, headers: { 'content-type': 'application/json' } },+ );+ });++ const provider = createRegenProvider();+ const submitted = await provider.submit({+ mode: 'trellis2',+ sourceUrl: 'https://three.ws/cdn/front.png',+ params: { images: ['https://three.ws/cdn/front.png'] },+ });+ const result = await provider.status(submitted.extJobId);+ expect(result.rigged).toBeUndefined();+ expect(result.jointCount).toBeUndefined();+ });+});