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: update agent fetching logic and enhance UI for agent selection

nirholas5c4b504c3735
diff --git a/api/marketplace/[action].js b/api/marketplace/[action].js
index 110b07920..e4231672b 100644
--- a/api/marketplace/[action].js
+++ b/api/marketplace/[action].js
@@ -18,6 +18,7 @@
import { sql } from '../_lib/db.js';
import { authenticateBearer, extractBearer, getSessionUser } from '../_lib/auth.js';
import { cors, error, json, method, readJson, wrap } from '../_lib/http.js';
+import { publicUrl } from '../_lib/r2.js';
import { clientIp, limits } from '../_lib/rate-limit.js';
const UUID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
@@ -135,17 +136,19 @@ async function handleList(req, res, url) {
const qLike = q ? `%${q}%` : null;
const rows = await sql`
- SELECT id, name, description, category, tags, avatar_id, user_id,
- forks_count, views_count, published_at, created_at, skills
- FROM agent_identities
- WHERE is_published = true
- AND deleted_at IS NULL
- AND (${cat}::text IS NULL OR category = ${cat})
+ SELECT ai.id, ai.name, ai.description, ai.category, ai.tags, ai.avatar_id, ai.user_id,
+ ai.forks_count, ai.views_count, ai.published_at, ai.created_at, ai.skills,
+ av.thumbnail_key
+ FROM agent_identities ai
+ LEFT JOIN avatars av ON av.id = ai.avatar_id AND av.deleted_at IS NULL
+ WHERE ai.is_published = true
+ AND ai.deleted_at IS NULL
+ AND (${cat}::text IS NULL OR ai.category = ${cat})
AND (
${qLike}::text IS NULL
- OR name ILIKE ${qLike}
- OR description ILIKE ${qLike}
- OR EXISTS (SELECT 1 FROM unnest(tags) t WHERE t ILIKE ${qLike})
+ OR ai.name ILIKE ${qLike}
+ OR ai.description ILIKE ${qLike}
+ OR EXISTS (SELECT 1 FROM unnest(ai.tags) t WHERE t ILIKE ${qLike})
)
ORDER BY ${orderBy}
LIMIT ${limit + 1} OFFSET ${offset}
@@ -235,18 +238,20 @@ async function handleSimilar(req, res, id) {
if (!base) return error(res, 404, 'not_found', 'agent not found');
const rows = await sql`
- SELECT id, name, description, category, tags, avatar_id, user_id,
- forks_count, views_count, published_at, created_at, skills,
+ SELECT ai.id, ai.name, ai.description, ai.category, ai.tags, ai.avatar_id, ai.user_id,
+ ai.forks_count, ai.views_count, ai.published_at, ai.created_at, ai.skills,
+ av.thumbnail_key,
(
- (CASE WHEN category = ${base.category} THEN 3 ELSE 0 END)
- + cardinality(ARRAY(SELECT unnest(tags) INTERSECT SELECT unnest(${base.tags}::text[])))
- + similarity(name, ${base.name})
- + similarity(coalesce(description,''), ${base.description || ''}) * 0.5
+ (CASE WHEN ai.category = ${base.category} THEN 3 ELSE 0 END)
+ + cardinality(ARRAY(SELECT unnest(ai.tags) INTERSECT SELECT unnest(${base.tags}::text[])))
+ + similarity(ai.name, ${base.name})
+ + similarity(coalesce(ai.description,''), ${base.description || ''}) * 0.5
) AS score
- FROM agent_identities
- WHERE is_published = true
- AND deleted_at IS NULL
- AND id <> ${id}
+ FROM agent_identities ai
+ LEFT JOIN avatars av ON av.id = ai.avatar_id AND av.deleted_at IS NULL
+ WHERE ai.is_published = true
+ AND ai.deleted_at IS NULL
+ AND ai.id <> ${id}
ORDER BY score DESC
LIMIT 8
`;
@@ -423,6 +428,7 @@ function toCard(row) {
category: row.category,
tags: row.tags || [],
avatar_id: row.avatar_id,
+ thumbnail_url: row.thumbnail_key ? publicUrl(row.thumbnail_key) : null,
author_id: row.user_id,
skills: row.skills || [],
forks_count: row.forks_count || 0,
diff --git a/chat/src/AgentPicker.svelte b/chat/src/AgentPicker.svelte
index 2af9c4a13..f57afd6c6 100644
--- a/chat/src/AgentPicker.svelte
+++ b/chat/src/AgentPicker.svelte
@@ -16,7 +16,7 @@
const res = await fetch(url);
if (res.ok) {
const json = await res.json();
- agents = json.data?.agents ?? [];
+ agents = json.data?.items ?? [];
}
} catch {}
loading = false;
@@ -69,27 +69,32 @@
{/if}
{#if loading}
- <p class="text-center text-[12px] text-slate-400">Loading…</p>
+ <p class="text-center text-[12px] text-slate-400 py-4">Loading…</p>
{:else if agents.length === 0}
- <p class="text-center text-[12px] text-slate-400">No agents found</p>
+ <p class="text-center text-[12px] text-slate-400 py-4">No agents found</p>
{:else}
- <div class="flex max-h-64 flex-col gap-1 overflow-y-auto">
+ <div class="grid grid-cols-3 gap-2 max-h-72 overflow-y-auto pr-0.5">
{#each agents as agent}
<button
- class="flex items-center gap-3 rounded-lg px-2 py-2 text-left transition hover:bg-gray-50
- {$localAgentId === agent.id ? 'bg-indigo-50 ring-1 ring-indigo-200' : ''}"
+ class="flex flex-col items-center gap-1.5 rounded-xl p-2 text-center transition hover:bg-gray-50
+ {$localAgentId === agent.id ? 'bg-indigo-50 ring-2 ring-indigo-300' : 'ring-1 ring-gray-100'}"
on:click={() => pick(agent)}
+ title={agent.description || agent.name}
>
- <div
- class="flex h-9 w-9 flex-shrink-0 items-center justify-center rounded-full text-[11px] font-bold text-white"
- style="background:{color(agent.id)}"
- >{initials(agent.name)}</div>
- <div class="min-w-0">
- <p class="truncate text-[13px] font-medium text-slate-800">{agent.name}</p>
- {#if agent.description}
- <p class="truncate text-[11px] text-slate-500">{agent.description}</p>
- {/if}
- </div>
+ {#if agent.thumbnail_url}
+ <img
+ src={agent.thumbnail_url}
+ alt={agent.name}
+ class="h-14 w-14 rounded-lg object-cover"
+ loading="lazy"
+ />
+ {:else}
+ <div
+ class="flex h-14 w-14 items-center justify-center rounded-lg text-[14px] font-bold text-white"
+ style="background:{color(agent.id)}"
+ >{initials(agent.name)}</div>
+ {/if}
+ <p class="w-full truncate text-[11px] font-medium text-slate-700 leading-tight">{agent.name}</p>
</button>
{/each}
</div>