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: harden wallet auth foundation for agent reliability
nirholasddaf3fdf1829
diff --git a/CLAUDE.md b/CLAUDE.mdindex b40112650..bb70d8717 100644--- a/CLAUDE.md+++ b/CLAUDE.md@@ -4,6 +4,27 @@ Root guidance for agents working in this repo. Read this first. Then read the sc---+## Current state (updated 2026-04-17) — read this before touching anything++**Working directory:** `/workspaces/3D-Agent`. All prompt files say `Repo: /workspaces/3D` — that path is stale. Use the actual working directory. Do not "fix" the prompts as part of an implementation task.++**What's done:**+- `api/auth/siwe/verify.js` — SIWE verify endpoint complete, VERCEL_URL preview-deploy support added (committed).+- `api/agents.js` — `/api/agents/me` 500 hardened: all errors caught, `[agents/me]` log prefix, `42P01` fallback. Race on concurrent first-agent insert is fixed via `ON CONFLICT DO NOTHING` + re-select.+- `api/_lib/schema.sql` — unique partial index `agent_identities_user_unique` on `(user_id) where deleted_at is null` added.++**What's in-flight / broken:**+- Band 1 (wallet auth) is the active band. Do not start band 2+ tasks.+- Next task: `prompts/wallet-auth/04-connect-wallet-button.md` — shared "Connect wallet" component. Depends on verify + agents/me being green (they are).++**Quick rules for agents starting a task:**+1. Run `node --check` on every JS file you touch.+2. Run `npm run build` before reporting done.+3. Don't fix bugs outside the task scope — note them in your report.+4. Don't create new top-level markdown files.++---+## How to work here1. **Move on your own.** You have broad permissions (see [.claude/settings.json](.claude/settings.json)). Don't ask before running builds, tests, formatters, git commits, or reads — just do them. Ask only before destructive ops, on-chain broadcasts, or production deploys.diff --git a/api/_lib/schema.sql b/api/_lib/schema.sqlindex f7a75dedc..57d3ae0d5 100644--- a/api/_lib/schema.sql+++ b/api/_lib/schema.sql@@ -257,6 +257,8 @@ create table if not exists agent_identities (create index if not exists agent_identities_useron agent_identities(user_id) where deleted_at is null;+create unique index if not exists agent_identities_user_unique+ on agent_identities(user_id) where deleted_at is null;create index if not exists agent_identities_walleton agent_identities(wallet_address) where wallet_address is not null;diff --git a/api/agents.js b/api/agents.jsindex 7e6986977..59893a11f 100644--- a/api/agents.js+++ b/api/agents.js@@ -80,7 +80,7 @@ async function handleGetOrCreateMe(req, res, auth) {if (!agent) {const wallet = await generateAgentWallet();- [agent] = await sql`+ await sql`INSERT INTO agent_identities (user_id, name, skills, wallet_address, meta)VALUES (${auth.userId},@@ -89,7 +89,13 @@ async function handleGetOrCreateMe(req, res, auth) {${wallet.address},${JSON.stringify({ encrypted_wallet_key: wallet.encrypted_key })}::jsonb)- RETURNING *+ ON CONFLICT (user_id) WHERE deleted_at IS NULL DO NOTHING+ `;+ // Re-select covers both: we inserted, or a concurrent request beat us.+ [agent] = await sql`+ SELECT * FROM agent_identities+ WHERE user_id = ${auth.userId} AND deleted_at IS NULL+ ORDER BY created_at ASC LIMIT 1`;}