Skip to content

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.

chore: zauth drain handling, anthropic proxy updates, changelog + features refresh

nirholas0d3926359f08
diff --git a/CHANGELOG.md b/CHANGELOG.md
index d9f635f54..50d683c81 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -6,8 +6,10 @@ Public history for [three.ws](https://three.ws), newest first. New pages come fr
## 2026-06-11
+- **Accurate uptime on the x402 Provider Hub** — The payment directory was counting every unpaid x402 discovery request (the protocol's standard 402 challenge) as a failed call, dragging three.ws endpoint success rates down even when every endpoint was healthy. Telemetry now reports only real payment attempts, so the published uptime reflects actual service health. `[fix, infra]`
- **Avatar pages back online after image-engine outage** — Fetching an individual avatar was failing with a server error, which also broke the walking avatar on the home page. The image-processing engine the avatar dress-up baker relies on failed to load in production and took the whole endpoint down with it. Avatar lookups now load independently of the baker, and the missing image libraries ship with the deployment, so avatar pages and the home hero are back. `[fix, infra]`
-- **Built-in AI stays up when a provider runs dry** — The platform's built-in AI (chat, tutor, fact-checker, persona tools, agent talk) now runs on a deeper safety net. Three independent free lanes — Groq, OpenRouter (with automatic rotation across multiple accounts when one runs out of credits or hits a rate limit), and NVIDIA-hosted models — always serve first, and if every one of them fails, the request quietly falls through to a paid backstop instead of showing you an error. Paid x402 endpoints that previously returned errors during a provider outage now degrade the same way. `[improvement, infra]`
+- **Built-in AI stays up when a provider runs dry** — The platform's built-in AI (chat, the Brain model workbench, embedded site widgets, tutor, fact-checker, persona tools, agent talk, the transaction explainer) now runs on a deeper safety net. Three independent free lanes — Groq, OpenRouter (with automatic rotation across multiple accounts when one runs out of credits or hits a rate limit), and NVIDIA-hosted models — always serve first, and if every one of them fails, the request quietly falls through to a paid backstop instead of showing you an error. Paid x402 endpoints that previously returned errors during a provider outage now degrade the same way. `[improvement, infra]`
+- **Embedded avatar chat replies again** — Avatars embedded straight from their public profile — the one-line widget on the homepage and anywhere else the avatar URL is dropped in — went silent when you typed a message: the chat box accepted your text but the avatar never answered. The built-in AI now recognizes a plain public avatar and serves it the free we-pay model with the same per-avatar rate and usage limits, so embedded chat responds out of the box. `[fix]`
- **Faster, quieter agents directory and site-wide page polish** — The on-chain agents directory now loads from our server-side index instead of contacting every agent's metadata host from your browser — pages render faster and no longer spray network errors. Also: the pump.fun cockpit's sidebar pages are now shareable deep links, mobile nav and footer links meet touch-target guidelines, anonymous visitors no longer trigger failed sign-in requests on Walk and Create, and assorted dead links were removed. (`/agents`) `[improvement, fix]`
- **Live $THREE market data, longer trade streams, and tutor session fixes** — $THREE market stats (price, holders, liquidity) are flowing again from our primary data source — a missing request header had been silently failing it to backups for days. Live trade streams no longer cut out after 30 seconds; they now run their full duration. The Pay-As-You-Learn Tutor no longer errors when resuming a session — running tabs persist correctly across questions — and Fact Checker results are cached properly so repeat checks of the same claim return instantly. `[fix, improvement]`
- **Scheduled jobs restored after dependency outage** — Every background job — pump.fun monitoring, coin payouts, club payouts, scheduled X posts, DCA runs, subscription billing, and the rest — had been failing since a recent dependency upgrade left a required Solana staking library out of the deployment. The missing library now ships with every deploy, and the image-processing engine behind avatar baking was rolled back to its proven version so it loads reliably in production. All scheduled jobs run again. `[fix, infra]`
diff --git a/api/_lib/zauth.js b/api/_lib/zauth.js
index 850a96a4f..c228af15e 100644
--- a/api/_lib/zauth.js
+++ b/api/_lib/zauth.js
@@ -182,24 +182,30 @@ function buildMiddleware() {
}
}
-// Paid x402 surfaces, by path. Three groups:
+// Paid x402 surfaces, by path. Two groups:
// 1. MCP servers + payer/dispatcher routes (each one settles x402 payments).
-// 2. /api/x402/* paid services — every route here 402-challenges EXCEPT the
-// free metadata/read endpoints (admin console, DID document, buyer
-// receipt lookup), which must not pollute the public zauth registry.
-// 3. Agent payment routes (delegated x402 calls + invoice payments).
+// 2. Agent payment routes (delegated x402 calls + invoice payments).
+//
+// /api/x402/* paid services are deliberately NOT path-monitored. Every x402
+// buyer flow starts with an unpaid request that gets the mandatory 402
+// challenge — a body whose first field is `error`, which the SDK's response
+// validation records as a failed call. Path-monitoring those routes therefore
+// reported protocol-correct discovery traffic as downtime on the Provider Hub
+// (success rates of 0–60% on endpoints that were healthy). Those routes are
+// instead reported via the payment-header condition below: a request that
+// actually attempts payment is monitored end-to-end, so genuine post-payment
+// failures (and verification rejections of real payment attempts) still
+// reach the dashboard.
const MONITORED_SERVERS =
/\/api\/(wk-x402|mcp|mcp-3d|mcp-agent|mcp-bazaar|pump-fun-mcp|ibm-mcp|x402-pay)(\/|$)/;
-const MONITORED_X402_FREE = /\/api\/x402\/(admin(\/|$)|did$|my-receipts$|pay-by-name$)/;
-const MONITORED_X402 = /\/api\/x402\/[^/]/;
const MONITORED_AGENTS =
/\/api\/agents\/x402\/|\/api\/agents\/[^/]+\/x402\/|\/api\/agents\/payments\//;
function shouldMonitorReq(req) {
- if (req.headers?.['x-payment-intent'] || req.headers?.['x-payment']) return true;
+ const h = req.headers || {};
+ if (h['x-payment-intent'] || h['x-payment'] || h['payment-signature']) return true;
const p = req.path || '';
if (MONITORED_SERVERS.test(p)) return true;
- if (MONITORED_X402.test(p) && !MONITORED_X402_FREE.test(p)) return true;
return MONITORED_AGENTS.test(p);
}
diff --git a/api/llm/anthropic.js b/api/llm/anthropic.js
index 448ca90ff..bb65c27d6 100644
--- a/api/llm/anthropic.js
+++ b/api/llm/anthropic.js
@@ -18,7 +18,12 @@ import { parse } from '../_lib/validate.js';
import { limits, clientIp } from '../_lib/rate-limit.js';
import { recordEvent, logger } from '../_lib/usage.js';
import { costMicroUsd } from '../_lib/llm-pricing.js';
-import { readEmbedPolicy } from '../_lib/embed-policy.js';
+import {
+ readEmbedPolicy,
+ readEmbedPolicyByAvatarId,
+ defaultEmbedPolicy,
+} from '../_lib/embed-policy.js';
+import { getAvatar } from '../_lib/avatars.js';
const log = logger('llm.anthropic');
@@ -265,12 +270,34 @@ const bodySchema = z.object({
// ── Handler ───────────────────────────────────────────────────────────────────
+// Resolve the embed policy for the `agent` query param. The param carries
+// whatever uuid the embed was pointed at, which is one of three things:
+// 1. an agent_identity id — the canonical agent embed
+// 2. an avatar id with an agent — an agent_identity linked via avatar_id
+// 3. a bare public avatar id — `/api/avatars/:id`, the documented embed
+// source (see src/manifest.js). These have no agent_identity row, so they
+// fall through to the default we-pay free-model policy. Without this the
+// homepage avatar widget (and any bare-avatar embed) chats into a 404.
+// Private/unlisted avatars and unknown ids resolve to null → caller 404s.
+async function resolveEmbedPolicy(id) {
+ const byAgentId = await readEmbedPolicy(id);
+ if (byAgentId) return byAgentId;
+
+ const byAvatarId = await readEmbedPolicyByAvatarId(id);
+ if (byAvatarId) return byAvatarId;
+
+ const avatar = await getAvatar({ id });
+ if (avatar && avatar.visibility === 'public') return defaultEmbedPolicy();
+
+ return null;
+}
+
export default wrap(async (req, res) => {
const url = new URL(req.url, 'http://x');
const agentId = url.searchParams.get('agent');
let policy = null;
- if (agentId) policy = await readEmbedPolicy(agentId);
+ if (agentId) policy = await resolveEmbedPolicy(agentId);
const corsOrigins = buildCorsAllowlist(policy);
if (cors(req, res, { origins: corsOrigins, methods: 'POST,OPTIONS' })) return;
diff --git a/data/changelog.json b/data/changelog.json
index 277485026..8af1612ed 100644
--- a/data/changelog.json
+++ b/data/changelog.json
@@ -1,6 +1,23 @@
{
"$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-06-11",
+ "title": "Embedded avatar chat replies again",
+ "summary": "Avatars embedded straight from their public profile — the one-line widget on the homepage and anywhere else the avatar URL is dropped in — went silent when you typed a message: the chat box accepted your text but the avatar never answered. The built-in AI now recognizes a plain public avatar and serves it the free we-pay model with the same per-avatar rate and usage limits, so embedded chat responds out of the box.",
+ "tags": [
+ "fix"
+ ]
+ },
+ {
+ "date": "2026-06-11",
+ "title": "Accurate uptime on the x402 Provider Hub",
+ "summary": "The payment directory was counting every unpaid x402 discovery request (the protocol's standard 402 challenge) as a failed call, dragging three.ws endpoint success rates down even when every endpoint was healthy. Telemetry now reports only real payment attempts, so the published uptime reflects actual service health.",
+ "tags": [
+ "fix",
+ "infra"
+ ]
+ },
{
"date": "2026-06-11",
"title": "Built-in AI stays up when a provider runs dry",
diff --git a/public/changelog.json b/public/changelog.json
index 5af87f40f..9778b581e 100644
--- a/public/changelog.json
+++ b/public/changelog.json
@@ -1,11 +1,22 @@
{
- "generated_at": "2026-06-11T04:22:01.997Z",
+ "generated_at": "2026-06-11T05:09:19.145Z",
"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-06-11",
+ "type": "update",
+ "title": "Accurate uptime on the x402 Provider Hub",
+ "summary": "The payment directory was counting every unpaid x402 discovery request (the protocol's standard 402 challenge) as a failed call, dragging three.ws endpoint success rates down even when every endpoint was healthy. Telemetry now reports only real payment attempts, so the published uptime reflects actual service health.",
+ "link": null,
+ "tags": [
+ "fix",
+ "infra"
+ ]
+ },
{
"date": "2026-06-11",
"type": "update",
@@ -21,13 +32,23 @@
"date": "2026-06-11",
"type": "update",
"title": "Built-in AI stays up when a provider runs dry",
- "summary": "The platform's built-in AI (chat, tutor, fact-checker, persona tools, agent talk) now runs on a deeper safety net. Three independent free lanes — Groq, OpenRouter (with automatic rotation across multiple accounts when one runs out of credits or hits a rate limit), and NVIDIA-hosted models — always serve first, and if every one of them fails, the request quietly falls through to a paid backstop instead of showing you an error. Paid x402 endpoints that previously returned errors during a provider outage now degrade the same way.",
+ "summary": "The platform's built-in AI (chat, the Brain model workbench, embedded site widgets, tutor, fact-checker, persona tools, agent talk, the transaction explainer) now runs on a deeper safety net. Three independent free lanes — Groq, OpenRouter (with automatic rotation across multiple accounts when one runs out of credits or hits a rate limit), and NVIDIA-hosted models — always serve first, and if every one of them fails, the request quietly falls through to a paid backstop instead of showing you an error. Paid x402 endpoints that previously returned errors during a provider outage now degrade the same way.",
"link": null,
"tags": [
"improvement",
"infra"
]
},
+ {
+ "date": "2026-06-11",
+ "type": "update",
+ "title": "Embedded avatar chat replies again",
+ "summary": "Avatars embedded straight from their public profile — the one-line widget on the homepage and anywhere else the avatar URL is dropped in — went silent when you typed a message: the chat box accepted your text but the avatar never answered. The built-in AI now recognizes a plain public avatar and serves it the free we-pay model with the same per-avatar rate and usage limits, so embedded chat responds out of the box.",
+ "link": null,
+ "tags": [
+ "fix"
+ ]
+ },
{
"date": "2026-06-11",
"type": "update",
diff --git a/public/changelog.xml b/public/changelog.xml
index 15bd1548b..0f3fe3ad7 100644
--- a/public/changelog.xml
+++ b/public/changelog.xml
@@ -6,6 +6,14 @@
<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>Accurate uptime on the x402 Provider Hub</title>
+ <link>https://three.ws/changelog</link>
+ <guid isPermaLink="false">2026-06-11:Accurate uptime on the x402 Provider Hub</guid>
+ <pubDate>Thu, 11 Jun 2026 12:00:00 GMT</pubDate>
+ <category>fix</category>
+ <description>The payment directory was counting every unpaid x402 discovery request (the protocol's standard 402 challenge) as a failed call, dragging three.ws endpoint success rates down even when every endpoint was healthy. Telemetry now reports only real payment attempts, so the published uptime reflects actual service health.</description>
+ </item>
<item>
<title>Avatar pages back online after image-engine outage</title>
<link>https://three.ws/changelog</link>
@@ -20,7 +28,15 @@
<guid isPermaLink="false">2026-06-11:Built-in AI stays up when a provider runs dry</guid>
<pubDate>Thu, 11 Jun 2026 12:00:00 GMT</pubDate>
<category>improvement</category>
- <description>The platform's built-in AI (chat, tutor, fact-checker, persona tools, agent talk) now runs on a deeper safety net. Three independent free lanes — Groq, OpenRouter (with automatic rotation across multiple accounts when one runs out of credits or hits a rate limit), and NVIDIA-hosted models — always serve first, and if every one of them fails, the request quietly falls through to a paid backstop instead of showing you an error. Paid x402 endpoints that previously returned errors during a provider outage now degrade the same way.</description>
+ <description>The platform's built-in AI (chat, the Brain model workbench, embedded site widgets, tutor, fact-checker, persona tools, agent talk, the transaction explainer) now runs on a deeper safety net. Three independent free lanes — Groq, OpenRouter (with automatic rotation across multiple accounts when one runs out of credits or hits a rate limit), and NVIDIA-hosted models — always serve first, and if every one of them fails, the request quietly falls through to a paid backstop instead of showing you an error. Paid x402 endpoints that previously returned errors during a provider outage now degrade the same way.</description>
+ </item>
+ <item>
+ <title>Embedded avatar chat replies again</title>
+ <link>https://three.ws/changelog</link>
+ <guid isPermaLink="false">2026-06-11:Embedded avatar chat replies again</guid>
+ <pubDate>Thu, 11 Jun 2026 12:00:00 GMT</pubDate>
+ <category>fix</category>
+ <description>Avatars embedded straight from their public profile — the one-line widget on the homepage and anywhere else the avatar URL is dropped in — went silent when you typed a message: the chat box accepted your text but the avatar never answered. The built-in AI now recognizes a plain public avatar and serves it the free we-pay model with the same per-avatar rate and usage limits, so embedded chat responds out of the box.</description>
</item>
<item>
<title>Faster, quieter agents directory and site-wide page polish</title>
diff --git a/public/features.json b/public/features.json
index e1c1598a9..9c4e9b8e4 100644
--- a/public/features.json
+++ b/public/features.json
@@ -1,5 +1,5 @@
{
- "generated_at": "2026-06-11T04:22:01.983Z",
+ "generated_at": "2026-06-11T05:09:19.132Z",
"generated_by": "scripts/build-page-index.mjs from data/pages.json",
"site": {
"name": "three.ws",
diff --git a/tests/api/llm-anthropic.test.js b/tests/api/llm-anthropic.test.js
index 5c75208be..3a7ebd771 100644
--- a/tests/api/llm-anthropic.test.js
+++ b/tests/api/llm-anthropic.test.js
@@ -14,9 +14,17 @@ process.env.UPSTASH_REDIS_REST_TOKEN ||= 'redis-token';
// ── Mocks ─────────────────────────────────────────────────────────────────
const policyState = { policy: null };
+const avatarPolicyState = { policy: null };
+const avatarState = { avatar: null };
vi.mock('../../api/_lib/embed-policy.js', () => ({
readEmbedPolicy: vi.fn(async () => policyState.policy),
+ readEmbedPolicyByAvatarId: vi.fn(async () => avatarPolicyState.policy),
+ defaultEmbedPolicy: () => JSON.parse(JSON.stringify(DEFAULT_POLICY)),
+}));
+
+vi.mock('../../api/_lib/avatars.js', () => ({
+ getAvatar: vi.fn(async () => avatarState.avatar),
}));
const rlState = {
@@ -177,10 +185,28 @@ const WE_PAY_POLICY = {
storage: { primary: 'r2', pinned_ipfs: false, onchain_attested: false },
};
+// Mirrors embed-policy.js defaultEmbedPolicy() — the we-pay free-model policy
+// granted to bare public-avatar embeds that have no agent_identity row.
+const DEFAULT_POLICY = {
+ version: 1,
+ origins: { mode: 'allowlist', hosts: [] },
+ surfaces: { script: true, iframe: true, widget: true, mcp: false },
+ brain: {
+ mode: 'we-pay',
+ proxy_url: null,
+ monthly_quota: 1000,
+ rate_limit_per_min: 10,
+ model: 'meta-llama/llama-3.3-70b-instruct:free',
+ },
+ storage: { primary: 'r2', pinned_ipfs: false, onchain_attested: false },
+};
+
// ── Reset between tests ───────────────────────────────────────────────────
beforeEach(() => {
policyState.policy = JSON.parse(JSON.stringify(WE_PAY_POLICY));
+ avatarPolicyState.policy = null;
+ avatarState.avatar = null;
rlState.ip = { success: true };
rlState.agent = { success: true };
usageEvents.length = 0;
@@ -200,8 +226,40 @@ describe('/api/llm/anthropic — agent + policy gating', () => {
expect(body.error).toBe('validation_error');
});
- it('returns 404 when policy not found for agent', async () => {
+ it('returns 404 when no agent, avatar-agent, or public avatar matches', async () => {
+ policyState.policy = null;
+ avatarPolicyState.policy = null;
+ avatarState.avatar = null;
+ const { status, body } = await invoke({ body: VALID_BODY });
+ expect(status).toBe(404);
+ expect(body.error).toBe('not_found');
+ });
+
+ it('falls back to the agent_identity linked by avatar_id', async () => {
+ policyState.policy = null;
+ avatarPolicyState.policy = JSON.parse(JSON.stringify(WE_PAY_POLICY));
+ const { status } = await invoke({ body: VALID_BODY });
+ expect(status).toBe(200);
+ });
+
+ it('grants the default we-pay policy to a bare public avatar embed', async () => {
+ policyState.policy = null;
+ avatarPolicyState.policy = null;
+ avatarState.avatar = { id: 'avatar-uuid', visibility: 'public' };
+ // The default policy serves the free OpenRouter model.
+ process.env.OPENROUTER_API_KEY = 'sk-or-test';
+ try {
+ const { status } = await invoke({ body: VALID_BODY });
+ expect(status).toBe(200);
+ } finally {
+ delete process.env.OPENROUTER_API_KEY;
+ }
+ });
+
+ it('does not grant a policy to a private avatar', async () => {
policyState.policy = null;
+ avatarPolicyState.policy = null;
+ avatarState.avatar = { id: 'avatar-uuid', visibility: 'private' };
const { status, body } = await invoke({ body: VALID_BODY });
expect(status).toBe(404);
expect(body.error).toBe('not_found');
diff --git a/tests/e2e/galaxy.spec.js b/tests/e2e/galaxy.spec.js
index 826c9ee9b..66ad377c0 100644
--- a/tests/e2e/galaxy.spec.js
+++ b/tests/e2e/galaxy.spec.js
@@ -189,8 +189,8 @@ test.describe('IBM Agent Galaxy', () => {
await gotoGalaxy(page, { mode: 'unavailable', expectState: 'unavailable' });
await expect(page.locator('#unavailableState')).toBeVisible();
await expect(page.locator('#unavailableState h2')).toContainText('not configured');
- // The IBM demos link is present so users know what to do.
- await expect(page.locator('#unavailableState a[href="/ibm/galaxy"]')).toBeVisible();
+ // The /ibm link is present so users know what to do.
+ await expect(page.locator('#unavailableState a[href="/ibm"]')).toBeVisible();
});
// ── State: no agents ────────────────────────────────────────────────────
diff --git a/tests/zauth-drain.test.js b/tests/zauth-drain.test.js
index 2f0a787ee..ba8bed3fb 100644
--- a/tests/zauth-drain.test.js
+++ b/tests/zauth-drain.test.js
@@ -45,7 +45,13 @@ function makeReq(path) {
return {
url: path,
method: 'GET',
- headers: { host: 'three.ws', 'x-forwarded-proto': 'https' },
+ // x-payment marks this as a real payment attempt — only those are
+ // monitored on /api/x402/* paths (unpaid 402 challenges are not).
+ headers: {
+ host: 'three.ws',
+ 'x-forwarded-proto': 'https',
+ 'x-payment': Buffer.from(JSON.stringify({ x402Version: 2 })).toString('base64'),
+ },
socket: { remoteAddress: '203.0.113.7' },
};
}
@@ -74,6 +80,15 @@ function makeRes() {
return res;
}
+test('unpaid x402 requests are not monitored — 402 challenges must not report as failed calls', async () => {
+ const { instrument } = await import('../api/_lib/zauth.js');
+
+ const req = makeReq('/api/x402/model-check');
+ delete req.headers['x-payment'];
+ const res = makeRes();
+ expect(instrument(req, res)).toBe(false);
+});
+
test('drain delivers the response event stranded behind an in-flight batch', async () => {
const { instrument, drain } = await import('../api/_lib/zauth.js');
diff --git a/vitest.config.js b/vitest.config.js
index acf73d04b..4fd2565f8 100644
--- a/vitest.config.js
+++ b/vitest.config.js
@@ -28,8 +28,15 @@ export default defineConfig({
'src/**/*.test.js',
'api/_lib/coin/**/*.test.js',
],
- testTimeout: 45_000,
- hookTimeout: 45_000,
+ // 45s proved too tight for this environment: with every fork cold-importing
+ // multi-thousand-module graphs concurrently, single imports have been
+ // measured at 51s (x402-paid-endpoint replay beforeAll) and 77s
+ // (api/_mcp/dispatch.js in all-modules-load). Which test pays the cold
+ // import varies run to run with scheduling, so per-test overrides are
+ // whack-a-mole — the ceiling itself must clear the measured worst case.
+ // Timeouts only bite hung tests; assertion failures still fail instantly.
+ testTimeout: 120_000,
+ hookTimeout: 120_000,
// Vitest 4 hoisted poolOptions.forks.* to top-level.
pool: 'forks',
maxForks: MAX_FORKS,