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(agents): keep platform-internal agents off the public directory and trending
nirholas1729c47b38ef
diff --git a/api/_lib/migrations/20261001200000_hide_llm_gateway_meter_agent.sql b/api/_lib/migrations/20261001200000_hide_llm_gateway_meter_agent.sqlnew file mode 100644index 000000000..2b11d51fc--- /dev/null+++ b/api/_lib/migrations/20261001200000_hide_llm_gateway_meter_agent.sql@@ -0,0 +1,22 @@+-- Migration: take the marketplace chat bot's AI-budget meter off the public wall.+-- Apply: node scripts/apply-migrations.mjs --apply --file 20261001200000_hide_llm_gateway_meter_agent.sql+-- Idempotent.+--+-- scripts/okx-bot-llm-gateway.mjs created the meter agent (meta.purpose =+-- 'llm-gateway-meter', owned by the marketplace-chat service account) with+-- is_published = false but never set is_public, which defaults to true. So+-- /api/agents/public listed it and /api/trending ranked it #1 on the bot's own+-- traffic, with a description that says "Not a public agent". The script now+-- writes is_public = false on create and on every re-run; this corrects the one+-- row it already made (55479fa8-13c6-44b3-a245-3156f2c836e5 on 2026-10-01).+-- Nothing reads is_public on the meter's own path (the LLM proxy resolves its+-- embed policy by id alone), so metering is unaffected.+--+-- To reverse: update agent_identities set is_public = true+-- where meta->>'purpose' = 'llm-gateway-meter' and is_public = false;++update agent_identities+set is_public = false,+ updated_at = now()+where meta->>'purpose' = 'llm-gateway-meter'+ and is_public = true;diff --git a/api/agents/public.js b/api/agents/public.jsindex 84be12879..efa115720 100644--- a/api/agents/public.js+++ b/api/agents/public.js@@ -26,6 +26,15 @@* carries `total` (the wall's addressable size) and `active_total` (agents with* any activity) for the header stats.*+ * Internal agents never list. An agent the platform made for itself (owned by a+ * `users.service_account` row) and never published is infrastructure, such as+ * the meter that budgets the marketplace chat bot's AI spend, not something to+ * browse. `is_public` defaults to true, so a provisioning script that forgets to+ * clear it would otherwise put that machinery on the public wall; every query+ * here therefore also requires "published, or owned by a person". The platform's+ * own published persona agents (service-account owned, published) still list,+ * and so do people's unpublished starter agents.+ ** Public, IP rate-limited, 30-second CDN cache.*/@@ -121,6 +130,9 @@ export default wrap(async (req, res) => {) ch on truewhere i.deleted_at is nulland i.is_public = true+ and not (i.is_published is not true and exists (+ select 1 from users su where su.id = i.user_id and su.service_account+ ))and (${!q} or (to_tsvector('english', coalesce(i.name,'') || ' ' || coalesce(i.description,''))@@ plainto_tsquery('english', ${q})@@ -166,6 +178,9 @@ export default wrap(async (req, res) => {))::int as active_totalfrom agent_identities iwhere i.deleted_at is null and i.is_public = true+ and not (i.is_published is not true and exists (+ select 1 from users su where su.id = i.user_id and su.service_account+ ))and (exists (select 1 from agent_actions aa where aa.agent_id = i.id)or exists (select 1 from usage_events ue where ue.agent_id = i.id and ue.kind = 'llm')@@ -216,6 +231,9 @@ export default wrap(async (req, res) => {left join avatars a on a.id = i.avatar_id and a.deleted_at is nullwhere i.deleted_at is nulland i.is_public = true+ and not (i.is_published is not true and exists (+ select 1 from users su where su.id = i.user_id and su.service_account+ ))and (${!q} or (to_tsvector('english', coalesce(i.name,'') || ' ' || coalesce(i.description,''))@@ plainto_tsquery('english', ${q})diff --git a/api/trending.js b/api/trending.jsindex ec2e838cb..eb0fc1c1d 100644--- a/api/trending.js+++ b/api/trending.js@@ -21,6 +21,12 @@* /trending is therefore a real filter on both rankings, not a decoration: the* coin list used to ignore it entirely and always answer with a fixed 36h floor.*+ * Internal agents are excluded by the same rule as /api/agents/public: an agent+ * owned by a service account that was never published is platform machinery+ * (the marketplace chat bot's AI-budget meter ranked #1 here on 2026-10-01 off+ * its own bot traffic), so both agent queries require "published, or owned by+ * a person".+ ** Cache: 2 min public CDN (trending doesn't need sub-minute freshness).*/@@ -92,6 +98,9 @@ export default wrap(async (req, res) => {left join avatars a on a.id = i.avatar_id and a.deleted_at is nullwhere i.deleted_at is nulland i.is_public = true+ and not (i.is_published is not true and exists (+ select 1 from users su where su.id = i.user_id and su.service_account+ ))) twhere t.chat_count > 0order by t.chat_count desc@@ -121,6 +130,9 @@ export default wrap(async (req, res) => {and u.created_at >= now() - ${interval}::intervaland i.deleted_at is nulland i.is_public = true+ and not (i.is_published is not true and exists (+ select 1 from users su where su.id = i.user_id and su.service_account+ ))group by i.id, i.name, i.description, i.meta,a.thumbnail_key, a.visibilityorder by window_chats descdiff --git a/data/changelog.json b/data/changelog.jsonindex 383d04958..71e02ded4 100644--- a/data/changelog.json+++ b/data/changelog.json@@ -1,6 +1,13 @@{"$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, desktop (desktop entries become the desktop app's release notes). `link` is optional and must be a live three.ws path.","entries": [+ {+ "date": "2026-10-01",+ "title": "Trending and the agent directory show only real agents",+ "summary": "A behind-the-scenes agent the platform uses to budget its marketplace chat bot was showing up in the public agent directory and sitting at number one on Trending, counted up by the bot's own conversations. It is no longer listed, and both lists now leave out any agent the platform runs for itself unless it has been deliberately published, so Trending ranks agents people actually talk to.",+ "tags": ["fix"],+ "link": "/trending"+ },{"date": "2026-10-01","title": "Avatar pictures show a natural standing pose instead of a T-pose",diff --git a/scripts/okx-bot-llm-gateway.mjs b/scripts/okx-bot-llm-gateway.mjsindex 3628e152d..a8bbb788b 100644--- a/scripts/okx-bot-llm-gateway.mjs+++ b/scripts/okx-bot-llm-gateway.mjs@@ -204,17 +204,20 @@ async function ensureUser(sql) {async function ensureAgent(sql, userId, model) {const policy = JSON.stringify(gatewayPolicy(model));const existing = await findAgent(sql, userId);+ // The meter is machinery, not a listed agent. is_public defaults to true on+ // agent_identities, so it is set false explicitly on both paths; a re-run also+ // heals a meter that was created before this was enforced.if (existing) {- await sql`update agent_identities set embed_policy = ${policy}::jsonb, updated_at = now() where id = ${existing.id}`;+ await sql`update agent_identities set embed_policy = ${policy}::jsonb, is_public = false, updated_at = now() where id = ${existing.id}`;return { id: existing.id, created: false };}const meta = JSON.stringify({ purpose: AGENT_PURPOSE, meters: 'the marketplace chat bot reply subsession (workers/okx-chat-bot)' });const [row] = await sql`- insert into agent_identities (user_id, name, description, is_published, meta, embed_policy, created_at, updated_at)+ insert into agent_identities (user_id, name, description, is_published, is_public, meta, embed_policy, created_at, updated_at)values (${userId}, ${AGENT_NAME},'Meters the AI budget of the three.ws marketplace chat bot. Not a public agent.',- false, ${meta}::jsonb, ${policy}::jsonb, now(), now()+ false, false, ${meta}::jsonb, ${policy}::jsonb, now(), now())returning id`;diff --git a/tests/api/agents-internal-visibility.test.js b/tests/api/agents-internal-visibility.test.jsnew file mode 100644index 000000000..74afbdb3a--- /dev/null+++ b/tests/api/agents-internal-visibility.test.js@@ -0,0 +1,109 @@+// Platform-internal agents never reach a public discovery surface.+//+// An agent the platform creates for its own plumbing (the marketplace chat bot's+// AI-budget meter, owned by a service account and never published) inherits+// is_public = true from the column default. On 2026-10-01 that put it on+// /api/agents/public and ranked it #1 on /api/trending off the bot's own traffic,+// with a description that says "Not a public agent". The rule both endpoints now+// apply is "published, or owned by a person", expressed against users.service_account+// rather than any agent id, so the next internal agent is covered too.+//+// This renders every agent query each endpoint runs (all sorts, both windows, the+// live wall's header totals) and asserts the rule is in each one.++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, limit: 60, remaining: 59, reset: Date.now() + 60_000 }) },+ clientIp: () => '127.0.0.1',+}));+vi.mock('../../api/_lib/r2.js', () => ({+ thumbnailUrl: (key) => `https://cdn.example/${key}`,+ publicUrl: (key) => `https://cdn.example/${key}`,+}));+vi.mock('../../api/_lib/trust/wallet-reputation.js', () => ({ scoreAgentsLite: async () => new Map() }));++const calls = [];+vi.mock('../../api/_lib/db.js', () => ({+ sql: Object.assign(+ (strings, ...values) => {+ calls.push(strings.join(' ? '));+ return Promise.resolve([]);+ },+ { transaction: async () => [] },+ ),+ isDbUnavailableError: () => false,+ isDbCapacityError: () => false,+}));++const { default: publicAgents } = await import('../../api/agents/public.js');+const { default: trending } = await import('../../api/trending.js');++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 call(handler, url) {+ const res = makeRes();+ await handler({ method: 'GET', url, headers: { host: 'three.ws', origin: 'https://three.ws' } }, res);+ return res;+}++// Whitespace-insensitive, so the assertion pins the rule and not its indentation.+const squash = (s) => s.replace(/\s+/g, ' ');+const INTERNAL_RULE =+ /not \(i\.is_published is not true and exists \( select 1 from users su where su\.id = i\.user_id and su\.service_account \)\)/;++function agentQueries() {+ return calls.map(squash).filter((q) => /from agent_identities i|join agent_identities i/.test(q));+}++beforeEach(() => {+ calls.length = 0;+});++describe('internal agents stay off public listings', () => {+ for (const sort of ['popular', 'newest', 'name', 'live']) {+ it(`/api/agents/public?sort=${sort} applies the rule to every agent query`, async () => {+ const res = await call(publicAgents, `/api/agents/public?sort=${sort}`);+ expect(res.statusCode).toBe(200);+ const queries = agentQueries();+ // The live sort also runs its header-totals query on the first page.+ expect(queries.length).toBe(sort === 'live' ? 2 : 1);+ for (const q of queries) expect(q).toMatch(INTERNAL_RULE);+ });+ }++ for (const win of ['24h', '7d', 'all']) {+ it(`/api/trending?window=${win} applies the rule to the agent ranking`, async () => {+ const res = await call(trending, `/api/trending?window=${win}`);+ expect(res.statusCode).toBe(200);+ const queries = agentQueries();+ expect(queries.length).toBe(1);+ expect(queries[0]).toMatch(INTERNAL_RULE);+ });+ }++ it('keys the rule on ownership and publication, never on a specific agent id', async () => {+ await call(publicAgents, '/api/agents/public');+ await call(trending, '/api/trending');+ for (const q of agentQueries()) {+ expect(q).not.toMatch(/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/);+ expect(q).not.toMatch(/llm-gateway-meter/);+ }+ });+});