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.

feat(forge): name Tripo and its model version in the result card and exported GLB

nirholas4a21260ed3da
diff --git a/api/_lib/forge-store.js b/api/_lib/forge-store.js
index 23ca8f694..77c743923 100644
--- a/api/_lib/forge-store.js
+++ b/api/_lib/forge-store.js
@@ -33,6 +33,7 @@ import { gradeSimReadiness } from './sim-readiness.js';
import { putGrade } from './sim-readiness-store.js';
import { dispatchWebhooks } from './webhook-dispatch.js';
import { autoCredentialForBytes } from './auto-provenance.js';
+import { tripoModelVersion } from '../_providers/tripo.js';
import { validForgeDestination } from '../../src/shared/forge-destinations.js';
// Stable, non-secret salt so a leaked DB row can't be trivially reversed to the
@@ -1296,6 +1297,10 @@ export async function listCreations({ clientKey, limit = 24 }) {
backend: r.backend ?? null,
tier: r.tier ?? null,
path: r.path ?? null,
+ // Not a stored column: Tripo's model version is a deployment-wide
+ // setting, read live the same way pollJob does, so the gallery card
+ // names exactly what produced the mesh without a schema change.
+ engine_version: r.backend === 'tripo' ? tripoModelVersion() : null,
model_category: r.model_category ?? 'other',
created_at: r.created_at,
}));
diff --git a/api/_providers/tripo.js b/api/_providers/tripo.js
index db18472cf..d0d03e15d 100644
--- a/api/_providers/tripo.js
+++ b/api/_providers/tripo.js
@@ -42,6 +42,11 @@ function modelVersion() {
return DEFAULT_MODEL_VERSION;
}
+// Exported so forge.js and the exported-file attribution stamp can name the
+// exact version a job ran on, without a second source of truth: this is the
+// same value threaded into every request body below.
+export const tripoModelVersion = modelVersion;
+
function mapStatus(s) {
switch (String(s || '').toLowerCase()) {
case 'queued':
diff --git a/api/forge.js b/api/forge.js
index 0a03595f6..5a3498de8 100644
--- a/api/forge.js
+++ b/api/forge.js
@@ -60,6 +60,7 @@ import { textToImage, synthesizeTurnaroundViews } from './_mcp3d/text-to-image.j
import { createRegenProvider } from './_providers/replicate.js';
import { createRegenProvider as createGcpProvider } from './_providers/gcp.js';
import { BYOK_PROVIDER_FACTORIES } from './_providers/byok-registry.js';
+import { tripoModelVersion } from './_providers/tripo.js';
import {
PATHS,
DEFAULT_PATH,
@@ -1862,6 +1863,7 @@ async function startJobWithBody(req, res, body) {
path,
tier: tier.id,
backend: backendId,
+ engine_version: byokProvider === 'tripo' ? tripoModelVersion() : undefined,
prompt: prompt || null,
preview_image_url: previewImageUrl,
reference_image_urls: isImageMode ? [imageUrls[0]] : [],
@@ -1904,6 +1906,7 @@ async function startJobWithBody(req, res, body) {
path,
tier: tier.id,
backend: backendId,
+ engine_version: byokProvider === 'tripo' ? tripoModelVersion() : undefined,
prompt: prompt || null,
preview_image_url: previewImageUrl,
reference_image_urls: isImageMode ? [imageUrls[0]] : [],
@@ -3164,6 +3167,10 @@ async function pollJob(req, res, jobId) {
backend: meta.backend ?? null,
tier: meta.tier ?? null,
path: meta.path ?? null,
+ // Tripo's model version is a deployment-wide setting (TRIPO_MODEL_VERSION
+ // or the provider's default), read live rather than stored per row: it
+ // cannot drift between submit and poll within the same job's lifetime.
+ engine_version: meta.backend === 'tripo' ? tripoModelVersion() : null,
// The reference view this job reconstructs from. The submit response
// already carries it, but a client that never saw that response -
// a coalesced job, a resumed job after a reload, a poll-time failover
diff --git a/src/forge.js b/src/forge.js
index c1f0c9af5..e8b349c95 100644
--- a/src/forge.js
+++ b/src/forge.js
@@ -2436,6 +2436,11 @@ function showResult(glbUrl, label, meta, { autoSaved = false, downloadUrl = null
}
linkResultTools(glbUrl);
els.download.href = downloadUrl || glbUrl;
+ // Carried to the download click handler below so the exported file's
+ // metadata can name the exact engine (and, for Tripo, model version) that
+ // produced it, deterministically rather than sniffed from the upstream GLB.
+ els.download.dataset.engine = meta?.backend || '';
+ els.download.dataset.engineVersion = meta?.engine_version || '';
els.download.setAttribute(
'download',
`${
@@ -2589,7 +2594,7 @@ async function loadGallery() {
.filter(Boolean)
.join(' ');
prov.title =
- `${c.path === 'geometry' ? 'Geometry-first' : c.path === 'sketch' ? 'Sketch→3D' : 'Image path'} · ${c.backend || ''} · ${c.tier || ''}`.trim();
+ `${c.path === 'geometry' ? 'Geometry-first' : c.path === 'sketch' ? 'Sketch→3D' : 'Image path'} · ${c.backend || ''}${c.engine_version ? ` ${c.engine_version}` : ''} · ${c.tier || ''}`.trim();
card.appendChild(prov);
}
@@ -4097,6 +4102,8 @@ els.download.addEventListener('click', async (e) => {
if (!res.ok) throw new Error(`fetch ${res.status}`);
const stamped = stampGlbAttribution(await res.arrayBuffer(), {
prompt: els.resultLabel?.textContent || '',
+ engine: ENGINE_LABELS[els.download.dataset.engine] || els.download.dataset.engine || undefined,
+ engineVersion: els.download.dataset.engineVersion || undefined,
});
const blobUrl = URL.createObjectURL(new Blob([stamped], { type: 'model/gltf-binary' }));
const a = document.createElement('a');
diff --git a/src/shared/glb-attribution.js b/src/shared/glb-attribution.js
index b9efd07a3..7259f0164 100644
--- a/src/shared/glb-attribution.js
+++ b/src/shared/glb-attribution.js
@@ -16,11 +16,11 @@ export const FORGE_GENERATOR = 'three.ws Forge — text/image → 3D (https://th
/**
* @param {ArrayBuffer} buffer A complete .glb file.
- * @param {{ prompt?: string, source?: string }} [meta]
+ * @param {{ prompt?: string, source?: string, engine?: string, engineVersion?: string }} [meta]
* @returns {ArrayBuffer} A new .glb with attribution stamped into asset.*.
* @throws {Error} If the buffer is not a well-formed glTF 2.0 binary.
*/
-export function stampGlbAttribution(buffer, { prompt, source = 'https://three.ws/forge' } = {}) {
+export function stampGlbAttribution(buffer, { prompt, source = 'https://three.ws/forge', engine, engineVersion } = {}) {
const dv = new DataView(buffer);
if (buffer.byteLength < 20 || dv.getUint32(0, true) !== GLB_MAGIC) {
throw new Error('not a GLB container');
@@ -42,6 +42,11 @@ export function stampGlbAttribution(buffer, { prompt, source = 'https://three.ws
json.asset.generator = FORGE_GENERATOR;
extras.source = source;
if (prompt) extras.prompt = String(prompt).slice(0, 500);
+ // Deterministic, platform-reported engine name/version: authoritative over
+ // extras.pipeline above, which only carries whatever string the upstream
+ // engine's own GLB happened to self-report.
+ if (engine) extras.engine = engine;
+ if (engineVersion) extras.engineVersion = engineVersion;
json.asset.extras = extras;
// Re-encode and pad to the 4-byte boundary the spec requires (0x20 for JSON).
diff --git a/tests/api/forge-tripo-engine-version.test.js b/tests/api/forge-tripo-engine-version.test.js
new file mode 100644
index 000000000..288b85736
--- /dev/null
+++ b/tests/api/forge-tripo-engine-version.test.js
@@ -0,0 +1,111 @@
+// Tripo submit responses name the exact model version the job ran on (work
+// order 084-partners-01, task 5: attribution). The version is a deployment-
+// wide setting (TRIPO_MODEL_VERSION, or the provider's default), read live at
+// response-build time rather than stored per row. Mirrors the harness in
+// tests/forge-high-gate-tripo-house.test.js: a stubbed fetch models Tripo's
+// real v3 wire protocol instead of touching the network.
+
+import { describe, it, expect, beforeEach, afterEach, vi } from 'vitest';
+import { Readable } from 'node:stream';
+
+let forge;
+const ORIGINAL_FETCH = globalThis.fetch;
+
+function mockRes() {
+ return {
+ statusCode: 200, _headers: {}, _body: '', _ended: false,
+ setHeader(k, v) { this._headers[k.toLowerCase()] = v; },
+ getHeader(k) { return this._headers[k.toLowerCase()]; },
+ end(b) { this._body = b || ''; this._ended = true; },
+ get json() { try { return JSON.parse(this._body); } catch { return null; } },
+ };
+}
+
+function mockReq({ body = null, headers = {} } = {}) {
+ const chunks = body != null ? [Buffer.from(JSON.stringify(body))] : [];
+ const r = Readable.from(chunks);
+ r.method = 'POST';
+ r.url = '/api/forge';
+ r.headers = { origin: 'http://localhost:3000', 'content-type': 'application/json', ...headers };
+ return r;
+}
+
+beforeEach(async () => {
+ vi.resetModules();
+ process.env.NODE_ENV = 'development';
+ process.env.APP_ORIGIN = 'https://three.ws';
+ process.env.JWT_SECRET = 'test-jwt-secret-at-least-32-characters-long';
+ delete process.env.TRIPO_API_KEY;
+ delete process.env.TRIPO_MODEL_VERSION;
+ delete process.env.HOLDER_PASS_SECRET;
+ globalThis.fetch = vi.fn(async () => ({
+ ok: true,
+ status: 200,
+ json: async () => ({ code: 0, data: { task_id: 'task-submitted-1' } }),
+ }));
+ forge = (await import('../../api/forge.js')).default;
+});
+
+afterEach(() => {
+ globalThis.fetch = ORIGINAL_FETCH;
+ delete process.env.TRIPO_MODEL_VERSION;
+ vi.restoreAllMocks();
+});
+
+describe('POST /api/forge: Tripo submit response names the engine version', () => {
+ it('names the default model version on a queued job', async () => {
+ const res = await (async () => {
+ const r = mockRes();
+ await forge(
+ mockReq({
+ body: { prompt: 'a brass telescope', tier: 'high', backend: 'tripo' },
+ headers: { 'x-forge-provider-key': 'caller-own-key' },
+ }),
+ r,
+ );
+ return r;
+ })();
+ expect(res.json?.backend).toBe('tripo');
+ expect(res.json?.status).toBe('queued');
+ expect(res.json?.engine_version).toBe('v3.1-20260211');
+ });
+
+ it('reflects an operator override via TRIPO_MODEL_VERSION', async () => {
+ process.env.TRIPO_MODEL_VERSION = 'v3.2-beta';
+ vi.resetModules();
+ forge = (await import('../../api/forge.js')).default;
+ const res = await (async () => {
+ const r = mockRes();
+ await forge(
+ mockReq({
+ body: { prompt: 'a brass telescope', tier: 'high', backend: 'tripo' },
+ headers: { 'x-forge-provider-key': 'caller-own-key' },
+ }),
+ r,
+ );
+ return r;
+ })();
+ expect(res.json?.engine_version).toBe('v3.2-beta');
+ });
+
+ it('never names an engine version for a non-Tripo backend', async () => {
+ const res = await (async () => {
+ const r = mockRes();
+ globalThis.fetch = vi.fn(async () => ({
+ ok: true,
+ status: 200,
+ json: async () => ({ result: 'meshy-task-1' }),
+ }));
+ await forge(
+ mockReq({
+ body: { prompt: 'a brass telescope', tier: 'high', backend: 'meshy' },
+ headers: { 'x-forge-provider-key': 'caller-own-key' },
+ }),
+ r,
+ );
+ return r;
+ })();
+ expect(res.json?.backend).toBe('meshy');
+ expect(res.json?.engine_version).toBeUndefined();
+ });
+});
diff --git a/tests/forge-store-list-engine-version.test.js b/tests/forge-store-list-engine-version.test.js
new file mode 100644
index 000000000..be9a44325
--- /dev/null
+++ b/tests/forge-store-list-engine-version.test.js
@@ -0,0 +1,84 @@
+/**
+ * listCreations() surfaces engine_version for Tripo rows (work order
+ * 084-partners-01, task 5: attribution). Tripo's model version is a
+ * deployment-wide setting (TRIPO_MODEL_VERSION or the provider's default),
+ * not a stored column, so this is computed live the same way pollJob does
+ * in api/forge.js rather than requiring a schema change.
+ */
+import { describe, it, expect, vi, beforeAll, afterEach } from 'vitest';
+
+beforeAll(() => {
+ Object.assign(process.env, {
+ DATABASE_URL: 'postgres://test:test@localhost:5432/test',
+ S3_ENDPOINT: 'https://s3.example.com',
+ S3_BUCKET: 'test-bucket',
+ S3_PUBLIC_DOMAIN: 'https://cdn.example.com',
+ S3_ACCESS_KEY_ID: 'test-key',
+ S3_SECRET_ACCESS_KEY: 'test-secret',
+ });
+});
+
+let rows = [];
+const sqlMock = vi.fn(async () => rows);
+
+vi.mock('../api/_lib/db.js', () => ({
+ sql: (...args) => sqlMock(...args),
+ isDbUnavailableError: () => false,
+}));
+
+vi.mock('../api/_lib/r2.js', () => ({
+ putObject: vi.fn(async () => {}),
+ objectStorageConfigured: () => true,
+ publicUrl: (key) => `https://cdn.example.com/${key}`,
+ deleteObject: vi.fn(async () => {}),
+ keyFromPublicUrl: () => null,
+}));
+
+const { listCreations } = await import('../api/_lib/forge-store.js');
+
+afterEach(() => {
+ sqlMock.mockClear();
+ delete process.env.TRIPO_MODEL_VERSION;
+});
+
+describe('listCreations: engine_version', () => {
+ it('names the live Tripo model version for a tripo-backed row', async () => {
+ rows = [
+ {
+ id: 'c1', prompt: 'a brass owl', aspect: '1:1', glb_url: 'https://cdn/x.glb',
+ web_glb_url: null, preview_image_url: null, outcome: 'generated', downloaded: false,
+ views_used: null, multiview: false, backend: 'tripo', tier: 'high', path: 'geometry',
+ model_category: 'other', created_at: new Date().toISOString(),
+ },
+ ];
+ const [row] = await listCreations({ clientKey: 'client-1' });
+ expect(row.engine_version).toBe('v3.1-20260211');
+ });
+
+ it('reflects TRIPO_MODEL_VERSION when the operator overrides it', async () => {
+ process.env.TRIPO_MODEL_VERSION = 'v3.2-beta';
+ rows = [
+ {
+ id: 'c2', prompt: 'x', aspect: null, glb_url: 'https://cdn/y.glb',
+ web_glb_url: null, preview_image_url: null, outcome: 'generated', downloaded: false,
+ views_used: null, multiview: false, backend: 'tripo', tier: 'high', path: 'geometry',
+ model_category: 'other', created_at: new Date().toISOString(),
+ },
+ ];
+ const [row] = await listCreations({ clientKey: 'client-1' });
+ expect(row.engine_version).toBe('v3.2-beta');
+ });
+
+ it('is null for a non-Tripo backend', async () => {
+ rows = [
+ {
+ id: 'c3', prompt: 'x', aspect: null, glb_url: 'https://cdn/z.glb',
+ web_glb_url: null, preview_image_url: null, outcome: 'generated', downloaded: false,
+ views_used: null, multiview: false, backend: 'trellis', tier: 'standard', path: 'image',
+ model_category: 'other', created_at: new Date().toISOString(),
+ },
+ ];
+ const [row] = await listCreations({ clientKey: 'client-1' });
+ expect(row.engine_version).toBeNull();
+ });
+});
diff --git a/tests/glb-attribution.test.js b/tests/glb-attribution.test.js
index 77bec68d0..1347c8956 100644
--- a/tests/glb-attribution.test.js
+++ b/tests/glb-attribution.test.js
@@ -69,6 +69,21 @@ describe('stampGlbAttribution', () => {
expect(out.json.asset.extras.pipeline).toBe('TRELLIS reconstructor');
});
+ it('stamps an explicit engine and model version, authoritative over the sniffed generator', () => {
+ const glb = buildGlb({ asset: { version: '2.0', generator: 'some upstream string' } });
+ const out = parseGlb(stampGlbAttribution(glb, { engine: 'Tripo', engineVersion: 'v3.1-20260211' }));
+ expect(out.json.asset.extras.engine).toBe('Tripo');
+ expect(out.json.asset.extras.engineVersion).toBe('v3.1-20260211');
+ expect(out.json.asset.extras.pipeline).toBe('some upstream string');
+ });
+
+ it('omits engine/engineVersion from extras when not given', () => {
+ const glb = buildGlb({ asset: { version: '2.0' } });
+ const out = parseGlb(stampGlbAttribution(glb, { prompt: 'x' }));
+ expect(out.json.asset.extras.engine).toBeUndefined();
+ expect(out.json.asset.extras.engineVersion).toBeUndefined();
+ });
+
it('keeps the BIN chunk byte-for-byte and updates lengths/alignment', () => {
const bin = new Uint8Array([1, 2, 3, 4, 5, 6, 7]); // 7 bytes → padded chunk
const glb = buildGlb({ asset: { version: '2.0' } }, bin);