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(agent-task): authorize against agent_identities, the table that actually exists

nirholas1c91d9a6f9e0
diff --git a/api/agent-task.js b/api/agent-task.js
index 44231e8e4..b54080e71 100644
--- a/api/agent-task.js
+++ b/api/agent-task.js
@@ -45,9 +45,13 @@ export default async function handleAgentTask(req, res) {
const agentId = (new URL(req.url, `http://${req.headers.host || 'x'}`).searchParams.get('agentId') || '').trim();
if (!agentId) return error(res, 400, 'missing_agent_id', 'agentId required');
- // Verify the polling identity owns this agent
+ // Verify the polling identity owns this agent. Agents live in
+ // agent_identities, the same table agent-screen-push.js authorizes
+ // against; there is no `agents` table.
const [agentRow] = await sql`
- SELECT id FROM agents WHERE id = ${agentId} AND user_id = ${userId} LIMIT 1
+ SELECT id FROM agent_identities
+ WHERE id = ${agentId} AND user_id = ${userId} AND deleted_at IS NULL
+ LIMIT 1
`;
if (!agentRow) return error(res, 403, 'forbidden', 'agent not owned by this user');
@@ -93,7 +97,9 @@ export default async function handleAgentTask(req, res) {
// Verify ownership
const [agentRow] = await sql`
- SELECT id, name FROM agents WHERE id = ${agentId} AND user_id = ${userId} LIMIT 1
+ SELECT id, name FROM agent_identities
+ WHERE id = ${agentId} AND user_id = ${userId} AND deleted_at IS NULL
+ LIMIT 1
`;
if (!agentRow) return error(res, 403, 'forbidden', 'agent not owned by this user');