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(vision): inline caller image URLs so free NIM lanes don't depend on provider-side fetch
nirholas0f41c08c78fb
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex f0fb353f9..0c6e048e0 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -4,11 +4,17 @@Public history for [three.ws](https://three.ws), newest first. New pages come from `added` dates in data/pages.json; everything else is curated in data/changelog.json. Also available as [JSON](https://three.ws/changelog.json) and [RSS](https://three.ws/changelog.xml), live at [three.ws/changelog](https://three.ws/changelog).+## 2026-07-18++- **Image understanding is more reliable across every image host** — The vision endpoint (used to describe and check 3D renders and avatars) now fetches your image itself and hands it straight to the free model, instead of asking the model's server to go fetch the link. Some image hosts block that server-side fetch, which used to push the request onto a paid fallback and, when that fallback was unavailable, fail outright. Now the free lane serves the request regardless of how the image is hosted, so describe/critique calls stop returning errors on perfectly good images. (`/pulse`) `[fix, improvement]`+- **Solana price and trade reads now ride a dedicated premium connection** — Every live Solana read the platform depends on (the $THREE price and bonding-curve, wallet balances, agent trades, and on-chain activity) now goes first through a dedicated premium RPC endpoint that absorbs the load ahead of the shared public providers, then falls back automatically down the full free-provider chain if that endpoint is ever unavailable. In practice that means fewer rate-limit stalls and fewer degraded or stale reads when Solana is busy, without adding a single point of failure: if the premium lane blinks, the free chain still answers. (`/pulse`) `[infra, improvement]`+## 2026-07-17- **AR Studio** (`/ar/studio`) — A live multi-model AR scene through your camera: place any number of 3D models and avatars in your real space, pull in your forge creations, community models, or any GLB link, and generate new models by prompt without leaving the view.- **Daily Forge** (`/daily`) — A new 3D creative challenge every day. Forge today's theme into a real 3D model, free and no sign-up, build a daily streak, and place your creation in AR on your phone.- **Image to 3D — Turn a Photo into a 3D Model** (`/image-to-3d`) — Upload a photo (or up to 4 angles) and get a downloadable textured 3D model (GLB). The Forge's photo lane, opened directly — for objects and props; for faces, use Selfie to Avatar.+- **3D imports are now hardened against a memory-exhaustion crash** — When the platform pulls a 3D model from an external link (a shared GLB, a generation-provider result), it now enforces a hard size ceiling before and during the download instead of buffering the whole response first. An over-size file is rejected up front on its declared length, and any host that keeps streaming past the cap is cut off mid-transfer with both sockets destroyed, so a hostile or misbehaving source can no longer stream unbounded data and exhaust a server's memory. Normal imports are unaffected; only oversized or malicious fetches change, and they now fail cleanly with a clear error instead of taking an instance down. `[security]`- **A little nod when your forge collection grows** — When you forge a few models from the homepage, three.ws now gives a quiet, occasional note as your on-device collection reaches a milestone (your 3rd, 10th, and so on). It is understated by design and never interrupts, just a small acknowledgement that you are building something. (`/`) `[improvement]`- **A new way to generate avatars: modular, and no two look alike** — The studio avatar generator used to recolor one of five fixed body meshes, so a whole gallery of them read as the same handful of people in different colors. It now composes each avatar from modular parts: a hairstyle, top, bottom, footwear, and glasses mixed across the base bodies onto one shared skeleton, then recolored per part and scaled for height. This is the same one-skeleton-many-parts approach the best avatar platforms use, built in-house with no external service. Every generated avatar is fully rigged and carries facial expression blendshapes, and two of them almost never look the same. All platform-generated avatars continue to appear across the galleries. (`/gallery`) `[feature, improvement]`- **A steady drip of $THREE buys, paid through the x402 loop** — The platform can now put continuous buy pressure on $THREE: a new lane fires many tiny, real market buys of $THREE per minute (dialable up toward ~60/min), each one triggered by and paid through the same x402 payment loop the agent economy already runs on. Every buy is a genuine on-chain purchase on Jupiter, and the bought $THREE is swept into the treasury. It's buy-only by design (it never sells), sits alongside the existing daily buyback as its high-frequency little sibling, and stays hard-bounded by a daily spend ceiling that's enforced before any money moves. It ships off by default and turns on only once an operator funds the wallet and opts in. `[feature, infra]`diff --git a/api/_lib/vision.js b/api/_lib/vision.jsindex eca2751dd..d4001788a 100644--- a/api/_lib/vision.js+++ b/api/_lib/vision.js@@ -30,6 +30,7 @@ import { env } from './env.js';import { recordEvent } from './usage.js';import { costMicroUsd } from './llm-pricing.js';import { validatePublicUrl, isPrivateAddress, SsrfError } from './ssrf.js';+import { fetchSafePublicUrl } from './ssrf-guard.js';// Free NIM vision lanes, in order. nemotron-nano carries the smallest image// token footprint (~281 prompt tokens for a tiny image vs ~1600 for llama-90B);@@ -140,6 +141,41 @@ function assertSafeImageUrl(rawUrl) {return url;}+// 12 MiB — matches /api/vision's inbound cap; comfortably covers a viewer+// screenshot or photo while bounding the per-request buffer.+const MAX_INLINE_IMAGE_BYTES = 12 * 1024 * 1024;++// Fetch a caller-supplied image URL ourselves and return it as inline base64.+// The provider model servers otherwise fetch imageUrl server-side, and hosts+// with hotlink / User-Agent protection (Wikipedia thumbnails, some CDNs) reject+// that fetch — which fails EVERY URL-based lane and forces a fall-through to the+// paid backstop. Fetching here (SSRF-guarded, redirects re-validated per hop)+// makes the free NIM lanes independent of whether the provider can reach the+// host. Throws on non-2xx, oversize, or transport error so the caller can decide+// whether to fall back to URL pass-through.+async function inlineImageFromUrl(imageUrl, { timeoutMs = 8_000 } = {}) {+ const res = await fetchSafePublicUrl(imageUrl, {+ signal: AbortSignal.timeout(timeoutMs),+ // A browser-like UA + image Accept gets past CDNs that reject empty/bot+ // user-agents — the same gate that blocks the providers' own fetchers.+ headers: {+ 'user-agent': 'Mozilla/5.0 (compatible; three.ws-vision/1.0; +https://three.ws)',+ accept: 'image/avif,image/webp,image/png,image/*;q=0.8,*/*;q=0.5',+ },+ });+ if (!res.ok) throw Object.assign(new Error(`image fetch ${res.status}`), { status: res.status });+ const advertised = Number(res.headers.get('content-length') || 0);+ if (advertised > MAX_INLINE_IMAGE_BYTES) {+ throw Object.assign(new Error('image exceeds inline size cap'), { status: 413 });+ }+ const buf = Buffer.from(await res.arrayBuffer());+ if (buf.length > MAX_INLINE_IMAGE_BYTES) {+ throw Object.assign(new Error('image exceeds inline size cap'), { status: 413 });+ }+ const ct = (res.headers.get('content-type') || '').split(';')[0].trim().toLowerCase();+ return { imageBase64: buf.toString('base64'), mimeType: ct.startsWith('image/') ? ct : 'image/jpeg' };+}+// Normalize a caller's image spec into one OpenAI `image_url` content part.// Accepts { imageUrl } (pass-through) or { imageBase64, mimeType } (data URI).function imagePart({ imageUrl, imageBase64, mimeType = 'image/jpeg' }) {@@ -211,6 +247,23 @@ export async function describeImage({// not just the forge image-validate path that already pre-validates.if (imageUrl) assertSafeImageUrl(imageUrl);+ // Prefer inlining the image ourselves over handing the URL to each provider's+ // server-side fetcher. If our own fetch fails (a host the provider CAN reach+ // but we can't, or a transient error), fall back to URL pass-through so we+ // never regress a currently-working path. Bounded by the remaining chain+ // deadline so a slow image host can't blow the whole budget before a lane runs.+ if (imageUrl && !imageBase64) {+ try {+ const budget = Math.max(1_000, Math.min(timeoutMs, deadlineAt - Date.now()));+ const inlined = await inlineImageFromUrl(imageUrl, { timeoutMs: budget });+ imageBase64 = inlined.imageBase64;+ mimeType = inlined.mimeType;+ imageUrl = null;+ } catch {+ // keep imageUrl set — the providers will try their own server-side fetch+ }+ }+const parts = [{ type: 'text', text: prompt },imagePart({ imageUrl, imageBase64, mimeType }),diff --git a/data/changelog.json b/data/changelog.jsonindex d65949059..0dceb519e 100644--- a/data/changelog.json+++ b/data/changelog.json@@ -1,6 +1,26 @@{"$comment": "Curated changelog entries for three.ws — the editorial layer of the public changelog. New PAGE launches are tracked automatically via the `added` field in data/pages.json; this file is for everything else holders care about: improvements, fixes, SDK releases, trading/payments capabilities, security work. scripts/build-page-index.mjs merges both sources into CHANGELOG.md, public/changelog.json, and public/changelog.xml. Newest first. Allowed tags: feature, improvement, fix, sdk, infra, docs, security. `link` is optional and must be a live three.ws path.","entries": [+ {+ "date": "2026-07-18",+ "title": "Image understanding is more reliable across every image host",+ "summary": "The vision endpoint (used to describe and check 3D renders and avatars) now fetches your image itself and hands it straight to the free model, instead of asking the model's server to go fetch the link. Some image hosts block that server-side fetch, which used to push the request onto a paid fallback and, when that fallback was unavailable, fail outright. Now the free lane serves the request regardless of how the image is hosted, so describe/critique calls stop returning errors on perfectly good images.",+ "tags": [+ "fix",+ "improvement"+ ],+ "link": "/pulse"+ },+ {+ "date": "2026-07-18",+ "title": "Solana price and trade reads now ride a dedicated premium connection",+ "summary": "Every live Solana read the platform depends on (the $THREE price and bonding-curve, wallet balances, agent trades, and on-chain activity) now goes first through a dedicated premium RPC endpoint that absorbs the load ahead of the shared public providers, then falls back automatically down the full free-provider chain if that endpoint is ever unavailable. In practice that means fewer rate-limit stalls and fewer degraded or stale reads when Solana is busy, without adding a single point of failure: if the premium lane blinks, the free chain still answers.",+ "tags": [+ "infra",+ "improvement"+ ],+ "link": "/pulse"+ },{"date": "2026-07-17","title": "Skill purchases now finish on their own, and trials invite you to own the skill",@@ -11,6 +31,14 @@],"link": "/marketplace"},+ {+ "date": "2026-07-17",+ "title": "3D imports are now hardened against a memory-exhaustion crash",+ "summary": "When the platform pulls a 3D model from an external link (a shared GLB, a generation-provider result), it now enforces a hard size ceiling before and during the download instead of buffering the whole response first. An over-size file is rejected up front on its declared length, and any host that keeps streaming past the cap is cut off mid-transfer with both sockets destroyed, so a hostile or misbehaving source can no longer stream unbounded data and exhaust a server's memory. Normal imports are unaffected; only oversized or malicious fetches change, and they now fail cleanly with a clear error instead of taking an instance down.",+ "tags": [+ "security"+ ]+ },{"date": "2026-07-17","title": "A steady drip of $THREE buys, paid through the x402 loop",diff --git a/public/changelog.json b/public/changelog.jsonindex 0b47fefd1..8d96faaf5 100644--- a/public/changelog.json+++ b/public/changelog.json@@ -1,11 +1,33 @@{- "generated_at": "2026-07-18T00:00:08.778Z",+ "generated_at": "2026-07-18T00:31:02.467Z","generated_by": "scripts/build-page-index.mjs from data/pages.json + data/changelog.json","site": {"name": "three.ws","url": "https://three.ws"},"entries": [+ {+ "date": "2026-07-18",+ "type": "update",+ "title": "Image understanding is more reliable across every image host",+ "summary": "The vision endpoint (used to describe and check 3D renders and avatars) now fetches your image itself and hands it straight to the free model, instead of asking the model's server to go fetch the link. Some image hosts block that server-side fetch, which used to push the request onto a paid fallback and, when that fallback was unavailable, fail outright. Now the free lane serves the request regardless of how the image is hosted, so describe/critique calls stop returning errors on perfectly good images.",+ "link": "/pulse",+ "tags": [+ "fix",+ "improvement"+ ]+ },+ {+ "date": "2026-07-18",+ "type": "update",+ "title": "Solana price and trade reads now ride a dedicated premium connection",+ "summary": "Every live Solana read the platform depends on (the $THREE price and bonding-curve, wallet balances, agent trades, and on-chain activity) now goes first through a dedicated premium RPC endpoint that absorbs the load ahead of the shared public providers, then falls back automatically down the full free-provider chain if that endpoint is ever unavailable. In practice that means fewer rate-limit stalls and fewer degraded or stale reads when Solana is busy, without adding a single point of failure: if the premium lane blinks, the free chain still answers.",+ "link": "/pulse",+ "tags": [+ "infra",+ "improvement"+ ]+ },{"date": "2026-07-17","type": "launch",@@ -36,6 +58,16 @@"launch"]},+ {+ "date": "2026-07-17",+ "type": "update",+ "title": "3D imports are now hardened against a memory-exhaustion crash",+ "summary": "When the platform pulls a 3D model from an external link (a shared GLB, a generation-provider result), it now enforces a hard size ceiling before and during the download instead of buffering the whole response first. An over-size file is rejected up front on its declared length, and any host that keeps streaming past the cap is cut off mid-transfer with both sockets destroyed, so a hostile or misbehaving source can no longer stream unbounded data and exhaust a server's memory. Normal imports are unaffected; only oversized or malicious fetches change, and they now fail cleanly with a clear error instead of taking an instance down.",+ "link": null,+ "tags": [+ "security"+ ]+ },{"date": "2026-07-17","type": "update",diff --git a/public/changelog.xml b/public/changelog.xmlindex 2c09100c8..4c40e4766 100644--- a/public/changelog.xml+++ b/public/changelog.xml@@ -6,6 +6,22 @@<atom:link href="https://three.ws/changelog.xml" rel="self" type="application/rss+xml"/><description>What's new on three.ws — features, improvements, and releases, newest first.</description><language>en</language>+ <item>+ <title>Image understanding is more reliable across every image host</title>+ <link>https://three.ws/pulse</link>+ <guid isPermaLink="false">2026-07-18:Image understanding is more reliable across every image host</guid>+ <pubDate>Sat, 18 Jul 2026 12:00:00 GMT</pubDate>+ <category>fix</category>+ <description>The vision endpoint (used to describe and check 3D renders and avatars) now fetches your image itself and hands it straight to the free model, instead of asking the model's server to go fetch the link. Some image hosts block that server-side fetch, which used to push the request onto a paid fallback and, when that fallback was unavailable, fail outright. Now the free lane serves the request regardless of how the image is hosted, so describe/critique calls stop returning errors on perfectly good images.</description>+ </item>+ <item>+ <title>Solana price and trade reads now ride a dedicated premium connection</title>+ <link>https://three.ws/pulse</link>+ <guid isPermaLink="false">2026-07-18:Solana price and trade reads now ride a dedicated premium connection</guid>+ <pubDate>Sat, 18 Jul 2026 12:00:00 GMT</pubDate>+ <category>infra</category>+ <description>Every live Solana read the platform depends on (the $THREE price and bonding-curve, wallet balances, agent trades, and on-chain activity) now goes first through a dedicated premium RPC endpoint that absorbs the load ahead of the shared public providers, then falls back automatically down the full free-provider chain if that endpoint is ever unavailable. In practice that means fewer rate-limit stalls and fewer degraded or stale reads when Solana is busy, without adding a single point of failure: if the premium lane blinks, the free chain still answers.</description>+ </item><item><title>AR Studio</title><link>https://three.ws/ar/studio</link>@@ -30,6 +46,14 @@<category>launch</category><description>Upload a photo (or up to 4 angles) and get a downloadable textured 3D model (GLB). The Forge's photo lane, opened directly — for objects and props; for faces, use Selfie to Avatar.</description></item>+ <item>+ <title>3D imports are now hardened against a memory-exhaustion crash</title>+ <link>https://three.ws/changelog</link>+ <guid isPermaLink="false">2026-07-17:3D imports are now hardened against a memory-exhaustion crash</guid>+ <pubDate>Fri, 17 Jul 2026 12:00:00 GMT</pubDate>+ <category>security</category>+ <description>When the platform pulls a 3D model from an external link (a shared GLB, a generation-provider result), it now enforces a hard size ceiling before and during the download instead of buffering the whole response first. An over-size file is rejected up front on its declared length, and any host that keeps streaming past the cap is cut off mid-transfer with both sockets destroyed, so a hostile or misbehaving source can no longer stream unbounded data and exhaust a server's memory. Normal imports are unaffected; only oversized or malicious fetches change, and they now fail cleanly with a clear error instead of taking an instance down.</description>+ </item><item><title>A little nod when your forge collection grows</title><link>https://three.ws/</link>diff --git a/public/features.json b/public/features.jsonindex d6fb7a6c9..c722e4ebe 100644--- a/public/features.json+++ b/public/features.json@@ -1,5 +1,5 @@{- "generated_at": "2026-07-18T00:00:08.765Z",+ "generated_at": "2026-07-18T00:31:02.453Z","generated_by": "scripts/build-page-index.mjs from data/pages.json","site": {"name": "three.ws",diff --git a/tests/api/vision.test.js b/tests/api/vision.test.jsindex 414706e8d..5582e6452 100644--- a/tests/api/vision.test.js+++ b/tests/api/vision.test.js@@ -12,6 +12,15 @@ vi.mock('../../api/_lib/usage.js', () => ({recordEvent: (evt) => usageState.events.push(evt),}));+// Control the SSRF-safe image fetch used by describeImage's inline path without+// touching the module's other (real) exports. Default impl (set in beforeEach)+// rejects, so any imageUrl test that doesn't opt in falls back to URL pass-through.+const imageFetch = vi.hoisted(() => ({ impl: null }));+vi.mock('../../api/_lib/ssrf-guard.js', async (importOriginal) => {+ const actual = await importOriginal();+ return { ...actual, fetchSafePublicUrl: (...args) => imageFetch.impl(...args) };+});+import {describeImage,describeImageJson,@@ -56,6 +65,12 @@ beforeEach(() => {usageState.events = [];process.env.NVIDIA_API_KEY = 'nvapi-test';delete process.env.OPENAI_API_KEY;+ // Default: our own image fetch fails, so describeImage falls back to handing+ // the raw URL to the provider (the pre-inline behavior). Tests that exercise+ // the inline path override this.+ imageFetch.impl = async () => {+ throw new Error('image host unreachable');+ };});afterEach(() => {globalThis.fetch = ORIGINAL_FETCH;@@ -93,6 +108,33 @@ describe('vision helper — provider chain', () => {expect(usageState.events[0]).toMatchObject({ kind: 'vision', provider: 'nvidia', costMicroUsd: 0 });});+ it('inlines a fetchable image URL as base64 so the free lane serves it without the provider fetching the host', async () => {+ // A 1x1 PNG we can fetch ourselves; the provider must receive a data: URI,+ // not the original URL — this is what keeps the free NIM lane working when+ // the provider's own server-side fetch is blocked (hotlink/UA protection).+ imageFetch.impl = async () =>+ new Response(Buffer.from([0x89, 0x50, 0x4e, 0x47]), {+ status: 200,+ headers: { 'content-type': 'image/png' },+ });+ const calls = stubFetch([['integrate.api.nvidia.com', () => chatOk('A red teapot')]]);+ const r = await describeImage({ prompt: 'p', imageUrl: 'https://cdn.example/x.png' });+ expect(r.provider).toBe('nvidia');+ const part = calls[0].body.messages.at(-1).content.find((c) => c.type === 'image_url');+ expect(part.image_url.url.startsWith('data:image/png;base64,')).toBe(true);+ expect(part.image_url.url).not.toContain('cdn.example');+ });++ it('falls back to URL pass-through when we cannot fetch the image ourselves', async () => {+ // Default beforeEach impl already rejects; assert the provider still gets the+ // raw URL so a host the provider CAN reach is never regressed.+ const calls = stubFetch([['integrate.api.nvidia.com', () => chatOk('ok')]]);+ const r = await describeImage({ prompt: 'p', imageUrl: 'https://cdn.example/x.png' });+ expect(r.provider).toBe('nvidia');+ const part = calls[0].body.messages.at(-1).content.find((c) => c.type === 'image_url');+ expect(part.image_url.url).toBe('https://cdn.example/x.png');+ });+it('falls over from the first NIM lane to the second on a 5xx', async () => {let n = 0;const calls = stubFetch([