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(workbench): add rest-pose/bbox generate controls and a batch queue panel

nirholasa39ae25c9c74
diff --git a/pages/workbench.html b/pages/workbench.html
index edce77b99..3edf1d10e 100644
--- a/pages/workbench.html
+++ b/pages/workbench.html
@@ -184,6 +184,9 @@
<button class="wb-strip-btn" type="button" id="wb-history-btn" data-tip="History (H)" aria-label="Generation history" aria-pressed="false" aria-controls="wb-history">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" aria-hidden="true"><circle cx="12" cy="12" r="9"/><path d="M12 7v5l3 2"/></svg>
</button>
+ <button class="wb-strip-btn" type="button" id="wb-batch-btn" data-tip="Batch (B)" aria-label="Batch queue" aria-pressed="false" aria-controls="wb-batch">
+ <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><rect x="3" y="3" width="7" height="7" rx="1.2"/><rect x="14" y="3" width="7" height="7" rx="1.2"/><rect x="3" y="14" width="7" height="7" rx="1.2"/><rect x="14" y="14" width="7" height="7" rx="1.2"/></svg>
+ </button>
<hr />
<button class="wb-strip-btn" type="button" id="wb-frame" data-tip="Frame model (F)" aria-label="Frame the model">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" aria-hidden="true"><path d="M4 9V4h5M20 9V4h-5M4 15v5h5M20 15v5h-5"/><circle cx="12" cy="12" r="2.5"/></svg>
@@ -201,6 +204,16 @@
<ul id="wb-history-list"></ul>
</section>
+ <section class="wb-history wb-batch" id="wb-batch" aria-label="Batch queue">
+ <header>
+ <strong>Batch</strong>
+ <button class="wb-btn" id="wb-batch-submit" type="button">Submit</button>
+ </header>
+ <p class="wb-batch-hint">One idea per line, up to 8. Uses the Generate Mesh node's current engine, quality and controls for every item.</p>
+ <textarea id="wb-batch-prompts" rows="4" placeholder="a red leather armchair&#10;a cracked clay pot&#10;a sci-fi helmet"></textarea>
+ <ul id="wb-batch-list"></ul>
+ </section>
+
<div class="wb-empty" id="wb-empty">
<div class="wb-empty-card">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.2" stroke-linejoin="round" aria-hidden="true"><path d="M12 2.8 20 7.4v9.2l-8 4.6-8-4.6V7.4z"/><path d="M4 7.4 12 12l8-4.6M12 12v9.2"/></svg>
diff --git a/src/workbench/api.js b/src/workbench/api.js
index 3e2476c0e..37e425244 100644
--- a/src/workbench/api.js
+++ b/src/workbench/api.js
@@ -250,3 +250,25 @@ export async function restyle(glbUrl, instruction, { signal } = {}) {
if (!res.ok || !data.glbUrl) throw toError(res, data, 'The material restyle failed.');
return data;
}
+
+/**
+ * Submit up to 8 /api/forge bodies as one group (api/forge-batch.js).
+ * @returns {Promise<{batch_id:string, status:string, items:object[]}>}
+ */
+export async function submitBatch(items, { signal } = {}) {
+ const { res, data } = await request('/api/forge-batch', {
+ method: 'POST',
+ signal,
+ headers: baseHeaders({ 'content-type': 'application/json' }),
+ body: JSON.stringify({ items }),
+ });
+ if (!res.ok || !data.batch_id) throw toError(res, data, `The batch could not start (${res.status}).`);
+ return data;
+}
+
+/** One status check on a batch group started with submitBatch(). */
+export async function pollBatchGroup(batchId, { signal } = {}) {
+ const { res, data } = await request(`/api/forge-batch?batch=${encodeURIComponent(batchId)}`, { signal, headers: baseHeaders() });
+ if (!res.ok) throw toError(res, data, `The batch could not be checked (${res.status}).`);
+ return data;
+}
diff --git a/src/workbench/main.js b/src/workbench/main.js
index 98f7fab9d..b74637922 100644
--- a/src/workbench/main.js
+++ b/src/workbench/main.js
@@ -5,9 +5,9 @@
import { mountViewport } from './viewport.js';
import { mountGraphEditor } from './graph-editor.js';
-import { runWorkflow } from './runner.js';
+import { generateBody, runWorkflow } from './runner.js';
import { countScene, decimateScene, smoothScene } from './mesh-tools.js';
-import { CLIENT_ID, fetchCatalog, fetchHealth, uploadImage } from './api.js';
+import { CLIENT_ID, fetchCatalog, fetchHealth, pollBatchGroup, submitBatch, uploadImage } from './api.js';
import {
NODE_TYPES,
PALETTE,
@@ -84,6 +84,16 @@ let editDepth = 0;
let hasModel = false;
let run = null;
+// Batch queue drawer: one group of fan-out prompt submissions (api/forge-batch.js),
+// polled on an interval until every item is terminal. Transient (not persisted):
+// the server already holds each group for an hour, so a reload just loses the
+// drawer's view of it, not the jobs themselves.
+const BATCH_MAX_ITEMS = 8;
+let batchId = null;
+let batchItems = [];
+let batchPollTimer = null;
+let batchSubmitting = false;
+
const activeFlow = () => flows.find((f) => f.id === activeId) || flows[0];
const editingFlow = () => flows.find((f) => f.id === editingId) || activeFlow();
@@ -247,7 +257,10 @@ function paramControl(node, p) {
onchange: (e) => {
const raw = e.target.value.trim();
if (raw === '') return set('');
- const n = Math.min(p.max, Math.max(p.min, Math.round(Number(raw))));
+ const step = Number(p.step) || 1;
+ const decimals = (String(step).split('.')[1] || '').length;
+ const snapped = Math.round(Number(raw) / step) * step;
+ const n = Number(Math.min(p.max, Math.max(p.min, snapped)).toFixed(decimals));
e.target.value = String(n);
set(n);
},
@@ -811,6 +824,7 @@ function toggleHistory(force) {
panel.dataset.open = String(open);
$('wb-history-btn').setAttribute('aria-pressed', String(open));
if (open) {
+ toggleBatch(false);
renderHistory();
panel.querySelector('button')?.focus({ preventScroll: true });
}
@@ -819,6 +833,7 @@ function toggleHistory(force) {
async function openRemote(url, name) {
if (run) return;
toggleHistory(false);
+ toggleBatch(false);
setBusy(true, { title: 'Loading model', text: name });
try {
await vp.loadGLB(url);
@@ -832,6 +847,117 @@ async function openRemote(url, name) {
}
}
+// ── batch queue ──────────────────────────────────────────────
+
+function toggleBatch(force) {
+ const panel = $('wb-batch');
+ const open = force ?? panel.dataset.open !== 'true';
+ panel.dataset.open = String(open);
+ $('wb-batch-btn').setAttribute('aria-pressed', String(open));
+ if (open) {
+ toggleHistory(false);
+ renderBatchList();
+ }
+}
+
+const BATCH_STATE_TEXT = {
+ queued: 'In line for a GPU',
+ running: 'Running',
+ done: 'Ready',
+ failed: 'Failed',
+};
+
+function renderBatchList() {
+ const list = $('wb-batch-list');
+ const submitBtn = $('wb-batch-submit');
+ submitBtn.disabled = batchSubmitting;
+ submitBtn.textContent = batchSubmitting ? 'Submitting…' : 'Submit';
+ if (!batchItems.length) {
+ list.replaceChildren(
+ h('li', { class: 'wb-history-empty', text: 'Queue a few prompts at once. Each one runs as its own job and lands here when ready.' }),
+ );
+ return;
+ }
+ list.replaceChildren(
+ ...batchItems.map((item) => {
+ const state = item.ok === false ? 'failed' : item.status || 'queued';
+ const row = h(
+ 'li',
+ { class: 'wb-batch-item', dataset: { state } },
+ h('span', {}, h('strong', { text: item.name }), h('small', { text: item.ok === false ? item.message || 'Failed' : BATCH_STATE_TEXT[state] || state })),
+ );
+ if (item.ok !== false && item.status === 'done' && item.glb_url) {
+ row.append(h('button', { class: 'wb-btn', type: 'button', text: 'Open', onclick: () => openRemote(item.glb_url, item.name) }));
+ }
+ return row;
+ }),
+ );
+}
+
+function stopBatchPolling() {
+ if (batchPollTimer) clearInterval(batchPollTimer);
+ batchPollTimer = null;
+}
+
+function startBatchPolling() {
+ stopBatchPolling();
+ batchPollTimer = setInterval(async () => {
+ if (!batchId) return stopBatchPolling();
+ try {
+ const group = await pollBatchGroup(batchId);
+ batchItems = group.items.map((item, i) => ({ ...batchItems[i], ...item }));
+ renderBatchList();
+ if (group.status === 'done' || group.status === 'partial') {
+ stopBatchPolling();
+ const ok = batchItems.filter((i) => i.ok !== false && i.status === 'done').length;
+ toast(`Batch finished: ${ok}/${batchItems.length} ready.`, { tone: group.status === 'done' ? 'ok' : 'warn' });
+ }
+ } catch {
+ // A transient poll failure keeps the last known status; the next tick retries.
+ }
+ }, 3000);
+}
+
+async function submitBatchFromPanel() {
+ if (batchSubmitting) return;
+ const prompts = $('wb-batch-prompts').value
+ .split('\n')
+ .map((s) => s.trim())
+ .filter(Boolean);
+ if (!prompts.length) {
+ toast('Add at least one prompt, one per line.', { tone: 'warn' });
+ return;
+ }
+ if (prompts.length > BATCH_MAX_ITEMS) {
+ toast(`A batch holds at most ${BATCH_MAX_ITEMS} prompts; only the first ${BATCH_MAX_ITEMS} were queued.`, { tone: 'warn' });
+ prompts.length = BATCH_MAX_ITEMS;
+ }
+
+ const node = generateNode(activeFlow());
+ const items = prompts.map((prompt) => generateBody(node.params, { prompt }));
+
+ stopBatchPolling();
+ batchId = null;
+ batchSubmitting = true;
+ batchItems = prompts.map((prompt) => ({ name: prompt.slice(0, 48), status: 'queued' }));
+ renderBatchList();
+
+ try {
+ const group = await submitBatch(items);
+ batchId = group.batch_id;
+ batchItems = group.items.map((item, i) => ({ name: batchItems[i].name, ...item }));
+ renderBatchList();
+ $('wb-batch-prompts').value = '';
+ startBatchPolling();
+ } catch (err) {
+ batchItems = [];
+ toast(`The batch could not start: ${err.message}`, { tone: 'err' });
+ } finally {
+ batchSubmitting = false;
+ renderBatchList();
+ }
+}
+
// ── viewport tools ─────────────────────────────────────────────
function syncModelTools() {
@@ -1045,6 +1171,8 @@ function wireViewport() {
$('wb-spin').addEventListener('click', () => setSpin(!vp.autoRotate));
$('wb-history-btn').addEventListener('click', () => toggleHistory());
$('wb-history-clear').addEventListener('click', clearHistory);
+ $('wb-batch-btn').addEventListener('click', () => toggleBatch());
+ $('wb-batch-submit').addEventListener('click', submitBatchFromPanel);
$('wb-frame').addEventListener('click', () => vp.frame());
$('wb-shot').addEventListener('click', screenshot);
@@ -1503,6 +1631,7 @@ function wireKeyboard() {
if (e.key === 'Escape') {
closeMenus();
toggleHistory(false);
+ toggleBatch(false);
return;
}
if (typing || app.dataset.view !== 'generate' || !vp) return;
@@ -1525,6 +1654,7 @@ function wireKeyboard() {
e: () => setEnv(!vp.environmentOn),
t: () => setSpin(!vp.autoRotate),
h: () => toggleHistory(),
+ b: () => toggleBatch(),
p: screenshot,
1: () => setMode('shaded'),
2: () => setMode('wireframe'),
diff --git a/src/workbench/runner.js b/src/workbench/runner.js
index 03005a580..f46671a7c 100644
--- a/src/workbench/runner.js
+++ b/src/workbench/runner.js
@@ -16,7 +16,7 @@ const STATUS_TEXT = {
processing: 'Running',
};
-function generateBody(params, source) {
+export function generateBody(params, source) {
const body = { path: 'image', tier: params.tier || 'standard' };
if (params.backend && params.backend !== 'auto') body.backend = params.backend;
if (source.url) body.image_urls = [source.url];
@@ -29,6 +29,11 @@ function generateBody(params, source) {
if (params.target_polycount !== '' && params.target_polycount != null) body.target_polycount = Number(params.target_polycount);
if (params.output_format && params.output_format !== 'glb') body.output_format = params.output_format;
if (params.seed !== '' && params.seed != null) body.seed = Number(params.seed);
+ if (params.pose) body.pose = params.pose;
+ const bx = Number(params.bbox_x), by = Number(params.bbox_y), bz = Number(params.bbox_z);
+ if (params.bbox_x !== '' && params.bbox_y !== '' && params.bbox_z !== '' && bx > 0 && by > 0 && bz > 0) {
+ body.bbox = [bx, by, bz];
+ }
return body;
}
diff --git a/src/workbench/workbench.css b/src/workbench/workbench.css
index 5b7ccb6b3..855880ffc 100644
--- a/src/workbench/workbench.css
+++ b/src/workbench/workbench.css
@@ -633,6 +633,40 @@ textarea.wb-input { height: auto; min-height: 64px; padding: 7px 8px; resize: ve
.wb-history li small { color: var(--wb-ink-dim); font-size: 10.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wb-history-empty { padding: 18px 14px; color: var(--wb-ink-dim); font-size: 11.5px; line-height: 1.5; }
+/* batch queue drawer */
+.wb-batch { width: 300px; }
+.wb-batch-hint { margin: 0; padding: 8px 12px 0; color: var(--wb-ink-dim); font-size: 10.5px; line-height: 1.4; }
+.wb-batch textarea#wb-batch-prompts {
+ margin: 8px 12px;
+ resize: vertical;
+ min-height: 64px;
+ max-height: 160px;
+ border: 1px solid var(--wb-line-soft);
+ border-radius: 6px;
+ background: var(--wb-field);
+ color: inherit;
+ font: inherit;
+ font-size: 11.5px;
+ padding: 7px 9px;
+}
+.wb-batch textarea#wb-batch-prompts:focus-visible { outline: 2px solid var(--wb-accent); outline-offset: -1px; }
+.wb-batch ul#wb-batch-list { list-style: none; margin: 0; padding: 0 6px 6px; overflow-y: auto; display: grid; gap: 4px; }
+.wb-batch-item {
+ display: grid;
+ grid-template-columns: 1fr auto;
+ align-items: center;
+ gap: 8px;
+ padding: 6px 8px;
+ border-radius: 6px;
+ background: var(--wb-field);
+ font-size: 11.5px;
+}
+.wb-batch-item span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
+.wb-batch-item small { display: block; color: var(--wb-ink-dim); font-size: 10px; }
+.wb-batch-item[data-state='failed'] small { color: var(--wb-err); }
+.wb-batch-item[data-state='done'] small { color: var(--wb-ok); }
+.wb-batch-item button { flex-shrink: 0; }
+
/* toasts */
.wb-toasts { position: fixed; right: 16px; bottom: 16px; z-index: 50; display: grid; gap: 8px; max-width: min(360px, calc(100vw - 32px)); }
.wb-toast {
diff --git a/src/workbench/workflows.js b/src/workbench/workflows.js
index 47b61ce8a..1bbd039eb 100644
--- a/src/workbench/workflows.js
+++ b/src/workbench/workflows.js
@@ -67,6 +67,21 @@ export const NODE_TYPES = {
],
},
{ key: 'target_polycount', label: 'Face budget', type: 'number', default: '', min: 100, max: 500000, step: 1000, placeholder: 'Auto' },
+ {
+ key: 'pose',
+ label: 'Rest pose',
+ type: 'select',
+ default: '',
+ hint: 'Only lanes without a reference image can honor this; others report pose_applied: false',
+ options: [
+ ['', 'Auto'],
+ ['t', 'T-pose'],
+ ['a', 'A-pose'],
+ ],
+ },
+ { key: 'bbox_x', label: 'Width (m)', type: 'number', default: '', min: 0.01, max: 50, step: 0.1, placeholder: 'Auto' },
+ { key: 'bbox_y', label: 'Height (m)', type: 'number', default: '', min: 0.01, max: 50, step: 0.1, placeholder: 'Auto' },
+ { key: 'bbox_z', label: 'Depth (m)', type: 'number', default: '', min: 0.01, max: 50, step: 0.1, placeholder: 'Auto' },
{
key: 'texture_size',
label: 'Texture',
diff --git a/tests/workbench-generate-body.test.js b/tests/workbench-generate-body.test.js
new file mode 100644
index 000000000..d793a2fc7
--- /dev/null
+++ b/tests/workbench-generate-body.test.js
@@ -0,0 +1,45 @@
+// src/workbench/runner.js generateBody(): the Workbench generate node's params
+// (src/workbench/workflows.js) map onto a /api/forge POST body. Covers the
+// pose and bbox passthrough added alongside api/forge-batch.js, since both
+// are additive, off-by-default fields and a typo here would silently drop
+// them rather than error.
+
+import { describe, expect, it } from 'vitest';
+import { generateBody } from '../src/workbench/runner.js';
+
+const baseParams = { tier: 'standard' };
+const prompted = { prompt: 'a red chair' };
+
+describe('generateBody', () => {
+ it('omits pose and bbox when unset', () => {
+ const body = generateBody(baseParams, prompted);
+ expect(body).not.toHaveProperty('pose');
+ expect(body).not.toHaveProperty('bbox');
+ });
+
+ it('forwards a requested pose', () => {
+ const body = generateBody({ ...baseParams, pose: 't' }, prompted);
+ expect(body.pose).toBe('t');
+ });
+
+ it('forwards a complete bbox as [x, y, z]', () => {
+ const body = generateBody({ ...baseParams, bbox_x: 2, bbox_y: 3, bbox_z: 1.5 }, prompted);
+ expect(body.bbox).toEqual([2, 3, 1.5]);
+ });
+
+ it('drops bbox when only some axes are set', () => {
+ const body = generateBody({ ...baseParams, bbox_x: 2, bbox_y: '', bbox_z: 1.5 }, prompted);
+ expect(body).not.toHaveProperty('bbox');
+ });
+
+ it('drops bbox when an axis is zero or negative', () => {
+ const body = generateBody({ ...baseParams, bbox_x: 0, bbox_y: 3, bbox_z: 1.5 }, prompted);
+ expect(body).not.toHaveProperty('bbox');
+ });
+
+ it('still forwards target_polycount and seed unchanged', () => {
+ const body = generateBody({ ...baseParams, target_polycount: 20000, seed: 7 }, prompted);
+ expect(body.target_polycount).toBe(20000);
+ expect(body.seed).toBe(7);
+ });
+});