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 PartCrafter and HoloPart lanes through the Forge API
nirholas9b1f6ae9b18f
diff --git a/api/_lib/forge-options.js b/api/_lib/forge-options.jsindex 5d9d48846..a4a79fc21 100644--- a/api/_lib/forge-options.js+++ b/api/_lib/forge-options.js@@ -14,6 +14,8 @@// the worker infers the front view when every label is omitted.// • fill_other_sides : ask Pixal3D to synthesize the other three sides from a// single uploaded photo (MV-Adapter) instead of requiring 2-4 views.+// • num_parts : PartCrafter's requested part count (2-16); absent keeps+// the backend's own default.// • derive_pbr : the ONE exception to "off by default": the material// completion pass (glb-pbr-derive.js) runs on every delivered mesh, because// an albedo-only material is a defect rather than a preference. Send@@ -24,7 +26,7 @@// message rather than silently doing something the caller didn't ask for. A value// that is simply absent is never an error — it just keeps the current default.-import { TRELLIS2_RESOLUTIONS, PIXAL3D_VIEW_LABELS } from './forge-tiers.js';+import { TRELLIS2_RESOLUTIONS, PIXAL3D_VIEW_LABELS, BACKENDS } from './forge-tiers.js';// glb is the universal default. The two compressed variants run a post-generation// pass (see glb-compress.js) that shrinks the delivered file without changing the@@ -56,6 +58,7 @@ function compressionFor(format) {* resolution: 512 | 1024 | 1536 | null, // TRELLIS.2 / Pixal3D voxel resolution* viewLabels: Array<'front'|'back'|'left'|'right'|null> | null, // per-image tag* fillOtherSides: boolean, // synthesize the other sides from one photo+ * numParts: number | null, // PartCrafter's requested part count (2-16)* derivePbr: boolean, // material completion pass, true unless opted out* hasOptions: boolean, // true iff any non-default option was supplied* errors: Array<{ field: string, message: string }>,@@ -160,6 +163,23 @@ export function normalizeForgeOptions(body) {}}+ // num_parts: PartCrafter's part count. Absent keeps the backend's own+ // default (BACKENDS.partcrafter.defaultParts); an out-of-range value is+ // rejected rather than silently clamped, same reasoning as resolution above.+ let numParts = null;+ if (b.num_parts !== undefined && b.num_parts !== null && b.num_parts !== '') {+ const n = Number(b.num_parts);+ const { minParts, maxParts } = BACKENDS.partcrafter;+ if (!Number.isFinite(n) || !Number.isInteger(n) || n < minParts || n > maxParts) {+ errors.push({+ field: 'num_parts',+ message: `num_parts must be an integer between ${minParts} and ${maxParts}.`,+ });+ } else {+ numParts = n;+ }+ }+// fill_other_sides: opt-IN. Asks Pixal3D to synthesize the other three sides// from a single uploaded photo instead of requiring 2-4 views.let fillOtherSides = false;@@ -191,6 +211,7 @@ export function normalizeForgeOptions(body) {resolution !== null ||viewLabels !== null ||fillOtherSides ||+ numParts !== null ||!derivePbr;return {@@ -202,6 +223,7 @@ export function normalizeForgeOptions(body) {resolution,viewLabels,fillOtherSides,+ numParts,derivePbr,hasOptions,errors,@@ -237,6 +259,7 @@ export function summarizeForgeOptions(opts) {resolution: opts.resolution ?? null,view_labels: opts.viewLabels ?? null,fill_other_sides: Boolean(opts.fillOtherSides),+ num_parts: opts.numParts ?? null,derive_pbr: opts.derivePbr !== false,};}diff --git a/api/_lib/forge-tiers.js b/api/_lib/forge-tiers.jsindex bca228455..79d42c39a 100644--- a/api/_lib/forge-tiers.js+++ b/api/_lib/forge-tiers.js@@ -401,6 +401,40 @@ export const BACKENDS = Object.freeze({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.',}),+ partcrafter: Object.freeze({+ id: 'partcrafter',+ label: 'PartCrafter (self-host)',+ vendor: 'wgsxm PartCrafter · self-host',+ paths: Object.freeze(['image']),+ byok: false,+ provider: 'gcp',+ // Our own PartCrafter worker (workers/model-partcrafter on Cloud Run,+ // MIT, NeurIPS 2025). The only image lane that hands back a part-+ // separated GLB: N named part nodes (part_01, part_02, ...) decoded in+ // one diffusion-transformer pass, ready for Restyle Studio's per-part+ // edit flow with no separate segmentation call needed. Opt-in only,+ // like pixal3d and anigen: never a named free default or a failover+ // target, so a plain request never lands here by chance, the caller+ // asks for editable parts explicitly. Single reference image; extra+ // images are accepted but only the first is used.+ requiresEnv: Object.freeze(['MODEL_PARTCRAFTER_URL', 'GCP_RECONSTRUCTION_KEY']),+ polyControl: false,+ userImages: true,+ // Discoverable capability flags the catalog/UI read directly, rather+ // than hardcoding a "partcrafter" check outside this registry.+ editableParts: true,+ minParts: 2,+ maxParts: 16,+ defaultParts: 4,+ baseEta: 110,+ // Cold-start budget for our own scale-to-zero worker: checkpoint copy ++ // pipeline load (PartCrafter diffusion transformer + RMBG-1.4) before+ // the first inference.+ coldStartSeconds: 100,+ credits: null,+ free: true,+ blurb: 'Image to editable 3D parts on our own PartCrafter worker: 2 to 16 named part meshes decoded in one pass, no vendor cost. Recolor, swap, or regenerate any one part in Restyle Studio without touching the rest.',+ }),triposg: Object.freeze({id: 'triposg',label: 'TripoSG',@@ -873,7 +907,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', 'anigen', ...MODLY_LANES]);+const SELF_HOST_IMAGE_LANES = Object.freeze(['trellis2', 'trellis_selfhost', 'pixal3d', 'anigen', 'partcrafter', ...MODLY_LANES]);export function isSelfHostImageLane(backendId) {return SELF_HOST_IMAGE_LANES.includes(backendId);@@ -884,6 +918,7 @@ export function selfHostLaneName(backendId) {if (MODLY_LANES.includes(backendId)) return BACKENDS[backendId].label;if (backendId === 'pixal3d') return 'Pixal3D';if (backendId === 'anigen') return 'AniGen';+ if (backendId === 'partcrafter') return 'PartCrafter';return 'Self-hosted TRELLIS';}@@ -993,6 +1028,10 @@ export function buildCatalog() {// (skeleton + skin weights predicted alongside the mesh), so the UI can// skip offering a separate rigging step for the result.rigged: Boolean(b.rigged),+ // True only for the lane that hands back a part-separated GLB (named+ // nodes per part, decoded in one pass), so the UI can offer Restyle+ // Studio's part picker without a separate segmentation call.+ editable_parts: Boolean(b.editableParts),estimates: b.paths.reduce((acc, p) => {acc[p] = TIER_IDS.map((tierId) => ({tier: tierId,diff --git a/api/_lib/mesh-input.js b/api/_lib/mesh-input.jsindex 6d664e10b..44b130009 100644--- a/api/_lib/mesh-input.js+++ b/api/_lib/mesh-input.js@@ -34,6 +34,7 @@ export function fbxUnsupportedMessage(lane, goal) {export const STYLIZE_FBX_MESSAGE = fbxUnsupportedMessage('stylize', 'restyle an FBX');export const SEGMENT_FBX_MESSAGE = fbxUnsupportedMessage('segment', 'split an FBX into parts');+export const HOLOPART_FBX_MESSAGE = fbxUnsupportedMessage('holopart', 'complete hidden parts of an FBX');/** True when the URL's path names an FBX file, whatever the query string carries. */export function isFbxMeshUrl(url) {diff --git a/api/_providers/gcp.js b/api/_providers/gcp.jsindex e2d7cfd90..54f83631d 100644--- a/api/_providers/gcp.js+++ b/api/_providers/gcp.js@@ -125,6 +125,17 @@ function serviceUrlForMode(mode) {// separate rerig step. Same /infer + /tasks/:id task shape; conditions// on the first reference image only.return readEnv('MODEL_ANIGEN_URL');+ case 'partcrafter':+ // Self-hosted PartCrafter worker (workers/model-partcrafter): the+ // editable-parts image lane. One reference view decoded into N named+ // part nodes in a single pass. Same /infer + /tasks/:id task shape.+ return readEnv('MODEL_PARTCRAFTER_URL');+ case 'holopart':+ // Self-hosted HoloPart worker (workers/model-holopart): completes the+ // occluded geometry of an already part-segmented mesh (e.g. the+ // output of `segment`), preserving part node names. Same+ // /infer + /tasks/:id task shape.+ return readEnv('MODEL_HOLOPART_URL');case 'modly':case 'modly_hunyuan':// Self-hosted Modly worker (workers/modly): one service, two models.@@ -275,6 +286,36 @@ function buildWorkerRequest(request) {};}+ if (mode === 'partcrafter') {+ // Self-hosted PartCrafter (workers/model-partcrafter): one reference+ // view in, a part-separated GLB (N named part nodes) 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, num_parts: Math.round(Number(params?.num_parts) || 4) };+ if (Number.isFinite(Number(params?.seed))) body.seed = Math.floor(Number(params.seed));+ return {+ path: '/infer',+ resultKey: 'result_gcs_url',+ body,+ };+ }++ if (mode === 'holopart') {+ // Self-hosted HoloPart (workers/model-holopart): an already part-+ // segmented mesh in (one named geometry per part, e.g. workers/segment's+ // own output), a mesh with every part's occluded geometry completed out.+ // Part node names are preserved verbatim by the worker.+ const body = { mesh_url: sourceUrl };+ 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);}@@ -562,6 +603,12 @@ const MODE_ETA = {pixal3d: 100,// Mesh + skeleton prediction + skin-weight transfer in one pass.anigen: 90,+ // N parts decoded in one diffusion-transformer pass; scales mildly with+ // the requested part count, which estimateEtaSeconds does not model here.+ partcrafter: 110,+ // Per-part point-cloud conditioning + diffusion decode for every part in+ // an already-segmented mesh.+ holopart: 100,// 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.@@ -672,7 +719,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 === 'anigen'+ mode === 'hunyuan' || mode === 'trellis2' || mode === 'modly' || mode === 'modly_hunyuan' || mode === 'anigen' || mode === 'partcrafter'? 1: (mode === 'reconstruct' || mode === 'trellis' || mode === 'pixal3d') && Array.isArray(workerReq.body.images)? workerReq.body.images.length@@ -783,8 +830,11 @@ export function createRegenProvider({ reconstructUrl } = {}) {result.faceCount = data.face_count;}// Surface the parts manifest so callers can render a selectable- // part list without a second fetch.- if (mode === 'segment') {+ // part list without a second fetch. PartCrafter and HoloPart share+ // the same `parts`/`part_count` shape as segment (id, name, region,+ // face_count, vertex_count, bbox, centroid, volume, color), so+ // Restyle Studio's part picker reads all three sources identically.+ if (mode === 'segment' || mode === 'partcrafter' || mode === 'holopart') {if (data.manifest_url) result.manifestUrl = data.manifest_url;if (Array.isArray(data.parts)) result.parts = data.parts;if (typeof data.part_count === 'number') result.partCount = data.part_count;diff --git a/api/forge-holopart.js b/api/forge-holopart.jsnew file mode 100644index 000000000..eacf391fc--- /dev/null+++ b/api/forge-holopart.js@@ -0,0 +1,137 @@+/**+ * /api/forge-holopart: complete the hidden/occluded geometry of every part+ * in an already part-segmented mesh (the output of /api/forge-segment or+ * the PartCrafter image lane).+ *+ * POST /api/forge-holopart { mesh_url: string, seed?: number }+ * → 202 { job_id, status, eta_seconds }+ *+ * GET /api/forge-holopart?job=<id>+ * → { job_id, status, result_url?, manifest_url?, parts?, part_count?, error? }+ *+ * Routes to workers/model-holopart (GCP Cloud Run) when MODEL_HOLOPART_URL+ * is set. mesh_url must already carry at least two named part geometries;+ * workers/segment and model-partcrafter both produce that shape.+ */++import { cors, json, method, readJson, wrap, rateLimited } from './_lib/http.js';+import { limits, clientIp } from './_lib/rate-limit.js';+import { assertPublicHttpsUrl, SsrfError } from './_lib/ssrf.js';+import { createRegenProvider } from './_providers/gcp.js';+import { isFbxMeshUrl, HOLOPART_FBX_MESSAGE } from './_lib/mesh-input.js';++const JOB_ID_RE = /^[A-Za-z0-9_-]{20,600}$/;+const SEED_MAX = 4_294_967_295;++function unconfigured(res) {+ return json(res, 503, {+ error: 'unconfigured',+ message:+ 'Hidden-part completion is not configured. Set MODEL_HOLOPART_URL and GCP_RECONSTRUCTION_KEY ' ++ 'to the URL and bearer secret of your deployed workers/model-holopart Cloud Run service.',+ });+}++async function startJob(req, res) {+ const ip = clientIp(req);+ const rl = await limits.mcp3dGenerate(ip);+ if (!rl.success) {+ return rateLimited(res, rl);+ }++ const body = await readJson(req, 4_000).catch(() => null);+ const rawMeshUrl = typeof body?.mesh_url === 'string' ? body.mesh_url.trim() : '';+ let meshUrl;+ try {+ meshUrl = await assertPublicHttpsUrl(rawMeshUrl);+ } catch (err) {+ return json(res, 400, {+ error: 'invalid_mesh_url',+ message: err instanceof SsrfError ? `mesh_url rejected: ${err.message}` : 'mesh_url must be a public https URL.',+ });+ }+ if (isFbxMeshUrl(meshUrl)) {+ return json(res, 400, { error: 'unsupported_mesh_format', message: HOLOPART_FBX_MESSAGE });+ }++ let seed;+ if (body?.seed !== undefined && body?.seed !== null) {+ const n = Number(body.seed);+ if (!Number.isFinite(n) || !Number.isInteger(n) || n < 0) {+ return json(res, 400, { error: 'invalid_seed', message: 'seed must be a non-negative integer.' });+ }+ seed = Math.min(n, SEED_MAX);+ }++ let provider;+ try {+ provider = createRegenProvider();+ if (!provider.supportsMode('holopart')) return unconfigured(res);+ } catch {+ return unconfigured(res);+ }++ try {+ const job = await provider.submit({+ mode: 'holopart',+ sourceUrl: meshUrl,+ params: { seed },+ });+ return json(res, 202, {+ job_id: job.extJobId,+ status: 'queued',+ eta_seconds: job.eta,+ });+ } catch (err) {+ return json(res, 502, { error: 'holopart_failed', message: err?.message || 'Part completion could not start.' });+ }+}++async function pollJob(req, res, jobId) {+ if (!JOB_ID_RE.test(jobId)) {+ return json(res, 400, { error: 'invalid_job', message: 'Malformed job id.' });+ }++ const rl = await limits.mcp3dStatus(clientIp(req));+ if (!rl.success) {+ return rateLimited(res, rl);+ }++ let provider;+ try {+ provider = createRegenProvider();+ } catch {+ return unconfigured(res);+ }++ let result;+ try {+ result = await provider.status(jobId);+ } catch (err) {+ return json(res, 502, {+ error: 'holopart_status_failed',+ message: err?.message || 'Could not read the part-completion job.',+ });+ }+ return json(res, 200, {+ job_id: jobId,+ status: result.status,+ result_url: result.resultGlbUrl || null,+ manifest_url: result.manifestUrl || null,+ parts: result.parts || null,+ part_count: result.partCount ?? null,+ error: result.error || null,+ });+}++export default wrap(async (req, res) => {+ if (cors(req, res, { methods: 'GET,POST,OPTIONS' })) return;+ if (!method(req, res, ['GET', 'POST'])) return;++ if (req.method === 'POST') return startJob(req, res);++ const url = new URL(req.url, 'http://localhost');+ const jobId = (url.searchParams.get('job') || '').trim();+ if (!jobId) return json(res, 400, { error: 'missing_job', message: 'Pass ?job=<id> to poll.' });+ return pollJob(req, res, jobId);+});diff --git a/api/forge.js b/api/forge.jsindex 29919f983..778f91dba 100644--- a/api/forge.js+++ b/api/forge.js@@ -2220,6 +2220,17 @@ async function startJobWithBody(req, res, body) {images: views,seed: opts.seed ?? undefined,},+ } : backendId === 'partcrafter' ? {+ mode: 'partcrafter',+ sourceUrl: referenceImageUrl,+ params: {+ // The worker reads only the first view; it decodes N named+ // part nodes in a single pass, ready for Restyle Studio's+ // per-part edit flow with no separate segmentation call.+ images: views,+ num_parts: opts.numParts ?? undefined,+ seed: opts.seed ?? undefined,+ },} : {mode: 'trellis',sourceUrl: referenceImageUrl,@@ -3242,6 +3253,12 @@ async function pollJob(req, res, jobId) {// client so it can skip offering a separate rerig step.rigged: result.rigged || undefined,joint_count: result.jointCount ?? undefined,+ // PartCrafter / HoloPart / segment all hand back the same named-part+ // manifest shape, so Restyle Studio's part picker reads it the same+ // way regardless of which worker produced the mesh.+ parts: result.parts ?? undefined,+ part_count: result.partCount ?? undefined,+ parts_manifest_url: result.manifestUrl ?? undefined,...metaFields,});}diff --git a/api/gpt-forge.js b/api/gpt-forge.jsindex d0f632baf..08ef61ad4 100644--- a/api/gpt-forge.js+++ b/api/gpt-forge.js@@ -2105,6 +2105,14 @@ async function startJob(req, res) {images: views,seed: opts.seed ?? undefined,},+ } : backendId === 'partcrafter' ? {+ mode: 'partcrafter',+ sourceUrl: referenceImageUrl,+ params: {+ images: views,+ num_parts: opts.numParts ?? undefined,+ seed: opts.seed ?? undefined,+ },} : {mode: 'trellis',sourceUrl: referenceImageUrl,@@ -3120,6 +3128,12 @@ async function pollJob(req, res, jobId) {// client so it can skip offering a separate rerig step.rigged: result.rigged || undefined,joint_count: result.jointCount ?? undefined,+ // PartCrafter / HoloPart / segment all hand back the same named-part+ // manifest shape, so Restyle Studio's part picker reads it the same+ // way regardless of which worker produced the mesh.+ parts: result.parts ?? undefined,+ part_count: result.partCount ?? undefined,+ parts_manifest_url: result.manifestUrl ?? undefined,...metaFields,};await rememberDoneFrame(jobId, doneFrame);