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(materialize): offer the physical print from the forge, creations and model pages
nirholas03b339eb5313
diff --git a/STRUCTURE.md b/STRUCTURE.mdindex 0bb1d989e..25f0797e2 100644--- a/STRUCTURE.md+++ b/STRUCTURE.md@@ -155,6 +155,7 @@ bottom.| Forge thumbnail coverage | [api/_lib/forge-thumbs.js](api/_lib/forge-thumbs.js) + cron [api/cron/forge-thumbnail-backfill.js](api/cron/forge-thumbnail-backfill.js) (`*/5`) | Live | Gives every finished forge model a real picture. The dominant free NVIDIA/TRELLIS lane is geometry-first and paints no reference image, so ~83% of finished `forge_creations` land with `preview_image_url = NULL` and render as gradient placeholders on every browse surface (showcase, gallery, `/community`, `/search`, creator portfolios). This cron claims the newest previewless models, renders each GLB to a 768² PNG via the shared headless-chromium renderer ([api/_lib/render-glb.js](api/_lib/render-glb.js)), uploads it, and fills the preview slot — object confirmed in R2 **before** the key is committed (same ORB-safety invariant as avatars), and **fill-only** so a maker's captured poster always wins. Self-provisioning claim ledger (`forge_thumbnail_backfill`, created at runtime), bounded attempts, lease-based reclaim, browser-death batch abort with attempt refund. `?dry_run=1` reports coverage. Tests: [tests/forge-thumbs.test.js](tests/forge-thumbs.test.js). || Catalog quality gate (what earns a slot in the public catalog) | [api/_lib/seed-quality.js](api/_lib/seed-quality.js), consumed by [api/cron/forge-seed-cron.js](api/cron/forge-seed-cron.js) | Live · mesh stage always on, vision stage behind `SEED_CRON_VISION` | The bar every platform-seeded model clears before it reaches [/characters](public/characters.html) or [/objects](pages/objects.html). Nobody asked for seeded content, so it has to earn its slot: a user who generates a coarse mesh chose to, a visitor browsing the catalog did not. Two stages, cheapest first. **Mesh sanity** is free and deterministic (reuses [api/_lib/glb-quality.js](api/_lib/glb-quality.js), the interactive forge's own scorer, plus catalog bounds: vertex floor/ceiling, byte floor/ceiling, must-carry-a-texture, non-collapsed bbox, and a mesh-count rule that applies to `avatar` only because a prop may legitimately be a pile of parts): a degenerate blob is rejected here for the price of a GLB fetch and never costs a model call. **Vision judge** renders one view and asks two questions: realism via `judgeOnce` imported (never forked) from [api/_lib/quality-bench.js](api/_lib/quality-bench.js) so the gate and the regression bench can never disagree about what a score means, plus a catalog-specific rig-readiness check (one complete humanoid with separated limbs, or a bust / blob / crowd?). **Fails closed on mesh, fails soft on vision:** an unreachable judge publishes on the mesh verdict marked `vision_unavailable`, because recording a Vertex outage as a quality reject would corrupt the accept-rate maths. Rejects are copied (never moved) to `forge/rejected/` with a full-verdict JSON sidecar, which is the tuning dataset. `SEED_GATE_VERSION` stamps every verdict since an accept rate is only comparable within one version. Two transports (in-process for Cloud Run, remote via `/api/render/avatar-clip` + `/api/vision` for a credential-less workstation) share one decision path. Docs: [docs/seed-quality.md](docs/seed-quality.md). Tests: [tests/seed-quality.test.js](tests/seed-quality.test.js) || Forge-Off (community voting + weekly board) | Store [api/_lib/forge-store.js](api/_lib/forge-store.js) (`castVote`/`removeVote`/`listShowcase` sort+voter/`forgeOffWeekStart`), endpoint [api/forge-vote.js](api/forge-vote.js), board read [api/forge-gallery.js](api/forge-gallery.js) (`scope=community&sort=top&window=week`), weekly crown cron [api/cron/forge-off-crown.js](api/cron/forge-off-crown.js) (`7 0 * * 1`), UI [src/forge-showcase.js](src/forge-showcase.js) + `/forge-studio` twin [src/forge-studio/forge-showcase.js](src/forge-studio/forge-showcase.js), schema [migration 20260625120000_forge_board.sql](api/_lib/migrations/20260625120000_forge_board.sql) | Live | Turns the "Fresh from the Forge" strip on [/forge](pages/forge.html) into a live board: auth-free upvotes (one per browser, keyed to the same `forge:cid` id as "Your creations"), a Fresh/Top-this-week sort toggle, optimistic vote pills that reconcile against the authoritative `vote_count` (recomputed from `forge_votes`, never a drifting counter), and a Monday-00:07-UTC cron that permanently crowns each week's top-voted creation into `forge_board_winners`. The crown is the writer the [Sketchfab showcase](docs/sketchfab.md) cron's strongest tier had been waiting on. Docs: [docs/forge-off.md](docs/forge-off.md). Tests: [tests/api/forge-gallery-community.test.js](tests/api/forge-gallery-community.test.js) |+| Materialize (generation to a physical object) | Page [pages/materialize.html](pages/materialize.html) `→ /materialize` + [src/materialize-lib.js](src/materialize-lib.js), order tracking [src/materialize-order.js](src/materialize-order.js) `→ /materialize/orders/:id`, operator console [pages/materialize-ops.html](pages/materialize-ops.html) + [src/materialize-ops.js](src/materialize-ops.js) `→ /materialize/ops`, certificate page [pages/certificate.html](pages/certificate.html) `→ /cert/:id` + [src/certificate-page.js](src/certificate-page.js), insert card [pages/print-insert.html](pages/print-insert.html) `→ /materialize/insert/:id`. Engine [api/_lib/print/](api/_lib/print) (mesh-io, topology, bvh, voxel-sdf, analyze, repair, export-stl, export-3mf, quote, gate, rules, certificate, editions, adapters, fulfillment, ops-notify). State machine [api/_lib/print-store.js](api/_lib/print-store.js). HTTP [api/print/](api/print) (catalog, quote, prepare, upload, orders, orders/[id], orders/[id]/confirm, certs/[id], editions, ops/[action], webhook/[provider]) plus the agent lane [api/x402/print-order.js](api/x402/print-order.js). Catalog [data/print-catalog.json](data/print-catalog.json). Sweep [api/cron/print-orders-sync.js](api/cron/print-orders-sync.js) | Live | The physical lane of the forge: any generation becomes a real print, shipped. One `POST /api/print/quote` both analyzes the mesh (manifold check, shells, open edges, thinnest wall, exact volume via the Manifold WASM kernel, a 0-100 score with buyer-readable deductions) and prices it from one tunable catalog file, returning an HMAC-signed 24h quote token that carries every priced parameter so checkout cannot be replayed or edited. Prepare reconstructs the solid, fills holes, scales, optionally hollows with drain holes, and writes STL / 3MF (with per-vertex colour sampled from the source texture, which is what makes a full-colour print possible) / repaired GLB. Checkout is USDC on Solana for humans and x402 for agents, on the same pipeline: `POST /api/x402/print-order` validates the token and address BEFORE issuing the 402, so a malformed order is refused for free. Fulfillment is an adapter layer (manual operator lane plus a partner API) behind a whitelisted state machine; provider webhooks are HMAC-verified against the raw bytes and idempotent by delivery id. Every shipped print gets a Solana-attested certificate hashing the exact manufactured file. **The fabrication gate runs twice and is not advisory:** deterministically at quote time (before money moves, returning 451 with the category and the policy link) and again on the paid order through the LLM chain, with `submitOrder()` refusing anything without a recorded `allow` verdict. Docs: [docs/materialize.md](docs/materialize.md). Spec: [specs/PRINT_PIPELINE.md](specs/PRINT_PIPELINE.md). Tests: [tests/api/print-fabrication-gate.test.js](tests/api/print-fabrication-gate.test.js), [tests/api/print-gate-wiring.test.js](tests/api/print-gate-wiring.test.js), [tests/api/print-exporters.test.js](tests/api/print-exporters.test.js), [tests/print-store.test.js](tests/print-store.test.js), [tests/print-adapter-contract.test.js](tests/print-adapter-contract.test.js), [tests/print-certificate.test.js](tests/print-certificate.test.js), [tests/print-ops-authorization.test.js](tests/print-ops-authorization.test.js) || Realism quality bench | Benchmark [data/quality-bench/prompts.json](data/quality-bench/prompts.json) (23 fixed prompts + 3 CC0 reference photos), runner [scripts/quality-bench.mjs](scripts/quality-bench.mjs), shared generate/render/judge core [api/_lib/quality-bench.js](api/_lib/quality-bench.js), dashboard [api/quality-bench.js](api/quality-bench.js) + [pages/quality-bench.html](pages/quality-bench.html) `→ /quality-bench` (internal, not in `data/pages.json`), weekly smoke cron [api/cron/quality-bench.js](api/cron/quality-bench.js) (`23 3 * * 1`) | Live | The measurement loop the realism campaign hangs on: fires the fixed prompt set through the real `/api/forge` path, renders 3 canonical views per result with the same headless three.js renderer as the avatar clip/OG-card renders ([api/_lib/render-clip.js](api/_lib/render-clip.js)), and scores every view with Vertex Gemini vision (`gemini-2.5-pro`, temperature 0, scored twice and averaged, judge never sees forge's internal prompt-enhancement text). Runs are committed append-only JSON under `data/quality-bench/runs/`; the dashboard renders score trends by lane/tier/subject-class, a worst-5 critique gallery, and the full results table. `node scripts/quality-bench.mjs --compare=latest,previous` exits nonzero on a >1.0 mean drop — run it before/after any forge change that could affect quality. Docs: [data/quality-bench/README.md](data/quality-bench/README.md). || Likeness bench (Phase 1 verification metric) | Scoring core [api/_lib/likeness-score.js](api/_lib/likeness-score.js), face-embedding runtime [api/_lib/face-embed.js](api/_lib/face-embed.js), store + distribution queries [api/_lib/likeness-store.js](api/_lib/likeness-store.js) ([schema](api/_lib/migrations/20260814000000_avatar_likeness_scores.sql)), weekly sweep [api/cron/likeness-eval.js](api/cron/likeness-eval.js) (`47 3 * * 1`), by-hand runner [scripts/likeness-eval.mjs](scripts/likeness-eval.mjs), internal board [api/likeness-bench.js](api/likeness-bench.js) + [pages/likeness-bench.html](pages/likeness-bench.html) `→ /likeness-bench` (admin or `x-ops-secret`, not in `data/pages.json`) | Live · applied 2026-08-14 (this file alone, via `apply-migrations.mjs --apply --file`, because `db:migrate` would have applied seven other agents' pending migrations with it). The header comment still reads "Draft, NOT applied" and must stay that way: an applied migration is an immutable record and editing its bytes trips the drift guard | The number the roadmap gates Phase 1 on, measured instead of asserted. The realism bench scores whether a generation looks real and never asks whose face it is; the reconstruction worker's ISE eval scores face *shape* offline against a synthetic set and stores nothing. This closes the gap: it renders a finished reconstruction head-framed at three yaws (head-on 0°, three-quarter 35°, profile 65°) with the platform's own `headshot` preset, embeds every render and every input capture with OSS face recognition (YuNet detection, MIT + SFace 128-d identity, Apache-2.0, both hash-pinned from OpenCV Zoo and run on `onnxruntime-web`'s WASM backend so there is no native install step), and files a 1-5 score against the generation record in `forge_creations`. The 1-5 mapping is anchored on SFace's own published decision boundary (cosine 0.363 = 3.0, so the roadmap's 4/5 gate is cosine 0.68, roughly twice the same-identity threshold) rather than on taste. **Refuses rather than fabricates:** `captures_unusable`, `render_unusable` and a genuinely low score are three separate statuses, and a budget-truncated sweep is withheld from the distribution. Reports `turn_falloff` (identity lost between head-on and the worst view), which is the only place a frontally-flattering texture transfer is visible. **Stores no biometrics:** no capture URLs, no crops, no embeddings, only the measurement. Docs: [docs/likeness-eval.md](docs/likeness-eval.md). Tests: [tests/likeness-score.test.js](tests/likeness-score.test.js) || Payment-outcome board (x402 failure visibility) | Endpoint [api/ops/payment-outcomes.js](api/ops/payment-outcomes.js), page [pages/payment-outcomes.html](pages/payment-outcomes.html) `-> /payment-outcomes` (admin session or `x-ops-secret`, `noindex`, not in `data/pages.json`), sensors [api/_lib/ops/x402-settle-health.js](api/_lib/ops/x402-settle-health.js) + [api/_lib/x402/wallet-balance-monitor.js](api/_lib/x402/wallet-balance-monitor.js) + [api/_lib/x402/sponsor-runway.js](api/_lib/x402/sponsor-runway.js) + [api/_lib/custodial-key-health.js](api/_lib/custodial-key-health.js) | Live | Every way an x402 payment can fail, in one read, before it halts the economy. The 2026-07-11 audit found the griefing classes (verify-reject floods, settle failures, sponsor-fee starvation) were only visible after the economy stopped: `recordPaymentMetric` was already emitting the events and nothing surfaced them. Four panels: inbound rates over 1h/3h/24h from the durable `x402_audit_log` (settle success, verify reject, replay reject with its own `inbound_attempts` denominator, top failure reasons by stage, replay stage split), the outbound ring settle sensor with its triage hint, every configured ring wallet against **its own** floor plus the measured sponsor runway, and stranded custody. The wallet panel is per-wallet on purpose: settle-floor starvation and dry wallets look identical from outside and have opposite fixes, and a board showing only the sponsor renders a starved payer as healthy. Panels are read independently and a failed one names itself in `degraded` (207 Multi-Status) rather than blanking the board; on the page a rate with no attempts renders `n/a` and an unmeasured custody total renders `not measured`, because a green zero on a reading that never happened is worse than no board. Docs: [docs/ops/payment-outcomes.md](docs/ops/payment-outcomes.md). |diff --git a/pages/forge.html b/pages/forge.htmlindex b1aaf2073..b95842fbd 100644--- a/pages/forge.html+++ b/pages/forge.html@@ -3998,6 +3998,7 @@</button><a class="btn btn-ghost" id="open-in-composer" href="/compose" title="Open this model in Scene Composer to attach it to an avatar or place it in a scene" data-i18n="forge.compose" data-i18n-attr="title:forge.open_this_model_in_scene_com_title">Compose</a><a class="btn btn-ghost" id="download" download data-i18n="forge.download_glb">Download GLB</a>+ <a class="btn btn-ghost" id="materialize-it" href="/materialize" title="Order this model as a real, high-precision physical print, shipped to you">Materialize</a><button class="btn" type="button" id="again" data-i18n="forge.make_another">Make another</button></div></div>diff --git a/src/creations.js b/src/creations.jsindex 6906548a6..2e0cb8eba 100644--- a/src/creations.js+++ b/src/creations.js@@ -117,6 +117,7 @@ function cardHTML(item) {${item.viewerUrl ? `<a class="cr-card-btn" href="${esc(item.viewerUrl)}" target="_blank" rel="noopener noreferrer">View</a>` : ''}<button class="cr-card-btn" type="button" data-lineage="${esc(item.id)}" aria-controls="cr-lineage-panel">Lineage</button>${item.prompt ? `<button class="cr-card-btn" type="button" data-copy-prompt="${esc(item.id)}" title="Copy the prompt that generated this model">Copy prompt</button>` : ''}+ <a class="cr-card-btn" href="/materialize?creation=${esc(item.id)}" title="Order this creation as a real physical print, shipped to you">Materialize</a><button class="cr-card-btn cr-card-btn--remix" type="button" data-remix-open="${esc(item.id)}">Remix — $0.25</button><span class="cr-time">${esc(timeAgo(item.createdAt))}</span></div>diff --git a/src/forge.js b/src/forge.jsindex b40111034..185dc1e22 100644--- a/src/forge.js+++ b/src/forge.js@@ -108,6 +108,7 @@ const els = {resultQuality: document.getElementById('result-quality'),verdict: document.getElementById('verdict'),download: document.getElementById('download'),+ materialize: document.getElementById('materialize-it'),again: document.getElementById('again'),refine: document.getElementById('refine'),refineLabel: document.getElementById('refine-label'),@@ -1993,6 +1994,19 @@ function showResult(glbUrl, label, meta, { autoSaved = false } = {}) {// Hide after animation completes (3s).setTimeout(() => els.savedChip?.classList.add('is-hidden'), 3100);}+ // Deep-link the physical lane at THIS generation. A creation id is the+ // better handle (it carries the prompt and the creator through to the+ // print), but a model that has not been persisted yet still materializes+ // from its own URL, so the action is never dead.+ if (els.materialize) {+ const handle = currentCreationId+ ? `?creation=${encodeURIComponent(currentCreationId)}`+ : glbUrl && !glbUrl.startsWith('blob:')+ ? `?glb=${encodeURIComponent(glbUrl)}`+ : '';+ els.materialize.href = `/materialize${handle}`;+ els.materialize.hidden = false;+ }els.download.href = glbUrl;els.download.setAttribute('download',diff --git a/src/materialize-ops.css b/src/materialize-ops.cssindex 0ab1dde23..096cf4fc6 100644--- a/src/materialize-ops.css+++ b/src/materialize-ops.css@@ -289,7 +289,10 @@opacity: 0;pointer-events: none;transition: opacity var(--dur-med, 220ms) var(--ease-out, ease);- z-index: 60;+ /* Above the sticky site header (nav.css uses z-index 100). The drawer is a+ modal surface: an operator reaching for Close must not hit a nav link that+ navigates away mid-job, which is exactly what happened at z-index 60. */+ z-index: 300;}.mo-drawer-scrim[data-open='true'] { opacity: 1; pointer-events: auto; }@@ -306,7 +309,7 @@border-left: 1px solid var(--color-border);transform: translateX(100%);transition: transform var(--dur-med, 220ms) var(--ease-out, ease);- z-index: 61;+ z-index: 301;overflow: hidden;}diff --git a/src/materialize-ops.js b/src/materialize-ops.jsindex 98c32b7a9..a4e57330f 100644--- a/src/materialize-ops.js+++ b/src/materialize-ops.js@@ -52,6 +52,12 @@ let counts = {};let adapters = [];let openOrderId = null;let lastFocused = null;+// The outcome of the last action, kept OUTSIDE the drawer's markup. Every+// action reloads the order, which re-renders the drawer, and an operator who+// loses the result line has no idea whether their click landed. The refund+// payout instruction matters even more: it carries the recipient and amount for+// an owner-executed transfer, and it must survive the reload that follows it.+let lastResult = null;const esc = (v) =>String(v ?? '').replace(/[&<>"']/g, (c) => ({ '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' })[c]);@@ -194,6 +200,7 @@ function openDrawer(orderId) {function closeDrawer() {openOrderId = null;+ lastResult = null;drawer.dataset.open = 'false';scrim.dataset.open = 'false';drawer.setAttribute('aria-hidden', 'true');@@ -330,8 +337,8 @@ function detailHtml({ order, events, webhook_deliveries: deliveries }) {? `<p class="mo-note">This order is closed. Nothing further can move it.</p>`: ''}</div>- <p class="mo-note" id="mo-result" role="status" aria-live="polite"></p>- <div id="mo-payout"></div>+ <p class="mo-note" id="mo-result" role="status" aria-live="polite"${resultFor(order.id) ? ` data-tone="${esc(resultFor(order.id).tone || '')}"` : ''}>${esc(resultFor(order.id)?.message || '')}</p>+ <div id="mo-payout">${payoutHtml(resultFor(order.id)?.payout)}</div></section><section>@@ -350,37 +357,47 @@ function detailHtml({ order, events, webhook_deliveries: deliveries }) {</section>`;}+/** The stored outcome, but only for the order it belongs to. */+function resultFor(orderId) {+ return lastResult && lastResult.orderId === orderId ? lastResult : null;+}++// The owner action a refund produces. Rendered from the API's own payout block,+// never recomputed here: no money number on this page is invented by the page.+function payoutHtml(payout) {+ if (!payout) return '';+ return `<p class="mo-payout"><strong>Owner action required.</strong>+ Send <strong>${Number(payout.amount_usdc || 0).toFixed(2)} USDC</strong> on Solana to+ <span class="mo-mono">${esc(payout.recipient || 'the buyer account')}</span>.+ ${esc(payout.instruction || '')}</p>`;+}+function wireDetail(data) {const order = data.order;- const result = drawerBody.querySelector('#mo-result');- const payoutEl = drawerBody.querySelector('#mo-payout');- const say = (message, tone = '') => {- result.textContent = message;- if (tone) result.dataset.tone = tone;- else delete result.dataset.tone;+ const say = (message, tone = '', payout = null) => {+ lastResult = { orderId: order.id, message, tone, payout };+ const el = drawerBody.querySelector('#mo-result');+ if (!el) return;+ el.textContent = message;+ if (tone) el.dataset.tone = tone;+ else delete el.dataset.tone;};const run = async (button, work) => {const buttons = [...drawerBody.querySelectorAll('button[data-act]')];for (const b of buttons) b.disabled = true;- button.dataset.busy = 'true';say('Working…');try {const body = await work();- say(body.message || 'Done.', 'ok');- if (body.payout) {- payoutEl.innerHTML = `<p class="mo-payout"><strong>Owner action required.</strong>- Send <strong>${Number(body.payout.amount_usdc || 0).toFixed(2)} USDC</strong> on Solana to- <span class="mo-mono">${esc(body.payout.recipient || 'the buyer account')}</span>.- ${esc(body.payout.instruction)}</p>`;- }+ // Stored before the reload, rendered again by detailHtml afterwards, so+ // the operator reads the outcome rather than watching it flash past.+ say(body.message || 'Done.', 'ok', body.payout || null);await loadQueue();await loadDetail(order.id);} catch (err) {say(err.message, 'error');for (const b of buttons) b.disabled = false;- delete button.dataset.busy;}};diff --git a/src/model-page.js b/src/model-page.jsindex 8a2588ca3..2be89db3b 100644--- a/src/model-page.js+++ b/src/model-page.js@@ -230,6 +230,7 @@ function renderInfo() {<span class="mp-stat" title="Page views">👁 <b id="mp-views">${formatCount(c.view_count)}</b></span>${c.remix_count ? `<span class="mp-stat" title="Remixes">⑂ <b>${formatCount(c.remix_count)}</b></span>` : ''}<a class="mp-action" href="${esc(c.glb_url)}" download>Download GLB</a>+ <a class="mp-action" href="/materialize?creation=${encodeURIComponent(c.id)}" title="Order this model as a real physical print, shipped to you">⬢ Materialize</a><button class="mp-action" id="mp-embed" type="button"></> Embed</button><button class="mp-action" id="mp-share" type="button">↗ Share</button>${c.remixable ? `<button class="mp-action" id="mp-remix" type="button">Remix · $0.25</button>` : ''}