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.

feat(agents): add an avatar=1 filter so model-rendering surfaces only offer usable agents

nirholasf86542d953ba
diff --git a/api/agents/public.js b/api/agents/public.js
index a51ac9fb8..0f214cf42 100644
--- a/api/agents/public.js
+++ b/api/agents/public.js
@@ -9,6 +9,7 @@
* &before=<iso> cursor (created_at <) for pagination (newest|popular|name)
* &offset=<n> offset pagination (live)
* &network=mainnet only show on-chain agents on this network
+ * &avatar=1 only agents whose avatar GLB is publicly readable
*
* Returns { agents, count, has_more, generated_at }. Each agent has the
* public-safe fields: id, name, description, skills, avatar_thumbnail_url,
@@ -91,6 +92,11 @@ export default wrap(async (req, res) => {
const before = p.get('before') || null;
const offset = Math.max(0, Math.min(5000, Number(p.get('offset') || 0) | 0));
const onchainOnly = p.get('onchain') === '1' || p.get('onchain') === 'true';
+ // avatar=1 keeps only agents that carry a publicly readable avatar GLB. Surfaces
+ // that render or export the model itself (the Claude artifact builder, embeds)
+ // need this: an agent with no avatar, or one whose avatar is private, cannot be
+ // rendered at all and would offer the visitor a pick that can only fail.
+ const avatarOnly = p.get('avatar') === '1' || p.get('avatar') === 'true';
// ── live sort: activity-first, placeholder-suppressed, offset-paginated ──────
if (sort === 'live') {
@@ -124,6 +130,10 @@ export default wrap(async (req, res) => {
i.meta->'onchain' is not null
or i.meta->>'sol_mint_address' is not null
))
+ and (${!avatarOnly} or (
+ a.storage_key is not null
+ and a.visibility in ('public', 'unlisted')
+ ))
and (
ac.last_action_at is not null
or ch.chat_count > 0
@@ -216,6 +226,10 @@ export default wrap(async (req, res) => {
i.meta->'onchain' is not null
or i.meta->>'sol_mint_address' is not null
))
+ and (${!avatarOnly} or (
+ a.storage_key is not null
+ and a.visibility in ('public', 'unlisted')
+ ))
order by
${sort === 'newest' ? sql`i.created_at desc` :
sort === 'name' ? sql`i.name asc` :
diff --git a/tests/api/agents-public-avatar-filter.test.js b/tests/api/agents-public-avatar-filter.test.js
new file mode 100644
index 000000000..e950709c3
--- /dev/null
+++ b/tests/api/agents-public-avatar-filter.test.js
@@ -0,0 +1,134 @@
+// GET /api/agents/public?avatar=1 must return only agents whose avatar GLB is
+// publicly readable. Surfaces that render or export the model itself (the Claude
+// artifact builder at /artifact, embeds) offer these agents as one-click picks,
+// and an agent with no avatar, or with a private one, can only ever fail there.
+//
+// The filter is a bound boolean inside the WHERE clause, so this test renders the
+// tagged-template query with its bound values interleaved and asserts both halves
+// of the contract: the predicate is in the SQL, and the flag flips with the param.
+
+import { describe, it, expect, vi, beforeEach } from 'vitest';
+
+vi.mock('../../api/_lib/zauth.js', () => ({ instrument: () => {}, drain: async () => {} }));
+vi.mock('../../api/_lib/sentry.js', () => ({ captureException: () => {} }));
+vi.mock('../../api/_lib/rate-limit.js', () => ({
+ limits: { publicIp: async () => ({ success: true }) },
+ clientIp: () => '127.0.0.1',
+}));
+vi.mock('../../api/_lib/r2.js', () => ({
+ thumbnailUrl: (key) => `https://cdn.example/${key}`,
+ publicUrl: (key) => `https://cdn.example/${key}`,
+}));
+
+const calls = [];
+const ROWS = [
+ {
+ id: '27a0f649-3b59-4552-bb0b-faf616ac448b',
+ name: 'Axis Signal Lab',
+ description: null,
+ skills: [],
+ home_url: null,
+ chat_count: 0,
+ created_at: '2026-07-01T00:00:00.000Z',
+ meta: {},
+ erc8004_agent_id: null,
+ chain_id: null,
+ avatar_thumbnail_key: 'u/1/thumb.png',
+ avatar_visibility: 'public',
+ },
+];
+
+vi.mock('../../api/_lib/db.js', () => ({
+ sql: (strings, ...values) => {
+ calls.push({ strings, values });
+ return Promise.resolve(ROWS);
+ },
+ isDbUnavailableError: () => false,
+ isDbCapacityError: () => false,
+}));
+
+function makeReq(qs) {
+ return { url: `/api/agents/public${qs}`, method: 'GET', headers: { host: 'three.ws' } };
+}
+
+function makeRes() {
+ return {
+ statusCode: 200,
+ _h: {},
+ writableEnded: false,
+ setHeader(k, v) {
+ this._h[k.toLowerCase()] = v;
+ },
+ getHeader(k) {
+ return this._h[k.toLowerCase()];
+ },
+ end(body) {
+ this._body = body;
+ this.writableEnded = true;
+ },
+ };
+}
+
+// Interleave the bound values back into the template so a predicate can be read
+// together with the flag that gates it.
+function render(call) {
+ return call.strings.reduce(
+ (acc, part, i) => acc + part + (i < call.values.length ? `<<${String(call.values[i])}>>` : ''),
+ '',
+ );
+}
+
+const FILTER_ON =
+ /and \(<<false>> or \(\s*a\.storage_key is not null\s*and a\.visibility in \('public', 'unlisted'\)/i;
+const FILTER_OFF = /and \(<<true>> or \(\s*a\.storage_key is not null/i;
+
+function agentQuery() {
+ return calls.map(render).find((q) => /a\.storage_key is not null/i.test(q));
+}
+
+let handler;
+
+beforeEach(async () => {
+ calls.length = 0;
+ vi.resetModules();
+ const mod = await import('../../api/agents/public.js');
+ handler = mod.default;
+});
+
+describe('GET /api/agents/public?avatar=1', () => {
+ it('leaves the filter off when avatar is not requested', async () => {
+ const res = makeRes();
+ await handler(makeReq('?sort=popular&limit=5'), res);
+ expect(res.statusCode).toBe(200);
+ expect(agentQuery()).toMatch(FILTER_OFF);
+ });
+
+ it('turns the filter on for avatar=1', async () => {
+ const res = makeRes();
+ await handler(makeReq('?sort=popular&limit=5&avatar=1'), res);
+ expect(res.statusCode).toBe(200);
+ expect(agentQuery()).toMatch(FILTER_ON);
+ });
+
+ it('accepts avatar=true as well', async () => {
+ const res = makeRes();
+ await handler(makeReq('?sort=popular&avatar=true'), res);
+ expect(agentQuery()).toMatch(FILTER_ON);
+ });
+
+ it('applies the same filter to the live wall', async () => {
+ const res = makeRes();
+ await handler(makeReq('?sort=live&avatar=1'), res);
+ expect(res.statusCode).toBe(200);
+ expect(agentQuery()).toMatch(FILTER_ON);
+ });
+
+ it('still returns mapped agents with the filter on', async () => {
+ const res = makeRes();
+ await handler(makeReq('?sort=popular&avatar=1'), res);
+ const agents = JSON.parse(res._body).agents;
+ expect(agents).toHaveLength(1);
+ expect(agents[0].id).toBe('27a0f649-3b59-4552-bb0b-faf616ac448b');
+ expect(agents[0].avatar_thumbnail).toBe('https://cdn.example/u/1/thumb.png');
+ });
+});