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.

test(friends): pin the schema-error and search-escaping fixes and publish their changelog entry

nichd63819ed2214
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 684540ed4..0ca1f4ef6 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -9,6 +9,7 @@ Public history for [three.ws](https://three.ws), newest first. New pages come fr
- **A shared walk card no longer sends people to an avatar that is gone**: Sharing a walk produces a card you can post on Farcaster, with a button that opens that avatar walking. A cast stays up forever, but the avatar behind it does not: it can be deleted, or switched to private. When that happened the button still pointed at the missing avatar, so anyone who tapped it landed on a walk that could never load, and the card's second button pointed at the same place as the first, so both said the same thing. The card now checks the avatar before it builds. If the avatar is gone or private it drops the link and invites you to walk your own instead of handing you a dead button, and if the check itself cannot run the link is kept rather than thrown away. The second button now goes to the avatar builder, so the two buttons finally offer two different things. The card also carries its image dimensions now, which stops the preview from reflowing while it loads. (`/walk`) `[fix]`
- **An avatar rendered through the MCP server can no longer be turned into a tracking beacon**: When an AI assistant renders one of your avatars through the three.ws MCP server, the server builds a small viewer page and the assistant displays it. The caller picks the background for that page. The check on that value blocked anything that could break out of the styling, but it still allowed a CSS url(), so a caller could point the background at an image on a server they control and quietly collect the address and referring page of everyone who ever viewed that avatar. Backgrounds and gradients never need url(), so it is refused outright now and the safe default is used instead. A second fix went in with it: the server works out its own public web address to build the links it hands back, and its test for a local development address matched anywhere in the name instead of the whole name, so a request arriving with a forged host like evil-127.0.0.1.example.com was treated as local and got plain http links rather than https. That test is now anchored to the whole host, and IPv6 loopback is recognised properly. The animation tools also stopped treating built-in JavaScript property names as though they were real animation clips, and the shared MCP helpers behind all of this are now covered by tests. (`/docs/mcp`) `[security, fix]`
- **An expired Bitcoin inscription order now says so, instead of looking like a broken server**: The Forever page writes your message into Bitcoin, then keeps a pay screen open while you send the payment from your own wallet. That screen is restored when you come back to the tab. If the inscription order behind it had since expired, the page had no way to say so: the server reported an order it could not find as a server fault, so the pay screen either sat there polling an order that no longer existed, or repainted itself empty with no charge address and no explanation. An order that no longer exists is now reported as exactly that, and the page retires it, tells you nothing was charged, and puts you back at the message box to start a new one. Three related fixes went in with it. An inscription that the provider rejected could come back marked as success, which briefly showed a pay screen for an order that was never created; every provider failure is now reported as one. A receive address with a typo is now caught by its checksum before the order is created, and tells you to recopy it from your wallet, rather than failing later with a message that explained nothing. And an order that expired unpaid is no longer counted as paid. (`/forever`) `[fix]`
+- **Copy-trading set up by an agent now keeps its alerts and can pay its leader**: Agents that arrange copy-trading through the MCP tools hit three problems. A Telegram chat supplied for copy alerts was thrown away, and worse, adjusting an existing subscription erased the chat already set on the dashboard, so the alerts stopped. Subscriptions created this way also never recorded the leader payout wallet, which meant the leader performance fee could not be settled on them. And when the database was briefly unreachable, the tools answered with a confident wrong answer: your leader does not exist, or you have no subscriptions at all. Alerts and the payout wallet are now stored correctly, an outage says plainly that the service is temporarily unavailable, two agents subscribing at the same moment no longer collide, and a trader profile now returns the open positions it always advertised so a leader can be vetted before being copied. (`/dashboard/copy`) `[fix]`
- **Embedded agents keep their tool calls, and the free brain lane bills what it actually used**: The we-pay brain behind every embedded agent streams its answers, and three things in that stream were wrong. Free providers were never asked to report how many tokens a streamed answer used, so the monthly token budget an owner sets on an agent counted zero for the lane most embeds run on: the budget could not be reached, and the usage screen showed no spend for real traffic. Groq reports those numbers in a field of its own, which was being ignored for the same reason; both are now read and charged. Tool calls fared worse: when a provider streamed a tool name in pieces, only the first piece survived, so the agent tried to call a tool that does not exist, and a call whose id never arrived was dropped in silence instead of being passed on. Finally, the second step of the automatic failover chain pointed at a model that no longer exists anywhere, so a rate-limited free lane skipped straight past it; it now points at a live free model on a separate account, and requests that leave the token limit unset no longer draw an avoidable rejection from Anthropic. (`/docs/api-reference`) `[fix, improvement]`
- **FBX export on the OKX 3D service line works again, and the Chinese-brief avatar prompt keeps its subject**: The paid FBX export service at /api/okx/3d/fbx-export was handing the conversion engine the wrong field names, so every call came back as a bad-request error and no model was ever converted. Nobody was charged for the failed calls, but nobody got an FBX either. It now speaks the engine's own contract, honors the requested target format (FBX, OBJ, STL, PLY, USDZ, 3MF), and a new test holds each of the three engine-backed services to the schema its engine publishes so a renamed field cannot break a paid lane again. Separately, when the Agent Identity Studio prompt director is unavailable, a Chinese-language brand brief now contributes only its first sentence to the fallback prompt, the same way an English one does, instead of pushing the style hints out of the generator's prompt budget. (`/api/okx/3d/catalog`) `[fix]`
- **FBX export on the OKX 3D studio works again**: The paid FBX export service at /api/okx/3d/fbx-export was handing the conversion engine the wrong parameter names, so every call came back as a rejected request instead of a converted model, and the format you asked for was dropped on the way through. The adapter now speaks the engine's own parameter names, so a rigged GLB converts to FBX (or OBJ, STL, PLY, USDZ, 3MF) and keeps its skeleton, skin weights, and blendshapes. Buyers were never charged for the failed calls. A contract test now checks every OKX studio service against the schema its engine actually publishes, so a renamed parameter cannot slip through again. Separately, a Chinese-language brand brief sent to the Agent Identity Studio now has its first sentence picked out correctly when the prompt director is unavailable, instead of the whole brief crowding out the style hints. (`/api/okx/3d/catalog`) `[fix]`
diff --git a/data/changelog.json b/data/changelog.json
index 9410e5a14..8accc7e9e 100644
--- a/data/changelog.json
+++ b/data/changelog.json
@@ -1,6 +1,15 @@
{
"$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-08-13",
+ "title": "Your friends list no longer goes blank when the database is mid-upgrade, and search finds unusual names",
+ "summary": "Two problems in the friends area. The friends list is built to survive an environment where the social tables have not been created yet: it shows an empty list instead of an error. That safety net was matching on the wording of the database error rather than its type, and the wording it looked for also appears when a single column is missing, which is what a partly-applied upgrade looks like. So during an upgrade the page answered normally and told you that you had no friends, no incoming requests, and no pending invites, with nothing anywhere reporting a fault. The safety net now recognises only a genuinely missing table, and any other database problem is reported as the error it is. Separately, friend search could not find a display name containing a backslash, and a search term ending in one quietly searched for something else, because the search was not escaping the backslash before handing the term to the database.",
+ "tags": [
+ "fix"
+ ],
+ "link": "/walk"
+ },
{
"date": "2026-08-13",
"title": "Copy-trading set up by an agent now keeps its alerts and can pay its leader",
@@ -20,16 +29,16 @@
],
"link": "/docs/api-reference"
},
- {
- "date": "2026-08-13",
- "title": "The CC0 object library answers a bad page request instead of quietly handing back the wrong page",
- "summary": "The free prop library behind /objects and the AR Studio Objects tray is also a public API anyone can page through. Ask it for a page size it cannot parse and it used to guess: a word where a number belongs silently returned a single object, a fractional page size handed back a fractional position to ask for next, and a page position sent without a page size was ignored outright. Every one of those looked like working pagination while quietly skipping or repeating props, so a script walking the whole catalogue could finish believing it had seen all 511 when it had not. Bad page requests now come back immediately as a clear error naming the parameter and the accepted range, while an oversized page still simply caps at the documented maximum. Separately, when the storage behind the library has a hiccup the endpoint still degrades to an empty list rather than an error page, but that emptiness is no longer cached for the next five minutes: the library reappears the moment storage recovers instead of staying blank long after.",
- "tags": [
- "fix",
- "improvement"
- ],
- "link": "/objects"
- },
+ {
+ "date": "2026-08-13",
+ "title": "The CC0 object library answers a bad page request instead of quietly handing back the wrong page",
+ "summary": "The free prop library behind /objects and the AR Studio Objects tray is also a public API anyone can page through. Ask it for a page size it cannot parse and it used to guess: a word where a number belongs silently returned a single object, a fractional page size handed back a fractional position to ask for next, and a page position sent without a page size was ignored outright. Every one of those looked like working pagination while quietly skipping or repeating props, so a script walking the whole catalogue could finish believing it had seen all 511 when it had not. Bad page requests now come back immediately as a clear error naming the parameter and the accepted range, while an oversized page still simply caps at the documented maximum. Separately, when the storage behind the library has a hiccup the endpoint still degrades to an empty list rather than an error page, but that emptiness is no longer cached for the next five minutes: the library reappears the moment storage recovers instead of staying blank long after.",
+ "tags": [
+ "fix",
+ "improvement"
+ ],
+ "link": "/objects"
+ },
{
"date": "2026-08-13",
"title": "FBX export on the OKX 3D service line works again, and the Chinese-brief avatar prompt keeps its subject",
diff --git a/public/changelog.json b/public/changelog.json
index ed606e1a7..6786049cb 100644
--- a/public/changelog.json
+++ b/public/changelog.json
@@ -1,5 +1,5 @@
{
- "generated_at": "2026-08-13T02:06:29.190Z",
+ "generated_at": "2026-08-13T02:08:12.489Z",
"generated_by": "scripts/build-page-index.mjs from data/pages.json + data/changelog.json",
"site": {
"name": "three.ws",
@@ -37,6 +37,16 @@
"fix"
]
},
+ {
+ "date": "2026-08-13",
+ "type": "update",
+ "title": "Copy-trading set up by an agent now keeps its alerts and can pay its leader",
+ "summary": "Agents that arrange copy-trading through the MCP tools hit three problems. A Telegram chat supplied for copy alerts was thrown away, and worse, adjusting an existing subscription erased the chat already set on the dashboard, so the alerts stopped. Subscriptions created this way also never recorded the leader payout wallet, which meant the leader performance fee could not be settled on them. And when the database was briefly unreachable, the tools answered with a confident wrong answer: your leader does not exist, or you have no subscriptions at all. Alerts and the payout wallet are now stored correctly, an outage says plainly that the service is temporarily unavailable, two agents subscribing at the same moment no longer collide, and a trader profile now returns the open positions it always advertised so a leader can be vetted before being copied.",
+ "link": "/dashboard/copy",
+ "tags": [
+ "fix"
+ ]
+ },
{
"date": "2026-08-13",
"type": "update",
diff --git a/public/changelog.xml b/public/changelog.xml
index 53ea1a961..5aae84a60 100644
--- a/public/changelog.xml
+++ b/public/changelog.xml
@@ -30,6 +30,14 @@
<category>fix</category>
<description>The Forever page writes your message into Bitcoin, then keeps a pay screen open while you send the payment from your own wallet. That screen is restored when you come back to the tab. If the inscription order behind it had since expired, the page had no way to say so: the server reported an order it could not find as a server fault, so the pay screen either sat there polling an order that no longer existed, or repainted itself empty with no charge address and no explanation. An order that no longer exists is now reported as exactly that, and the page retires it, tells you nothing was charged, and puts you back at the message box to start a new one. Three related fixes went in with it. An inscription that the provider rejected could come back marked as success, which briefly showed a pay screen for an order that was never created; every provider failure is now reported as one. A receive address with a typo is now caught by its checksum before the order is created, and tells you to recopy it from your wallet, rather than failing later with a message that explained nothing. And an order that expired unpaid is no longer counted as paid.</description>
</item>
+ <item>
+ <title>Copy-trading set up by an agent now keeps its alerts and can pay its leader</title>
+ <link>https://three.ws/dashboard/copy</link>
+ <guid isPermaLink="false">2026-08-13:Copy-trading set up by an agent now keeps its alerts and can pay its leader</guid>
+ <pubDate>Thu, 13 Aug 2026 12:00:00 GMT</pubDate>
+ <category>fix</category>
+ <description>Agents that arrange copy-trading through the MCP tools hit three problems. A Telegram chat supplied for copy alerts was thrown away, and worse, adjusting an existing subscription erased the chat already set on the dashboard, so the alerts stopped. Subscriptions created this way also never recorded the leader payout wallet, which meant the leader performance fee could not be settled on them. And when the database was briefly unreachable, the tools answered with a confident wrong answer: your leader does not exist, or you have no subscriptions at all. Alerts and the payout wallet are now stored correctly, an outage says plainly that the service is temporarily unavailable, two agents subscribing at the same moment no longer collide, and a trader profile now returns the open positions it always advertised so a leader can be vetted before being copied.</description>
+ </item>
<item>
<title>Embedded agents keep their tool calls, and the free brain lane bills what it actually used</title>
<link>https://three.ws/docs/api-reference</link>
diff --git a/public/features.json b/public/features.json
index 0d0401a0d..a3838c26b 100644
--- a/public/features.json
+++ b/public/features.json
@@ -1,5 +1,5 @@
{
- "generated_at": "2026-08-13T02:06:29.107Z",
+ "generated_at": "2026-08-13T02:08:12.401Z",
"generated_by": "scripts/build-page-index.mjs from data/pages.json",
"site": {
"name": "three.ws",
diff --git a/tests/api/friends-graph-schema-errors.test.js b/tests/api/friends-graph-schema-errors.test.js
new file mode 100644
index 000000000..9e0b513db
--- /dev/null
+++ b/tests/api/friends-graph-schema-errors.test.js
@@ -0,0 +1,125 @@
+// GET /api/friends: how the handler classifies a schema-level database error.
+//
+// The friends graph deliberately degrades to an empty graph when its tables are
+// not migrated yet, so a fresh environment renders the social UI instead of a
+// 500. That degradation used to be keyed on substrings of the error message
+// ("relation", "does not exist"), which quietly over-matched: Postgres phrases a
+// missing COLUMN as `column "responded_at" of relation "friendships" does not
+// exist`, so a HALF-applied migration took the same branch. The endpoint then
+// answered 200 with an empty graph and every user looked like they had no
+// friends, no requests, and no pending invites, with nothing anywhere surfacing
+// the broken schema.
+//
+// The classification is now the Postgres SQLSTATE: 42P01 (undefined_table) is
+// the only code that may degrade. These tests pin both sides of that line.
+//
+// Mocks: the auth, rate-limit, presence, and friends-store boundaries only. The
+// real handler, the real api/_lib/http.js response layer, and the real control
+// flow all run.
+
+import { describe, it, expect, vi, beforeEach } from 'vitest';
+
+const authState = { account: { userId: '00000000-0000-0000-0000-0000000000aa' } };
+vi.mock('../../api/_lib/account-auth.js', () => ({
+ resolveAccount: vi.fn(async () => authState.account),
+}));
+
+const rlState = { success: true };
+vi.mock('../../api/_lib/rate-limit.js', () => ({
+ limits: {
+ publicIp: vi.fn(async () => rlState),
+ chatUser: vi.fn(async () => rlState),
+ },
+ clientIp: vi.fn(() => '127.0.0.1'),
+}));
+
+vi.mock('../../api/_lib/csrf.js', () => ({ requireCsrf: vi.fn(async () => true) }));
+
+vi.mock('../../api/_lib/presence-store.js', () => ({
+ readPresence: vi.fn(async () => ({})),
+ notifyMultiplayer: vi.fn(async () => ({ delivered: false, reason: 'unconfigured' })),
+}));
+
+const listGraph = vi.fn();
+vi.mock('../../api/_lib/friends-store.js', () => ({
+ listGraph: (...a) => listGraph(...a),
+ sendRequest: vi.fn(),
+ acceptRequest: vi.fn(),
+ declineRequest: vi.fn(),
+ removeFriend: vi.fn(),
+ muteUser: vi.fn(),
+ unmuteUser: vi.fn(),
+}));
+
+const { default: friendsHandler } = await import('../../api/friends/index.js');
+
+// A NeonDbError as the driver actually surfaces it: a `code` carrying the
+// SQLSTATE alongside the human-readable message.
+function dbError(code, message) {
+ return Object.assign(new Error(message), { name: 'NeonDbError', code });
+}
+
+function makeRes() {
+ return {
+ statusCode: 200,
+ _h: {},
+ setHeader(k, v) { this._h[k.toLowerCase()] = v; },
+ getHeader(k) { return this._h[k.toLowerCase()]; },
+ end(body) { this._body = body; },
+ };
+}
+
+async function get() {
+ const req = { method: 'GET', headers: {}, url: '/api/friends', query: {} };
+ const res = makeRes();
+ await friendsHandler(req, res);
+ let body = null;
+ try { body = JSON.parse(res._body); } catch { /* non-JSON body stays null */ }
+ return { res, body };
+}
+
+beforeEach(() => {
+ listGraph.mockReset();
+ rlState.success = true;
+ authState.account = { userId: '00000000-0000-0000-0000-0000000000aa' };
+});
+
+describe('GET /api/friends schema-error classification', () => {
+ it('degrades to an empty graph when the friends tables are not migrated (42P01)', async () => {
+ listGraph.mockRejectedValue(dbError('42P01', 'relation "friendships" does not exist'));
+ const { res, body } = await get();
+ expect(res.statusCode).toBe(200);
+ expect(body.data).toEqual({ friends: [], incoming: [], outgoing: [] });
+ });
+
+ it('surfaces a half-applied migration instead of reporting an empty graph (42703)', async () => {
+ // The message contains both "relation" and "does not exist", which is
+ // exactly what made the old substring test swallow it.
+ listGraph.mockRejectedValue(
+ dbError('42703', 'column "responded_at" of relation "friendships" does not exist'),
+ );
+ const { res, body } = await get();
+ expect(res.statusCode).toBe(500);
+ expect(body.data).toBeUndefined();
+ expect(body.error).toBe('internal_error');
+ });
+
+ it('surfaces any other database failure rather than hiding the graph', async () => {
+ listGraph.mockRejectedValue(dbError('57014', 'canceling statement due to statement timeout'));
+ const { res } = await get();
+ expect(res.statusCode).toBe(500);
+ });
+
+ it('returns the real graph, presence-annotated, on the success path', async () => {
+ listGraph.mockResolvedValue({
+ friends: [{ id: 'f-1', name: 'ada' }],
+ incoming: [],
+ outgoing: [],
+ });
+ const { res, body } = await get();
+ expect(res.statusCode).toBe(200);
+ expect(body.data.friends).toEqual([
+ { id: 'f-1', name: 'ada', online: false, realm: null, server: null },
+ ]);
+ });
+});
diff --git a/tests/friends-store-search-escaping.test.js b/tests/friends-store-search-escaping.test.js
new file mode 100644
index 000000000..c7ce5e982
--- /dev/null
+++ b/tests/friends-store-search-escaping.test.js
@@ -0,0 +1,106 @@
+// searchUsers(): LIKE-pattern escaping in the friend search.
+//
+// The search wraps the caller's term in `%…%` and runs it through ILIKE, so
+// every character Postgres treats as special has to be neutralised first. The
+// escaper originally covered the two wildcards (% and _) but not the escape
+// character itself, which broke two ways:
+//
+// * a term ending in a backslash escaped the closing wildcard, so "neo\"
+// became the pattern %neo\% and matched a literal "neo%" instead;
+// * a backslash anywhere in the term escaped the following character, so a
+// display name holding one ("neo\matrix") could never be found.
+//
+// Escaping the backslash FIRST fixes both. These tests capture the pattern the
+// store actually hands to Postgres, then assert the real matching semantics of
+// each pattern against Postgres' documented ILIKE rules.
+
+import { describe, it, expect, vi, beforeEach } from 'vitest';
+
+// Capture every query's parameters. The store composes a `publicUserCols()`
+// fragment into its SELECT, so the mock has to return a fragment-ish object for
+// the no-parameter column list and a normal result for real queries.
+const queries = [];
+vi.mock('../api/_lib/db.js', () => ({
+ sql: Object.assign(
+ vi.fn((strings, ...values) => {
+ queries.push({ text: strings.join('?'), values });
+ return Promise.resolve([]);
+ }),
+ { transaction: vi.fn(async (fns) => { for (const f of fns) await f; }) },
+ ),
+ isDbUnavailableError: () => false,
+ isDbCapacityError: () => false,
+}));
+
+const { searchUsers } = await import('../api/_lib/friends-store.js');
+
+const ME = '00000000-0000-0000-0000-0000000000aa';
+
+// The LIKE pattern is the first parameter that starts and ends with a wildcard.
+function capturedPattern() {
+ for (const q of queries) {
+ for (const v of q.values) {
+ if (typeof v === 'string' && v.startsWith('%') && v.endsWith('%')) return v;
+ }
+ }
+ return null;
+}
+
+// Postgres ILIKE, reduced to the rules this escaping depends on: a backslash
+// escapes the next character (making it literal), an unescaped % matches any
+// run, an unescaped _ matches one character.
+function ilikeMatches(pattern, subject) {
+ let rx = '';
+ for (let i = 0; i < pattern.length; i++) {
+ const c = pattern[i];
+ if (c === '\\') { rx += pattern[++i]?.replace(/[.*+?^${}()|[\]\\]/g, '\\$&') ?? ''; continue; }
+ if (c === '%') { rx += '[\\s\\S]*'; continue; }
+ if (c === '_') { rx += '[\\s\\S]'; continue; }
+ rx += c.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
+ }
+ return new RegExp(`^${rx}$`, 'i').test(subject);
+}
+
+beforeEach(() => { queries.length = 0; });
+
+describe('searchUsers LIKE escaping', () => {
+ it('escapes a backslash so a name containing one is findable', async () => {
+ await searchUsers(ME, 'o\\m');
+ const pattern = capturedPattern();
+ expect(pattern).toBe('%o\\\\m%');
+ expect(ilikeMatches(pattern, 'neo\\matrix')).toBe(true);
+ });
+
+ it('keeps a trailing backslash from swallowing the closing wildcard', async () => {
+ await searchUsers(ME, 'neo\\');
+ const pattern = capturedPattern();
+ // The term's backslash is escaped, so the final % stays a wildcard.
+ expect(pattern).toBe('%neo\\\\%');
+ expect(ilikeMatches(pattern, 'neo\\matrix')).toBe(true);
+ // The pre-fix pattern matched a literal "neo%" and missed the real name.
+ expect(ilikeMatches('%neo\\%', 'neo\\matrix')).toBe(false);
+ });
+
+ it('still escapes the wildcards themselves', async () => {
+ await searchUsers(ME, 'pct%user');
+ const pattern = capturedPattern();
+ expect(pattern).toBe('%pct\\%user%');
+ expect(ilikeMatches(pattern, 'pct%user')).toBe(true);
+ expect(ilikeMatches(pattern, 'pctSOMETHINGuser')).toBe(false);
+ });
+
+ it('escapes the single-character wildcard', async () => {
+ await searchUsers(ME, 'a_b');
+ const pattern = capturedPattern();
+ expect(pattern).toBe('%a\\_b%');
+ expect(ilikeMatches(pattern, 'a_b')).toBe(true);
+ expect(ilikeMatches(pattern, 'axb')).toBe(false);
+ });
+
+ it('never queries for a term shorter than two characters', async () => {
+ expect(await searchUsers(ME, 'a')).toEqual([]);
+ expect(await searchUsers(ME, ' ')).toEqual([]);
+ expect(await searchUsers(ME, null)).toEqual([]);
+ expect(queries.length).toBe(0);
+ });
+});