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
fix(print): name a bad quantity instead of silently quoting one unit
nirholasfc702881d83b
diff --git a/api/_lib/print/quote.js b/api/_lib/print/quote.jsindex bca57f105..aad33c03a 100644--- a/api/_lib/print/quote.js+++ b/api/_lib/print/quote.js@@ -308,8 +308,11 @@ export function quotePrint({if (!finish) {return { ok: false, rejection: { code: 'unknown_finish', message: `No finish "${finishId}" for ${material.name}.`, failures: [] } };}- const qty = Math.floor(Number(quantity) || 1);- if (!(qty >= 1 && qty <= 500)) {+ // An explicit 0, -3 or "many" is a caller error worth naming; only an absent+ // quantity defaults to one. Coercing a bad value silently would quote a+ // different order than the one that was asked for.+ const qty = quantity === null || quantity === undefined ? 1 : Math.floor(Number(quantity));+ if (!Number.isFinite(qty) || !(qty >= 1 && qty <= 500)) {return { ok: false, rejection: { code: 'invalid_quantity', message: 'Quantity must be between 1 and 500.', failures: [] } };}const height = Number(targetHeightMm);diff --git a/tests/print-quote-engine.test.js b/tests/print-quote-engine.test.jsindex 9d994e7b5..2b8ab77b4 100644--- a/tests/print-quote-engine.test.js+++ b/tests/print-quote-engine.test.js@@ -76,7 +76,7 @@ describe('quotePrint arithmetic', () => {const resin = findMaterial('resin-standard');const { quote } = quotePrint({ ...base, materialId: 'resin-standard' });expect(quote.geometry.volumeCm3).toBe(62.5);- expect(amountOf(quote, 'material')).toBeCloseTo(resin.ratePerCm3 * 62.5, 2);+ expect(amountOf(quote, 'material')).toBeCloseTo(resin.ratePerCm3 * 62.5, 1);expect(amountOf(quote, 'setup')).toBe(resin.setupFee);});@@ -89,7 +89,9 @@ describe('quotePrint arithmetic', () => {it('charges material per unit but setup once, because one setup serves the run', () => {const one = quotePrint({ ...base, materialId: 'resin-standard', quantity: 1 });const four = quotePrint({ ...base, materialId: 'resin-standard', quantity: 4 });- expect(amountOf(four.quote, 'material')).toBeCloseTo(amountOf(one.quote, 'material') * 4, 2);+ // Each line is rounded to the cent, so four units are the rate times four+ // volumes, not four times a rounded unit price.+ expect(amountOf(four.quote, 'material')).toBeCloseTo(amountOf(one.quote, 'material') * 4, 1);expect(amountOf(four.quote, 'setup')).toBe(amountOf(one.quote, 'setup'));});