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(api): correct the forge NIM lane, draft limits and receipt currency handling
nirholas5e6460e4a32e
diff --git a/api/nim-forge.js b/api/nim-forge.jsindex 455d729dd..ce92621ee 100644--- a/api/nim-forge.js+++ b/api/nim-forge.js@@ -12,12 +12,16 @@//// The hosted NVIDIA preview rejects real images (only its 4 sample example_ids,// verified live) — so this demo only works against a self-hosted NIM. Point-// NIM_TRELLIS_URL (or MODEL_TRELLIS_URL) at it.+// NIM_TRELLIS_URL at it.import { wrap, cors, json, method, readJson, rateLimited } from './_lib/http.js';import { limits, clientIp } from './_lib/rate-limit.js';-const NIM_URL = process.env.NIM_TRELLIS_URL || process.env.MODEL_TRELLIS_URL || '';+// NIM_TRELLIS_URL only. MODEL_TRELLIS_URL points at our own Cloud Run TRELLIS+// worker (workers/model-trellis/), whose async `/infer` + `/tasks/{id}` API is+// not the NIM contract, so falling back to it reported the demo as configured+// and then 404'd every generation.+const NIM_URL = process.env.NIM_TRELLIS_URL || '';const NIM_KEY = process.env.NIM_TRELLIS_KEY || process.env.NVIDIA_API_KEY || '';// A self-host NIM reconstructs in ~15–45 s on an L4; give the synchronous call@@ -96,7 +100,7 @@ export default wrap(async (req, res) => {return json(res, 503, {error: 'unconfigured',message:- 'Self-hosted TRELLIS NIM is not configured. Set NIM_TRELLIS_URL (or MODEL_TRELLIS_URL) to your NIM base URL.',+ 'Self-hosted TRELLIS NIM is not configured. Set NIM_TRELLIS_URL to your NIM base URL.',});}diff --git a/api/x/draft.js b/api/x/draft.jsindex 5412ea552..d392106e6 100644--- a/api/x/draft.js+++ b/api/x/draft.js@@ -15,7 +15,10 @@ import { llmComplete, LlmUnavailableError } from '../_lib/llm.js';import { MAX_TWEET_LEN } from '../_lib/x-post.js';const MAX_DRAFTS = 3;-const MAX_PROMPT_LEN = 500;+// The dashboard sends whatever is in the compose box as the prompt, and that box+// legitimately holds a whole multi-part thread, so the ceiling has to clear a few+// tweets' worth of text while still bounding what reaches the model.+const MAX_PROMPT_LEN = 2000;const MAX_THREAD_PARTS = 5;// Mirrors the tone select in the dashboard X panel (src/dashboard/dashboard.js).diff --git a/api/x402/my-receipts.js b/api/x402/my-receipts.jsindex 5edcbecda..0bb061fb3 100644--- a/api/x402/my-receipts.js+++ b/api/x402/my-receipts.js@@ -61,7 +61,7 @@ function withinFreshnessWindow(issuedAt) {// USDC on Solana/Base/BSC, USD₮0 on X Layer, and $THREE on the Solana rail. An// asset we don't recognise returns null and the client renders the raw atomic// amount rather than guessing a scale.-function assetDecimals(asset) {+export function assetDecimals(asset) {if (!asset) return null;const want = String(asset).toLowerCase();const configured = [diff --git a/tests/api-x-endpoints.test.js b/tests/api-x-endpoints.test.jsindex 5b3feb07c..0812b2eb0 100644--- a/tests/api-x-endpoints.test.js+++ b/tests/api-x-endpoints.test.js@@ -218,6 +218,15 @@ describe('POST /api/x/draft', () => {expect(llmComplete).not.toHaveBeenCalled();});+ it('accepts a full thread pasted into the compose box but bounds what reaches the model', async () => {+ llmComplete.mockResolvedValue({ text: 'ok' });+ const wholeThread = 'x'.repeat(1500);+ expect((await call(draft, { method: 'POST', url: '/api/x/draft', body: { prompt: wholeThread } })).statusCode).toBe(200);+ const tooLong = await call(draft, { method: 'POST', url: '/api/x/draft', body: { prompt: 'x'.repeat(2001) } });+ expect(tooLong.statusCode).toBe(400);+ expect(llmComplete).toHaveBeenCalledTimes(1);+ });+it('rejects an unknown tone', async () => {const res = await call(draft, { method: 'POST', url: '/api/x/draft', body: { tone: 'shakespearean' } });expect(res.statusCode).toBe(400);diff --git a/tests/market-heatmap-board.test.js b/tests/market-heatmap-board.test.jsindex f4dbb6b44..e10fbf355 100644--- a/tests/market-heatmap-board.test.js+++ b/tests/market-heatmap-board.test.js@@ -21,7 +21,27 @@ Object.assign(process.env, {X402_FEE_PAYER_SOLANA: 'So11111111111111111111111111111111111111112',});-const { rankOr, breadth, OUTPUT_SCHEMA } = await import('../api/x402/market-heatmap.js');+const { finite, rankOr, breadth, OUTPUT_SCHEMA } = await import('../api/x402/market-heatmap.js');++describe('finite', () => {+ it('passes real numbers through, including a legitimate zero', () => {+ expect(finite(118250)).toBe(118250);+ expect(finite('2.4')).toBe(2.4);+ expect(finite(0)).toBe(0);+ expect(finite(-1.5)).toBe(-1.5);+ });++ it('reports an absent value as null instead of inventing a 0', () => {+ // Number(null) and Number('') are both 0: coercing first would publish a+ // "the coin moved 0%" claim for a window the upstream never priced.+ expect(finite(null)).toBeNull();+ expect(finite(undefined)).toBeNull();+ expect(finite('')).toBeNull();+ expect(finite('n/a')).toBeNull();+ expect(finite(Number.NaN)).toBeNull();+ expect(finite(Number.POSITIVE_INFINITY)).toBeNull();+ });+});describe('rankOr', () => {it('keeps a real 1-based rank', () => {