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(tournaments): keep the store and index routes in step with the action dispatcher
nirholas7307eff55ea6
diff --git a/api/_lib/tournament-store.js b/api/_lib/tournament-store.jsindex 87a6519cb..5c14fbdf8 100644--- a/api/_lib/tournament-store.js+++ b/api/_lib/tournament-store.js@@ -182,9 +182,15 @@ export async function getEntry(tournamentId, agentId) {}/**- * Join a tournament. Idempotent on (tournament_id, agent_id): a re-join returns the- * existing row untouched (the original baseline snapshot stands). Stores the+ * Join a tournament. Idempotent on (tournament_id, agent_id): a re-join keeps the+ * original baseline snapshot and joined_at (scoring is scoped by the tournament+ * window, not by entry time, so the first entry is the honest record). Stores the* join-time wallet + all-time metrics snapshot so window scoping is auditable.+ *+ * An entry that was WITHDRAWN is flipped back to active, because the alternative is+ * worse than a rejection: the insert conflicts, the handler answers `joined: true`+ * off the stale row, the UI congratulates the user, and the agent sits out the whole+ * tournament. A disqualified entry is never revived this way.*/export async function joinTournament({ tournamentId, agentId, wallet, snapshot }) {await ensureTournamentTables();@@ -195,6 +201,13 @@ export async function joinTournament({ tournamentId, agentId, wallet, snapshot }returning *`;if (row) return { entry: row, created: true };+ const [rejoined] = await sql`+ update tournament_entries+ set status = 'active', wallet = coalesce(${wallet ?? null}, wallet), updated_at = now()+ where tournament_id = ${tournamentId} and agent_id = ${agentId} and status = 'withdrawn'+ returning *+ `;+ if (rejoined) return { entry: rejoined, created: false };const existing = await getEntry(tournamentId, agentId);return { entry: existing, created: false };}diff --git a/api/tournaments/[id].js b/api/tournaments/[id].jsindex e1655fc58..a370c6e97 100644--- a/api/tournaments/[id].js+++ b/api/tournaments/[id].js@@ -1,5 +1,5 @@/**- * Social Trading Arena — single-tournament endpoint + sub-routes.+ * Social Trading Arena: single-tournament endpoint + sub-routes.** GET /api/tournaments/:id → state + live standings + prize + attestation* GET /api/tournaments/:id/stream → SSE live rank changes@@ -158,7 +158,7 @@ async function handleJoin(req, res, id) {if (!tournament) return error(res, 404, 'not_found', 'tournament not found');const status = derivedStatus(tournament, Date.now());if (['ended', 'closed', 'settled', 'cancelled'].includes(status)) {- return error(res, 409, 'closed', 'this tournament has ended — entries are closed');+ return error(res, 409, 'closed', 'this tournament has ended, entries are closed');}// Ownership check.@@ -193,7 +193,10 @@ async function handleJoin(req, res, id) {}const { entry, created } = await joinTournament({ tournamentId: id, agentId, wallet, snapshot });- if (!entry) return error(res, 500, 'join_failed', 'could not record the entry — try again');+ if (!entry) return error(res, 500, 'join_failed', 'could not record the entry, try again');+ if (entry.status === 'disqualified') {+ return error(res, 409, 'disqualified', 'that agent was disqualified from this tournament and cannot re-enter');+ }return json(res,diff --git a/api/tournaments/index.js b/api/tournaments/index.jsindex 1a53ebeb3..23edd465d 100644--- a/api/tournaments/index.js+++ b/api/tournaments/index.js@@ -1,5 +1,5 @@/**- * Social Trading Arena — tournament collection endpoint.+ * Social Trading Arena: tournament collection endpoint.** GET /api/tournaments?network=mainnet&phase=live → list (public)* POST /api/tournaments → create (auth required)@@ -143,7 +143,7 @@ export default wrap(async (req, res) => {);}- // POST — create+ // POST: createconst rl = await limits.mcpIp(clientIp(req));if (!rl.success) return rateLimited(res, rl);