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
chore: prune stale docs (prompts, club)
nirholas278b36e56aa5
diff --git a/docs/club/PERF_NOTES.md b/docs/club/PERF_NOTES.mddeleted file mode 100644index 1b44ec4be..000000000--- a/docs/club/PERF_NOTES.md+++ /dev/null@@ -1,124 +0,0 @@-# /club — performance notes--The pole-club scene is a hot path: four spotlights, four rigged dancers,-bloom + chromatic aberration on the high tier, plus the mirror-ball cube-cam. To keep it usable on a mid-range phone we pick a render profile-once at boot from real capability signals, then re-apply on demand-mid-session if a frame-budget watchdog detects sustained slow frames.--## Profile tiers--Defined in [`src/club-perf.js`](../../src/club-perf.js). Profiles gate-flags on the renderer, lights, and any future scene additions (mirror-ball, volumetric cones, crowd, postFX). The detector reads:--- `navigator.userAgent` — mobile UA match only-- `navigator.deviceMemory` — RAM (missing on Safari → defaults to 8 GB)-- `navigator.hardwareConcurrency` — CPU thread count-- `matchMedia('(pointer: coarse)')` — touch input as a fallback signal--| Tier | pixelRatio | shadows | bloom | chromaticAberration | mirrorBall | cubeCam | volumetricCones | crowdInstances | discoLights |-|--------|------------|---------|-------|---------------------|------------|---------|------------------|----------------|-------------|-| high | min(dpr,2) | yes | yes | yes | yes | yes | yes | 80 | 4 |-| medium | min(dpr,1.5)| yes | yes | no | yes | no | yes | 40 | 4 |-| low | 1.0 | no | no | no | no | no | no | 12 | 2 |--The chosen profile is exposed on `window.__clubProfile` so other scene-modules (the venue loader, post-FX composer, mirror-ball builder) can-read it without an import cycle.--## Frame-budget watchdog--Lives in the same file. The render loop calls `watchdog.tick(dt)` once-per frame. It keeps an EMA of frame time; when the EMA stays above-`1/28s` (≈35.7 ms, or roughly 28 fps) for >2 seconds, it drops one-tier and emits a `console.info('[club] downgrading profile to ...')`.-It never auto-upgrades — a recovery usually means the user moved away-from a busy moment, and we'd rather stay safe than risk a re-thrash.--The downgrade re-applies cheap render-state flags:--- `renderer.setPixelRatio(next.pixelRatio)`-- `renderer.shadowMap.enabled = next.shadows`-- per-pole `spot.castShadow` matches the new tier-- excess disco lights are removed from the scene--Features built once at boot (mirror ball geometry, volumetric cone-meshes) stay constructed — tearing down GPU resources mid-flight-itself spikes frame time, which would defeat the purpose.--## Visibility pause--The animate loop cancels its `requestAnimationFrame` on-`document.hidden`, and the leaderboard polling timer also stops. On-resume we discard the gap delta from `THREE.Clock` so the watchdog-doesn't see one huge frame on the first tick.--## Asset budget--Combined first-load budget after prompts 01–04:--| Asset | Cap |-|---------------------------|----------------|-| `club-venue.glb` | 8 MB compressed |-| 4× dancer GLBs | 8 MB total |-| `pole.glb` + `stage.glb` | 1 MB |-| `mirrorball.glb` | 200 KB |-| HDRI | 2 MB |-| Animation clip JSON | ~150 KB / clip, lazy |-| Audio | ~1 MB / track, lazy |-| JS bundle (Vite, gzip) | ≤500 KB |--Total eager budget ≈ 20 MB. On a 3 Mbps mobile link that's ≈7 s wall-clock; with Vite's preload + HTTP/2 multiplexing, plausibly <5 s.--## Mobile layout--[`pages/club.html`](../../pages/club.html) keeps the existing-`max-width: 800px` breakpoint but switches the right panel into a-fixed-position bottom sheet:--- A 44 pt drag handle at the top toggles `.is-expanded` on the panel;- CSS `transform: translateY(...)` animates the slide. No JS gesture- library — a single tap is enough.-- The leaderboard is wrapped in `<details>` and starts collapsed on- mobile (kept open on desktop via JS that listens for- `matchMedia('(max-width: 800px)')` changes).-- VIP cam buttons (`.club-cam-btn`) and tip CTAs get a 44×44 min size- per Apple HIG / Material guidelines.-- The canvas has `touch-action: none` (orbit + pinch own gestures);- the panel has `touch-action: pan-y` so vertical scroll on the tip- feed isn't intercepted.--## Device matrix (manual end-to-end)--| Device | Profile picked | Observed fps | Notes |-|-------------------------------------|----------------|--------------|-------|-| MacBook Pro M2 / Chrome 120 | high | 60 | All effects on; bloom + cube cam + cones visible. |-| MacBook Pro M2 / Safari 17 | high | 60 | Cube cam works. |-| iPhone 12 / Safari 17 | medium | ≥30 | Mirror ball uses static reflection (cubeCam off). |-| Pixel 6 / Chrome 120 | medium | ≥30 | Bloom on, chromatic aberration off. |-| iPad Pro 11" / Safari 17 | medium | 45–60 | Coarse pointer triggers medium even with high specs. |-| 2020 Chromebook (Celeron 4 GB) | low | ≥30 | No shadows, no bloom; watchdog occasionally trims. |-| Galaxy A52 / Chrome 120 | low | ≥30 | Detected via deviceMemory < 4. |--Numbers are wall-clock observations from manual testing; the watchdog-console line (`[club] downgrading profile to <tier>`) is the source of-truth when investigating a remote-screenshot bug report.--## Adding a new feature--When prompts 05+ add scene features, gate them on the active profile:--```js-import { PROFILES } from './club-perf.js';-const profile = window.__clubProfile ?? PROFILES.medium;-if (profile.volumetricCones) {- // build the cone mesh-}-```--If your feature can be cheaply disabled per-frame (e.g. a render-target-pass), also add an early-return in your update tick keyed on the-current `window.__clubProfile` — that way mid-session downgrades drop-the cost without rebuilding GPU resources.diff --git a/docs/club/PLAN.md b/docs/club/PLAN.mddeleted file mode 100644index 132712b30..000000000--- a/docs/club/PLAN.md+++ /dev/null@@ -1,242 +0,0 @@-# Pole Club — Build-Out Plan--The `/club` page at [pages/club.html](../../pages/club.html) and-[src/club.js](../../src/club.js) currently runs on Three.js primitives:-cylinders for poles, circles for stages, neon rings, four clones of-`/avatars/default.glb`, and the generic dance clips already in-`/animations/manifest.json`. The paid x402 endpoint-[api/x402/dance-tip.js](../../api/x402/dance-tip.js) is wired and-indexed by the bazaar; tipping triggers a real settlement, returns a-ticket, and a stand-in dancer walks the rig from "backstage" to the-pole.--This plan tracks what's required to turn that placeholder rig into a-fully wired, professional 3D venue with distinct dancers, real pole-choreography, club lighting + audio, server-side tip persistence, and-per-dancer leaderboards/payouts. No primitives shipped to prod; no-synthesized art; no `setTimeout`-faked timing.--Each task lives as a self-contained prompt under [prompts/club/](../../prompts/club/).-Run them in any order — each restates its own context.--## Hard rails (from [CLAUDE.md](../../CLAUDE.md))--- No mocks, no fake data, no placeholders, no TODOs, no stubs.-- Real APIs, real animations, real GLBs, real audio.-- Errors handled at boundaries only.-- Done = wired in the UI, exercised in a real browser, no console- errors, `npm test` green, `git diff` reviewed.-- Push to **both** remotes (`threeD` → `nirholas/3D-Agent`,- `threews` → `nirholas/three.ws`) only when the user says push.--## Scope — the venue--| Element | Today | Target |-|---|---|---|-| Walls / floor / ceiling | `PlaneGeometry` + `CircleGeometry` + `MeshStandardMaterial` | Authored `club-venue.glb` with PBR materials, baked AO, real architectural detail (girders, ceiling beams, ducts, alcoves) |-| Bar | A single flat plane | A bar GLB with bottles, glassware, neon backsplash, animated bartender or static idle figure |-| Dance floor | Emissive circle | Lit panel floor (animated emissive tiles), reflective varnish, scuff/wear baked in |-| Crowd | None | Low-poly cheering crowd silhouettes lining the perimeter (instanced) + occasional VIP figures in alcoves |-| Backstage | Invisible offstage point | A visible curtain/door GLB the dancer emerges from |-| Skybox | Solid `#07050b` | HDRI of a dim club ceiling with disco-ball highlight + low key red/magenta cast |--→ [prompts/club/01-venue-glb-and-environment.md](../../prompts/club/01-venue-glb-and-environment.md)--## Scope — the dancers--Each of the four pole slots needs a **distinct authored dancer GLB**,-not a cloned default avatar. Outfits, hair, body shape, skin tone, and-accent palette must read differently across slots. All four share the-canonical Avaturn skeleton so the existing animation JSON clips drive-them without retargeting at runtime.--- `public/club/dancers/dancer-01.glb` — neon pink palette-- `public/club/dancers/dancer-02.glb` — cyan palette-- `public/club/dancers/dancer-03.glb` — amber palette-- `public/club/dancers/dancer-04.glb` — violet palette--Bound at runtime via a small registry that maps slot → GLB URL +-display name + bio + tip wallet.--→ [prompts/club/02-dancer-glbs.md](../../prompts/club/02-dancer-glbs.md)--## Scope — the pole rig + pole choreography--The cylinder pole prop becomes a textured pole GLB with a flared base-and a ceiling-mounted top. A small spotlight rig hangs off the ceiling-mount.--The current dance clips (`rumba`, `silly`, `thriller`, `capoeira`,-`hiphop`) aren't pole choreography — they're free-floor Mixamo clips.-Add pole-specific clips:--- `pole-walk-on` — entry routine from backstage-- `pole-spin` — single revolution, looping-- `pole-climb` — climb to mid-pole-- `pole-invert` — upside-down hang-- `pole-floorwork` — return to ground crawl-- `pole-bow` — exit bow--Each clip authored from Mixamo or freely-licensed mocap, retargeted by-[scripts/build-animations.mjs](../../scripts/build-animations.mjs) (or-its successor), output to `public/animations/clips/pole-*.json`,-registered in `public/animations/manifest.json`, exposed via the-`dance-tip` endpoint's `STYLES` map.--The `dance-tip` endpoint adds new style keys (`spin`, `climb`,-`invert`, `floor`, `combo`) that map to clip sequences played back to-back during the performance window.--→ [prompts/club/03-pole-rig-and-pole-animations.md](../../prompts/club/03-pole-rig-and-pole-animations.md)--## Scope — lighting + post-processing--- Volumetric spotlights with visible cones (god-rays through fog- density volume) — one per pole, color from `POLE_COLORS`.-- A real mirror ball with cube-camera reflections that scatter dots- across the floor and walls.-- RGB strip lights along the bar edge + ceiling rails (instanced- `LineSegments` with bloom).-- Animated rim lights that pulse on the beat of the active dancer's- music track.-- Bloom + vignette + filmic tone mapping via `EffectComposer` from- `three/addons/postprocessing/*`. Optional subtle chromatic- aberration during high-energy clips (`thriller`, `pole-spin`).-- Real fog volume (the existing `Fog` is fine as a baseline) tuned- for visibility through god-rays without obscuring dancers.--→ [prompts/club/04-lighting-and-postfx.md](../../prompts/club/04-lighting-and-postfx.md)--## Scope — audio + music--- Background club ambience (crowd murmur, low rumble, occasional- glass clinks) looping at –24 LUFS via Web Audio API.-- Per-style music tracks under `public/club/audio/<style>.mp3` (or- `.ogg`) — short loopable cuts (~30-60s) licensed CC-BY or- public-domain. Each `STYLE` in `api/x402/dance-tip.js` adds a- `track` field pointing at the audio file.-- Crossfade ambience ↓ + style track ↑ when a dancer starts- performing. Reverse on exit.-- Master mute / volume controls in the right panel.-- Optional: WebAudio analyser feeding a beat-detection pulse into the- rim lighting in prompt 04.--→ [prompts/club/05-audio-and-music.md](../../prompts/club/05-audio-and-music.md)--## Scope — camera + interaction--- Free orbit (current) as default.-- Click a pole-card → camera dollies to a VIP shot of that pole- (front + low + slight tilt up). Escape returns to free orbit.-- `1` / `2` / `3` / `4` keys jump to each pole's VIP shot.-- `0` key returns to overhead "house" cam (top-down, gentle yaw).-- Smooth interpolated transitions, no teleports.-- Touch controls: tap a pole-card on mobile, drag to orbit, pinch to- zoom.--→ [prompts/club/06-camera-and-controls.md](../../prompts/club/06-camera-and-controls.md)--## Scope — server-backed live tip feed--Today the feed lives in-memory in the browser tab — refresh wipes it,-other visitors can't see your tips. Persist:--- Schema migration: `club_tips (id uuid pk, ticket_id text, dancer- text, dance text, label text, payer text, network text,- amount_atomics numeric, asset text, started_at timestamptz,- ends_at timestamptz, created_at timestamptz default now())`.-- The `dance-tip` paid endpoint, on a settled payment, inserts a row.-- New endpoint `GET /api/club/tips?limit=20` returns recent rows.-- New SSE endpoint `GET /api/club/tips/stream` pushes new rows live.-- `/club` page renders the SSE stream into the right panel and- preloads the last 20 on boot.--→ [prompts/club/07-tip-feed-realtime.md](../../prompts/club/07-tip-feed-realtime.md)--## Scope — per-dancer leaderboard + payout sweep--- Schema: `club_dancer_wallets (dancer text pk, evm_address text,- solana_address text, label text, bio text)`.-- Aggregate view: `club_leaderboard` materialized view computing- per-dancer tip count and atomic sum for `last_hour`, `last_day`,- `all_time`.-- New endpoint `GET /api/club/leaderboard` returns it.-- Right-panel leaderboard widget rendering live ranks.-- Cron `api/cron/[name].js` handler `club-payouts`: every N minutes,- sums unpaid tips per dancer, sends payout via existing Solana /- EVM payout rails (see `api/payments/*`), records the payout- signature, marks tips paid.--→ [prompts/club/08-leaderboard-and-payouts.md](../../prompts/club/08-leaderboard-and-payouts.md)--## Scope — mobile + low-perf path--- Detect low-perf devices via `navigator.deviceMemory` / `hardwareConcurrency` / pointer type.-- Drop shadow map size, disable bloom + cube-cam reflections, halve- pixel ratio, skip the mirror ball animation, switch fog to linear.-- Single-pole VIP cam locks become the default layout on screens- <768px (no orbit drag).-- Test: real iPhone Safari + Pixel Chrome. Frame rate ≥30fps locked.--→ [prompts/club/09-mobile-and-perf.md](../../prompts/club/09-mobile-and-perf.md)--## Scope — end-to-end tests + verification--- Unit: `tests/api/club-tip.test.js` covers `dance-tip` handler — all- styles, all dancers, error paths.-- Unit: `tests/api/club-feed.test.js` covers `/api/club/tips` +- SSE handshake.-- Unit: `tests/club-leaderboard.test.js` covers the materialized- view query and payout sweep math.-- Playwright smoke: `tests/e2e/club.spec.js` boots `npm run dev`,- visits `/club`, stubs the x402 settle (network intercept), asserts- a dancer walks to the pole and the named clip plays.-- Manual: tip from a real Phantom wallet on Solana mainnet, watch- the on-chain confirmation, see the dancer perform.--→ [prompts/club/10-e2e-tests-and-verification.md](../../prompts/club/10-e2e-tests-and-verification.md)--## Asset pipeline--GLBs (venue, dancers, props) authored in Blender, exported with Draco-mesh compression and KTX2 texture compression (see-[prompts/finish-features/add-mesh-compression-deps.md](../../prompts/finish-features/add-mesh-compression-deps.md)-for the loader wiring). All animation clips bake from Mixamo FBX-through the existing-[scripts/build-animations.mjs](../../scripts/build-animations.mjs)-retarget pass; output JSON is committed under-`public/animations/clips/`.--Audio cuts trimmed in Audacity, encoded to OGG Vorbis q4 and MP3 192k-side-by-side; `<audio>` element picks the supported one. License-provenance recorded in `public/club/audio/LICENSES.md`.--## Integration map--| New thing | Touches |-|---|---|-| Venue GLB | [src/club.js](../../src/club.js) bootstrap + scene replacement |-| Dancer GLBs | [src/club.js](../../src/club.js) `PoleStation.attachAvatar` + new dancer registry |-| Pole rig GLB | [src/club.js](../../src/club.js) pole primitive replacement |-| Pole clips | [public/animations/manifest.json](../../public/animations/manifest.json), `STYLES` in [api/x402/dance-tip.js](../../api/x402/dance-tip.js) |-| Lighting + postfx | [src/club.js](../../src/club.js) renderer + light setup |-| Audio | New `src/club-audio.js`, right-panel UI in [pages/club.html](../../pages/club.html) |-| Camera | New `src/club-camera.js`, [src/club.js](../../src/club.js) animate loop |-| Tip feed (SSE) | New `api/club/tips.js`, [api/x402/dance-tip.js](../../api/x402/dance-tip.js) `handler`, [src/club.js](../../src/club.js) feed render |-| Leaderboard + payouts | New `api/club/leaderboard.js`, `api/cron/[name].js` new branch, schema migration |-| Tests | New `tests/api/club-*.test.js`, `tests/e2e/club.spec.js` |--## Done--The full feature is shippable when:--1. Every prompt under `prompts/club/` is closed.-2. `/club` loads in <3s on broadband desktop, <6s on 4G mobile.-3. A real Phantom wallet on mainnet can tip a dancer end-to-end with- no console errors, the dancer performs the chosen routine with- pole choreography, the tip lands in the live feed across all open- browser tabs, the leaderboard updates, and the dancer's wallet- receives the payout within the cron window.-4. `npm test` green.-5. Playwright smoke green.-6. Both remotes pushed.diff --git a/docs/club/RELEASE_CHECKLIST.md b/docs/club/RELEASE_CHECKLIST.mddeleted file mode 100644index 54d88c665..000000000--- a/docs/club/RELEASE_CHECKLIST.md+++ /dev/null@@ -1,49 +0,0 @@-# /club release checklist--Run on a clean checkout after `npm install && npm run build`. This file is-human-signed; CI does not check it.--## Local smoke-- [ ] `npm run dev` boots, `/club` loads under 5s on broadband.-- [ ] Venue renders authored GLB, no console errors.-- [ ] All four dancers visible at backstage doors.-- [ ] `npm test` green (unit + e2e).-- [ ] `npm run test:e2e` green standalone.--## Real wallet (mainnet)-- [ ] Connect Phantom on Solana. Tip pole 1 for $0.001 USDC.-- [ ] On-chain confirmation in Solscan within 5s.-- [ ] Dancer 1 walks from backstage to pole.-- [ ] Music for the chosen style fades up; ambience fades down.-- [ ] Volumetric spotlight cone ramps up.-- [ ] Tip row appears in the right-panel feed.-- [ ] Open `/club` in a second browser; same tip row appears via SSE.--## Cron payouts-- [ ] Repeat tips until dancer 1's unpaid total exceeds 0.005 USDC.-- [ ] Trigger `/api/cron/club-payouts` with `CRON_SECRET`.-- [ ] On-chain payout signature recorded in `club_payouts`.-- [ ] `club_tips.paid_at` set on swept rows.-- [ ] Leaderboard "unpaid" column drops for dancer 1.--## Mobile-- [ ] iPhone 12 Safari: profile `medium`, ≥30 fps.-- [ ] Pixel 6 Chrome: profile `medium`, ≥30 fps.--## Deploy-- [ ] Vercel preview deploy of the branch passes both x402 endpoints- reachable + SSE keepalive.-- [ ] Promote to production.-- [ ] Verify production OG card renders for `/club` via Twitter card- validator.-- [ ] Verify x402 bazaar discovery: `curl -i https://three.ws/api/x402/dance-tip`- returns 402 with the discovery extension intact.--## Secrets — reference only-Never commit secret values to this file. The mainnet checklist relies on:--- `PHANTOM_TEST_WALLET` (held by the release engineer; not stored in repo).-- `CRON_SECRET` (Vercel env: `vercel env pull` to read locally).-- `SOLANA_RPC_URL`, `BASE_RPC_URL` (Vercel env).-- Treasury keypair env vars used by `/api/cron/club-payouts` (see- `vercel env ls`).diff --git a/docs/prompts/monetization/02-purchase-skill-button.md b/docs/prompts/monetization/02-purchase-skill-button.mddeleted file mode 100644index 457b7c9b1..000000000--- a/docs/prompts/monetization/02-purchase-skill-button.md+++ /dev/null@@ -1,74 +0,0 @@-----status: not-started-----# Prompt 2: Add Purchase Button for Priced Skills--## Objective-In the agent detail page, replace the price badge for unowned, paid skills with a "Purchase" button to initiate the buying process.--## Explanation-Displaying the price is the first step. Now, we need to give users a clear call-to-action to buy the skill. This prompt focuses on changing the UI to be interactive. The actual payment flow will be handled in subsequent prompts.--## Instructions-1. **Check Ownership:**- * The frontend needs to know which skills the current user already owns. Create a new API endpoint (e.g., `/api/users/me/purchased-skills`) that returns a list of skill IDs owned by the authenticated user.- * In `src/marketplace.js`, fetch the list of purchased skills when the component mounts.--2. **Conditionally Render Button:**- * Inside the `renderDetail` function, modify the skill rendering loop.- * For each skill, determine its state: free, paid and owned, or paid and unowned.- * - If free, show the "Free" badge.- * - If paid and owned, show an "Owned" badge.- * - If paid and unowned, show a "Purchase" button with the price.--3. **Button Styling:**- * Style the "Purchase" button to be a prominent call-to-action.- * Style the "Owned" badge to give the user clear feedback.--## Code Example (Frontend - `src/marketplace.js`)-```javascript-// Inside renderDetail function, assuming `ownedSkills` is a Set of skill names--const skillPrices = a.skill_prices || {};-$('d-skills').innerHTML = skillsArr.map(s => {- const name = typeof s === 'string' ? s : (s.name || '');- const price = skillPrices[name];- const isOwned = ownedSkills.has(name);- let badge = '';-- if (price && !isOwned) {- badge = `<button class="purchase-btn" data-skill-name="${escapeHtml(name)}">${(price.amount / 1e6).toFixed(2)} USDC</button>`;- } else if (price && isOwned) {- badge = `<span class="price-badge price-owned">Owned</span>`;- } else {- badge = `<span class="price-badge price-free">Free</span>`;- }- return `<span class="skill-entry">${escapeHtml(name)}${badge}</span>`;-}).join(' ');-```--## CSS Example (`/marketplace.css`)-```css-.purchase-btn {- background-color: #5a67d8;- color: white;- border: none;- padding: 4px 10px;- font-size: 11px;- font-weight: 600;- border-radius: 4px;- cursor: pointer;- margin-left: 8px;- vertical-align: middle;- transition: background-color 0.2s;-}--.purchase-btn:hover {- background-color: #434190;-}--.price-owned {- color: #9ae6b4;- background-color: rgba(72, 187, 120, 0.1);-}-```diff --git a/docs/prompts/monetization/03-solana-pay-integration.md b/docs/prompts/monetization/03-solana-pay-integration.mddeleted file mode 100644index 086851cb0..000000000--- a/docs/prompts/monetization/03-solana-pay-integration.md+++ /dev/null@@ -1,65 +0,0 @@-----status: not-started-----# Prompt 3: Solana Pay Integration for Skill Purchases--## Objective-Integrate Solana Pay to allow users to purchase skills using a QR code or wallet deeplink.--## Explanation-We need a robust payment mechanism. Solana Pay is a standard for on-chain payments that provides a great user experience on both desktop and mobile. When a user clicks "Purchase," we will generate a Solana Pay QR code that encodes the transaction details (recipient, amount, currency).--## Instructions-1. **Add Solana Pay Library:**- * Add the `@solana/pay` library to your frontend dependencies using npm: `npm install @solana/pay`.--2. **Create a Payment Request API:**- * Create a new backend endpoint, e.g., `/api/payments/request`.- * This endpoint should take `agentId` and `skillName` as input.- * It should look up the skill's price and the creator's payout address from the database.- * Generate a unique reference key (a new Solana public key) for the transaction and store it in a `skill_purchases` table with a `pending` status. This reference will be used for verification later.- * The endpoint should return a JSON object containing the `recipient` address, `amount`, `splToken` (mint address for USDC), and the `reference` key as a string.--3. **Generate QR Code on Frontend:**- * In `src/marketplace.js`, add a click handler to the "Purchase" buttons.- * When a button is clicked, call the `/api/payments/request` endpoint.- * Use the response data and the `@solana/pay` library to generate a Solana Pay URL.- * Display a modal with a QR code generated from this URL. The library provides utilities for this.- * The modal should also include a "Pay with Wallet" button for mobile users, which creates a `solana:PAY_URL` deeplink.--## Code Example (Frontend - `src/marketplace.js`)-```javascript-import { createQR, encodeURL } from '@solana/pay';-import { PublicKey } from '@solana/web3.js';-import BigNumber from 'bignumber.js';--// ... inside the purchase button click handler ...--const skillName = button.dataset.skillName;-const agentId = currentAgent.id;--try {- const { recipient, amount, splToken, reference } = await post('/api/payments/request', { agentId, skillName });-- const url = encodeURL({- recipient: new PublicKey(recipient),- amount: new BigNumber(amount).dividedBy(1e6), // Convert from lamports to token units- splToken: new PublicKey(splToken),- reference: new PublicKey(reference),- label: `3D-Agent Skill Purchase`,- message: `Skill: ${skillName} for Agent: ${agentId}`,- });-- // --- Render Modal with QR Code ---- const qr = createQR(url);- const modal = document.getElementById('payment-modal');- const qrContainer = modal.querySelector('.qr-code-container');- qrContainer.innerHTML = '';- qr.append(qrContainer);- modal.style.display = 'block';--} catch (error) {- console.error('Payment request failed', error);- // Show an error message to the user-}-```diff --git a/docs/prompts/monetization/04-backend-payment-verification.md b/docs/prompts/monetization/04-backend-payment-verification.mddeleted file mode 100644index e6729a5f2..000000000--- a/docs/prompts/monetization/04-backend-payment-verification.md+++ /dev/null@@ -1,71 +0,0 @@-----status: not-started-----# Prompt 4: Backend Payment Verification--## Objective-Create a backend endpoint to verify the Solana Pay transaction and confirm that the skill purchase was successful.--## Explanation-After the user completes the payment, the frontend needs to confirm with the backend that the transaction was valid. The backend will find the transaction on the Solana blockchain using the unique `reference` key we generated earlier, validate it, and update the purchase status in the database.--## Instructions-1. **Create Verification Endpoint:**- * Create a new backend endpoint, e.g., `GET /api/payments/verify`.- * It should accept the `reference` public key as a query parameter.--2. **Find and Validate Transaction:**- * Inside the endpoint, use the Solana Web3 JS library (`@solana/web3.js`) to connect to the blockchain.- * Use the `findReference` method to find the transaction signature associated with our `reference` public key.- * Once you have the signature, fetch the full transaction details.- * Verify that the transaction details (recipient, amount, SPL token mint) match the details stored in your `skill_purchases` table for the given reference. This is crucial for security.--3. **Update Database:**- * If the transaction is valid, update the corresponding record in the `skill_purchases` table. Set its status from `pending` to `completed` and associate it with the user ID.- * The endpoint should return a success message.--4. **Frontend Polling:**- * In the frontend payment modal, after displaying the QR code, start polling the `/api/payments/verify` endpoint every few seconds, sending the `reference` key.- * When the endpoint returns a success status, close the modal, show a "Purchase Successful" confirmation message, and refresh the agent detail view to show the skill as "Owned".--## Code Example (Backend - `/api/payments/verify.js`)-```javascript-import { Connection, PublicKey } from '@solana/web3.js';-import { findReference, validateTransfer } from '@solana/pay';-import BigNumber from 'bignumber.js';--// ... inside the endpoint handler ...--const { reference } = req.query;-if (!reference) {- return res.status(400).json({ error: 'Reference key is required' });-}--// 1. Get purchase details from DB-const purchase = await db.getPendingPurchaseByReference(reference);-if (!purchase) {- return res.status(404).json({ error: 'Pending purchase not found' });-}--// 2. Find transaction on-chain-const connection = new Connection(process.env.SOLANA_RPC_HOST);-const signatureInfo = await findReference(connection, new PublicKey(reference), { finality: 'confirmed' });--// 3. Validate transaction-await validateTransfer(- connection,- signatureInfo.signature,- {- recipient: new PublicKey(purchase.recipient),- amount: new BigNumber(purchase.amount).dividedBy(1e6), // Convert to token units- splToken: new PublicKey(purchase.spl_token_mint),- reference: new PublicKey(reference),- },- { commitment: 'confirmed' }-);--// 4. If validation passes, update DB-await db.markPurchaseCompleted(reference, userId);--res.status(200).json({ status: 'verified' });-```diff --git a/docs/prompts/monetization/05-unlock-skill-after-purchase.md b/docs/prompts/monetization/05-unlock-skill-after-purchase.mddeleted file mode 100644index 2451d8ad9..000000000--- a/docs/prompts/monetization/05-unlock-skill-after-purchase.md+++ /dev/null@@ -1,57 +0,0 @@-----status: not-started-----# Prompt 5: Unlock Skill After Purchase--## Objective-Ensure that once a skill is purchased and verified, the user gains immediate access to use it with the agent.--## Explanation-The final step of the core purchase flow is to "unlock" the skill. This involves updating the application's state to reflect the new ownership and making sure that the agent's runtime can now execute this skill for the user.--## Instructions-1. **Modify Skill Execution Logic:**- * Locate the core logic where an agent's skill is invoked by a user. This might be in the `Runtime` class or a similar agent-brain module.- * Before executing a skill, add a check:- * Is the skill priced?- * If so, does the current user own it?--2. **Create an Ownership Check API:**- * Create a reusable backend function or endpoint, e.g., `hasSkillAccess(userId, agentId, skillName)`.- * This function should query your database (`skill_purchases` table) to see if a `completed` purchase record exists for that user and skill.- * The skill execution logic will call this function. If the user doesn't have access, the skill execution should fail with an informative error message like "You must purchase this skill to use it."--3. **Real-time UI Updates:**- * Ensure that when the payment verification poll succeeds (from Prompt 4), the frontend state is updated immediately.- * The `ownedSkills` set from Prompt 2 should be updated with the newly purchased skill name.- * The UI should automatically re-render, changing the "Purchase" button to an "Owned" badge without requiring a page reload.--## Code Example (Backend - Agent Runtime)-```javascript-// Inside the skill execution logic of the agent's brain--async function executeSkill(userId, agentId, skillName, args) {- const skill = getSkillDefinition(skillName);- if (!skill) {- throw new Error('Skill not found.');- }-- // Check if the skill is priced- const priceInfo = await db.getSkillPrice(agentId, skillName);-- if (priceInfo) {- // If it's a paid skill, verify ownership- const hasAccess = await db.hasSkillAccess(userId, agentId, skillName);- if (!hasAccess) {- // Return a message to the user instead of throwing an error- return {- output: `You have not purchased the "${skillName}" skill. Please purchase it from the marketplace to use it.`,- isError: true,- };- }- }-- // --- If checks pass, proceed with skill execution ---- return skill.execute(args);-}-```diff --git a/docs/prompts/monetization/06-user-purchased-skills-api.md b/docs/prompts/monetization/06-user-purchased-skills-api.mddeleted file mode 100644index e189266be..000000000--- a/docs/prompts/monetization/06-user-purchased-skills-api.md+++ /dev/null@@ -1,59 +0,0 @@-----status: not-started-----# Prompt 6: User's Purchased Skills API and UI--## Objective-Create a dedicated API endpoint and a new UI section in the user's dashboard to display all the skills they have purchased across all agents.--## Explanation-Users need a central place to see all their purchased assets. This enhances the user experience by providing a clear record of their purchases and reinforces the value of their account on the platform.--## Instructions-1. **Create Backend API Endpoint:**- * Create a new endpoint, e.g., `GET /api/users/me/skills`.- * This endpoint should be authenticated and retrieve the current user's ID.- * Query the `skill_purchases` table for all `completed` purchases made by the user.- * Join the data with the `agents` and `skills` tables to return rich information for each purchase, such as the skill name, the agent it belongs to, the agent's avatar, and the purchase date.--2. **Create Dashboard Page:**- * Create a new HTML file for the dashboard page, e.g., `dashboard.html`, if it doesn't exist.- * Add a new section or tab to this page titled "My Purchased Skills".--3. **Fetch and Render Skills:**- * In the corresponding JavaScript file for the dashboard (`dashboard.js`), fetch the data from the `/api/users/me/skills` endpoint when the page loads.- * Render the purchased skills in a user-friendly list or grid format.- * Each item should display the skill name, the agent's name, and an avatar, and link back to that agent's detail page in the marketplace.--## Code Example (Frontend - `dashboard.js`)-```javascript-async function renderPurchasedSkills() {- const container = document.getElementById('purchased-skills-container');- container.innerHTML = 'Loading...';-- try {- const skills = await get('/api/users/me/skills'); // Your API helper-- if (!skills || skills.length === 0) {- container.innerHTML = '<p>You have not purchased any skills yet.</p>';- return;- }-- container.innerHTML = skills.map(skill => `- <div class="purchased-skill-card">- <img src="${skill.agent_avatar_url}" alt="${skill.agent_name}" class="purchased-skill-avatar" />- <div class="purchased-skill-info">- <h4 class="purchased-skill-name">${escapeHtml(skill.name)}</h4>- <p class="purchased-skill-agent">for <a href="/marketplace/agent/${skill.agent_id}">${escapeHtml(skill.agent_name)}</a></p>- </div>- <div class="purchased-skill-date">- Purchased on ${new Date(skill.purchase_date).toLocaleDateString()}- </div>- </div>- `).join('');- } catch (error) {- container.innerHTML = '<p>Failed to load your purchased skills.</p>';- console.error(error);- }-}-```diff --git a/docs/prompts/monetization/07-skill-pricing-dashboard.md b/docs/prompts/monetization/07-skill-pricing-dashboard.mddeleted file mode 100644index 2938579ce..000000000--- a/docs/prompts/monetization/07-skill-pricing-dashboard.md+++ /dev/null@@ -1,59 +0,0 @@-----status: not-started-----# Prompt 7: Skill Pricing Dashboard for Creators--## Objective-Create a dashboard for agent creators to view their skills and set or update prices for them.--## Explanation-To create a functioning marketplace, we need to empower creators. This prompt focuses on building the user interface where a creator can manage the monetization of their agent's skills.--## Instructions-1. **Create Creator Dashboard Page:**- * In the user dashboard area, create a new section or page accessible to users who have created agents, titled "My Agents & Skills".- * This page should list all the agents created by the current user.--2. **Agent Skill Management UI:**- * For each agent listed, provide a "Manage Skills" button.- * Clicking this button should lead to a view that lists all skills associated with that agent.- * Next to each skill, display its current price (or "Not for sale") and an "Edit Price" button.--3. **Price Editing Modal:**- * Clicking "Edit Price" should open a modal.- * The modal should contain a form with an input for the price and a dropdown for the currency (initially, only USDC on Solana).- * The form should handle both setting a price for a new skill and updating an existing one.- * Include a "Remove from sale" button to make a skill free again.--4. **Backend API for Pricing:**- * Create a secure backend endpoint, e.g., `POST /api/agents/:agentId/skills/price`.- * The endpoint must verify that the authenticated user is the owner of the agent.- * It should accept `skillName`, `amount`, and `currencyMint` as input.- * This endpoint will `INSERT` or `UPDATE` a record in the `agent_skill_prices` table. If the amount is set to 0 or null, the existing price record should be deleted.--## Code Example (Frontend - Price Edit Modal)-```html-<div id="price-edit-modal" class="modal">- <div class="modal-content">- <span class="close-button">×</span>- <h3>Set Price for <span id="modal-skill-name"></span></h3>- <form id="price-form">- <input type="hidden" id="modal-agent-id">- <div class="form-group">- <label for="price-amount">Price</label>- <input type="number" id="price-amount" step="0.01" min="0" required>- </div>- <div class="form-group">- <label for="price-currency">Currency</label>- <select id="price-currency" disabled>- <option value="EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyB7uVv">USDC (Solana)</option>- </select>- </div>- <div class="form-actions">- <button type="submit" class="btn-primary">Save Price</button>- <button type="button" id="remove-price-btn" class="btn-danger">Remove from Sale</button>- </div>- </form>- </div>-</div>-```