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(forge): point the TRELLIS NIM lane at its own URL var instead of the worker's
nirholas60fd359242fa
diff --git a/api/forge-nim.js b/api/forge-nim.jsindex 1e619db1d..d864bdd6b 100644--- a/api/forge-nim.js+++ b/api/forge-nim.js@@ -19,7 +19,7 @@//// GET /api/forge-nim?action=health → { configured, reachable, baseUrl }//-// The NIM URL comes from MODEL_TRELLIS_URL; a request may override it (handy for+// The NIM URL comes from NIM_TRELLIS_URL; a request may override it (handy for// pointing the demo at your own box), but the override is SSRF-guarded — only// https hosts that don't resolve to private/loopback/link-local/metadata space,// so this can never be turned into an internal-network probe.@@ -109,14 +109,21 @@ function assertSafeBaseUrl(raw) {}// Resolve the NIM origin for this request. A caller-supplied baseUrl is SSRF-// guarded; absent that, fall back to the operator-configured MODEL_TRELLIS_URL.+// guarded; absent that, fall back to the operator-configured NIM_TRELLIS_URL.+//+// This deliberately does NOT read MODEL_TRELLIS_URL. That variable is the+// platform-wide pointer to our own Cloud Run TRELLIS worker+// (workers/model-trellis/), which speaks a different contract: an async+// `/infer` + `/tasks/{id}` API, not the NIM's synchronous `/v1/infer`. Reading+// it here made health report a configured, unreachable NIM and turned every+// generation into a 404 against a service that was never a NIM.function resolveBaseUrl(requested) {if (requested) return assertSafeBaseUrl(requested);- const configured = env.MODEL_TRELLIS_URL || process.env.MODEL_TRELLIS_URL;+ const configured = env.NIM_TRELLIS_URL || process.env.NIM_TRELLIS_URL;if (!configured) {throw Object.assign(new Error(- 'No self-hosted TRELLIS NIM is configured. Set MODEL_TRELLIS_URL on the deployment, or pass a baseUrl pointing at your own NIM (nvcr.io/nim/microsoft/trellis).',+ 'No self-hosted TRELLIS NIM is configured. Set NIM_TRELLIS_URL on the deployment, or pass a baseUrl pointing at your own NIM (nvcr.io/nim/microsoft/trellis).',),// expose: this is a documented contract error, not a leaked runtime code,// so wrap() may hand the caller the real reason instead of internal_error.diff --git a/api/x402/market.js b/api/x402/market.jsindex edccebcf5..278138419 100644--- a/api/x402/market.js+++ b/api/x402/market.js@@ -2,11 +2,10 @@//// Lists every paid /api/x402/market-* endpoint (the registry family plus the// hand-written siblings market-heatmap and market-mood) with its live price,-// params, and a runnable example so an agent (or a human with curl) can-// discover the whole-// bundle in one unauthenticated call. The paid endpoints themselves are-// x402-gated (USDC on Solana or Base); this index is free the same way-// /api/crypto is free for the crypto bundle — discovery costs nothing,+// params, and a runnable example, so an agent (or a human with curl) can+// discover the whole bundle in one unauthenticated call. The paid endpoints+// themselves are x402-gated (USDC on Solana or Base); this index is free the+// same way /api/crypto is free for the crypto bundle. Discovery costs nothing,// data costs a micro-payment.import { cors, json, method, wrap, rateLimited } from '../_lib/http.js';diff --git a/tests/solana-agents-crawl.test.js b/tests/solana-agents-crawl.test.jsindex 7c2acf38f..69d40b822 100644--- a/tests/solana-agents-crawl.test.js+++ b/tests/solana-agents-crawl.test.js@@ -6,6 +6,7 @@ import {agencStatusLabel,agencActive,} from '../api/_lib/solana-agents-normalize.js';+import { remainingMs, withDeadline } from '../api/_lib/solana-agents-crawl.js';describe('solana-agents-crawl helpers', () => {describe('truncate', () => {@@ -100,4 +101,59 @@ describe('solana-agents-crawl helpers', () => {expect(agencStatusLabel(99)).toBe(null);});});++ // Registry enumeration (getProgramAccounts / Anchor .all()) takes no timeout of+ // its own, so the crawl budget is only real if these two enforce it. A 2026-08-14+ // audit run measured the cron at 272s against its declared 240s budget, inside+ // 48s of Cloud Scheduler's 320s attempt deadline.+ describe('remainingMs', () => {+ it('falls back to the scan budget when no deadline is set', () => {+ expect(remainingMs(undefined, 5_000)).toBe(5_000);+ expect(remainingMs(null, 5_000)).toBe(5_000);+ });+ it('reports the time left, going negative once the deadline has passed', () => {+ expect(remainingMs(Date.now() + 10_000)).toBeGreaterThan(9_000);+ expect(remainingMs(Date.now() - 1_000)).toBeLessThan(0);+ });+ });++ describe('withDeadline', () => {+ it('returns the value when the call finishes in time', async () => {+ await expect(withDeadline(Promise.resolve('scanned'), 1_000, 'gpa-v2')).resolves.toBe('scanned');+ });++ it('rejects with the budget label once the call overruns', async () => {+ const hang = new Promise(() => {});+ await expect(withDeadline(hang, 10, 'gpa-v2')).rejects.toThrow(/gpa-v2: exceeded its 0s budget/);+ });++ it('refuses to start a scan with no budget left', async () => {+ await expect(withDeadline(Promise.resolve('x'), 0, 'agenc account scan'))+ .rejects.toThrow(/no time left in the crawl budget/);+ await expect(withDeadline(Promise.resolve('x'), -5_000, 'agenc account scan'))+ .rejects.toThrow(/no time left in the crawl budget/);+ });++ it('surfaces the underlying failure unchanged when the call loses to nothing', async () => {+ await expect(withDeadline(Promise.reject(new Error('504 Gateway Timeout')), 1_000, 'gpa-v1'))+ .rejects.toThrow('504 Gateway Timeout');+ });++ // A scan that finishes after the timer fired must settle quietly. Left+ // unhandled it would take the whole instance down long after the cron+ // already returned its report.+ it('swallows a rejection that lands after the budget expired', async () => {+ const unhandled = [];+ const onUnhandled = (err) => unhandled.push(err);+ process.on('unhandledRejection', onUnhandled);+ try {+ const late = new Promise((_, reject) => setTimeout(() => reject(new Error('late 504')), 30));+ await expect(withDeadline(late, 5, 'gpa-v2')).rejects.toThrow(/exceeded its/);+ await new Promise((r) => setTimeout(r, 80));+ } finally {+ process.off('unhandledRejection', onUnhandled);+ }+ expect(unhandled).toEqual([]);+ });+ });});diff --git a/tests/solana-token-meta-token2022.test.js b/tests/solana-token-meta-token2022.test.jsindex 671b5a74f..6efa255ce 100644--- a/tests/solana-token-meta-token2022.test.js+++ b/tests/solana-token-meta-token2022.test.js@@ -20,6 +20,8 @@* caller gets billed for.*/+import { readFileSync } from 'node:fs';+import { describe, it, expect, vi, beforeEach } from 'vitest';import { PublicKey } from '@solana/web3.js';import { TOKEN_2022_PROGRAM_ID, TOKEN_PROGRAM_ID } from '@solana/spl-token';@@ -29,16 +31,13 @@ const SYSTEM_PROGRAM = '11111111111111111111111111111112';// Real mainnet bytes: the $THREE mint account, carrying the metadataPointer and// tokenMetadata extensions (name "three.ws", symbol "three", ipfs.io uri).-const THREE_MINT_ACCOUNT_B64 =- 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUIaigDGNAwAGAQAAAAAAAAAAAAAAAAAAAAAA' +- 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA' +- 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAARIAQAAAAAAAAAAAAAAAAAAA' +- 'AAAAAAAAAAAAAAAAAAAAAAAAAANmVY1rrT6TOBsHGhgrWf58Jwp3c966+FFfgpUEBdj8fEwCtAAAAAAAAAAA' +- 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA2ZVjWutPpM4GwcaGCtZ/nwnCndz3rr4UV+ClQQF2Px8IAAAAdG' +- 'hyZWUud3MFAAAAdGhyZWVQAAAAaHR0cHM6Ly9pcGZzLmlvL2lwZnMvYmFma3JlaWZ0b3JnczVrbm9xcjN6NT' +- 'N1bmpwZG1neWhwNGFiam5xamthc3QzaXEzdGZvZmV0bTJvb20AAAAA';--const THREE_MINT_DATA = Buffer.from(THREE_MINT_ACCOUNT_B64, 'base64');+const THREE_MINT_DATA = Buffer.from(+ readFileSync(+ new URL('./_fixtures/three-mint-token2022.base64', import.meta.url),+ 'utf8',+ ).trim(),+ 'base64',+);// A classic SPL mint: 82 bytes, owned by the original token program, metadata// lives in a separate Metaplex PDA. Layout tail is what the reader parses.