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(x402): keep bazaar discovery block in the Payment-Required header
fudjia223602859d76
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 4a37d4411..6d23bc55b 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -17,6 +17,7 @@ Public history for [three.ws](https://three.ws), newest first. New pages come fr- **News story links no longer go dead** — Every article on the news feed gets a permanent link, but stories published near a month boundary could slip through the hourly archiver and their links would eventually 404. The archiver now files each story under its real publication month (and no longer caps how many articles it sweeps per run), story pages look in neighboring months and redirect to the right address when a link's month is off by one, and a link that truly can't be found now offers a one-click archive search for that story's title instead of a dead end. (`/markets/news`) `[fix, improvement]`- **Oversized x402 payment headers fixed** — Three paid endpoints (vanity, pump launch, agent reputation) mirrored their entire payment challenge — schemas, signed offers and all — into a single HTTP header that grew past 16 KB, the point where proxies and many clients drop or fail to parse the response. The header mirror is now capped at 8 KB: it slims down or steps aside when the challenge is large, while the response body always carries the complete challenge. Payment tooling that reads only headers still gets everything it needs to pay. `[fix]`- **Paid downloads can never ship before the payment settles** — Every paid endpoint on three.ws follows a 'deliver, then settle' order: the handler produces its result, the wrapper charges the buyer on-chain, and only then sends the response. That works for endpoints that hand back a value, but a streaming endpoint — one that writes its own file or feed directly to the connection, the natural shape for a binary download — could deliver the good before the settlement step ran, handing it over for free. No live endpoint did this, but it was a latent trap for the next one built. The payment wrapper now refuses to complete such a response silently: a streaming route must opt in explicitly, and when it does, the wrapper settles the payment first and only then lets the download start. Any endpoint that tried to send its body early is now caught and flagged instead of leaking the good. `[security]`+- **Paid endpoints are fully discoverable by payment crawlers again** — Agent-payment directories like AgentCash and x402scan discover a paid API by reading its 402 'payment required' challenge and checking that each endpoint declares what it takes in and what it returns. three.ws sends that challenge two ways — a complete JSON body and a compact copy in a response header — and crawlers read the header. To stay under strict header-size limits, the header copy had been dropping its entire discovery block on richer endpoints, so those endpoints looked schema-less to crawlers even though the full body was correct. The header now keeps the discovery block, shrinking only the parts a crawler doesn't need (and falling back to a compact placeholder schema for the largest endpoints) so every paid route advertises its input and output shape while the header stays small. All 21 paid endpoints now pass AgentCash's discovery validator cleanly. (`/openapi.json`) `[improvement, infra]`- **Paid endpoints now confirm a payment can settle before doing the work** — The in-house payment facilitator that verifies agent-to-agent USDC payments used to check only that a payment was correctly formed — the right amount, token, and recipient — but not that the buyer's account actually held the funds. Because paid endpoints run the requested work first and settle the payment afterward, a payment signed from an empty account could pass the check, trigger real (and sometimes costly) work like an AI generation, and only then fail to settle — leaving the platform to absorb the cost. Verification now simulates the payment on-chain, and falls back to a direct balance check if that's briefly unavailable, so a payment that can't settle is rejected before any work runs. Genuine, funded payments are unaffected. `[security]`- **Seeker wallet signing fixed before it ever shipped** — Automated testing of the Solana Seeker app in an Android emulator against Solana Mobile's reference wallet caught four bugs in our Mobile Wallet Adapter integration: the app icon was sent in a format the wallet spec rejects, and message signing, transaction signing, and send-transaction all read the wallet's response in the wrong shape. All four are fixed — wallet connect was verified end to end, returning a real public key through the on-device signing flow. `[fix, security]`- **The autonomous coin launcher learned taste** — The Memetic Launcher's picks got a full quality overhaul. Its cultural radar was half-blind — the pump.fun intel feed was silenced by a miscalibrated quality bar and generic sector words like 'meme' drowned out actual memes — so most picks fell back to random word-salad names. Now the radar reads live meme culture properly (Know Your Meme, Google Trends, Hacker News, Wikipedia attention, and pump.fun's own breakout data), each launch rides a specific rising narrative, the launcher remembers its recent picks so it never re-mints the same joke, coin descriptions are no longer cut off mid-sentence, and a quality gate refuses to spend real SOL on a filler pick when no genuine signal exists. Launch previews in the user launcher now refresh hourly instead of every minute. (`/launcher`) `[improvement, fix]`diff --git a/api/_lib/x402-spec.js b/api/_lib/x402-spec.jsindex 8f4cc1e80..5f78cc1ca 100644--- a/api/_lib/x402-spec.js+++ b/api/_lib/x402-spec.js@@ -1465,21 +1465,101 @@ export async function build402Body({// 8 KB leaves comfortable room for the ~0.5 KB of ordinary headers.const PAYMENT_REQUIRED_HEADER_MAX = 8 * 1024;-// The base64 header value mirroring a 402 envelope — or a spec-valid slimmed-// mirror ({x402Version, error, resource, accepts} without `extensions`, which-// is where the bulk lives: bazaar schemas, signed offers, SIWX declarations)-// when the full envelope would blow the header budget, or null when even the-// slim form is too large (many-accept endpoints). Header-only readers still-// get everything needed to pay (accepts is complete); the JSON body remains-// the canonical, complete envelope per the v2 spec.+const isPlainRecord = (v) => v != null && typeof v === 'object' && !Array.isArray(v);++// Drop the human-facing `info` examples from a bazaar extension, keeping the+// machine-readable `schema` that discovery validators actually parse. Returns+// null when nothing worth advertising survives.+function bazaarWithoutInfo(bazaar) {+ if (!isPlainRecord(bazaar)) return null;+ const { info, ...rest } = bazaar;+ return isPlainRecord(rest.schema) ? rest : null;+}++// A structurally-valid but compact bazaar mirror for the header: it preserves+// the input (queryParams/body) and output presence that agent-discovery+// crawlers key on (agentcash's extractSchemas2 / x402scan's Bazaar probe read+// `schema.properties.input.properties.{body|queryParams}` and+// `schema.properties.output.properties.example`), but replaces the potentially+// large per-field JSON Schemas with `{ type: 'object' }`. The canonical JSON+// body still carries the full, detailed schema — this is only the size-capped+// header fallback for routes whose real schema is too big to mirror verbatim.+function compactDiscoveryBazaar(bazaar) {+ const schema = bazaar?.schema;+ const inputProps = schema?.properties?.input?.properties;+ if (!isPlainRecord(inputProps)) return null;+ const input = {+ type: inputProps.type ?? { type: 'string', const: 'http' },+ method: inputProps.method ?? { type: 'string' },+ ...(isPlainRecord(inputProps.body)+ ? { body: { type: 'object' } }+ : isPlainRecord(inputProps.queryParams)+ ? { queryParams: { type: 'object' } }+ : {}),+ };+ const hasOutput = isPlainRecord(schema?.properties?.output);+ return {+ discoverable: bazaar.discoverable !== undefined ? bazaar.discoverable : true,+ schema: {+ ...(schema.$schema ? { $schema: schema.$schema } : {}),+ type: 'object',+ properties: {+ input: {+ type: 'object',+ properties: input,+ ...(Array.isArray(schema.properties.input.required)+ ? { required: schema.properties.input.required }+ : {}),+ additionalProperties: false,+ },+ ...(hasOutput+ ? {+ output: {+ type: 'object',+ properties: {+ type: { type: 'string' },+ example: { type: 'object' },+ },+ required: ['type'],+ },+ }+ : {}),+ },+ ...(Array.isArray(schema.required) ? { required: schema.required } : {}),+ },+ };+}++// The base64 header value mirroring a 402 envelope. When the full envelope+// fits the budget it ships verbatim. Otherwise we shed the heavy+// payment-execution extensions (signed offers, gas-sponsoring hints, SIWX /+// auth-hints, builder-code) but KEEP the `bazaar` discovery extension, because+// agent-discovery crawlers (agentcash, x402scan's Bazaar) read the challenge+// from THIS header, not the JSON body — dropping bazaar makes every paid route+// look schema-less to them. We try, in order: full bazaar, bazaar without the+// `info` examples, then a compact bazaar with `{type:'object'}` field schemas —+// picking the first that fits — before falling back to the extension-less slim+// mirror, then null. Header-only payers still get everything needed to pay+// (accepts is always complete); the JSON body remains the canonical, complete+// envelope with the full detailed schemas per the v2 spec.export function paymentRequiredHeaderValue(body) {- const full = Buffer.from(JSON.stringify(body), 'utf8').toString('base64');+ const encode = (obj) => Buffer.from(JSON.stringify(obj), 'utf8').toString('base64');+ const full = encode(body);if (full.length <= PAYMENT_REQUIRED_HEADER_MAX) return full;- const { x402Version, error, resource, accepts } = body;- const slim = Buffer.from(- JSON.stringify({ x402Version, error, resource, accepts }),- 'utf8',- ).toString('base64');++ const { x402Version, error, resource, accepts, extensions } = body;+ const slimBase = { x402Version, error, resource, accepts };+ const bazaar = extensions?.bazaar;+ if (isPlainRecord(bazaar)) {+ const candidates = [bazaar, bazaarWithoutInfo(bazaar), compactDiscoveryBazaar(bazaar)];+ for (const candidate of candidates) {+ if (!candidate) continue;+ const mirror = encode({ ...slimBase, extensions: { bazaar: candidate } });+ if (mirror.length <= PAYMENT_REQUIRED_HEADER_MAX) return mirror;+ }+ }++ const slim = encode(slimBase);return slim.length <= PAYMENT_REQUIRED_HEADER_MAX ? slim : null;}diff --git a/data/changelog.json b/data/changelog.jsonindex 696c05cf4..f26999415 100644--- a/data/changelog.json+++ b/data/changelog.json@@ -1,6 +1,16 @@{"$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-12",+ "title": "Paid endpoints are fully discoverable by payment crawlers again",+ "summary": "Agent-payment directories like AgentCash and x402scan discover a paid API by reading its 402 'payment required' challenge and checking that each endpoint declares what it takes in and what it returns. three.ws sends that challenge two ways — a complete JSON body and a compact copy in a response header — and crawlers read the header. To stay under strict header-size limits, the header copy had been dropping its entire discovery block on richer endpoints, so those endpoints looked schema-less to crawlers even though the full body was correct. The header now keeps the discovery block, shrinking only the parts a crawler doesn't need (and falling back to a compact placeholder schema for the largest endpoints) so every paid route advertises its input and output shape while the header stays small. All 21 paid endpoints now pass AgentCash's discovery validator cleanly.",+ "tags": [+ "improvement",+ "infra"+ ],+ "link": "/openapi.json"+ },{"date": "2026-07-12","title": "News story links no longer go dead",diff --git a/public/changelog.json b/public/changelog.jsonindex 184cb710d..7a429a4ac 100644--- a/public/changelog.json+++ b/public/changelog.json@@ -1,5 +1,5 @@{- "generated_at": "2026-07-12T09:06:40.738Z",+ "generated_at": "2026-07-12T09:50:29.602Z","generated_by": "scripts/build-page-index.mjs from data/pages.json + data/changelog.json","site": {"name": "three.ws",@@ -121,6 +121,17 @@"security"]},+ {+ "date": "2026-07-12",+ "type": "update",+ "title": "Paid endpoints are fully discoverable by payment crawlers again",+ "summary": "Agent-payment directories like AgentCash and x402scan discover a paid API by reading its 402 'payment required' challenge and checking that each endpoint declares what it takes in and what it returns. three.ws sends that challenge two ways — a complete JSON body and a compact copy in a response header — and crawlers read the header. To stay under strict header-size limits, the header copy had been dropping its entire discovery block on richer endpoints, so those endpoints looked schema-less to crawlers even though the full body was correct. The header now keeps the discovery block, shrinking only the parts a crawler doesn't need (and falling back to a compact placeholder schema for the largest endpoints) so every paid route advertises its input and output shape while the header stays small. All 21 paid endpoints now pass AgentCash's discovery validator cleanly.",+ "link": "/openapi.json",+ "tags": [+ "improvement",+ "infra"+ ]+ },{"date": "2026-07-12","type": "update",diff --git a/public/changelog.xml b/public/changelog.xmlindex e819f733a..77bece794 100644--- a/public/changelog.xml+++ b/public/changelog.xml@@ -94,6 +94,14 @@<category>security</category><description>Every paid endpoint on three.ws follows a 'deliver, then settle' order: the handler produces its result, the wrapper charges the buyer on-chain, and only then sends the response. That works for endpoints that hand back a value, but a streaming endpoint — one that writes its own file or feed directly to the connection, the natural shape for a binary download — could deliver the good before the settlement step ran, handing it over for free. No live endpoint did this, but it was a latent trap for the next one built. The payment wrapper now refuses to complete such a response silently: a streaming route must opt in explicitly, and when it does, the wrapper settles the payment first and only then lets the download start. Any endpoint that tried to send its body early is now caught and flagged instead of leaking the good.</description></item>+ <item>+ <title>Paid endpoints are fully discoverable by payment crawlers again</title>+ <link>https://three.ws/openapi.json</link>+ <guid isPermaLink="false">2026-07-12:Paid endpoints are fully discoverable by payment crawlers again</guid>+ <pubDate>Sun, 12 Jul 2026 12:00:00 GMT</pubDate>+ <category>improvement</category>+ <description>Agent-payment directories like AgentCash and x402scan discover a paid API by reading its 402 'payment required' challenge and checking that each endpoint declares what it takes in and what it returns. three.ws sends that challenge two ways — a complete JSON body and a compact copy in a response header — and crawlers read the header. To stay under strict header-size limits, the header copy had been dropping its entire discovery block on richer endpoints, so those endpoints looked schema-less to crawlers even though the full body was correct. The header now keeps the discovery block, shrinking only the parts a crawler doesn't need (and falling back to a compact placeholder schema for the largest endpoints) so every paid route advertises its input and output shape while the header stays small. All 21 paid endpoints now pass AgentCash's discovery validator cleanly.</description>+ </item><item><title>Paid endpoints now confirm a payment can settle before doing the work</title><link>https://three.ws/changelog</link>diff --git a/public/features.json b/public/features.jsonindex 50f83cf36..3eaf3caaf 100644--- a/public/features.json+++ b/public/features.json@@ -1,5 +1,5 @@{- "generated_at": "2026-07-12T09:06:40.723Z",+ "generated_at": "2026-07-12T09:50:29.589Z","generated_by": "scripts/build-page-index.mjs from data/pages.json","site": {"name": "three.ws",diff --git a/tests/api/x402-spec.test.js b/tests/api/x402-spec.test.jsindex af42fad7c..d5f7c550c 100644--- a/tests/api/x402-spec.test.js+++ b/tests/api/x402-spec.test.js@@ -515,9 +515,14 @@ describe('send402 PAYMENT-REQUIRED header', () => {// Endpoints with rich bazaar schemas + per-accept signed offers were// emitting 11–17 KB header mirrors; the production LB dropped them// outright and x402scan flagged HEADERS_OVERFLOW on registration. The- // header is capped at 8 KB: full mirror when it fits, an extensions-free- // slim mirror when it doesn't, no header at all when even that overflows.- // The JSON body always carries the complete envelope.+ // header is capped at 8 KB. Because agent-discovery crawlers (agentcash,+ // x402scan's Bazaar) read the challenge from THIS header — not the JSON+ // body — the overflow fallback KEEPS the `bazaar` discovery extension while+ // shedding the heavy payment-execution extensions, degrading it in tiers+ // (full bazaar → drop `info` examples → compact `{type:'object'}` field+ // schemas) so input/output schema presence survives even for big schemas.+ // Only when no bazaar tier fits do we fall to an extension-less slim mirror,+ // then to no header. The JSON body always carries the complete envelope.describe('paymentRequiredHeaderValue cap', () => {function envelopeWithExtensions(extBytes, acceptsCount = 1) {return {@@ -535,6 +540,78 @@ describe('send402 PAYMENT-REQUIRED header', () => {};}+ // A realistic schema-bearing bazaar. `infoBytes` pads the human-facing+ // `info` examples; `fieldBytes` pads the per-field JSON Schemas inside+ // `schema` — letting a test force each degradation tier deterministically.+ function envelopeWithBazaarSchema({ infoBytes = 0, fieldBytes = 0 } = {}) {+ const pad = (n) => (n > 0 ? { description: 'x'.repeat(n) } : {});+ const queryParams = {+ type: 'object',+ properties: { id: { type: 'string', ...pad(fieldBytes) } },+ };+ const example = {+ type: 'object',+ properties: { ok: { type: 'boolean', ...pad(fieldBytes) } },+ };+ return {+ x402Version: 2,+ error: 'X-PAYMENT header is required',+ resource: { url: 'https://three.ws/api/x402/foo', description: 'demo', mimeType: 'application/json' },+ accepts: [{+ scheme: 'exact',+ network: 'eip155:8453',+ amount: '1000',+ payTo: '0x0000000000000000000000000000000000000000',+ asset: '0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913',+ }],+ extensions: {+ bazaar: {+ discoverable: true,+ info: {+ input: { type: 'http', method: 'GET', ...pad(infoBytes) },+ output: { type: 'json', example: { ok: true } },+ },+ schema: {+ $schema: 'https://json-schema.org/draft/2020-12/schema',+ type: 'object',+ properties: {+ input: {+ type: 'object',+ properties: {+ type: { type: 'string', const: 'http' },+ method: { type: 'string' },+ queryParams,+ },+ required: ['type', 'method'],+ additionalProperties: false,+ },+ output: {+ type: 'object',+ properties: { type: { type: 'string' }, example },+ required: ['type'],+ },+ },+ required: ['input'],+ },+ },+ eip2612GasSponsoring: { info: { version: '1' } },+ },+ };+ }++ // Mirror of the agentcash validator's extractSchemas2: the discovery+ // crawler considers a challenge complete when it can read an input schema+ // (`schema.properties.input.properties.{body|queryParams}`) and an output+ // schema (`schema.properties.output.properties.example`).+ function discoverySchemasResolvable(decoded) {+ const schema = decoded?.extensions?.bazaar?.schema;+ const inProps = schema?.properties?.input?.properties;+ const input = inProps?.body ?? inProps?.queryParams;+ const output = schema?.properties?.output?.properties?.example;+ const isRec = (v) => v != null && typeof v === 'object' && !Array.isArray(v);+ return isRec(input) && isRec(output);+ }+it('mirrors the full envelope when it fits', async () => {const { paymentRequiredHeaderValue } = await loadSpec();const body = envelopeWithExtensions(100);@@ -542,8 +619,52 @@ describe('send402 PAYMENT-REQUIRED header', () => {expect(JSON.parse(Buffer.from(header, 'base64').toString('utf8'))).toEqual(body);});- it('drops extensions when the full mirror exceeds 8 KB, keeping a payable slim envelope', async () => {+ it('keeps the full bazaar (info + schema) when a schema-bearing envelope fits', async () => {+ const { paymentRequiredHeaderValue } = await loadSpec();+ const body = envelopeWithBazaarSchema();+ const header = paymentRequiredHeaderValue(body);+ expect(header.length).toBeLessThanOrEqual(8 * 1024);+ const decoded = JSON.parse(Buffer.from(header, 'base64').toString('utf8'));+ // Full envelope fit — bazaar and its info both survive verbatim.+ expect(decoded.extensions.bazaar.info).toBeDefined();+ expect(decoded.extensions.eip2612GasSponsoring).toBeDefined();+ expect(discoverySchemasResolvable(decoded)).toBe(true);+ });++ it('drops the bazaar info examples (keeping the real schema) when the full mirror overflows', async () => {+ const { paymentRequiredHeaderValue } = await loadSpec();+ const body = envelopeWithBazaarSchema({ infoBytes: 20_000 });+ const header = paymentRequiredHeaderValue(body);+ expect(header.length).toBeLessThanOrEqual(8 * 1024);+ const decoded = JSON.parse(Buffer.from(header, 'base64').toString('utf8'));+ // Heavy payment extensions and the bloated info are gone; the machine+ // schema the discovery crawler needs stays, verbatim.+ expect(decoded.extensions.bazaar.info).toBeUndefined();+ expect(decoded.extensions.eip2612GasSponsoring).toBeUndefined();+ expect(decoded.extensions.bazaar.schema.properties.input.properties.queryParams.properties)+ .toBeDefined();+ expect(discoverySchemasResolvable(decoded)).toBe(true);+ });++ it('compacts the bazaar field schemas when even the schema alone overflows', async () => {+ const { paymentRequiredHeaderValue } = await loadSpec();+ const body = envelopeWithBazaarSchema({ fieldBytes: 20_000 });+ const header = paymentRequiredHeaderValue(body);+ expect(header.length).toBeLessThanOrEqual(8 * 1024);+ const decoded = JSON.parse(Buffer.from(header, 'base64').toString('utf8'));+ // Field schemas collapse to a compact `{type:'object'}` placeholder,+ // but input/output presence — all the crawler keys on — survives.+ expect(decoded.extensions.bazaar.schema.properties.input.properties.queryParams)+ .toEqual({ type: 'object' });+ expect(decoded.extensions.bazaar.schema.properties.output.properties.example)+ .toEqual({ type: 'object' });+ expect(discoverySchemasResolvable(decoded)).toBe(true);+ });++ it('falls to an extension-less slim mirror when no bazaar tier fits', async () => {const { paymentRequiredHeaderValue } = await loadSpec();+ // Schema-less bazaar that is itself far too big — no discovery tier+ // can shrink it, so only the payable slim envelope survives.const body = envelopeWithExtensions(20_000);const header = paymentRequiredHeaderValue(body);expect(header.length).toBeLessThanOrEqual(8 * 1024);