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
feat(compete): add the /compete and /compete/:slug pages, routes, docs and nav entry for builder competitions
nirholas3172dcf7e344
diff --git a/STRUCTURE.md b/STRUCTURE.mdindex 509040412..ba4a0e0e9 100644--- a/STRUCTURE.md+++ b/STRUCTURE.md@@ -104,6 +104,7 @@ packages, a generated standalone GitHub mirror). See| Sell an agent as a paid API | Owner switch on the agent wallet Earn tab [src/agent-wallet-hub/tabs/earn.js](src/agent-wallet-hub/tabs/earn.js) (client [src/agent-economy-hub.js](src/agent-economy-hub.js)), owner API [api/agents/[id]/api-service.js](api/agents/%5Bid%5D/api-service.js) `→ GET/PUT /api/agents/:id/api-service`, paid route [api/x402/agents.js](api/x402/agents.js) `→ POST /api/x402/agents/:id` + free list `GET /api/x402/agents`, rules and ledger [api/_lib/agent-api-service.js](api/_lib/agent-api-service.js), shared turn [api/_lib/agent-turn.js](api/_lib/agent-turn.js), discovery slice `buildSellableAgentItems()` in [api/wk.js](api/wk.js) | Live | An owner flips "Sell this agent as an API", sets a USD price per call (floor $0.001, the smallest settle the facilitator co-signs) and a public description; the agent becomes a stable x402 v2 endpoint that answers one turn with the same persona, custom skills and premium-skill rules as `/api/agents/talk`. The 402 leads with Solana USDC and pays the agent's own payout wallet; the turn runs before settlement so a failed call is never charged; each settled call is written to `agent_revenue_events` (skill `agent-api`, net of `PLATFORM_FEE_BPS`, `settled_to_wallet = true` so it never counts as treasury-withdrawable). Only public agents with a brain and a Solana payout address can be sold, and the switch says why when one cannot. Agents on sale appear in `/.well-known/x402.json` and under Agents on [/x402](public/x402-stripe.html). Docs: [docs/x402.md](docs/x402.md#sell-your-agent-as-an-api), [docs/api-reference.md](docs/api-reference.md#sell-an-agent-as-an-api). Tests: [tests/api/x402-agent-api.test.js](tests/api/x402-agent-api.test.js) || Platform analytics (every platform total, one page) | [pages/analytics.html](pages/analytics.html) `→ /analytics` + page module [src/platform-analytics.js](src/platform-analytics.js), endpoint [api/platform/analytics.js](api/platform/analytics.js) `→ GET /api/platform/analytics?window=30d\|90d\|all`, data layer [api/_lib/platform-analytics.js](api/_lib/platform-analytics.js) | Live | The partner and investor view: agents, agents with a wallet, coins launched, 3D models generated, LLM tokens processed, x402 settlements and volume, marketplace sales and volume, and agent-to-agent hire volume, each with an all-time total, a zero-filled daily series and a `method` string rendered under "How each number is calculated". Counting predicates match the endpoints that already publish the same figure (`/api/home-stats`, the `MARKET_PAID_KINDS` gate, `platformEconomyStats()`), so no two pages disagree. A failing source is `null` plus a named `errors` entry, never a zero; the page shows an unavailable tile for it and a whole-page retry only when nothing could be read. Creator fees (SOL) read the `agent_coin_earnings` snapshot from parity order 015 with the same per-wallet counting rule as `/api/agents/:id/earnings`. Docs: [docs/api-reference.md](docs/api-reference.md#platform-analytics-api). Tests: [tests/platform-analytics.test.js](tests/platform-analytics.test.js) || Why three.ws (builder pitch on live numbers) | [pages/why-three-ws.html](pages/why-three-ws.html) `→ /why-three-ws` + page module [src/why-three-ws.js](src/why-three-ws.js) | Live | What a builder gets, the build-get found-earn-reinvest loop as an accessible SVG, and a comparison against categories of platform (never named products) where each cell links to its proof. The five proof tiles are read from `GET /api/platform/analytics?window=all` (nothing numeric is typed into the page); a failed metric renders as Unavailable, never zero. Tests: [tests/why-three-ws.test.js](tests/why-three-ws.test.js) |+| Builder competitions (tokenized build-off) | [pages/compete.html](pages/compete.html) `→ /compete`, `/compete/:slug` + page module [src/compete.js](src/compete.js), config [data/competitions.json](data/competitions.json) (ships empty), API [api/competitions.js](api/competitions.js), logic [api/_lib/competitions.js](api/_lib/competitions.js), registrations [api/_lib/migrations/20261023200000_competition_entries.sql](api/_lib/migrations/20261023200000_competition_entries.sql) | Live (no competition configured) | Enter an agent, launch its coin through three.ws inside the window, rank by creator fees earned (same attribution as the agent earnings page). Phase and countdown come from the clock; dates, tracks, prizes, judges and rules come from `data/competitions.json`, so running one is a config edit. Empty config renders "no competition is running". How to run one: [docs/competitions.md](docs/competitions.md). Tests: [tests/competitions.test.js](tests/competitions.test.js) || Experiments (public write-ups of what we tried) | [pages/experiments.html](pages/experiments.html) `→ /experiments` + page module [src/experiments-index.js](src/experiments-index.js), entries [data/experiments.json](data/experiments.json), write-ups `docs/experiments-<slug>.md` (served at `/docs/experiments-<slug>`), validator [scripts/lib/experiments-index.mjs](scripts/lib/experiments-index.mjs) run by `npm run build:pages`, published index `public/experiments.json` | Live | One card per experiment (question, status, spend, published date, headline result) with a URL-synced status filter, each opening a write-up in the six-section template: the question, method, spend, result, what we got wrong, what we changed, plus an appendix of the SELECT queries behind every number. The build fails on a missing field, an unknown status, a missing write-up, or a write-up missing a template section. How to add one: [docs/experiments.md](docs/experiments.md). Tests: [tests/experiments-index.test.js](tests/experiments-index.test.js) || Agent Symphony (economy as generative music) | [pages/symphony.html](pages/symphony.html) `→ /symphony`, engine [src/symphony.js](src/symphony.js), grammar [src/symphony-score.js](src/symphony-score.js) | Live | The live activity bus (`GET /api/feed` + `/api/feed-stream` SSE) rendered as WebAudio generative music: one synthesized note per real platform event, voice by event type (payments pluck, coin buys land as bass, new agents chime, guard refusals play dissonance, jackpots glissando), pitch register by amount (whales sit lower), stable per-actor motif + stereo position via FNV-1a hash, all quantized to one pentatonic scale so arbitrary event streams harmonize. Canvas visualization, live ledger with real click-throughs, and a MediaRecorder tap that exports a shareable audio clip of the master bus. A burst gate collapses event floods (a sniper sweep emitting dozens of identical guard events) into one accented note per actor per 1.5s. Solo mode narrows the stream to one participant client-side (`?agent=<id>` exact, `?actor=<label>` case-insensitive), reachable from the per-row "solo" control and from the "Listen →" link on every agent profile's Wallet Story card. No audio assets, no synthetic events. Tests: [tests/symphony-score.test.js](tests/symphony-score.test.js) || Platform activity feed | [pages/feed.html](pages/feed.html) `→ /feed` + [pages/community.html](pages/community.html) `→ /community`, backend [api/users/me/feed.js](api/users/me/feed.js) | Live | Reverse-chronological creation events (avatars, agents, coins, models, worlds) plus follow activity, merged at read time from `forge_creations`, `dioramas`, and `user_follows` (no separate event log to drift out of sync). `?scope=following` (default; session-gated, anonymous gets 401) vs `?scope=all` (public; powers `/community` and first-visit feeds); `limit` 1..50, `before` ISO cursor. Items deep-link to creator portfolios. Distinct from the Money Pulse ticker `GET /api/feed` ([docs/money-feed.md](docs/money-feed.md)). Docs: [docs/social-layer.md](docs/social-layer.md) |diff --git a/data/pages.json b/data/pages.jsonindex 1dcfedf74..74158df33 100644--- a/data/pages.json+++ b/data/pages.json@@ -2847,6 +2847,14 @@"changefreq": "weekly","added": "2026-09-30"},+ {+ "path": "/compete",+ "title": "Builder competitions",+ "description": "Build an agent, launch its coin on three.ws, and climb a live leaderboard ranked by creator fees earned. Dates, tracks, prizes, judges and rules for each competition, with registration and a countdown.",+ "priority": 0.6,+ "changefreq": "daily",+ "added": "2026-10-23"+ },{"path": "/analytics","title": "Platform Analytics",@@ -6619,6 +6627,14 @@"changefreq": "monthly","added": "2026-09-30"},+ {+ "path": "/docs/competitions",+ "title": "Docs · Running a builder competition",+ "description": "How to run a tokenized builder competition: the data/competitions.json fields, the phases, how entries are ranked by creator fees earned, an example config and the registration API.",+ "priority": 0.5,+ "changefreq": "monthly",+ "added": "2026-10-23"+ },{"path": "/docs/experiments-agent-launch-funnel","title": "Experiment · How many new agents ever launch a coin?",diff --git a/docs/competitions.md b/docs/competitions.mdnew file mode 100644index 000000000..96cdfbd7b--- /dev/null+++ b/docs/competitions.md@@ -0,0 +1,56 @@+# Builder competitions: how to run one++[/compete](https://three.ws/compete) lists every competition configured in [data/competitions.json](../data/competitions.json). The file ships as an empty array, and with it empty the page and the API say "no competition is running". Running one is a config edit and a deploy, not a build.++## The format++A builder enters an agent, launches that agent's coin through three.ws before the tokenize deadline, and ranks on a live leaderboard by the creator fees the agent earns. An entry is **tokenized** when its agent launched a mainnet coin through three.ws (a row in `pump_agent_mints`) between `starts_at` and `tokenize_by`. Fees come from the creator-earnings snapshot behind the [agent earnings page](https://three.ws/leaderboard?tab=earned), attributed by the same rule, so the board and an agent's own page never disagree. Untokenized entries are listed after the ranked ones.++## Add a competition++Append an object to `data/competitions.json`. Every field is validated when the API reads the file; an invalid file answers `competitions_config_invalid` naming the field, and `tests/competitions.test.js` fails in CI.++| Field | Meaning |+|---|---|+| `slug` | URL id, lowercase letters, digits and `-`. The page is `/compete/<slug>`. |+| `title`, `summary` | Heading and one-line description. |+| `starts_at` | Registration opens (ISO 8601). Launches count from here. |+| `register_by` | Registration closes. |+| `tokenize_by` | Last moment a coin launch counts. |+| `ends_at` | Competition ends. Order: `starts_at` < `register_by` and `tokenize_by` <= `ends_at`. |+| `tracks` | `[{ name, description }]`. When present, an entry must pick one. |+| `prizes` | `[{ place, amount, asset, vesting }]`. Display only; paying a prize is a spend and goes through the normal confirmation. |+| `judges` | `[{ name, role, url }]`. |+| `rules` | List of rule sentences. |+| `winners` | After judging: `[{ place, agent_id, note }]`. Shown when the competition has ended. |++Phases, from the clock: `upcoming` (before `starts_at`), `open` (registration), `building` (registration closed), `ended`. The hero counts down to the next deadline.++## Example++```json+[+ {+ "slug": "autumn-build",+ "title": "Autumn Agent Build",+ "summary": "Ship an agent, launch its coin, earn the most creator fees.",+ "starts_at": "2026-11-01T00:00:00Z",+ "register_by": "2026-11-20T23:59:00Z",+ "tokenize_by": "2026-12-05T23:59:00Z",+ "ends_at": "2026-12-12T23:59:00Z",+ "tracks": [{ "name": "Trading", "description": "Agents that trade on Solana." }],+ "prizes": [{ "place": "1st", "amount": 5000, "asset": "USDC", "vesting": "Paid within 14 days of the end." }],+ "judges": [{ "name": "Jane Doe", "role": "Judge" }],+ "rules": ["The agent must be public.", "The coin must be launched through three.ws inside the window."]+ }+]+```++## API++- `GET /api/competitions` lists competitions with their phase.+- `GET /api/competitions/:slug` returns the competition, the ranked entries, the ranking method and the viewer's own entries.+- `GET /api/competitions/:slug/entries` returns the entries alone.+- `POST /api/competitions/:slug/entries` registers `{ agent_id, track, team_name, x_handle }` for the signed-in caller. It enforces the registration window, that the agent belongs to the caller and is public, a known track, and one entry per agent.++Registrations live in `competition_entries` ([migration](../api/_lib/migrations/20261023200000_competition_entries.sql)). Code: [api/_lib/competitions.js](../api/_lib/competitions.js), [api/competitions.js](../api/competitions.js), [src/compete.js](../src/compete.js).diff --git a/pages/compete.html b/pages/compete.htmlnew file mode 100644index 000000000..c3b71347f--- /dev/null+++ b/pages/compete.html@@ -0,0 +1,132 @@+<!DOCTYPE html>+<html lang="en">+<head>+ <style>/* three.ws hidden-guard: make the `hidden` attribute authoritative; see scripts/lib/hidden-guard.mjs */[hidden]{display:none!important}</style>+ <script>/* three.ws theme boot: no-flash */(function(){try{var m=localStorage.getItem('twx_theme');var l=m==='auto'?(window.matchMedia&&window.matchMedia('(prefers-color-scheme: light)').matches):m==='light';document.documentElement.setAttribute('data-theme',l?'light':'dark');}catch(e){document.documentElement.setAttribute('data-theme','dark');}})();</script>+ <meta charset="utf-8" />+ <meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover" />+ <title>Builder competitions · three.ws</title>+ <meta name="description" content="Build an agent, launch its coin on three.ws, and climb a live leaderboard ranked by the creator fees it earns. Dates, tracks, prizes and rules for every competition." />+ <link rel="canonical" href="https://three.ws/compete" />+ <link rel="icon" href="/favicon.ico" sizes="any" />+ <link rel="icon" type="image/svg+xml" href="/favicon.svg" />+ <link rel="apple-touch-icon" href="/apple-touch-icon.png" />+ <link rel="manifest" href="/manifest.webmanifest" />+ <link rel="stylesheet" href="/style.css" />+ <link rel="stylesheet" href="/nav.css" />+ <link rel="stylesheet" href="/mobile.css" />+ <meta property="og:type" content="website" />+ <meta property="og:site_name" content="three.ws" />+ <meta property="og:title" content="three.ws Builder competitions" />+ <meta property="og:description" content="Build an agent, launch its coin, and climb a live leaderboard ranked by creator fees earned." />+ <meta property="og:url" content="https://three.ws/compete" />+ <meta property="og:image" content="https://three.ws/api/page-og?s=crypto&t=Builder+competitions&d=Build+an+agent%2C+launch+its+coin%2C+and+climb+a+live+leaderboard+ranked+by+creator+fees+earned.&p=%2Fcompete" />+ <meta property="og:image:alt" content="three.ws Builder competitions" />+ <meta property="og:locale" content="en_US" />+ <meta name="twitter:card" content="summary_large_image" />+ <meta name="twitter:site" content="@trythreews" />+ <meta name="twitter:title" content="three.ws Builder competitions" />+ <meta name="twitter:description" content="Build an agent, launch its coin, and climb a live leaderboard ranked by creator fees earned." />+ <meta name="twitter:image" content="https://three.ws/api/page-og?s=crypto&t=Builder+competitions&d=Build+an+agent%2C+launch+its+coin%2C+and+climb+a+live+leaderboard+ranked+by+creator+fees+earned.&p=%2Fcompete" />+ <meta name="robots" content="index, follow, max-image-preview:large, max-snippet:-1" />+ <script type="application/ld+json">{"@context":"https://schema.org","@type":"CollectionPage","name":"Builder competitions","description":"Build an agent, launch its coin on three.ws, and climb a live leaderboard ranked by creator fees earned.","url":"https://three.ws/compete","isPartOf":{"@type":"WebSite","name":"three.ws","url":"https://three.ws"}}</script>+ <style>+ :root { --cp-maxw: 1000px; --cp-ok: #16a34a; --cp-warn: #d97706; }+ :root:not([data-theme="light"]) { --cp-ok: var(--success); --cp-warn: #fbbf24; }+ * { box-sizing: border-box; }+ html, body { margin: 0; background: var(--bg-0); color: var(--ink); }+ body { font-family: var(--font-body, 'Inter', system-ui, sans-serif); min-height: 100vh; }+ .site-header { position: sticky; top: 0; z-index: 50; background: color-mix(in srgb, var(--bg-0) 82%, transparent); backdrop-filter: blur(10px); }+ a { color: inherit; }+ a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }++ .cp-wrap { max-width: var(--cp-maxw); min-width: 0; width: 100%; margin: 0 auto; padding: 0 18px 96px; }+ #cp-root { min-width: 0; width: 100%; }+ .cp-hero { padding: 40px 0 8px; }+ .cp-eyebrow { font-size: 0.74rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--ink-dim); font-weight: 650; margin: 0 0 10px; }+ .cp-hero h1 { font-size: clamp(1.8rem, 4.6vw, 2.7rem); line-height: 1.1; margin: 0 0 12px; letter-spacing: -0.025em; color: var(--ink-bright, var(--ink)); overflow-wrap: anywhere; }+ .cp-hero p { margin: 0 0 10px; max-width: 66ch; color: var(--ink-dim); line-height: 1.6; font-size: 1.02rem; }+ .cp-hero a, .cp-foot a, .cp-empty a { text-decoration: underline; text-underline-offset: 3px; }+ .cp-hero a:hover, .cp-foot a:hover, .cp-empty a:hover { color: var(--ink-bright, var(--ink)); }++ .cp-phase { display: inline-flex; align-items: center; gap: 6px; font-size: 0.8rem; font-weight: 650; padding: 3px 10px 3px 8px; border-radius: 999px; border: 1px solid var(--stroke-strong); color: var(--ink-dim); margin-bottom: 12px; }+ .cp-phase::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }+ .cp-phase[data-phase="open"] { color: var(--cp-ok); border-color: color-mix(in srgb, var(--cp-ok) 45%, transparent); }+ .cp-phase[data-phase="building"] { color: var(--cp-warn); border-color: color-mix(in srgb, var(--cp-warn) 45%, transparent); }++ .cp-count { display: flex; flex-wrap: wrap; gap: 10px; margin: 18px 0 4px; align-items: stretch; }+ .cp-count-label { flex: 1 1 100%; font-size: 0.85rem; color: var(--ink-dim); }+ .cp-unit { min-width: 76px; padding: 10px 12px; border-radius: var(--radius-md, 10px); background: var(--surface-1); border: 1px solid var(--stroke); text-align: center; }+ .cp-unit b { display: block; font-size: 1.6rem; font-variant-numeric: tabular-nums; color: var(--ink-bright, var(--ink)); line-height: 1.2; }+ .cp-unit span { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-dim); }++ .cp-section { margin-top: 36px; }+ .cp-section h2 { font-size: 1.15rem; margin: 0 0 12px; letter-spacing: -0.01em; color: var(--ink-bright, var(--ink)); }+ .cp-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(260px, 100%), 1fr)); gap: 12px; }+ .cp-card { padding: 16px 18px; border-radius: var(--radius-md, 10px); background: var(--surface-1); border: 1px solid var(--stroke); transition: border-color var(--duration-fast) var(--ease-standard), background var(--duration-fast) var(--ease-standard); }+ a.cp-card { display: block; text-decoration: none; }+ a.cp-card:hover { border-color: var(--stroke-strong); background: var(--surface-2); }+ a.cp-card:active { transform: translateY(1px); }+ .cp-card h3 { margin: 0 0 6px; font-size: 1rem; color: var(--ink-bright, var(--ink)); overflow-wrap: anywhere; }+ .cp-card p { margin: 0; color: var(--ink-dim); line-height: 1.55; font-size: 0.9rem; overflow-wrap: anywhere; }+ .cp-big { font-size: 1.5rem; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--ink-bright, var(--ink)); }+ .cp-rules { margin: 0; padding-left: 20px; color: var(--ink); line-height: 1.65; font-size: 0.95rem; }+ .cp-rules li { margin-bottom: 6px; overflow-wrap: anywhere; }+ .cp-dates { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(190px, 100%), 1fr)); min-width: 0; gap: 10px; margin: 0; }+ .cp-dates div { padding: 10px 14px; border-radius: var(--radius-md, 10px); border: 1px solid var(--stroke); background: var(--surface-1); }+ .cp-dates dt { font-size: 0.74rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-dim); }+ .cp-dates dd { margin: 2px 0 0; font-variant-numeric: tabular-nums; }++ .cp-form { display: grid; gap: 12px; max-width: 520px; padding: 18px; border-radius: var(--radius-md, 10px); background: var(--surface-1); border: 1px solid var(--stroke); }+ .cp-form label { display: grid; gap: 4px; font-size: 0.85rem; color: var(--ink-dim); font-weight: 600; }+ .cp-form input, .cp-form select { font: inherit; font-weight: 400; color: var(--ink); background: var(--bg-0); border: 1px solid var(--stroke-strong); border-radius: 8px; padding: 9px 11px; min-height: 40px; width: 100%; }+ .cp-form input:hover, .cp-form select:hover { border-color: var(--ink-dim); }+ .cp-btn { appearance: none; border: 1px solid var(--stroke-strong); background: var(--surface-3); color: var(--ink-bright, var(--ink)); font: inherit; font-size: 0.92rem; font-weight: 650; padding: 10px 16px; min-height: 40px; border-radius: 8px; cursor: pointer; text-decoration: none; display: inline-flex; justify-content: center; align-items: center; transition: background var(--duration-fast), transform var(--duration-instant); }+ .cp-btn:hover { background: var(--surface-2); }+ .cp-btn:active { transform: translateY(1px); }+ .cp-btn[disabled] { opacity: 0.55; cursor: progress; }+ .cp-msg { font-size: 0.88rem; line-height: 1.5; margin: 0; }+ .cp-msg[data-kind="error"] { color: var(--danger, #f87171); }+ .cp-msg[data-kind="ok"] { color: var(--cp-ok); }++ .cp-tablewrap { overflow-x: auto; border: 1px solid var(--stroke); border-radius: var(--radius-md, 10px); }+ .cp-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; min-width: 560px; }+ .cp-table th, .cp-table td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--stroke); vertical-align: top; overflow-wrap: anywhere; }+ .cp-table th { font-size: 0.74rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-dim); background: var(--surface-1); }+ .cp-table tr:last-child td { border-bottom: 0; }+ .cp-table tbody tr:hover { background: var(--surface-1); }+ .cp-table .num { text-align: right; font-variant-numeric: tabular-nums; }+ .cp-table a { text-decoration: underline; text-underline-offset: 3px; }+ .cp-pill { font-size: 0.72rem; padding: 2px 8px; border-radius: 999px; border: 1px solid var(--stroke-strong); color: var(--ink-dim); white-space: nowrap; }+ .cp-method { margin: 10px 2px 0; font-size: 0.82rem; color: var(--ink-dim); line-height: 1.55; }++ .cp-skel { height: 110px; border-radius: var(--radius-md, 10px); }+ .skeleton { background: var(--surface-2); background-image: linear-gradient(90deg, var(--surface-1) 0%, var(--surface-3) 50%, var(--surface-1) 100%); background-size: 200% 100%; animation: cp-shimmer 1.4s ease-in-out infinite; }+ @keyframes cp-shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }+ .cp-empty { padding: 28px 20px; border-radius: var(--radius-md, 10px); border: 1px dashed var(--stroke-strong); color: var(--ink-dim); line-height: 1.6; }+ .cp-empty strong { color: var(--ink-bright, var(--ink)); display: block; margin-bottom: 4px; }+ .cp-error { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; padding: 14px 16px; border-radius: var(--radius-md, 10px); border: 1px solid color-mix(in srgb, var(--danger) 45%, transparent); background: color-mix(in srgb, var(--danger) 9%, transparent); line-height: 1.5; font-size: 0.9rem; }+ .cp-foot { margin-top: 32px; font-size: 0.86rem; color: var(--ink-dim); line-height: 1.6; }+ @media (prefers-reduced-motion: reduce) { .skeleton { animation: none; } }+ </style>+</head>+<body>+ <header class="site-header"><div id="nav-container"></div></header>+ <script src="/nav.js"></script>++ <main class="cp-wrap" id="main">+ <div id="cp-root" aria-live="polite" aria-busy="true">+ <section class="cp-hero">+ <p class="cp-eyebrow">Builder competitions</p>+ <h1>Build an agent. Launch its coin. Climb the board.</h1>+ </section>+ <div class="cp-skel skeleton" aria-hidden="true"></div>+ </div>+ <p class="cp-foot">Entries rank by the creator fees their agent earns, read from the same data as <a href="/leaderboard?tab=earned">the earnings leaderboard</a>. How a competition is run: <a href="/docs/competitions">competition docs</a>.</p>+ </main>++ <div id="footer-container"></div>+ <script src="/footer.js"></script>+ <script type="module" src="/src/compete.js"></script>+</body>+</html>diff --git a/public/nav-data.js b/public/nav-data.jsindex df012ee97..16f2a80f3 100644--- a/public/nav-data.js+++ b/public/nav-data.js@@ -394,6 +394,12 @@ export const NAV_GROUPS = [tier: 'advanced',desc: 'What we tried, what it cost, what the numbers said and what we got wrong, with the queries behind every number',},+ {+ title: 'Builder Competitions',+ href: '/compete',+ tier: 'advanced',+ desc: 'Enter an agent, launch its coin, and rank by creator fees earned on a live leaderboard',+ },{title: 'Platform Analytics',href: '/analytics',diff --git a/src/compete.js b/src/compete.jsnew file mode 100644index 000000000..f56651ed7--- /dev/null+++ b/src/compete.js@@ -0,0 +1,234 @@+/**+ * /compete and /compete/:slug: builder competitions. Reads /api/competitions+ * (configured in data/competitions.json) and renders the index, or one+ * competition with its countdown, tracks, prizes, rules, registration form and+ * the live leaderboard. Every figure comes from the API.+ */++const root = document.getElementById('cp-root');+const slug = location.pathname.replace(/^\/compete\/?/, '').split('/')[0] || null;+let ticker = null;++const esc = (s) => String(s ?? '').replace(/[&<>"']/g, (c) => ({ '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' })[c]);+const fmtDate = (iso) => new Date(iso).toLocaleString(undefined, { dateStyle: 'medium', timeStyle: 'short' });+const fmtAmount = (n) => Number(n).toLocaleString(undefined, { maximumFractionDigits: 6 });+const PHASE_LABEL = { upcoming: 'Opens soon', open: 'Registration open', building: 'Building', ended: 'Ended' };++function setBusy(b) {+ root.setAttribute('aria-busy', String(b));+}++async function getJson(url) {+ const r = await fetch(url, { credentials: 'include' });+ const body = await r.json().catch(() => ({}));+ if (!r.ok) {+ const err = new Error(body.message || body.error_description || `request failed (${r.status})`);+ err.status = r.status;+ throw err;+ }+ return body;+}++function errorState(message, retry) {+ root.innerHTML = `<section class="cp-hero"><p class="cp-eyebrow">Builder competitions</p><h1>Could not load</h1></section>+ <div class="cp-error" role="alert"><span>${esc(message)}</span><button class="cp-btn" type="button" id="cp-retry">Retry</button></div>`;+ document.getElementById('cp-retry').addEventListener('click', retry);+ setBusy(false);+}++/* ---- index ---- */++function renderIndex(list) {+ const hero = `<section class="cp-hero"><p class="cp-eyebrow">Builder competitions</p>+ <h1>Build an agent. Launch its coin. Climb the board.</h1>+ <p>Enter an agent, launch its coin through three.ws before the deadline, and rank by the creator fees it earns. Every number on a competition page is read live from the platform.</p></section>`;+ if (!list.length) {+ root.innerHTML = `${hero}<div class="cp-empty"><strong>No competition is running right now.</strong>+ Nothing is scheduled yet. You can still <a href="/create">create an agent</a> and <a href="/launch">launch its coin</a> today, and watch what agents earn on <a href="/leaderboard?tab=earned">the earnings leaderboard</a>.</div>`;+ setBusy(false);+ return;+ }+ root.innerHTML = `${hero}<div class="cp-grid">${list+ .map(+ (c) => `<a class="cp-card" href="/compete/${encodeURIComponent(c.slug)}">+ <span class="cp-phase" data-phase="${esc(c.phase)}">${esc(PHASE_LABEL[c.phase])}</span>+ <h3>${esc(c.title)}</h3>+ <p>${esc(c.summary || `${fmtDate(c.starts_at)} to ${fmtDate(c.ends_at)}`)}</p></a>`,+ )+ .join('')}</div>`;+ setBusy(false);+}++async function loadIndex() {+ try {+ renderIndex((await getJson('/api/competitions')).competitions);+ } catch (e) {+ errorState(`The competition list could not be loaded: ${e.message}`, loadIndex);+ }+}++/* ---- detail ---- */++function countdownHtml(deadline) {+ if (!deadline) return '';+ return `<div class="cp-count" role="timer" aria-label="${esc(deadline.label)}">+ <div class="cp-count-label">${esc(deadline.label)} <span id="cp-when">${esc(fmtDate(deadline.at))}</span></div>+ ${['d', 'h', 'm', 's'].map((u) => `<div class="cp-unit"><b id="cp-${u}">0</b><span>${{ d: 'days', h: 'hours', m: 'min', s: 'sec' }[u]}</span></div>`).join('')}+ </div>`;+}++function startTicker(deadline, onZero) {+ clearInterval(ticker);+ if (!deadline) return;+ const target = Date.parse(deadline.at);+ const tick = () => {+ const left = Math.max(0, target - Date.now());+ const parts = { d: Math.floor(left / 864e5), h: Math.floor(left / 36e5) % 24, m: Math.floor(left / 6e4) % 60, s: Math.floor(left / 1e3) % 60 };+ for (const [k, v] of Object.entries(parts)) {+ const el = document.getElementById(`cp-${k}`);+ if (el) el.textContent = String(v);+ }+ if (left === 0) {+ clearInterval(ticker);+ onZero();+ }+ };+ tick();+ ticker = setInterval(tick, 1000);+}++function leaderboardHtml(d) {+ const { entries } = d;+ if (!entries.length) {+ return `<div class="cp-empty"><strong>No entries yet.</strong>${d.competition.registration_open ? 'Be the first: register an agent above.' : 'Registration is not open, so the board is empty.'}</div>`;+ }+ return `<div class="cp-tablewrap"><table class="cp-table"><thead><tr><th scope="col">#</th><th scope="col">Agent</th><th scope="col">Team</th><th scope="col">Coin</th><th scope="col" class="num">Creator fees</th></tr></thead><tbody>+ ${entries+ .map(+ (e) => `<tr><td>${e.rank ?? '<span class="cp-pill">not launched</span>'}</td>+ <td><a href="${esc(e.agent.url)}">${esc(e.agent.name)}</a>${e.track ? `<br><small>${esc(e.track)}</small>` : ''}</td>+ <td>${esc(e.team_name || '')}${e.x_handle ? `<br><a href="https://x.com/${encodeURIComponent(e.x_handle)}" rel="noopener noreferrer">@${esc(e.x_handle)}</a>` : ''}</td>+ <td>${e.coin ? `<a href="${esc(e.coin.url)}">${esc(e.coin.symbol ? `$${e.coin.symbol}` : e.coin.name || 'Coin')}</a>` : '<span class="cp-pill">none yet</span>'}</td>+ <td class="num">${e.fees_sol == null ? '' : `${fmtAmount(e.fees_sol)} SOL`}</td></tr>`,+ )+ .join('')}</tbody></table></div>+ <p class="cp-method">${esc(d.method)}${d.refreshed_at ? ` Fee data refreshed ${esc(fmtDate(d.refreshed_at))}.` : ''}</p>`;+}++async function registerFormHtml(d) {+ const c = d.competition;+ if (!c.registration_open) return '';+ if (!d.viewer.signed_in) {+ return `<div class="cp-empty"><strong>Sign in to enter.</strong><a href="/login?next=${encodeURIComponent(location.pathname)}">Sign in</a> with the account that owns your agent.</div>`;+ }+ let agents = [];+ try {+ agents = (await getJson('/api/agents')).agents || [];+ } catch {+ return `<div class="cp-error" role="alert"><span>Your agents could not be loaded.</span><button class="cp-btn" type="button" onclick="location.reload()">Retry</button></div>`;+ }+ const open = agents.filter((a) => !d.viewer.entered_agent_ids.includes(a.id));+ if (!agents.length) {+ return `<div class="cp-empty"><strong>You need an agent to enter.</strong><a href="/create">Create one</a>, then come back.</div>`;+ }+ if (!open.length) return `<div class="cp-empty"><strong>You are in.</strong>Every one of your agents is already entered.</div>`;+ return `<form class="cp-form" id="cp-form" novalidate>+ <label>Agent<select name="agent_id" required>${open.map((a) => `<option value="${esc(a.id)}">${esc(a.name)}${a.is_public === false ? ' (private)' : ''}</option>`).join('')}</select></label>+ ${c.tracks.length ? `<label>Track<select name="track" required>${c.tracks.map((t) => `<option value="${esc(t.name)}">${esc(t.name)}</option>`).join('')}</select></label>` : ''}+ <label>Team name<input name="team_name" maxlength="80" autocomplete="off" /></label>+ <label>X handle<input name="x_handle" maxlength="16" placeholder="@yourhandle" autocomplete="off" /></label>+ <button class="cp-btn" type="submit">Enter the competition</button>+ <p class="cp-msg" id="cp-msg" role="status"></p>+ </form>`;+}++function wireForm(c, reload) {+ const form = document.getElementById('cp-form');+ if (!form) return;+ form.addEventListener('submit', async (ev) => {+ ev.preventDefault();+ const msg = document.getElementById('cp-msg');+ const btn = form.querySelector('button[type="submit"]');+ const data = Object.fromEntries(new FormData(form));+ for (const k of Object.keys(data)) if (data[k] === '') delete data[k];+ btn.disabled = true;+ msg.dataset.kind = '';+ msg.textContent = 'Submitting...';+ try {+ const cr = await fetch('/api/csrf-token', { credentials: 'include' });+ const token = cr.ok ? (await cr.json()).token : null;+ const r = await fetch(`/api/competitions/${encodeURIComponent(c.slug)}/entries`, {+ method: 'POST',+ credentials: 'include',+ headers: { 'content-type': 'application/json', ...(token ? { 'x-csrf-token': token } : {}) },+ body: JSON.stringify(data),+ });+ const body = await r.json().catch(() => ({}));+ if (!r.ok) throw new Error(body.message || body.error_description || `entry failed (${r.status})`);+ msg.dataset.kind = 'ok';+ msg.textContent = 'You are entered. Launch the agent coin before the tokenize deadline to appear ranked.';+ setTimeout(reload, 900);+ } catch (e) {+ msg.dataset.kind = 'error';+ msg.textContent = e.message;+ btn.disabled = false;+ }+ });+}++function winnersHtml(d) {+ const c = d.competition;+ if (c.phase !== 'ended') return '';+ const byId = new Map(d.entries.map((e) => [e.agent.id, e]));+ if (!c.winners.length) return `<section class="cp-section"><h2>Winners</h2><div class="cp-empty"><strong>Winners have not been announced.</strong>Judging is under way.</div></section>`;+ return `<section class="cp-section"><h2>Winners</h2><div class="cp-grid">${c.winners+ .map((w) => {+ const e = byId.get(w.agent_id);+ return `<div class="cp-card"><h3>${esc(w.place)}</h3><p>${e ? `<a href="${esc(e.agent.url)}">${esc(e.agent.name)}</a>` : esc(w.agent_id)}${w.note ? `<br>${esc(w.note)}` : ''}</p></div>`;+ })+ .join('')}</div></section>`;+}++async function renderDetail(d, reload) {+ const c = d.competition;+ const form = await registerFormHtml(d);+ root.innerHTML = `<section class="cp-hero">+ <span class="cp-phase" data-phase="${esc(c.phase)}">${esc(PHASE_LABEL[c.phase])}</span>+ <h1>${esc(c.title)}</h1>+ ${c.summary ? `<p>${esc(c.summary)}</p>` : ''}+ ${countdownHtml(c.next_deadline)}+ </section>+ <section class="cp-section" aria-label="Schedule"><dl class="cp-dates">+ <div><dt>Registration opens</dt><dd>${esc(fmtDate(c.starts_at))}</dd></div>+ <div><dt>Registration closes</dt><dd>${esc(fmtDate(c.register_by))}</dd></div>+ <div><dt>Coin launched by</dt><dd>${esc(fmtDate(c.tokenize_by))}</dd></div>+ <div><dt>Ends</dt><dd>${esc(fmtDate(c.ends_at))}</dd></div></dl></section>+ ${winnersHtml(d)}+ ${c.prizes.length ? `<section class="cp-section"><h2>Prizes</h2><div class="cp-grid">${c.prizes.map((p) => `<div class="cp-card"><h3>${esc(p.place)}</h3><div class="cp-big">${esc(fmtAmount(p.amount))} ${esc(p.asset)}</div>${p.vesting ? `<p>${esc(p.vesting)}</p>` : ''}</div>`).join('')}</div></section>` : ''}+ ${c.tracks.length ? `<section class="cp-section"><h2>Tracks</h2><div class="cp-grid">${c.tracks.map((t) => `<div class="cp-card"><h3>${esc(t.name)}</h3><p>${esc(t.description)}</p></div>`).join('')}</div></section>` : ''}+ ${c.judges.length ? `<section class="cp-section"><h2>Judges</h2><div class="cp-grid">${c.judges.map((j) => `<div class="cp-card"><h3>${j.url ? `<a href="${esc(j.url)}" rel="noopener noreferrer">${esc(j.name)}</a>` : esc(j.name)}</h3>${j.role ? `<p>${esc(j.role)}</p>` : ''}</div>`).join('')}</div></section>` : ''}+ ${c.rules.length ? `<section class="cp-section"><h2>Rules</h2><ol class="cp-rules">${c.rules.map((r) => `<li>${esc(r)}</li>`).join('')}</ol></section>` : ''}+ ${form ? `<section class="cp-section"><h2>Enter</h2>${form}</section>` : ''}+ <section class="cp-section"><h2>Leaderboard</h2>${leaderboardHtml(d)}</section>`;+ document.title = `${c.title} · three.ws`;+ setBusy(false);+ wireForm(c, reload);+ startTicker(c.next_deadline, reload);+}++async function loadDetail() {+ try {+ await renderDetail(await getJson(`/api/competitions/${encodeURIComponent(slug)}`), loadDetail);+ } catch (e) {+ if (e.status === 404) {+ root.innerHTML = `<section class="cp-hero"><p class="cp-eyebrow">Builder competitions</p><h1>Competition not found</h1></section>+ <div class="cp-empty"><strong>There is no competition called "${esc(slug)}".</strong>See <a href="/compete">all competitions</a>.</div>`;+ setBusy(false);+ return;+ }+ errorState(`This competition could not be loaded: ${e.message}`, loadDetail);+ }+}++if (slug) loadDetail();+else loadIndex();diff --git a/vercel.json b/vercel.jsonindex 17f0c28ea..3519cf01e 100644--- a/vercel.json+++ b/vercel.json@@ -463,6 +463,26 @@"src": "/analytics/?","dest": "/analytics.html"},+ {+ "src": "/compete/?",+ "dest": "/compete.html"+ },+ {+ "src": "/compete/([^/]+)/?",+ "dest": "/compete.html"+ },+ {+ "src": "/api/competitions/?",+ "dest": "/api/competitions.js"+ },+ {+ "src": "/api/competitions/([^/]+)/entries/?",+ "dest": "/api/competitions.js?slug=$1&part=entries"+ },+ {+ "src": "/api/competitions/([^/]+)/?",+ "dest": "/api/competitions.js?slug=$1"+ },{"src": "/why-three-ws/?","dest": "/why-three-ws.html"diff --git a/vite.config.js b/vite.config.jsindex db6a7d8eb..5f113695d 100644--- a/vite.config.js+++ b/vite.config.js@@ -939,6 +939,7 @@ const appConfig = {analytics: resolve(__dirname, 'pages/analytics.html'),'why-three-ws': resolve(__dirname, 'pages/why-three-ws.html'),experiments: resolve(__dirname, 'pages/experiments.html'),+ compete: resolve(__dirname, 'pages/compete.html'),economy: resolve(__dirname, 'pages/economy.html'),'overlay-control': resolve(__dirname, 'pages/overlay-control.html'),'mocap-studio': resolve(__dirname, 'pages/mocap-studio.html'),@@ -1947,6 +1948,8 @@ const appConfig = {'/fees/': resolve(root, 'pages/fees.html'),'/sniper/experiments': resolve(root, 'pages/sniper-experiments.html'),'/sniper/experiments/': resolve(root, 'pages/sniper-experiments.html'),+ '/compete': resolve(root, 'pages/compete.html'),+ '/compete/': resolve(root, 'pages/compete.html'),'/dex-volumes': resolve(root, 'pages/dex-volumes.html'),'/dex-volumes/': resolve(root, 'pages/dex-volumes.html'),'/hacks': resolve(root, 'pages/hacks.html'),@@ -2503,6 +2506,8 @@ const appConfig = {filePath = resolve(root, 'pages/earnings.html');else if (!filePath && /^\/agents\/[^/.]+\/earnings\/?$/.test(path))filePath = resolve(root, 'pages/agent-earnings.html');+ else if (!filePath && /^\/compete\/[^/.]+\/?$/.test(path))+ filePath = resolve(root, 'pages/compete.html');// /launch/intents/:id → one funded pump.fun launch intent (quote, funding,// confirmation, stage tracker). Mirrors vercel.json's// `/launch/intents/([^/.]+)/?`; the list itself is /launch/intents.