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.

Implement feature X to enhance user experience and optimize performance

udvk653737f03d0d
diff --git a/ARCHITECTURE.md b/ARCHITECTURE.md
index ca4077102..ef2b19f68 100644
--- a/ARCHITECTURE.md
+++ b/ARCHITECTURE.md
@@ -37,7 +37,7 @@ graph TD
Lib["api/_lib/ — 413 shared utilities\ndb.js · auth.js · redis.js · r2.js · x402-spec.js · memory-store.js"]
end
- APILayer --> Neon["Neon Postgres\n(primary DB)\npgvector · 160+ tables"]
+ APILayer --> Neon["Neon Postgres\n(primary DB)\npgvector · ~260 tables"]
APILayer --> Redis["Upstash Redis REST\n(rate limit + cache)"]
APILayer --> R2["Cloudflare R2\nGLBs · Audio · Thumbnails · Metadata"]
APILayer --> MCPSvc["MCP Servers — 8 remote endpoints\n/api/mcp · /api/mcp-3d\n/api/pump-fun-mcp · /api/ibm-mcp · + 4 more"]
@@ -855,6 +855,17 @@ Full 52-blendshape ARKit vocabulary with cross-format mapping. Falls back to jaw
MediaPipe Pose Landmarker → 33 world landmarks → `pose-solve.js` → per-bone quaternion deltas → damped slerp → canonical bone names via `glb-canonicalize` → `bone.quaternion`.
+### Face Mocap & Selfie Capture
+
+- **`src/avatar-face-capture.js`** — selfie → 52 ARKit blendshape weights + face-shape transfer via MediaPipe Face Landmarker (478 landmarks).
+- **`src/face-mocap-overlay.js`** — live 478-landmark + tessellation-mesh + iris/lip/eye/brow debug overlay over the webcam PiP.
+- **`src/avatar-wardrobe.js`** — layered garment editor exploiting the multi-skinned-mesh-on-one-skeleton structure of RPM/Avaturn/Wolf3D exports.
+- **`src/avatar-sculpt.js`** — face/body morph sliders + face-type blend wheel driving the 52 ARKit blendshapes by name plus RPM body-shape morphs.
+
+### Mixamo R2 Animation Catalog
+
+Beyond the ~100 baked canonical clips, `public/animations/mixamo/` indexes a **2,453-entry** on-demand library streamed from Cloudflare R2: `index.json` (Mixamo asset ID → R2 keys + byte sizes), `name-map.json` (UUID → human name), `catalog.json`, `hf-manifest.json`. Curation/preset layer: `src/animation-presets.js` (categories + featured set) and `src/animation-library.js` (`/pose` gallery: click-to-retarget, transport bar, export animated GLB). Bind-pose data: `src/animation-canonical-rest.js` (`CANONICAL_REST`/`_WORLD` from `cz.glb`, generated by `scripts/build-canonical-rest.mjs`).
+
### Animated USDZ Export (`src/usdz-animated.js`)
Bakes skinned mesh vertex positions at N keyframes, surgically rewrites `USDZExporter` ZIP output to add time-sampled point arrays. Fallback to static USDZ on failure. Enables iOS AR Quick Look animated avatars.
@@ -1151,13 +1162,15 @@ Platform registers agent identities as `*.threews.sol` subdomains:
### Vanity Wallet Protocol
-**Path:** `src/solana/vanity/`
+**Solana — `src/solana/vanity/`** (WASM core compiled from `crates/vanity-grinder`):
+
+- Browser-side WASM-accelerated grinder (~25k keypairs/sec single-threaded, fanned across cores via a Web Worker pool); pure-JS Ed25519 fallback; `grindViaApi()` hosted lane for short patterns.
+- Proof-of-grind Ed25519 certificates published at `/.well-known/three-vanity.json` (`proof-of-grind.js`, `verifiable-grind.js`).
+- Split-key (server-side non-custody) and sealed-envelope delivery (`sealed-envelope.js`).
+- BIP-39 mnemonic grinder.
+- **Three economic protocols** (versioned, isomorphic): grind-bounty market (`bounty-protocol.js` — `three-vanity-bounty/v1`, x402-escrowed, sealed-envelope payout against an X25519 recipient key, honest difficulty-pricing oracle), sealed wallet drops (`drop-protocol.js` — `three-drop/...`, bearer-token `#k=` fragment claim), and a grind-to-earn mining pool (`pool-protocol.js` — `three-grind-pool/v1`, share-difficulty accounting, 60% winner bonus). API side: `api/vanity/*` (bounties/cert/gallery/drops/og) + `api/x402/vanity-verifiable.js`.
-- Browser-side WASM-accelerated grinder
-- Proof-of-grind Ed25519 certificates published at `/.well-known/three-vanity.json`
-- Split-key (server-side non-custody) and sealed-envelope delivery
-- BIP-39 mnemonic grinder
-- Bounty protocol on-chain
+**EVM — `src/eth/vanity/`** (parallel grinder, surfaced at `/eth-vanity`): EOA grinder (`eoa-grinder.js` + worker), CREATE2 contract-address grinder (`grinder.js` + `grinder-worker.js`), multi-chain factory awareness (`chains.js`), `validation.js`, `wordlist.js`, card UI `src/agent-eth-vanity-card.js`. Knows four cross-chain deployer/factory addresses: Arachnid proxy `0x4e59b448…`, CreateX `0xba5ed099…`, Safe Singleton Factory `0x4e1dcf7a…`, Coinbase Smart Wallet factory `0x0ba5ed0c…`.
---
@@ -1267,6 +1280,13 @@ flowchart TD
**Withdrawal:** `POST /api/billing/withdrawals` → `agent_withdrawals` row (pending) → async off-chain worker executes on-chain transfer to payout wallet from `agent_payout_wallets`.
+**Fee ceilings & multi-recipient splits** (beyond the single platform fee above):
+- `api/_lib/marketplace-platform-fee.js` — `MARKETPLACE_PLATFORM_FEE_BPS` default 0, **max `MAX_FEE_BPS=1000` (10%)**; recipient `MARKETPLACE_PLATFORM_FEE_WALLET` (falls back to `PLATFORM_TREASURY_KEYPAIR`/`TREASURY_KEYPAIR`); fee comes out of listed price (creator gets price − fee).
+- `api/_lib/pump-platform-fee.js` — separate `PUMP_PLATFORM_FEE_BPS` default 0, **max 500 (5%)**, recipient `PUMP_PLATFORM_FEE_WALLET`.
+- **Listing splits** — tables `listing_splits`, `listing_split_recipients`, `split_distributions` (migration `20260628090000_marketplace_splits.sql`) for multi-party revenue routing.
+- **Fork royalties** — `api/_lib/fork-royalties.js`: `ROYALTY_PER_CREATOR_CAP_BPS=1000`, `ROYALTY_TOTAL_CAP_BPS=2000`, `MIN_FORKER_KEEP_BPS=8000`.
+- **Cosmetics economy** — `api/_lib/cosmetics-economy.js`: `DEFAULT_CREATOR_BPS=5000`, `MAX_CREATOR_BPS=9000` (creator-split item economy behind `api/cosmetics/*` + `api/x402/cosmetic-purchase.js`).
+
---
### Merchant Console
@@ -1285,9 +1305,25 @@ Any user can become a merchant:
### Subscription & DCA
-- **Subscriptions:** `api/subscriptions/` — Stripe-backed plans, `agent_delegations` + `agent_subscriptions` tables
-- **DCA Strategies:** `api/dca-strategies.js` — dollar-cost-averaging on whitelisted tokens; executed by `cron/run-dca` worker
-- **Copy Trading:** `api/copy/` — `@three-ws/copy-mcp` + `@three-ws/strategies`
+- **Subscriptions:** `api/subscriptions.js` (delegation-based recurring records) + `api/subscriptions/{subscribe,verify}.js` (USDC checkout with gasless fee-payer, atomic creator/treasury split). Libs `api/_lib/{subscription-pricing,subscription-checkout,subscription-billing}.js`. Tables `subscription_plans`, `subscription_plan_skills`, `subscription_checkouts`, `user_agent_subscriptions`, `agent_subscriptions`, `agent_delegations`. Cron `run-subscriptions`. Also `api/copy/subscriptions.js`.
+- **DCA Strategies:** `api/dca-strategies.js` — dollar-cost-averaging on whitelisted tokens (`DCA_ALLOWED_TOKEN_OUT`, `DCA_CHAIN_ID`); executed by `api/cron/run-dca.js`. Tables `dca_strategies`, `dca_executions`.
+- **Copy / Mirror Trading:** `api/copy/` (5 endpoints) + `api/mirror/` — `@three-ws/copy-mcp` + `@three-ws/strategies`; fanned out by `cron/{copy,mirror,signal,strategy}-fanout`.
+
+---
+
+### Spending Guardrails (autonomous-agent safety chokepoint)
+
+Every outbound agent payment passes a spend-control layer:
+
+- **Trade guards** — `api/_lib/agent-trade-guards.js`: single policy governing withdraw / x402-pay / snipe / trade via `meta.spend_limits` (`daily_usd`, `per_tx_usd`, `withdraw_allowlist`). Shipped as `@three-ws/agent-guards`.
+- **Solana spend policy** — `api/_lib/agent-spend-policy.js`: `meta.spend_policy` (`max_sol_per_tx`, `daily_sol_cap`, `allowed_mints`), compiled via `spend-policy-compiler.js` + `spend-policy-rules.js`.
+- **Buyer-side x402 caps** — `api/_lib/x402-spending-cap.js` + `x402-spending-ledger.js` + `x402-spending-price.js`: per-call + sliding-window USDC caps via SDK lifecycle hooks. Env `X402_MAX_PER_CALL_ATOMIC`.
+
+### x402 Protocol Subpackage (`api/_lib/x402/`)
+
+15 modules implementing x402 v2 transports/extensions: `a2a-client`/`a2a-server`, `access-control`, `api-keys`, `audit-log`, `auth-hints`, `bazaar-client`/`bazaar-helpers`, `idempotency-cache`, `offer-receipt-issuer`/`offer-receipt-server`, `payment-identifier-client`/`payment-identifier-server`, `paywall-handler`, `receipt-storage`. (`x402-buildout/` is the 41-prompt spec-driven build plan behind these — build docs, not runtime code.)
+
+**Two coexisting 402 protocols:** (1) CDP/PayAI x402 **v2 wire spec** in `api/_lib/x402-spec.js` (CAIP-2 networks, `X-PAYMENT`/`X-PAYMENT-RESPONSE` base64 envelopes, facilitator `/verify`+`/settle`, schemes `exact`/`direct`, Permit2/EIP-2612). (2) Pump **agent-skill 402** in `api/_lib/x402.js` (`version:"x402/0.1"`, `kind:"agent-skill"`, `x-payment-intent` retry header). Solana settles in **USDC or $THREE** (opt-in `X402_ACCEPT_THREE_SOLANA=true`).
---
@@ -1375,12 +1411,16 @@ flowchart TD
AUD["Audio"] -->|"POST /api/asr"| RIV["NVIDIA Riva gRPC"]
RIV --> TXT2["transcript text"]
- IMG["Image"] -->|"POST /api/vision"| VLM["NVIDIA NIM\nNemotron-nano-12B-v2-VL"]
+ IMG["Image"] -->|"POST /api/vision"| VLM["NVIDIA NIM\nnvidia/nemotron-nano-12b-v2-vl"]
+ VLM -->|"lane 2"| VLM2["meta/llama-3.2-11b-vision-instruct"]
VLM --> DESC["description"]
- VLM -->|"backstop"| MINI["OpenAI gpt-4o-mini"]
+ VLM2 --> DESC
+ VLM2 -->|"backstop"| MINI["OpenAI gpt-4o-mini"]
MINI --> DESC
```
+**TTS backends** (`api/tts/`): primary NVIDIA Magpie gRPC (`tts-nvidia.js`) + **ElevenLabs** (`eleven.js`, `eleven-clone.js` voice cloning, `eleven_flash_v2_5`, R2-cached) + **Microsoft Edge TTS** (`edge.js`, WebSocket, R2-cached) + OpenAI backstop. Router `tts/speak.js`, catalog `tts/voices.js`. ASR = NVIDIA Riva gRPC (`asr-nvidia.js`); A2F = NVIDIA Audio2Face-3D gRPC (`a2f-nvidia.js`). All NVIDIA lanes share `NVIDIA_API_KEY` (nvapi). Content safety = IBM Granite Guardian (`api/guardian/assess.js`) + NVIDIA NemoGuard.
+
---
### Long-Running Workers
@@ -1563,7 +1603,17 @@ Every pump.fun coin is an enterable 3D world. `@coin-communities/sdk/node` provi
#### Agora — Agent & Human Economy (`api/agora/[action].js`)
-AgenC on-chain task marketplace overlaid with a 3D city world. Agents and humans register, claim/complete tasks, earn $THREE. Tables: `agora_citizens`, `agora_activity`. Full MCP: `@three-ws/agora-mcp`.
+AgenC on-chain task marketplace overlaid with a 3D city world. Agents and humans register, claim/complete tasks, earn $THREE. The `[action]` router exposes 4 GET reads (`citizens`, `board`, `pulse`, `passport`); the agent-action/task-execution write path lives in `api/agora/act.js`. Tables: `agora_citizens`, `agora_activity`, `agora_vouches`, `agora_idempotency`. Full MCP: `@three-ws/agora-mcp`. The platform's live narrow-AGI cognitive state is exposed at `api/agi/state.js`.
+
+#### Creator-Fee & Social-Fee Sharing (`api/pump/[action].js`)
+
+Revenue routing to coin creators and GitHub contributors: `collect-creator-fee`, `distribute-creator-fees`, `create-fee-sharing`, `update-fee-shares`, `fee-info`, `create-social-fee-pda`, `social-fee-claim-status`, `resolve-github-shareholder`/`github-resolve` (prep/agent variants). Tables `pump_buyback_runs`, `pump_distribute_runs`.
+
+#### Coin Autopilot & Holder Cohorts
+
+- **`api/pump/autopilot.js`** — per-coin autonomous policy engine (`pump_autopilot` table) gating the `run-buyback` and `run-distribute-payments` crons; owner-tunable buyback/distribution automation.
+- **`api/coin/[mint]/cohorts.js`** — named holder audience slices (whales, etc.) backing `/go` bounty targeting, with creator-only paginated member export.
+- **`api/pump/intel-enrich.js`** (+ `api/_lib/pump-intel/enrich.js`) — funder-resolution pass lighting up the bubble-map (writes `pump_coin_wallets.funder` + funder-derived signals on `pump_coin_intel`).
#### $THREE Leaderboard (`api/leaderboard.js`)
@@ -1660,9 +1710,9 @@ three.ws/ (root package v1.5.2, Node 24.x)
**Driver:** `@neondatabase/serverless` HTTP driver (tagged-template `sql` with composable fragments)
-**Schema:** `api/_lib/schema.sql` — 160+ tables
+**Schema:** `api/_lib/schema.sql` — ~260 tables (full list in [Complete Database Table Inventory](#complete-database-table-inventory))
-**Migrations:** `api/_lib/migrations/` — 160+ dated migration files (2026-04-29 through 2026-06-29)
+**Migrations:** `api/_lib/migrations/` — 234 dated migration files (2026-04-29 through 2026-06-23)
Key table groups:
@@ -2206,6 +2256,176 @@ sequenceDiagram
---
+## Exhaustive Subsystem Reference
+
+This section enumerates the full internal surface area that the higher-level sections summarize — the complete `api/` feature tree, the `api/_lib/` utility layer, every `src/` subsystem, the agent-discovery files, and the public static apps.
+
+### API Feature Directory Index (`api/`)
+
+The serverless tree holds **146 feature directories + 115 top-level handler files**. Beyond the feature areas detailed under [API Endpoints by Feature Area](#api-endpoints-by-feature-area), the complete directory map is:
+
+| Group | `api/` directories |
+|-------|--------------------|
+| Identity & auth | `auth/` · `oauth/` · `users/` · `user/` · `api-keys/` · `keys/` · `permissions/` · `custody/` · `registry/` · `erc8004/` · `onboarding/` |
+| Agents & brain | `agents/` · `agent/` · `agent-3d/` · `agent-economy/` · `agent-trade/` · `autopilot/` · `genome/` · `dad/` · `persona/` · `brain/` · `memory/` · `seed/` · `agi/` |
+| Avatars & 3D | `avatar/` · `avatars/` · `animations/` · `mocap/` · `render/` · `scene/` · `studio/` · `studio-assets/` · `cz/` · `frames/` · `forever/` |
+| Pump.fun & markets | `pump/` · `pump-bounties/` · `oracle/` · `sniper/` · `signals/` · `intel/` · `aixbt/` · `kol/` · `traders/` · `trades/` · `trading/` · `insights/` · `portfolio/` · `token/` · `three-token/` · `launch/` · `launchpad/` |
+| Strategies & social trading | `mirror/` · `copy/` · `swarms/` · `vaults/` |
+| x402 & payments | `x402/` · `x402-pay/` · `pay/` · `payments/` · `bazaar/` · `ca2x402/` · `billing/` · `credits/` · `onramp/` · `purchase/` · `subscriptions/` · `monetization/` · `ledger/` · `tx/` · `usage/` |
+| Marketplace & assets | `marketplace/` · `creators/` · `skills/` · `plugins/` · `assets/` · `cosmetics/` · `rider/` · `referral/` |
+| Community & worlds | `agora/` · `agenc/` · `clash/` · `club/` · `community/` · `crews/` · `friends/` · `social/` · `stage/` · `play/` · `world/` · `galaxy/` · `irl/` · `share/` · `tournaments/` · `bounties/` · `labor/` |
+| MCP servers | `_mcp/` · `_mcp3d/` · `_mcp-studio/` · `_mcpagent/` · `_mcpbazaar/` · `_mcpibm/` · `_studio/` · `_providers/` |
+| AI / voice / LLM | `chat/` · `llm/` · `tts/` · `watsonx/` · `ibm/` · `guardian/` · `inference/` · `tutor/` |
+| Naming & on-chain | `threews/` · `three/` · `nft/` · `pinning/` · `reputation/` · `sdp/` |
+| Infra, SEO & ops | `cron/` · `sitemap/` · `rss/` · `og/` · `webhooks/` · `push/` · `notifications/` · `developer/` · `platform/` · `admin/` · `jobs/` · `embed/` · `widgets/` · `dashboard/` · `demo/` · `actions/` · `v1/` · `api/` |
+| Partner / distribution | `aws-marketplace/` · `lobehub/` · `chat-plugin/` |
+| Social (X) | `x/` |
+| Vanity | `vanity/` |
+
+### `api/_lib/` — Full Utility Catalog
+
+The shared library is **~370 modules + 19 subpackages**. Beyond the core modules already listed under [Core Utility Modules](#core-utility-modules-api_lib), they group as:
+
+| Domain | Representative modules |
+|--------|------------------------|
+| Auth & identity | `account-auth.js` · `account-tier.js` · `siwe.js` · `siws.js` · `siwx-server.js` · `siwx-storage.js` · `saml.js` · `privy.js` · `csrf.js` · `zauth.js` · `agent-identity.js` · `agent-registry.js` · `identity-integrity.js` · `agent-recovery.js` |
+| Wallet & custody | `agent-wallet.js` · `avatar-wallet.js` · `solana-wallet.js` · `agent-usdc-transfer.js` · `solana-transfer.js` · `evm-transfer.js` · `balances.js` · `custody-proof.js` · `wallet-anomaly.js` · `wallet-capabilities.js` · `wallet-intents.js` · `secret-box.js` · `crypto.js` · `resolve-recipient.js` |
+| x402 & payments | `x402.js` · `x402-spec.js` · `x402-paid-endpoint.js` · `x402-buyer-fetch.js` · `x402-buyer-axios.js` · `x402-user-payer.js` · `x402-bsc-direct.js` · `x402-solana-confirm.js` · `x402-spending-cap.js` · `x402-spending-ledger.js` · `x402-spending-price.js` · `x402-prices.js` · `x402-errors.js` · `x402-builder-code.js` · `evm-payment-verify.js` · `fee.js` · `splits.js` · `payout.js` · `credits.js` · `credit-deposit.js` · `metering.js` · `usage.js` · subdir `x402/` |
+| Agent runtime & economy | `agent-economy.js` · `agent-delegate.js` · `agent-spend-policy.js` · `spend-policy-compiler.js` · `spend-policy-rules.js` · `agent-trade-guards.js` · `agent-strategy-runtime.js` · `agent-paid-services.js` · `agent-pumpfun.js` · `agent-mirror.js` · `agent-labor.js` · `genome.js` · `genome-agent.js` · `networth-model.js` · `patronage.js` · `monetization.js` · `treasury-autopilot.js` · subdir `a2a/` |
+| Memory & AI | `memory-store.js` · `memory-entities.js` · `embeddings.js` · `embedding-math.js` · `agent-embeddings.js` · `chunker.js` · `rerank.js` · `reflection.js` · `brain-bundle.js` · `brain-anchor.js` · `brain-sign.js` · `llm.js` · `llm-health.js` · `llm-pricing.js` · `chat-models.js` · `provider-health.js` · `provider-keys.js` · `orchestrate.js` · `watsonx.js` · `watsonx-forecast.js` · `granite-guardian.js` · `moderation.js` · `vision.js` · `text-extract.js` · `strip-reasoning.js` · `reasoning-ledger.js` · `circulation.js` · `circulation-personas.js` · `persona-store.js` |
+| Voice & 3D media | `tts-nvidia.js` · `tts-voices.js` · `asr-nvidia.js` · `a2f-nvidia.js` · `elevenlabs.js` · `render-clip.js` · `render-glb.js` · `glb-compress.js` · `glb-inspect.js` · `glb-quality.js` · `glb-themer.js` · `bake.js` · `model-inspect.js` · `rig-inspect.js` · `auto-rig.js` · `auto-rig-eligibility.js` · `avatars.js` · `avatar-render.js` · `avatar-agent.js` · `avatar-alt-text.js` · `accessories.js` · `cosmetics.js` · `cosmetics-economy.js` · `cosmetics-ownership.js` · `avaturn-headless.js` · `avaturn-seed.js` · `fetch-model.js` · subdirs `a2f-protos/`, `riva-protos/` |
+| Forge (3D gen) | `forge-tiers.js` · `forge-options.js` · `forge-scale.js` · `forge-cache.js` · `forge-store.js` · `forge-events.js` · `forge-health.js` · `forge-lane-health.js` · `forge-image-validate.js` · `forge-job-token.js` · `forge-provider-key.js` · `forge-consumption-payment.js` · `forge-high-payment.js` · `regen-provider.js` · `reconstruct-finalize.js` |
+| Pump / market / oracle | `pump.js` · `pump-launch.js` · `pump-quote.js` · `pump-swap-ix.js` · `pump-trade-args.js` · `pump-pricing.js` · `pump-platform-fee.js` · `pump-vanity.js` · `pump-claims.js` · `pump-go.js` · `pump-alert-eval.js` · `pump-alert-runner.js` · `pump-launch-feed.js` · `pumpfun-ws-feed.js` · `pumpfun-mcp.js` · `smart-money.js` · `birdeye.js` · `gmgn-feed.js` · `helius.js` · `token-market.js` · `token-metadata.js` · `aixbt.js` · `trade-firewall.js` · `anomaly-events.js` · subdirs `pump-intel/`, `oracle/`, `sniper/`, `market/`, `coin/`, `token/` |
+| Strategy & trading engines | `strategy-backtest.js` · `strategy-compiler.js` · `strategy-schema.js` · `signal-engine.js` · `execution-engine.js` · `orders.js` · `market-maker.js` · `mirror-engine.js` · `mirror-stats.js` · `copy-engine.js` · `copy-earnings.js` · `swarms.js` · `syndicate.js` · `vault-store.js` · `vault-trade.js` · `vault-jupiter.js` · `vault-accounting.js` · `vault-wallet.js` · `vault-transfer.js` · `vault-auth.js` · subdirs `copy/`, `pricing/` |
+| Tournaments & games | `tournament-engine.js` · `tournament-scoring.js` · `tournament-settlement.js` · `tournament-store.js` · `tournament-attest.js` · `clash.js` · `clash-store.js` · `play-pass.js` · `bounty-judge.js` · `bounty-likes.js` |
+| Naming, attest & on-chain | `threews-sns.js` · `sas.js` · `solana-attestations.js` · `solana-collection.js` · `solana-signers.js` · `solana-token-meta.js` · `solana-validation-attest.js` · `attest-event.js` · `validation-attest.js` · `trader-score-attest.js` · `onchain.js` · `onchain-deploy.js` · `ledger-anchor.js` · `erc8004-chains.js` · `skill-license-issue.js` · `skill-license-onchain.js` · `skill-license-verify.js` · `skill-nft.js` · `nft-gate.js` · subdirs `solana/`, `evm/`, `trust/` |
+| Community / world / IRL | `agora-human.js` · `agora-policy.js` · `world-gate.js` · `world-store.js` · `world-lines.js` · `world-service-auth.js` · `coin-communities.js` · `holder-pass.js` · `stage-bridge.js` · `stage-split.js` · `galaxy.js` · `galaxy-flows.js` · `diorama-store.js` · `friends-store.js` · `presence-store.js` · `crews-store.js` · `builds-store.js` · `irl-auth.js` · `irl-bake.js` · `irl-drops.js` · `irl-presence.js` · `geohash.js` · subdir `club/` |
+| Vanity & sealed drops | `vanity-bounty-payout.js` · `vanity-bounty-store.js` · `vanity-cert-store.js` · `vanity-gallery-store.js` · `vanity-service-key.js` · `sealed-drop-funding.js` · `sealed-drop-store.js` |
+| Skills & marketplace | `skill-access.js` · `skill-runtime.js` · `skill-pricing-rules.js` · `skill-price-cache.js` · `marketplace-platform-fee.js` · `fork-royalties.js` · `remix-royalty.js` · `royalty.js` · `referrals.js` · `referral-rewards.js` |
+| Subscriptions & billing | `subscription-billing.js` · `subscription-checkout.js` · `subscription-pricing.js` · `aws-marketplace.js` · `aws-marketplace-bridge.js` |
+| $THREE & access gates | `three-access.js` · `three-gate.js` · `three-tier.js` · `three-brand.js` · `embed-policy.js` · `embed.js` |
+| Infra, storage & delivery | `db.js` · `db-retry.js` · `redis.js` · `redis-usage.js` · `cache.js` · `r2.js` · `storage-mode.js` · `qstash.js` · `ipfs-pin.js` · `sentry.js` · `axiom.js` · `email.js` · `newsletter.js` · `rss-feed.js` · `indexnow.js` · `web-push.js` · `webhook-dispatch.js` · `notify.js` · `notify-prefs.js` · `alert-delivery.js` · `alerts.js` · `gateway.js` · `resilience.js` · `sse-poll-breaker.js` · `rate-limit.js` · `ssrf.js` · `ssrf-guard.js` · `http.js` · `http-params.js` · `env.js` · `ids.js` · `pii.js` · `audit.js` · subdirs `services/`, `format/`, `migrations/` |
+
+**`api/_lib/` subpackages:** `a2a/` (agent-to-agent mandates + spend ledger) · `x402/` · `solana/` · `evm/` · `oracle/` · `sniper/` · `pump-intel/` · `coin/` · `token/` · `market/` · `pricing/` · `copy/` · `club/` · `trust/` · `services/` · `format/` · `a2f-protos/` + `riva-protos/` (NVIDIA gRPC protobufs) · `migrations/` (Neon SQL migrations).
+
+---
+
+### Frontend Subsystems (`src/`) — Complete Map
+
+Beyond the page controllers in the Surfaces tables, `src/` contains **62 subsystem directories**:
+
+| Subsystem dir | Role |
+|---------------|------|
+| `agent-wallet/` · `agent-wallet-hub/` | 19-tab Solana wallet hub + shared wallet logic |
+| `studio/` · `editor/` · `launchpad/` · `forge-studio/` | Agent studio, launchpad/embed editors |
+| `scene-studio/` | Vendored Three.js r184 scene editor |
+| `mission-control/` | Terminal / multi-SSE trading fusion |
+| `arena/` | Tournament arena |
+| `agora/` · `community/` · `social/` · `kol/` | Social + commons + KOL surfaces |
+| `city/` · `game/` · `play/` · `diorama/` | 3D worlds & game systems |
+| `constellation/` · `coin3d/` · `mint/` | Token-space visualizations + mint flows |
+| `irl/` · `ar/` | AR + real-world placement |
+| `voice/` | TTS/ASR/lipsync/A2F drivers |
+| `runtime/` | Runtime LLM brain + viseme lipsync |
+| `solana/` · `eth/` · `onchain/` · `erc7710/` · `erc8004/` · `attestations/` · `proof-of-custody/` · `arweave/` · `pinning/` | On-chain identity, attestations, decentralized storage |
+| `mirror/` · `pump/` | Copy/mirror trading + pump surfaces |
+| `memory/` | Mind-palace memory graph |
+| `dad/` | Agent personality / lineage helpers |
+| `dashboard/` · `dashboard-next/` | Legacy + next dashboard SPAs |
+| `viewer/` · `loaders/` · `three/` · `physics/` · `embodiment/` | Core 3D rendering, GLTF loaders, physics, embodiment |
+| `widget/` · `widgets/` · `components/` · `plugins/` | Embeddable widgets + web components |
+| `auth/` · `permissions/` | Auth UI + ERC-7710 permission flows |
+| `skills/` · `feature-tour/` · `glossary/` · `demo/` · `artifact/` · `proof/` · `sns/` · `lib/` · `shared/` · `pages/` | Skills UI, onboarding tour, glossary, demos, artifacts, SNS, shared primitives |
+
+---
+
+### Agent-Discovery & Well-Known Files (`public/.well-known/`)
+
+Machine-readable manifests that let agents, crawlers, and wallets discover the platform:
+
+| File | Purpose |
+|------|---------|
+| `3d-agent-card.json` + `.schema.json` | three.ws 3D agent card + its JSON Schema |
+| `agent-card.json` | A2A / agent-card discovery |
+| `agent-registration.json` | Agent registration descriptor |
+| `three-ws-agent.metaplex.json` | Metaplex on-chain agent metadata |
+| `ai-plugin.json` | OpenAI plugin manifest |
+| `lobehub-plugin.json` | LobeHub plugin manifest |
+| `openapi.yaml` | OpenAPI spec for the public API |
+| `validators.json` | Allow-listed GLB-validation authorities |
+| `security.txt` | Security disclosure contact |
+| `x402.json` (served at `/.well-known/x402.json`) | Published x402 payable services (see [Bazaar Marketplace](#bazaar-marketplace)) |
+| `three-vanity.json` | Proof-of-grind vanity certificates (see [Vanity Wallet Protocol](#vanity-wallet-protocol)) |
+
+---
+
+### Public Static Apps (`public/`)
+
+Standalone HTML apps and asset roots served directly (not Vite-controller pages): `discover/` (ERC-8004 marketplace) · `my-agents/` · `agents/` · `gallery/` · `studio/` · `scene-studio/` · `reputation/` · `hydrate/` · `validation/` · `pay/` + `pay/c/` (x402 checkout) · `x402/` · `agenc/` · `club/` · `chat/` · `lobehub/` · `dashboard/` + `dashboard-next/` · `persona/` · `admin/` · `internal/` · `tour/` · `widgets-gallery/` · `demos/` + `demos-embed/` + `demo/` · `news/` · `changelog/` · `legal/` · `docs/` · `store/` · `launch/` · plus asset roots: `animations/`, `accessories/`, `cosmetics/`, `environments/`, `textures/`, `fonts/`, `badges/`, `og/`, `locales/` (i18n catalogs), `sitemap/`, `vendor/`.
+
+---
+
+### Complete Cron Schedule (`api/cron/`)
+
+**62 scheduled jobs** are declared in `vercel.json` (`crons`). Full inventory by domain (schedule in cron syntax):
+
+| Domain | Job (`/api/cron/…`) — schedule |
+|--------|-------------------------------|
+| Oracle & intel | `oracle-score` `*/2m` · `oracle-digest` `08:00` · `intel-learn` `*/15m` · `reconcile-decisions` `*/10m` · `gmgn-seed` `03:00` |
+| Smart money & reputation | `smart-money-rollup` `*/5m` · `smart-money-graph` `*/10m` · `recompute-reputation` `*/10m` · `trader-score-attest` `09:45` |
+| Pump.fun | `pumpfun-monitor` `*/3m` · `pumpfun-graduations-sync` `*/2m` · `pumpfun-signals` `*/15m` · `pump-agent-stats` `*/10m` · `radar-watchlist` `*/10m` |
+| Buyback & payouts | `run-buyback` `hourly` · `run-distribute-payments` `:30` · `run-three-buyback` `06:00` · `run-coin-cycle` `*/5m` · `run-coin-payouts` `1-59/5m` · `club-payouts` `2-59/5m` · `cosmetic-splits-sweep` `:15` · `settle-royalties` `03:00` · `treasury-autopilot` `:23` |
+| Trading fanout | `copy-fanout` · `mirror-fanout` · `signal-fanout` · `strategy-fanout` (all `*/2m`) · `run-dca` `hourly` |
+| Subscriptions & billing | `run-subscriptions` `hourly` · `process-subscriptions` `*/6h` · `process-withdrawals` `hourly` · `expire-pending-purchases` `*/5m` · `flush-usage-events` `*/1m` |
+| On-chain attest & index | `erc8004-crawl` `*/15m` · `solana-attestations-crawl` `*/10m` · `solana-attest-event-cleanup` `*/10m` · `custody-attest` `17 */6h` · `index-delegations` `*/5m` |
+| Agent lifecycle | `reflect-sweep` `*/30m` · `dead-man-switch` `05:00` · `auto-rig-sweep` `*/5m` · `avaturn-seed-cron` `*/1m` |
+| Forge | `forge-seed-cron` `*/1m` · `forge-smoke` `09:30` |
+| $THREE | `three-holders-snapshot` `*/5m` |
+| IRL & worlds | `irl-drops-refund` `*/10m` · `irl-reap` `:17` · `world-health` `*/15m` |
+| Wallet & custody | `wallet-intents` `*/10m` · `relayer-balance-check` `*/6h` |
+| X (social) | `run-x-scheduled-posts` `*/1m` · `run-x-triggers` `*/5m` · `fetch-x-metrics` `*/6h` |
+| Health & maintenance | `quota-check` `hourly` · `uptime-check` `*/5m` · `/api/llm/health` `hourly` · `audit-log-cleanup` `04:00` · `cleanup-csrf-tokens` `:17` · `siwx-gc` `03:00` |
+| Reference agent | `unstoppable-tick` `*/5m` |
+| Activity | `pulse-tick` `*/2m` |
+
+All cron handlers authenticate via the `CRON_SECRET` Bearer gate.
+
+---
+
+### Complete Database Table Inventory
+
+The schema (`api/_lib/schema.sql` + **234 dated migration files**, 2026-04-29 → 2026-06-23) defines **~260 Postgres tables** (pgvector for embeddings). Full inventory by domain:
+
+| Group | Tables |
+|-------|--------|
+| Identity & auth | `users` · `sessions` · `api_keys` · `oauth_clients` · `oauth_auth_codes` · `oauth_refresh_tokens` · `password_resets` · `email_verifications` · `csrf_tokens` · `siwe_nonces` · `siws_nonces` · `siwx_nonces` · `gate_nonces` · `saml_request_ids` · `agent_identities` · `agent_registrations_pending` · `user_subdomains` · `solana_credentials` |
+| Agents | `agent_versions` · `agent_decisions` · `agent_actions` · `agent_jobs` · `agent_mood_history` · `agent_reflections` · `agent_reflection_runs` · `agent_brain_anchors` · `agent_memories` · `agent_memory_entities` · `agent_memory_entity_links` · `agent_memory_pins` · `agent_bookmarks` · `agent_reviews` · `agent_anomaly_events` |
+| Wallets & custody | `user_wallets` · `agent_payout_wallets` · `agent_wallet_capabilities` · `agent_wallet_intents` · `agent_custody_events` · `custody_attestation_epochs` · `custody_attestation_leaves` · `wallet_value_snapshots` · `wallet_reputation` · `agent_withdrawals` · `payouts` · `payment_configs_pending` |
+| Recovery & delegation | `agent_recovery_guardians` · `agent_recovery_requests` · `agent_recovery_approvals` · `agent_delegations` · `agent_autopilot_proposals` |
+| Payments & x402 | `agent_payments` · `agent_payment_intents` · `agent_revenue_events` · `agent_paid_services` · `siwx_payments` · `token_payments` · `bsc_consumed_tx` · `credit_accounts` · `credit_ledger` · `usage_events` · `developer_webhooks` · `webhook_deliveries` |
+| Skills & marketplace | `marketplace_skills` · `marketplace_themes` · `agent_skill_prices` · `skill_pricing_rules` · `skill_purchases` · `skill_access_grants` · `skill_installs` · `skill_license_mints` · `skill_payment_earnings` · `skill_usage_logs` · `skill_ratings` · `skill_reviews` · `skill_bundles` · `bundle_items` · `bundle_purchases` · `purchase_receipts` · `purchase_events` · `paid_assets` · `asset_purchases` · `asset_purchase_receipts` · `asset_prices` · `plugins` |
+| Royalties & splits | `fork_royalty_terms` · `fork_royalty_payouts` · `royalty_ledger` · `listing_splits` · `listing_split_recipients` · `split_distributions` · `cosmetic_creator_splits` · `referral_visits` |
+| Pump.fun & oracle | `pump_agent_mints` · `pump_agent_payments` · `pump_agent_trades` · `pump_agent_price_points` · `pump_agent_stats` · `pump_coin_intel` · `pump_coin_outcomes` · `pump_coin_wallets` · `pump_intel_weights` · `pump_relay_trades` · `pump_trade_delegations` · `pump_buyback_runs` · `pump_distribute_runs` · `pump_autopilot` · `pumpfun_graduations` · `pumpfun_monitor_cursor` · `pumpfun_signals` · `pumpfun_signals_cursor` · `oracle_conviction` · `oracle_conviction_history` · `oracle_narrative` · `oracle_agent_watch` · `oracle_watch_actions` · `oracle_followers` · `coin_smart_money` · `smart_money_scored` · `smart_wallet_clusters` · `smart_wallet_folded` · `smart_wallet_reputation` · `firewall_decisions` |
+| Trading engines | `orders` · `order_fills` · `strategy_backtests` · `strategy_kill_switch` · `agent_strategies` · `agent_strategy_equips` · `agent_strategy_positions` · `agent_sniper_strategies` · `agent_sniper_positions` · `market_maker_policies` · `market_maker_actions` · `dca_strategies` · `dca_executions` · `copy_subscriptions` · `copy_executions` · `agent_mirror_follows` · `agent_mirror_fills` · `signal_feeds` · `signal_emissions` · `signal_deliveries` · `signal_subscriptions` · `swarms` · `swarm_members` · `swarm_votes` · `swarm_payouts` · `agent_vaults` · `vault_backers` · `vault_positions` · `vault_events` · `portfolio_snapshots` |
+| Alerts & signals | `pump_alert_rules` · `pump_alert_rule_fires` · `pump_alert_deliveries` · `user_alert_configs` · `user_alert_fires` · `radar_watchlist` · `radar_events` |
+| Tournaments & games | `tournaments` · `tournament_entries` · `clash_battles` · `coin_draws` · `coin_events` · `coin_holders` · `coin_launches` · `coin_payouts` |
+| Community & social | `agora_citizens` · `agora_activity` · `agora_vouches` · `agora_idempotency` · `crews` · `crew_members` · `crew_invites` · `friendships` · `social_connections` · `user_follows` · `user_mutes` · `direct_messages` · `agent_hires` · `agent_bids` · `agent_bounties` · `bounties` · `bounty_submissions` · `bounty_submission_likes` · `agent_labor_policies` |
+| Club & cosmetics | `club_tips` · `club_payouts` · `club_bans` · `club_dancer_wallets` · `rider_passes` · `cosmetic_sales` · `genome_breedings` |
+| IRL | `irl_drops` · `irl_drop_claims` |
+| Walk & widgets | `walk_sessions` · `walk_events` · `walk_metrics` · `walk_achievements` · `walk_control_sessions` · `walk_control_commands` · `widgets` · `widget_views` · `widget_chat_threads` · `widget_chat_messages` · `widget_knowledge_docs` · `widget_knowledge_chunks` · `world_docs` |
+| Avatars & media | `avatars` · `avatar_regen_jobs` · `animation_clips` · `mocap_clips` · `token_metadata` · `launchpad_pages` |
+| Forge | `forge_creations` · `forge_votes` · `forge_board_winners` · `forge_seed_jobs` · `forge_consumption_redemptions` · `forge_high_redemptions` |
+| Subscriptions & billing | `subscription_plans` · `subscriptions` · `subscription_payments` · `subscription_checkouts` · `creator_subscriptions` · `user_agent_subscriptions` · `agent_subscriptions` · `plan_quotas` · `plan_payment_intents` · `aws_marketplace_customers` · `aws_marketplace_metering` |
+| Attestations & ledger | `solana_attestations` · `solana_attestations_cursor` · `solana_attest_event_claims` · `ledger_anchors` · `decision_outcomes` · `audit_log` |
+| $THREE | `three_allowances` · `three_buyback_runs` · `three_holder_snapshot` · `three_holder_snapshot_meta` · `three_rewards_distributions` |
+| Notifications & infra | `notification_events` · `notification_preferences` · `user_notifications` · `push_subscriptions` · `newsletter_subscribers` · `bot_heartbeat` · `indexer_state` · `circulation_actions` · `scene_gates` · `chat_brand_config` · `user_prefs` |
+| Reference agent (Unstoppable) | `unstoppable_activity` · `unstoppable_reflections` · `unstoppable_treasury` |
+| X (social) | `x_posts` · `x_scheduled_posts` · `x_triggers` · `x_pending_reviews` |
+
+> `master_wallets` is created at runtime via inline `CREATE TABLE IF NOT EXISTS` rather than a migration (see [Technical Debt](#technical-debt)).
+
+---
+
## Published Artifacts
### Core Platform Packages
@@ -2305,6 +2525,145 @@ sequenceDiagram
---
+## Agent Discovery & Well-Known Manifests
+
+three.ws is built to be discovered and consumed by other agents, crawlers, and registries. It publishes a full suite of machine-readable manifests under `/.well-known/` — some static (`public/.well-known/`), some served dynamically (`api/wk.js`, `api/openapi-json.js`).
+
+| Manifest | Path | Purpose |
+|----------|------|---------|
+| A2A Agent Card | `/.well-known/agent-card.json` | Google A2A agent card: `provider`, `capabilities`, `authentication`, `skills`, input/output modes |
+| 3D Agent Card | `/.well-known/3d-agent-card.json` (+ `.schema.json`) | three.ws-native card: `model`, `services`, `x402Support`, `x402Endpoints`, `registrations` |
+| ERC-8004 Registration | `/.well-known/agent-registration.json` | On-chain agent identity manifest (agentCard + services + x402Support) for ERC-8004 hydration |
+| Metaplex Metadata | `/.well-known/three-ws-agent.metaplex.json` | Token/NFT metadata (`animation_url`, `body`, model) |
+| OpenAI Plugin | `/.well-known/ai-plugin.json` | ChatGPT plugin manifest (`name_for_model`, `api`, auth) |
+| LobeHub Plugin | `/.well-known/lobehub-plugin.json` | LobeHub plugin (`identifier`, `ui`, `api`, `systemRole`) |
+| OpenAPI | `/.well-known/openapi.yaml` · `api/openapi-json.js` | Full REST API specification |
+| ERC-8004 Validators | `/.well-known/validators.json` | Allow-listed validator addresses (mainnet + testnet) |
+| Security | `/.well-known/security.txt` | Security disclosure contact |
+| **x402 service catalog** | `/.well-known/x402.json` · `/.well-known/x402-discovery` | Dynamically generated payable-endpoint catalog (PayAI/CDP-discoverable) |
+| **Vanity proof-of-grind** | `/.well-known/three-vanity.json` | Ed25519 proof-of-grind certificates for vanity addresses |
+
+These feed: x402 Bazaar discovery (PayAI + Coinbase CDP crawlers), ERC-8004 registries across 12+ chains, LobeHub/ChatGPT plugin stores, and A2A agent-to-agent capability negotiation.
+
+### ERC-8004 On-Chain Deployment Matrix
+
+CREATE2-deterministic, so `IdentityRegistry` + `ReputationRegistry` share one address per environment class. Liveness is asserted by `scripts/verify-onchain-parity.mjs` (`eth_getCode` sweep), not by stored tx hashes.
+
+| Registry | Address | Mainnet liveness |
+|----------|---------|------------------|
+| `IdentityRegistry` | `0x8004A169FB4a3325136EB29fA0ceB6D2e539a432` | bytecode-verified (2026-06-19) on **12 chains**: Ethereum (1), Optimism (10), BSC (56), Gnosis (100), Polygon (137), Mantle (5000), Base (8453), Arbitrum One (42161), Celo (42220), Avalanche (43114), Linea (59144), Scroll (534352) |
+| `ReputationRegistry` | `0x8004BAa17C55a88189AE136b182e5fdA19dE9b63` | same 12 chains |
+| `ValidationRegistry` | `0x8004Cb1BF31DAf7788923b405b754f57acEB4272` | **testnet only** (mainnet pending; `src/erc8004/abi.js` `MAINNET.validationRegistry = ''`) |
+
+**Not yet deployed (mainnet):** Fantom (250), zkSync Era (324 — CREATE2 derives differently), Moonbeam (1284) — `eth_getCode` returned `0x` on 2026-06-19; registration/reputation writes revert there until deployed. **Testnets (bytecode-verified):** BSC (97), Ethereum Sepolia (11155111), Base Sepolia (84532), Arbitrum Sepolia (421614), Optimism Sepolia (11155420), + more. See `contracts/DEPLOYMENTS.md`.
+
+---
+
+## Scheduled Jobs (Cron Reference)
+
+**`vercel.json` declares 61 cron schedules** (the platform is heavily clock-driven). All hit `GET /api/cron/*` (or `/api/llm/health`) with `Authorization: Bearer $CRON_SECRET`. Full schedule:
+
+| Domain | Crons (path → schedule) |
+|--------|--------------------------|
+| **Oracle / Intel** | `oracle-score` `*/2m` · `intel-learn` `*/15m` · `reflect-sweep` `*/30m` · `pulse-tick` `*/2m` · `gmgn-seed` `daily 03:00` · `pumpfun-signals` `*/15m` · `reconcile-decisions` `*/10m` |
+| **Pump.fun** | `pumpfun-monitor` `*/3m` · `pumpfun-graduations-sync` `*/2m` · `pump-agent-stats` `*/10m` · `run-buyback` `hourly` · `run-distribute-payments` `:30 hourly` · `run-coin-cycle` `*/5m` · `run-coin-payouts` `*/5m` |
+| **Smart money / radar** | `smart-money-rollup` `*/5m` · `smart-money-graph` `*/10m` · `radar-watchlist` `*/10m` · `recompute-reputation` `*/10m` |
+| **Trading fan-out** | `copy-fanout` `*/2m` · `mirror-fanout` `*/2m` · `signal-fanout` `*/2m` · `strategy-fanout` `*/2m` · `run-dca` `hourly` · `run-subscriptions` `hourly` |
+| **$THREE / treasury** | `three-holders-snapshot` `*/5m` · `treasury-autopilot` `:23 hourly` · `run-three-buyback` `daily 06:00` · `settle-royalties` `daily 03:00` |
+| **Wallet / custody** | `wallet-intents` `*/10m` · `index-delegations` `*/5m` · `process-withdrawals` `hourly` · `custody-attest` `:17 */6h` · `relayer-balance-check` `*/6h` · `dead-man-switch` `daily 05:00` |
+| **On-chain indexing** | `erc8004-crawl` `*/15m` · `solana-attestations-crawl` `*/10m` · `trader-score-attest` `daily 09:45` · `solana-attest-event-cleanup` `*/10m` |
+| **Avatars / Forge** | `avaturn-seed-cron` `*/1m` · `auto-rig-sweep` `*/5m` · `forge-seed-cron` `*/1m` · `forge-smoke` `daily 09:30` |
+| **Community / IRL** | `club-payouts` `*/5m` · `irl-drops-refund` `*/10m` · `irl-reap` `:17 hourly` · `unstoppable-tick` `*/5m` |
+| **X / social** | `run-x-scheduled-posts` `*/1m` · `run-x-triggers` `*/5m` · `fetch-x-metrics` `*/6h` |
+| **Billing / subscriptions** | `process-subscriptions` `*/6h` · `expire-pending-purchases` `*/5m` · `flush-usage-events` `*/1m` |
+| **Platform health / GC** | `uptime-check` `*/5m` · `world-health` `*/15m` · `quota-check` `hourly` · `/api/llm/health` `hourly` · `audit-log-cleanup` `daily 04:00` · `cleanup-csrf-tokens` `:17 hourly` · `siwx-gc` `daily 03:00` |
+
+---
+
+## Build, Test & Release Pipeline
+
+Root `package.json` (v1.5.2, Node 24.x) declares **42 npm workspaces** and ~90 scripts. The pipeline is asset-heavy and gate-enforced — no external CI, so these scripts ARE the quality gate.
+
+### Dev & Run
+
+| Script | Purpose |
+|--------|---------|
+| `dev` | `vite --port 3000` |
+| `dev:multi` / `dev:walk-all` | Multiplayer Colyseus server / full walk stack |
+| `dev:lib` | `TARGET=lib vite` (CDN bundle dev) |
+| `setup` / `postinstall` | `setup-dev.mjs`; postinstall builds payments SDK, fixes pump/x402/zauth/colyseus ESM, copies Three.js decoders, installs Claude skills |
+
+### Asset Bake (prebuild)
+
+`prebuild` runs in parallel: `build:news`, `build-skill-metadata`, `build-local-skill-packs`, `build:club-assets` (props/venue/HDRI/audio/entrance), `build:walk-environments`, then `inject-blog-seo`, `inject-hidden-guard`, `build:page-index` + page/handler/guard audits (strict), `inject-seo-meta`, `inject-theme-boot`. Other bakers: `build:animations` (Mixamo FBX → canonical JSON), `convert:fbx`, `extract:animations`, `bake:mannequin`, `build:wasm` (`wasm-pack` for `crates/vanity-grinder` → `src/solana/vanity/wasm`), `optimize:glb`, `build:artifact-viewer`, `build:apps-sdk-viewer`.
+
+### Build & Bundle
+
+| Script | Purpose |
+|--------|---------|
+| `build` | Vite MPA build (`--max-old-space-size=6144`) + strip service worker from embeds |
+| `build:lib` / `build:lib:full` | CDN library bundle (ES / ES+UMD) |
+| `build:artifact` | Claude Artifact bundle (`vite.config.artifact.js`) |
+| `build:chat` / `build:avatar-studio` | Sub-app builds (`chat/`, `character-studio/`) |
+| `build:vercel` | `build-vercel.mjs` — esbuild-bundle all `api/*.js` for deploy |
+| `build:all` | chat + app + lib |
+| `build:extension(:prod)` | Chrome MV3 walk-avatar extension |
+
+### Audit / Verify / Smoke Gates
+
+`gate` = `test:gate` + `audit:mcp` + `audit:routes` + `audit:handlers` + `audit:pages` + `audit:hidden-guard`. Plus: `verify:solana` / `verify:onchain` (parity), `verify:x402` (catalog + discovery), `smoke:onchain(:ci)`, `smoke:agent-wallet`, `smoke:mcp` / `test:mcp`, `audit:deploy` (esbuild-bundle guard), `guard:esbuild(:all)`, `check:images --strict`, `audit:web` / `snapshot` (page visual snapshots).
+
+### i18n & Publish
+
+`i18n` (extract → translate, `i18n:lint`), `changelog:push` (Telegram), `publish:lib`, `publish:packages(:dry)`, `publish:mcp(:dry)`, `release:lib`, `apply:r2-cors`, `generate-icons`.
+
+---
+
+## Configuration & Environment Reference
+
+The codebase references **~260 distinct `process.env.*` keys** across `api/`; `api/_lib/env.js` centralizes ~200 with `req()`/`opt()` guards. (The Infrastructure section lists the load-bearing subset; this is the full categorized surface.)
+
+| Category | Keys |
+|----------|------|
+| **Core infra** | `DATABASE_URL` · `UPSTASH_REDIS_REST_URL/_TOKEN` · `UPSTASH_CACHE_REST_URL/_TOKEN` · `UPSTASH_MANAGEMENT_API_KEY` · `UPSTASH_EMAIL` · `KV_REST_API_URL/_TOKEN` · `S3_ENDPOINT/_BUCKET/_PUBLIC_DOMAIN/_ACCESS_KEY_ID/_SECRET_ACCESS_KEY` · `JWT_SECRET` · `JWT_KID` · `WALLET_ENCRYPTION_KEY` · `INTERNAL_API_KEY` · `CRON_SECRET` · `CHROMIUM_PACK_URL` · `APP_ORIGIN` · `PUBLIC_APP_ORIGIN` · `DEFAULT_APP_ORIGIN` · `STOREFRONT_ORIGIN` · `SERVER_DOMAIN` · `NODE_ENV` · `VERCEL_ENV` |
+| **RPC & chains** | `SOLANA_RPC_URL` · `SOLANA_RPC_URL_DEVNET` · `MAINNET_RPC_URL` · `BASE_RPC_URL` · `BASE_SEPOLIA_RPC_URL` · `SEPOLIA_RPC_URL` · `EVM_RPC_URL` · `RPC_URL_8453` · `RPC_URL_84532` · `CLUB_BASE_RPC_URL` · `A2A_REPUTATION_RPC_URL` · `HELIUS_API_KEY` · `ETHERSCAN_API_KEY` |
+| **$THREE & treasuries** | `THREE_TOKEN_MINT` · `THREE_TOKEN_DECIMALS` · `THREE_TREASURY_WALLET` · `THREE_REWARDS_WALLET` · `THREE_BURN_ADDRESS` · `THREE_QUOTE_SECRET` · `THREE_QUOTE_TTL_S` · `THREE_PRIZE_PAYOUT_KEY` · `THREE_ALLOWANCE_DELEGATE_SECRET_KEY_B64` · `THREE_WS_MARK_ENFORCE` · `PLATFORM_TREASURY_KEYPAIR` · `TREASURY_KEYPAIR` · `COIN_TREASURY_SECRET_KEY_B64` · `COIN_CREATOR_SECRET_KEY_B64_*` · `CLUB_SOLANA_TREASURY_SECRET_KEY_B64` · `CLUB_EVM_TREASURY_PRIVATE_KEY` |
+| **LLM / AI** | `ANTHROPIC_API_KEY` · `OPENAI_API_KEY` · `GROQ_API_KEY` · `OPENROUTER_API_KEY` · `OPENROUTER_FALLBACK_KEYS` · `NVIDIA_API_KEY` · `NVIDIA_A2F_FUNCTION_ID` · `NVIDIA_ASR_FUNCTION_ID` · `NVIDIA_COSMOS_INVOKE_URL` · `WATSONX_API_KEY/_URL/_PROJECT_ID/_SPACE_ID/_MODEL_ID/_GUARDIAN_MODEL_ID/_API_VERSION` · `WATSONX_ORCHESTRATE_URL/_API_KEY/_AGENT` · `DASHSCOPE_API_KEY` · `MODELSCOPE_API_KEY` · `LIVEPEER_API_KEY` · `VOYAGE_API_KEY` · `AIXBT_API_KEY/_API_BASE/_ENABLED` · `ELEVENLABS_API_KEY` |
+| **x402 / payments** | `X402_FACILITATOR_URL(_BASE/_SOLANA)` · `X402_FACILITATOR_TOKEN(_BASE/_SOLANA)` · `X402_CDP_FACILITATOR_URL` · `X402_PAY_TO(_BASE/_BSC/_SOLANA)` · `X402_ASSET_ADDRESS_BASE/_BSC/_ARBITRUM` · `X402_ASSET_MINT(_SOLANA)` · `X402_FEE_PAYER_SOLANA` · `X402_ACCEPT_THREE_SOLANA` · `X402_THREE_AMOUNT_SOLANA` · `X402_EVM_NETWORKS` · `X402_MAX_PER_CALL/_HOUR/_DAY_ATOMIC` · `X402_MAX_AMOUNT_REQUIRED` · `X402_IDEMPOTENCY_TTL_SECONDS` · `X402_BUILDER_CODE_APP/_WALLET` · `CDP_API_KEY_ID/_SECRET` · `BSC_OPERATOR_KEY` · `PLATFORM_FEE_BPS` |
+| **Agent payments / guards** | `A2A_MANDATE_SECRET` · `A2A_PAYER_PRIVATE_KEY` · `A2A_PAYER_SOLANA_PRIVATE_KEY/_SECRET` · `GUARDIAN_SEND_CAP_USD` · `GUARDIAN_DISABLE` · `AGENT_RELAYER_KEY/_ADDRESS` · `PERMISSIONS_RELAYER_ENABLED` |
+| **Auth / identity** | `PRIVY_APP_ID/_APP_SECRET/_JWKS_ENDPOINT` · `VITE_PRIVY_APP_ID` · `GITHUB_OAUTH_CLIENT_ID/_SECRET` · `X_OAUTH_CLIENT_ID/_SECRET` · `NEYNAR_API_KEY` · `SAML_IDP_*` / `SAML_SP_*` (12 keys) · `ADMIN_ADDRESSES` · `BUILT_IN_ADMIN_ADDRESSES` · `ERC8004_VALIDATOR_PRIVATE_KEY` · `VALIDATOR_PRIVATE_KEY` · `HOLDER_PASS_SECRET` · `WALLET_CAPABILITY_SECRET` |
+| **Storage / pinning / SNS** | `PINATA_JWT` · `NFT_STORAGE_TOKEN` · `BUBBLEGUM_MERKLE_TREE` · `BUBBLEGUM_TREE_AUTHORITY` · `THREEWS_SOL_PARENT_SECRET_BASE58` · `THREEWS_SOL_PARENT_DOMAIN` · `MINT_PUBKEY` |
+| **Vanity / drops** | `VANITY_SERVICE_KEY` · `VANITY_BOUNTY_PAYOUT_KEY` · `VANITY_DROP_FUNDING_KEY` |
+| **Multiplayer / worlds** | `MULTIPLAYER_URL` · `MULTIPLAYER_INTERNAL_URL` · `MULTIPLAYER_SHARED_SECRET` |
+| **AWS Marketplace** | `AWS_MP_PRODUCT_CODE` · `AWS_MP_REGION` · `AWS_MP_ACCESS_KEY_ID/_SECRET_ACCESS_KEY` · `AWS_MP_SNS_TOPIC_ARN` · `AWS_MP_METERING_DIMENSION` · `AWS_MP_ENTITLEMENT_REQUIRED` · `AWS_MP_DEFAULT_RATE_LIMIT_PER_MINUTE` |
+| **Avatars / feature flags** | `AVATURN_API_KEY/_API_URL/_SEED_ENABLED` · `CHAT_ADMIN_KEY` · `RIDER_HELIUS_WEBHOOK_SECRET` · `RIDER_VAULT_ADDRESS` · `CZ_AGENT_ID/_AGENT_NAME/_REGISTRY_CONTRACT` · `ZAUTH_API_KEY/_DEBUG/_INCLUDE_BODIES` · `OFFER_RECEIPT_SIGNING_PRIVATE_KEY/_JWK/_JWS_ALG/_FORMAT` |
+| **Publishing / comms** | `DEV_TO_API_KEY` · `MEDIUM_INTEGRATION_TOKEN` · `MEDIUM_AUTHOR_ID` (Telegram keys: `TELEGRAM_BOT_TOKEN`, `TELEGRAM_CHANGELOG_CHAT_ID`) |
+
+---
+
+## Database Schema — Complete Table Index
+
+`api/_lib/schema.sql` + ~160 dated migration files in `api/_lib/migrations/` define **~276 Postgres tables** (Neon, with `pgvector`). Complete index by domain:
+
+| Domain | Tables |
+|--------|--------|
+| **Identity & Auth** | `users` · `sessions` · `password_resets` · `email_verifications` · `api_keys` · `csrf_tokens` · `oauth_clients` · `oauth_auth_codes` · `oauth_refresh_tokens` · `siwe_nonces` · `siws_nonces` · `siwx_nonces` · `siwx_payments` · `gate_nonces` · `saml_request_ids` · `solana_credentials` · `user_subdomains` · `user_prefs` · `user_wallets` · `user_follows` · `user_mutes` · `user_notifications` · `social_connections` · `friendships` · `direct_messages` · `newsletter_subscribers` · `push_subscriptions` |
+| **Agents core** | `agent_identities` · `agent_versions` · `agent_actions` · `agent_decisions` · `agent_mood_history` · `agent_reflections` · `agent_reflection_runs` · `agent_brain_anchors` · `agent_memories` · `agent_memory_entities` · `agent_memory_entity_links` · `agent_memory_pins` · `agent_registrations_pending` · `agent_bookmarks` · `agent_reviews` · `agent_anomaly_events` |
+| **Wallets, custody & ledger** | `agent_payout_wallets` · `agent_payments` · `agent_payment_intents` · `agent_revenue_events` · `agent_withdrawals` · `agent_custody_events` · `agent_recovery_requests` · `agent_recovery_approvals` · `agent_recovery_guardians` · `agent_wallet_capabilities` · `agent_wallet_intents` · `agent_delegations` · `three_allowances` · `payouts` · `payment_configs_pending` · `custody_attestation_epochs` · `custody_attestation_leaves` · `ledger_anchors` · `credit_accounts` · `credit_ledger` · `circulation_actions` · `token_payments` |
+| **Skills, assets & royalties** | `marketplace_skills` · `marketplace_themes` · `agent_skill_prices` · `skill_pricing_rules` · `skill_purchases` · `skill_access_grants` · `skill_installs` · `skill_license_mints` · `skill_payment_earnings` · `skill_usage_logs` · `skill_ratings` · `skill_reviews` · `skill_bundles` · `bundle_items` · `bundle_purchases` · `paid_assets` · `asset_prices` · `asset_purchases` · `asset_purchase_receipts` · `fork_royalty_terms` · `fork_royalty_payouts` · `listing_splits` · `listing_split_recipients` · `split_distributions` · `royalty_ledger` · `purchase_events` · `purchase_receipts` |
+| **Pump.fun, oracle & intel** | `pump_agent_mints` · `pump_agent_payments` · `pump_agent_trades` · `pump_agent_stats` · `pump_agent_price_points` · `pump_coin_intel` · `pump_coin_outcomes` · `pump_coin_wallets` · `pump_intel_weights` · `pump_relay_trades` · `pump_trade_delegations` · `pump_buyback_runs` · `pump_distribute_runs` · `pump_autopilot` · `pump_alert_rules` · `pump_alert_rule_fires` · `pump_alert_deliveries` · `pumpfun_graduations` · `pumpfun_monitor_cursor` · `pumpfun_signals` · `pumpfun_signals_cursor` · `oracle_conviction` · `oracle_conviction_history` · `oracle_narrative` · `oracle_agent_watch` · `oracle_watch_actions` · `oracle_followers` · `coin_smart_money` · `smart_money_scored` · `smart_wallet_clusters` · `smart_wallet_folded` · `smart_wallet_reputation` · `wallet_reputation` · `firewall_decisions` · `radar_watchlist` · `radar_events` |
+| **Trading, strategies & vaults** | `agent_sniper_strategies` · `agent_sniper_positions` · `agent_strategies` · `agent_strategy_equips` · `agent_strategy_positions` · `strategy_backtests` · `strategy_kill_switch` · `orders` · `order_fills` · `agent_mirror_follows` · `agent_mirror_fills` · `copy_subscriptions` · `copy_executions` · `dca_strategies` · `dca_executions` · `market_maker_policies` · `market_maker_actions` · `swarms` · `swarm_members` · `swarm_votes` · `swarm_payouts` · `agent_vaults` · `vault_backers` · `vault_positions` · `vault_events` · `signal_feeds` · `signal_emissions` · `signal_subscriptions` · `signal_deliveries` · `decision_outcomes` · `portfolio_snapshots` · `wallet_value_snapshots` |
+| **x402, billing & subscriptions** | `x402_skus` · `x402_merchant_settings` · `x402_receipts` · `x402_checkout_calls` · `x402_pump_launches` · `x402_subscriptions` · `x402_access_log` · `x402_audit_log` · `subscriptions` · `subscription_plans` · `subscription_payments` · `subscription_checkouts` · `creator_subscriptions` · `user_agent_subscriptions` · `agent_subscriptions` · `plan_payment_intents` · `plan_quotas` · `bsc_consumed_tx` · `aws_marketplace_customers` · `aws_marketplace_metering` |
+| **Community, worlds & labor** | `agora_citizens` · `agora_activity` · `agora_vouches` · `agora_idempotency` · `clash_battles` · `club_tips` · `club_payouts` · `club_bans` · `club_dancer_wallets` · `coin_launches` · `coin_events` · `coin_holders` · `coin_draws` · `coin_payouts` · `crews` · `crew_members` · `crew_invites` · `walk_sessions` · `walk_events` · `walk_metrics` · `walk_achievements` · `walk_control_sessions` · `walk_control_commands` · `tournaments` · `tournament_entries` · `bounties` · `bounty_submissions` · `bounty_submission_likes` · `agent_bounties` · `agent_jobs` · `agent_hires` · `agent_bids` · `agent_labor_policies` · `genome_breedings` · `irl_drops` · `irl_drop_claims` · `rider_passes` · `unstoppable_activity` · `unstoppable_reflections` · `unstoppable_treasury` · `scene_gates` · `world_docs` |
+| **3D, avatars & forge** | `avatars` · `avatar_regen_jobs` · `animation_clips` · `mocap_clips` · `forge_creations` · `forge_votes` · `forge_board_winners` · `forge_seed_jobs` · `forge_consumption_redemptions` · `forge_high_redemptions` · `cosmetic_sales` · `cosmetic_creator_splits` · `token_metadata` · `launchpad_pages` |
+| **Patronage & agent services** | `agent_patron_perks` · `agent_patron_prefs` · `agent_paid_services` · `agent_autopilot_proposals` |
+| **Widgets, notifications & RAG** | `widgets` · `widget_views` · `widget_chat_threads` · `widget_chat_messages` · `widget_knowledge_docs` · `widget_knowledge_chunks` · `plugins` · `chat_brand_config` · `notification_events` · `notification_preferences` · `user_alert_configs` · `user_alert_fires` |
+| **Indexing, attestations & infra** | `erc8004_agents_index` · `erc8004_crawl_cursor` · `solana_attestations` · `solana_attestations_cursor` · `solana_attest_event_claims` · `three_holder_snapshot` · `three_holder_snapshot_meta` · `three_rewards_distributions` · `three_buyback_runs` · `usage_events` · `audit_log` · `bot_heartbeat` · `indexer_state` · `webhook_deliveries` · `developer_webhooks` · `referral_visits` |
+
+> Several tables (e.g. `master_wallets`) are bootstrapped at runtime via `CREATE TABLE IF NOT EXISTS` rather than a migration — see [Known Gaps](#known-gaps--in-progress).
+
+---
+
## Known Gaps & In-Progress
### Critical / Blocking