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 UI enhancements, animation library fixes, segment + GCP + pipeline updates
nirholas585de367daf5
diff --git a/api/_mcp3d/tools/studio.js b/api/_mcp3d/tools/studio.jsindex dbe6791bc..dc0643075 100644--- a/api/_mcp3d/tools/studio.js+++ b/api/_mcp3d/tools/studio.js@@ -60,6 +60,24 @@ function regenProvider(mode = 'reconstruct') {}}+// Region (magic-brush) edits MUST run on the GCP texture worker — the Replicate+// path has no masked-inpaint model, so we never silently fall back to it and+// drop the mask. Require GCP explicitly and fail with a clear message otherwise.+function regionProvider() {+ if (process.env?.GCP_RECONSTRUCTION_KEY) {+ try {+ const gcp = createGcpProvider();+ if (gcp.supportsMode('retex_region')) return gcp;+ } catch {+ // fall through to the explicit error below+ }+ }+ throw rpcError(+ -32000,+ 'Region retexture requires the GCP texture worker (set GCP_RECONSTRUCTION_KEY and GCP_TEXTURE_URL).',+ );+}+// Validate via the shared DNS-resolving SSRF guard: https-only, the hostname is// resolved and every A/AAAA record is checked against the full private/loopback/// link-local/ULA/IPv4-mapped/metadata blocklist (covering 172.16/12, [::1],@@ -848,7 +866,7 @@ export const toolDefs = [isError: true,};}- const provider = regenProvider('retex_region');+ const provider = regionProvider();const job = await provider.submit({mode: 'retex_region',sourceUrl: args.mesh_url,diff --git a/api/_providers/gcp.js b/api/_providers/gcp.jsindex 19fba5421..da9c299b8 100644--- a/api/_providers/gcp.js+++ b/api/_providers/gcp.js@@ -82,10 +82,18 @@ function buildWorkerRequest(request) {const photos = Array.isArray(params?.images) && params.images.length? params.images: [sourceUrl].filter(Boolean);+ const body = { images: photos, body_type: params?.bodyType || 'neutral' };+ // Quality-tier provenance + poly budget for the self-host high-detail path.+ // Only forwarded when set, so the default request shape is unchanged.+ if (Number.isFinite(Number(params?.target_polycount))) {+ body.target_polycount = Math.round(Number(params.target_polycount));+ }+ if (params?.tier) body.tier = params.tier;+ if (params?.path) body.path = params.path;return {path: '/reconstruct',resultKey: 'glb_url',- body: { images: photos, body_type: params?.bodyType || 'neutral' },+ body,};}diff --git a/pages/forge.html b/pages/forge.htmlindex 5295402c4..6e1cb2646 100644--- a/pages/forge.html+++ b/pages/forge.html@@ -164,6 +164,79 @@box-shadow: none;}+ /* Quality tier + engine + BYOK --------------------------------- */+ .forge-quality {+ display: flex;+ flex-direction: column;+ gap: var(--space-sm);+ margin-top: var(--space-sm);+ padding-top: var(--space-sm);+ border-top: 1px solid var(--stroke);+ }+ .fq-row {+ display: flex;+ align-items: center;+ gap: var(--space-sm);+ flex-wrap: wrap;+ }+ .fq-label {+ font-family: var(--font-mono);+ font-size: var(--text-xs);+ text-transform: uppercase;+ letter-spacing: 0.04em;+ color: var(--ink-dim);+ min-width: 4.2rem;+ }+ .byok-row {+ display: flex;+ align-items: center;+ gap: var(--space-sm);+ flex-wrap: wrap;+ }+ .byok-input {+ flex: 1 1 16rem;+ min-width: 0;+ background: var(--surface-1);+ border: 1px solid var(--stroke);+ border-radius: var(--radius-md);+ color: var(--ink);+ font-family: var(--font-mono);+ font-size: var(--text-sm);+ padding: 0.5rem 0.7rem;+ outline: none;+ transition: border-color 0.15s, box-shadow 0.15s;+ }+ .byok-input:focus-visible {+ border-color: var(--accent);+ box-shadow: 0 0 0 3px var(--accent-soft);+ }+ .byok-input[aria-invalid='true'] {+ border-color: var(--danger);+ }+ .byok-hint {+ flex-basis: 100%;+ font-size: var(--text-xs);+ color: var(--ink-dim);+ }+ .byok-hint a {+ color: var(--accent);+ text-decoration: none;+ }+ .byok-hint a:hover {+ text-decoration: underline;+ }+ .fq-estimate {+ margin: 0;+ font-family: var(--font-mono);+ font-size: var(--text-xs);+ color: var(--ink-dim);+ min-height: 1.1em;+ }+ .fq-estimate strong {+ color: var(--ink);+ font-weight: 600;+ }+/* Mode switch -------------------------------------------------- */.mode-switch-wrap {display: flex;@@ -1095,6 +1168,37 @@</p></div>+ <!-- Quality tier + generation engine + BYOK key -->+ <div class="forge-quality" id="forge-quality">+ <div class="fq-row">+ <span class="fq-label" id="tier-label">Quality</span>+ <div class="aspect" role="group" aria-labelledby="tier-label" id="tier">+ <button type="button" data-tier="draft" aria-pressed="false">Draft</button>+ <button type="button" data-tier="standard" aria-pressed="true">Standard</button>+ <button type="button" data-tier="high" aria-pressed="false">High</button>+ </div>+ </div>+ <div class="fq-row">+ <span class="fq-label" id="engine-label">Engine</span>+ <div class="aspect" role="group" aria-labelledby="engine-label" id="engine"></div>+ </div>+ <div class="byok-row is-hidden" id="byok-row">+ <label class="fq-label" for="provider-key" id="byok-label">API key</label>+ <input+ class="byok-input"+ id="provider-key"+ type="password"+ autocomplete="off"+ autocapitalize="off"+ spellcheck="false"+ placeholder="Your provider API key (kept in this browser)"+ aria-describedby="byok-hint"+ />+ <span class="byok-hint" id="byok-hint"></span>+ </div>+ <p class="fq-estimate" id="estimate" aria-live="polite"></p>+ </div>+<div class="composer-row"><divclass="aspect"diff --git a/src/animation-library.js b/src/animation-library.jsindex 97b9ae127..17f8d5129 100644--- a/src/animation-library.js+++ b/src/animation-library.js@@ -168,9 +168,12 @@ export class AnimationLibrary {});const grid = el('div', { class: 'al-grid' });const empty = el('div', { class: 'al-empty' });- const transport = this._renderTransport();- this._refs = { search, chips, grid, empty, transport };+ // Shell refs first; _renderTransport() merges its own sub-refs (label,+ // speed, export button) into this._refs, so it must run after this assign.+ this._refs = { search, chips, grid, empty };+ const transport = this._renderTransport();+ this._refs.transport = transport;this.host.appendChild(search);this.host.appendChild(chips);diff --git a/src/forge.js b/src/forge.jsindex 725648174..e8303d8c4 100644--- a/src/forge.js+++ b/src/forge.js@@ -64,15 +64,40 @@ const els = {creations: document.getElementById('creations'),creationsGrid: document.getElementById('creations-grid'),creationsCount: document.getElementById('creations-count'),+ // Quality tier + generation engine + BYOK key.+ tier: document.getElementById('tier'),+ engine: document.getElementById('engine'),+ byokRow: document.getElementById('byok-row'),+ byokLabel: document.getElementById('byok-label'),+ byokHint: document.getElementById('byok-hint'),+ providerKey: document.getElementById('provider-key'),+ estimate: document.getElementById('estimate'),};let aspectRatio = '1:1';let elapsedTimer = null;let pollAbort = false;-let mode = 'text'; // 'text' | 'image'+let mode = 'text'; // 'text' | 'image' — input mode (prompt vs photos)let lastJob = null; // { prompt, imageUrls } — for retrylet currentCreationId = null;+// Generation route + quality. `genPath` is the task's image|geometry axis;+// `genBackend` names the provider; both come from the selected engine button.+// The catalog (tiers + backends + cost/time matrix) is fetched once on load.+let catalog = null;+let selectedTier = 'standard';+let selectedEngine = { id: 'trellis', path: 'image', backend: 'trellis', byok: null, polyControl: false };+// BYOK key held only in memory for this session — sent per request, never stored+// by the page. Signed-in users can instead save it server-side in Account.+let providerKey = '';++// Friendly engine labels + where to mint a key, keyed by backend id.+const ENGINE_LABELS = { trellis: 'Fast', meshy: 'Meshy', tripo: 'Tripo', hunyuan3d: 'Hunyuan3D' };+const KEY_HINTS = {+ meshy: { label: 'Meshy AI', url: 'https://www.meshy.ai/settings/api' },+ tripo: { label: 'Tripo AI', url: 'https://platform.tripo3d.ai/api-keys' },+};+// One entry per reference-view slot. `state` drives the slot's rendered region;// `url` is the durable public URL (what we send); `objectUrl` is the local// preview blob, revoked when the slot is cleared.diff --git a/src/segment.js b/src/segment.jsindex d01c18a96..e01319bbc 100644--- a/src/segment.js+++ b/src/segment.js@@ -196,6 +196,7 @@ function loadSegmentedModel(glbUrl, manifest) {if (!o.isMesh) return;o.material = o.material.clone();o.material.vertexColors = true;+ o.material.needsUpdate = true; // force a shader recompile so the per-part tint showsconst id = partIdFor(o);if (!byId.has(id)) {const man = manifestById.get(id);@@ -539,6 +540,9 @@ function onPointerMove(e) {}function onPointerUp(e) {if (!parts.length) return;+ // Only the canvas selects — a release on a parts-panel button (or anywhere+ // else) must not clobber the current selection.+ if (e.target !== renderer.domElement) return;// Ignore drags (orbit) — only treat a near-stationary release as a click.if (Math.abs(e.clientX - downX) > 4 || Math.abs(e.clientY - downY) > 4) return;setPointer(e);diff --git a/workers/avatar-pipeline-controller/main.py b/workers/avatar-pipeline-controller/main.pyindex 0c65f111f..0c90288e2 100644--- a/workers/avatar-pipeline-controller/main.py+++ b/workers/avatar-pipeline-controller/main.py@@ -167,6 +167,7 @@ async def _run_pipeline(images: list[str],body_type: str,model_name: str,+ target_polycount: int | None = None,) -> None:t0 = time.time()backend_url = BACKENDS[model_name]@@ -174,11 +175,17 @@ async def _run_pipeline(try:# ── Stage 1: Mesh generation ──────────────────────────────────────_set_job(job_id, {"status": "running", "stage": "mesh_generation"})- log.info("[%s] submitting to %s", job_id, model_name)+ log.info("[%s] submitting to %s (target_polycount=%s)", job_id, model_name, target_polycount)++ infer_payload = {"images": images, "body_type": body_type, "job_id": job_id}+ # Forward the tier's poly budget to backends that support it; omitted when+ # unset so a backend that ignores it sees the original request shape.+ if target_polycount:+ infer_payload["target_polycount"] = int(target_polycount)resp = await _http.post(f"{backend_url}/infer",- json={"images": images, "body_type": body_type, "job_id": job_id},+ json=infer_payload,headers={"authorization": f"Bearer {API_KEY}"},)if resp.status_code != 202:@@ -320,6 +327,12 @@ class ReconstructRequest(BaseModel):job_id: str | None = Nonebody_type: str = "neutral"model: str | None = None+ # Quality-tier provenance + target polygon budget (see api/_lib/forge-tiers.js).+ # Recorded on the job and forwarded to the backend so the high tier yields a+ # denser mesh. All optional — the default request shape is unchanged.+ tier: str | None = None+ path: str | None = None+ target_polycount: int | None = Field(default=None, ge=100, le=1_000_000)@app.post("/reconstruct", status_code=202)@@ -340,10 +353,17 @@ async def reconstruct("model": model_name,"image_count": len(body.images),"body_type": body.body_type,+ # Provenance: which generation path + quality tier produced this job, so+ # GET /jobs reports tier + backend + path back to the caller.+ "tier": body.tier,+ "path": body.path or "image",+ "target_polycount": body.target_polycount,"created_at": datetime.now(timezone.utc),})- background_tasks.add_task(_run_pipeline, job_id, body.images, body.body_type, model_name)+ background_tasks.add_task(+ _run_pipeline, job_id, body.images, body.body_type, model_name, body.target_polycount,+ )return {"job_id": job_id, "status": "queued", "model": model_name}diff --git a/workers/segment/main.py b/workers/segment/main.pyindex 9a7b960e1..ce27fa7f0 100644--- a/workers/segment/main.py+++ b/workers/segment/main.py@@ -156,6 +156,9 @@ def _run_segmentation(manifest["parts"] = [p.manifest() for p in parts]manifest["part_count"] = len(parts)manifest["only_part"] = f"part_{parts[0].index:02d}"+ # The cap/merge warning describes the full run, not this single-part+ # export — drop it so the response isn't misleading.+ manifest["warnings"] = []return glb_bytes, manifest