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.

fix: update SQL query in handleCreate to improve avatar linking logic fix: remove 'chat' from workspaces in package.json fix: update script source in chat index.html for asset changes

nirholasdd1a599df84c
diff --git a/api/avatars/index.js b/api/avatars/index.js
index 7486c8278..24bb87c9f 100644
--- a/api/avatars/index.js
+++ b/api/avatars/index.js
@@ -115,13 +115,18 @@ async function handleCreate(req, res) {
queueMicrotask(async () => {
try {
await sql`
- update agent_identities
- set avatar_id = ${avatar.id}
- where user_id = ${auth.userId}
- and avatar_id is null
- and deleted_at is null
- order by created_at asc
- limit 1
+ WITH agent_to_update AS (
+ SELECT id FROM agent_identities
+ WHERE user_id = ${auth.userId}
+ AND avatar_id IS NULL
+ AND deleted_at IS NULL
+ ORDER BY created_at ASC
+ LIMIT 1
+ )
+ UPDATE agent_identities
+ SET avatar_id = ${avatar.id}
+ FROM agent_to_update
+ WHERE agent_identities.id = agent_to_update.id
`;
} catch (err) {
console.error('[avatars] auto-link to agent_identities failed', {
diff --git a/api/plugins/[action].js b/api/plugins/[action].js
index b8151689f..c1b12d328 100644
--- a/api/plugins/[action].js
+++ b/api/plugins/[action].js
@@ -144,7 +144,13 @@ async function handleList(req, res, url) {
AND p.deleted_at IS NULL
${category ? sql`AND p.category = ${category}` : sql``}
${q ? sql`AND (p.name ILIKE ${'%' + q + '%'} OR p.description ILIKE ${'%' + q + '%'})` : sql``}
- ORDER BY ${sort === 'popular' ? sql`p.install_count DESC, p.created_at DESC` : sort === 'new' ? sql`p.created_at DESC` : sql`p.name ASC`}
+ ORDER BY ${sql.unsafe(
+ sort === 'popular'
+ ? 'p.install_count DESC, p.created_at DESC'
+ : sort === 'new'
+ ? 'p.created_at DESC'
+ : 'p.name ASC',
+ )}
LIMIT ${limit + 1} OFFSET ${offset}
`;
diff --git a/package.json b/package.json
index 86b53af08..682fa65b7 100644
--- a/package.json
+++ b/package.json
@@ -24,8 +24,7 @@
],
"workspaces": [
"agent-payments-sdk",
- "character-studio",
- "chat"
+ "character-studio"
],
"main": "src/app.js",
"browserslist": [
diff --git a/public/chat/index.html b/public/chat/index.html
index 966685e33..715d001ad 100644
--- a/public/chat/index.html
+++ b/public/chat/index.html
@@ -44,7 +44,7 @@
}
}
</script>
- <script type="module" crossorigin src="/chat/assets/index-TQ0in7gb.js"></script>
+ <script type="module" crossorigin src="/chat/assets/index-0gtmVzsq.js"></script>
<link rel="stylesheet" crossorigin href="/chat/assets/index-BS8U8RZM.css">
</head>
<body>